Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Skool_wkshp_lib2015 by
menu.cpp
00001 #include "menu.h" 00002 #include "serial_lcd.h" 00003 #include "keypad.h" 00004 #include "rtc.h" 00005 00006 const char MAINMENU_ITEMS[4][16] = {{0x90,'b','r','e','s','z','t',0x82,'s',' ','k','i','/','b','e',' '},//"Ébresztés ki/be "}, 00007 {'I','d',0x00,' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '},//"Ido "}, 00008 {0x90,'b','r','e','s','z','t',0x82,'s',' ',' ',' ',' ',' ',' ',' '},//"Ébresztés "}, 00009 {'D',0xE0,'t','u','m',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' '}};//"Dátum "}}; 00010 const char MAINMENU_2NDLINE[16] = {' ',' ',' ',' ',' ',' ',' ','b','e',0xE0,'l','l',0xE1,'t',0xE0,'s'};//" beállítás"}; 00011 const char ALARM_A_TEXT[16] = {' ',' ',' ',0xFB,0x90,'b','r','e','s','z','t',0x00,0xFC,' ',' ',' '};//"<Ébreszto>" 00012 volatile FSM_State Main_FSM_States = IN_LOOP; 00013 volatile int MainMenu_CurrentItem = 0; 00014 extern int AlarmA_Enabled; 00015 00016 void ShowMainMenuItem(int ItemNr) { 00017 write_ser_lcd(0x01, false); // Clear display 00018 wait_us(1100); 00019 write_ser_lcd(0x06, false); 00020 wait_us(30); 00021 write_ser_lcd(0x80, false); // Move address to beginning of first line 00022 wait_us(30); 00023 write_ser_text(MAINMENU_ITEMS[ItemNr], 16); 00024 if (ItemNr > 0) { 00025 write_ser_lcd(0xC0, false); // Move address to beginning of second line 00026 write_ser_text(MAINMENU_2NDLINE, 16); 00027 } 00028 } 00029 00030 void ExecuteMainMenuItem(int ItemNr) { 00031 switch (ItemNr) { 00032 case 0: Main_FSM_States = ALARM_ON_OFF; 00033 if (AlarmA_Enabled == 0) { 00034 AlarmA_Enable(); 00035 } else AlarmA_Disable(); 00036 break; 00037 case 1: Main_FSM_States = SET_TIME; 00038 SetRTCTime(); 00039 break; 00040 case 2: Main_FSM_States = SET_ALARM; 00041 SetRTCAlarm(); 00042 break; 00043 case 3: Main_FSM_States = SET_DATE; 00044 SetRTCDate(); 00045 break; 00046 default: break; 00047 } 00048 } 00049 00050 void MainMenu_Handler(void) { 00051 int keypress; 00052 int isexit = 0; 00053 00054 MainMenu_CurrentItem = 0; 00055 ShowMainMenuItem(MainMenu_CurrentItem); 00056 while ((isexit == 0) & (Main_FSM_States != FINISH)) { 00057 keypress = Poll_keypad_vert(); 00058 switch (keypress) { 00059 case 0x01: MainMenu_CurrentItem = ((MainMenu_CurrentItem == 0) ? 0 : MainMenu_CurrentItem - 1); 00060 ShowMainMenuItem(MainMenu_CurrentItem); 00061 break; 00062 case 0x05: ExecuteMainMenuItem(MainMenu_CurrentItem); 00063 isexit = 1; 00064 break; 00065 case 0x09: MainMenu_CurrentItem = ((MainMenu_CurrentItem == MAINMENU_ITEMMAX - 1) ? MAINMENU_ITEMMAX - 1 : MainMenu_CurrentItem + 1); 00066 ShowMainMenuItem(MainMenu_CurrentItem); 00067 break; 00068 case 0x0E: isexit = 1; 00069 Main_FSM_States = FINISH; 00070 break; 00071 default: break; 00072 } 00073 } 00074 write_ser_lcd(0x01, false); 00075 wait_us(1100); 00076 write_ser_lcd(0x06, false); 00077 wait_us(30); 00078 write_ser_lcd(0x0C, false); 00079 wait_us(30); 00080 ShowTime(); 00081 ShowDate(); 00082 HAL_GPIO_WritePin(GPIOC, cols[0] | cols[1] | cols[2], GPIO_PIN_SET); 00083 HAL_GPIO_WritePin(GPIOC, cols[2], GPIO_PIN_RESET); 00084 Main_FSM_States = IN_LOOP; 00085 } 00086 00087 void ShowAlarmText(void) { 00088 write_ser_lcd(0x01, false); // Clear display 00089 wait_us(1100); 00090 write_ser_lcd(0x06, false); // Entry mode set 00091 wait_us(30); 00092 write_ser_lcd(0x80, false); // set DDRAM addr to 0x00, beginning of 1st line 00093 wait_us(30); 00094 write_ser_text(ALARM_A_TEXT, 16); 00095 }
Generated on Thu Jul 14 2022 17:13:24 by
1.7.2
