|
|
@ -62,6 +62,8 @@ MainMenu::MainMenu() { |
|
|
|
"Radio Stations", |
|
|
|
"Toggle Light", |
|
|
|
"Test2", |
|
|
|
"AlarmClock", |
|
|
|
"SLEEP", |
|
|
|
"\xAB Return"}; |
|
|
|
if (mp3.playing) { |
|
|
|
string_list[0] = "STOP"; |
|
|
@ -89,6 +91,14 @@ uint8_t MainMenu::select() { |
|
|
|
iot.mqtt.publish(topic.c_str(), 0, false, "test2" ); |
|
|
|
break; |
|
|
|
case 4: |
|
|
|
menuChange = eAlarmClockScreen; |
|
|
|
return current_pos; |
|
|
|
break; |
|
|
|
case 5: |
|
|
|
menuChange = eSuspendScreen; |
|
|
|
return current_pos; |
|
|
|
break; |
|
|
|
case 6: |
|
|
|
menuChange = eMainScreen; |
|
|
|
break; |
|
|
|
default: |
|
|
@ -269,3 +279,58 @@ void MainScreen::previous() { |
|
|
|
led.setBrightness((255*volume)/100); |
|
|
|
Serial.printf("volume: %d\n", volume); |
|
|
|
} |
|
|
|
|
|
|
|
void AlarmClockScreen::draw() { |
|
|
|
uint8_t header_height = 12; |
|
|
|
u8g2.clearBuffer(); |
|
|
|
|
|
|
|
/* draw Title */ |
|
|
|
u8g2.setFont(u8g2_font_guildenstern_nbp_tr); |
|
|
|
u8g2.drawUTF8(2,header_height-2,title); |
|
|
|
u8g2.drawLine(0,header_height,u8g2.getDisplayWidth(),header_height); |
|
|
|
|
|
|
|
char alarmStr[9]; |
|
|
|
sprintf(alarmStr, "%02d:%02d", hours, minutes); |
|
|
|
u8g2.setFont(u8g2_font_inb19_mf); |
|
|
|
u8g2.drawStr(20, 55, alarmStr); |
|
|
|
|
|
|
|
u8g2.sendBuffer(); // transfer internal memory to the display
|
|
|
|
} |
|
|
|
|
|
|
|
void AlarmClockScreen::next() { |
|
|
|
if (millis() - lastRotary <= 40) minutes+=20; |
|
|
|
else if (millis() - lastRotary <= 80) minutes+=5; |
|
|
|
else minutes++; |
|
|
|
lastRotary = millis(); |
|
|
|
|
|
|
|
if (minutes >= 60) { |
|
|
|
hours += minutes/60; |
|
|
|
hours %= 24; |
|
|
|
minutes %= 60; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void AlarmClockScreen::previous() { |
|
|
|
if (millis() - lastRotary <= 40) minutes-=20; |
|
|
|
else if (millis() - lastRotary <= 80) minutes-=5; |
|
|
|
else minutes--; |
|
|
|
lastRotary = millis(); |
|
|
|
|
|
|
|
if (minutes < 0) { |
|
|
|
hours += minutes/60 -1; |
|
|
|
if (hours < 0) hours = hours%24 +24; |
|
|
|
minutes = minutes % 60 + 60 ; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
uint8_t AlarmClockScreen::select() { |
|
|
|
setWakeupTime(0); |
|
|
|
menuChange = eMainScreen; |
|
|
|
} |
|
|
|
|
|
|
|
void SuspendScreen::draw() { |
|
|
|
mp3.stop(); |
|
|
|
led.stop(); |
|
|
|
delay(1000); |
|
|
|
suspend(30); |
|
|
|
} |
|
|
|