Midi foot controller with Banks (code)

Status
Not open for further replies.

intergalatico

Well-known member
Hello,

I am building a midi foot controller with 12x buttons (2x for Bank UP/Down), 10x TFT Color Graphic Displays, 1x 2 Digits Display (to display with Bank I am).

The TFT's should display the function of the foot switch.

It will be like this:

6 7 8 9 10
1 2 3 4 5

Where the 1-5 Buttons are to send PC (Program Change) and the 6-10 CC messages. So that when we are on the Program 1 (Button 1), the display 1 will give me the name of the program and the displays form 6 – 10 will display the functions according to this program. On the Program 2 the 6 – 10 will have other functions and so other display configuration. And so on through programs 3 to 5.

With the Bank buttons I will be able to have more then only 5 programs.

I would be very thankful if someone could give me a code example where I can begin. I did find some examples around forums but none with the Bank function that I want.

The whole Graphic library and display things I am taking care. I am using Teensy 3.2

Thank you very much!

Cheers
 
I thought bank select was CC 0 MSB and CC 32 LSB ...

Without knowing more ... I would suggest that you would use CC 0 and CC 32 to set the bank, and then send the relevant program change straight after. Bank select doesn't take effect until a PC is received...BUT it all depends on the midi implementation you are trying to 'drive' ...

I use CC 0 and CC 32 (i.e. I have code for setting them) but I use them to send continuous 10 bit volume data !! and I don't use Program Change.
 
Thank you Adrian,

but I think I didn't explained myself too clear. I want to change the banks INSIDE my controller in a way that I will have more functions on the same Button.

I was trying to use the "bounce" example from the "bounce" library, and I add a second button to go up and down. My idea was that the "counter" will be my Bank number. So for each "counter" number I will have a "if" function where I can put all the functions from the all 10 foot switches.

The problem right now is that I want to have 10 Banks. I don't know how to reset the counter after reaching the 10th bank. I am sure is a easy tweaking but I can't find in anyplace. Someone?

Thank you!

Here my code:

Code:
#include <Bounce.h>

const int buttonPinDown = 5;
const int buttonPinUP = 8;
Bounce pushbuttonDown = Bounce(buttonPinDown, 10);  // 10 ms debounce
Bounce pushbuttonUp = Bounce(buttonPinUP, 10);  // 10 ms debounce

void setup() {
  pinMode(buttonPinDown, INPUT_PULLUP);
  pinMode(buttonPinUP, INPUT_PULLUP);
  Serial.begin(57600);
  Serial.println("Pushbutton Bounce library test:");
}

byte previousState = HIGH;         // what state was the button last time
unsigned int count = 0;            // how many times has it changed to low
unsigned long countAt = 0;         // when count changed
unsigned int countPrinted = 0;     // last count printed

void loop() {
  
  if (pushbuttonDown.update()) {
    if (pushbuttonDown.fallingEdge()) {
      count = count + 1;
      countAt = millis();
    }
  } else {
    if (count != countPrinted) {
      unsigned long nowMillis = millis();
      if (nowMillis - countAt > 100) {
        Serial.print("count: ");
        Serial.println(count);
        countPrinted = count;
      }
    }
  }

 if (pushbuttonUp.update()) {
    if (pushbuttonUp.fallingEdge()) {
      count = count - 1;
      countAt = millis();
    }
  } else {
    if (count != countPrinted) {
      unsigned long nowMillis = millis();
      if (nowMillis - countAt > 100) {
        Serial.print("count: ");
        Serial.println(count);
        countPrinted = count;
      }
    }
  }
 
}
 
Ah sorry I get you now ... I actually do something similar for controller modes (I have one set of buttons and 3 different choosable 'mappings' as to what they do) .

So .... create a function to poll two buttons and do your count ... I would suggest that you put in some thing like this at the end...

Code:
if (count > 10) {count = 10;}
if (count < 1) {count = 1;}

or reset it to whatever.

Then I would have a function that reads in all of the buttons data, and then process it using the switch / case syntax...

Code:
//read in the buttons data, then process it ..

switch (count)
{
case 1:
//code using buttons data...
break;

case 2:
//code
break;

case 3:
//code
break;
}
 
