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
Revision 7:0244f1a26545, committed 2019-09-17
- Comitter:
- foxbrianr
- Date:
- Tue Sep 17 14:24:27 2019 +0000
- Parent:
- 6:010ceb99f7b0
- Child:
- 8:f15a5358883c
- Commit message:
- RC01
Changed in this revision
--- a/ESCMControlApp.cpp Tue Sep 17 13:48:57 2019 +0000 +++ b/ESCMControlApp.cpp Tue Sep 17 14:24:27 2019 +0000 @@ -59,13 +59,14 @@ // --------------------------------------------------------------------- RealTimeClock rtc; -/* for incoming messages */ -CircularBuffer<event_t, 64> message_queue; - -/* for button presses */ +// --------------------------------------------------------------------- +// queue for button presses +// --------------------------------------------------------------------- CircularBuffer<event_t, 64> event_queue; -/* for playing sound */ +// --------------------------------------------------------------------- +// queue for playing sound +// --------------------------------------------------------------------- CircularBuffer<playbackMessage_t, 10> playback_queue; @@ -180,21 +181,6 @@ } /*************************************************************************/ -void ESCMControlApp::processMessageQueue () -{ - event_t e; - - if (message_queue.empty()) - return; - - while (!message_queue.empty()) { - message_queue.pop(e); - tx485Message(e.event); - ThisThread::sleep_for(100); - } -} - -/*************************************************************************/ void ESCMControlApp::processSoundQueue () { playbackMessage_t e; @@ -287,20 +273,6 @@ va_end(args); } -/*************************************************************************/ -void ESCMControlApp::postEvent (uint16_t address) -{ - event_t e; - - e.event = address; - - if (!message_queue.full()) { - message_queue.push(e); - } else { - printf("Message Queue Full\n"); - } -} - /************************************************************************* * The following function is called with a new event is received to
--- a/ESCMControlApp.h Tue Sep 17 13:48:57 2019 +0000 +++ b/ESCMControlApp.h Tue Sep 17 14:24:27 2019 +0000 @@ -76,8 +76,6 @@ extern emic2 speaker; -extern CircularBuffer<event_t, 64> message_queue; - extern CircularBuffer<event_t, 64> event_queue; extern CircularBuffer<playbackMessage_t, 10> playback_queue; @@ -110,7 +108,6 @@ static void getTime(char *timeBuffer); static void setTime(int hours, int mins, int sec, int months, int days, int years ); - static void postEvent (uint16_t address); static void postEvent (uint16_t address, uint16_t source); int cur_address;
--- a/Menu.lib Tue Sep 17 13:48:57 2019 +0000 +++ b/Menu.lib Tue Sep 17 14:24:27 2019 +0000 @@ -1,1 +1,1 @@ -https://os.mbed.com/users/foxbrianr/code/Menu/#9f4d4f8ffc00 +https://os.mbed.com/users/foxbrianr/code/Menu/#af3769d17a35
--- 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) {