///---------------------------------------------------------------------------- /// Function Break ///---------------------------------------------------------------------------- void HandleUserPowerOffDuringTimerMode(void) { INPUT_MSG_STRUCT mn_msg; uint8 choice; // Simulate a keypress if the user pressed the off key, which doesn't register as a keypess KeypressEventMgr(); MessageBox(getLangText(STATUS_TEXT), getLangText(UNIT_IS_IN_TIMER_MODE_TEXT), MB_OK); choice = MessageBox(getLangText(WARNING_TEXT), getLangText(CANCEL_TIMER_MODE_Q_TEXT), MB_YESNO); // User decided to cancel Timer mode if (choice == MB_FIRST_CHOICE) { g_unitConfig.timerMode = DISABLED; // Disable the Power Off timer ClearSoftTimer(POWER_OFF_TIMER_NUM); // Save Unit Config SaveRecordData(&g_unitConfig, DEFAULT_RECORD, REC_UNIT_CONFIG_TYPE); OverlayMessage(getLangText(STATUS_TEXT), getLangText(TIMER_MODE_DISABLED_TEXT), 2 * SOFT_SECS); } else // User decided to stay in Timer mode { choice = MessageBox(getLangText(STATUS_TEXT), getLangText(POWER_UNIT_OFF_EARLY_Q_TEXT), MB_YESNO); if (choice == MB_FIRST_CHOICE) { MessageBox(getLangText(STATUS_TEXT), getLangText(POWERING_UNIT_OFF_NOW_TEXT), MB_OK); MessageBox(getLangText(STATUS_TEXT), getLangText(PLEASE_PRESS_ENTER_TEXT), MB_OK); // Turn unit off/sleep debug("Timer mode: Shutting down unit early due to user request. Powering off now...\r\n"); PowerUnitOff(SHUTDOWN_UNIT); // Return unnecessary } } SETUP_MENU_MSG(MAIN_MENU); JUMP_TO_ACTIVE_MENU(); }
///---------------------------------------------------------------------------- /// Function Break ///---------------------------------------------------------------------------- void SummaryMenuProc(INPUT_MSG_STRUCT msg, WND_LAYOUT_STRUCT *wnd_layout_ptr) { INPUT_MSG_STRUCT mn_msg; uint16 tempSummaryIndex = 0; if (msg.cmd == ACTIVATE_MENU_CMD) { wnd_layout_ptr->start_col = SUMMARY_WND_STARTING_COL; /* 6 */ wnd_layout_ptr->end_col = SUMMARY_WND_END_COL; /* 127 leaving one pixel space at the end */ wnd_layout_ptr->start_row = SUMMARY_WND_STARTING_ROW; /* 8 */ wnd_layout_ptr->end_row = SUMMARY_WND_END_ROW; /* 6 */ DumpSummaryListFileToEventBuffer(); g_summaryListMenuActive = YES; s_totalRamSummaries = g_summaryList.validEntries; if (msg.data[0] == START_FROM_TOP) { // Find the first valid summary index and set the top and current index to match s_topMenuSummaryIndex = s_currentSummaryIndex = GetFirstValidRamSummaryIndex(); debug("First valid ram summary index: %d\r\n", s_topMenuSummaryIndex); g_summaryListArrowChar = DOWN_ARROW_CHAR; } } else if (msg.cmd == KEYPRESS_MENU_CMD) { switch (msg.data[0]) { case (ENTER_KEY): // Check if the top menu summary index represents a valid index if (s_topMenuSummaryIndex < g_summaryList.validEntries) { // Grab the event info, assuming it's cached cacheSummaryListEntry(s_currentSummaryIndex); g_summaryEventNumber = g_summaryList.cachedEntry.eventNumber; g_updateResultsEventRecord = YES; debug("Summary menu: Calling Results Menu for Event #%d\r\n", g_summaryEventNumber); switch (g_summaryList.cachedEntry.mode) { case WAVEFORM_MODE: case MANUAL_CAL_MODE: case BARGRAPH_MODE: case COMBO_MODE: SETUP_MENU_MSG(RESULTS_MENU); JUMP_TO_ACTIVE_MENU(); break; case MANUAL_TRIGGER_MODE: break; default: break; } } break; case (DOWN_ARROW_KEY): // Check if the top menu summary index represents a valid index if (s_topMenuSummaryIndex < s_totalRamSummaries) { SummaryMenuScroll(DOWN); } break; case (UP_ARROW_KEY): // Check if the top menu summary index represents a valid index if (s_topMenuSummaryIndex < s_totalRamSummaries) { SummaryMenuScroll(UP); } break; case (ESC_KEY): tempSummaryIndex = GetFirstValidRamSummaryIndex(); // Check if the top menu summary index represents a valid index and if the current index isn't the first if ((s_topMenuSummaryIndex < s_totalRamSummaries) && (tempSummaryIndex != s_currentSummaryIndex)) { s_topMenuSummaryIndex = s_currentSummaryIndex = tempSummaryIndex; g_summaryListArrowChar = DOWN_ARROW_CHAR; debug("Summary List: Setting Current Index to first valid Summary index\r\n"); } else // We're done here { g_summaryListMenuActive = NO; SETUP_USER_MENU_MSG(&configMenu, EVENT_SUMMARIES); JUMP_TO_ACTIVE_MENU(); } break; default: break; } } }
///---------------------------------------------------------------------------- /// Function Break ///---------------------------------------------------------------------------- void TimerModeDateMenuProc(INPUT_MSG_STRUCT msg, REC_MN_STRUCT *rec_ptr, WND_LAYOUT_STRUCT *wnd_layout_ptr, MN_LAYOUT_STRUCT *mn_layout_ptr) { INPUT_MSG_STRUCT mn_msg; DATE_TIME_STRUCT time; uint32 input; //uint8 dayOfWeek = 0; switch (msg.cmd) { case (ACTIVATE_MENU_CMD): wnd_layout_ptr->start_col = TIMER_MODE_DATE_WND_STARTING_COL; wnd_layout_ptr->end_col = TIMER_MODE_DATE_WND_END_COL; wnd_layout_ptr->start_row = TIMER_MODE_DATE_WND_STARTING_ROW; wnd_layout_ptr->end_row = TIMER_MODE_DATE_WND_END_ROW; mn_layout_ptr->curr_ln = 0; mn_layout_ptr->top_ln = 0; mn_layout_ptr->sub_ln = 0; time = GetCurrentTime(); LoadTimerModeDateMnDefRec(rec_ptr, &time); rec_ptr[mn_layout_ptr->curr_ln].enterflag = TRUE; break; case (KEYPRESS_MENU_CMD): input = msg.data[0]; switch (input) { case (ENTER_KEY): g_unitConfig.timerStartDate.day = (char)rec_ptr[TMD_START_DAY].numrec.tindex; g_unitConfig.timerStartDate.month = (char)rec_ptr[TMD_START_MONTH].numrec.tindex; g_unitConfig.timerStartDate.year = (char)rec_ptr[TMD_START_YEAR].numrec.tindex; g_unitConfig.timerStopDate.day = (char)rec_ptr[TMD_STOP_DAY].numrec.tindex; g_unitConfig.timerStopDate.month = (char)rec_ptr[TMD_STOP_MONTH].numrec.tindex; g_unitConfig.timerStopDate.year = (char)rec_ptr[TMD_STOP_YEAR].numrec.tindex; ProcessTimerModeSettings(PROMPT); SETUP_USER_MENU_MSG(&configMenu, DEFAULT_ITEM_1); JUMP_TO_ACTIVE_MENU(); break; case (DOWN_ARROW_KEY): if (rec_ptr[mn_layout_ptr->curr_ln].enterflag == TRUE) { TimerModeDateMenuDvScroll(DOWN, &rec_ptr[mn_layout_ptr->curr_ln]); } break; case (UP_ARROW_KEY): if (rec_ptr[mn_layout_ptr->curr_ln].enterflag == TRUE) { TimerModeDateMenuDvScroll(UP, &rec_ptr[mn_layout_ptr->curr_ln]); } break; case (PLUS_KEY): rec_ptr[mn_layout_ptr->curr_ln].enterflag = FALSE; TimerModeDateMenuScroll(DOWN, mn_layout_ptr); rec_ptr[mn_layout_ptr->curr_ln].enterflag = TRUE; break; case (MINUS_KEY): rec_ptr[mn_layout_ptr->curr_ln].enterflag = FALSE; TimerModeDateMenuScroll(UP, mn_layout_ptr); rec_ptr[mn_layout_ptr->curr_ln].enterflag = TRUE; break; case (ESC_KEY): SETUP_MENU_MSG(TIMER_MODE_TIME_MENU); JUMP_TO_ACTIVE_MENU(); break; default: break; } break; default: break; } }
///---------------------------------------------------------------------------- /// Function Break ///---------------------------------------------------------------------------- void TimerModeTimeMenuProc(INPUT_MSG_STRUCT msg, REC_MN_STRUCT *rec_ptr, WND_LAYOUT_STRUCT *wnd_layout_ptr, MN_LAYOUT_STRUCT *mn_layout_ptr) { INPUT_MSG_STRUCT mn_msg; DATE_TIME_STRUCT time; uint32 input; switch (msg.cmd) { case (ACTIVATE_MENU_CMD): wnd_layout_ptr->start_col = TIMER_MODE_TIME_WND_STARTING_COL; wnd_layout_ptr->end_col = TIMER_MODE_TIME_WND_END_COL; wnd_layout_ptr->start_row = TIMER_MODE_TIME_WND_STARTING_ROW; wnd_layout_ptr->end_row = TIMER_MODE_TIME_WND_END_ROW; mn_layout_ptr->curr_ln = 0; mn_layout_ptr->top_ln = 0; mn_layout_ptr->sub_ln = 0; time = GetCurrentTime(); LoadTimerModeTimeMnDefRec(rec_ptr,&time); rec_ptr[mn_layout_ptr->curr_ln].enterflag = TRUE; break; case (ACTIVATE_MENU_WITH_DATA_CMD): wnd_layout_ptr->start_col = TIMER_MODE_TIME_WND_STARTING_COL; wnd_layout_ptr->end_col = TIMER_MODE_TIME_WND_END_COL; wnd_layout_ptr->start_row = TIMER_MODE_TIME_WND_STARTING_ROW; wnd_layout_ptr->end_row = TIMER_MODE_TIME_WND_END_ROW; mn_layout_ptr->curr_ln = 0; mn_layout_ptr->top_ln = 0; mn_layout_ptr->sub_ln = 0; rec_ptr[mn_layout_ptr->curr_ln].enterflag = TRUE; break; case (KEYPRESS_MENU_CMD): input = msg.data[0]; switch (input) { case (ENTER_KEY): rec_ptr[s_dataRecordCurrentItem].enterflag = FALSE; TimerModeKeepTime(rec_ptr); SETUP_MENU_MSG(TIMER_MODE_DATE_MENU); JUMP_TO_ACTIVE_MENU(); break; case (DOWN_ARROW_KEY): if (rec_ptr[mn_layout_ptr->curr_ln].enterflag == TRUE) { TimerModeTimeMenuDvScroll(DOWN,&rec_ptr[mn_layout_ptr->curr_ln]); } break; case (UP_ARROW_KEY): if (rec_ptr[mn_layout_ptr->curr_ln].enterflag == TRUE) { TimerModeTimeMenuDvScroll(UP,&rec_ptr[mn_layout_ptr->curr_ln]); } break; case (PLUS_KEY): rec_ptr[mn_layout_ptr->curr_ln].enterflag = FALSE; TimerModeTimeMenuScroll(DOWN, mn_layout_ptr); rec_ptr[mn_layout_ptr->curr_ln].enterflag = TRUE; break; case (MINUS_KEY): rec_ptr[mn_layout_ptr->curr_ln].enterflag = FALSE; TimerModeTimeMenuScroll(UP, mn_layout_ptr); rec_ptr[mn_layout_ptr->curr_ln].enterflag = TRUE; break; case (ESC_KEY): SETUP_USER_MENU_MSG(&timerModeFreqMenu, g_unitConfig.timerModeFrequency); JUMP_TO_ACTIVE_MENU(); break; default: break; } break; default: break; } }
///---------------------------------------------------------------------------- /// Function Break ///---------------------------------------------------------------------------- void LoadRecordMenuProc(INPUT_MSG_STRUCT msg, WND_LAYOUT_STRUCT *wnd_layout_ptr, MN_LAYOUT_STRUCT *mn_layout_ptr) { uint8 buff[20]; REC_EVENT_MN_STRUCT temp_rec; INPUT_MSG_STRUCT mn_msg; uint32 input; uint8 i; switch (msg.cmd) { case (ACTIVATE_MENU_CMD): wnd_layout_ptr->start_col = LOAD_REC_WND_STARTING_COL; wnd_layout_ptr->end_col = LOAD_REC_WND_END_COL; wnd_layout_ptr->start_row = LOAD_REC_WND_STARTING_ROW; wnd_layout_ptr->end_row = LOAD_REC_WND_END_ROW; mn_layout_ptr->curr_ln = 1; mn_layout_ptr->top_ln = 1; LoadTempMenuTable(s_loadRecordMenuTable); for (i = 1; i <= MAX_NUM_OF_SAVED_SETUPS; i++) { GetRecordData(&temp_rec, i, REC_TRIGGER_USER_MENU_TYPE); if (temp_rec.validRecord == YES) { switch (temp_rec.opMode) { case (WAVEFORM_MODE): sprintf((char*)buff, "%s (%s)", (char*)temp_rec.name, getLangText(SELF_TRG_TEXT)); break; case (BARGRAPH_MODE): sprintf((char*)buff, "%s (%s)", (char*)temp_rec.name, getLangText(BAR_TEXT)); break; case (COMBO_MODE): sprintf((char*)buff, "%s (%s)", (char*)temp_rec.name, getLangText(COMBO_TEXT)); break; default: sprintf((char*)buff, "%s (UNK)", (char*)temp_rec.name); break; } } else { sprintf((char*)buff, "<%s>", getLangText(EMPTY_TEXT)); } // Add 3 to i to offset past the default settings strcpy((char*)&(g_menuPtr[i + 3].data[0]), (char*)buff); } // Add in the "<END>" text to signal the end of the list sprintf((char*)buff, "<%s>", getLangText(END_TEXT)); strcpy((char*)&(g_menuPtr[i + 3].data[0]), (char*)buff); i++; // Add the end string to allow other routines to match on the end of the menu strcpy((char*)&(g_menuPtr[i + 3].data[0]), ".end."); break; case (KEYPRESS_MENU_CMD): input = msg.data[0]; switch (input) { case (ENTER_KEY): switch (mn_layout_ptr->curr_ln) { case (1): LoadTrigRecordDefaults(&g_triggerRecord, WAVEFORM_MODE); break; case (2): LoadTrigRecordDefaults(&g_triggerRecord, BARGRAPH_MODE); break; case (3): LoadTrigRecordDefaults(&g_triggerRecord, COMBO_MODE); break; default: // Check if the first char matches a "<" for either "<EMPTY>" or "<END>" if (strncmp((char*)&g_menuPtr[mn_layout_ptr->curr_ln].data[0], "<", 1) == 0) { // Record slot is empty, do nothing return; } else { GetRecordData(&g_triggerRecord, (uint32)(mn_layout_ptr->curr_ln - 3), REC_TRIGGER_USER_MENU_TYPE); } break; } UpdateModeMenuTitle(g_triggerRecord.opMode); SETUP_USER_MENU_MSG(&modeMenu, MONITOR); JUMP_TO_ACTIVE_MENU(); break; case (DELETE_KEY): // Check if the current line is beyond the default entries if (mn_layout_ptr->curr_ln > 3) { GetRecordData(&temp_rec, (uint32)(mn_layout_ptr->curr_ln - 3), REC_TRIGGER_USER_MENU_TYPE); if (temp_rec.validRecord == YES) { sprintf((char*)g_spareBuffer, "%s (%s)", getLangText(DELETE_SAVED_SETUP_Q_TEXT), temp_rec.name); if (MessageBox(getLangText(WARNING_TEXT), (char*)g_spareBuffer, MB_YESNO) == MB_FIRST_CHOICE) { memset(&temp_rec.name, 0, sizeof(temp_rec.name)); temp_rec.validRecord = NO; SaveRecordData(&temp_rec, (uint32)(mn_layout_ptr->curr_ln - 3), REC_TRIGGER_USER_MENU_TYPE); sprintf((char*)&(g_menuPtr[mn_layout_ptr->curr_ln].data[0]), "<%s>", getLangText(EMPTY_TEXT)); } } } break; case (DOWN_ARROW_KEY): MenuScroll(DOWN, SELECT_MN_WND_LNS, mn_layout_ptr); // Prevent the cursor from selecting the "<END>" text if (mn_layout_ptr->curr_ln == 18) { mn_layout_ptr->curr_ln = 17; } break; case (UP_ARROW_KEY): MenuScroll(UP, SELECT_MN_WND_LNS, mn_layout_ptr); break; case (ESC_KEY): SETUP_MENU_MSG(MAIN_MENU); mn_msg.data[0] = ESC_KEY; JUMP_TO_ACTIVE_MENU(); break; case (HELP_KEY): SETUP_USER_MENU_MSG(&helpMenu, CONFIG); JUMP_TO_ACTIVE_MENU(); break; default: break; } break; default: break; } }
void InitSoftwareSettings_NS8100(void) { INPUT_MSG_STRUCT mn_msg; debug("Init Software Settings...\r\n"); //------------------------------------------------------------------------- // Init version msg //------------------------------------------------------------------------- InitVersionMsg(); //------------------------------------------------------------------------- // Init time msg and update current time //------------------------------------------------------------------------- InitTimeMsg(); UpdateCurrentTime(); //------------------------------------------------------------------------- // Get the function address passed by the bootloader //------------------------------------------------------------------------- CheckBootloaderAppPresent(); debug("Bootloader check complete\r\n"); //------------------------------------------------------------------------- // Load the Unit Config //------------------------------------------------------------------------- LoadUnitConfig(); debug("Loading Unit Config record\r\n"); //------------------------------------------------------------------------- // Build the language table based on the user's last language choice //------------------------------------------------------------------------- BuildLanguageLinkTable(g_unitConfig.languageMode); debug("Language Tables built\r\n"); //------------------------------------------------------------------------- // Initialize Unit Config items such as contrast, timers //------------------------------------------------------------------------- ActivateUnitConfigOptions(); debug("Activated Unit Config Options\r\n"); //------------------------------------------------------------------------- // Display the Splash screen //------------------------------------------------------------------------- DisplaySplashScreen(); debug("Display Splash screen complete\r\n"); //------------------------------------------------------------------------- // Wait at least 3 seconds for the main screen to be displayed //------------------------------------------------------------------------- debug("Three second delay for Splash screen\r\n"); SoftUsecWait(3 * SOFT_SECS); //------------------------------------------------------------------------- // Display Smart Sensor information if found //------------------------------------------------------------------------- DisplaySmartSensorInfo(INFO_ON_INIT); //------------------------------------------------------------------------- // Bootloader entry check //------------------------------------------------------------------------- BootloaderEntryCheck(); //------------------------------------------------------------------------- // Load the Factory Setup Record //------------------------------------------------------------------------- LoadFactorySetupRecord(); debug("Factory setup record loaded\r\n"); //------------------------------------------------------------------------- // Load Default Trigger Record //------------------------------------------------------------------------- LoadDefaultTriggerRecord(); debug("Default Trigger record loaded\r\n"); //------------------------------------------------------------------------- // Load the Modem Setup Record //------------------------------------------------------------------------- LoadModemSetupRecord(); debug("Modem Setup record loaded\r\n"); //------------------------------------------------------------------------- // Add OnOff Log Timestamp //------------------------------------------------------------------------- AddOnOffLogTimestamp(ON); debug("On/Off Log timestamp appended\r\n"); #if 0 // Removed debug log file due to inducing system problems //------------------------------------------------------------------------- // Switch Debug Log file SwitchDebugLogFile(); #endif //------------------------------------------------------------------------- // Init Global Unique Event Number //------------------------------------------------------------------------- InitCurrentEventNumber(); debug("Current Event Number initialized\r\n"); //------------------------------------------------------------------------- // Init AutoDialout //------------------------------------------------------------------------- InitAutoDialout(); debug("Auto Dialout initialized\r\n"); //------------------------------------------------------------------------- // Init Monitor Log //------------------------------------------------------------------------- InitMonitorLog(); debug("Monitor Log initialized\r\n"); //------------------------------------------------------------------------- // Init the Sensor Parameters //------------------------------------------------------------------------- InitSensorParameters(g_factorySetupRecord.seismicSensorType, (uint8)g_triggerRecord.srec.sensitivity); debug("Sensor Parameters initialized\r\n"); //------------------------------------------------------------------------- // Init the Summary List file //------------------------------------------------------------------------- ManageEventsDirectory(); InitSummaryListFile(); debug("Summary List initialized\r\n"); //------------------------------------------------------------------------- // Update Flash Usage Stats //------------------------------------------------------------------------- OverlayMessage(getLangText(STATUS_TEXT), getLangText(CALCULATING_EVENT_STORAGE_SPACE_FREE_TEXT), 0); GetSDCardUsageStats(); debug("Flash Usage Stats updated (Cluster size: %d bytes)\r\n", g_sdCardUsageStats.clusterSizeInBytes); //------------------------------------------------------------------------- // Check for Timer mode activation //------------------------------------------------------------------------- if (TimerModeActiveCheck() == TRUE) { debug("--- Timer Mode Startup ---\r\n"); ProcessTimerMode(); } else // Normal startup { debug("--- Normal Startup ---\r\n"); } //------------------------------------------------------------------------- // Init the cmd message handling buffers before initialization of the ports. //------------------------------------------------------------------------- RemoteCmdMessageHandlerInit(); debug("Craft Message Handler initialized\r\n"); //------------------------------------------------------------------------- // Init the input buffers and status flags for input craft data. //------------------------------------------------------------------------- CraftInitStatusFlags(); debug("Craft Status flags initilaized\r\n"); //------------------------------------------------------------------------- // Signal remote end that RS232 Comm is available //------------------------------------------------------------------------- SET_RTS; SET_DTR; debug("Craft RTS and DTR enabled\r\n"); //------------------------------------------------------------------------- // Reset LCD timers //------------------------------------------------------------------------- ResetSoftTimer(LCD_BACKLIGHT_ON_OFF_TIMER_NUM); ResetSoftTimer(LCD_POWER_ON_OFF_TIMER_NUM); //------------------------------------------------------------------------- // Turn on the Green keypad LED when system init complete //------------------------------------------------------------------------- debug("Init complete, turning Kepypad LED Green...\r\n"); WriteMcp23018(IO_ADDRESS_KPD, GPIOA, ((ReadMcp23018(IO_ADDRESS_KPD, GPIOA) & 0xCF) | GREEN_LED_PIN)); //------------------------------------------------------------------------- // Assign a one second keypad led update timer //------------------------------------------------------------------------- AssignSoftTimer(KEYPAD_LED_TIMER_NUM, ONE_SECOND_TIMEOUT, KeypadLedUpdateTimerCallBack); debug("Keypad LED Timer initialized\r\n"); //------------------------------------------------------------------------- // Jump to the true main menu //------------------------------------------------------------------------- debug("Jumping to Main Menu\r\n"); SETUP_MENU_MSG(MAIN_MENU); JUMP_TO_ACTIVE_MENU(); //------------------------------------------------------------------------- // Enable Craft input (delayed to prevent serial input from locking unit) //------------------------------------------------------------------------- InitCraftInterruptBuffers(); Setup_8100_Usart1_RS232_ISR(); if (GET_HARDWARE_ID == HARDWARE_ID_REV_8_WITH_GPS_MOD) { EnableGps(); } //------------------------------------------------------------------------- // Enable keypad key input (delayed to prevent key input from locking unit) //------------------------------------------------------------------------- EnableMcp23018Interrupts(); debug("Mcp23018 interrupts enabled\r\n"); //------------------------------------------------------------------------- // Display last line of system init //------------------------------------------------------------------------- DisplayVersionToDebug(); }