fix smaller bugs in Menu code and implement first test of main menu with one functional sunbmenu for the safety parameters
This commit is contained in:
		@@ -30,7 +30,7 @@ void menu_handle(struct lcd_menu *menu, int16_t rotary_encoder_delta, enum butto
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	menu->inputs.push_button = push_button;
 | 
			
		||||
	menu->inputs.rotary_encoder_delta = rotary_encoder_delta;
 | 
			
		||||
	menu->inputs.rotary_encoder_delta += rotary_encoder_delta;
 | 
			
		||||
 | 
			
		||||
	if (menu->active_entry == NULL)
 | 
			
		||||
		menu->active_entry = menu->root_entry;
 | 
			
		||||
@@ -121,7 +121,7 @@ void menu_list_display(struct menu_list *list, uint32_t top_row, uint32_t bottom
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Calculate list parameters */
 | 
			
		||||
	row_count = top_row - bottom_row + 1;
 | 
			
		||||
	row_count = bottom_row - top_row + 1;
 | 
			
		||||
	mid_row = (top_row + bottom_row) / 2;
 | 
			
		||||
	count_above_mid = mid_row - top_row;
 | 
			
		||||
	count_below_mid = bottom_row - mid_row;
 | 
			
		||||
@@ -133,11 +133,11 @@ void menu_list_display(struct menu_list *list, uint32_t top_row, uint32_t bottom
 | 
			
		||||
		start_index = list->currently_selected - count_above_mid;
 | 
			
		||||
	} else if (list->currently_selected < count_above_mid) {
 | 
			
		||||
		start_index = 0;
 | 
			
		||||
	} else if ((list->entry_count - list->currently_selected - 1) < count_below_mid) {
 | 
			
		||||
		if (list->entry_count < row_count) {
 | 
			
		||||
	} else if ((list->entry_count - list->currently_selected - 1) <= count_below_mid) {
 | 
			
		||||
		if (list->entry_count < row_count)
 | 
			
		||||
			start_index = 0;
 | 
			
		||||
		}
 | 
			
		||||
		start_index = list->entry_count - row_count;
 | 
			
		||||
		else
 | 
			
		||||
			start_index = list->entry_count - row_count;
 | 
			
		||||
	} else {
 | 
			
		||||
		start_index = 0;
 | 
			
		||||
	}
 | 
			
		||||
@@ -182,3 +182,22 @@ void menu_list_scroll_up(struct menu_list *list)
 | 
			
		||||
	if (list->currently_selected > 0)
 | 
			
		||||
		list->currently_selected--;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void menu_ack_rotary_delta(struct lcd_menu *menu)
 | 
			
		||||
{
 | 
			
		||||
	if (!menu)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	menu->inputs.rotary_encoder_delta = 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void menu_display_clear(struct lcd_menu *menu)
 | 
			
		||||
{
 | 
			
		||||
	uint8_t i;
 | 
			
		||||
 | 
			
		||||
	if (!menu || !menu->update_display)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	for (i = 0; i < 4; i++)
 | 
			
		||||
		menu->update_display(i, "");
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user