Add rename sheet menu.
This commit is contained in:
parent
e6fbac08ed
commit
b67ec501b4
@ -6326,11 +6326,56 @@ static void lcd_select_sheet_menu()
|
||||
MENU_END();
|
||||
}
|
||||
|
||||
static void lcd_rename_sheet_menu()
|
||||
{
|
||||
struct MenuData
|
||||
{
|
||||
bool initialized;
|
||||
uint8_t selected;
|
||||
char name[sizeof(Sheet::name)];
|
||||
};
|
||||
static_assert(sizeof(menu_data)>= sizeof(MenuData),"MenuData doesn't fit into menu_data");
|
||||
MenuData* menuData = (MenuData*)&(menu_data[0]);
|
||||
|
||||
if (!menuData->initialized)
|
||||
{
|
||||
eeprom_read_block(menuData->name, EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].name, sizeof(Sheet::name));
|
||||
lcd_encoder = menuData->name[0];
|
||||
menuData->initialized = true;
|
||||
}
|
||||
if (lcd_encoder < '\x20') lcd_encoder = '\x20';
|
||||
if (lcd_encoder > '\x7F') lcd_encoder = '\x7F';
|
||||
|
||||
menuData->name[menuData->selected] = lcd_encoder;
|
||||
lcd_set_cursor(0,0);
|
||||
for (uint_least8_t i = 0; i < sizeof(Sheet::name); ++i)
|
||||
{
|
||||
lcd_putc(menuData->name[i]);
|
||||
}
|
||||
lcd_set_cursor(menuData->selected, 1);
|
||||
lcd_putc('^');
|
||||
if (lcd_clicked())
|
||||
{
|
||||
if ((menuData->selected + 1u) < sizeof(Sheet::name))
|
||||
{
|
||||
lcd_encoder = menuData->name[++(menuData->selected)];
|
||||
}
|
||||
else
|
||||
{
|
||||
eeprom_update_block(menuData->name,
|
||||
EEPROM_Sheets_base->s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].name,
|
||||
sizeof(Sheet::name));
|
||||
menu_back();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void lcd_sheet_menu()
|
||||
{
|
||||
MENU_BEGIN();
|
||||
MENU_ITEM_BACK_P(_T(MSG_MAIN));
|
||||
MENU_ITEM_SUBMENU_P(_i("Select"), lcd_select_sheet_menu);
|
||||
MENU_ITEM_SUBMENU_P(_i("Select"), lcd_select_sheet_menu); //// c=18
|
||||
MENU_ITEM_SUBMENU_P(_i("Rename"), lcd_rename_sheet_menu); //// c=18
|
||||
|
||||
MENU_END();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user