//------------------------- 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;
}
}