![](/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
ESCMControlApp.h@5:65f21c0b6b79, 2019-09-12 (annotated)
- Committer:
- foxbrianr
- Date:
- Thu Sep 12 11:28:26 2019 +0000
- Revision:
- 5:65f21c0b6b79
- Parent:
- 3:ecaf9963341b
- Child:
- 6:010ceb99f7b0
beta1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
foxbrianr | 3:ecaf9963341b | 1 | #ifndef _ESCM_CONTROL_APP_ |
foxbrianr | 3:ecaf9963341b | 2 | #define _ESCM_CONTROL_APP_ |
foxbrianr | 3:ecaf9963341b | 3 | |
foxbrianr | 3:ecaf9963341b | 4 | |
foxbrianr | 3:ecaf9963341b | 5 | #include "mbed.h" |
foxbrianr | 3:ecaf9963341b | 6 | #include "Menu.h" |
foxbrianr | 3:ecaf9963341b | 7 | #include "LCD.h" |
foxbrianr | 3:ecaf9963341b | 8 | #include "AddressMap.h" |
foxbrianr | 3:ecaf9963341b | 9 | #include "EventLog.h" |
foxbrianr | 3:ecaf9963341b | 10 | #include "TimeUtilities.h" |
foxbrianr | 3:ecaf9963341b | 11 | |
foxbrianr | 3:ecaf9963341b | 12 | #include "emic2.h" |
foxbrianr | 3:ecaf9963341b | 13 | |
foxbrianr | 3:ecaf9963341b | 14 | |
foxbrianr | 5:65f21c0b6b79 | 15 | #define LIMIT(x,low,high) x = ((x<=low)? low : ((x>=high) ? high : x )); |
foxbrianr | 5:65f21c0b6b79 | 16 | #define WRAP (x,low,high) ((x<low)?(high-1):((x>high)?0:x)); |
foxbrianr | 5:65f21c0b6b79 | 17 | |
foxbrianr | 5:65f21c0b6b79 | 18 | typedef struct { |
foxbrianr | 5:65f21c0b6b79 | 19 | int event; |
foxbrianr | 5:65f21c0b6b79 | 20 | } event_t; |
foxbrianr | 5:65f21c0b6b79 | 21 | |
foxbrianr | 5:65f21c0b6b79 | 22 | typedef struct { |
foxbrianr | 5:65f21c0b6b79 | 23 | char message[64]; |
foxbrianr | 5:65f21c0b6b79 | 24 | } playbackMessage_t; |
foxbrianr | 5:65f21c0b6b79 | 25 | |
foxbrianr | 5:65f21c0b6b79 | 26 | |
foxbrianr | 3:ecaf9963341b | 27 | extern LCD lcd; |
foxbrianr | 3:ecaf9963341b | 28 | |
foxbrianr | 5:65f21c0b6b79 | 29 | extern AddressMap addressMap; |
foxbrianr | 5:65f21c0b6b79 | 30 | |
foxbrianr | 3:ecaf9963341b | 31 | extern ESCM_EventLog escmEventLog; |
foxbrianr | 3:ecaf9963341b | 32 | |
foxbrianr | 3:ecaf9963341b | 33 | extern RealTimeClock rtc; |
foxbrianr | 3:ecaf9963341b | 34 | |
foxbrianr | 3:ecaf9963341b | 35 | extern Serial rs485port1; |
foxbrianr | 3:ecaf9963341b | 36 | extern DigitalOut rs485port1mode; |
foxbrianr | 3:ecaf9963341b | 37 | |
foxbrianr | 3:ecaf9963341b | 38 | extern Serial rs485port2; |
foxbrianr | 3:ecaf9963341b | 39 | extern DigitalOut rs485port2mode; |
foxbrianr | 3:ecaf9963341b | 40 | |
foxbrianr | 3:ecaf9963341b | 41 | extern CAN canport; |
foxbrianr | 3:ecaf9963341b | 42 | extern DigitalOut canportmode; |
foxbrianr | 3:ecaf9963341b | 43 | |
foxbrianr | 3:ecaf9963341b | 44 | extern emic2 speaker; |
foxbrianr | 3:ecaf9963341b | 45 | |
foxbrianr | 3:ecaf9963341b | 46 | |
foxbrianr | 5:65f21c0b6b79 | 47 | extern CircularBuffer<event_t, 64> message_queue; |
foxbrianr | 5:65f21c0b6b79 | 48 | |
foxbrianr | 5:65f21c0b6b79 | 49 | extern CircularBuffer<event_t, 64> event_queue; |
foxbrianr | 5:65f21c0b6b79 | 50 | |
foxbrianr | 5:65f21c0b6b79 | 51 | extern CircularBuffer<playbackMessage_t, 10> playback_queue; |
foxbrianr | 5:65f21c0b6b79 | 52 | |
foxbrianr | 5:65f21c0b6b79 | 53 | |
foxbrianr | 3:ecaf9963341b | 54 | class ESCMControlApp |
foxbrianr | 3:ecaf9963341b | 55 | { |
foxbrianr | 3:ecaf9963341b | 56 | |
foxbrianr | 3:ecaf9963341b | 57 | public: |
foxbrianr | 3:ecaf9963341b | 58 | |
foxbrianr | 3:ecaf9963341b | 59 | void init(void); |
foxbrianr | 3:ecaf9963341b | 60 | void update(void); |
foxbrianr | 5:65f21c0b6b79 | 61 | void processMessageQueue (); |
foxbrianr | 5:65f21c0b6b79 | 62 | void processSoundQueue (); |
foxbrianr | 3:ecaf9963341b | 63 | |
foxbrianr | 3:ecaf9963341b | 64 | //void rx485Message(); |
foxbrianr | 3:ecaf9963341b | 65 | void tx485Message(int address); |
foxbrianr | 3:ecaf9963341b | 66 | void txCanMessage501 (int address); |
foxbrianr | 3:ecaf9963341b | 67 | void txCanMessage502 (int address); |
foxbrianr | 5:65f21c0b6b79 | 68 | void txCanMessage580 (int address); |
foxbrianr | 3:ecaf9963341b | 69 | |
foxbrianr | 3:ecaf9963341b | 70 | static void say (char *format, ...); |
foxbrianr | 5:65f21c0b6b79 | 71 | static void refresh_display (void); |
foxbrianr | 3:ecaf9963341b | 72 | |
foxbrianr | 5:65f21c0b6b79 | 73 | static void getTime(char *timeBuffer); |
foxbrianr | 5:65f21c0b6b79 | 74 | static void setTime(int hours, int mins, int sec, int months, int days, int years ); |
foxbrianr | 5:65f21c0b6b79 | 75 | |
foxbrianr | 5:65f21c0b6b79 | 76 | static void postEvent (uint16_t address); |
foxbrianr | 5:65f21c0b6b79 | 77 | static void postEvent (uint16_t address, uint16_t source); |
foxbrianr | 5:65f21c0b6b79 | 78 | |
foxbrianr | 3:ecaf9963341b | 79 | int cur_address; |
foxbrianr | 3:ecaf9963341b | 80 | |
foxbrianr | 3:ecaf9963341b | 81 | char fault[4]; |
foxbrianr | 5:65f21c0b6b79 | 82 | |
foxbrianr | 5:65f21c0b6b79 | 83 | int dataRxCnt; |
foxbrianr | 5:65f21c0b6b79 | 84 | int dataTxCnt; |
foxbrianr | 5:65f21c0b6b79 | 85 | |
foxbrianr | 5:65f21c0b6b79 | 86 | Mutex event_ctrl ; |
foxbrianr | 5:65f21c0b6b79 | 87 | Mutex emic_ctrl ; |
foxbrianr | 5:65f21c0b6b79 | 88 | Mutex can_ctrl ; |
foxbrianr | 5:65f21c0b6b79 | 89 | Mutex rs485_ctrl; |
foxbrianr | 3:ecaf9963341b | 90 | }; |
foxbrianr | 3:ecaf9963341b | 91 | |
foxbrianr | 5:65f21c0b6b79 | 92 | extern ESCMControlApp escmController; |
foxbrianr | 5:65f21c0b6b79 | 93 | |
foxbrianr | 3:ecaf9963341b | 94 | #endif |