Skip to content

Expander MCP23017 #155

@forsakenrecordingstudios

Description

Hello,

I am trying to add 3 of these Mux to my sketch, how do i get this Mux added to your library? Also im told i can run all 3 on 1 interrupt, do you have any insight on this?

#include <Encoder.h> // Include the Encoder library.

// Include the library
#include <Control_Surface.h>

// Instantiate a MIDI Interface to use
USBMIDI_Interface midi;



// Buttons
const int LF = A0;
const int MF = A1;
const int HF = A2;
const int LC = A3;
const int LMF = A4;
const int HMF = A5;
const int HC = A6;
const int ShowCurve = A7;
const int HighQuality = A8;
const int GainAuto = A9;



// LEDS
//const int LFLED = 44;
//const int MFLED = 45;
//const int HFLED = 46;
//const int LCLED = 47;
//const int LMFLED = 48;
//const int HMFLED = 49;
//const int HCLED = 50;
//const int ShowCurveLED = 51;
//const int HighQualityLED = 52;
//const int GainAutoLED = 53;

const pin_t ledPins[] =  {44, 45, 46, 47, 48, 49, 50, 51, 52, 53};

//Encoders
int LFQa = 2;
int LFQb = 3;

// Instantiate an analog multiplexer
MCP23017 mux1 = {
  2,       // Digital input pin
  {A10, A11} // Address pins 
};

CCRotaryEncoder knob1 [] = {
  {mux.pin(6), {MIDI_CC::Channel_Volume, CHANNEL_7}},
  {mux.pin(7), {MIDI_CC::Channel_Volume, CHANNEL_8}},

};


 //Freq Activation
CCButtonLatched buttons[] =  {
  {LF, MCU::SOLO_1},
  {MF, MCU::SOLO_2},
  {HF, MCU::SOLO_3},
  {LC, MCU::SOLO_4},
  {LMF, MCU::SOLO_5},
  {HMF, MCU::SOLO_6},
  {HC, MCU::SOLO_7},
  {ShowCurve, MCU::SOLO_8},
  {HighQuality, MCU::MUTE_1},
  {GainAuto, MCU::MUTE_2},
  
};

//CCRotaryEncoder enc1 = {
  //{LFQa, LFQb}, 
  //MIDI_CC::Pan,
  //1,
    
//};

//CCPotentiometer potentiometer = {
 // A10, {MIDI_CC::Channel_Volume, CHANNEL_1}

};








  






// Initialize the Control Surface
void setup() {

   // Add the mapping function to the potentiometer
    //potentiometer.map(mappingFunction);
 
 //LED Controll
 for (pin_t ledPin : ledPins)
    pinMode(ledPin, OUTPUT);

 //Encoders
    pinMode(LFQa, INPUT_PULLUP);
    pinMode(LFQb, INPUT_PULLUP);

  
  
  // Use the Mackie Control protocol for sending relative MIDI CC messages.
  RelativeCCSender::setMode (TWOS_COMPLEMENT);
  Serial.begin(115200);
  Control_Surface.begin(); // Initialize Control Surface
  //Control_Surface.setMIDIInputCallbacks(channelMsgCallback, nullptr, nullptr); //MIDI Read
}

//Led Controll
template <class T, size_t N> 
constexpr size_t len(const T (&)[N]) { return N; }



// Update the Control Surface
void loop() {

// Update the control surface
  Control_Surface.loop();

 //LED Controll
 static_assert(len(ledPins) == len(buttons), "Use the same number of LEDs as the number of buttons!");
  for (size_t i = 0; i < len(buttons); ++i)
    digitalWrite(ledPins[i], buttons[i].getState());
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions