|
@ -23,7 +23,8 @@ void SelectionList::draw() { |
|
|
|
|
|
|
|
|
/* draw menu items */ |
|
|
/* draw menu items */ |
|
|
u8g2.setFont(u8g2_font_9x18B_tr); |
|
|
u8g2.setFont(u8g2_font_9x18B_tr); |
|
|
for (int i=0; i<visible; i++) { |
|
|
int length = std::min(visible, (uint8_t)string_list.size()); |
|
|
|
|
|
for (int i=0; i<length; i++) { |
|
|
u8g2.drawUTF8(item_x_offset,header_height+2+(i+1)*item_height,string_list[top_item+i].c_str()); |
|
|
u8g2.drawUTF8(item_x_offset,header_height+2+(i+1)*item_height,string_list[top_item+i].c_str()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -33,7 +34,8 @@ void SelectionList::draw() { |
|
|
|
|
|
|
|
|
void SelectionList::next() { |
|
|
void SelectionList::next() { |
|
|
if (current_pos < string_list.size()-1) current_pos++; |
|
|
if (current_pos < string_list.size()-1) current_pos++; |
|
|
if (current_pos > top_item+visible-1) top_item++; |
|
|
int length = std::min(visible, (uint8_t)string_list.size()); |
|
|
|
|
|
if (current_pos > top_item+length-1) top_item++; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void SelectionList::previous() { |
|
|
void SelectionList::previous() { |
|
@ -42,6 +44,44 @@ void SelectionList::previous() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
uint8_t SelectionList::select() { |
|
|
uint8_t SelectionList::select() { |
|
|
|
|
|
switch (current_pos) { |
|
|
|
|
|
// case 0:
|
|
|
|
|
|
// break;
|
|
|
|
|
|
default: |
|
|
|
|
|
Serial.println("unknown entry selected"); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
menuChange = eMainScreen; |
|
|
|
|
|
return current_pos; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
MainMenu::MainMenu() { |
|
|
|
|
|
string_list = { |
|
|
|
|
|
"MP3", |
|
|
|
|
|
"test", |
|
|
|
|
|
"test2", |
|
|
|
|
|
"test3"}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
uint8_t MainMenu::select() { |
|
|
|
|
|
String topic = "esp32-node/stat/" + iot.hostname + "/blabla"; |
|
|
|
|
|
switch (current_pos) { |
|
|
|
|
|
case 0: |
|
|
|
|
|
if (mp3.playing) { |
|
|
|
|
|
mp3.stop(); |
|
|
|
|
|
} else { |
|
|
|
|
|
mp3.start(); |
|
|
|
|
|
} |
|
|
|
|
|
break; |
|
|
|
|
|
case 1: |
|
|
|
|
|
iot.mqtt.publish(topic.c_str(), 1, true, "test" ); |
|
|
|
|
|
case 2: |
|
|
|
|
|
iot.mqtt.publish(topic.c_str(), 1, true, "foo" ); |
|
|
|
|
|
default: |
|
|
|
|
|
Serial.println("unknown entry selected"); |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
menuChange = eMainScreen; |
|
|
return current_pos; |
|
|
return current_pos; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -135,15 +175,7 @@ void MainScreen::draw() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
uint8_t MainScreen::select() { |
|
|
uint8_t MainScreen::select() { |
|
|
if(millis() - lastButtonPress >= 1000) { |
|
|
menuChange = eMainMenu; |
|
|
Serial.println("Button pressed"); |
|
|
|
|
|
lastButtonPress = millis(); |
|
|
|
|
|
if (mp3.playing) { |
|
|
|
|
|
mp3.stop(); |
|
|
|
|
|
} else { |
|
|
|
|
|
mp3.start(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void MainScreen::next() { |
|
|
void MainScreen::next() { |
|
|