#include "Graphics.h"
#define BUTTON1 23
#define BUTTON2 5
#define BUTTON3 18
#define BUTTON4 19
int selector = 0;
void setButtonDebounce() {
pinMode(BUTTON1, INPUT_PULLUP);
pinMode(BUTTON2, INPUT_PULLUP);
pinMode(BUTTON3, INPUT_PULLUP);
pinMode(BUTTON4, INPUT_PULLUP);
}
void readButtons() {
// No need to loop through buttons, we'll read them individually
}
void setup() {
Serial.begin(115200);
setButtonDebounce();
displayInit();
delay(10);
welcomeMessage();
delay(2000);
}
void loop() {
readButtons();
// Check each button individually
if (digitalRead(BUTTON1) == LOW && selector <= 4) {
selector++;
} else if (digitalRead(BUTTON2) == LOW && selector > 0) {
selector--;
} else {
selector = 0;
}
menuBar(selector);
}
void levelSix() {
display.clearDisplay();
static const unsigned char PROGMEM image_paint_0_bits[] = { 0x80, 0xc0, 0xe0, 0xf0, 0xe0, 0xc0, 0x80 };
static const unsigned char PROGMEM image_Button_bits[] = { 0x1f, 0xff, 0x00, 0x60, 0x00, 0x80, 0xc0, 0x00, 0x40, 0xc0, 0x00, 0x40, 0xc0, 0x00, 0x40, 0xc0, 0x00, 0x40, 0xc0, 0x00, 0x40, 0xc0, 0x00, 0x40, 0xc0, 0x00, 0x40, 0xc0, 0x00, 0x40, 0xc0, 0x00, 0x40, 0xc0, 0x00, 0x40, 0xc0, 0x00, 0x40, 0xc0, 0x00, 0x40, 0xc0, 0x00, 0x40, 0xe0, 0x00, 0xc0, 0x7f, 0xff, 0x80, 0x3f, 0xff, 0x00 };
static const unsigned char PROGMEM image_paint_1_bits[] = { 0x80, 0x40, 0x20, 0x40, 0x80 };
static const unsigned char PROGMEM image_paint_2_bits[] = { 0xff, 0xff, 0x80, 0xff, 0xff, 0x80, 0xc0, 0x01, 0x80, 0xc0, 0x01, 0x80, 0xc0, 0x01, 0x80, 0xc0, 0x01, 0x80, 0xc0, 0x01, 0x80, 0xc0, 0x01, 0x80, 0xc0, 0x01, 0x80, 0xc0, 0x01, 0x80, 0xc0, 0x01, 0x80, 0xc0, 0x01, 0x80, 0xc0, 0x01, 0x80, 0xff, 0xff, 0x80, 0xff, 0xff, 0x80 };
static const unsigned char PROGMEM image_paint_3_bits[] = { 0x20, 0x40, 0x80, 0x40, 0x20 };
display.setTextColor(1);
display.setTextSize(1);
display.setTextWrap(false);
display.setCursor(7, 13);
display.print("BRK > 2");
display.setCursor(7, 3);
display.print("EIN > 2");
display.setCursor(7, 23);
display.print("OUT > 2");
display.setCursor(7, 33);
display.print("EIN > 2");
display.setCursor(75, 31);
display.print("6");
display.setCursor(111, 10);
display.print("<");
display.setCursor(111, 46);
display.print(">");
display.drawRect(107, 8, 13, 11, 1);
display.drawRect(107, 44, 13, 11, 1);
display.drawRect(107, 26, 13, 11, 1);
display.drawBitmap(112, 28, image_paint_0_bits, 4, 7, 1);
display.setCursor(64, 15);
display.print("LEVEL");
display.drawBitmap(68, 26, image_Button_bits, 18, 18, 1);
display.drawBitmap(112, 47, image_paint_1_bits, 3, 5, 1);
display.drawBitmap(105, 24, image_paint_2_bits, 17, 15, 1);
display.setCursor(7, 54);
display.print("OUT > 2");
display.setCursor(7, 44);
display.print("BRK > 2");
display.drawBitmap(113, 11, image_paint_3_bits, 3, 5, 1);
display.display();
}
void levelOne() {
display.clearDisplay();
static const unsigned char PROGMEM image_paint_0_bits[] = { 0x80, 0xc0, 0xe0, 0xf0, 0xe0, 0xc0, 0x80 };
static const unsigned char PROGMEM image_Button_bits[] = { 0x1f, 0xff, 0x00, 0x60, 0x00, 0x80, 0xc0, 0x00, 0x40, 0xc0, 0x00, 0x40, 0xc0, 0x00, 0x40, 0xc0, 0x00, 0x40, 0xc0, 0x00, 0x40, 0xc0, 0x00, 0x40, 0xc0, 0x00, 0x40, 0xc0, 0x00, 0x40, 0xc0, 0x00, 0x40, 0xc0, 0x00, 0x40, 0xc0, 0x00, 0x40, 0xc0, 0x00, 0x40, 0xc0, 0x00, 0x40, 0xe0, 0x00, 0xc0, 0x7f, 0xff, 0x80, 0x3f, 0xff, 0x00 };
static const unsigned char PROGMEM image_paint_1_bits[] = { 0x80, 0x40, 0x20, 0x40, 0x80 };
static const unsigned char PROGMEM image_paint_2_bits[] = { 0xff, 0xff, 0x80, 0xff, 0xff, 0x80, 0xc0, 0x01, 0x80, 0xc0, 0x01, 0x80, 0xc0, 0x01, 0x80, 0xc0, 0x01, 0x80, 0xc0, 0x01, 0x80, 0xc0, 0x01, 0x80, 0xc0, 0x01, 0x80, 0xc0, 0x01, 0x80, 0xc0, 0x01, 0x80, 0xc0, 0x01, 0x80, 0xc0, 0x01, 0x80, 0xff, 0xff, 0x80, 0xff, 0xff, 0x80 };
static const unsigned char PROGMEM image_paint_3_bits[] = { 0x20, 0x40, 0x80, 0x40, 0x20 };
display.setTextColor(1);
display.setTextSize(1);
display.setTextWrap(false);
display.setCursor(6, 24);
display.print("BRK > 2");
display.setCursor(6, 13);
display.print("EIN > 2");
display.setCursor(6, 36);
display.print("OUT > 2");
display.setCursor(6, 48);
display.print("BRK > 2");
display.setCursor(75, 31);
display.print("1");
display.setCursor(111, 10);
display.print("<");
display.setCursor(111, 46);
display.print(">");
display.drawRect(107, 8, 13, 11, 1);
display.drawRect(107, 44, 13, 11, 1);
display.drawRect(107, 26, 13, 11, 1);
display.drawBitmap(112, 28, image_paint_0_bits, 4, 7, 1);
display.setCursor(64, 15);
display.print("LEVEL");
display.drawBitmap(68, 26, image_Button_bits, 18, 18, 1);
display.drawBitmap(112, 47, image_paint_1_bits, 3, 5, 1);
display.drawBitmap(105, 24, image_paint_2_bits, 17, 15, 1);
display.drawBitmap(113, 11, image_paint_3_bits, 3, 5, 1);
display.display();
}
void addNewExcercise() {
display.clearDisplay();
static const unsigned char PROGMEM image_paint_0_bits[] = { 0xfc };
static const unsigned char PROGMEM image_paint_1_bits[] = { 0x10, 0x10, 0x10, 0xfe, 0x10, 0x10, 0x10 };
static const unsigned char PROGMEM image_paint_2_bits[] = { 0xff, 0xff, 0x80, 0xff, 0xff, 0x80, 0xff, 0xff, 0x80, 0xff, 0xff, 0x80, 0xff, 0xff, 0x80, 0xff, 0xff, 0x80, 0xf0, 0x0f, 0x80, 0xf0, 0x0f, 0x80, 0xf0, 0x0f, 0x80, 0xff, 0xff, 0x80, 0xff, 0xff, 0x80, 0xff, 0xff, 0x80, 0xff, 0xff, 0x80, 0xff, 0xff, 0x80 };
static const unsigned char PROGMEM image_paint_3_bits[] = { 0xff, 0xff, 0xe0, 0xff, 0xff, 0xe0, 0xf8, 0x03, 0xe0, 0xf8, 0x03, 0xe0, 0xf8, 0x03, 0xe0, 0xf8, 0x03, 0xe0, 0xf8, 0x03, 0xe0, 0xf8, 0x03, 0xe0, 0xf8, 0x03, 0xe0, 0xf8, 0x03, 0xe0, 0xf8, 0x03, 0xe0, 0xff, 0xff, 0xe0, 0xff, 0xff, 0xe0, 0xff, 0xff, 0xe0 };
display.setTextColor(1);
display.setTextSize(1);
display.setTextWrap(false);
display.setCursor(30, 10);
display.print("Inhale");
display.setCursor(75, 10);
display.print("10");
display.setCursor(31, 27);
display.print("Break");
display.setCursor(75, 27);
display.print("60");
display.setCursor(31, 44);
display.print("Exhale");
display.setCursor(75, 44);
display.print("24");
display.setCursor(89, 10);
display.print("S");
display.setCursor(89, 27);
display.print("S");
display.setCursor(89, 44);
display.print("S");
display.drawRect(28, 6, 72, 15, 1);
display.drawRect(28, 22, 72, 17, 1);
display.drawRect(28, 40, 72, 16, 1);
display.drawRect(103, 22, 21, 16, 1);
display.drawBitmap(12, 30, image_paint_0_bits, 6, 1, 1);
display.drawBitmap(12, 48, image_paint_0_bits, 6, 1, 1);
display.drawBitmap(110, 26, image_paint_1_bits, 7, 7, 1);
display.drawRect(103, 40, 21, 16, 1);
display.drawBitmap(110, 44, image_paint_1_bits, 7, 7, 1);
display.drawLine(70, 6, 70, 20, 1);
display.drawLine(70, 22, 70, 37, 1);
display.drawLine(70, 40, 70, 55, 1);
display.drawRect(103, 6, 21, 15, 1);
display.drawBitmap(110, 9, image_paint_1_bits, 7, 7, 1);
display.drawBitmap(12, 13, image_paint_0_bits, 6, 1, 1);
display.drawRect(7, 6, 17, 15, 1);
display.drawRect(7, 23, 17, 15, 1);
display.drawRect(7, 40, 17, 16, 1);
display.drawBitmap(7, 41, image_paint_2_bits, 17, 14, 1);
display.drawBitmap(104, 41, image_paint_3_bits, 19, 14, 1);
display.display();
}