Giter VIP home page Giter VIP logo

Comments (6)

tttapa avatar tttapa commented on May 24, 2024
CCPotentiometer pots[] = {
  {A0, MIDI_CC::General_Purpose_Controller_1},
  {A1, MIDI_CC::General_Purpose_Controller_2},
  {A2, MIDI_CC::General_Purpose_Controller_3},
  {A3, MIDI_CC::General_Purpose_Controller_4},
};

analog_t invertPot(analog_t val) {
  return 1023 - val;
}

void setup () {
  for (auto &pot : pots)
    pot.map(invertPot);
  Control_Surface.begin();
}

I can't test it right now, and I've been changing some things about the mapping function lately, so please let me know if it works.

from control-surface.

W-Floyd avatar W-Floyd commented on May 24, 2024

That works perfectly! Thanks so much.

from control-surface.

tttapa avatar tttapa commented on May 24, 2024

Glad to hear!

from control-surface.

benwadub avatar benwadub commented on May 24, 2024

hi, I got the same problem, I made my pcb and inverted the way they should work, and on top and vcc on bottom :-(
could you tell me how I could invert it

Bankable::CCPotentiometer fader [] = { //ici on déclare les faders avec comme vu plus haut le numéro de CC et le canal
  {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(8), {7, CHANNEL_1}},
  {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(9), {7, CHANNEL_2}},
  {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(10), {7, CHANNEL_3}},
  {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(11), {7, CHANNEL_4}},
  {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(12), {7, CHANNEL_5}},
  {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(13), {7, CHANNEL_6}},
  {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(14), {7, CHANNEL_7}},
  {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(15), {7, CHANNEL_8}}, 
};

from control-surface.

tttapa avatar tttapa commented on May 24, 2024

The changes to the mapping functions are mentioned in the readme:

  • 31edaa6
    The mapping function is now applied before applying hysteresis.
    This means that the input and output values of the function should be
    16 - ANALOG_FILTER_SHIFT_FACTOR bits wide instead of 7. By default this is
    14 bits.
    The signature of the mapping function is now analog_t f(analog_t raw),
    where the return value and raw are both numbers in [0, 16383].

For general mapping, see this example: CCPotentiometer-Map.ino
Inverting the potentiometer is supported directly using the CCPotentiometer::invert function:

CCPotentiometer potentiometer = {
    A0, {MIDI_CC::Channel_Volume, CHANNEL_1}
};
 
void setup() {
    potentiometer.invert();
    Control_Surface.begin();
}

Of if you have an array of potentiometers, use a for loop:

Bankable::CCPotentiometer faders[] = {
  {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(8), {7, CHANNEL_1}},
  {{bank3, BankType::CHANGE_CHANNEL}, mux3.pin(9), {7, CHANNEL_2}},
  // ...
};

void setup() {
    for (auto &fader : faders)
        fader.invert();
    Control_Surface.begin();
}

from control-surface.

benwadub avatar benwadub commented on May 24, 2024

Thanks a lot! With the for loop will it only invert my faders and let the other pots in the normal functionement?

from control-surface.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.