BANKS WITH MULTIPLE BUTTON FUNCTION #1045
diegogauffin
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi there! I would like to have some banks for some CCButtons , and it would be really usefull that some of the banks were with CCButtons and others banks were CCLatched class. Would it be that posible ?
This is the code i am using:
#include <Control_Surface.h>
USBMIDI_Interface midi;
Bank<5> bank(3);
// │ └───── number of tracks per bank
// └───────────── number of banks
// Instantiate a Bank selector to control which one of the four Banks is active.
IncrementSelectorLEDs<5> selector {
bank, // Bank to manage
1,
{2,5,6,7,15} // push button pin
};
Bankable::CCButton<5> b1 = {
{bank, BankType::CHANGE_ADDRESS}, // bank configuration
0, // digital pin
{102, CHANNEL_11}, // address
};
Bankable::CCButton<5> b2 = {
{bank, BankType::CHANGE_ADDRESS}, // bank configuration
19, // digital pin
{103, CHANNEL_11}, // address
};
Bankable::CCButton<5> b3 = {
{bank, BankType::CHANGE_ADDRESS}, // bank configuration
20, // digital pin
{104, CHANNEL_11}, // address
};
Bankable::CCPotentiometer potentiometer1 {
{bank, BankType::ChangeChannel}, // bank configuration
A6, // analog pin PEDAL
{MIDI_CC::Expression_Controller_LSB , Channel_1}, // address
};
Bankable::CCPotentiometer potentiometer2 {
{bank, BankType::ChangeChannel}, // bank configuration
A3, // analog pin
{MIDI_CC::General_Purpose_Controller_1_LSB, Channel_1}, // address
};
// The maximum value that can be measured (usually 16383 = 2¹⁴-1)
constexpr analog_t maxRawValue = CCPotentiometer::getMaxRawValue();
// The filtered value read when potentiometer is at the 0% position
constexpr analog_t minimumValue = 11200;
// The filtered value read when potentiometer is at the 100% position
constexpr analog_t maximumValue = 14700;
// A mapping function to eliminate the dead zones of the potentiometer:
// Some potentiometers don't output a perfect zero signal when you move them to
// the zero position, they will still output a value of 1 or 2, and the same
// goes for the maximum position.
analog_t mappingFunction(analog_t raw) {
// make sure that the analog value is between the minimum and maximum
raw = constrain(raw, minimumValue, maximumValue);
// map the value from [minimumValue, maximumValue] to [0, maxRawValue]
return map(raw, minimumValue, maximumValue, 0, maxRawValue);
}
void setup() {
Control_Surface.begin();
potentiometer1.map(mappingFunction);
potentiometer2.map(mappingFunction);
}
void loop() {
Control_Surface.loop();
}
Beta Was this translation helpful? Give feedback.
All reactions