void gotoMenuIdleState() { switch (menu_control(main_table, main_table_max)) { case -2: break; case -1: setMenuCurrentState(MENU_RESET_STATE); set_current_menu(0); gotoMenuResetState(); break; case 0: setMenuCurrentState(MENU_PHASE_STATE); set_current_menu(0); gotoMenuPhaseState(); break; case 1: setMenuCurrentState(MENU_PASSWORD_STATE); // 2012-04-30 Liz: User need to key in password for access set_current_menu(1); user_input_control(4); break; case 2: setMenuCurrentState(MENU_INFO_STATE); set_current_menu(0); gotoMenuInfoState(); break; default: break; } }
void gotoMenuResetState(void) { static unsigned int boardrequest = 12000; int i; char s[17] = ""; // Sends a request to bottom board to get readings. // Any readings received will be processed in mcu.c. if( TickGet()-Timer > (5*TICK_SECOND) ) { //s[0] = ph_4total; // 2014-07-01 Liz removed s[0] = 0; // 2014-07-01 Liz added s[1] = 10; s[2] = 'N'; //2012-09-24: Liz added to distinguish from EEPROM request. // Show on the LCD the reading that is in the local variable // while at the same time request for a new reading from the // bottom board. // 2012-05-10(Eric) - No need to retry here since it is not critical. // More impt to release control back to main loop. MCURequestToBOTTOMBoard(MMT_READING_REQUEST, s, 3, FALSE, FALSE); //MCURequestToBOTTOMBoard(MMT_READING_REQUEST, s, 2, FALSE, TRUE); // 2014-07-01 Liz removed // ph_4total++; // if( ph_4total >= 4) // { // ph_4total = 1; // //Convert3RealEnergyToCharArray(s); // Convert3RealEnergyToCharArray(s, 1, 1); // // LCD_PrintString(s, LCD_ROW1, 0); // } // 20114-07-01 Liz added Convert3RealEnergyToCharArray(s, 1, 1); LCD_PrintString(s, LCD_ROW1, 0); /////////////////////// Timer = TickGet(); } switch (menu_control(reset_table, reset_table_max)) { case -2: break; case 0: setMenuCurrentState(MENU_IDLE_STATE); set_current_menu(0); gotoMenuIdleState(); LCD_PrintStringPGM("",LCD_ROW1); break; default: break; } }
void gotoMenuSettingState(void) { switch (menu_control(sett_table, sett_table_max)) { case -2: break; case -1: setMenuCurrentState(MENU_IDLE_STATE); set_current_menu(1); //user_input_control(4); break; case 0: // 2012-05-02 Liz: CT_Rating input setMenuCurrentState(SUBMENU_SETTINGS_STATE); set_current_menu(0); user_input_control(4); #ifdef APP_USE_BUZZER sound(); #endif break; case 1: // 2012-05-02 Liz: Reset Energy setMenuCurrentState(SUBMENU_SETTINGS_STATE); set_current_menu(1); { char t[10] = {'T'}; MCURequestToBOTTOMBoard(MMT_RESET_ENR_COUNTER, t, 1, TRUE, TRUE); if( t[0] == 'O' && t[1] == 'K' ) LCD_PrintStringPGM("OK", LCD_ROW1); else LCD_PrintStringPGM("Failed", LCD_ROW1); } #ifdef APP_USE_BUZZER sound(); #endif break; case 2: // 2012-06-07 Liz: IP address input setMenuCurrentState(SUBMENU_SETTINGS_STATE); set_current_menu(2); user_input_control(3); #ifdef APP_USE_BUZZER sound(); #endif break; default: break; } }
void gotoMenuMiscState(void) { switch (menu_control(misc_table, misc_table_max)) { case -2: break; case -1: //setMenuCurrentState(MENU_IDLE_STATE); setMenuCurrentState(MENU_PHASE_STATE); set_current_menu(3); gotoMenuPhaseState(); break; case 0: setMenuCurrentState(SUBMENU_MEASUREMENTS_STATE); set_current_menu(0); // Put Voltage function here setCurrentReadingDisplay(FREQUENCY); #ifdef APP_USE_BUZZER sound(); #endif break; case 1: setMenuCurrentState(SUBMENU_MEASUREMENTS_STATE); set_current_menu(1); // Put Voltage function here setCurrentReadingDisplay(TOTALPOWER); #ifdef APP_USE_BUZZER sound(); #endif break; case 2: setMenuCurrentState(SUBMENU_MEASUREMENTS_STATE); set_current_menu(2); // Put Voltage function here setCurrentReadingDisplay(CURRENT_NEUTRAL); #ifdef APP_USE_BUZZER sound(); #endif break; default: break; } }
/*================== State functions ====================*/ void gotoMenuPhaseState(void) { switch (menu_control(phase_table, phase_table_max)) { case -2: break; case -1: setMenuCurrentState(MENU_IDLE_STATE); set_current_menu(0); gotoMenuIdleState(); break; case 0: setMenuCurrentState(MENU_MEASUREMENTS_STATE); set_current_menu(0); setPhase(1); //setPhase('A'); gotoMenuMeasurementState(); break; case 1: setMenuCurrentState(MENU_MEASUREMENTS_STATE); set_current_menu(0); setPhase(2); //setPhase('B'); gotoMenuMeasurementState(); break; case 2: setMenuCurrentState(MENU_MEASUREMENTS_STATE); set_current_menu(0); setPhase(3); //setPhase('C'); gotoMenuMeasurementState(); break; case 3: setMenuCurrentState(MENU_MISC_STATE); set_current_menu(0); setPhase(0); //setPhase('M'); gotoMenuMiscState(); break; default: break; } }
/* Intro screen eventloop */ static int intro_event_loop (void) { Uint8 needupdate, rval, isevent; SDL_Event Event; Sint8 command; Uint32 delay, lasttime; while (1) { if (game_settings.mbg_anim) { needupdate = 1; isevent = SDL_PollEvent (&Event); } else { needupdate = 0; isevent = 1; if (!SDL_WaitEvent (&Event)) { printf ("Error occured while waiting for an event: %s\n", SDL_GetError ()); exit (1); } } if (isevent) switch (Event.type) { case SDL_KEYDOWN: command = -1; if (intr_message.show) { intr_message.show = 0; if (intr_message.setkey) { *intr_message.setkey = Event.key.keysym.sym; intr_message.setkey = NULL; return 0; } needupdate = 1; } else { if (Event.key.keysym.sym == SDLK_F11) screenshot (); else if (Event.key.keysym.sym == SDLK_UP) command = MNU_UP; else if (Event.key.keysym.sym == SDLK_DOWN) command = MNU_DOWN; else if (Event.key.keysym.sym == SDLK_LEFT) command = MNU_LEFT; else if (Event.key.keysym.sym == SDLK_RIGHT) command = MNU_RIGHT; else if (Event.key.keysym.sym == SDLK_RETURN) { if((Event.key.keysym.mod & (KMOD_LALT|KMOD_RALT))) toggle_fullscreen(); else command = MNU_ENTER; } else if (Event.key.keysym.sym == SDLK_ESCAPE) command = MNU_BACK; } if (command >= 0) { if (command != MNU_ENTER && command != MNU_BACK) playwave (WAV_BLIP); else playwave (WAV_BLIP2); rval = menu_control (&intro_menu, command); if (rval == INTRO_RVAL_STARTGAME || rval == INTRO_RVAL_EXIT) return rval; needupdate = 1; } break; case SDL_JOYBUTTONUP: case SDL_JOYBUTTONDOWN: joystick_button (&Event.jbutton); break; case SDL_JOYAXISMOTION: joystick_motion (&Event.jaxis, 0); break; case SDL_QUIT: exit(0); default: break; } if (!(game_settings.mbg_anim && isevent)) { lasttime = SDL_GetTicks (); if (needupdate) draw_intro_screen (); if (game_settings.mbg_anim) { delay = SDL_GetTicks () - lasttime; if (delay >= 60) delay = 0; else delay = 60 - delay; SDL_Delay (delay); } } } /* Never reached */ return 0; }
void gotoMenuInfoState(void) { switch (menu_control(info_table, info_table_max)) { case -2: break; case -1: setMenuCurrentState(MENU_IDLE_STATE); set_current_menu(2); gotoMenuIdleState(); break; case 0: setMenuCurrentState(SUBMENU_INFO_STATE); set_current_menu(0); // Put MAC Address function here LCD_PrintString(strMACAddress, LCD_ROW1, 0); #ifdef APP_USE_BUZZER sound(); #endif break; case 1: setMenuCurrentState(SUBMENU_INFO_STATE); set_current_menu(1); // Put IP Address function here LCD_PrintString(strIPAddress, LCD_ROW1, 0); #ifdef APP_USE_BUZZER sound(); #endif break; case 2: setMenuCurrentState(SUBMENU_INFO_STATE); set_current_menu(2); // if (Credit_Balance[0] != '$') // LCD_PrintStringPGM("NA",LCD_ROW1); // else // Remove due to customer request to change the symbol to 'RM' instead of '$' so that cannot add this check point. by Stephen-16/07/2012 LCD_PrintString(Credit_Balance,LCD_ROW1, 0); #ifdef APP_USE_BUZZER sound(); #endif break; case 3: { BYTE ct_resp[10]; setMenuCurrentState(SUBMENU_INFO_STATE); set_current_menu(3); // 2012-05-03 Liz: Put CT display here // 2012-05-09(Eric) - Modified to save code and data space... // Eric(2012-09-19) - When bWait_Response = TRUE, msg_in cannot be null. if(!MCURequestToBOTTOMBoard(MMT_CT_RATING_REQUEST, ct_resp, 10, TRUE, TRUE)) LCD_PrintStringPGM("Try Again...", LCD_ROW1); else LCD_PrintString(ct_resp, LCD_ROW1, 0); #ifdef APP_USE_BUZZER sound(); #endif } break; case 4: setMenuCurrentState(SUBMENU_INFO_STATE); set_current_menu(4); // Put BUILD VER, function here { char s[16]; memcpypgm2ram(s, (ROM void*)FIRMWARE_VERSION, 16); LCD_PrintString(s, LCD_ROW1, 0); } #ifdef APP_USE_BUZZER sound(); #endif break; default: break; } }
void gotoMenuMeasurementState() { switch (menu_control(meas_table, meas_table_max)) { case -2: break; case -1: //setMenuCurrentState(MENU_IDLE_STATE); setMenuCurrentState(MENU_PHASE_STATE); //set_current_menu(ph - 65); set_current_menu(ph-1); gotoMenuPhaseState(); break; case 0: setMenuCurrentState(SUBMENU_MEASUREMENTS_STATE); set_current_menu(0); // Put Voltage function here setCurrentReadingDisplay(VOLTAGE); #ifdef APP_USE_BUZZER sound(); #endif break; case 1: setMenuCurrentState(SUBMENU_MEASUREMENTS_STATE); set_current_menu(1); // Put Current function here setCurrentReadingDisplay(CURRENT); #ifdef APP_USE_BUZZER sound(); #endif break; case 2: setMenuCurrentState(SUBMENU_MEASUREMENTS_STATE); set_current_menu(2); // Put Power function here setCurrentReadingDisplay(POWER); #ifdef APP_USE_BUZZER sound(); #endif break; case 3: setMenuCurrentState(SUBMENU_MEASUREMENTS_STATE); set_current_menu(3); // Put Power function here setCurrentReadingDisplay(PWR_FACTOR); #ifdef APP_USE_BUZZER sound(); #endif break; case 4: setMenuCurrentState(SUBMENU_MEASUREMENTS_STATE); set_current_menu(4); // Put Energy function here setCurrentReadingDisplay(ENERGY); #ifdef APP_USE_BUZZER sound(); #endif break; case 5: setMenuCurrentState(SUBMENU_MEASUREMENTS_STATE); set_current_menu(5); // Put Energy function here setCurrentReadingDisplay(MAX_DEMAND); #ifdef APP_USE_BUZZER sound(); #endif break; default: break; } }