Last edited:
I've found that good quality switches do not need 10ms debouncing 2 ms should be enough. I use 1.2ms (1.5 is the 'average', I read somewhere)

Anyway, try this, maybe? I haven't compiled it.

Code:
#include <Bounce.h>

const int buttonPinDown = 5;
const int buttonPinUP = 8;
Bounce pushbuttonDown = Bounce(buttonPinDown, 5);  // 5 ms debounce
Bounce pushbuttonUp = Bounce(buttonPinUP, 5);  // 5 ms debounce
bool buttonUp = false;
bool buttonDown= false;
void bankSelect();
void buttonProcess();

void setup() {
  pinMode(buttonPinDown, INPUT_PULLUP);
  pinMode(buttonPinUP, INPUT_PULLUP);
  Serial.begin(57600);
  Serial.println("Pushbutton Bounce library test:");
}


unsigned int count = 1;            // bank number


void loop() {
bankSelect();
buttonProcess();
delay(1);
}

void bankSelect(){
 if (pushbuttonDown.update()) {  
    if (pushbuttonDown.fallingEdge()) {count ++; buttonDown = true; if (count > 10) {count = 1;}
   }
if (buttonDown) {Serial.println(String ("bank: ") + count); buttonDown=false;}
 
if (pushbuttonUp.update()) {  
   if (pushbuttonUp.fallingEdge()) { count--; buttonUp=true; if (count < 1) {count = 10;}
    }
  if (buttonUp) {Serial.println(String ("bank: ") + count); buttonUp=false;}  
}

void buttonProcess(){
//read in the buttons data, then process it ..

switch (count)
{
case 1:
true;//code using buttons data...
break;
case 2:
true;//code
break;
case 3:
true;//code
break;
}
}
 
Last edited:
Hey Adrian,

thank you so much that you toke your time to write this for me! I really appreciate!

But, 2 things:
1. The counter on the ascending direction is skipping the number "1" and on the descending direction the number "9".
2. Is possible to make that the counter after the "10" don't still on the "10" but reset to "0"? Like a circle.

Here is what happens on the serial monitor when I start to pull the "pushbuttonUp" 11 times and then "pushbuttonDown" also 11 times:
Code:
bank: 2
bank: 3
bank: 4
bank: 5
bank: 6
bank: 7
bank: 8
bank: 9
bank: 10
bank: 10
bank: 10
bank: 8
bank: 7
bank: 6
bank: 5
bank: 4
bank: 3
bank: 2
bank: 1
bank: 0
bank: 0

Again, thank you!!!
 
Last edited:
I've edited the code (ABOVE) slightly (changed the debounce time, and a bit of a restructure, made it 'circular' ...) Should work!! I will test it at home later ... sorry it didn't work first time ... I suspect it might be a timing issue, so I have added in a slight delay.
 
Last edited:
Thank you! But you didn't posted the code... did you forgot or you want to try at home first?

But thank you anyway, really!

EDIT: Oh, I got it! Sorry! You changed on the code above! Thank you!
 
Last edited:
I am trying, and now I have a cycle movement but the Bank Up button goes just one step forward then wont work anymore. At first wont compile but I put some "}" that was missing one the "void bankSelect()":

Code:
#include <Bounce.h>

const int buttonPinDown = 13;
const int buttonPinUP = 14;
Bounce pushbuttonDown = Bounce(buttonPinDown, 5);  // 5 ms debounce
Bounce pushbuttonUp = Bounce(buttonPinUP, 5);  // 5 ms debounce
bool buttonUp = false;
bool buttonDown= false;
void bankSelect();
void buttonProcess();

void setup() {
  pinMode(buttonPinDown, INPUT_PULLUP);
  pinMode(buttonPinUP, INPUT_PULLUP);
  Serial.begin(57600);
  Serial.println("Pushbutton Bounce library test:");
}


unsigned int count = 1;            // bank number


void loop() {
bankSelect();
buttonProcess();
delay(1);
}

void bankSelect(){
 if (pushbuttonDown.update()) {  
 if (pushbuttonDown.fallingEdge()) {count ++; buttonDown=true; if (count > 10) {count = 1;} }
   }
 if (buttonDown) {Serial.println(String ("bank: ") + count); buttonDown=false;}
 
 if (pushbuttonUp.update()) {  
 if (pushbuttonUp.fallingEdge()) { count--; buttonUp=true; if (count < 1) {count = 10;} }
    }
 if (buttonUp) {Serial.println(String ("bank: ") + count); buttonUp=false;}  
}

void buttonProcess(){
//read in the buttons data, then process it ..

switch (count)
{
case 1:
true;//code using buttons data...
break;
case 2:
true;//code
break;
case 3:
true;//code
break;
}
}

EDIT: Sorry!!! I changed the pins, from 13, 14 to 15, 16 and now is working just like supposed to do! Thanks a lot! I will develop further with the other functions and will post here! Thanks for your help!!!
 
Last edited:
Cool ...I just noticed the missing brackets!! I don't have a compiler on me, so sorry about that .... good luck!
 
So, I am trying to get further and noticed that the program is more complex that I though! To print one thing on the display that is selected means that the other ones have to be cleaned and so goes on. It would be more easy to have the multiple functions grouped in one. I know that that is possible but I don't know how to do it.

Something like this: When I print a name on the screen I have to do this:
Code:
  tft1.setCursor(30, 70);
  tft1.setRotation(45);
  tft1.fillScreen(patch01Background);
  tft1.setTextColor(BLACK);
  tft1.setTextSize(4);
  tft1.println(patch01);

Would be way easier if I just had to type: writePatch01() (or something like this).

How I can do this?

Thank you!

Here is how my whole code is developing:
Code:
//------------------------- Libraries -------------------------//

#include <Bounce.h>              // Buttons
#include <SPI.h>
#include <Wire.h>                // Digole library need this to compile
//#include <DigoleSerial.h>        // Digole library
#include <Adafruit_GFX_AS.h>     // Core graphics library
#include <Adafruit_ILI9341_AS.h> // Hardware-specific library

//-------------------------- Pins ------------------------------//
// ILI9341_AS
#define sclk 13      // 
#define mosi 11      // 

// Display #1
#define tft1_cs 3 
#define tft1_dc 4
#define tft1_rst 9

// Display #2
#define tft2_cs 5
#define tft2_dc 6
#define tft2_rst 10

Adafruit_ILI9341_AS tft1 = Adafruit_ILI9341_AS(tft1_cs, tft1_dc, tft1_rst); // Data=11, Clock=13
Adafruit_ILI9341_AS tft2 = Adafruit_ILI9341_AS(tft2_cs, tft2_dc, tft2_rst);

// Digole
#define _Digole_Serial_SPI_ 
#include <DigoleSerial.h>        // Digole library
#if defined(_Digole_Serial_SPI_)
// Display #3
DigoleSerialDisp mydisp1(7,14,15);  //data, clock, SS
// Display #4
DigoleSerialDisp mydisp2(7,14,2);
#endif
#define SC_W 176  //screen width in pixels
#define SC_H 220  //screen Hight in pixels

// Buttons
const int buttonPinBankdown = 16;
const int buttonPinBankup = 17;
const int buttonPinPreset1 = 18;
const int buttonPinPreset2 = 19;
const int buttonPinStomp1 = 20;
const int buttonPinStomp2 = 21;

//unsigned int count = 1;   // bank number

//----------------------------- Bounce -------------------------------------//

Bounce pushbuttonBankdown = Bounce(buttonPinBankdown, 5);  // 5 ms debounce
Bounce pushbuttonBankup = Bounce(buttonPinBankup, 5);  // 5 ms debounce
Bounce pushbuttonPreset1 = Bounce(buttonPinPreset1, 5);  // 5 ms debounce
Bounce pushbuttonPreset2 = Bounce(buttonPinPreset2, 5);  // 5 ms debounce
Bounce pushbuttonStomp1 = Bounce(buttonPinStomp1, 5);  // 5 ms debounce
Bounce pushbuttonStomp2 = Bounce(buttonPinStomp2, 5);  // 5 ms debounce

bool buttonUp = false;
bool buttonDown= false;
void bankSelect();
void bankButtonProcess();
void buttonSelectProcess();

//---------------------------- Colors ------------------------------------//

#define BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0  
#define WHITE   0xFFFF

#define black           0x00
#define blue            0x03
#define red             0xE0
#define green           0x1C
#define yellow          0x1F
#define white           0xFF
#define brown           0x32
//-------------------------------- Program Text -----------------------//

// Bank #1
#define patch01             "Program01"
#define patch01Background   YELLOW
 
#define patch02             "Program02"
#define patch02Background   GREEN

#define stomp01             "Overdrive"
#define stomp01Background   blue         // no caps

#define stomp02             "   Chorus"
#define stomp02Background   green       // no caps


// Bank #2
#define patch11             "Program11"
#define patch11Background   GREEN
 
#define patch12             "Program12"
#define patch12Background   CYAN

#define stomp11             "UNIVIBE"
#define stomp11Background   yellow        // no caps

#define stomp12             "EPIANO"
#define stomp12Background   blue          // no caps

// ---------------------------- SETUP ----------------------------//

void setup() {
  
  pinMode(buttonPinBankdown, INPUT_PULLUP);
  pinMode(buttonPinBankup, INPUT_PULLUP);
  pinMode(buttonPinPreset1, INPUT_PULLUP);
  pinMode(buttonPinPreset2, INPUT_PULLUP);
  pinMode(buttonPinStomp1, INPUT_PULLUP);
  pinMode(buttonPinStomp2, INPUT_PULLUP);
  
  Serial.begin(57600);
  Serial.println("Pushbutton Bounce library test:");


// unsigned int count = 1;   // bank number

// Displays Begin, Clear and set rotation

  mydisp1.begin();
  mydisp1.clearScreen(); //CLear screen
  mydisp1.setBackLight(50);
  

  mydisp2.begin();
  mydisp2.clearScreen(); //CLear screen
  mydisp2.setBackLight(50);
  
  tft1.init();
  tft1.setRotation(2);
  tft1.fillScreen(ILI9341_BLACK);


  tft2.init();
  tft2.setRotation(2);
  tft2.fillScreen(ILI9341_BLACK);

}

unsigned int count = 1;   // bank number

//-------------------------------- LOOP ------------------------------//

void loop() {
bankSelect();
bankButtonProcess();
buttonSelectProcess();

delay(1);
}


void bankSelect(){
 if (pushbuttonBankdown.update()) {  
 if (pushbuttonBankdown.fallingEdge()) {count ++; buttonDown=true; if (count > 10) {count = 1;} }
   }
 if (buttonDown) {Serial.println(String ("bank: ") + count); buttonDown=false;}
 
 if (pushbuttonBankup.update()) {  
 if (pushbuttonBankup.fallingEdge()) { count--; buttonUp=true; if (count < 1) {count = 10;} }
    }
 if (buttonUp) {Serial.println(String ("bank: ") + count); buttonUp=false;}  
}

void buttonSelectProcess(){
  if (pushbuttonPreset1.update()){
    if (pushbuttonPreset1.read() == HIGH) 
  tft1.fillRect(20, 30, 300, 200, RED);          // Print the "SELECT" status
  tft1.setCursor(30, 70);
  tft1.setTextColor(BLACK);
  tft1.setTextSize(4);
  tft1.println(patch01);


  
  }
  
}

void bankButtonProcess(){
//read in the buttons data, then process it ..

switch (count)
{
case 1: true;

//Display #1
  tft1.setCursor(30, 70);
  tft1.setRotation(45);
  tft1.fillScreen(patch01Background);
  tft1.setTextColor(BLACK);
  tft1.setTextSize(4);
  tft1.println(patch01);
//Display #2
  tft2.setCursor(30, 70);
  tft2.setRotation(45);
  tft2.fillScreen(patch02Background);
  tft2.setTextColor(BLACK);
  tft2.setTextSize(4);
  tft2.println(patch02);

//Display #3
  mydisp1.setColor(000000000);
  mydisp1.setBgColor();

  mydisp1.clearScreen();

  mydisp1.setDrawWindow(0, 0, 176, 220);
  mydisp1.setColor(stomp01Background);
  mydisp1.setBgColor();

  mydisp1.cleanDrawWindow();

  mydisp1.setRotation(45);
  mydisp1.setFont(120);
  mydisp1.setColor(000000000);
  mydisp1.setPrintPos(5,2);
  mydisp1.print(stomp01);

//Display #4
  mydisp2.setColor(000000000);
  mydisp2.setBgColor();

  mydisp2.clearScreen();

  mydisp2.setDrawWindow(0, 0, 176, 220);
  mydisp2.setColor(stomp02Background);
  mydisp2.setBgColor();

  mydisp2.cleanDrawWindow();

  mydisp2.setRotation(45);
  mydisp2.setFont(120);
  mydisp2.setColor(000000000);
  mydisp2.setPrintPos(5,2);
  mydisp2.print(stomp02);


break;
case 2:
true;//code
break;
case 3:
true;//code
break;
}
}
 
Nevermind. I figured out how to make a group of functions.

Now I move to the problem that the program is printing on the display the whole time that the loop is running. How can I make to print just once?

Thank you!
 
First post here and on my phone so I won't be able to write example code. I think you're asking how to only write to an LCD when something changes? If so, you could have an if statement before writing anything to an LCD that checks a flag that gets set when you push a button (and subsequently cleared when writing to an lcd). So button 1 could maybe set a Boolean value to true and the code that writes to lcd 1 will only do so if the Boolean is true (and will then set it to false so it won't repeatedly write after pressing the button once).
 
I think sandalhat is suggesting:

Code:
bool change1 = false; //initialise

//set change1 with some code ....yadayada, and then call the 'write' function:

FUNCTION(change1);


void FUNCTION (bool &change) //pass the flag by reference
{
if (change) {/*lcdwrite()*;/ change = false;} // write lcd and reset flag
}

and you just keep on supplying the change1 as true 1 or false 0, calling the FUNCTION repeatedly
 
Last edited:
Thank you guys! But I am facing difficulties to put this on my code. I understood the concept but I can't put it to work. Could somebody have the kindness to adapt this to my code?

Here is what I tried:

Code:
// before SETUP
bool preset01Active= false;
bool preset02Active= false;
bool stomp01Active= false;
bool stomp02Active= false;

// then on the loop

switch (count)
{
case 1: true;

//Display #1
  if (preset01Active= false){
      printPreset01();
      printPreset02();
      printStomp01();
      printStomp02();
      preset01Active= true;
      preset02Active= false;
  }

And here is the whole code:

Code:
//------------------------- Libraries -------------------------//

#include <Bounce.h>              // Buttons
#include <SPI.h>
#include <Wire.h>                // Digole library need this to compile
//#include <DigoleSerial.h>        // Digole library
#include <Adafruit_GFX_AS.h>     // Core graphics library
#include <Adafruit_ILI9341_AS.h> // Hardware-specific library

//-------------------------- Pins ------------------------------//
// ILI9341_AS
#define sclk 13      // 
#define mosi 11      // 

// Display #1
#define tft1_cs 3 
#define tft1_dc 4
#define tft1_rst 9

// Display #2
#define tft2_cs 5
#define tft2_dc 6
#define tft2_rst 10

Adafruit_ILI9341_AS tft1 = Adafruit_ILI9341_AS(tft1_cs, tft1_dc, tft1_rst); // Data=11, Clock=13
Adafruit_ILI9341_AS tft2 = Adafruit_ILI9341_AS(tft2_cs, tft2_dc, tft2_rst);

// Digole
#define _Digole_Serial_SPI_ 
#include <DigoleSerial.h>        // Digole library
#if defined(_Digole_Serial_SPI_)
// Display #3
DigoleSerialDisp mydisp1(7,14,15);  //data, clock, SS
// Display #4
DigoleSerialDisp mydisp2(7,14,2);
#endif
#define SC_W 176  //screen width in pixels
#define SC_H 220  //screen Hight in pixels

// Buttons
const int buttonPinBankdown = 16;
const int buttonPinBankup = 17;
const int buttonPinPreset1 = 18;
const int buttonPinPreset2 = 19;
const int buttonPinStomp1 = 20;
const int buttonPinStomp2 = 21;

//unsigned int count = 1;   // bank number

//----------------------------- Bounce -------------------------------------//

Bounce pushbuttonBankdown = Bounce(buttonPinBankdown, 2);  // 5 ms debounce
Bounce pushbuttonBankup = Bounce(buttonPinBankup, 2);  // 5 ms debounce
Bounce pushbuttonPreset1 = Bounce(buttonPinPreset1, 2);  // 5 ms debounce
Bounce pushbuttonPreset2 = Bounce(buttonPinPreset2, 2);  // 5 ms debounce
Bounce pushbuttonStomp1 = Bounce(buttonPinStomp1, 2);  // 5 ms debounce
Bounce pushbuttonStomp2 = Bounce(buttonPinStomp2, 2);  // 5 ms debounce

bool buttonUp = false;
bool buttonDown= false;
bool preset01Active= false;
bool preset02Active= false;
bool stomp01Active= false;
bool stomp02Active= false;

//------------------------------------ void --------------------//

void bankSelect();
void bankButtonProcess();
void buttonSelectProcess();

void printPreset01();
void printPreset02();
void printPreset11();
void printPreset12();

void printStomp01();
void PrintStomp02();
void printStomp11();
void printStomp12();


//---------------------------- Colors ------------------------------------//

#define BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0  
#define WHITE   0xFFFF

#define black           0x00
#define blue            0x03
#define red             0xE0
#define green           0x1C
#define yellow          0x1F
#define white           0xFF
#define brown           0x32
//-------------------------------- Program Text -----------------------//

// Bank #1
#define patch01             "Program01"
#define patch01Background   YELLOW
 
#define patch02             "Program02"
#define patch02Background   GREEN

#define stomp01             "Overdrive"
#define stomp01Background   blue         // no caps

#define stomp02             "   Chorus"
#define stomp02Background   green       // no caps


// Bank #2
#define patch11             "Program11"
#define patch11Background   GREEN
 
#define patch12             "Program12"
#define patch12Background   CYAN

#define stomp11             "UNIVIBE"
#define stomp11Background   yellow        // no caps

#define stomp12             "EPIANO"
#define stomp12Background   blue          // no caps

// ---------------------------- SETUP ----------------------------//

void setup() {
  
  pinMode(buttonPinBankdown, INPUT_PULLUP);
  pinMode(buttonPinBankup, INPUT_PULLUP);
  pinMode(buttonPinPreset1, INPUT_PULLUP);
  pinMode(buttonPinPreset2, INPUT_PULLUP);
  pinMode(buttonPinStomp1, INPUT_PULLUP);
  pinMode(buttonPinStomp2, INPUT_PULLUP);
  
  Serial.begin(57600);
  Serial.println("Pushbutton Bounce library test:");


// unsigned int count = 1;   // bank number

// Displays Begin, Clear and set rotation

  mydisp1.begin();
  mydisp1.clearScreen(); //CLear screen
  mydisp1.setBackLight(50);
  

  mydisp2.begin();
  mydisp2.clearScreen(); //CLear screen
  mydisp2.setBackLight(50);
  
  tft1.init();
  tft1.setRotation(2);
  tft1.fillScreen(ILI9341_BLACK);


  tft2.init();
  tft2.setRotation(2);
  tft2.fillScreen(ILI9341_BLACK);

}

unsigned int count = 1;   // bank number

// void

void printPreset01(){
  tft1.setCursor(30, 70);
  tft1.setRotation(45);
  tft1.fillScreen(patch01Background);
  tft1.setTextColor(BLACK);
  tft1.setTextSize(4);
  tft1.println(patch01);  
}

void printPreset02(){ 
  tft2.setCursor(30, 70);
  tft2.setRotation(45);
  tft2.fillScreen(patch02Background);
  tft2.setTextColor(BLACK);
  tft2.setTextSize(4);
  tft2.println(patch02);
}

void printStomp01(){
  mydisp1.setColor(000000000);
  mydisp1.setBgColor();

  mydisp1.clearScreen();

  mydisp1.setDrawWindow(0, 0, 176, 220);
  mydisp1.setColor(stomp01Background);
  mydisp1.setBgColor();

  mydisp1.cleanDrawWindow();

  mydisp1.setRotation(45);
  mydisp1.setFont(120);
  mydisp1.setColor(000000000);
  mydisp1.setPrintPos(5,2);
  mydisp1.print(stomp01);
}

void printStomp02(){
  mydisp2.setColor(000000000);
  mydisp2.setBgColor();

  mydisp2.clearScreen();

  mydisp2.setDrawWindow(0, 0, 176, 220);
  mydisp2.setColor(stomp02Background);
  mydisp2.setBgColor();

  mydisp2.cleanDrawWindow();

  mydisp2.setRotation(45);
  mydisp2.setFont(120);
  mydisp2.setColor(000000000);
  mydisp2.setPrintPos(5,2);
  mydisp2.print(stomp02);
}

void printPreset11(){
  tft1.setCursor(30, 70);
  tft1.setRotation(45);
  tft1.fillScreen(patch11Background);
  tft1.setTextColor(BLACK);
  tft1.setTextSize(4);
  tft1.println(patch11);  
}

void printPreset12(){ 
  tft2.setCursor(30, 70);
  tft2.setRotation(45);
  tft2.fillScreen(patch12Background);
  tft2.setTextColor(BLACK);
  tft2.setTextSize(4);
  tft2.println(patch12);
}

void printStomp11(){
  mydisp1.setColor(000000000);
  mydisp1.setBgColor();

  mydisp1.clearScreen();

  mydisp1.setDrawWindow(0, 0, 176, 220);
  mydisp1.setColor(stomp11Background);
  mydisp1.setBgColor();

  mydisp1.cleanDrawWindow();

  mydisp1.setRotation(45);
  mydisp1.setFont(120);
  mydisp1.setColor(000000000);
  mydisp1.setPrintPos(5,2);
  mydisp1.print(stomp11);
}

void printStomp12(){
  mydisp2.setColor(000000000);
  mydisp2.setBgColor();

  mydisp2.clearScreen();

  mydisp2.setDrawWindow(0, 0, 176, 220);
  mydisp2.setColor(stomp12Background);
  mydisp2.setBgColor();

  mydisp2.cleanDrawWindow();

  mydisp2.setRotation(45);
  mydisp2.setFont(120);
  mydisp2.setColor(000000000);
  mydisp2.setPrintPos(5,2);
  mydisp2.print(stomp12);
}

//-------------------------------- LOOP ------------------------------//

void loop() {
bankSelect();
bankButtonProcess();
buttonSelectProcess();

delay(1);
}


void bankSelect(){
 if (pushbuttonBankdown.update()) {  
 if (pushbuttonBankdown.fallingEdge()) {count ++; buttonDown=true; if (count > 10) {count = 1;} }
   }
 if (buttonDown) {Serial.println(String ("bank: ") + count); buttonDown=false;}
 
 if (pushbuttonBankup.update()) {  
 if (pushbuttonBankup.fallingEdge()) { count--; buttonUp=true; if (count < 1) {count = 10;} }
    }
 if (buttonUp) {Serial.println(String ("bank: ") + count); buttonUp=false;}  
}

void buttonSelectProcess(){

  switch (count){
  case 1: true;
  
  if (pushbuttonPreset1.update()){
    if (pushbuttonPreset1.read() == LOW) 
  tft1.fillRect(20, 30, 300, 200, RED);          // Print the "SELECT" status
  tft1.setCursor(30, 70);
  tft1.setTextColor(BLACK);
  tft1.setTextSize(4);
  tft1.println(patch01);
  }
  break;
  case 2: true;
    if (pushbuttonPreset1.update()){
    if (pushbuttonPreset1.read() == LOW) 
  tft1.fillRect(20, 30, 300, 200, RED);          // Print the "SELECT" status
  tft1.setCursor(30, 70);
  tft1.setTextColor(BLACK);
  tft1.setTextSize(4);
  tft1.println(patch11);
  
}
}
}
void bankButtonProcess(){
//read in the buttons data, then process it ..

switch (count)
{
case 1: true;

//Display #1
  if (preset01Active= false){
      printPreset01();
      printPreset02();
      printStomp01();
      printStomp02();
      preset01Active= true;
      preset02Active= false;
  }

//Display #2
  //if (preset02Active= false) {
   // printPreset02();
    //preset01Active= false;
   // preset02Active= true;
 // }

//Display #3
  printStomp01();

//Display #4
  printStomp02();


break;

case 2:
true;

//Display #1
  printPreset11();

//Display #2
  printPreset12();

//Display #3
  printStomp11();

//Display #4
  printStomp12();
break;

case 3:
true;//code
break;
}
}
 
Status
Not open for further replies.
Back
Top