|
@ -280,6 +280,12 @@ void MainScreen::previous() { |
|
|
Serial.printf("volume: %d\n", volume); |
|
|
Serial.printf("volume: %d\n", volume); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
AlarmClockScreen::AlarmClockScreen() { |
|
|
|
|
|
time_t now; |
|
|
|
|
|
time(&now); |
|
|
|
|
|
localtime_r(&now, &alarmTime); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void AlarmClockScreen::draw() { |
|
|
void AlarmClockScreen::draw() { |
|
|
uint8_t header_height = 12; |
|
|
uint8_t header_height = 12; |
|
|
u8g2.clearBuffer(); |
|
|
u8g2.clearBuffer(); |
|
@ -290,7 +296,7 @@ void AlarmClockScreen::draw() { |
|
|
u8g2.drawLine(0,header_height,u8g2.getDisplayWidth(),header_height); |
|
|
u8g2.drawLine(0,header_height,u8g2.getDisplayWidth(),header_height); |
|
|
|
|
|
|
|
|
char alarmStr[9]; |
|
|
char alarmStr[9]; |
|
|
sprintf(alarmStr, "%02d:%02d", hours, minutes); |
|
|
strftime(alarmStr, sizeof(alarmStr), "%H:%M", &alarmTime); |
|
|
u8g2.setFont(u8g2_font_inb19_mf); |
|
|
u8g2.setFont(u8g2_font_inb19_mf); |
|
|
u8g2.drawStr(20, 55, alarmStr); |
|
|
u8g2.drawStr(20, 55, alarmStr); |
|
|
|
|
|
|
|
@ -298,33 +304,33 @@ void AlarmClockScreen::draw() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void AlarmClockScreen::next() { |
|
|
void AlarmClockScreen::next() { |
|
|
if (millis() - lastRotary <= 40) minutes+=20; |
|
|
if (millis() - lastRotary <= 40) alarmTime.tm_min+=20; |
|
|
else if (millis() - lastRotary <= 80) minutes+=5; |
|
|
else if (millis() - lastRotary <= 80) alarmTime.tm_min+=5; |
|
|
else minutes++; |
|
|
else alarmTime.tm_min++; |
|
|
lastRotary = millis(); |
|
|
lastRotary = millis(); |
|
|
|
|
|
|
|
|
if (minutes >= 60) { |
|
|
if (alarmTime.tm_min >= 60) { |
|
|
hours += minutes/60; |
|
|
alarmTime.tm_hour += alarmTime.tm_min/60; |
|
|
hours %= 24; |
|
|
alarmTime.tm_hour %= 24; |
|
|
minutes %= 60; |
|
|
alarmTime.tm_min %= 60; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void AlarmClockScreen::previous() { |
|
|
void AlarmClockScreen::previous() { |
|
|
if (millis() - lastRotary <= 40) minutes-=20; |
|
|
if (millis() - lastRotary <= 40) alarmTime.tm_min-=20; |
|
|
else if (millis() - lastRotary <= 80) minutes-=5; |
|
|
else if (millis() - lastRotary <= 80) alarmTime.tm_min-=5; |
|
|
else minutes--; |
|
|
else alarmTime.tm_min--; |
|
|
lastRotary = millis(); |
|
|
lastRotary = millis(); |
|
|
|
|
|
|
|
|
if (minutes < 0) { |
|
|
if (alarmTime.tm_min < 0) { |
|
|
hours += minutes/60 -1; |
|
|
alarmTime.tm_hour += alarmTime.tm_min/60 -1; |
|
|
if (hours < 0) hours = hours%24 +24; |
|
|
if (alarmTime.tm_hour < 0) alarmTime.tm_hour = alarmTime.tm_hour%24 +24; |
|
|
minutes = minutes % 60 + 60 ; |
|
|
alarmTime.tm_min = alarmTime.tm_min % 60 + 60 ; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
uint8_t AlarmClockScreen::select() { |
|
|
uint8_t AlarmClockScreen::select() { |
|
|
setWakeupTime(0); |
|
|
setAlarmTime(alarmTime); |
|
|
menuChange = eMainScreen; |
|
|
menuChange = eMainScreen; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -332,5 +338,6 @@ void SuspendScreen::draw() { |
|
|
mp3.stop(); |
|
|
mp3.stop(); |
|
|
led.stop(); |
|
|
led.stop(); |
|
|
delay(1000); |
|
|
delay(1000); |
|
|
|
|
|
u8g2.setPowerSave(1); |
|
|
suspend(30); |
|
|
suspend(30); |
|
|
} |
|
|
} |
|
|