UI dokonceno
This commit is contained in:
parent
d2687e3c2c
commit
d54f37258d
File diff suppressed because it is too large
Load diff
|
@ -14,12 +14,19 @@ int brightnessValue = 1;
|
||||||
ButtonColors noDraw = {NODRAW, NODRAW, NODRAW};
|
ButtonColors noDraw = {NODRAW, NODRAW, NODRAW};
|
||||||
enum screenMode {DARK, LIGHT};
|
enum screenMode {DARK, LIGHT};
|
||||||
screenMode COLOR_MODE = DARK;
|
screenMode COLOR_MODE = DARK;
|
||||||
|
enum dataMode {ATTENTION, MEDITATION, QUALITY, RAW, STOP};
|
||||||
|
dataMode DATA_MODE = STOP;
|
||||||
|
|
||||||
Button screenModeButton(0, 190, 50, 50, false, "", noDraw);
|
Button screenModeButton(0, 190, 50, 50, false, "", noDraw);
|
||||||
Button brightnessButton(55, 190, 50, 50, false, "", noDraw);
|
Button brightnessButton(55, 190, 50, 50, false, "", noDraw);
|
||||||
Button restartButton(200, 191, 45, 50, false, "", noDraw);
|
Button restartButton(200, 191, 45, 50, false, "", noDraw);
|
||||||
Button powerOffButton(260, 186, 55, 55, false, "", noDraw);
|
Button powerOffButton(260, 186, 55, 55, false, "", noDraw);
|
||||||
|
|
||||||
|
Button attentionButton(0, 2, 48, 48, false, "", noDraw);
|
||||||
|
Button meditationButton(90, 2, 48, 48, false, "", noDraw);
|
||||||
|
Button qualityButton(180, 2, 48, 48, false, "", noDraw);
|
||||||
|
Button rawButton(270, 2, 48, 48, false, "", noDraw);
|
||||||
|
|
||||||
uint16_t COLORS[2] = {WHITE, BLACK};
|
uint16_t COLORS[2] = {WHITE, BLACK};
|
||||||
|
|
||||||
///SETUP
|
///SETUP
|
||||||
|
@ -34,6 +41,12 @@ void setup(){
|
||||||
brightnessButton.addHandler(brightnessHandler, E_TOUCH);
|
brightnessButton.addHandler(brightnessHandler, E_TOUCH);
|
||||||
restartButton.addHandler(restartHandler, E_TOUCH);
|
restartButton.addHandler(restartHandler, E_TOUCH);
|
||||||
powerOffButton.addHandler(powerOffHandler, E_TOUCH);
|
powerOffButton.addHandler(powerOffHandler, E_TOUCH);
|
||||||
|
|
||||||
|
attentionButton.addHandler(attentionHandler, E_TOUCH);
|
||||||
|
meditationButton.addHandler(meditationHandler, E_TOUCH);
|
||||||
|
qualityButton.addHandler(qualityHandler, E_TOUCH);
|
||||||
|
rawButton.addHandler(rawHandler, E_TOUCH);
|
||||||
|
|
||||||
drawGui(COLOR_MODE);
|
drawGui(COLOR_MODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,17 +56,11 @@ void drawGui(screenMode COLOR_MODE) {
|
||||||
M5.Lcd.fillScreen((COLORS[COLOR_MODE] - 1) % 2);
|
M5.Lcd.fillScreen((COLORS[COLOR_MODE] - 1) % 2);
|
||||||
M5.Lcd.setTextColor(COLORS[COLOR_MODE]);
|
M5.Lcd.setTextColor(COLORS[COLOR_MODE]);
|
||||||
|
|
||||||
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]);
|
M5.Lcd.drawLine(0, 60, 320, 60, COLORS[COLOR_MODE]);
|
||||||
|
|
||||||
// BODY
|
// BODY
|
||||||
M5.Lcd.drawString("Attention", 20, 80, 4);
|
//M5.Lcd.drawString("Attention", 20, 80, 4);
|
||||||
M5.Lcd.drawString("Meditation", 160, 80, 4);
|
//M5.Lcd.drawString("Meditation", 160, 80, 4);
|
||||||
|
|
||||||
// BOTTOM
|
// BOTTOM
|
||||||
M5.Lcd.drawLine(0, 180, 320, 180, COLORS[COLOR_MODE]);
|
M5.Lcd.drawLine(0, 180, 320, 180, COLORS[COLOR_MODE]);
|
||||||
|
@ -63,11 +70,21 @@ void drawGui(screenMode COLOR_MODE) {
|
||||||
M5.lcd.drawBitmap(55, 191, 50, 50, (uint16_t *) brightness_white);
|
M5.lcd.drawBitmap(55, 191, 50, 50, (uint16_t *) brightness_white);
|
||||||
M5.lcd.drawBitmap(200, 191, 45, 50, (uint16_t *) restart_white);
|
M5.lcd.drawBitmap(200, 191, 45, 50, (uint16_t *) restart_white);
|
||||||
M5.lcd.drawBitmap(260, 186, 55, 55, (uint16_t *) power_off_white);
|
M5.lcd.drawBitmap(260, 186, 55, 55, (uint16_t *) power_off_white);
|
||||||
|
|
||||||
|
M5.lcd.drawBitmap(0, 2, 48, 48, (uint16_t *) attention_white);
|
||||||
|
M5.lcd.drawBitmap(90, 2, 48, 48, (uint16_t *) meditation_white);
|
||||||
|
M5.lcd.drawBitmap(180, 2, 48, 48, (uint16_t *) quality_white);
|
||||||
|
M5.lcd.drawBitmap(270, 2, 48, 48, (uint16_t *) raw_white);
|
||||||
} else {
|
} else {
|
||||||
M5.lcd.drawBitmap(0, 191, 50, 50, (uint16_t *) modeSwitchLight);
|
M5.lcd.drawBitmap(0, 191, 50, 50, (uint16_t *) modeSwitchLight);
|
||||||
M5.lcd.drawBitmap(55, 191, 50, 50, (uint16_t *) brightness);
|
M5.lcd.drawBitmap(55, 191, 50, 50, (uint16_t *) brightness);
|
||||||
M5.lcd.drawBitmap(200, 191, 45, 50, (uint16_t *) restart);
|
M5.lcd.drawBitmap(200, 191, 45, 50, (uint16_t *) restart);
|
||||||
M5.lcd.drawBitmap(260, 186, 55, 55, (uint16_t *) power_off);
|
M5.lcd.drawBitmap(260, 186, 55, 55, (uint16_t *) power_off);
|
||||||
|
|
||||||
|
M5.lcd.drawBitmap(0, 2, 48, 48, (uint16_t *) attention);
|
||||||
|
M5.lcd.drawBitmap(90, 2, 48, 48, (uint16_t *) meditation);
|
||||||
|
M5.lcd.drawBitmap(180, 2, 48, 48, (uint16_t *) quality);
|
||||||
|
M5.lcd.drawBitmap(270, 2, 48, 48, (uint16_t *) raw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,4 +137,99 @@ void powerOffHandler(Event& e) {
|
||||||
delay(500);
|
delay(500);
|
||||||
M5.Axp.SetLDOEnable(3, false);
|
M5.Axp.SetLDOEnable(3, false);
|
||||||
M5.shutdown();
|
M5.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void attentionHandler(Event& e) {
|
||||||
|
M5.Axp.SetLDOEnable(3, true);
|
||||||
|
delay(50);
|
||||||
|
M5.Axp.SetLDOEnable(3, false);
|
||||||
|
if(DATA_MODE == ATTENTION){
|
||||||
|
Serial2.print("0");
|
||||||
|
DATA_MODE = STOP;
|
||||||
|
}else{
|
||||||
|
Serial2.print("0");
|
||||||
|
delay(50);
|
||||||
|
Serial2.print("1");
|
||||||
|
DATA_MODE = ATTENTION;
|
||||||
|
}
|
||||||
|
drawGui(COLOR_MODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void meditationHandler(Event& e) {
|
||||||
|
M5.Axp.SetLDOEnable(3, true);
|
||||||
|
delay(50);
|
||||||
|
M5.Axp.SetLDOEnable(3, false);
|
||||||
|
if(DATA_MODE == MEDITATION){
|
||||||
|
Serial2.print("0");
|
||||||
|
DATA_MODE = STOP;
|
||||||
|
}else{
|
||||||
|
Serial2.print("0");
|
||||||
|
delay(50);
|
||||||
|
Serial2.print("2");
|
||||||
|
DATA_MODE = MEDITATION;
|
||||||
|
}
|
||||||
|
drawGui(COLOR_MODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void qualityHandler(Event& e) {
|
||||||
|
M5.Axp.SetLDOEnable(3, true);
|
||||||
|
delay(50);
|
||||||
|
M5.Axp.SetLDOEnable(3, false);
|
||||||
|
if(DATA_MODE == QUALITY){
|
||||||
|
Serial2.print("0");
|
||||||
|
DATA_MODE = STOP;
|
||||||
|
}else{
|
||||||
|
Serial2.print("0");
|
||||||
|
delay(50);
|
||||||
|
Serial2.print("3");
|
||||||
|
DATA_MODE = QUALITY;
|
||||||
|
}
|
||||||
|
drawGui(COLOR_MODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rawHandler(Event& e) {
|
||||||
|
M5.Axp.SetLDOEnable(3, true);
|
||||||
|
delay(50);
|
||||||
|
M5.Axp.SetLDOEnable(3, false);
|
||||||
|
if(DATA_MODE == RAW){
|
||||||
|
Serial2.print("0");
|
||||||
|
DATA_MODE = STOP;
|
||||||
|
}else{
|
||||||
|
Serial2.print("0");
|
||||||
|
delay(50);
|
||||||
|
Serial2.print("4");
|
||||||
|
DATA_MODE = RAW;
|
||||||
|
}
|
||||||
|
drawGui(COLOR_MODE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void writeScreenData(dataMode DATA_MODE, screenMode COLOR_MODE, String data){
|
||||||
|
M5.Lcd.setTextColor(COLORS[COLOR_MODE]);
|
||||||
|
if(DATA_MODE == ATTENTION){
|
||||||
|
M5.Lcd.drawString("ATTENTION", 90, 80, 4);
|
||||||
|
}else if(DATA_MODE ==MEDITATION){
|
||||||
|
M5.Lcd.drawString("MEDITATION", 84, 80, 4);
|
||||||
|
}else if(DATA_MODE == QUALITY){
|
||||||
|
M5.Lcd.drawString("SIGNAL QUALITY", 60, 80, 4);
|
||||||
|
}else if(DATA_MODE == RAW){
|
||||||
|
M5.Lcd.drawString("RAW", 132, 80, 4);
|
||||||
|
}else{
|
||||||
|
M5.Lcd.drawString("...", 148, 100, 4);
|
||||||
|
}
|
||||||
|
if(DATA_MODE != STOP){
|
||||||
|
M5.Lcd.drawString(data, 132, 128, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String stringReceived = "";
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
M5.update();
|
||||||
|
if(Serial2.available()){
|
||||||
|
stringReceived = Serial2.read();
|
||||||
|
writeScreenData(DATA_MODE, COLOR_MODE, stringReceived);
|
||||||
|
stringReceived = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue