///---------------------------------------------------------------------------- /// Function Break ///---------------------------------------------------------------------------- void TurnDisplayOff(void) { DisplayTimerCallBack(); LcdPwTimerCallBack(); while (g_kpadInterruptWhileProcessing == YES) { g_kpadInterruptWhileProcessing = NO; ReadMcp23018(IO_ADDRESS_KPD, GPIOB); } g_kpadProcessingFlag = DEACTIVATED; }
///---------------------------------------------------------------------------- /// Function Break ///---------------------------------------------------------------------------- void KeypadLedUpdateTimerCallBack(void) { static uint8 ledState = KEYPAD_LED_STATE_UNKNOWN; uint8 lastLedState; uint8 config; // = ReadMcp23018(IO_ADDRESS_KPD, GPIOA); BOOLEAN externalChargePresent = CheckExternalChargeVoltagePresent(); // States // 1) Init complete, not monitoring, not charging --> Static Green // 2) Init complete, not monitoring, charging --> Static Red // 3) Init complete, monitoring, not charging --> Flashing Green (state transition) // 4) Init complete, monitoring, charging --> Alternate Flashing Green/Red (state transition) // Hold the last state lastLedState = ledState; if ((g_sampleProcessing == IDLE_STATE) && (externalChargePresent == FALSE)) { //debug("Keypad LED: State 1\r\n"); ledState = KEYPAD_LED_STATE_IDLE_GREEN_ON; } else if ((g_sampleProcessing == IDLE_STATE) && (externalChargePresent == TRUE)) { //debug("Keypad LED: State 2\r\n"); ledState = KEYPAD_LED_STATE_CHARGE_RED_ON; } else if ((g_sampleProcessing == ACTIVE_STATE) && (externalChargePresent == FALSE)) { //debug("Keypad LED: State 3\r\n"); if (ledState == KEYPAD_LED_STATE_ACTIVE_GREEN_ON) { ledState = KEYPAD_LED_STATE_ACTIVE_GREEN_OFF; } else { ledState = KEYPAD_LED_STATE_ACTIVE_GREEN_ON; } } else // ((g_sampleProcessing == ACTIVE_STATE) && (externalChargePresent == TRUE)) { //debug("Keypad LED: State 4\r\n"); if (ledState == KEYPAD_LED_STATE_ACTIVE_CHARGE_GREEN_ON) { ledState = KEYPAD_LED_STATE_ACTIVE_CHARGE_RED_ON; } else { ledState = KEYPAD_LED_STATE_ACTIVE_CHARGE_GREEN_ON; } } // Check if the state changed if (ledState != lastLedState) { config = ReadMcp23018(IO_ADDRESS_KPD, GPIOA); switch (ledState) { case KEYPAD_LED_STATE_BOTH_OFF: case KEYPAD_LED_STATE_ACTIVE_GREEN_OFF: config &= ~RED_LED_PIN; config &= ~GREEN_LED_PIN; break; case KEYPAD_LED_STATE_IDLE_GREEN_ON: case KEYPAD_LED_STATE_ACTIVE_GREEN_ON: case KEYPAD_LED_STATE_ACTIVE_CHARGE_GREEN_ON: config &= ~RED_LED_PIN; config |= GREEN_LED_PIN; break; case KEYPAD_LED_STATE_CHARGE_RED_ON: case KEYPAD_LED_STATE_ACTIVE_CHARGE_RED_ON: config &= ~GREEN_LED_PIN; config |= RED_LED_PIN; break; } WriteMcp23018(IO_ADDRESS_KPD, GPIOA, config); } AssignSoftTimer(KEYPAD_LED_TIMER_NUM, ONE_SECOND_TIMEOUT, KeypadLedUpdateTimerCallBack); }
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(); }