|
|
@ -4,4 +4,39 @@ SelectionList::SelectionList() {} |
|
|
|
|
|
|
|
SelectionList::SelectionList(const char* title, uint8_t start_pos, const char* string_list) {} |
|
|
|
|
|
|
|
void SelectionList::draw() {} |
|
|
|
void SelectionList::draw() { |
|
|
|
uint8_t item_x_offset = 15; |
|
|
|
uint8_t header_height = 12; |
|
|
|
uint8_t item_height = 12; |
|
|
|
uint8_t num_active_item = current_pos - top_item; |
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
/* draw menu items */ |
|
|
|
u8g2.setFont(u8g2_font_9x18B_tr); |
|
|
|
for (int i=0; i<visible; i++) { |
|
|
|
u8g2.drawUTF8(item_x_offset,header_height+2+(i+1)*item_height,string_list[top_item+i].c_str()); |
|
|
|
} |
|
|
|
|
|
|
|
u8g2.drawFrame(0,header_height+1+num_active_item*item_height,u8g2.getDisplayWidth(),item_height+2 ); |
|
|
|
u8g2.sendBuffer(); // transfer internal memory to the display
|
|
|
|
} |
|
|
|
|
|
|
|
void SelectionList::next() { |
|
|
|
if (current_pos < string_list.size()-1) current_pos++; |
|
|
|
if (current_pos > top_item+visible-1) top_item++; |
|
|
|
} |
|
|
|
|
|
|
|
void SelectionList::previous() { |
|
|
|
if (current_pos > 0 ) current_pos--; |
|
|
|
if (current_pos < top_item) top_item--; |
|
|
|
} |
|
|
|
|
|
|
|
uint8_t SelectionList::select() { |
|
|
|
return current_pos; |
|
|
|
} |
|
|
|