![](/media/cache/group/download_IjbieK2.png.50x50_q85.png)
demo new haven display
Dependencies: LCD Menu ButtonCtrl TimeManagement EventLog AddressMap emic2
ESCM 2000 Control and Display application provides interface for the LPC1768 processor boards with the ECSM 2000 system.
This application implements SW interface : - RX 485 Receive from physical system - RX 485 Interface to send toECOM / ESCM board - CAN Interface to send to ECOM / ESCM board - 4x40 LCD with menu controls - RTC configuration -EMIC2 Sound Card - GPIO Extender to push buttons etc
Diff: main.cpp
- Revision:
- 7:0244f1a26545
- Parent:
- 6:010ceb99f7b0
- Child:
- 8:f15a5358883c
diff -r 010ceb99f7b0 -r 0244f1a26545 main.cpp --- a/main.cpp Tue Sep 17 13:48:57 2019 +0000 +++ b/main.cpp Tue Sep 17 14:24:27 2019 +0000 @@ -53,7 +53,6 @@ #define MAX_THREADS 6 Thread * threads [MAX_THREADS]; -OsTaskPerfData_t g_perfData; /*------------------------------------------------------------------- * define displays @@ -90,6 +89,8 @@ static volatile uint64_t idle; +#if DEBUG +OsTaskPerfData_t g_perfData; void InitPerfData() { for (int i=0;i<MAX_THREADS;i++) @@ -143,7 +144,7 @@ void ShowPerfData (OsPerfData_t *data) { } - +#endif /*********************************************************************** * Thread to read GPIO and handle events @@ -181,10 +182,14 @@ while(1) { +#if DEBUG UpdatePerfDataStart(&g_perfData.task[0]); +#endif escmController.update(); +#if DEBUG UpdatePerfDataStop(&g_perfData.task[0]); +#endif ThisThread::sleep_for(200); } } @@ -207,12 +212,14 @@ toggleLed3(); - Menu *activeMenu = Menu::setCurrentMenu (&editAddress); + Menu *activeMenu = Menu::setCurrentMenu (&showEvents); while (true) { +#if DEBUG UpdatePerfDataStart(&g_perfData.task[2]); - #if 0 +#endif + #if AUTO_REFESH_ENABLED // note force a refresh if (counter==0) { activeMenu->update_needed = 1; @@ -242,61 +249,14 @@ toggleLed3(); +#if DEBUG UpdatePerfDataStop(&g_perfData.task[2]); +#endif ThisThread::sleep_for(10); } } /*********************************************************************** -* Handle Terminal Prompts -* TODO: should have its own queue. -***********************************************************************/ - -void TerminalPrompt(void) // const *name) -{ - - pc.printf("Starting escmTerm task\n" ); - - while (1) - { - int c; - pc.printf("\n>>"); - pc.scanf("%d", &c); - - /* echo */ - pc.printf("\n%0d",c); - - if ( c >= 0 && c < 99) { - ESCMControlApp::postEvent((uint16_t)c); - } - else if (c==555) - { - addressMap.reset(); - } - else if (c==666) - { - escmEventLog.reset(); - } - else if (c==999) - { - pc.printf("\nThread | size | free | used | max | "); - pc.printf("\n------------------------------------ "); - for(int i = 0; i<MAX_THREADS; i++) { - pc.printf("\n%-8d | %4d | %4d | %4d | %4d |", - i, - threads[i]->stack_size(), - threads[i]->free_stack(), - threads[i]->used_stack(), - threads[i]->max_stack() - ) ; - } - } - else - { - } - } -} -/*********************************************************************** * Play sounds * TODO: should have its own queue. ***********************************************************************/ @@ -308,16 +268,21 @@ while (1) { +#if DEBUG UpdatePerfDataStart(&g_perfData.task[3]); +#endif toggleLed2(); escmController.processSoundQueue(); +#if DEBUG UpdatePerfDataStop(&g_perfData.task[3]); +#endif Thread::wait(200); } } +#if DEBUG /*********************************************************************** * Dumps thread stats ***********************************************************************/ @@ -376,7 +341,59 @@ Thread::wait(200); } } +#endif + +#if TEST +/*********************************************************************** +* Handle Terminal Prompts +* TODO: should have its own queue. +***********************************************************************/ + +void TerminalPrompt(void) // const *name) +{ + + pc.printf("Starting escmTerm task\n" ); + + while (1) + { + int c; + pc.printf("\n>>"); + pc.scanf("%d", &c); + + /* echo */ + pc.printf("\n%0d",c); + + if ( c >= 0 && c < 99) { + ESCMControlApp::postEvent((uint16_t)c,99); + } + else if (c==555) + { + addressMap.reset(); + } + else if (c==666) + { + escmEventLog.reset(); + } + else if (c==999) + { + pc.printf("\nThread | size | free | used | max | "); + pc.printf("\n------------------------------------ "); + for(int i = 0; i<MAX_THREADS; i++) { + pc.printf("\n%-8d | %4d | %4d | %4d | %4d |", + i, + threads[i]->stack_size(), + threads[i]->free_stack(), + threads[i]->used_stack(), + threads[i]->max_stack() + ) ; + } + } + else + { + } + } +} /*********************************************************************** * process incoming messages from rx485 serial (ISR) ***********************************************************************/ @@ -405,6 +422,7 @@ } #endif } +#endif /*********************************************************************** * Main Loop ***********************************************************************/ @@ -434,8 +452,10 @@ led1=!led1; +#if DEBUG InitPerfData(); - +#endif + lcd.init(); lcd.cls(); lcd.locate(0,0); @@ -461,22 +481,30 @@ toggleLed1(); - EventQueue *stats_queue = mbed_event_queue(); - threads[0] = new Thread(osPriorityNormal5, 0x300 ); threads[1] = new Thread(osPriorityNormal4, 0x500 ); threads[2] = new Thread(osPriorityNormal3, 0x1000 ); threads[3] = new Thread(osPriorityNormal2, 0x400 ); +#if DEBUG threads[4] = new Thread(osPriorityNormal1, 0x200 ); +#endif + +#if TEST threads[5] = new Thread(osPriorityLow, 0x100 ); +#endif threads[0]->start(ESCMController_Update); threads[1]->start(ReadGPIOExtender); threads[2]->start(UpdateDisplay); threads[3]->start(PlaySound); - threads[4]->start(PrintSystemStats); - //threads[5]->start(TerminalPrompt); +#if DEBUG + //threads[4]->start(PrintSystemStats); +#endif + +#if TEST + threads[5]->start(TerminalPrompt); +#endif while(1) {