Added GUI.
92
GUI/GUI/GUI.ino
Normal file
|
@ -0,0 +1,92 @@
|
|||
#include <M5Core2.h>
|
||||
#include "icons.cpp" // icons
|
||||
|
||||
ButtonColors noDraw = {NODRAW, NODRAW, NODRAW};
|
||||
Button screenModeButton(0, 190, 50, 50, false, "", noDraw);
|
||||
Button restartButton(200, 191, 45, 50, false, "", noDraw);
|
||||
Button powerOffButton(260, 186, 55, 55, false, "", noDraw);
|
||||
|
||||
enum screenMode {DARK, LIGHT};
|
||||
screenMode COLOR_MODE = LIGHT;
|
||||
|
||||
uint16_t COLORS[2] = {WHITE, BLACK};
|
||||
|
||||
void setup() {
|
||||
M5.begin();
|
||||
|
||||
screenModeButton.addHandler(screenModeHandler, E_TOUCH);
|
||||
restartButton.addHandler(restartHandler, E_TOUCH);
|
||||
powerOffButton.addHandler(powerOffHandler, E_TOUCH);
|
||||
drawGui(COLOR_MODE);
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
M5.update();
|
||||
}
|
||||
|
||||
void drawGui(screenMode COLOR_MODE) {
|
||||
M5.Lcd.clear();
|
||||
M5.Lcd.fillScreen((COLORS[COLOR_MODE] - 1) % 2);
|
||||
M5.Lcd.setTextColor(COLORS[COLOR_MODE]);
|
||||
|
||||
// HEADER
|
||||
if (COLOR_MODE == DARK) {
|
||||
M5.lcd.drawBitmap(5, 5, 50, 50, (uint16_t *) signal_white_2_3);
|
||||
} else {
|
||||
M5.lcd.drawBitmap(5, 5, 50, 50, (uint16_t *) signal_1_3);
|
||||
}
|
||||
|
||||
M5.Lcd.drawString("100", 60, 20, 4);
|
||||
|
||||
if (COLOR_MODE == DARK) {
|
||||
M5.lcd.drawBitmap(280, 5, 30, 50, (uint16_t *) bluetooth_dark);
|
||||
} else {
|
||||
M5.lcd.drawBitmap(280, 5, 30, 50, (uint16_t *) bluetooth_light);
|
||||
}
|
||||
|
||||
M5.Lcd.drawLine(0, 60, 320, 60, COLORS[COLOR_MODE]);
|
||||
|
||||
// BODY
|
||||
M5.Lcd.drawString("Attention", 20, 80, 4);
|
||||
M5.Lcd.drawString("Meditation", 160, 80, 4);
|
||||
|
||||
M5.Lcd.drawString("20", 60, 130, 4);
|
||||
M5.Lcd.drawString("0", 220, 130, 4);
|
||||
|
||||
// BOTTOM
|
||||
M5.Lcd.drawLine(0, 180, 320, 180, COLORS[COLOR_MODE]);
|
||||
screenModeButton.draw();
|
||||
if (COLOR_MODE == DARK) {
|
||||
M5.lcd.drawBitmap(0, 191, 50, 50, (uint16_t *) modeSwitchDark);
|
||||
M5.lcd.drawBitmap(200, 191, 45, 50, (uint16_t *) restart_white);
|
||||
M5.lcd.drawBitmap(260, 186, 55, 55, (uint16_t *) power_off_white);
|
||||
} else {
|
||||
M5.lcd.drawBitmap(0, 191, 50, 50, (uint16_t *) modeSwitchLight);
|
||||
M5.lcd.drawBitmap(200, 191, 45, 50, (uint16_t *) restart);
|
||||
M5.lcd.drawBitmap(260, 186, 55, 55, (uint16_t *) power_off);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void screenModeHandler(Event& e) {
|
||||
if (COLOR_MODE == DARK) {
|
||||
COLOR_MODE = LIGHT;
|
||||
} else {
|
||||
COLOR_MODE = DARK;
|
||||
}
|
||||
|
||||
drawGui(COLOR_MODE);
|
||||
}
|
||||
|
||||
void restartHandler(Event& e) {
|
||||
M5.shutdown(1);
|
||||
}
|
||||
|
||||
void powerOffHandler(Event& e) {
|
||||
M5.shutdown();
|
||||
}
|
2614
GUI/GUI/icons.cpp
Normal file
BIN
GUI/img/bluetooth_dark.png
Normal file
After Width: | Height: | Size: 471 B |
BIN
GUI/img/bluetooth_light.png
Normal file
After Width: | Height: | Size: 471 B |
BIN
GUI/img/icons8-day-and-night-50.png
Normal file
After Width: | Height: | Size: 815 B |
BIN
GUI/img/image.png
Normal file
After Width: | Height: | Size: 2 KiB |
BIN
GUI/img/power_off.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
GUI/img/power_off_white.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
GUI/img/restart.png
Normal file
After Width: | Height: | Size: 612 B |
BIN
GUI/img/restart_white.png
Normal file
After Width: | Height: | Size: 612 B |
BIN
GUI/img/signal_0_3.png
Normal file
After Width: | Height: | Size: 372 B |
BIN
GUI/img/signal_1_3.png
Normal file
After Width: | Height: | Size: 345 B |
BIN
GUI/img/signal_2_3.png
Normal file
After Width: | Height: | Size: 234 B |
BIN
GUI/img/signal_3_3.png
Normal file
After Width: | Height: | Size: 225 B |
BIN
GUI/img/signal_white_0_3.png
Normal file
After Width: | Height: | Size: 372 B |
BIN
GUI/img/signal_white_1_3.png
Normal file
After Width: | Height: | Size: 378 B |
BIN
GUI/img/signal_white_2_3.png
Normal file
After Width: | Height: | Size: 234 B |
BIN
GUI/img/signal_white_3_3.png
Normal file
After Width: | Height: | Size: 225 B |