![](/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@7:0244f1a26545, 2019-09-17 (annotated)
- Committer:
- foxbrianr
- Date:
- Tue Sep 17 14:24:27 2019 +0000
- Revision:
- 7:0244f1a26545
- Parent:
- 6:010ceb99f7b0
RC01
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
foxbrianr | 6:010ceb99f7b0 | 1 | /************************************************************************** |
foxbrianr | 6:010ceb99f7b0 | 2 | * @file ESCMControlApp.h |
foxbrianr | 6:010ceb99f7b0 | 3 | * @brief Main class for wrapping the interface with ESCM Control |
foxbrianr | 6:010ceb99f7b0 | 4 | * Application |
foxbrianr | 6:010ceb99f7b0 | 5 | * @version: V1.0 |
foxbrianr | 6:010ceb99f7b0 | 6 | * @date: 9/17/2019 |
foxbrianr | 6:010ceb99f7b0 | 7 | |
foxbrianr | 6:010ceb99f7b0 | 8 | * |
foxbrianr | 6:010ceb99f7b0 | 9 | * @note |
foxbrianr | 6:010ceb99f7b0 | 10 | * Copyright (C) 2019 E3 Design. All rights reserved. |
foxbrianr | 6:010ceb99f7b0 | 11 | * |
foxbrianr | 6:010ceb99f7b0 | 12 | * @par |
foxbrianr | 6:010ceb99f7b0 | 13 | * E3 Designers LLC is supplying this software for use with Cortex-M3 LPC1768 |
foxbrianr | 6:010ceb99f7b0 | 14 | * processor based microcontroller for the ESCM 2000 Monitor and Display. |
foxbrianr | 6:010ceb99f7b0 | 15 | * * |
foxbrianr | 6:010ceb99f7b0 | 16 | * @par |
foxbrianr | 6:010ceb99f7b0 | 17 | * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED |
foxbrianr | 6:010ceb99f7b0 | 18 | * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF |
foxbrianr | 6:010ceb99f7b0 | 19 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. |
foxbrianr | 6:010ceb99f7b0 | 20 | * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR |
foxbrianr | 6:010ceb99f7b0 | 21 | * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. |
foxbrianr | 6:010ceb99f7b0 | 22 | * |
foxbrianr | 6:010ceb99f7b0 | 23 | ******************************************************************************/ |
foxbrianr | 6:010ceb99f7b0 | 24 | #ifndef _ESCM_CONTROL_APP_ |
foxbrianr | 3:ecaf9963341b | 25 | #define _ESCM_CONTROL_APP_ |
foxbrianr | 3:ecaf9963341b | 26 | |
foxbrianr | 3:ecaf9963341b | 27 | |
foxbrianr | 3:ecaf9963341b | 28 | #include "mbed.h" |
foxbrianr | 3:ecaf9963341b | 29 | #include "Menu.h" |
foxbrianr | 6:010ceb99f7b0 | 30 | #include "EditTimeMenu.h" |
foxbrianr | 6:010ceb99f7b0 | 31 | #include "EditAddressMenu.h" |
foxbrianr | 6:010ceb99f7b0 | 32 | #include "DisplayCodesMenu.h" |
foxbrianr | 6:010ceb99f7b0 | 33 | #include "FactoryResetMenu.h" |
foxbrianr | 3:ecaf9963341b | 34 | #include "LCD.h" |
foxbrianr | 3:ecaf9963341b | 35 | #include "AddressMap.h" |
foxbrianr | 3:ecaf9963341b | 36 | #include "EventLog.h" |
foxbrianr | 3:ecaf9963341b | 37 | #include "TimeUtilities.h" |
foxbrianr | 3:ecaf9963341b | 38 | |
foxbrianr | 3:ecaf9963341b | 39 | #include "emic2.h" |
foxbrianr | 3:ecaf9963341b | 40 | |
foxbrianr | 3:ecaf9963341b | 41 | |
foxbrianr | 5:65f21c0b6b79 | 42 | #define LIMIT(x,low,high) x = ((x<=low)? low : ((x>=high) ? high : x )); |
foxbrianr | 6:010ceb99f7b0 | 43 | #define WRAP(x,low,high) ((x<low)?(high-1):((x>high)?0:x)); |
foxbrianr | 5:65f21c0b6b79 | 44 | |
foxbrianr | 5:65f21c0b6b79 | 45 | typedef struct { |
foxbrianr | 5:65f21c0b6b79 | 46 | int event; |
foxbrianr | 5:65f21c0b6b79 | 47 | } event_t; |
foxbrianr | 5:65f21c0b6b79 | 48 | |
foxbrianr | 5:65f21c0b6b79 | 49 | typedef struct { |
foxbrianr | 5:65f21c0b6b79 | 50 | char message[64]; |
foxbrianr | 5:65f21c0b6b79 | 51 | } playbackMessage_t; |
foxbrianr | 5:65f21c0b6b79 | 52 | |
foxbrianr | 6:010ceb99f7b0 | 53 | extern Serial pc; |
foxbrianr | 5:65f21c0b6b79 | 54 | |
foxbrianr | 6:010ceb99f7b0 | 55 | extern LCD lcd; |
foxbrianr | 6:010ceb99f7b0 | 56 | extern Menu rootMenu; |
foxbrianr | 6:010ceb99f7b0 | 57 | extern EditTimeMenu editTime; |
foxbrianr | 6:010ceb99f7b0 | 58 | extern EditAddressMenu editAddress; |
foxbrianr | 6:010ceb99f7b0 | 59 | extern DisplayCodesMenu showEvents; |
foxbrianr | 6:010ceb99f7b0 | 60 | extern FactoryResetMenu factoryReset; |
foxbrianr | 3:ecaf9963341b | 61 | |
foxbrianr | 5:65f21c0b6b79 | 62 | extern AddressMap addressMap; |
foxbrianr | 5:65f21c0b6b79 | 63 | |
foxbrianr | 3:ecaf9963341b | 64 | extern ESCM_EventLog escmEventLog; |
foxbrianr | 3:ecaf9963341b | 65 | |
foxbrianr | 3:ecaf9963341b | 66 | extern RealTimeClock rtc; |
foxbrianr | 3:ecaf9963341b | 67 | |
foxbrianr | 6:010ceb99f7b0 | 68 | extern Serial escmRs485_Input; |
foxbrianr | 6:010ceb99f7b0 | 69 | extern DigitalOut escmRs485_Mode; |
foxbrianr | 3:ecaf9963341b | 70 | |
foxbrianr | 6:010ceb99f7b0 | 71 | extern Serial microCommRs485_Tx; |
foxbrianr | 6:010ceb99f7b0 | 72 | extern DigitalOut microCommRs485_Mode; |
foxbrianr | 3:ecaf9963341b | 73 | |
foxbrianr | 6:010ceb99f7b0 | 74 | extern CAN microCommCanItf; |
foxbrianr | 6:010ceb99f7b0 | 75 | extern DigitalOut microCommCan_Mode; |
foxbrianr | 3:ecaf9963341b | 76 | |
foxbrianr | 3:ecaf9963341b | 77 | extern emic2 speaker; |
foxbrianr | 3:ecaf9963341b | 78 | |
foxbrianr | 5:65f21c0b6b79 | 79 | extern CircularBuffer<event_t, 64> event_queue; |
foxbrianr | 5:65f21c0b6b79 | 80 | |
foxbrianr | 5:65f21c0b6b79 | 81 | extern CircularBuffer<playbackMessage_t, 10> playback_queue; |
foxbrianr | 5:65f21c0b6b79 | 82 | |
foxbrianr | 5:65f21c0b6b79 | 83 | |
foxbrianr | 3:ecaf9963341b | 84 | class ESCMControlApp |
foxbrianr | 3:ecaf9963341b | 85 | { |
foxbrianr | 3:ecaf9963341b | 86 | |
foxbrianr | 3:ecaf9963341b | 87 | public: |
foxbrianr | 3:ecaf9963341b | 88 | |
foxbrianr | 3:ecaf9963341b | 89 | void init(void); |
foxbrianr | 3:ecaf9963341b | 90 | void update(void); |
foxbrianr | 5:65f21c0b6b79 | 91 | void processMessageQueue (); |
foxbrianr | 5:65f21c0b6b79 | 92 | void processSoundQueue (); |
foxbrianr | 3:ecaf9963341b | 93 | |
foxbrianr | 6:010ceb99f7b0 | 94 | void relayMessage(int address); |
foxbrianr | 3:ecaf9963341b | 95 | void tx485Message(int address); |
foxbrianr | 3:ecaf9963341b | 96 | void txCanMessage501 (int address); |
foxbrianr | 3:ecaf9963341b | 97 | void txCanMessage502 (int address); |
foxbrianr | 5:65f21c0b6b79 | 98 | void txCanMessage580 (int address); |
foxbrianr | 3:ecaf9963341b | 99 | |
foxbrianr | 6:010ceb99f7b0 | 100 | static void info (char *format, ...); |
foxbrianr | 6:010ceb99f7b0 | 101 | static void warning (char *format, ...); |
foxbrianr | 6:010ceb99f7b0 | 102 | static void error (char *format, ...); |
foxbrianr | 6:010ceb99f7b0 | 103 | |
foxbrianr | 6:010ceb99f7b0 | 104 | static void say (int address); |
foxbrianr | 3:ecaf9963341b | 105 | static void say (char *format, ...); |
foxbrianr | 5:65f21c0b6b79 | 106 | static void refresh_display (void); |
foxbrianr | 3:ecaf9963341b | 107 | |
foxbrianr | 5:65f21c0b6b79 | 108 | static void getTime(char *timeBuffer); |
foxbrianr | 5:65f21c0b6b79 | 109 | static void setTime(int hours, int mins, int sec, int months, int days, int years ); |
foxbrianr | 5:65f21c0b6b79 | 110 | |
foxbrianr | 5:65f21c0b6b79 | 111 | static void postEvent (uint16_t address, uint16_t source); |
foxbrianr | 5:65f21c0b6b79 | 112 | |
foxbrianr | 3:ecaf9963341b | 113 | int cur_address; |
foxbrianr | 3:ecaf9963341b | 114 | |
foxbrianr | 3:ecaf9963341b | 115 | char fault[4]; |
foxbrianr | 5:65f21c0b6b79 | 116 | |
foxbrianr | 5:65f21c0b6b79 | 117 | int dataRxCnt; |
foxbrianr | 5:65f21c0b6b79 | 118 | int dataTxCnt; |
foxbrianr | 5:65f21c0b6b79 | 119 | |
foxbrianr | 5:65f21c0b6b79 | 120 | Mutex event_ctrl ; |
foxbrianr | 5:65f21c0b6b79 | 121 | Mutex emic_ctrl ; |
foxbrianr | 5:65f21c0b6b79 | 122 | Mutex can_ctrl ; |
foxbrianr | 5:65f21c0b6b79 | 123 | Mutex rs485_ctrl; |
foxbrianr | 3:ecaf9963341b | 124 | }; |
foxbrianr | 3:ecaf9963341b | 125 | |
foxbrianr | 5:65f21c0b6b79 | 126 | extern ESCMControlApp escmController; |
foxbrianr | 5:65f21c0b6b79 | 127 | |
foxbrianr | 3:ecaf9963341b | 128 | #endif |