Repository for import to local machine
Dependencies: DMBasicGUI DMSupport
main.cpp@2:6e94a7fd1e37, 2017-07-20 (annotated)
- Committer:
- jmitc91516
- Date:
- Thu Jul 20 15:31:28 2017 +0000
- Revision:
- 2:6e94a7fd1e37
- Parent:
- 1:a5258871b33d
- Child:
- 3:010aeeacd7d7
Now displays GC state in centre of Home page.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jmitc91516 | 0:47c880c1463d | 1 | #include "mbed.h" |
jmitc91516 | 0:47c880c1463d | 2 | #include "DMBoard.h" |
jmitc91516 | 0:47c880c1463d | 3 | #include "lpc_swim.h" |
jmitc91516 | 0:47c880c1463d | 4 | #include "lpc_swim_font.h" |
jmitc91516 | 0:47c880c1463d | 5 | |
jmitc91516 | 0:47c880c1463d | 6 | #include <string.h> |
jmitc91516 | 0:47c880c1463d | 7 | |
jmitc91516 | 1:a5258871b33d | 8 | #include <stdio.h> |
jmitc91516 | 1:a5258871b33d | 9 | #include <stdlib.h> |
jmitc91516 | 1:a5258871b33d | 10 | |
jmitc91516 | 0:47c880c1463d | 11 | #include "GuiLib.h" |
jmitc91516 | 0:47c880c1463d | 12 | #include "GuiDisplay.h" |
jmitc91516 | 0:47c880c1463d | 13 | |
jmitc91516 | 0:47c880c1463d | 14 | #include "USBHostGC.h" |
jmitc91516 | 0:47c880c1463d | 15 | #include "TouchPanelPageSelector.h" |
jmitc91516 | 0:47c880c1463d | 16 | #include "GCHeatControl.h" |
jmitc91516 | 0:47c880c1463d | 17 | #include "GetGCStatusLoop.h" |
jmitc91516 | 0:47c880c1463d | 18 | #include "GCComponentStatusColorArea.h" |
jmitc91516 | 1:a5258871b33d | 19 | #include "GCStateAndFaultCodes.h" |
jmitc91516 | 1:a5258871b33d | 20 | #include "ProgressBar.h" |
jmitc91516 | 1:a5258871b33d | 21 | #include "EasyGUITouchAreaIndices.h" |
jmitc91516 | 1:a5258871b33d | 22 | #include "NetworkParameters.h" |
jmitc91516 | 1:a5258871b33d | 23 | #include "ServiceInterval.h" |
jmitc91516 | 1:a5258871b33d | 24 | #include "SettingsHandler.h" |
jmitc91516 | 1:a5258871b33d | 25 | #include "GasCalibrationPageHandler.h" |
jmitc91516 | 1:a5258871b33d | 26 | #include "ColumnDHAutoCalibrationPageHandler.h" |
jmitc91516 | 1:a5258871b33d | 27 | #include "ColumnDHManualCalibrationPageHandler.h" |
jmitc91516 | 1:a5258871b33d | 28 | #include "ColumnDHSensorCalibrationPageHandler.h" |
jmitc91516 | 1:a5258871b33d | 29 | #include "ColumnDHPSUDACPageHandler.h" |
jmitc91516 | 1:a5258871b33d | 30 | #include "GasBackPressureDACPageHandler.h" |
jmitc91516 | 1:a5258871b33d | 31 | #include "GasChannelDACAndADCPageHandler.h" |
jmitc91516 | 1:a5258871b33d | 32 | #include "NudgeAndDampPageHandler.h" |
jmitc91516 | 1:a5258871b33d | 33 | #include "NumericKeypadPageHandler.h" |
jmitc91516 | 1:a5258871b33d | 34 | #include "EthernetKeypadPageHandler.h" |
jmitc91516 | 1:a5258871b33d | 35 | #include "DebugCommandsPageHandler.h" |
jmitc91516 | 1:a5258871b33d | 36 | #include "QSPIBitmap.h" |
jmitc91516 | 1:a5258871b33d | 37 | #include "DetectorIgnitionHandler.h" |
jmitc91516 | 1:a5258871b33d | 38 | #include "SwimDraw.h" |
jmitc91516 | 1:a5258871b33d | 39 | #include "USBHostGCUtilities.h" |
jmitc91516 | 1:a5258871b33d | 40 | |
jmitc91516 | 1:a5258871b33d | 41 | |
jmitc91516 | 1:a5258871b33d | 42 | #define BUILD_DATE "20 July 2017" // Copied to easyGUI variable "GuiVar_buildDate", displayed on both Settings pages (normal and Running). |
jmitc91516 | 1:a5258871b33d | 43 | // *** MUST update for each 'delivered' build, MUST correspond with date on 'delivered' binary file *** |
jmitc91516 | 1:a5258871b33d | 44 | // This should be updated first thing every morning, and immediately after every 'delivery' |
jmitc91516 | 1:a5258871b33d | 45 | // (to e.g. "dd mmm yyyy #2"), so that it is ready for the next one. |
jmitc91516 | 1:a5258871b33d | 46 | // Also - 'deliver' the ZIP file produced by the 'Export Program' command (right-click on the project |
jmitc91516 | 1:a5258871b33d | 47 | // in 'Program Workspace' at the left of this screen), as well as the binary executable and the ReadMe.txt file, |
jmitc91516 | 1:a5258871b33d | 48 | // and now the EasyGUI project file as well. |
jmitc91516 | 1:a5258871b33d | 49 | |
jmitc91516 | 1:a5258871b33d | 50 | // Defined in GuiDisplay.c - set the display frame address at runtime |
jmitc91516 | 1:a5258871b33d | 51 | extern "C" { |
jmitc91516 | 1:a5258871b33d | 52 | void GuiDisplay_SetFrameAddress(void *newFrameAddress); |
jmitc91516 | 1:a5258871b33d | 53 | } |
jmitc91516 | 1:a5258871b33d | 54 | |
jmitc91516 | 1:a5258871b33d | 55 | // Used by QSPIBitmaps class |
jmitc91516 | 1:a5258871b33d | 56 | bool qspiAlreadyFormatted = false; |
jmitc91516 | 1:a5258871b33d | 57 | |
jmitc91516 | 1:a5258871b33d | 58 | //#define MEMORY_TEST_OCT_2016 |
jmitc91516 | 1:a5258871b33d | 59 | #ifdef MEMORY_TEST_OCT_2016 |
jmitc91516 | 1:a5258871b33d | 60 | const int clogLength = 1000; |
jmitc91516 | 1:a5258871b33d | 61 | char clogUpMemory[clogLength]; |
jmitc91516 | 1:a5258871b33d | 62 | #endif // MEMORY_TEST_OCT_2016 |
jmitc91516 | 1:a5258871b33d | 63 | |
jmitc91516 | 1:a5258871b33d | 64 | /* |
jmitc91516 | 1:a5258871b33d | 65 | This application provides a draft implementation of the LPC4088 user interface to the GC. |
jmitc91516 | 1:a5258871b33d | 66 | It talks to the GC over a USB link. |
jmitc91516 | 1:a5258871b33d | 67 | |
jmitc91516 | 1:a5258871b33d | 68 | The associated easyGUI project is C:/easyGUI Projects/GC500_5inch.gui |
jmitc91516 | 1:a5258871b33d | 69 | |
jmitc91516 | 1:a5258871b33d | 70 | It is intended for use with the Embedded Artists LPC4088 board, 5 inch display. |
jmitc91516 | 1:a5258871b33d | 71 | |
jmitc91516 | 1:a5258871b33d | 72 | Note that the two most important functions in this application are: |
jmitc91516 | 1:a5258871b33d | 73 | main (obviously) or, more specifically, getGCStatusLoop->MainLoopWithEthernet(), called from main |
jmitc91516 | 1:a5258871b33d | 74 | TouchCallback, which handles the user's interaction with the LPC4088 touch screen |
jmitc91516 | 1:a5258871b33d | 75 | |
jmitc91516 | 1:a5258871b33d | 76 | Most other functions are (ultimately) called by those two. |
jmitc91516 | 1:a5258871b33d | 77 | */ |
jmitc91516 | 1:a5258871b33d | 78 | |
jmitc91516 | 1:a5258871b33d | 79 | // Forward declarations |
jmitc91516 | 1:a5258871b33d | 80 | GuiConst_INTCOLOR SixteenBitColorValue(GuiConst_INT8U red, GuiConst_INT8U green, GuiConst_INT8U blue); |
jmitc91516 | 1:a5258871b33d | 81 | void DrawHeatOnOffButton(void); |
jmitc91516 | 1:a5258871b33d | 82 | void SetupDoorActuatorCommandUserInterface(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC, bool beforePageDisplay); |
jmitc91516 | 1:a5258871b33d | 83 | |
jmitc91516 | 1:a5258871b33d | 84 | |
jmitc91516 | 1:a5258871b33d | 85 | static bool canUnlockDoorActuators = true; // Set false if there is some reason why they cannot be unlocked even when the GC is idle |
jmitc91516 | 1:a5258871b33d | 86 | /* |
jmitc91516 | 1:a5258871b33d | 87 | Function to gives the rest of the world access to the above flag |
jmitc91516 | 1:a5258871b33d | 88 | */ |
jmitc91516 | 1:a5258871b33d | 89 | void CanUnlockDoorActuators(bool value) |
jmitc91516 | 1:a5258871b33d | 90 | { |
jmitc91516 | 1:a5258871b33d | 91 | canUnlockDoorActuators = value; |
jmitc91516 | 1:a5258871b33d | 92 | } |
jmitc91516 | 1:a5258871b33d | 93 | |
jmitc91516 | 1:a5258871b33d | 94 | |
jmitc91516 | 1:a5258871b33d | 95 | //#define ALLOW_DEBUG_PRINTS // Without this, our 'debug print' functions contain no code, and do nothing. |
jmitc91516 | 1:a5258871b33d | 96 | // So we do not have to remove all the debug prints throughout this application - |
jmitc91516 | 1:a5258871b33d | 97 | // just comment out this #define. |
jmitc91516 | 1:a5258871b33d | 98 | // Note that we are currently *not* applying this to the code in the 'DrawErrorMessage()' function, |
jmitc91516 | 1:a5258871b33d | 99 | // which is only used here in main.cpp. |
jmitc91516 | 1:a5258871b33d | 100 | |
jmitc91516 | 1:a5258871b33d | 101 | |
jmitc91516 | 1:a5258871b33d | 102 | /* |
jmitc91516 | 1:a5258871b33d | 103 | Code received from Embedded Artists, to cause the LPC4088 to reboot |
jmitc91516 | 1:a5258871b33d | 104 | (thus allowing us to restart the Ethernet connection with a different IP address) |
jmitc91516 | 1:a5258871b33d | 105 | */ |
jmitc91516 | 1:a5258871b33d | 106 | void reboot() |
jmitc91516 | 1:a5258871b33d | 107 | { |
jmitc91516 | 1:a5258871b33d | 108 | /* Disable watchdog */ |
jmitc91516 | 1:a5258871b33d | 109 | LPC_WDT->MOD = 0; |
jmitc91516 | 1:a5258871b33d | 110 | LPC_WDT->TC = 0xFF; |
jmitc91516 | 1:a5258871b33d | 111 | |
jmitc91516 | 1:a5258871b33d | 112 | /* Set WDT timeout to 0.1s using the 500kHz oscillator |
jmitc91516 | 1:a5258871b33d | 113 | and the fixed pre-scaler of 4 */ |
jmitc91516 | 1:a5258871b33d | 114 | LPC_WDT->TC = ((500000 / 4) / 10); |
jmitc91516 | 1:a5258871b33d | 115 | |
jmitc91516 | 1:a5258871b33d | 116 | /* Make sure a watchdog timeout causes a reset */ |
jmitc91516 | 1:a5258871b33d | 117 | LPC_WDT->MOD |= (1<<1); |
jmitc91516 | 1:a5258871b33d | 118 | |
jmitc91516 | 1:a5258871b33d | 119 | /* Enable the watchdog */ |
jmitc91516 | 1:a5258871b33d | 120 | LPC_WDT->MOD |= (1<<0); |
jmitc91516 | 1:a5258871b33d | 121 | |
jmitc91516 | 1:a5258871b33d | 122 | /* Initial feed to start the watchdog */ |
jmitc91516 | 1:a5258871b33d | 123 | LPC_WDT->FEED = 0xAA; |
jmitc91516 | 1:a5258871b33d | 124 | LPC_WDT->FEED = 0x55; |
jmitc91516 | 1:a5258871b33d | 125 | |
jmitc91516 | 1:a5258871b33d | 126 | /* Should reboot after 100ms */ |
jmitc91516 | 1:a5258871b33d | 127 | while(true); |
jmitc91516 | 1:a5258871b33d | 128 | } |
jmitc91516 | 0:47c880c1463d | 129 | |
jmitc91516 | 0:47c880c1463d | 130 | |
jmitc91516 | 0:47c880c1463d | 131 | // ** Start of timeout code to guard against multiple presses of the Heat On/Off button ** |
jmitc91516 | 0:47c880c1463d | 132 | // (which is in the same position as the Abort Run button) |
jmitc91516 | 0:47c880c1463d | 133 | Timeout heatOnOffTimeout; |
jmitc91516 | 0:47c880c1463d | 134 | |
jmitc91516 | 0:47c880c1463d | 135 | bool heatOnOffAvailable = true; |
jmitc91516 | 0:47c880c1463d | 136 | |
jmitc91516 | 0:47c880c1463d | 137 | void MakeHeatOnOffAvailableAgain(void) |
jmitc91516 | 0:47c880c1463d | 138 | { |
jmitc91516 | 0:47c880c1463d | 139 | heatOnOffAvailable = true; |
jmitc91516 | 0:47c880c1463d | 140 | } |
jmitc91516 | 0:47c880c1463d | 141 | |
jmitc91516 | 0:47c880c1463d | 142 | void StartHeatOnOffTimeout(void) |
jmitc91516 | 0:47c880c1463d | 143 | { |
jmitc91516 | 0:47c880c1463d | 144 | heatOnOffAvailable = false; |
jmitc91516 | 0:47c880c1463d | 145 | heatOnOffTimeout.attach(&MakeHeatOnOffAvailableAgain, 1.0); // Wait 1.0 sec before accepting touches again on Heat On/Off button |
jmitc91516 | 0:47c880c1463d | 146 | } |
jmitc91516 | 0:47c880c1463d | 147 | // ** End of Heat On/Off timeout code ** |
jmitc91516 | 0:47c880c1463d | 148 | |
jmitc91516 | 1:a5258871b33d | 149 | #define USE_HEAT_ONOFF_BUTTON_BITMAPS |
jmitc91516 | 1:a5258871b33d | 150 | |
jmitc91516 | 1:a5258871b33d | 151 | //#define TURN_HEAT_OFF_ON_ABORT // Doing this may or may not be a good idea... |
jmitc91516 | 0:47c880c1463d | 152 | |
jmitc91516 | 0:47c880c1463d | 153 | // These are 'global' - TouchCallback function, as well as main(), needs to access them |
jmitc91516 | 0:47c880c1463d | 154 | TouchPanelPageSelectors touchPanelPageSelectors; |
jmitc91516 | 0:47c880c1463d | 155 | GCHeatControl* theGCHeatControl; |
jmitc91516 | 0:47c880c1463d | 156 | |
jmitc91516 | 1:a5258871b33d | 157 | |
jmitc91516 | 0:47c880c1463d | 158 | GetGCStatusLoop* getGCStatusLoop = NULL; |
jmitc91516 | 0:47c880c1463d | 159 | |
jmitc91516 | 0:47c880c1463d | 160 | HomePageGCComponentStatusColorAreas homePageGCComponentStatusColorAreas; |
jmitc91516 | 0:47c880c1463d | 161 | SingleGCComponentPageStatusColorAreas singleGCComponentPageStatusColorAreas; |
jmitc91516 | 0:47c880c1463d | 162 | |
jmitc91516 | 1:a5258871b33d | 163 | #define USE_QSPI_BITMAPS |
jmitc91516 | 1:a5258871b33d | 164 | #ifdef USE_QSPI_BITMAPS |
jmitc91516 | 1:a5258871b33d | 165 | QSPIBitmaps qspiBitmaps; |
jmitc91516 | 1:a5258871b33d | 166 | #endif // USE_QSPI_BITMAPS |
jmitc91516 | 1:a5258871b33d | 167 | |
jmitc91516 | 1:a5258871b33d | 168 | //#define WANT_STATUS_RECTANGLE_ON_COLUMN_AUTO_CALIB_PAGE |
jmitc91516 | 1:a5258871b33d | 169 | //#define WANT_STATUS_RECTANGLE_ON_GAS_CALIB_PAGES |
jmitc91516 | 0:47c880c1463d | 170 | |
jmitc91516 | 1:a5258871b33d | 171 | /* |
jmitc91516 | 1:a5258871b33d | 172 | Bodge so GuiDisplay.c ('easyGUIFixed' file) can call Thread::wait |
jmitc91516 | 1:a5258871b33d | 173 | (giving it an accurate millisecond timer) |
jmitc91516 | 1:a5258871b33d | 174 | */ |
jmitc91516 | 1:a5258871b33d | 175 | extern "C" { |
jmitc91516 | 1:a5258871b33d | 176 | void EasyGUIWaitMs(GuiConst_INT32U msec) |
jmitc91516 | 1:a5258871b33d | 177 | { |
jmitc91516 | 1:a5258871b33d | 178 | Thread::wait(msec); |
jmitc91516 | 1:a5258871b33d | 179 | } |
jmitc91516 | 1:a5258871b33d | 180 | } |
jmitc91516 | 0:47c880c1463d | 181 | |
jmitc91516 | 1:a5258871b33d | 182 | /* |
jmitc91516 | 1:a5258871b33d | 183 | Passed three 8-bit colour components - red, green and blue. |
jmitc91516 | 1:a5258871b33d | 184 | |
jmitc91516 | 1:a5258871b33d | 185 | Returns the corresponding 16-bit colour value (5 bits for red, 6 bits for green, 5 bits for blue). |
jmitc91516 | 1:a5258871b33d | 186 | */ |
jmitc91516 | 0:47c880c1463d | 187 | GuiConst_INTCOLOR SixteenBitColorValue(GuiConst_INT8U red, GuiConst_INT8U green, GuiConst_INT8U blue) |
jmitc91516 | 0:47c880c1463d | 188 | { |
jmitc91516 | 0:47c880c1463d | 189 | // Make sure we don't have numeric overflow problems during the conversion |
jmitc91516 | 0:47c880c1463d | 190 | GuiConst_INT32U red32 = red; |
jmitc91516 | 0:47c880c1463d | 191 | GuiConst_INT32U green32 = green; |
jmitc91516 | 0:47c880c1463d | 192 | GuiConst_INT32U blue32 = blue; |
jmitc91516 | 0:47c880c1463d | 193 | |
jmitc91516 | 1:a5258871b33d | 194 | //#define REVERSE_RED_AND_BLUE |
jmitc91516 | 1:a5258871b33d | 195 | #ifdef REVERSE_RED_AND_BLUE |
jmitc91516 | 1:a5258871b33d | 196 | GuiConst_INT32U rgb = (red32 << 16) | (green32 << 8) | blue32; |
jmitc91516 | 1:a5258871b33d | 197 | #else |
jmitc91516 | 0:47c880c1463d | 198 | GuiConst_INT32U rgb = (blue32 << 16) | (green32 << 8) | red32; |
jmitc91516 | 1:a5258871b33d | 199 | #endif |
jmitc91516 | 1:a5258871b33d | 200 | |
jmitc91516 | 0:47c880c1463d | 201 | return GuiLib_RgbToPixelColor(rgb); |
jmitc91516 | 0:47c880c1463d | 202 | } |
jmitc91516 | 0:47c880c1463d | 203 | |
jmitc91516 | 1:a5258871b33d | 204 | // DebugPrint without '#ifdef ALLOW_DEBUG_PRINTS' |
jmitc91516 | 1:a5258871b33d | 205 | void SpecialDebugPrint(char *stuffToPrint, GuiConst_INT16S X, GuiConst_INT16S Y) |
jmitc91516 | 1:a5258871b33d | 206 | { |
jmitc91516 | 1:a5258871b33d | 207 | static int counter = 0; |
jmitc91516 | 1:a5258871b33d | 208 | char buff[300]; |
jmitc91516 | 1:a5258871b33d | 209 | |
jmitc91516 | 1:a5258871b33d | 210 | const GuiConst_INT16U fontNo = GuiFont_Helv1; |
jmitc91516 | 1:a5258871b33d | 211 | |
jmitc91516 | 1:a5258871b33d | 212 | GuiDisplay_Lock(); |
jmitc91516 | 1:a5258871b33d | 213 | |
jmitc91516 | 1:a5258871b33d | 214 | // (Attempt to) clear previous strings from display |
jmitc91516 | 1:a5258871b33d | 215 | sprintf(buff, " "); |
jmitc91516 | 1:a5258871b33d | 216 | GuiLib_DrawStr( |
jmitc91516 | 1:a5258871b33d | 217 | X, //GuiConst_INT16S X, |
jmitc91516 | 1:a5258871b33d | 218 | Y, //GuiConst_INT16S Y, |
jmitc91516 | 1:a5258871b33d | 219 | fontNo, //GuiConst_INT16U FontNo, |
jmitc91516 | 1:a5258871b33d | 220 | buff, //GuiConst_TEXT PrefixLocate *String, |
jmitc91516 | 1:a5258871b33d | 221 | GuiLib_ALIGN_LEFT, //GuiConst_INT8U Alignment, |
jmitc91516 | 1:a5258871b33d | 222 | GuiLib_PS_ON, //GuiConst_INT8U PsWriting, |
jmitc91516 | 1:a5258871b33d | 223 | GuiLib_TRANSPARENT_OFF, //GuiConst_INT8U Transparent, |
jmitc91516 | 1:a5258871b33d | 224 | GuiLib_UNDERLINE_OFF, //GuiConst_INT8U Underlining, |
jmitc91516 | 1:a5258871b33d | 225 | 0, //GuiConst_INT16S BackBoxSizeX, |
jmitc91516 | 1:a5258871b33d | 226 | 0, //GuiConst_INT16S BackBoxSizeY1, |
jmitc91516 | 1:a5258871b33d | 227 | 0, //GuiConst_INT16S BackBoxSizeY2, |
jmitc91516 | 1:a5258871b33d | 228 | GuiLib_BBP_NONE, //GuiConst_INT8U BackBorderPixels, |
jmitc91516 | 1:a5258871b33d | 229 | SixteenBitColorValue(0, 0, 0xFF), //GuiConst_INTCOLOR ForeColor, |
jmitc91516 | 1:a5258871b33d | 230 | SixteenBitColorValue(0, 0xFF, 0) //GuiConst_INTCOLOR BackColor |
jmitc91516 | 1:a5258871b33d | 231 | ); |
jmitc91516 | 1:a5258871b33d | 232 | |
jmitc91516 | 1:a5258871b33d | 233 | sprintf(buff, "%s [%d]", stuffToPrint, ++counter); |
jmitc91516 | 1:a5258871b33d | 234 | |
jmitc91516 | 1:a5258871b33d | 235 | GuiLib_DrawStr( |
jmitc91516 | 1:a5258871b33d | 236 | X, //GuiConst_INT16S X, |
jmitc91516 | 1:a5258871b33d | 237 | Y, //GuiConst_INT16S Y, |
jmitc91516 | 1:a5258871b33d | 238 | fontNo, //GuiConst_INT16U FontNo, |
jmitc91516 | 1:a5258871b33d | 239 | buff, //GuiConst_TEXT PrefixLocate *String, |
jmitc91516 | 1:a5258871b33d | 240 | GuiLib_ALIGN_LEFT, //GuiConst_INT8U Alignment, |
jmitc91516 | 1:a5258871b33d | 241 | GuiLib_PS_ON, //GuiConst_INT8U PsWriting, |
jmitc91516 | 1:a5258871b33d | 242 | GuiLib_TRANSPARENT_OFF, //GuiConst_INT8U Transparent, |
jmitc91516 | 1:a5258871b33d | 243 | GuiLib_UNDERLINE_OFF, //GuiConst_INT8U Underlining, |
jmitc91516 | 1:a5258871b33d | 244 | 0, //GuiConst_INT16S BackBoxSizeX, |
jmitc91516 | 1:a5258871b33d | 245 | 0, //GuiConst_INT16S BackBoxSizeY1, |
jmitc91516 | 1:a5258871b33d | 246 | 0, //GuiConst_INT16S BackBoxSizeY2, |
jmitc91516 | 1:a5258871b33d | 247 | GuiLib_BBP_NONE, //GuiConst_INT8U BackBorderPixels, |
jmitc91516 | 1:a5258871b33d | 248 | SixteenBitColorValue(0, 0, 0xFF), //GuiConst_INTCOLOR ForeColor, |
jmitc91516 | 1:a5258871b33d | 249 | SixteenBitColorValue(0, 0xFF, 0) //GuiConst_INTCOLOR BackColor |
jmitc91516 | 1:a5258871b33d | 250 | ); |
jmitc91516 | 1:a5258871b33d | 251 | |
jmitc91516 | 1:a5258871b33d | 252 | GuiLib_Refresh(); |
jmitc91516 | 1:a5258871b33d | 253 | |
jmitc91516 | 1:a5258871b33d | 254 | GuiDisplay_Unlock(); |
jmitc91516 | 1:a5258871b33d | 255 | } |
jmitc91516 | 1:a5258871b33d | 256 | |
jmitc91516 | 1:a5258871b33d | 257 | /* |
jmitc91516 | 1:a5258871b33d | 258 | Prints (i.e. displays) the specified text at the specified coordinates on the screen, |
jmitc91516 | 1:a5258871b33d | 259 | blue text on a green background, using easyGUI. |
jmitc91516 | 1:a5258871b33d | 260 | |
jmitc91516 | 1:a5258871b33d | 261 | Args are: null-terminated string to print, x coord, y coord. |
jmitc91516 | 1:a5258871b33d | 262 | |
jmitc91516 | 1:a5258871b33d | 263 | No return code. |
jmitc91516 | 1:a5258871b33d | 264 | */ |
jmitc91516 | 0:47c880c1463d | 265 | void DebugPrint(char *stuffToPrint, GuiConst_INT16S X, GuiConst_INT16S Y) |
jmitc91516 | 0:47c880c1463d | 266 | { |
jmitc91516 | 1:a5258871b33d | 267 | #ifdef ALLOW_DEBUG_PRINTS |
jmitc91516 | 0:47c880c1463d | 268 | char buff[200]; |
jmitc91516 | 0:47c880c1463d | 269 | |
jmitc91516 | 0:47c880c1463d | 270 | const GuiConst_INT16U fontNo = GuiFont_Helv1; |
jmitc91516 | 0:47c880c1463d | 271 | |
jmitc91516 | 0:47c880c1463d | 272 | GuiDisplay_Lock(); |
jmitc91516 | 0:47c880c1463d | 273 | |
jmitc91516 | 0:47c880c1463d | 274 | // (Attempt to) clear previous strings from display |
jmitc91516 | 0:47c880c1463d | 275 | sprintf(buff, " "); |
jmitc91516 | 0:47c880c1463d | 276 | GuiLib_DrawStr( |
jmitc91516 | 0:47c880c1463d | 277 | X, //GuiConst_INT16S X, |
jmitc91516 | 0:47c880c1463d | 278 | Y, //GuiConst_INT16S Y, |
jmitc91516 | 0:47c880c1463d | 279 | fontNo, //GuiConst_INT16U FontNo, |
jmitc91516 | 0:47c880c1463d | 280 | buff, //GuiConst_TEXT PrefixLocate *String, |
jmitc91516 | 0:47c880c1463d | 281 | GuiLib_ALIGN_LEFT, //GuiConst_INT8U Alignment, |
jmitc91516 | 0:47c880c1463d | 282 | GuiLib_PS_ON, //GuiConst_INT8U PsWriting, |
jmitc91516 | 0:47c880c1463d | 283 | GuiLib_TRANSPARENT_OFF, //GuiConst_INT8U Transparent, |
jmitc91516 | 0:47c880c1463d | 284 | GuiLib_UNDERLINE_OFF, //GuiConst_INT8U Underlining, |
jmitc91516 | 0:47c880c1463d | 285 | 0, //GuiConst_INT16S BackBoxSizeX, |
jmitc91516 | 0:47c880c1463d | 286 | 0, //GuiConst_INT16S BackBoxSizeY1, |
jmitc91516 | 0:47c880c1463d | 287 | 0, //GuiConst_INT16S BackBoxSizeY2, |
jmitc91516 | 0:47c880c1463d | 288 | GuiLib_BBP_NONE, //GuiConst_INT8U BackBorderPixels, |
jmitc91516 | 0:47c880c1463d | 289 | SixteenBitColorValue(0, 0, 0xFF), //GuiConst_INTCOLOR ForeColor, |
jmitc91516 | 0:47c880c1463d | 290 | SixteenBitColorValue(0, 0xFF, 0) //GuiConst_INTCOLOR BackColor |
jmitc91516 | 0:47c880c1463d | 291 | ); |
jmitc91516 | 0:47c880c1463d | 292 | |
jmitc91516 | 0:47c880c1463d | 293 | GuiLib_DrawStr( |
jmitc91516 | 0:47c880c1463d | 294 | X, //GuiConst_INT16S X, |
jmitc91516 | 0:47c880c1463d | 295 | Y, //GuiConst_INT16S Y, |
jmitc91516 | 0:47c880c1463d | 296 | fontNo, //GuiConst_INT16U FontNo, |
jmitc91516 | 0:47c880c1463d | 297 | stuffToPrint, //GuiConst_TEXT PrefixLocate *String, |
jmitc91516 | 0:47c880c1463d | 298 | GuiLib_ALIGN_LEFT, //GuiConst_INT8U Alignment, |
jmitc91516 | 0:47c880c1463d | 299 | GuiLib_PS_ON, //GuiConst_INT8U PsWriting, |
jmitc91516 | 0:47c880c1463d | 300 | GuiLib_TRANSPARENT_OFF, //GuiConst_INT8U Transparent, |
jmitc91516 | 0:47c880c1463d | 301 | GuiLib_UNDERLINE_OFF, //GuiConst_INT8U Underlining, |
jmitc91516 | 0:47c880c1463d | 302 | 0, //GuiConst_INT16S BackBoxSizeX, |
jmitc91516 | 0:47c880c1463d | 303 | 0, //GuiConst_INT16S BackBoxSizeY1, |
jmitc91516 | 0:47c880c1463d | 304 | 0, //GuiConst_INT16S BackBoxSizeY2, |
jmitc91516 | 0:47c880c1463d | 305 | GuiLib_BBP_NONE, //GuiConst_INT8U BackBorderPixels, |
jmitc91516 | 0:47c880c1463d | 306 | SixteenBitColorValue(0, 0, 0xFF), //GuiConst_INTCOLOR ForeColor, |
jmitc91516 | 0:47c880c1463d | 307 | SixteenBitColorValue(0, 0xFF, 0) //GuiConst_INTCOLOR BackColor |
jmitc91516 | 0:47c880c1463d | 308 | ); |
jmitc91516 | 0:47c880c1463d | 309 | |
jmitc91516 | 0:47c880c1463d | 310 | GuiLib_Refresh(); |
jmitc91516 | 0:47c880c1463d | 311 | |
jmitc91516 | 0:47c880c1463d | 312 | GuiDisplay_Unlock(); |
jmitc91516 | 1:a5258871b33d | 313 | #endif //ALLOW_DEBUG_PRINTS |
jmitc91516 | 0:47c880c1463d | 314 | } |
jmitc91516 | 0:47c880c1463d | 315 | |
jmitc91516 | 1:a5258871b33d | 316 | /* |
jmitc91516 | 1:a5258871b33d | 317 | A 'wrapper' function for the above, so that the caller does not need access |
jmitc91516 | 1:a5258871b33d | 318 | to the easyGUI declarations |
jmitc91516 | 1:a5258871b33d | 319 | |
jmitc91516 | 1:a5258871b33d | 320 | Intended to be used as an 'extern' in other modules. |
jmitc91516 | 1:a5258871b33d | 321 | */ |
jmitc91516 | 0:47c880c1463d | 322 | void EasyGUIDebugPrint(char *stuffToPrint, short X, short Y) |
jmitc91516 | 0:47c880c1463d | 323 | { |
jmitc91516 | 1:a5258871b33d | 324 | #ifdef ALLOW_DEBUG_PRINTS |
jmitc91516 | 0:47c880c1463d | 325 | DebugPrint(stuffToPrint, (GuiConst_INT16S) X, (GuiConst_INT16S) Y); |
jmitc91516 | 1:a5258871b33d | 326 | #endif // ALLOW_DEBUG_PRINTS |
jmitc91516 | 0:47c880c1463d | 327 | } |
jmitc91516 | 0:47c880c1463d | 328 | |
jmitc91516 | 1:a5258871b33d | 329 | /* |
jmitc91516 | 1:a5258871b33d | 330 | Version of the above that increments, and displays, a counter each time it is called - |
jmitc91516 | 1:a5258871b33d | 331 | so the user can see if it is being called repeatedly, or if the application has simply hung |
jmitc91516 | 1:a5258871b33d | 332 | */ |
jmitc91516 | 1:a5258871b33d | 333 | void EasyGUIDebugPrintWithCounter(char *stuffToPrint, short X, short Y) |
jmitc91516 | 0:47c880c1463d | 334 | { |
jmitc91516 | 1:a5258871b33d | 335 | #ifdef ALLOW_DEBUG_PRINTS |
jmitc91516 | 1:a5258871b33d | 336 | static int counter = 0; |
jmitc91516 | 1:a5258871b33d | 337 | char buff[300]; |
jmitc91516 | 1:a5258871b33d | 338 | sprintf(buff, "%s [%d]", stuffToPrint, ++counter); |
jmitc91516 | 1:a5258871b33d | 339 | |
jmitc91516 | 1:a5258871b33d | 340 | DebugPrint(buff, (GuiConst_INT16S) X, (GuiConst_INT16S) Y); |
jmitc91516 | 1:a5258871b33d | 341 | #endif // ALLOW_DEBUG_PRINTS |
jmitc91516 | 0:47c880c1463d | 342 | } |
jmitc91516 | 0:47c880c1463d | 343 | |
jmitc91516 | 1:a5258871b33d | 344 | extern "C" { |
jmitc91516 | 1:a5258871b33d | 345 | void EasyGUIDebugPrintWithCounterCalledFromC(char *stuffToPrint, short X, short Y) |
jmitc91516 | 1:a5258871b33d | 346 | { |
jmitc91516 | 1:a5258871b33d | 347 | EasyGUIDebugPrintWithCounter(stuffToPrint, X, Y); |
jmitc91516 | 1:a5258871b33d | 348 | } |
jmitc91516 | 0:47c880c1463d | 349 | } |
jmitc91516 | 0:47c880c1463d | 350 | |
jmitc91516 | 1:a5258871b33d | 351 | /* |
jmitc91516 | 1:a5258871b33d | 352 | Gets the GC status. |
jmitc91516 | 1:a5258871b33d | 353 | |
jmitc91516 | 1:a5258871b33d | 354 | Args are: a pointer to the USBHostGC instance that corresponds to the GC, |
jmitc91516 | 1:a5258871b33d | 355 | a pointer to the USBDeviceConnected instance that (also) corresponds to the GC |
jmitc91516 | 1:a5258871b33d | 356 | |
jmitc91516 | 1:a5258871b33d | 357 | Returns the GC status as an integer - see the GC_STATE enumeration in GCStateAndFaultCodes.h |
jmitc91516 | 1:a5258871b33d | 358 | for the possible values. |
jmitc91516 | 1:a5258871b33d | 359 | */ |
jmitc91516 | 1:a5258871b33d | 360 | int GetGCStatus(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC) |
jmitc91516 | 0:47c880c1463d | 361 | { |
jmitc91516 | 0:47c880c1463d | 362 | while(usbHostGC->ExecutingSetDeviceReport()) {} |
jmitc91516 | 0:47c880c1463d | 363 | |
jmitc91516 | 0:47c880c1463d | 364 | char response[50]; |
jmitc91516 | 1:a5258871b33d | 365 | int status; |
jmitc91516 | 0:47c880c1463d | 366 | |
jmitc91516 | 0:47c880c1463d | 367 | // Ensure we always have valid chars in the positions we are interested in, |
jmitc91516 | 0:47c880c1463d | 368 | // in case we get "DNAK" or "EPKT" back |
jmitc91516 | 0:47c880c1463d | 369 | response[6] = '0'; |
jmitc91516 | 0:47c880c1463d | 370 | response[7] = '0'; |
jmitc91516 | 0:47c880c1463d | 371 | |
jmitc91516 | 0:47c880c1463d | 372 | usbHostGC->SetDeviceReport(usbDevice, "QSTA", response); |
jmitc91516 | 1:a5258871b33d | 373 | // We expect a response like "DSTA00nn", where "nn" is the status. |
jmitc91516 | 1:a5258871b33d | 374 | sscanf(&response[6], "%d", &status); |
jmitc91516 | 1:a5258871b33d | 375 | |
jmitc91516 | 1:a5258871b33d | 376 | return status; |
jmitc91516 | 1:a5258871b33d | 377 | } |
jmitc91516 | 1:a5258871b33d | 378 | |
jmitc91516 | 1:a5258871b33d | 379 | /* |
jmitc91516 | 1:a5258871b33d | 380 | Tells the caller whether or not the GC is ready to run |
jmitc91516 | 1:a5258871b33d | 381 | |
jmitc91516 | 1:a5258871b33d | 382 | Args are: a pointer to the USBHostGC instance that corresponds to the GC, |
jmitc91516 | 1:a5258871b33d | 383 | a pointer to the USBDeviceConnected instance that (also) corresponds to the GC |
jmitc91516 | 1:a5258871b33d | 384 | |
jmitc91516 | 1:a5258871b33d | 385 | Returns true if the GC is ready to run, false if not. |
jmitc91516 | 1:a5258871b33d | 386 | */ |
jmitc91516 | 1:a5258871b33d | 387 | bool GCIsReadyToRun(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC) |
jmitc91516 | 1:a5258871b33d | 388 | { |
jmitc91516 | 1:a5258871b33d | 389 | #ifdef USE_VERSION_102 // See GCStateAndFaultCodes.h |
jmitc91516 | 1:a5258871b33d | 390 | return (GetGCStatus(usbDevice, usbHostGC) == GC_STATE_102_METHOD_READY_TO_RUN); |
jmitc91516 | 1:a5258871b33d | 391 | #else |
jmitc91516 | 1:a5258871b33d | 392 | return (GetGCStatus(usbDevice, usbHostGC) == GC_STATE_READY_TO_RUN); |
jmitc91516 | 1:a5258871b33d | 393 | #endif |
jmitc91516 | 1:a5258871b33d | 394 | } |
jmitc91516 | 1:a5258871b33d | 395 | |
jmitc91516 | 1:a5258871b33d | 396 | /* |
jmitc91516 | 1:a5258871b33d | 397 | Tells the caller whether or not the GC is in the 'stabilising' state |
jmitc91516 | 0:47c880c1463d | 398 | |
jmitc91516 | 1:a5258871b33d | 399 | Args are: a pointer to the USBHostGC instance that corresponds to the GC, |
jmitc91516 | 1:a5258871b33d | 400 | a pointer to the USBDeviceConnected instance that (also) corresponds to the GC |
jmitc91516 | 1:a5258871b33d | 401 | |
jmitc91516 | 1:a5258871b33d | 402 | Returns true if the GC is stabilising, false if not. |
jmitc91516 | 1:a5258871b33d | 403 | */ |
jmitc91516 | 1:a5258871b33d | 404 | bool GCIsStabilising(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC) |
jmitc91516 | 1:a5258871b33d | 405 | { |
jmitc91516 | 1:a5258871b33d | 406 | #ifdef USE_VERSION_102 // See GCStateAndFaultCodes.h |
jmitc91516 | 1:a5258871b33d | 407 | return (GetGCStatus(usbDevice, usbHostGC) == GC_STATE_102_METHOD_STABILISING); |
jmitc91516 | 1:a5258871b33d | 408 | #else |
jmitc91516 | 1:a5258871b33d | 409 | return false; // No "stabilising" state before version 1.02 |
jmitc91516 | 1:a5258871b33d | 410 | #endif |
jmitc91516 | 1:a5258871b33d | 411 | } |
jmitc91516 | 1:a5258871b33d | 412 | |
jmitc91516 | 1:a5258871b33d | 413 | /* |
jmitc91516 | 1:a5258871b33d | 414 | Tells the caller whether or not the GC is in the 'equilibrating' state |
jmitc91516 | 1:a5258871b33d | 415 | |
jmitc91516 | 1:a5258871b33d | 416 | Args are: a pointer to the USBHostGC instance that corresponds to the GC, |
jmitc91516 | 1:a5258871b33d | 417 | a pointer to the USBDeviceConnected instance that (also) corresponds to the GC |
jmitc91516 | 1:a5258871b33d | 418 | |
jmitc91516 | 1:a5258871b33d | 419 | Returns true if the GC is equilibrating, false if not. |
jmitc91516 | 1:a5258871b33d | 420 | */ |
jmitc91516 | 1:a5258871b33d | 421 | bool GCIsEquilibrating(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC) |
jmitc91516 | 1:a5258871b33d | 422 | { |
jmitc91516 | 1:a5258871b33d | 423 | #ifdef USE_VERSION_102 // See GCStateAndFaultCodes.h |
jmitc91516 | 1:a5258871b33d | 424 | return (GetGCStatus(usbDevice, usbHostGC) == GC_STATE_102_METHOD_EQUILIBRATING); |
jmitc91516 | 1:a5258871b33d | 425 | #else |
jmitc91516 | 1:a5258871b33d | 426 | return (GetGCStatus(usbDevice, usbHostGC) == GC_STATE_EQUILIBRATING); |
jmitc91516 | 1:a5258871b33d | 427 | #endif |
jmitc91516 | 0:47c880c1463d | 428 | } |
jmitc91516 | 0:47c880c1463d | 429 | |
jmitc91516 | 1:a5258871b33d | 430 | /* |
jmitc91516 | 1:a5258871b33d | 431 | Tells the caller whether or not the GC is running |
jmitc91516 | 1:a5258871b33d | 432 | |
jmitc91516 | 1:a5258871b33d | 433 | Args are: a pointer to the USBHostGC instance that corresponds to the GC, |
jmitc91516 | 1:a5258871b33d | 434 | a pointer to the USBDeviceConnected instance that (also) corresponds to the GC |
jmitc91516 | 1:a5258871b33d | 435 | |
jmitc91516 | 1:a5258871b33d | 436 | Returns true if the GC is running, false if not. |
jmitc91516 | 1:a5258871b33d | 437 | */ |
jmitc91516 | 1:a5258871b33d | 438 | bool GCIsRunning(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC) |
jmitc91516 | 1:a5258871b33d | 439 | { |
jmitc91516 | 1:a5258871b33d | 440 | int gcStatus = GetGCStatus(usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 441 | |
jmitc91516 | 1:a5258871b33d | 442 | #ifdef USE_VERSION_102 // See GCStateAndFaultCodes.h |
jmitc91516 | 1:a5258871b33d | 443 | return ((gcStatus >= GC_STATE_102_METHOD_RUNNING_MINIMUM) && (gcStatus <= GC_STATE_102_METHOD_RUNNING_MAXIMUM)); |
jmitc91516 | 1:a5258871b33d | 444 | #else |
jmitc91516 | 1:a5258871b33d | 445 | return ((gcStatus >= GC_STATE_RUNNING_MINIMUM) && (gcStatus <= GC_STATE_RUNNING_MAXIMUM)); |
jmitc91516 | 1:a5258871b33d | 446 | #endif |
jmitc91516 | 1:a5258871b33d | 447 | } |
jmitc91516 | 1:a5258871b33d | 448 | |
jmitc91516 | 1:a5258871b33d | 449 | /* |
jmitc91516 | 1:a5258871b33d | 450 | Pass the current value of 'GuiVar_columnMaxTemp2' to the GC as the maximum column temperature. |
jmitc91516 | 1:a5258871b33d | 451 | Intended to be called by the NumericKeypadPageHandler if the user presses the Apply button |
jmitc91516 | 1:a5258871b33d | 452 | when we are editing the maximum column temperature. We pass a pointer to this function |
jmitc91516 | 1:a5258871b33d | 453 | to the NumericKeypadPageHandler instance when we start editing. |
jmitc91516 | 1:a5258871b33d | 454 | |
jmitc91516 | 1:a5258871b33d | 455 | See the definition of 'ApplyFunctionPtr' in NumericKeypadPageHandler.h |
jmitc91516 | 1:a5258871b33d | 456 | */ |
jmitc91516 | 1:a5258871b33d | 457 | void SetColumnMaxTempFromEasyGuiVariable(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC) |
jmitc91516 | 1:a5258871b33d | 458 | { |
jmitc91516 | 1:a5258871b33d | 459 | int maxTemp; |
jmitc91516 | 1:a5258871b33d | 460 | sscanf(GuiVar_columnMaxTemp2, "%d", &maxTemp); |
jmitc91516 | 1:a5258871b33d | 461 | |
jmitc91516 | 1:a5258871b33d | 462 | char buff[40]; |
jmitc91516 | 1:a5258871b33d | 463 | sprintf(buff, "SCMX%.4d", maxTemp); |
jmitc91516 | 1:a5258871b33d | 464 | |
jmitc91516 | 1:a5258871b33d | 465 | while(usbHostGC->ExecutingSetDeviceReport()) {} |
jmitc91516 | 1:a5258871b33d | 466 | |
jmitc91516 | 1:a5258871b33d | 467 | char response[50]; |
jmitc91516 | 1:a5258871b33d | 468 | usbHostGC->SetDeviceReport(usbDevice, buff, response); |
jmitc91516 | 1:a5258871b33d | 469 | } |
jmitc91516 | 1:a5258871b33d | 470 | |
jmitc91516 | 1:a5258871b33d | 471 | |
jmitc91516 | 1:a5258871b33d | 472 | /* |
jmitc91516 | 1:a5258871b33d | 473 | Draws the Run button in the correct place, in the correct enabled/disabled state. |
jmitc91516 | 1:a5258871b33d | 474 | |
jmitc91516 | 1:a5258871b33d | 475 | Arg is: true to display the button in an enabled state, false to display it disabled. |
jmitc91516 | 1:a5258871b33d | 476 | |
jmitc91516 | 1:a5258871b33d | 477 | No return code. |
jmitc91516 | 1:a5258871b33d | 478 | */ |
jmitc91516 | 0:47c880c1463d | 479 | void DrawRunButton(bool enabled) |
jmitc91516 | 0:47c880c1463d | 480 | { |
jmitc91516 | 1:a5258871b33d | 481 | #define USE_BITMAPS |
jmitc91516 | 1:a5258871b33d | 482 | #ifdef USE_BITMAPS |
jmitc91516 | 2:6e94a7fd1e37 | 483 | GuiConst_INT8U bitmapIndex = GuiStruct_Bitmap_RunButtonBlank; |
jmitc91516 | 1:a5258871b33d | 484 | if(enabled) { |
jmitc91516 | 1:a5258871b33d | 485 | bitmapIndex = GuiStruct_Bitmap_RunButtonGreen; |
jmitc91516 | 1:a5258871b33d | 486 | } |
jmitc91516 | 1:a5258871b33d | 487 | GuiConst_INTCOLOR transparentColor = SixteenBitColorValue(255, 255, 255); // In the 'corners' of the bitmap |
jmitc91516 | 1:a5258871b33d | 488 | |
jmitc91516 | 1:a5258871b33d | 489 | // Hard coded coordinates copied from easyGUI (I have not found |
jmitc91516 | 1:a5258871b33d | 490 | // a way of getting them from the easyGUI code at runtime) |
jmitc91516 | 1:a5258871b33d | 491 | GuiLib_ShowBitmap(bitmapIndex, 327, 170, transparentColor); |
jmitc91516 | 1:a5258871b33d | 492 | |
jmitc91516 | 1:a5258871b33d | 493 | #else // Draw a 'button' that consists of a box containing the word 'Run'. |
jmitc91516 | 1:a5258871b33d | 494 | |
jmitc91516 | 0:47c880c1463d | 495 | // Black if enabled, grey if disabled |
jmitc91516 | 0:47c880c1463d | 496 | GuiConst_INTCOLOR buttonColor = (enabled) ? 0 : SixteenBitColorValue(0x80, 0x80, 0x80); |
jmitc91516 | 0:47c880c1463d | 497 | |
jmitc91516 | 0:47c880c1463d | 498 | GuiConst_TEXT *buttonText = "Run"; |
jmitc91516 | 0:47c880c1463d | 499 | |
jmitc91516 | 0:47c880c1463d | 500 | // These are hard-coded to match the corresponding definitions in easyGUI |
jmitc91516 | 0:47c880c1463d | 501 | // (I have not found a way of getting these values from easyGUI at run time) |
jmitc91516 | 0:47c880c1463d | 502 | const GuiConst_INT16S textX1 = 400; |
jmitc91516 | 0:47c880c1463d | 503 | const GuiConst_INT16S textY1 = 220; |
jmitc91516 | 0:47c880c1463d | 504 | const GuiConst_INT16U textFont = GuiFont_Helv1; |
jmitc91516 | 0:47c880c1463d | 505 | |
jmitc91516 | 0:47c880c1463d | 506 | const GuiConst_INT16S boxX1 = 338; |
jmitc91516 | 0:47c880c1463d | 507 | const GuiConst_INT16S boxY1 = 195; |
jmitc91516 | 0:47c880c1463d | 508 | const GuiConst_INT16S boxX2 = 462; |
jmitc91516 | 0:47c880c1463d | 509 | const GuiConst_INT16S boxY2 = 235; |
jmitc91516 | 0:47c880c1463d | 510 | |
jmitc91516 | 0:47c880c1463d | 511 | GuiLib_Box(boxX1, boxY1, boxX2, boxY2, buttonColor); |
jmitc91516 | 0:47c880c1463d | 512 | |
jmitc91516 | 0:47c880c1463d | 513 | GuiLib_DrawStr( |
jmitc91516 | 0:47c880c1463d | 514 | textX1, //GuiConst_INT16S X, |
jmitc91516 | 0:47c880c1463d | 515 | textY1, //GuiConst_INT16S Y, |
jmitc91516 | 0:47c880c1463d | 516 | textFont, //GuiConst_INT16U FontNo, |
jmitc91516 | 0:47c880c1463d | 517 | buttonText, //GuiConst_TEXT PrefixLocate *String, |
jmitc91516 | 0:47c880c1463d | 518 | GuiLib_ALIGN_CENTER, //GuiConst_INT8U Alignment, |
jmitc91516 | 0:47c880c1463d | 519 | GuiLib_PS_ON, //GuiConst_INT8U PsWriting, |
jmitc91516 | 0:47c880c1463d | 520 | GuiLib_TRANSPARENT_ON, //GuiConst_INT8U Transparent, |
jmitc91516 | 0:47c880c1463d | 521 | GuiLib_UNDERLINE_OFF, //GuiConst_INT8U Underlining, |
jmitc91516 | 0:47c880c1463d | 522 | 0, //GuiConst_INT16S BackBoxSizeX, |
jmitc91516 | 0:47c880c1463d | 523 | 0, //GuiConst_INT16S BackBoxSizeY1, |
jmitc91516 | 0:47c880c1463d | 524 | 0, //GuiConst_INT16S BackBoxSizeY2, |
jmitc91516 | 0:47c880c1463d | 525 | GuiLib_BBP_NONE, //GuiConst_INT8U BackBorderPixels, |
jmitc91516 | 0:47c880c1463d | 526 | buttonColor, //GuiConst_INTCOLOR ForeColor, |
jmitc91516 | 0:47c880c1463d | 527 | SixteenBitColorValue(0xFF, 0xFF, 0xFF) //GuiConst_INTCOLOR BackColor (should be ignored with GuiLib_TRANSPARENT_ON) |
jmitc91516 | 0:47c880c1463d | 528 | ); |
jmitc91516 | 1:a5258871b33d | 529 | #endif // USE_BITMAPS |
jmitc91516 | 1:a5258871b33d | 530 | } |
jmitc91516 | 1:a5258871b33d | 531 | |
jmitc91516 | 1:a5258871b33d | 532 | |
jmitc91516 | 1:a5258871b33d | 533 | // Make these values available to the rest of the application |
jmitc91516 | 1:a5258871b33d | 534 | GuiConst_INTCOLOR GetFakeBackgroundBitmapMainColour(void) |
jmitc91516 | 1:a5258871b33d | 535 | { |
jmitc91516 | 1:a5258871b33d | 536 | return SixteenBitColorValue(173, 222, 231); // From Background317 bitmap |
jmitc91516 | 1:a5258871b33d | 537 | //return SixteenBitColorValue(0, 148, 165); // From Background320 bitmap |
jmitc91516 | 1:a5258871b33d | 538 | } |
jmitc91516 | 1:a5258871b33d | 539 | |
jmitc91516 | 1:a5258871b33d | 540 | GuiConst_INTCOLOR GetFakeBackgroundBitmapButtonBandColour(void) |
jmitc91516 | 1:a5258871b33d | 541 | { |
jmitc91516 | 1:a5258871b33d | 542 | //return SixteenBitColorValue(173, 173, 173); // Grey band at bottom |
jmitc91516 | 1:a5258871b33d | 543 | return SixteenBitColorValue(192, 192, 192); |
jmitc91516 | 1:a5258871b33d | 544 | } |
jmitc91516 | 1:a5258871b33d | 545 | |
jmitc91516 | 1:a5258871b33d | 546 | |
jmitc91516 | 1:a5258871b33d | 547 | /* |
jmitc91516 | 1:a5258871b33d | 548 | Draws the background bitmap. It fills the screen - |
jmitc91516 | 1:a5258871b33d | 549 | so you do not need to call GuiLib_Clear if you call this. |
jmitc91516 | 1:a5258871b33d | 550 | (*** BUT - maybe this causes easyGUI to lose track of which page is displayed, |
jmitc91516 | 1:a5258871b33d | 551 | and/or of its touch areas - so reinstated as a test with |
jmitc91516 | 1:a5258871b33d | 552 | '#define WANT_GUILIB_CLEAR_BEFORE_DRAWING_BITMAP' ***) |
jmitc91516 | 1:a5258871b33d | 553 | |
jmitc91516 | 1:a5258871b33d | 554 | Alternatively - if the bitmap we are using has blocks of solid colour anyway - |
jmitc91516 | 1:a5258871b33d | 555 | draw the areas directly (we could then save memory by not including |
jmitc91516 | 1:a5258871b33d | 556 | the actual bitmap in the application) |
jmitc91516 | 1:a5258871b33d | 557 | */ |
jmitc91516 | 1:a5258871b33d | 558 | static void DrawSpecifiedBackgroundBitmap(GuiConst_INT8U bitmapIndex) |
jmitc91516 | 1:a5258871b33d | 559 | { |
jmitc91516 | 1:a5258871b33d | 560 | // Does this solve bug #4? |
jmitc91516 | 1:a5258871b33d | 561 | //#define WANT_GUILIB_CLEAR_BEFORE_DRAWING_BITMAP |
jmitc91516 | 1:a5258871b33d | 562 | #ifdef WANT_GUILIB_CLEAR_BEFORE_DRAWING_BITMAP |
jmitc91516 | 1:a5258871b33d | 563 | GuiLib_Clear(); |
jmitc91516 | 1:a5258871b33d | 564 | #undef WANT_GUILIB_CLEAR_BEFORE_DRAWING_BITMAP |
jmitc91516 | 1:a5258871b33d | 565 | #endif //WANT_GUILIB_CLEAR_BEFORE_DRAWING_BITMAP |
jmitc91516 | 1:a5258871b33d | 566 | // Answer - no, it doesn't |
jmitc91516 | 1:a5258871b33d | 567 | |
jmitc91516 | 1:a5258871b33d | 568 | //#define FAKE_BITMAP |
jmitc91516 | 1:a5258871b33d | 569 | #ifdef FAKE_BITMAP |
jmitc91516 | 1:a5258871b33d | 570 | GuiLib_FillBox(0, 0, 800, 423, GetFakeBackgroundBitmapMainColour()); |
jmitc91516 | 1:a5258871b33d | 571 | GuiLib_FillBox(0, 424, 800, 480, GetFakeBackgroundBitmapButtonBandColour()); |
jmitc91516 | 1:a5258871b33d | 572 | #undef FAKE_BITMAP |
jmitc91516 | 1:a5258871b33d | 573 | #else |
jmitc91516 | 1:a5258871b33d | 574 | GuiLib_ShowBitmap(bitmapIndex, 0, 0, -1); // -1 means 'no transparent colour' |
jmitc91516 | 1:a5258871b33d | 575 | #endif // FAKE_BITMAP |
jmitc91516 | 1:a5258871b33d | 576 | } |
jmitc91516 | 1:a5258871b33d | 577 | |
jmitc91516 | 1:a5258871b33d | 578 | /* |
jmitc91516 | 1:a5258871b33d | 579 | Draws the default background bitmap, i.e. *without* the Ellutia logo |
jmitc91516 | 1:a5258871b33d | 580 | */ |
jmitc91516 | 1:a5258871b33d | 581 | void DrawBackgroundBitmap(void) |
jmitc91516 | 1:a5258871b33d | 582 | { |
jmitc91516 | 1:a5258871b33d | 583 | DrawSpecifiedBackgroundBitmap(GuiStruct_Bitmap_BlankBackground); |
jmitc91516 | 1:a5258871b33d | 584 | } |
jmitc91516 | 1:a5258871b33d | 585 | |
jmitc91516 | 1:a5258871b33d | 586 | /* |
jmitc91516 | 1:a5258871b33d | 587 | Same as the above, but draws the background bitmap *with* the Ellutia logo |
jmitc91516 | 1:a5258871b33d | 588 | */ |
jmitc91516 | 1:a5258871b33d | 589 | void DrawBackgroundBitmapWithLogo(void) |
jmitc91516 | 1:a5258871b33d | 590 | { |
jmitc91516 | 1:a5258871b33d | 591 | DrawSpecifiedBackgroundBitmap(GuiStruct_Bitmap_BootScreen); |
jmitc91516 | 1:a5258871b33d | 592 | } |
jmitc91516 | 1:a5258871b33d | 593 | |
jmitc91516 | 1:a5258871b33d | 594 | /* |
jmitc91516 | 1:a5258871b33d | 595 | For Display (LPC4088) Bug #11, draw a background bitmap without a grey bar at the bottom. |
jmitc91516 | 1:a5258871b33d | 596 | For now, fake this with a page full of one colour |
jmitc91516 | 1:a5258871b33d | 597 | */ |
jmitc91516 | 1:a5258871b33d | 598 | void DrawFakeBackgroundBitmapForNumericKeypadPage(void) |
jmitc91516 | 1:a5258871b33d | 599 | { |
jmitc91516 | 1:a5258871b33d | 600 | // GuiLib_FillBox(0, 0, 800, 480, SixteenBitColorValue(0, 90, 99)); |
jmitc91516 | 1:a5258871b33d | 601 | // Above is for the old background bitmap. For the new "BlankBackground", we need... |
jmitc91516 | 1:a5258871b33d | 602 | GuiLib_FillBox(0, 0, 800, 480, SixteenBitColorValue(255, 255, 255)); |
jmitc91516 | 1:a5258871b33d | 603 | } |
jmitc91516 | 1:a5258871b33d | 604 | |
jmitc91516 | 1:a5258871b33d | 605 | |
jmitc91516 | 1:a5258871b33d | 606 | /* |
jmitc91516 | 1:a5258871b33d | 607 | This functions erases the portions of the door Lock and Release buttons (on the Column pages) |
jmitc91516 | 1:a5258871b33d | 608 | that remain visible when they are replaced by the Close or Unlock buttons. |
jmitc91516 | 1:a5258871b33d | 609 | |
jmitc91516 | 1:a5258871b33d | 610 | I have to admit that I still do not understand why simply redrawing the whole page |
jmitc91516 | 1:a5258871b33d | 611 | (starting with the background bitmap) does not do this. |
jmitc91516 | 1:a5258871b33d | 612 | |
jmitc91516 | 1:a5258871b33d | 613 | No arguments, no return code. |
jmitc91516 | 1:a5258871b33d | 614 | */ |
jmitc91516 | 1:a5258871b33d | 615 | void DrawBackgroundBitmapOverDoorLockAndReleaseButtons(void) |
jmitc91516 | 1:a5258871b33d | 616 | { |
jmitc91516 | 1:a5258871b33d | 617 | // I also do not understand why the first coordinate pair in the call to GuiLib_ShowBitmapArea |
jmitc91516 | 1:a5258871b33d | 618 | // needs to be 0, 0 to display the correct part of the bitmap. I expected them to be the same |
jmitc91516 | 1:a5258871b33d | 619 | // as the second coordinate pair - but that caused the top left portion of the bitmap to be displayed, |
jmitc91516 | 1:a5258871b33d | 620 | // not the part where the buttons actually are. |
jmitc91516 | 1:a5258871b33d | 621 | GuiLib_ShowBitmapArea(GuiStruct_Bitmap_BlankBackground, 0, 0, 248, 405, 323, 480, -1); // -1 means 'no transparent colour' |
jmitc91516 | 1:a5258871b33d | 622 | GuiLib_ShowBitmapArea(GuiStruct_Bitmap_BlankBackground, 0, 0, 477, 405, 552, 480, -1); // -1 means 'no transparent colour' |
jmitc91516 | 1:a5258871b33d | 623 | // GuiLib_FillBox(248, 405, 323, 480, SixteenBitColorValue(165, 165, 173)); |
jmitc91516 | 1:a5258871b33d | 624 | // GuiLib_FillBox(477, 405, 552, 480, SixteenBitColorValue(115, 123, 132)); |
jmitc91516 | 1:a5258871b33d | 625 | } |
jmitc91516 | 1:a5258871b33d | 626 | #define USING_BACKGROUND_BITMAP |
jmitc91516 | 1:a5258871b33d | 627 | |
jmitc91516 | 1:a5258871b33d | 628 | |
jmitc91516 | 1:a5258871b33d | 629 | |
jmitc91516 | 1:a5258871b33d | 630 | /* |
jmitc91516 | 1:a5258871b33d | 631 | Copies the build date (#define'd as BUILD_DATE at the top of this file) |
jmitc91516 | 1:a5258871b33d | 632 | to the easyGUI variable that displays it on the Settings page |
jmitc91516 | 1:a5258871b33d | 633 | */ |
jmitc91516 | 1:a5258871b33d | 634 | void SetupEasyGUIBuildDateVariable(void) |
jmitc91516 | 0:47c880c1463d | 635 | { |
jmitc91516 | 1:a5258871b33d | 636 | strcpy(GuiVar_buildDate, BUILD_DATE); |
jmitc91516 | 1:a5258871b33d | 637 | } |
jmitc91516 | 1:a5258871b33d | 638 | |
jmitc91516 | 1:a5258871b33d | 639 | |
jmitc91516 | 1:a5258871b33d | 640 | /* |
jmitc91516 | 1:a5258871b33d | 641 | Draw a part of a profile - which will be a quadrilateral, vertical at left and right, horizontal at the bottom, but a sloping straight line at the top - |
jmitc91516 | 1:a5258871b33d | 642 | by calling the EasyGUI GuiLib_VLine function multiple times. |
jmitc91516 | 1:a5258871b33d | 643 | |
jmitc91516 | 1:a5258871b33d | 644 | Args: colour of the profile to the left of the boundary |
jmitc91516 | 1:a5258871b33d | 645 | colour of the profile to the right of the boundary |
jmitc91516 | 1:a5258871b33d | 646 | X coords of the left and right edges of the section |
jmitc91516 | 1:a5258871b33d | 647 | X coord of the colour boundary |
jmitc91516 | 1:a5258871b33d | 648 | Y coord of the bottom |
jmitc91516 | 1:a5258871b33d | 649 | Y coords of the top left and top right |
jmitc91516 | 1:a5258871b33d | 650 | |
jmitc91516 | 1:a5258871b33d | 651 | Returns true if OK, false if it failed (e.g. the coords were invalid). |
jmitc91516 | 1:a5258871b33d | 652 | */ |
jmitc91516 | 1:a5258871b33d | 653 | bool DrawProfileSectionUsingGuiLibVLine(GuiConst_INTCOLOR colour1, GuiConst_INTCOLOR colour2, GuiConst_INT16S xLeft, GuiConst_INT16S xRight, GuiConst_INT16S xColourBoundary, |
jmitc91516 | 1:a5258871b33d | 654 | GuiConst_INT16S yBottom, GuiConst_INT16S yTopLeft, GuiConst_INT16S yTopRight) |
jmitc91516 | 1:a5258871b33d | 655 | { |
jmitc91516 | 1:a5258871b33d | 656 | if(xRight <= xLeft) return false; // Would cause divide by zero if they were equal |
jmitc91516 | 1:a5258871b33d | 657 | |
jmitc91516 | 1:a5258871b33d | 658 | // y = mx + c |
jmitc91516 | 1:a5258871b33d | 659 | double yDiff = (double) (yTopRight - yTopLeft); |
jmitc91516 | 1:a5258871b33d | 660 | double xDiff = (double) (xRight - xLeft); |
jmitc91516 | 1:a5258871b33d | 661 | double m = yDiff / xDiff; |
jmitc91516 | 1:a5258871b33d | 662 | double c = (double) yTopLeft - (m * (double) xLeft); |
jmitc91516 | 1:a5258871b33d | 663 | |
jmitc91516 | 1:a5258871b33d | 664 | GuiConst_INT16S lineX; |
jmitc91516 | 1:a5258871b33d | 665 | double lineYTop; |
jmitc91516 | 1:a5258871b33d | 666 | |
jmitc91516 | 1:a5258871b33d | 667 | // Draw first colour up to boundary. |
jmitc91516 | 1:a5258871b33d | 668 | // Allow for the boundary being past the right-hand end |
jmitc91516 | 1:a5258871b33d | 669 | for (lineX = xLeft; (lineX <= xColourBoundary) && (lineX <= xRight); ++lineX) { |
jmitc91516 | 1:a5258871b33d | 670 | lineYTop = (((double) lineX) * m) + c; |
jmitc91516 | 1:a5258871b33d | 671 | GuiLib_VLine(lineX, yBottom, (GuiConst_INT16S) lineYTop, colour1); |
jmitc91516 | 1:a5258871b33d | 672 | } |
jmitc91516 | 1:a5258871b33d | 673 | |
jmitc91516 | 1:a5258871b33d | 674 | // Draw second colour after boundary, if we have not already reached the right-hand end |
jmitc91516 | 1:a5258871b33d | 675 | for (; lineX <= xRight; ++lineX) { |
jmitc91516 | 1:a5258871b33d | 676 | lineYTop = (((double) lineX) * m) + c; |
jmitc91516 | 1:a5258871b33d | 677 | GuiLib_VLine(lineX, yBottom, (GuiConst_INT16S) lineYTop, colour2); |
jmitc91516 | 1:a5258871b33d | 678 | } |
jmitc91516 | 1:a5258871b33d | 679 | |
jmitc91516 | 1:a5258871b33d | 680 | return true; |
jmitc91516 | 1:a5258871b33d | 681 | } |
jmitc91516 | 1:a5258871b33d | 682 | |
jmitc91516 | 1:a5258871b33d | 683 | /* |
jmitc91516 | 1:a5258871b33d | 684 | Displays the specified easyGUI 'structure' (or page, to use a more easily understood term). |
jmitc91516 | 1:a5258871b33d | 685 | |
jmitc91516 | 1:a5258871b33d | 686 | Args are: the index of the structure to be displayed, |
jmitc91516 | 1:a5258871b33d | 687 | a pointer to the USBHostGC instance that corresponds to the GC, |
jmitc91516 | 1:a5258871b33d | 688 | a pointer to the USBDeviceConnected instance that (also) corresponds to the GC |
jmitc91516 | 1:a5258871b33d | 689 | a boolean - defaulting to true - that gives the caller the option to stop the 'structure' |
jmitc91516 | 1:a5258871b33d | 690 | updating its easyGUI variables (either from the GC or from its own internal values) |
jmitc91516 | 1:a5258871b33d | 691 | when it is redisplayed. This is set false by the NumericKeypadHandler, |
jmitc91516 | 1:a5258871b33d | 692 | when the user has just pressed the Apply button on the Numeric Keypad page |
jmitc91516 | 1:a5258871b33d | 693 | and NumericKeypadHandler has updated the corresponding easyGUI variable |
jmitc91516 | 1:a5258871b33d | 694 | on the page that called it, to stop the calling page/structure |
jmitc91516 | 1:a5258871b33d | 695 | from promptly overwriting that same variable. |
jmitc91516 | 1:a5258871b33d | 696 | |
jmitc91516 | 1:a5258871b33d | 697 | No return code. |
jmitc91516 | 1:a5258871b33d | 698 | |
jmitc91516 | 1:a5258871b33d | 699 | TODO: "Refactor" this function. It has had code added to it piecemeal over a long period, |
jmitc91516 | 1:a5258871b33d | 700 | and has become too large to easily understand. |
jmitc91516 | 1:a5258871b33d | 701 | */ |
jmitc91516 | 1:a5258871b33d | 702 | void DisplayEasyGuiStructure(int structureIndex, USBDeviceConnected* usbDevice, USBHostGC* usbHostGC, bool updateEasyGUIVariables = true) |
jmitc91516 | 1:a5258871b33d | 703 | { |
jmitc91516 | 1:a5258871b33d | 704 | // If required, query the GC to find out if it is ready to run, etc, *before* clearing the display - |
jmitc91516 | 0:47c880c1463d | 705 | // otherwise the display remains clear while we talk to the GC - causes noticeable flickering |
jmitc91516 | 2:6e94a7fd1e37 | 706 | GCStateSimplified simplifiedGCState = GC_IDLE; |
jmitc91516 | 0:47c880c1463d | 707 | if((structureIndex == GuiStruct_HomePage_1) && (usbDevice != NULL) && (usbHostGC != NULL)) { |
jmitc91516 | 1:a5258871b33d | 708 | int gcStatus = GetGCStatus(usbDevice, usbHostGC); |
jmitc91516 | 2:6e94a7fd1e37 | 709 | simplifiedGCState = GCStateOrFaultCode::GetSimplifiedGCState(gcStatus); |
jmitc91516 | 0:47c880c1463d | 710 | } |
jmitc91516 | 0:47c880c1463d | 711 | |
jmitc91516 | 1:a5258871b33d | 712 | #define DEBUG_HERE |
jmitc91516 | 1:a5258871b33d | 713 | #ifdef DEBUG_HERE |
jmitc91516 | 1:a5258871b33d | 714 | char dbg[100]; |
jmitc91516 | 1:a5258871b33d | 715 | sprintf(dbg, "DisplayEasyGuiStructure - structure is %d", structureIndex); |
jmitc91516 | 1:a5258871b33d | 716 | EasyGUIDebugPrint(dbg, 0, 20); |
jmitc91516 | 1:a5258871b33d | 717 | #undef DEBUG_HERE |
jmitc91516 | 1:a5258871b33d | 718 | #endif |
jmitc91516 | 0:47c880c1463d | 719 | |
jmitc91516 | 1:a5258871b33d | 720 | #ifdef USING_BACKGROUND_BITMAP |
jmitc91516 | 1:a5258871b33d | 721 | // We want the status rectangles to be 'on top' of this - |
jmitc91516 | 1:a5258871b33d | 722 | // if we include it in the easyGUI page itself, it gets drawn by GuiLib_ShowScreen, |
jmitc91516 | 1:a5258871b33d | 723 | // and overwrites the rectangles |
jmitc91516 | 1:a5258871b33d | 724 | if((structureIndex == GuiStruct_GCConnectionPage_Def) || (structureIndex == GuiStruct_EthernetConnectionPage_Def)) { |
jmitc91516 | 1:a5258871b33d | 725 | DrawBackgroundBitmapWithLogo(); |
jmitc91516 | 1:a5258871b33d | 726 | } else if ((structureIndex == GuiStruct_NumericKeypadPage_Def) || (structureIndex == GuiStruct_EthernetKeypadPage_Def)) { |
jmitc91516 | 1:a5258871b33d | 727 | DrawFakeBackgroundBitmapForNumericKeypadPage(); |
jmitc91516 | 1:a5258871b33d | 728 | } else { |
jmitc91516 | 1:a5258871b33d | 729 | DrawBackgroundBitmap(); |
jmitc91516 | 1:a5258871b33d | 730 | } |
jmitc91516 | 1:a5258871b33d | 731 | #else |
jmitc91516 | 1:a5258871b33d | 732 | GuiLib_Clear(); // Don't need this if we have drawn the background bitmap - it covers the entire screen |
jmitc91516 | 1:a5258871b33d | 733 | #endif |
jmitc91516 | 1:a5258871b33d | 734 | |
jmitc91516 | 1:a5258871b33d | 735 | // Now, display the status rectangles and the component bitmaps, as appropriate for the page we are displaying. |
jmitc91516 | 0:47c880c1463d | 736 | // Note - we draw the status rectangles after GuiLib_Clear - otherwise we wouldn't see the rectangles at all - |
jmitc91516 | 1:a5258871b33d | 737 | // and before GuiLib_ShowScreen - so text, etc, is drawn on top of the rectangles. |
jmitc91516 | 1:a5258871b33d | 738 | // We draw the component bitmaps, after - therefore, on top of - the status rectangles. |
jmitc91516 | 0:47c880c1463d | 739 | switch(structureIndex) { |
jmitc91516 | 0:47c880c1463d | 740 | case GuiStruct_HomePage_1: |
jmitc91516 | 1:a5258871b33d | 741 | #ifdef USE_QSPI_BITMAPS |
jmitc91516 | 1:a5258871b33d | 742 | qspiBitmaps.DisplayAllHomePageBitmaps(); |
jmitc91516 | 1:a5258871b33d | 743 | #else |
jmitc91516 | 0:47c880c1463d | 744 | homePageGCComponentStatusColorAreas.DisplayAll(); |
jmitc91516 | 1:a5258871b33d | 745 | #endif // USE_QSPI_BITMAPS |
jmitc91516 | 0:47c880c1463d | 746 | break; |
jmitc91516 | 0:47c880c1463d | 747 | case GuiStruct_ColumnPage1_2: |
jmitc91516 | 0:47c880c1463d | 748 | case GuiStruct_ColumnPage2_9: |
jmitc91516 | 1:a5258871b33d | 749 | case GuiStruct_ColumnTempProfilePage_60: |
jmitc91516 | 1:a5258871b33d | 750 | case GuiStruct_ColumnDHPage1_40: |
jmitc91516 | 1:a5258871b33d | 751 | case GuiStruct_ColumnDHPage2_50: |
jmitc91516 | 1:a5258871b33d | 752 | case GuiStruct_ColumnDHTempProfilePage_61: |
jmitc91516 | 1:a5258871b33d | 753 | #ifdef WANT_STATUS_RECTANGLE_ON_COLUMN_AUTO_CALIB_PAGE |
jmitc91516 | 1:a5258871b33d | 754 | case GuiStruct_ColumnDHAutoCalibrationPage_Def: |
jmitc91516 | 1:a5258871b33d | 755 | #endif // WANT_STATUS_RECTANGLE_ON_COLUMN_AUTO_CALIB_PAGE |
jmitc91516 | 0:47c880c1463d | 756 | singleGCComponentPageStatusColorAreas.DisplayGCComponentStatus(COLUMN); |
jmitc91516 | 1:a5258871b33d | 757 | qspiBitmaps.DisplayColumnComponentBitmap(); |
jmitc91516 | 0:47c880c1463d | 758 | break; |
jmitc91516 | 0:47c880c1463d | 759 | case GuiStruct_InjectorPage1_3: |
jmitc91516 | 1:a5258871b33d | 760 | case GuiStruct_InjectorTempProfilePage_25: |
jmitc91516 | 1:a5258871b33d | 761 | case GuiStruct_InjectorGasStatusPage_30: |
jmitc91516 | 1:a5258871b33d | 762 | case GuiStruct_InjectorConsumablesPage_20: |
jmitc91516 | 0:47c880c1463d | 763 | singleGCComponentPageStatusColorAreas.DisplayGCComponentStatus(INJECTOR); |
jmitc91516 | 1:a5258871b33d | 764 | qspiBitmaps.DisplayInjectorComponentBitmap(); |
jmitc91516 | 0:47c880c1463d | 765 | break; |
jmitc91516 | 1:a5258871b33d | 766 | case GuiStruct_DetectorFIDPage_4: |
jmitc91516 | 1:a5258871b33d | 767 | case GuiStruct_DetectorECDPage_12: |
jmitc91516 | 1:a5258871b33d | 768 | case GuiStruct_DetectorFPDPage_14: |
jmitc91516 | 1:a5258871b33d | 769 | case GuiStruct_DetectorTCDPage_11: |
jmitc91516 | 1:a5258871b33d | 770 | case GuiStruct_DetectorNonePage_31: |
jmitc91516 | 1:a5258871b33d | 771 | case GuiStruct_DetectorNPDPage_28: |
jmitc91516 | 1:a5258871b33d | 772 | case GuiStruct_DetectorPIDPage_29: |
jmitc91516 | 1:a5258871b33d | 773 | case GuiStruct_DetectorSPDIDPage_30: |
jmitc91516 | 1:a5258871b33d | 774 | case GuiStruct_DetectorTXLPage_27: |
jmitc91516 | 0:47c880c1463d | 775 | singleGCComponentPageStatusColorAreas.DisplayGCComponentStatus(DETECTOR); |
jmitc91516 | 1:a5258871b33d | 776 | qspiBitmaps.DisplayDetectorComponentBitmap(); |
jmitc91516 | 0:47c880c1463d | 777 | break; |
jmitc91516 | 1:a5258871b33d | 778 | case GuiStruct_GasProfilePage_15: |
jmitc91516 | 1:a5258871b33d | 779 | case GuiStruct_GasInformationPage_6: |
jmitc91516 | 1:a5258871b33d | 780 | #ifdef WANT_STATUS_RECTANGLE_ON_GAS_CALIB_PAGES |
jmitc91516 | 1:a5258871b33d | 781 | case GuiStruct_GasCalibrationPage_Def: |
jmitc91516 | 1:a5258871b33d | 782 | case GuiStruct_GasBackPressureDACPage_Def: |
jmitc91516 | 1:a5258871b33d | 783 | case GuiStruct_GasChannelDACAndADCPage_Def: |
jmitc91516 | 1:a5258871b33d | 784 | #endif |
jmitc91516 | 0:47c880c1463d | 785 | singleGCComponentPageStatusColorAreas.DisplayGCComponentStatus(GAS); |
jmitc91516 | 1:a5258871b33d | 786 | qspiBitmaps.DisplayGasComponentBitmap(); |
jmitc91516 | 0:47c880c1463d | 787 | break; |
jmitc91516 | 0:47c880c1463d | 788 | default: // Don't need to display status rectangle for this page |
jmitc91516 | 0:47c880c1463d | 789 | break; |
jmitc91516 | 0:47c880c1463d | 790 | } |
jmitc91516 | 1:a5258871b33d | 791 | |
jmitc91516 | 1:a5258871b33d | 792 | if(structureIndex == GuiStruct_RunningPage1_7) { |
jmitc91516 | 1:a5258871b33d | 793 | if(getGCStatusLoop != NULL) { |
jmitc91516 | 1:a5258871b33d | 794 | getGCStatusLoop->UpdateMethodRunTimeEasyGUIVariables(false); |
jmitc91516 | 1:a5258871b33d | 795 | } |
jmitc91516 | 1:a5258871b33d | 796 | } |
jmitc91516 | 1:a5258871b33d | 797 | |
jmitc91516 | 1:a5258871b33d | 798 | if((structureIndex == GuiStruct_ColumnPage1_2) || (structureIndex == GuiStruct_ColumnDHPage1_40)){ |
jmitc91516 | 1:a5258871b33d | 799 | if(getGCStatusLoop != NULL) { |
jmitc91516 | 1:a5258871b33d | 800 | getGCStatusLoop->UpdateColumnStatusEasyGUIVariable(); |
jmitc91516 | 1:a5258871b33d | 801 | } |
jmitc91516 | 1:a5258871b33d | 802 | } |
jmitc91516 | 1:a5258871b33d | 803 | |
jmitc91516 | 1:a5258871b33d | 804 | if(structureIndex == GuiStruct_InjectorPage1_3){ |
jmitc91516 | 1:a5258871b33d | 805 | if(getGCStatusLoop != NULL) { |
jmitc91516 | 1:a5258871b33d | 806 | getGCStatusLoop->UpdateInjectorStatusEasyGUIVariable(); |
jmitc91516 | 1:a5258871b33d | 807 | } |
jmitc91516 | 1:a5258871b33d | 808 | } |
jmitc91516 | 1:a5258871b33d | 809 | |
jmitc91516 | 1:a5258871b33d | 810 | if(structureIndex == GuiStruct_EthernetParametersPage_50) { |
jmitc91516 | 1:a5258871b33d | 811 | NetworkParameters *networkParameters = NetworkParameters::GetInstance(usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 812 | |
jmitc91516 | 1:a5258871b33d | 813 | if(networkParameters != NULL) { |
jmitc91516 | 1:a5258871b33d | 814 | networkParameters->DisplayingEasyGUIPage(updateEasyGUIVariables); |
jmitc91516 | 1:a5258871b33d | 815 | } |
jmitc91516 | 1:a5258871b33d | 816 | } |
jmitc91516 | 1:a5258871b33d | 817 | |
jmitc91516 | 1:a5258871b33d | 818 | if(structureIndex == GuiStruct_GasCalibrationPage_Def) { |
jmitc91516 | 1:a5258871b33d | 819 | GasCalibrationPageHandler *gasCalibrationPageHandler = GasCalibrationPageHandler::GetInstance(usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 820 | |
jmitc91516 | 1:a5258871b33d | 821 | if(gasCalibrationPageHandler != NULL) { |
jmitc91516 | 1:a5258871b33d | 822 | gasCalibrationPageHandler->DisplayingEasyGUIPage(updateEasyGUIVariables); |
jmitc91516 | 1:a5258871b33d | 823 | } |
jmitc91516 | 1:a5258871b33d | 824 | } |
jmitc91516 | 1:a5258871b33d | 825 | |
jmitc91516 | 1:a5258871b33d | 826 | if(structureIndex == GuiStruct_GasBackPressureDACPage_Def) { |
jmitc91516 | 1:a5258871b33d | 827 | GasBackPressureDACPageHandler *gasBackPressureDACPageHandler = GasBackPressureDACPageHandler::GetInstance(usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 828 | |
jmitc91516 | 1:a5258871b33d | 829 | if(gasBackPressureDACPageHandler != NULL) { |
jmitc91516 | 1:a5258871b33d | 830 | gasBackPressureDACPageHandler->DisplayingEasyGUIPage(updateEasyGUIVariables); |
jmitc91516 | 1:a5258871b33d | 831 | } |
jmitc91516 | 1:a5258871b33d | 832 | } |
jmitc91516 | 1:a5258871b33d | 833 | |
jmitc91516 | 1:a5258871b33d | 834 | if(structureIndex == GuiStruct_GasChannelDACAndADCPage_Def) { |
jmitc91516 | 1:a5258871b33d | 835 | GasChannelDACAndADCPageHandler *gasChannelDACAndADCPageHandler = GasChannelDACAndADCPageHandler::GetInstance(usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 836 | |
jmitc91516 | 1:a5258871b33d | 837 | if(gasChannelDACAndADCPageHandler != NULL) { |
jmitc91516 | 1:a5258871b33d | 838 | gasChannelDACAndADCPageHandler->DisplayingEasyGUIPage(); |
jmitc91516 | 1:a5258871b33d | 839 | } |
jmitc91516 | 1:a5258871b33d | 840 | } |
jmitc91516 | 1:a5258871b33d | 841 | |
jmitc91516 | 1:a5258871b33d | 842 | if(structureIndex == GuiStruct_ColumnDHAutoCalibrationPage_Def) { |
jmitc91516 | 1:a5258871b33d | 843 | ColumnDHAutoCalibrationPageHandler *columnDHAutoCalibrationPageHandler = ColumnDHAutoCalibrationPageHandler::GetInstance(usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 844 | |
jmitc91516 | 1:a5258871b33d | 845 | if(columnDHAutoCalibrationPageHandler != NULL) { |
jmitc91516 | 1:a5258871b33d | 846 | columnDHAutoCalibrationPageHandler->DisplayingEasyGUIPage(); |
jmitc91516 | 1:a5258871b33d | 847 | } |
jmitc91516 | 1:a5258871b33d | 848 | } |
jmitc91516 | 1:a5258871b33d | 849 | |
jmitc91516 | 1:a5258871b33d | 850 | if(structureIndex == GuiStruct_ColumnDHManualCalibrationPage_Def) { |
jmitc91516 | 1:a5258871b33d | 851 | ColumnDHManualCalibrationPageHandler *columnDHManualCalibrationPageHandler = ColumnDHManualCalibrationPageHandler::GetInstance(usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 852 | |
jmitc91516 | 1:a5258871b33d | 853 | if(columnDHManualCalibrationPageHandler != NULL) { |
jmitc91516 | 1:a5258871b33d | 854 | columnDHManualCalibrationPageHandler->DisplayingEasyGUIPage(updateEasyGUIVariables); |
jmitc91516 | 1:a5258871b33d | 855 | } |
jmitc91516 | 1:a5258871b33d | 856 | } |
jmitc91516 | 1:a5258871b33d | 857 | |
jmitc91516 | 1:a5258871b33d | 858 | if(structureIndex == GuiStruct_ColumnDHSensorCalibration_Def) { |
jmitc91516 | 1:a5258871b33d | 859 | ColumnDHSensorCalibrationPageHandler *columnDHSensorCalibrationPageHandler = ColumnDHSensorCalibrationPageHandler::GetInstance(usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 860 | |
jmitc91516 | 1:a5258871b33d | 861 | if(columnDHSensorCalibrationPageHandler != NULL) { |
jmitc91516 | 1:a5258871b33d | 862 | columnDHSensorCalibrationPageHandler->DisplayingEasyGUIPage(updateEasyGUIVariables); |
jmitc91516 | 1:a5258871b33d | 863 | } |
jmitc91516 | 1:a5258871b33d | 864 | } |
jmitc91516 | 1:a5258871b33d | 865 | |
jmitc91516 | 1:a5258871b33d | 866 | if(structureIndex == GuiStruct_PSU_DAC_Page_Def) { |
jmitc91516 | 1:a5258871b33d | 867 | ColumnDHPSUDACPageHandler *columnDHPSUDACPageHandler = ColumnDHPSUDACPageHandler::GetInstance(usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 868 | |
jmitc91516 | 1:a5258871b33d | 869 | if(columnDHPSUDACPageHandler != NULL) { |
jmitc91516 | 1:a5258871b33d | 870 | columnDHPSUDACPageHandler->DisplayingEasyGUIPage(updateEasyGUIVariables); |
jmitc91516 | 1:a5258871b33d | 871 | } |
jmitc91516 | 1:a5258871b33d | 872 | } |
jmitc91516 | 1:a5258871b33d | 873 | |
jmitc91516 | 1:a5258871b33d | 874 | if(NudgeAndDampPageHandler::PageIsANudgeAndDampPage(structureIndex)) { |
jmitc91516 | 1:a5258871b33d | 875 | NudgeAndDampPageHandler *nudgeAndDampPageHandler = NudgeAndDampPageHandler::GetInstance(usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 876 | |
jmitc91516 | 1:a5258871b33d | 877 | if(nudgeAndDampPageHandler != NULL) { |
jmitc91516 | 1:a5258871b33d | 878 | nudgeAndDampPageHandler->DisplayingEasyGUIPage(structureIndex, updateEasyGUIVariables); |
jmitc91516 | 1:a5258871b33d | 879 | } |
jmitc91516 | 1:a5258871b33d | 880 | } |
jmitc91516 | 1:a5258871b33d | 881 | |
jmitc91516 | 1:a5258871b33d | 882 | |
jmitc91516 | 1:a5258871b33d | 883 | if(structureIndex == GuiStruct_ServicingHomePage_Def) { |
jmitc91516 | 1:a5258871b33d | 884 | #ifdef USE_QSPI_BITMAPS |
jmitc91516 | 1:a5258871b33d | 885 | // Use same bitmaps on Servicing Home Page, as on the main Home Page |
jmitc91516 | 1:a5258871b33d | 886 | qspiBitmaps.DisplayAllHomePageBitmaps(); |
jmitc91516 | 1:a5258871b33d | 887 | #endif |
jmitc91516 | 1:a5258871b33d | 888 | } |
jmitc91516 | 1:a5258871b33d | 889 | |
jmitc91516 | 0:47c880c1463d | 890 | GuiLib_ShowScreen(structureIndex, GuiLib_NO_CURSOR, GuiLib_RESET_AUTO_REDRAW); |
jmitc91516 | 0:47c880c1463d | 891 | |
jmitc91516 | 0:47c880c1463d | 892 | // But draw the run button, if required, on top of the fixed part of the home page |
jmitc91516 | 1:a5258871b33d | 893 | // Same for the Heat On/Off button, and the Stabilising or Equilibrating messages (again, if required) |
jmitc91516 | 0:47c880c1463d | 894 | if(structureIndex == GuiStruct_HomePage_1) { |
jmitc91516 | 2:6e94a7fd1e37 | 895 | //#define ALWAYS_WANT_RUN_BUTTON |
jmitc91516 | 2:6e94a7fd1e37 | 896 | #ifdef ALWAYS_WANT_RUN_BUTTON |
jmitc91516 | 2:6e94a7fd1e37 | 897 | DrawRunButton((simplifiedGCState == GC_READY_TO_RUN) || (simplifiedGCState == GC_RUNNING)); |
jmitc91516 | 2:6e94a7fd1e37 | 898 | #else |
jmitc91516 | 2:6e94a7fd1e37 | 899 | if((simplifiedGCState == GC_READY_TO_RUN) || (simplifiedGCState == GC_RUNNING)) { |
jmitc91516 | 2:6e94a7fd1e37 | 900 | DrawRunButton(true); |
jmitc91516 | 2:6e94a7fd1e37 | 901 | } |
jmitc91516 | 2:6e94a7fd1e37 | 902 | #endif // ALWAYS_WANT_RUN_BUTTON |
jmitc91516 | 2:6e94a7fd1e37 | 903 | |
jmitc91516 | 1:a5258871b33d | 904 | #ifdef USE_HEAT_ONOFF_BUTTON_BITMAPS |
jmitc91516 | 1:a5258871b33d | 905 | DrawHeatOnOffButton(); |
jmitc91516 | 1:a5258871b33d | 906 | #endif |
jmitc91516 | 1:a5258871b33d | 907 | |
jmitc91516 | 2:6e94a7fd1e37 | 908 | GCStateOrFaultCode::DrawSimplifiedStateMessageOnHomePageRunButton(simplifiedGCState); |
jmitc91516 | 0:47c880c1463d | 909 | } |
jmitc91516 | 0:47c880c1463d | 910 | |
jmitc91516 | 1:a5258871b33d | 911 | if(structureIndex == GuiStruct_InjectorTempProfilePage_25) { |
jmitc91516 | 1:a5258871b33d | 912 | |
jmitc91516 | 1:a5258871b33d | 913 | // Make sure the injector temperature profile graph is drawn |
jmitc91516 | 1:a5258871b33d | 914 | // on entering this page (note that we must do this *after* |
jmitc91516 | 1:a5258871b33d | 915 | // drawing the injector status rectangle and *after* 'GuiLib_ShowScreen') |
jmitc91516 | 1:a5258871b33d | 916 | |
jmitc91516 | 1:a5258871b33d | 917 | if(getGCStatusLoop != NULL) { |
jmitc91516 | 1:a5258871b33d | 918 | getGCStatusLoop->DisplayInjectorTempProfilePageGraph(); |
jmitc91516 | 1:a5258871b33d | 919 | } |
jmitc91516 | 1:a5258871b33d | 920 | } |
jmitc91516 | 1:a5258871b33d | 921 | |
jmitc91516 | 1:a5258871b33d | 922 | if(structureIndex == GuiStruct_GasProfilePage_15) { |
jmitc91516 | 1:a5258871b33d | 923 | |
jmitc91516 | 1:a5258871b33d | 924 | // Make sure the gas pressure profile graph is drawn |
jmitc91516 | 1:a5258871b33d | 925 | // on entering this page (note that we must do this *after* |
jmitc91516 | 1:a5258871b33d | 926 | // drawing the gas status rectangle and *after* 'GuiLib_ShowScreen') |
jmitc91516 | 1:a5258871b33d | 927 | |
jmitc91516 | 1:a5258871b33d | 928 | if(getGCStatusLoop != NULL) { |
jmitc91516 | 1:a5258871b33d | 929 | getGCStatusLoop->DisplayGasFlowProfilePageGraph(); |
jmitc91516 | 1:a5258871b33d | 930 | } |
jmitc91516 | 1:a5258871b33d | 931 | } |
jmitc91516 | 1:a5258871b33d | 932 | |
jmitc91516 | 1:a5258871b33d | 933 | if(structureIndex == GuiStruct_ColumnTempProfilePage_60) { |
jmitc91516 | 1:a5258871b33d | 934 | |
jmitc91516 | 1:a5258871b33d | 935 | // Make sure the column temperature profile graph is drawn |
jmitc91516 | 1:a5258871b33d | 936 | // on entering this page (note that we must do this *after* |
jmitc91516 | 1:a5258871b33d | 937 | // drawing the column status rectangle and *after* 'GuiLib_ShowScreen') |
jmitc91516 | 1:a5258871b33d | 938 | |
jmitc91516 | 1:a5258871b33d | 939 | if(getGCStatusLoop != NULL) { |
jmitc91516 | 1:a5258871b33d | 940 | getGCStatusLoop->DisplayColumnTempProfilePageGraph(CONVENTIONAL_COLUMN); |
jmitc91516 | 1:a5258871b33d | 941 | } |
jmitc91516 | 1:a5258871b33d | 942 | |
jmitc91516 | 1:a5258871b33d | 943 | //Also in GetGCStatusLoop::DisplayColumnTempProfilePageData |
jmitc91516 | 1:a5258871b33d | 944 | //#define SWIM_TEST |
jmitc91516 | 1:a5258871b33d | 945 | #ifdef SWIM_TEST |
jmitc91516 | 1:a5258871b33d | 946 | SwimDraw* swimDrawInstance = SwimDraw::GetInstance(); |
jmitc91516 | 1:a5258871b33d | 947 | if(swimDrawInstance != NULL) { |
jmitc91516 | 1:a5258871b33d | 948 | // two horizontal boxes |
jmitc91516 | 1:a5258871b33d | 949 | swimDrawInstance->DrawRectangle(SixteenBitColorValue(0xFF, 0, 0), 50, 200, 650, 250); |
jmitc91516 | 1:a5258871b33d | 950 | swimDrawInstance->DrawRectangle(SixteenBitColorValue(0, 0, 0xFF), 50, 350, 650, 400); |
jmitc91516 | 1:a5258871b33d | 951 | |
jmitc91516 | 1:a5258871b33d | 952 | // two vertical boxes |
jmitc91516 | 1:a5258871b33d | 953 | swimDrawInstance->DrawRectangle(SixteenBitColorValue(0xFF, 0, 0), 100, 50, 150, 350); |
jmitc91516 | 1:a5258871b33d | 954 | swimDrawInstance->DrawRectangle(SixteenBitColorValue(0, 0, 0xFF), 500, 50, 550, 350); |
jmitc91516 | 1:a5258871b33d | 955 | } |
jmitc91516 | 1:a5258871b33d | 956 | #else // Draw the same boxes with easyGUI |
jmitc91516 | 1:a5258871b33d | 957 | // GuiLib_FillBox(50, 200, 650, 250, SixteenBitColorValue(0xFF, 0, 0)); |
jmitc91516 | 1:a5258871b33d | 958 | // GuiLib_FillBox(50, 350, 650, 400, SixteenBitColorValue(0, 0, 0xFF)); |
jmitc91516 | 1:a5258871b33d | 959 | |
jmitc91516 | 1:a5258871b33d | 960 | // GuiLib_FillBox(100, 50, 150, 350, SixteenBitColorValue(0xFF, 0, 0)); |
jmitc91516 | 1:a5258871b33d | 961 | // GuiLib_FillBox(500, 50, 550, 350, SixteenBitColorValue(0, 0, 0xFF)); |
jmitc91516 | 1:a5258871b33d | 962 | |
jmitc91516 | 1:a5258871b33d | 963 | // No - draw a dummy profile section |
jmitc91516 | 1:a5258871b33d | 964 | // DrawProfileSectionUsingGuiLibVLine(SixteenBitColorValue(0xFF, 0, 0), 300, 500, 350, 200, 125); |
jmitc91516 | 1:a5258871b33d | 965 | #endif // SWIM_TEST |
jmitc91516 | 1:a5258871b33d | 966 | } |
jmitc91516 | 1:a5258871b33d | 967 | |
jmitc91516 | 1:a5258871b33d | 968 | if(structureIndex == GuiStruct_ColumnDHTempProfilePage_61) { |
jmitc91516 | 1:a5258871b33d | 969 | |
jmitc91516 | 1:a5258871b33d | 970 | // Make sure the directly heated column temperature profile graph is drawn |
jmitc91516 | 1:a5258871b33d | 971 | // on entering this page (note that we must do this *after* |
jmitc91516 | 1:a5258871b33d | 972 | // drawing the column status rectangle and *after* 'GuiLib_ShowScreen') |
jmitc91516 | 1:a5258871b33d | 973 | |
jmitc91516 | 1:a5258871b33d | 974 | if(getGCStatusLoop != NULL) { |
jmitc91516 | 1:a5258871b33d | 975 | getGCStatusLoop->DisplayColumnTempProfilePageGraph(DIRECTLY_HEATED_COLUMN); |
jmitc91516 | 1:a5258871b33d | 976 | } |
jmitc91516 | 1:a5258871b33d | 977 | } |
jmitc91516 | 1:a5258871b33d | 978 | |
jmitc91516 | 1:a5258871b33d | 979 | // Column page - must draw Lock/Release buttons if required |
jmitc91516 | 1:a5258871b33d | 980 | if((structureIndex == GuiStruct_ColumnDHAutoCalibrationPage_Def) || |
jmitc91516 | 1:a5258871b33d | 981 | (structureIndex == GuiStruct_ColumnDHPage1_40) || |
jmitc91516 | 1:a5258871b33d | 982 | (structureIndex == GuiStruct_ColumnDHPage2_50) || |
jmitc91516 | 1:a5258871b33d | 983 | (structureIndex == GuiStruct_ColumnDHTempProfilePage_61) || |
jmitc91516 | 1:a5258871b33d | 984 | (structureIndex == GuiStruct_ColumnPage1_2) || |
jmitc91516 | 1:a5258871b33d | 985 | (structureIndex == GuiStruct_ColumnPage2_9) || |
jmitc91516 | 1:a5258871b33d | 986 | (structureIndex == GuiStruct_ColumnTempProfilePage_60)) { |
jmitc91516 | 1:a5258871b33d | 987 | SetupDoorActuatorCommandUserInterface(usbDevice, usbHostGC, false); |
jmitc91516 | 1:a5258871b33d | 988 | } |
jmitc91516 | 1:a5258871b33d | 989 | |
jmitc91516 | 1:a5258871b33d | 990 | if(structureIndex == GuiStruct_RunningPage1_7) { |
jmitc91516 | 1:a5258871b33d | 991 | if(getGCStatusLoop != NULL) { |
jmitc91516 | 1:a5258871b33d | 992 | getGCStatusLoop->UpdateAndDisplayRunningPage1ProgressBar(false); |
jmitc91516 | 1:a5258871b33d | 993 | } |
jmitc91516 | 1:a5258871b33d | 994 | } |
jmitc91516 | 1:a5258871b33d | 995 | |
jmitc91516 | 0:47c880c1463d | 996 | GuiLib_Refresh(); |
jmitc91516 | 0:47c880c1463d | 997 | #define DEBUG_HERE |
jmitc91516 | 0:47c880c1463d | 998 | #ifdef DEBUG_HERE |
jmitc91516 | 1:a5258871b33d | 999 | char dbg2[100]; |
jmitc91516 | 1:a5258871b33d | 1000 | sprintf(dbg2, "After GuiLib_Refresh main 1"); |
jmitc91516 | 1:a5258871b33d | 1001 | EasyGUIDebugPrint(dbg2, 0, 40); |
jmitc91516 | 0:47c880c1463d | 1002 | #undef DEBUG_HERE |
jmitc91516 | 0:47c880c1463d | 1003 | #endif |
jmitc91516 | 0:47c880c1463d | 1004 | |
jmitc91516 | 0:47c880c1463d | 1005 | if(getGCStatusLoop != NULL) { |
jmitc91516 | 0:47c880c1463d | 1006 | getGCStatusLoop->SetCurrentPage(structureIndex); |
jmitc91516 | 0:47c880c1463d | 1007 | } |
jmitc91516 | 1:a5258871b33d | 1008 | } // End of "DisplayEasyGUIStructure" |
jmitc91516 | 0:47c880c1463d | 1009 | |
jmitc91516 | 1:a5258871b33d | 1010 | /* |
jmitc91516 | 1:a5258871b33d | 1011 | Draws the specified error message in a standard position (X = 90, Y = 240), |
jmitc91516 | 1:a5258871b33d | 1012 | blue text on a green background. |
jmitc91516 | 1:a5258871b33d | 1013 | |
jmitc91516 | 1:a5258871b33d | 1014 | The argument is a pointer to the (null-terminated) message text. |
jmitc91516 | 1:a5258871b33d | 1015 | */ |
jmitc91516 | 0:47c880c1463d | 1016 | void DrawErrorMessage(char *msg) |
jmitc91516 | 0:47c880c1463d | 1017 | { |
jmitc91516 | 0:47c880c1463d | 1018 | const GuiConst_INT16U fontNo = GuiFont_Helv1; |
jmitc91516 | 0:47c880c1463d | 1019 | |
jmitc91516 | 0:47c880c1463d | 1020 | GuiLib_DrawStr( |
jmitc91516 | 0:47c880c1463d | 1021 | 90, //GuiConst_INT16S X, |
jmitc91516 | 0:47c880c1463d | 1022 | 240, //GuiConst_INT16S Y, |
jmitc91516 | 0:47c880c1463d | 1023 | fontNo, //GuiConst_INT16U FontNo, |
jmitc91516 | 0:47c880c1463d | 1024 | msg, //GuiConst_TEXT PrefixLocate *String, |
jmitc91516 | 0:47c880c1463d | 1025 | GuiLib_ALIGN_LEFT, //GuiConst_INT8U Alignment, |
jmitc91516 | 0:47c880c1463d | 1026 | GuiLib_PS_ON, //GuiConst_INT8U PsWriting, |
jmitc91516 | 0:47c880c1463d | 1027 | GuiLib_TRANSPARENT_OFF, //GuiConst_INT8U Transparent, |
jmitc91516 | 0:47c880c1463d | 1028 | GuiLib_UNDERLINE_OFF, //GuiConst_INT8U Underlining, |
jmitc91516 | 0:47c880c1463d | 1029 | 0, //GuiConst_INT16S BackBoxSizeX, |
jmitc91516 | 0:47c880c1463d | 1030 | 0, //GuiConst_INT16S BackBoxSizeY1, |
jmitc91516 | 0:47c880c1463d | 1031 | 0, //GuiConst_INT16S BackBoxSizeY2, |
jmitc91516 | 0:47c880c1463d | 1032 | GuiLib_BBP_NONE, //GuiConst_INT8U BackBorderPixels, |
jmitc91516 | 0:47c880c1463d | 1033 | SixteenBitColorValue(0, 0, 0xFF), //GuiConst_INTCOLOR ForeColor, |
jmitc91516 | 0:47c880c1463d | 1034 | SixteenBitColorValue(0, 0xFF, 0) //GuiConst_INTCOLOR BackColor |
jmitc91516 | 0:47c880c1463d | 1035 | ); |
jmitc91516 | 0:47c880c1463d | 1036 | } |
jmitc91516 | 0:47c880c1463d | 1037 | |
jmitc91516 | 1:a5258871b33d | 1038 | /* |
jmitc91516 | 1:a5258871b33d | 1039 | Update the easyGUI variable that displays the command to turn the GC heat on or off, |
jmitc91516 | 1:a5258871b33d | 1040 | so that it matches the GC's current state. |
jmitc91516 | 1:a5258871b33d | 1041 | */ |
jmitc91516 | 0:47c880c1463d | 1042 | void UpdateHeatOnOffEasyGuiVariable(void) |
jmitc91516 | 0:47c880c1463d | 1043 | { |
jmitc91516 | 0:47c880c1463d | 1044 | // Note that the easyGUI variable is not the current status of the heat on the GC, |
jmitc91516 | 0:47c880c1463d | 1045 | // but the command to toggle its current state |
jmitc91516 | 0:47c880c1463d | 1046 | if(theGCHeatControl != NULL) { |
jmitc91516 | 0:47c880c1463d | 1047 | if(theGCHeatControl->IsHeatOn()) { |
jmitc91516 | 0:47c880c1463d | 1048 | strcpy(GuiVar_heatOnOffCommand, "Heat Off"); |
jmitc91516 | 0:47c880c1463d | 1049 | } else { |
jmitc91516 | 0:47c880c1463d | 1050 | strcpy(GuiVar_heatOnOffCommand, "Heat On"); |
jmitc91516 | 0:47c880c1463d | 1051 | } |
jmitc91516 | 0:47c880c1463d | 1052 | } |
jmitc91516 | 0:47c880c1463d | 1053 | } |
jmitc91516 | 0:47c880c1463d | 1054 | |
jmitc91516 | 1:a5258871b33d | 1055 | void DrawHeatOnOffButton(void) |
jmitc91516 | 0:47c880c1463d | 1056 | { |
jmitc91516 | 1:a5258871b33d | 1057 | // Note that the text on the button is not the current status of the heat on the GC, |
jmitc91516 | 1:a5258871b33d | 1058 | // but the command to toggle its current state |
jmitc91516 | 1:a5258871b33d | 1059 | GuiConst_INT8U bitmapIndex = GuiStruct_Bitmap_HeatOn; |
jmitc91516 | 1:a5258871b33d | 1060 | if(theGCHeatControl != NULL) { |
jmitc91516 | 1:a5258871b33d | 1061 | if(theGCHeatControl->IsHeatOn()) { |
jmitc91516 | 1:a5258871b33d | 1062 | bitmapIndex = GuiStruct_Bitmap_HeatOff; |
jmitc91516 | 1:a5258871b33d | 1063 | } |
jmitc91516 | 1:a5258871b33d | 1064 | } |
jmitc91516 | 0:47c880c1463d | 1065 | |
jmitc91516 | 0:47c880c1463d | 1066 | #define DEBUG_HERE |
jmitc91516 | 0:47c880c1463d | 1067 | #ifdef DEBUG_HERE |
jmitc91516 | 0:47c880c1463d | 1068 | char dbg[100]; |
jmitc91516 | 1:a5258871b33d | 1069 | sprintf(dbg, "DHOOB - bitmapIndex is %d", bitmapIndex); |
jmitc91516 | 1:a5258871b33d | 1070 | EasyGUIDebugPrint(dbg, 0, 440); |
jmitc91516 | 0:47c880c1463d | 1071 | #endif |
jmitc91516 | 0:47c880c1463d | 1072 | #undef DEBUG_HERE |
jmitc91516 | 0:47c880c1463d | 1073 | |
jmitc91516 | 1:a5258871b33d | 1074 | // Hard coded coordinates copied from easyGUI (I have not found |
jmitc91516 | 1:a5258871b33d | 1075 | // a way of getting them from the easyGUI code at runtime) |
jmitc91516 | 1:a5258871b33d | 1076 | GuiLib_ShowBitmap(bitmapIndex, 0, 404, -1); // No transparent colour |
jmitc91516 | 0:47c880c1463d | 1077 | } |
jmitc91516 | 0:47c880c1463d | 1078 | |
jmitc91516 | 1:a5258871b33d | 1079 | |
jmitc91516 | 1:a5258871b33d | 1080 | /* |
jmitc91516 | 1:a5258871b33d | 1081 | General function to pass a command to the GC, and return success or failure to the caller. |
jmitc91516 | 1:a5258871b33d | 1082 | |
jmitc91516 | 1:a5258871b33d | 1083 | Args are: the command (null-terminated string) |
jmitc91516 | 1:a5258871b33d | 1084 | a pointer to the USBHostGC instance that corresponds to the GC, |
jmitc91516 | 1:a5258871b33d | 1085 | a pointer to the USBDeviceConnected instance that (also) corresponds to the GC |
jmitc91516 | 1:a5258871b33d | 1086 | |
jmitc91516 | 1:a5258871b33d | 1087 | Returns true if the GC returned "DACK" in response, false if it returned "DNAK" |
jmitc91516 | 1:a5258871b33d | 1088 | (or "EPKT", or anything other than "DACK"). |
jmitc91516 | 1:a5258871b33d | 1089 | */ |
jmitc91516 | 1:a5258871b33d | 1090 | bool ExecuteGCCommand(char *cmd, USBDeviceConnected* usbDevice, USBHostGC* usbHostGC) |
jmitc91516 | 0:47c880c1463d | 1091 | { |
jmitc91516 | 1:a5258871b33d | 1092 | #define USE_GC_UTILS // Testing new class |
jmitc91516 | 1:a5258871b33d | 1093 | #ifdef USE_GC_UTILS |
jmitc91516 | 1:a5258871b33d | 1094 | return USBHostGCUtilities::SendCommandToGCWithDACKResponse(usbDevice, usbHostGC, cmd); |
jmitc91516 | 1:a5258871b33d | 1095 | #else |
jmitc91516 | 0:47c880c1463d | 1096 | while(usbHostGC->ExecutingSetDeviceReport()) {} |
jmitc91516 | 0:47c880c1463d | 1097 | |
jmitc91516 | 0:47c880c1463d | 1098 | char response[50]; |
jmitc91516 | 0:47c880c1463d | 1099 | usbHostGC->SetDeviceReport(usbDevice, cmd, response); |
jmitc91516 | 0:47c880c1463d | 1100 | // We expect a response like this: "DACK" for success, "DNAK" for failure |
jmitc91516 | 0:47c880c1463d | 1101 | |
jmitc91516 | 0:47c880c1463d | 1102 | #define DEBUG_HERE |
jmitc91516 | 0:47c880c1463d | 1103 | #ifdef DEBUG_HERE |
jmitc91516 | 0:47c880c1463d | 1104 | char dbg[100]; |
jmitc91516 | 0:47c880c1463d | 1105 | sprintf(dbg, "%s returned %s", cmd, response); |
jmitc91516 | 1:a5258871b33d | 1106 | EasyGUIDebugPrint(dbg, 0, 20); |
jmitc91516 | 0:47c880c1463d | 1107 | #endif |
jmitc91516 | 0:47c880c1463d | 1108 | #undef DEBUG_HERE |
jmitc91516 | 1:a5258871b33d | 1109 | |
jmitc91516 | 1:a5258871b33d | 1110 | return (response[1] == 'A'); |
jmitc91516 | 1:a5258871b33d | 1111 | #endif // USE_GC_UTILS |
jmitc91516 | 1:a5258871b33d | 1112 | } |
jmitc91516 | 1:a5258871b33d | 1113 | |
jmitc91516 | 1:a5258871b33d | 1114 | /* |
jmitc91516 | 1:a5258871b33d | 1115 | Starts the GC running, by passing it the "CRUN" command. |
jmitc91516 | 0:47c880c1463d | 1116 | |
jmitc91516 | 1:a5258871b33d | 1117 | Args are: a pointer to the USBHostGC instance that corresponds to the GC, |
jmitc91516 | 1:a5258871b33d | 1118 | a pointer to the USBDeviceConnected instance that (also) corresponds to the GC |
jmitc91516 | 1:a5258871b33d | 1119 | |
jmitc91516 | 1:a5258871b33d | 1120 | Returns true if the GC returned "DACK" in response, false if it returned "DNAK". |
jmitc91516 | 1:a5258871b33d | 1121 | */ |
jmitc91516 | 1:a5258871b33d | 1122 | bool StartGCRun(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC) |
jmitc91516 | 1:a5258871b33d | 1123 | { |
jmitc91516 | 1:a5258871b33d | 1124 | return ExecuteGCCommand("CRUN", usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 1125 | } |
jmitc91516 | 1:a5258871b33d | 1126 | |
jmitc91516 | 1:a5258871b33d | 1127 | /* |
jmitc91516 | 1:a5258871b33d | 1128 | Stops the GC running, by passing it the "CSTP" or "CABT" command. |
jmitc91516 | 1:a5258871b33d | 1129 | |
jmitc91516 | 1:a5258871b33d | 1130 | Args are: a pointer to the USBHostGC instance that corresponds to the GC, |
jmitc91516 | 1:a5258871b33d | 1131 | a pointer to the USBDeviceConnected instance that (also) corresponds to the GC |
jmitc91516 | 1:a5258871b33d | 1132 | |
jmitc91516 | 1:a5258871b33d | 1133 | Returns true if the GC returned "DACK" in response, false if it returned "DNAK". |
jmitc91516 | 1:a5258871b33d | 1134 | */ |
jmitc91516 | 1:a5258871b33d | 1135 | bool StopGCRun(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC) |
jmitc91516 | 1:a5258871b33d | 1136 | { |
jmitc91516 | 1:a5258871b33d | 1137 | // TODO: Find out which is the correct command here |
jmitc91516 | 1:a5258871b33d | 1138 | // char *cmd = "CSTP"; |
jmitc91516 | 1:a5258871b33d | 1139 | char *cmd = "CABT"; |
jmitc91516 | 1:a5258871b33d | 1140 | return ExecuteGCCommand(cmd, usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 1141 | } |
jmitc91516 | 1:a5258871b33d | 1142 | |
jmitc91516 | 1:a5258871b33d | 1143 | /* |
jmitc91516 | 1:a5258871b33d | 1144 | Takes the GC out of standby mode, by passing it the "CDIS" command. |
jmitc91516 | 1:a5258871b33d | 1145 | |
jmitc91516 | 1:a5258871b33d | 1146 | Args are: a pointer to the USBHostGC instance that corresponds to the GC, |
jmitc91516 | 1:a5258871b33d | 1147 | a pointer to the USBDeviceConnected instance that (also) corresponds to the GC |
jmitc91516 | 1:a5258871b33d | 1148 | |
jmitc91516 | 1:a5258871b33d | 1149 | Returns true if the GC returned "DACK" in response, false if it returned "DNAK". |
jmitc91516 | 1:a5258871b33d | 1150 | */ |
jmitc91516 | 1:a5258871b33d | 1151 | bool ExitGCStandbyMode(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC) |
jmitc91516 | 1:a5258871b33d | 1152 | { |
jmitc91516 | 1:a5258871b33d | 1153 | if( ExecuteGCCommand("CDIS", usbDevice, usbHostGC)) { |
jmitc91516 | 1:a5258871b33d | 1154 | if(getGCStatusLoop != NULL) { |
jmitc91516 | 1:a5258871b33d | 1155 | getGCStatusLoop->ExitedGCStandbyMode(); |
jmitc91516 | 1:a5258871b33d | 1156 | } |
jmitc91516 | 1:a5258871b33d | 1157 | |
jmitc91516 | 1:a5258871b33d | 1158 | return true; |
jmitc91516 | 1:a5258871b33d | 1159 | } |
jmitc91516 | 1:a5258871b33d | 1160 | |
jmitc91516 | 1:a5258871b33d | 1161 | // 'else' |
jmitc91516 | 1:a5258871b33d | 1162 | return false; |
jmitc91516 | 0:47c880c1463d | 1163 | } |
jmitc91516 | 0:47c880c1463d | 1164 | |
jmitc91516 | 1:a5258871b33d | 1165 | /* |
jmitc91516 | 1:a5258871b33d | 1166 | Takes the GC out of its error state, by passing it the "CCLR" command. |
jmitc91516 | 1:a5258871b33d | 1167 | |
jmitc91516 | 1:a5258871b33d | 1168 | Args are: a pointer to the USBHostGC instance that corresponds to the GC, |
jmitc91516 | 1:a5258871b33d | 1169 | a pointer to the USBDeviceConnected instance that (also) corresponds to the GC |
jmitc91516 | 1:a5258871b33d | 1170 | |
jmitc91516 | 1:a5258871b33d | 1171 | Returns true if the GC returned "DACK" in response, false if it returned "DNAK". |
jmitc91516 | 1:a5258871b33d | 1172 | */ |
jmitc91516 | 1:a5258871b33d | 1173 | bool ClearGCErrors(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC) |
jmitc91516 | 1:a5258871b33d | 1174 | { |
jmitc91516 | 1:a5258871b33d | 1175 | return ExecuteGCCommand("CCLR", usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 1176 | } |
jmitc91516 | 1:a5258871b33d | 1177 | |
jmitc91516 | 1:a5258871b33d | 1178 | |
jmitc91516 | 1:a5258871b33d | 1179 | /* |
jmitc91516 | 1:a5258871b33d | 1180 | Opens the (column) door on the GC, by passing it the "COPN" command. |
jmitc91516 | 1:a5258871b33d | 1181 | |
jmitc91516 | 1:a5258871b33d | 1182 | Args are: a pointer to the USBHostGC instance that corresponds to the GC, |
jmitc91516 | 1:a5258871b33d | 1183 | a pointer to the USBDeviceConnected instance that (also) corresponds to the GC |
jmitc91516 | 1:a5258871b33d | 1184 | |
jmitc91516 | 1:a5258871b33d | 1185 | Returns true if the GC returned "DACK" in response, false if it returned "DNAK". |
jmitc91516 | 1:a5258871b33d | 1186 | */ |
jmitc91516 | 1:a5258871b33d | 1187 | bool OpenDoor(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC) |
jmitc91516 | 1:a5258871b33d | 1188 | { |
jmitc91516 | 1:a5258871b33d | 1189 | return ExecuteGCCommand("COPN", usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 1190 | } |
jmitc91516 | 1:a5258871b33d | 1191 | |
jmitc91516 | 1:a5258871b33d | 1192 | |
jmitc91516 | 1:a5258871b33d | 1193 | /* |
jmitc91516 | 1:a5258871b33d | 1194 | Set up the variable "GuiVar_doorActuatorCommandFGColour", to show - depending on |
jmitc91516 | 1:a5258871b33d | 1195 | the current state of the GC - whether the Lock/Unlock facility is enabled or not, |
jmitc91516 | 1:a5258871b33d | 1196 | by displaying the command in black (enabled) or grey (disabled). |
jmitc91516 | 1:a5258871b33d | 1197 | |
jmitc91516 | 1:a5258871b33d | 1198 | Args are: a pointer to the USBHostGC instance that corresponds to the GC, |
jmitc91516 | 1:a5258871b33d | 1199 | a pointer to the USBDeviceConnected instance that (also) corresponds to the GC |
jmitc91516 | 1:a5258871b33d | 1200 | |
jmitc91516 | 1:a5258871b33d | 1201 | No return code. |
jmitc91516 | 1:a5258871b33d | 1202 | */ |
jmitc91516 | 1:a5258871b33d | 1203 | void SetupDoorActuatorCommandColour(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC, bool actuatorsAreMoving) |
jmitc91516 | 1:a5258871b33d | 1204 | { |
jmitc91516 | 1:a5258871b33d | 1205 | // We allow the user to change the state of the actuators only if the GC is in the idle or fault states, |
jmitc91516 | 1:a5258871b33d | 1206 | // and if there is no other reason why they should be disabled (e.g. we are calibrating, and the oven is hot |
jmitc91516 | 1:a5258871b33d | 1207 | // even though the heat is not on. Show this to the user by setting the text colour to black (enabled) |
jmitc91516 | 1:a5258871b33d | 1208 | // or grey (disabled) |
jmitc91516 | 1:a5258871b33d | 1209 | bool enabled = false; |
jmitc91516 | 1:a5258871b33d | 1210 | if(!actuatorsAreMoving) { |
jmitc91516 | 1:a5258871b33d | 1211 | GCStateSimplified simplifiedGCState = GCStateOrFaultCode::GetSimplifiedGCState(GetGCStatus(usbDevice, usbHostGC)); |
jmitc91516 | 1:a5258871b33d | 1212 | if((simplifiedGCState == GC_IDLE) || (simplifiedGCState == GC_FAULTED)) { |
jmitc91516 | 1:a5258871b33d | 1213 | if(canUnlockDoorActuators) { |
jmitc91516 | 1:a5258871b33d | 1214 | enabled = true; |
jmitc91516 | 1:a5258871b33d | 1215 | } |
jmitc91516 | 1:a5258871b33d | 1216 | } |
jmitc91516 | 1:a5258871b33d | 1217 | } |
jmitc91516 | 1:a5258871b33d | 1218 | // All other situations - must be disabled |
jmitc91516 | 1:a5258871b33d | 1219 | |
jmitc91516 | 1:a5258871b33d | 1220 | if(enabled) { |
jmitc91516 | 1:a5258871b33d | 1221 | GuiVar_doorActuatorCommandFGColour = 0; // Black |
jmitc91516 | 1:a5258871b33d | 1222 | } else { |
jmitc91516 | 1:a5258871b33d | 1223 | GuiVar_doorActuatorCommandFGColour = SixteenBitColorValue(192, 192, 192); // Grey - but bright enough to show up against grey button colour |
jmitc91516 | 1:a5258871b33d | 1224 | } |
jmitc91516 | 1:a5258871b33d | 1225 | } |
jmitc91516 | 1:a5258871b33d | 1226 | |
jmitc91516 | 1:a5258871b33d | 1227 | |
jmitc91516 | 1:a5258871b33d | 1228 | typedef enum enumDoorActuatorStatus { LOCKED, UNLOCKED, CLOSED_BUT_NOT_LOCKED, INTERMEDIATE, MOVING } DoorActuatorStatus; |
jmitc91516 | 1:a5258871b33d | 1229 | static bool lockingActuators; // Do not display "Release" while we are doing this |
jmitc91516 | 1:a5258871b33d | 1230 | /* |
jmitc91516 | 1:a5258871b33d | 1231 | Finds out, and returns, the status of the door actuators. |
jmitc91516 | 1:a5258871b33d | 1232 | |
jmitc91516 | 1:a5258871b33d | 1233 | Args are: a pointer to the USBHostGC instance that corresponds to the GC, |
jmitc91516 | 1:a5258871b33d | 1234 | a pointer to the USBDeviceConnected instance that (also) corresponds to the GC |
jmitc91516 | 1:a5258871b33d | 1235 | |
jmitc91516 | 1:a5258871b33d | 1236 | Returns the status, as a value in the 'DoorActuatorStatus' enumeration defined above. |
jmitc91516 | 1:a5258871b33d | 1237 | */ |
jmitc91516 | 1:a5258871b33d | 1238 | DoorActuatorStatus GetDoorActuatorStatus(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC) |
jmitc91516 | 0:47c880c1463d | 1239 | { |
jmitc91516 | 0:47c880c1463d | 1240 | while(usbHostGC->ExecutingSetDeviceReport()) {} |
jmitc91516 | 0:47c880c1463d | 1241 | |
jmitc91516 | 0:47c880c1463d | 1242 | char response[50]; |
jmitc91516 | 1:a5258871b33d | 1243 | usbHostGC->SetDeviceReport(usbDevice, "QACT1004", response); |
jmitc91516 | 1:a5258871b33d | 1244 | |
jmitc91516 | 1:a5258871b33d | 1245 | |
jmitc91516 | 1:a5258871b33d | 1246 | // We expect a response of the form "DACnnnnn", where "nnnnn" is the decimal value |
jmitc91516 | 1:a5258871b33d | 1247 | // of two bytes, the most significant of which contains the states of each of the three actuators, |
jmitc91516 | 1:a5258871b33d | 1248 | // while the least significant contains the software version (which we ignore). |
jmitc91516 | 1:a5258871b33d | 1249 | |
jmitc91516 | 1:a5258871b33d | 1250 | int actuatorStatus; |
jmitc91516 | 1:a5258871b33d | 1251 | sscanf(&response[3], "%d", &actuatorStatus); |
jmitc91516 | 1:a5258871b33d | 1252 | |
jmitc91516 | 1:a5258871b33d | 1253 | if(actuatorStatus & 0x8000) { // Top bit set |
jmitc91516 | 1:a5258871b33d | 1254 | return MOVING; |
jmitc91516 | 1:a5258871b33d | 1255 | } |
jmitc91516 | 1:a5258871b33d | 1256 | |
jmitc91516 | 1:a5258871b33d | 1257 | int actuator1Status = (actuatorStatus & 0x300) >> 8; |
jmitc91516 | 1:a5258871b33d | 1258 | int actuator2Status = (actuatorStatus & 0xC00) >> 10; |
jmitc91516 | 1:a5258871b33d | 1259 | int actuator3Status = (actuatorStatus & 0x3000) >> 12; |
jmitc91516 | 1:a5258871b33d | 1260 | |
jmitc91516 | 1:a5258871b33d | 1261 | // Status 1 means locked, 2 means unlocked, 3 means closed but not locked (actuators 1 and 2 only), |
jmitc91516 | 1:a5258871b33d | 1262 | // 0 means intermediate |
jmitc91516 | 1:a5258871b33d | 1263 | if ((actuator1Status == 1) && (actuator2Status == 1) && (actuator3Status == 1)) { |
jmitc91516 | 1:a5258871b33d | 1264 | return LOCKED; |
jmitc91516 | 1:a5258871b33d | 1265 | } |
jmitc91516 | 1:a5258871b33d | 1266 | // 'else' ... |
jmitc91516 | 1:a5258871b33d | 1267 | if((actuator1Status == 2) && (actuator2Status == 2) && (actuator3Status == 2)) { |
jmitc91516 | 1:a5258871b33d | 1268 | return UNLOCKED; |
jmitc91516 | 1:a5258871b33d | 1269 | } |
jmitc91516 | 1:a5258871b33d | 1270 | // 'else' ... |
jmitc91516 | 1:a5258871b33d | 1271 | if((actuator1Status == 3) && (actuator2Status == 3) && (actuator3Status == 2)) { |
jmitc91516 | 1:a5258871b33d | 1272 | return CLOSED_BUT_NOT_LOCKED; |
jmitc91516 | 1:a5258871b33d | 1273 | } |
jmitc91516 | 1:a5258871b33d | 1274 | // 'else' ... |
jmitc91516 | 1:a5258871b33d | 1275 | return INTERMEDIATE; |
jmitc91516 | 1:a5258871b33d | 1276 | } |
jmitc91516 | 1:a5258871b33d | 1277 | |
jmitc91516 | 1:a5258871b33d | 1278 | /* |
jmitc91516 | 1:a5258871b33d | 1279 | We have now replaced the "Open Door" button with a button to toggle |
jmitc91516 | 1:a5258871b33d | 1280 | the state of the door actuators - i.e. lock them if they are unlocked |
jmitc91516 | 1:a5258871b33d | 1281 | and vice versa. We display the corresponding command in the easyGUI variable |
jmitc91516 | 1:a5258871b33d | 1282 | "GuiVar_doorActuatorCommand". This function reads the current state |
jmitc91516 | 1:a5258871b33d | 1283 | of the actuators, and sets up that variable appropriately. It also sets up |
jmitc91516 | 1:a5258871b33d | 1284 | the variable "GuiVar_doorActuatorCommandFGColour", to show - depending on |
jmitc91516 | 1:a5258871b33d | 1285 | the current state of the GC - whether the facility is enabled or not, |
jmitc91516 | 1:a5258871b33d | 1286 | by displaying the command in black (enabled) or grey (disabled). |
jmitc91516 | 1:a5258871b33d | 1287 | |
jmitc91516 | 1:a5258871b33d | 1288 | It also now - since we have a separate state for "closed but not locked" - |
jmitc91516 | 1:a5258871b33d | 1289 | displays the two "Lock" and "Release" buttons if required. |
jmitc91516 | 1:a5258871b33d | 1290 | |
jmitc91516 | 1:a5258871b33d | 1291 | Args are: a pointer to the USBHostGC instance that corresponds to the GC, |
jmitc91516 | 1:a5258871b33d | 1292 | a pointer to the USBDeviceConnected instance that (also) corresponds to the GC |
jmitc91516 | 1:a5258871b33d | 1293 | a boolean set to true before displaying the easyGUI page (GuiLib_ShowScreen), false if afterwards |
jmitc91516 | 1:a5258871b33d | 1294 | |
jmitc91516 | 1:a5258871b33d | 1295 | No return code. |
jmitc91516 | 1:a5258871b33d | 1296 | */ |
jmitc91516 | 1:a5258871b33d | 1297 | void SetupDoorActuatorCommandUserInterface(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC, bool beforePageDisplay) |
jmitc91516 | 1:a5258871b33d | 1298 | { |
jmitc91516 | 1:a5258871b33d | 1299 | //#define DEBUG_PRINT_HERE |
jmitc91516 | 1:a5258871b33d | 1300 | #ifdef DEBUG_PRINT_HERE |
jmitc91516 | 1:a5258871b33d | 1301 | char buff[100]; |
jmitc91516 | 1:a5258871b33d | 1302 | sprintf(buff, "%s", beforePageDisplay ? "Before page display" : "After page display"); |
jmitc91516 | 1:a5258871b33d | 1303 | SpecialDebugPrint(buff, 150, 430); |
jmitc91516 | 1:a5258871b33d | 1304 | #endif |
jmitc91516 | 1:a5258871b33d | 1305 | |
jmitc91516 | 1:a5258871b33d | 1306 | DoorActuatorStatus doorActuatorStatus = GetDoorActuatorStatus(usbDevice, usbHostGC); |
jmitc91516 | 0:47c880c1463d | 1307 | |
jmitc91516 | 1:a5258871b33d | 1308 | // SetupDoorActuatorCommandColour(usbDevice, usbHostGC, (doorActuatorStatus == MOVING)); |
jmitc91516 | 1:a5258871b33d | 1309 | SetupDoorActuatorCommandColour(usbDevice, usbHostGC, false); |
jmitc91516 | 1:a5258871b33d | 1310 | |
jmitc91516 | 1:a5258871b33d | 1311 | if(beforePageDisplay) { |
jmitc91516 | 1:a5258871b33d | 1312 | |
jmitc91516 | 1:a5258871b33d | 1313 | // Do nothing - do not change the button text, etc - if the actuators are moving |
jmitc91516 | 1:a5258871b33d | 1314 | if(doorActuatorStatus != MOVING) { |
jmitc91516 | 1:a5258871b33d | 1315 | if(doorActuatorStatus == UNLOCKED) { |
jmitc91516 | 1:a5258871b33d | 1316 | strcpy(GuiVar_doorActuatorCommand, "Close"); |
jmitc91516 | 1:a5258871b33d | 1317 | } else if (doorActuatorStatus == LOCKED) { |
jmitc91516 | 1:a5258871b33d | 1318 | strcpy(GuiVar_doorActuatorCommand, "Unlock"); |
jmitc91516 | 1:a5258871b33d | 1319 | lockingActuators = false; |
jmitc91516 | 1:a5258871b33d | 1320 | } else { // i.e. all other states, including INTERMEDIATE (possible emergency stop) |
jmitc91516 | 1:a5258871b33d | 1321 | if(!lockingActuators) { // Do not display this while we are locking - confusing |
jmitc91516 | 1:a5258871b33d | 1322 | strcpy(GuiVar_doorActuatorCommand, "Release"); |
jmitc91516 | 1:a5258871b33d | 1323 | } |
jmitc91516 | 1:a5258871b33d | 1324 | } |
jmitc91516 | 1:a5258871b33d | 1325 | } |
jmitc91516 | 1:a5258871b33d | 1326 | } else { |
jmitc91516 | 1:a5258871b33d | 1327 | if(doorActuatorStatus == CLOSED_BUT_NOT_LOCKED) { |
jmitc91516 | 1:a5258871b33d | 1328 | GetGCStatusLoop::DisplayColumnLockAndReleaseButtons(); |
jmitc91516 | 1:a5258871b33d | 1329 | #ifdef DEBUG_PRINT_HERE |
jmitc91516 | 1:a5258871b33d | 1330 | char buff2[100]; |
jmitc91516 | 1:a5258871b33d | 1331 | sprintf(buff2, "%s", "Drawing lock and release buttons"); |
jmitc91516 | 1:a5258871b33d | 1332 | SpecialDebugPrint(buff2, 150, 460); |
jmitc91516 | 1:a5258871b33d | 1333 | #endif |
jmitc91516 | 1:a5258871b33d | 1334 | } else { // Including MOVING |
jmitc91516 | 1:a5258871b33d | 1335 | DrawBackgroundBitmapOverDoorLockAndReleaseButtons(); |
jmitc91516 | 1:a5258871b33d | 1336 | #ifdef DEBUG_PRINT_HERE |
jmitc91516 | 1:a5258871b33d | 1337 | char buff2[100]; |
jmitc91516 | 1:a5258871b33d | 1338 | sprintf(buff2, "%s", "*** NOT *** drawing lock and release buttons"); |
jmitc91516 | 1:a5258871b33d | 1339 | SpecialDebugPrint(buff2, 150, 460); |
jmitc91516 | 1:a5258871b33d | 1340 | #undef DEBUG_PRINT_HERE |
jmitc91516 | 1:a5258871b33d | 1341 | #endif |
jmitc91516 | 1:a5258871b33d | 1342 | } |
jmitc91516 | 1:a5258871b33d | 1343 | } |
jmitc91516 | 1:a5258871b33d | 1344 | } |
jmitc91516 | 1:a5258871b33d | 1345 | |
jmitc91516 | 1:a5258871b33d | 1346 | |
jmitc91516 | 1:a5258871b33d | 1347 | /* |
jmitc91516 | 1:a5258871b33d | 1348 | Tells the caller whether or not the door actuator buttons have changed, |
jmitc91516 | 1:a5258871b33d | 1349 | from the single "Close"/"Unlock" button to the two "Lock" and "Release" buttons, |
jmitc91516 | 1:a5258871b33d | 1350 | or vice versa |
jmitc91516 | 1:a5258871b33d | 1351 | */ |
jmitc91516 | 1:a5258871b33d | 1352 | bool DoorActuatorButtonsHaveChanged(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC) |
jmitc91516 | 1:a5258871b33d | 1353 | { |
jmitc91516 | 1:a5258871b33d | 1354 | bool doorActuatorButtonsHaveChanged = false; |
jmitc91516 | 0:47c880c1463d | 1355 | |
jmitc91516 | 1:a5258871b33d | 1356 | static DoorActuatorStatus previousDoorActuatorStatus = INTERMEDIATE; |
jmitc91516 | 1:a5258871b33d | 1357 | |
jmitc91516 | 1:a5258871b33d | 1358 | DoorActuatorStatus doorActuatorStatus = GetDoorActuatorStatus(usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 1359 | |
jmitc91516 | 1:a5258871b33d | 1360 | // Do not change buttons if actuators are moving |
jmitc91516 | 1:a5258871b33d | 1361 | if(doorActuatorStatus != MOVING) { |
jmitc91516 | 1:a5258871b33d | 1362 | if((doorActuatorStatus == LOCKED) || (doorActuatorStatus == UNLOCKED)) { |
jmitc91516 | 1:a5258871b33d | 1363 | if((previousDoorActuatorStatus == CLOSED_BUT_NOT_LOCKED) || (previousDoorActuatorStatus == INTERMEDIATE)) { |
jmitc91516 | 1:a5258871b33d | 1364 | doorActuatorButtonsHaveChanged = true; |
jmitc91516 | 1:a5258871b33d | 1365 | } |
jmitc91516 | 1:a5258871b33d | 1366 | } else if (doorActuatorStatus == CLOSED_BUT_NOT_LOCKED) { |
jmitc91516 | 1:a5258871b33d | 1367 | if(previousDoorActuatorStatus != CLOSED_BUT_NOT_LOCKED) { |
jmitc91516 | 1:a5258871b33d | 1368 | doorActuatorButtonsHaveChanged = true; |
jmitc91516 | 1:a5258871b33d | 1369 | } |
jmitc91516 | 1:a5258871b33d | 1370 | } |
jmitc91516 | 1:a5258871b33d | 1371 | |
jmitc91516 | 1:a5258871b33d | 1372 | // We ignore the 'moving' state |
jmitc91516 | 1:a5258871b33d | 1373 | previousDoorActuatorStatus = doorActuatorStatus; |
jmitc91516 | 1:a5258871b33d | 1374 | } |
jmitc91516 | 1:a5258871b33d | 1375 | |
jmitc91516 | 1:a5258871b33d | 1376 | return doorActuatorButtonsHaveChanged; |
jmitc91516 | 1:a5258871b33d | 1377 | } |
jmitc91516 | 1:a5258871b33d | 1378 | |
jmitc91516 | 1:a5258871b33d | 1379 | |
jmitc91516 | 1:a5258871b33d | 1380 | /* |
jmitc91516 | 1:a5258871b33d | 1381 | Toggles the state of the door actuator on the GC - i.e. if it is locked, |
jmitc91516 | 1:a5258871b33d | 1382 | unlocks it, and vice versa. |
jmitc91516 | 1:a5258871b33d | 1383 | |
jmitc91516 | 1:a5258871b33d | 1384 | Args are: the index of the touch area the user touched (note that we assume |
jmitc91516 | 1:a5258871b33d | 1385 | this must be one of the 'door actuator areas' (seeEasyGUITouchAreaIndices.h) |
jmitc91516 | 1:a5258871b33d | 1386 | a pointer to the USBHostGC instance that corresponds to the GC, |
jmitc91516 | 1:a5258871b33d | 1387 | a pointer to the USBDeviceConnected instance that (also) corresponds to the GC |
jmitc91516 | 1:a5258871b33d | 1388 | |
jmitc91516 | 1:a5258871b33d | 1389 | Returns true if the GC executed the operation successfully, false if not |
jmitc91516 | 1:a5258871b33d | 1390 | */ |
jmitc91516 | 1:a5258871b33d | 1391 | bool DealWithDoorActuatorButtons(int touchAreaIndex, USBDeviceConnected* usbDevice, USBHostGC* usbHostGC) |
jmitc91516 | 1:a5258871b33d | 1392 | { |
jmitc91516 | 1:a5258871b33d | 1393 | // Disallow movement unless GC is in idle or faulted states |
jmitc91516 | 1:a5258871b33d | 1394 | int gcStatus = GetGCStatus(usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 1395 | GCStateSimplified simplifiedGCState = GCStateOrFaultCode::GetSimplifiedGCState(gcStatus); |
jmitc91516 | 1:a5258871b33d | 1396 | if((simplifiedGCState != GC_IDLE) && (simplifiedGCState != GC_FAULTED)) { |
jmitc91516 | 1:a5258871b33d | 1397 | return false; |
jmitc91516 | 0:47c880c1463d | 1398 | } |
jmitc91516 | 0:47c880c1463d | 1399 | |
jmitc91516 | 1:a5258871b33d | 1400 | bool bOK = false; |
jmitc91516 | 1:a5258871b33d | 1401 | |
jmitc91516 | 1:a5258871b33d | 1402 | DoorActuatorStatus doorActuatorStatus = GetDoorActuatorStatus(usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 1403 | |
jmitc91516 | 1:a5258871b33d | 1404 | if(doorActuatorStatus != MOVING) { |
jmitc91516 | 1:a5258871b33d | 1405 | if(doorActuatorStatus == UNLOCKED) { |
jmitc91516 | 1:a5258871b33d | 1406 | // Two touch areas, but only one button - treat both the same |
jmitc91516 | 1:a5258871b33d | 1407 | // Close actuator, but do not lock it |
jmitc91516 | 1:a5258871b33d | 1408 | bOK = ExecuteGCCommand("CACT1005", usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 1409 | } else if (doorActuatorStatus == LOCKED) { |
jmitc91516 | 1:a5258871b33d | 1410 | // Two touch areas, but only one button - treat both the same |
jmitc91516 | 1:a5258871b33d | 1411 | // Unlock actuator |
jmitc91516 | 1:a5258871b33d | 1412 | bOK = ExecuteGCCommand("CACT1006", usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 1413 | } else if (doorActuatorStatus == CLOSED_BUT_NOT_LOCKED) { |
jmitc91516 | 1:a5258871b33d | 1414 | // Unlock or Lock, depending on the touch area |
jmitc91516 | 1:a5258871b33d | 1415 | if(touchAreaIndex == DOOR_ACTUATOR_AREA_1) { |
jmitc91516 | 1:a5258871b33d | 1416 | // Lock |
jmitc91516 | 1:a5258871b33d | 1417 | bOK = ExecuteGCCommand("CACT1007", usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 1418 | if(bOK) { |
jmitc91516 | 1:a5258871b33d | 1419 | lockingActuators = true; |
jmitc91516 | 1:a5258871b33d | 1420 | // Get the text ready for the Close/Unlock button |
jmitc91516 | 1:a5258871b33d | 1421 | strcpy(GuiVar_doorActuatorCommand, "Unlock"); |
jmitc91516 | 1:a5258871b33d | 1422 | } |
jmitc91516 | 1:a5258871b33d | 1423 | } else { |
jmitc91516 | 1:a5258871b33d | 1424 | // Assume DOOR_ACTUATOR_AREA_2 - release, i.e. unlock |
jmitc91516 | 1:a5258871b33d | 1425 | bOK = ExecuteGCCommand("CACT1006", usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 1426 | if(bOK) { |
jmitc91516 | 1:a5258871b33d | 1427 | // Get the text ready for the Close/Unlock button |
jmitc91516 | 1:a5258871b33d | 1428 | strcpy(GuiVar_doorActuatorCommand, "Close"); |
jmitc91516 | 1:a5258871b33d | 1429 | } |
jmitc91516 | 1:a5258871b33d | 1430 | } |
jmitc91516 | 1:a5258871b33d | 1431 | } else { // Assume INTERMEDIATE - for safety, always unlock |
jmitc91516 | 1:a5258871b33d | 1432 | bOK = ExecuteGCCommand("CACT1006", usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 1433 | } |
jmitc91516 | 1:a5258871b33d | 1434 | } |
jmitc91516 | 1:a5258871b33d | 1435 | |
jmitc91516 | 1:a5258871b33d | 1436 | if(bOK) { |
jmitc91516 | 1:a5258871b33d | 1437 | SetupDoorActuatorCommandUserInterface(usbDevice, usbHostGC, false); |
jmitc91516 | 1:a5258871b33d | 1438 | } |
jmitc91516 | 1:a5258871b33d | 1439 | |
jmitc91516 | 1:a5258871b33d | 1440 | return bOK; |
jmitc91516 | 1:a5258871b33d | 1441 | } |
jmitc91516 | 1:a5258871b33d | 1442 | |
jmitc91516 | 1:a5258871b33d | 1443 | |
jmitc91516 | 1:a5258871b33d | 1444 | /* |
jmitc91516 | 1:a5258871b33d | 1445 | Tells the caller whether or not a specified GC command represents the start of a method, |
jmitc91516 | 1:a5258871b33d | 1446 | and that therefore a new method is now being sent to the GC. |
jmitc91516 | 1:a5258871b33d | 1447 | |
jmitc91516 | 1:a5258871b33d | 1448 | Params: pointer to a null-terminated string containing the command in question |
jmitc91516 | 1:a5258871b33d | 1449 | |
jmitc91516 | 1:a5258871b33d | 1450 | Returns true if the command is one that occurs at the start of a method (and nowhere else), |
jmitc91516 | 1:a5258871b33d | 1451 | false if not. |
jmitc91516 | 1:a5258871b33d | 1452 | |
jmitc91516 | 1:a5258871b33d | 1453 | This code is intended to be as efficient as possible. |
jmitc91516 | 1:a5258871b33d | 1454 | |
jmitc91516 | 1:a5258871b33d | 1455 | Currently, called from GetGCStatusLoop class and EthernetThread class |
jmitc91516 | 1:a5258871b33d | 1456 | */ |
jmitc91516 | 1:a5258871b33d | 1457 | bool IsStartOfMethodCommand(char *gcCommand) |
jmitc91516 | 1:a5258871b33d | 1458 | { |
jmitc91516 | 1:a5258871b33d | 1459 | // We are looking for "CLCK" - lock local keyboard. |
jmitc91516 | 1:a5258871b33d | 1460 | // Ellution only sends this at the start of a method. |
jmitc91516 | 1:a5258871b33d | 1461 | |
jmitc91516 | 1:a5258871b33d | 1462 | if((gcCommand[0] == 'C') && (gcCommand[1] == 'L') && (gcCommand[2] == 'C') && (gcCommand[3] == 'K')) { |
jmitc91516 | 1:a5258871b33d | 1463 | return true; |
jmitc91516 | 1:a5258871b33d | 1464 | } |
jmitc91516 | 1:a5258871b33d | 1465 | |
jmitc91516 | 1:a5258871b33d | 1466 | return false; // Not "CLCK" |
jmitc91516 | 1:a5258871b33d | 1467 | } |
jmitc91516 | 1:a5258871b33d | 1468 | |
jmitc91516 | 1:a5258871b33d | 1469 | /* |
jmitc91516 | 1:a5258871b33d | 1470 | Tells the caller whether or not a specified GC command represents the end of a method, |
jmitc91516 | 1:a5258871b33d | 1471 | and that therefore a new method has just been sent to the GC. |
jmitc91516 | 1:a5258871b33d | 1472 | |
jmitc91516 | 1:a5258871b33d | 1473 | Params: pointer to a null-terminated string containing the command in question |
jmitc91516 | 1:a5258871b33d | 1474 | |
jmitc91516 | 1:a5258871b33d | 1475 | Returns true if the command is one that occurs at the end of a method (and nowhere else), |
jmitc91516 | 1:a5258871b33d | 1476 | false if not. |
jmitc91516 | 1:a5258871b33d | 1477 | |
jmitc91516 | 1:a5258871b33d | 1478 | This code is intended to be as efficient as possible. |
jmitc91516 | 1:a5258871b33d | 1479 | |
jmitc91516 | 1:a5258871b33d | 1480 | Currently, called from GetGCStatusLoop class and EthernetThread class |
jmitc91516 | 1:a5258871b33d | 1481 | */ |
jmitc91516 | 1:a5258871b33d | 1482 | bool IsEndOfMethodCommand(char *gcCommand) |
jmitc91516 | 1:a5258871b33d | 1483 | { |
jmitc91516 | 1:a5258871b33d | 1484 | // We are looking for "CULK" - unlock local keyboard. |
jmitc91516 | 1:a5258871b33d | 1485 | // Ellution only sends this at the end of a method. |
jmitc91516 | 1:a5258871b33d | 1486 | |
jmitc91516 | 1:a5258871b33d | 1487 | if((gcCommand[0] == 'C') && (gcCommand[1] == 'U') && (gcCommand[2] == 'L') && (gcCommand[3] == 'K')) { |
jmitc91516 | 1:a5258871b33d | 1488 | return true; |
jmitc91516 | 1:a5258871b33d | 1489 | } |
jmitc91516 | 1:a5258871b33d | 1490 | |
jmitc91516 | 1:a5258871b33d | 1491 | return false; // Not "CULK" |
jmitc91516 | 0:47c880c1463d | 1492 | } |
jmitc91516 | 0:47c880c1463d | 1493 | |
jmitc91516 | 1:a5258871b33d | 1494 | |
jmitc91516 | 1:a5258871b33d | 1495 | /* |
jmitc91516 | 1:a5258871b33d | 1496 | Tells the caller whether or not a specified GC command is a control command, |
jmitc91516 | 1:a5258871b33d | 1497 | which received "DACK" in acknowledgement, and is therefore likely |
jmitc91516 | 1:a5258871b33d | 1498 | to have caused the GC to change its state. |
jmitc91516 | 1:a5258871b33d | 1499 | |
jmitc91516 | 1:a5258871b33d | 1500 | Params: pointer to a null-terminated string containing the command in question |
jmitc91516 | 1:a5258871b33d | 1501 | |
jmitc91516 | 1:a5258871b33d | 1502 | Returns true if the command is a control command and if it succeeded, false if not. |
jmitc91516 | 1:a5258871b33d | 1503 | |
jmitc91516 | 1:a5258871b33d | 1504 | This code is intended to be as efficient as possible. |
jmitc91516 | 1:a5258871b33d | 1505 | |
jmitc91516 | 1:a5258871b33d | 1506 | Currently, called from GetGCStatusLoop class and EthernetThread class |
jmitc91516 | 1:a5258871b33d | 1507 | */ |
jmitc91516 | 1:a5258871b33d | 1508 | bool IsSuccessfulControlCommand(char* gcCommand, char* gcResponse) |
jmitc91516 | 1:a5258871b33d | 1509 | { |
jmitc91516 | 1:a5258871b33d | 1510 | // Simple criteria - does the command start with 'C'? |
jmitc91516 | 1:a5258871b33d | 1511 | // - was the response "DACK"? |
jmitc91516 | 1:a5258871b33d | 1512 | |
jmitc91516 | 1:a5258871b33d | 1513 | if(gcCommand[0] != 'C') { |
jmitc91516 | 1:a5258871b33d | 1514 | return false; |
jmitc91516 | 1:a5258871b33d | 1515 | } |
jmitc91516 | 1:a5258871b33d | 1516 | |
jmitc91516 | 1:a5258871b33d | 1517 | |
jmitc91516 | 1:a5258871b33d | 1518 | if(gcResponse[0] != 'D') { |
jmitc91516 | 1:a5258871b33d | 1519 | return false; |
jmitc91516 | 1:a5258871b33d | 1520 | } |
jmitc91516 | 1:a5258871b33d | 1521 | |
jmitc91516 | 1:a5258871b33d | 1522 | if(gcResponse[1] != 'A') { |
jmitc91516 | 1:a5258871b33d | 1523 | return false; |
jmitc91516 | 1:a5258871b33d | 1524 | } |
jmitc91516 | 1:a5258871b33d | 1525 | |
jmitc91516 | 1:a5258871b33d | 1526 | if(gcResponse[2] != 'C') { |
jmitc91516 | 1:a5258871b33d | 1527 | return false; |
jmitc91516 | 1:a5258871b33d | 1528 | } |
jmitc91516 | 1:a5258871b33d | 1529 | |
jmitc91516 | 1:a5258871b33d | 1530 | if(gcResponse[3] != 'K') { |
jmitc91516 | 1:a5258871b33d | 1531 | return false; |
jmitc91516 | 1:a5258871b33d | 1532 | } |
jmitc91516 | 1:a5258871b33d | 1533 | |
jmitc91516 | 1:a5258871b33d | 1534 | // All the above were true |
jmitc91516 | 1:a5258871b33d | 1535 | return true; |
jmitc91516 | 1:a5258871b33d | 1536 | } |
jmitc91516 | 1:a5258871b33d | 1537 | |
jmitc91516 | 1:a5258871b33d | 1538 | |
jmitc91516 | 1:a5258871b33d | 1539 | /* |
jmitc91516 | 1:a5258871b33d | 1540 | Increment the run count recorded in the QSPI settings. |
jmitc91516 | 1:a5258871b33d | 1541 | |
jmitc91516 | 1:a5258871b33d | 1542 | This would be called (for example) after the Run button has been pressed. |
jmitc91516 | 1:a5258871b33d | 1543 | */ |
jmitc91516 | 1:a5258871b33d | 1544 | void IncrementRunCountInQSPISettings(void) |
jmitc91516 | 0:47c880c1463d | 1545 | { |
jmitc91516 | 1:a5258871b33d | 1546 | int runCount = SettingsHandler::GetIntegerValueFromQSPISettings("RunCount", 0); |
jmitc91516 | 1:a5258871b33d | 1547 | |
jmitc91516 | 1:a5258871b33d | 1548 | // Debug prints |
jmitc91516 | 1:a5258871b33d | 1549 | char dbg[100]; |
jmitc91516 | 1:a5258871b33d | 1550 | sprintf(dbg, "Run count read: %d", runCount); |
jmitc91516 | 1:a5258871b33d | 1551 | EasyGUIDebugPrint(dbg, 500, 460); |
jmitc91516 | 1:a5258871b33d | 1552 | |
jmitc91516 | 1:a5258871b33d | 1553 | SettingsHandler::DisplayQSPIDirectory(600, 250); |
jmitc91516 | 1:a5258871b33d | 1554 | // End of debug prints |
jmitc91516 | 1:a5258871b33d | 1555 | |
jmitc91516 | 1:a5258871b33d | 1556 | ++runCount; |
jmitc91516 | 1:a5258871b33d | 1557 | |
jmitc91516 | 1:a5258871b33d | 1558 | SettingsHandler::PutIntegerValueToQSPISettings("RunCount", runCount); |
jmitc91516 | 1:a5258871b33d | 1559 | } |
jmitc91516 | 1:a5258871b33d | 1560 | |
jmitc91516 | 1:a5258871b33d | 1561 | /* |
jmitc91516 | 1:a5258871b33d | 1562 | Update the values of all the easyGUI variables whose values are derived |
jmitc91516 | 1:a5258871b33d | 1563 | from the run count. This should be called (for example) after |
jmitc91516 | 1:a5258871b33d | 1564 | the Run button has been pressed. |
jmitc91516 | 1:a5258871b33d | 1565 | */ |
jmitc91516 | 1:a5258871b33d | 1566 | void UpdateAllEasyGUIVariablesThatDependOnRunCount(void) |
jmitc91516 | 1:a5258871b33d | 1567 | { |
jmitc91516 | 1:a5258871b33d | 1568 | int runCount = SettingsHandler::GetIntegerValueFromQSPISettings("RunCount", 0); |
jmitc91516 | 1:a5258871b33d | 1569 | |
jmitc91516 | 1:a5258871b33d | 1570 | int columnInstalledRunCount = SettingsHandler::GetIntegerValueFromQSPISettings("RunCountWhenColumnInstalled", 0); |
jmitc91516 | 1:a5258871b33d | 1571 | sprintf(GuiVar_columnInjectionsSinceInstallation, "%d", (runCount - columnInstalledRunCount)); |
jmitc91516 | 1:a5258871b33d | 1572 | |
jmitc91516 | 1:a5258871b33d | 1573 | int linerChangedRunCount = SettingsHandler::GetIntegerValueFromQSPISettings("RunCountWhenLinerChanged", 0); |
jmitc91516 | 1:a5258871b33d | 1574 | sprintf(GuiVar_injectionCountSinceLinerChanged, "%d", (runCount - linerChangedRunCount)); |
jmitc91516 | 1:a5258871b33d | 1575 | |
jmitc91516 | 1:a5258871b33d | 1576 | int septaChangedRunCount = SettingsHandler::GetIntegerValueFromQSPISettings("RunCountWhenSeptaChanged", 0); |
jmitc91516 | 1:a5258871b33d | 1577 | sprintf(GuiVar_injectionCountSinceSeptaChanged, "%d", (runCount - septaChangedRunCount)); |
jmitc91516 | 1:a5258871b33d | 1578 | |
jmitc91516 | 1:a5258871b33d | 1579 | int oRingChangedRunCount = SettingsHandler::GetIntegerValueFromQSPISettings("RunCountWhenOringChanged", 0); |
jmitc91516 | 1:a5258871b33d | 1580 | sprintf(GuiVar_injectionCountSinceOringChanged, "%d", (runCount - oRingChangedRunCount)); |
jmitc91516 | 1:a5258871b33d | 1581 | } |
jmitc91516 | 1:a5258871b33d | 1582 | |
jmitc91516 | 1:a5258871b33d | 1583 | |
jmitc91516 | 1:a5258871b33d | 1584 | /* |
jmitc91516 | 1:a5258871b33d | 1585 | Sends the specified command to the GC. |
jmitc91516 | 1:a5258871b33d | 1586 | |
jmitc91516 | 1:a5258871b33d | 1587 | This must be a "Sxxx" command, that only expects "DACK" or "DNAK" back, |
jmitc91516 | 1:a5258871b33d | 1588 | not actual data. |
jmitc91516 | 1:a5258871b33d | 1589 | |
jmitc91516 | 1:a5258871b33d | 1590 | Args are: a pointer to the USBHostGC instance that corresponds to the GC, |
jmitc91516 | 1:a5258871b33d | 1591 | a pointer to the USBDeviceConnected instance that (also) corresponds to the GC |
jmitc91516 | 1:a5258871b33d | 1592 | |
jmitc91516 | 1:a5258871b33d | 1593 | Returns true if the GC returned "DACK" in response, false if it returned "DNAK". |
jmitc91516 | 1:a5258871b33d | 1594 | */ |
jmitc91516 | 1:a5258871b33d | 1595 | bool SendAnyCommandToGC(char *cmd, USBDeviceConnected* usbDevice, USBHostGC* usbHostGC) |
jmitc91516 | 1:a5258871b33d | 1596 | { |
jmitc91516 | 1:a5258871b33d | 1597 | #define USE_GC_UTILS // Testing new class |
jmitc91516 | 1:a5258871b33d | 1598 | #ifdef USE_GC_UTILS |
jmitc91516 | 1:a5258871b33d | 1599 | return USBHostGCUtilities::SendCommandToGCWithDACKResponse(usbDevice, usbHostGC, cmd); |
jmitc91516 | 1:a5258871b33d | 1600 | #else |
jmitc91516 | 0:47c880c1463d | 1601 | while(usbHostGC->ExecutingSetDeviceReport()) {} |
jmitc91516 | 0:47c880c1463d | 1602 | |
jmitc91516 | 0:47c880c1463d | 1603 | char response[50]; |
jmitc91516 | 1:a5258871b33d | 1604 | usbHostGC->SetDeviceReport(usbDevice, cmd, response); |
jmitc91516 | 0:47c880c1463d | 1605 | // We expect a response like this: "DACK" for success, "DNAK" for failure |
jmitc91516 | 0:47c880c1463d | 1606 | |
jmitc91516 | 0:47c880c1463d | 1607 | return (response[1] == 'A'); |
jmitc91516 | 1:a5258871b33d | 1608 | #endif // USE_GC_UTILS |
jmitc91516 | 1:a5258871b33d | 1609 | } |
jmitc91516 | 1:a5258871b33d | 1610 | |
jmitc91516 | 1:a5258871b33d | 1611 | |
jmitc91516 | 1:a5258871b33d | 1612 | /* |
jmitc91516 | 1:a5258871b33d | 1613 | This function performs the "set up" operations required |
jmitc91516 | 1:a5258871b33d | 1614 | when the GC starts running. It is intended to be called |
jmitc91516 | 1:a5258871b33d | 1615 | whenever the GC starts running - note that this may happen |
jmitc91516 | 1:a5258871b33d | 1616 | not only when the user presses our "Run" button, but if |
jmitc91516 | 1:a5258871b33d | 1617 | he sends a "CRUN" command to the GC from the PC (e.g. using |
jmitc91516 | 1:a5258871b33d | 1618 | Ellution), or if something triggers the "Run" pin |
jmitc91516 | 1:a5258871b33d | 1619 | on the GC board itself (and that does not pass through |
jmitc91516 | 1:a5258871b33d | 1620 | the LPC4088, so it cannot be detected directly by this software). |
jmitc91516 | 1:a5258871b33d | 1621 | |
jmitc91516 | 1:a5258871b33d | 1622 | Args are: a pointer to the USBHostGC instance that corresponds to the GC, |
jmitc91516 | 1:a5258871b33d | 1623 | a pointer to the USBDeviceConnected instance that (also) corresponds to the GC |
jmitc91516 | 1:a5258871b33d | 1624 | |
jmitc91516 | 1:a5258871b33d | 1625 | No return code |
jmitc91516 | 1:a5258871b33d | 1626 | */ |
jmitc91516 | 1:a5258871b33d | 1627 | void SetupForStartOfRun(USBDeviceConnected* usbDevice, USBHostGC* usbHostGC) |
jmitc91516 | 1:a5258871b33d | 1628 | { |
jmitc91516 | 1:a5258871b33d | 1629 | if(getGCStatusLoop != NULL) { |
jmitc91516 | 1:a5258871b33d | 1630 | getGCStatusLoop->SetGCIsRunning(); |
jmitc91516 | 1:a5258871b33d | 1631 | IncrementRunCountInQSPISettings(); |
jmitc91516 | 1:a5258871b33d | 1632 | UpdateAllEasyGUIVariablesThatDependOnRunCount(); |
jmitc91516 | 1:a5258871b33d | 1633 | getGCStatusLoop->UpdateGCMethodRunningProfiles(); |
jmitc91516 | 1:a5258871b33d | 1634 | getGCStatusLoop->SetRunningPage1ProgressBarToZero(); |
jmitc91516 | 1:a5258871b33d | 1635 | getGCStatusLoop->SetupTemperatureWhileRunningEasyGUIVariables(); |
jmitc91516 | 1:a5258871b33d | 1636 | DisplayEasyGuiStructure(GuiStruct_RunningPage1_7, usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 1637 | } |
jmitc91516 | 0:47c880c1463d | 1638 | } |
jmitc91516 | 0:47c880c1463d | 1639 | |
jmitc91516 | 1:a5258871b33d | 1640 | |
jmitc91516 | 1:a5258871b33d | 1641 | static void RemoveUnitsFromEasyGUIStringIfFound(char* destination, GuiConst_TEXT* easyGUIString, char* units) |
jmitc91516 | 1:a5258871b33d | 1642 | { |
jmitc91516 | 1:a5258871b33d | 1643 | strcpy(destination, easyGUIString); |
jmitc91516 | 1:a5258871b33d | 1644 | |
jmitc91516 | 1:a5258871b33d | 1645 | int unitsLength = strlen(units); |
jmitc91516 | 1:a5258871b33d | 1646 | int stringLength = strlen(destination); |
jmitc91516 | 1:a5258871b33d | 1647 | |
jmitc91516 | 1:a5258871b33d | 1648 | if(strcmp(units, &destination[stringLength - unitsLength]) == 0) { |
jmitc91516 | 1:a5258871b33d | 1649 | destination[stringLength - unitsLength] = '\0'; |
jmitc91516 | 1:a5258871b33d | 1650 | } |
jmitc91516 | 1:a5258871b33d | 1651 | } |
jmitc91516 | 1:a5258871b33d | 1652 | |
jmitc91516 | 1:a5258871b33d | 1653 | |
jmitc91516 | 1:a5258871b33d | 1654 | /* |
jmitc91516 | 1:a5258871b33d | 1655 | This is the main function dealing with user interaction via the LPC4088 touch panel. |
jmitc91516 | 1:a5258871b33d | 1656 | ************************************************************************************ |
jmitc91516 | 1:a5258871b33d | 1657 | |
jmitc91516 | 1:a5258871b33d | 1658 | It is (currently, until we rationalise this code) called by the GetGCStatusLoop code |
jmitc91516 | 1:a5258871b33d | 1659 | that deals with touch events. (Ideally, we should move it into the GetGCStatusLoop class |
jmitc91516 | 1:a5258871b33d | 1660 | at some point.) |
jmitc91516 | 1:a5258871b33d | 1661 | |
jmitc91516 | 1:a5258871b33d | 1662 | Args are: the touch coordinates (x, y and z - we do not use the z coordinate) |
jmitc91516 | 1:a5258871b33d | 1663 | a pointer to the USBHostGC instance that corresponds to the GC, |
jmitc91516 | 1:a5258871b33d | 1664 | a pointer to the USBDeviceConnected instance that (also) corresponds to the GC |
jmitc91516 | 1:a5258871b33d | 1665 | a count of timer ticks |
jmitc91516 | 1:a5258871b33d | 1666 | a boolean set to true if the touch is 'new', false if not (a touch is 'new' |
jmitc91516 | 1:a5258871b33d | 1667 | if it occurs after a period when the user appears not to have touched the screen). |
jmitc91516 | 1:a5258871b33d | 1668 | |
jmitc91516 | 1:a5258871b33d | 1669 | Looks to see if the user has touched a defined easyGUI touch area, and responds accordingly. |
jmitc91516 | 1:a5258871b33d | 1670 | |
jmitc91516 | 1:a5258871b33d | 1671 | No return code. |
jmitc91516 | 1:a5258871b33d | 1672 | |
jmitc91516 | 1:a5258871b33d | 1673 | See EasyGUITouchAreaIndices.h for the touch area index values. |
jmitc91516 | 1:a5258871b33d | 1674 | */ |
jmitc91516 | 0:47c880c1463d | 1675 | void TouchCallback(touch_coordinate_t touchCoords, USBDeviceConnected* usbDevice, USBHostGC* usbHostGC, int tickCount, bool newTouch) |
jmitc91516 | 0:47c880c1463d | 1676 | { |
jmitc91516 | 1:a5258871b33d | 1677 | EasyGUIDebugPrintWithCounter("TouchCallback 0 ", 500, 440); |
jmitc91516 | 1:a5258871b33d | 1678 | |
jmitc91516 | 0:47c880c1463d | 1679 | GuiConst_INT32S touchAreaIndex = GuiLib_TouchCheck((GuiConst_INT16S)touchCoords.x, (GuiConst_INT16S)touchCoords.y); |
jmitc91516 | 0:47c880c1463d | 1680 | |
jmitc91516 | 1:a5258871b33d | 1681 | EasyGUIDebugPrintWithCounter("TouchCallback 1 ", 500, 440); |
jmitc91516 | 1:a5258871b33d | 1682 | |
jmitc91516 | 0:47c880c1463d | 1683 | if(touchAreaIndex >= 0) { |
jmitc91516 | 1:a5258871b33d | 1684 | |
jmitc91516 | 1:a5258871b33d | 1685 | //#define ALLOW_DEBUG_PRINTS_HERE |
jmitc91516 | 1:a5258871b33d | 1686 | #ifdef ALLOW_DEBUG_PRINTS_HERE |
jmitc91516 | 1:a5258871b33d | 1687 | char buff[300]; |
jmitc91516 | 1:a5258871b33d | 1688 | sprintf(buff, "tAI: %d", touchAreaIndex); |
jmitc91516 | 1:a5258871b33d | 1689 | SpecialDebugPrint(buff, 150, 410); |
jmitc91516 | 1:a5258871b33d | 1690 | #undef ALLOW_DEBUG_PRINTS_HERE |
jmitc91516 | 1:a5258871b33d | 1691 | #endif // ALLOW_DEBUG_PRINTS_HERE |
jmitc91516 | 1:a5258871b33d | 1692 | |
jmitc91516 | 0:47c880c1463d | 1693 | bool dealtWithTouch = false; |
jmitc91516 | 0:47c880c1463d | 1694 | |
jmitc91516 | 0:47c880c1463d | 1695 | // page selector? |
jmitc91516 | 0:47c880c1463d | 1696 | TouchPanelPageSelector* touchPanelPageSelector = touchPanelPageSelectors.GetTouchPanelPageSelector(touchAreaIndex); |
jmitc91516 | 0:47c880c1463d | 1697 | |
jmitc91516 | 0:47c880c1463d | 1698 | if( touchPanelPageSelector != NULL) { |
jmitc91516 | 1:a5258871b33d | 1699 | |
jmitc91516 | 1:a5258871b33d | 1700 | // User has touched a page selector |
jmitc91516 | 1:a5258871b33d | 1701 | // ******************************** |
jmitc91516 | 1:a5258871b33d | 1702 | |
jmitc91516 | 0:47c880c1463d | 1703 | // Do not keep switching pages if the user keeps 'touching' - |
jmitc91516 | 0:47c880c1463d | 1704 | // switch only if he 'lets go', then presses again |
jmitc91516 | 0:47c880c1463d | 1705 | if(newTouch) { |
jmitc91516 | 1:a5258871b33d | 1706 | |
jmitc91516 | 1:a5258871b33d | 1707 | // Depending on the touch area, we may need to do extra stuff here |
jmitc91516 | 1:a5258871b33d | 1708 | // before displaying the appropriate page |
jmitc91516 | 0:47c880c1463d | 1709 | |
jmitc91516 | 1:a5258871b33d | 1710 | if(touchAreaIndex == GAS_SAVER_RETURN_TO_READY) { |
jmitc91516 | 0:47c880c1463d | 1711 | // Take GC out of standby mode |
jmitc91516 | 0:47c880c1463d | 1712 | ExitGCStandbyMode(usbDevice, usbHostGC); |
jmitc91516 | 0:47c880c1463d | 1713 | } |
jmitc91516 | 0:47c880c1463d | 1714 | |
jmitc91516 | 1:a5258871b33d | 1715 | if(touchAreaIndex == CLEAR_ERRORS_BUTTON) { |
jmitc91516 | 0:47c880c1463d | 1716 | // Take GC out of error state |
jmitc91516 | 0:47c880c1463d | 1717 | ClearGCErrors(usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 1718 | |
jmitc91516 | 1:a5258871b33d | 1719 | // Make sure the component status rectangles change colour immediately, |
jmitc91516 | 1:a5258871b33d | 1720 | // not after ~10 seconds |
jmitc91516 | 1:a5258871b33d | 1721 | if(getGCStatusLoop != NULL) { |
jmitc91516 | 1:a5258871b33d | 1722 | getGCStatusLoop->UpdateHomePageGCComponentStatusColorAreas(); |
jmitc91516 | 1:a5258871b33d | 1723 | |
jmitc91516 | 1:a5258871b33d | 1724 | getGCStatusLoop->UpdateSingleGCComponentPageStatusColorArea(COLUMN); |
jmitc91516 | 1:a5258871b33d | 1725 | getGCStatusLoop->UpdateSingleGCComponentPageStatusColorArea(INJECTOR); |
jmitc91516 | 1:a5258871b33d | 1726 | getGCStatusLoop->UpdateSingleGCComponentPageStatusColorArea(DETECTOR); |
jmitc91516 | 1:a5258871b33d | 1727 | getGCStatusLoop->UpdateSingleGCComponentPageStatusColorArea(GAS); |
jmitc91516 | 1:a5258871b33d | 1728 | } |
jmitc91516 | 0:47c880c1463d | 1729 | } |
jmitc91516 | 0:47c880c1463d | 1730 | |
jmitc91516 | 1:a5258871b33d | 1731 | if(touchAreaIndex == ABORT_RUN_YES) { |
jmitc91516 | 1:a5258871b33d | 1732 | |
jmitc91516 | 1:a5258871b33d | 1733 | // Abort Run request confirmed |
jmitc91516 | 1:a5258871b33d | 1734 | |
jmitc91516 | 1:a5258871b33d | 1735 | //#define DEBUG_PRINT_ON_FAILURE |
jmitc91516 | 1:a5258871b33d | 1736 | #ifdef DEBUG_PRINT_ON_FAILURE |
jmitc91516 | 1:a5258871b33d | 1737 | if(!StopGCRun(usbDevice, usbHostGC)) { |
jmitc91516 | 1:a5258871b33d | 1738 | SpecialDebugPrint("*** StopGCRun failed ***", 150, 430); |
jmitc91516 | 1:a5258871b33d | 1739 | } |
jmitc91516 | 1:a5258871b33d | 1740 | #undef DEBUG_PRINT_ON_FAILURE |
jmitc91516 | 1:a5258871b33d | 1741 | #else |
jmitc91516 | 1:a5258871b33d | 1742 | StopGCRun(usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 1743 | #endif // DEBUG_PRINT_ON_FAILURE |
jmitc91516 | 1:a5258871b33d | 1744 | |
jmitc91516 | 1:a5258871b33d | 1745 | getGCStatusLoop->ClearGCIsRunning(); |
jmitc91516 | 1:a5258871b33d | 1746 | |
jmitc91516 | 1:a5258871b33d | 1747 | #ifdef SERVICE_INTERVALS_ACTIVE |
jmitc91516 | 1:a5258871b33d | 1748 | ServiceInterval::TellAllServiceIntervalsInstrumentHasCycled(); |
jmitc91516 | 1:a5258871b33d | 1749 | #endif // SERVICE_INTERVALS_ACTIVE |
jmitc91516 | 1:a5258871b33d | 1750 | |
jmitc91516 | 1:a5258871b33d | 1751 | #ifdef TURN_HEAT_OFF_ON_ABORT |
jmitc91516 | 1:a5258871b33d | 1752 | // Turn heat off |
jmitc91516 | 1:a5258871b33d | 1753 | if(heatOnOffAvailable) { |
jmitc91516 | 1:a5258871b33d | 1754 | if(theGCHeatControl != NULL) { |
jmitc91516 | 1:a5258871b33d | 1755 | if(theGCHeatControl->IsHeatOn()) { |
jmitc91516 | 1:a5258871b33d | 1756 | theGCHeatControl->TurnHeatOff(); |
jmitc91516 | 1:a5258871b33d | 1757 | #ifdef USE_HEAT_ONOFF_BUTTON_BITMAPS |
jmitc91516 | 1:a5258871b33d | 1758 | DrawHeatOnOffButton(); |
jmitc91516 | 1:a5258871b33d | 1759 | #else |
jmitc91516 | 1:a5258871b33d | 1760 | UpdateHeatOnOffEasyGuiVariable(); |
jmitc91516 | 1:a5258871b33d | 1761 | #endif // USE_HEAT_ONOFF_BUTTON_BITMAPS |
jmitc91516 | 1:a5258871b33d | 1762 | } |
jmitc91516 | 1:a5258871b33d | 1763 | |
jmitc91516 | 1:a5258871b33d | 1764 | StartHeatOnOffTimeout(); |
jmitc91516 | 1:a5258871b33d | 1765 | } |
jmitc91516 | 1:a5258871b33d | 1766 | } |
jmitc91516 | 1:a5258871b33d | 1767 | #endif // TURN_HEAT_OFF_ON_ABORT |
jmitc91516 | 1:a5258871b33d | 1768 | } |
jmitc91516 | 1:a5258871b33d | 1769 | |
jmitc91516 | 1:a5258871b33d | 1770 | if(touchAreaIndex == SETTINGS_TO_NETWORK_PARAMS_BUTTON) { |
jmitc91516 | 1:a5258871b33d | 1771 | // We are about to display the Network Parameters page - so tell the class |
jmitc91516 | 1:a5258871b33d | 1772 | // to display the real IP address, etc - i.e. the values we are actually using |
jmitc91516 | 1:a5258871b33d | 1773 | NetworkParameters *networkParameters = NetworkParameters::GetInstance(usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 1774 | if(networkParameters != NULL) { |
jmitc91516 | 1:a5258871b33d | 1775 | networkParameters->RestoreRealValues(); |
jmitc91516 | 1:a5258871b33d | 1776 | } |
jmitc91516 | 1:a5258871b33d | 1777 | } |
jmitc91516 | 1:a5258871b33d | 1778 | |
jmitc91516 | 1:a5258871b33d | 1779 | if(touchAreaIndex == SETTINGS_TO_SERVICING_PAGE_BUTTON) { |
jmitc91516 | 1:a5258871b33d | 1780 | strcpy(GuiVar_engineersLockCodeMessage, "No lock code entered"); |
jmitc91516 | 1:a5258871b33d | 1781 | } |
jmitc91516 | 1:a5258871b33d | 1782 | |
jmitc91516 | 1:a5258871b33d | 1783 | if(touchAreaIndex == SERVICING_PAGE_GC_CMDS_BUTTON ) { |
jmitc91516 | 1:a5258871b33d | 1784 | // Clear the easyGUI variables that display the command and the response |
jmitc91516 | 1:a5258871b33d | 1785 | GuiVar_debugCommandTx[0] = '\0'; |
jmitc91516 | 1:a5258871b33d | 1786 | GuiVar_debugCommandRx[0] = '\0'; |
jmitc91516 | 1:a5258871b33d | 1787 | } |
jmitc91516 | 1:a5258871b33d | 1788 | |
jmitc91516 | 1:a5258871b33d | 1789 | if(touchPanelPageSelector->CanChangePage()) { |
jmitc91516 | 1:a5258871b33d | 1790 | DisplayEasyGuiStructure(touchPanelPageSelector->GetPageNumber(usbDevice, usbHostGC), usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 1791 | } |
jmitc91516 | 0:47c880c1463d | 1792 | } |
jmitc91516 | 1:a5258871b33d | 1793 | |
jmitc91516 | 0:47c880c1463d | 1794 | dealtWithTouch = true; // The user touched a page selector, so we have still 'dealt' with this, |
jmitc91516 | 0:47c880c1463d | 1795 | // whether we had a 'new touch' or not |
jmitc91516 | 1:a5258871b33d | 1796 | } // TouchPanelPageSelector |
jmitc91516 | 0:47c880c1463d | 1797 | |
jmitc91516 | 0:47c880c1463d | 1798 | if(!dealtWithTouch) { |
jmitc91516 | 1:a5258871b33d | 1799 | |
jmitc91516 | 1:a5258871b33d | 1800 | if(touchAreaIndex == RUN_BUTTON) { |
jmitc91516 | 0:47c880c1463d | 1801 | if(newTouch) { // As above - do not do this repeatedly - GC does not like it... |
jmitc91516 | 1:a5258871b33d | 1802 | |
jmitc91516 | 1:a5258871b33d | 1803 | EasyGUIDebugPrintWithCounter("TouchCallback 4.1 ", 500, 440); |
jmitc91516 | 1:a5258871b33d | 1804 | |
jmitc91516 | 0:47c880c1463d | 1805 | if(GCIsReadyToRun(usbDevice, usbHostGC)) { |
jmitc91516 | 1:a5258871b33d | 1806 | // Start run - if this works, display the 'Run' page, etc, else do nothing |
jmitc91516 | 0:47c880c1463d | 1807 | if(StartGCRun(usbDevice, usbHostGC)) { |
jmitc91516 | 1:a5258871b33d | 1808 | SetupForStartOfRun(usbDevice, usbHostGC); |
jmitc91516 | 0:47c880c1463d | 1809 | } else { |
jmitc91516 | 0:47c880c1463d | 1810 | DrawErrorMessage("*** Run failed to start ***"); |
jmitc91516 | 0:47c880c1463d | 1811 | |
jmitc91516 | 0:47c880c1463d | 1812 | // Give user time to read error, then erase it |
jmitc91516 | 0:47c880c1463d | 1813 | Thread::wait(2000); |
jmitc91516 | 0:47c880c1463d | 1814 | |
jmitc91516 | 0:47c880c1463d | 1815 | DisplayEasyGuiStructure(GuiStruct_HomePage_1, usbDevice, usbHostGC); |
jmitc91516 | 0:47c880c1463d | 1816 | } |
jmitc91516 | 1:a5258871b33d | 1817 | } else { |
jmitc91516 | 1:a5258871b33d | 1818 | // GC is not ready to run - tell the user why |
jmitc91516 | 1:a5258871b33d | 1819 | getGCStatusLoop->SetupGCNotReadyStateEasyGUIVariable(); |
jmitc91516 | 1:a5258871b33d | 1820 | |
jmitc91516 | 1:a5258871b33d | 1821 | DisplayEasyGuiStructure(GuiStruct_GCNotReadyToRunPage_Def, usbDevice, usbHostGC); |
jmitc91516 | 0:47c880c1463d | 1822 | } |
jmitc91516 | 0:47c880c1463d | 1823 | } |
jmitc91516 | 0:47c880c1463d | 1824 | |
jmitc91516 | 0:47c880c1463d | 1825 | dealtWithTouch = true; |
jmitc91516 | 0:47c880c1463d | 1826 | } |
jmitc91516 | 1:a5258871b33d | 1827 | } // Run button |
jmitc91516 | 0:47c880c1463d | 1828 | |
jmitc91516 | 0:47c880c1463d | 1829 | if(!dealtWithTouch) { |
jmitc91516 | 1:a5258871b33d | 1830 | |
jmitc91516 | 1:a5258871b33d | 1831 | if(touchAreaIndex == HEAT_ON_BUTTON) { // Heat on/off button |
jmitc91516 | 0:47c880c1463d | 1832 | if(newTouch) { // As above - do not do this repeatedly - GC does not like it... |
jmitc91516 | 0:47c880c1463d | 1833 | if(heatOnOffAvailable) { |
jmitc91516 | 0:47c880c1463d | 1834 | if(theGCHeatControl != NULL) { |
jmitc91516 | 0:47c880c1463d | 1835 | if(theGCHeatControl->IsHeatOn()) { |
jmitc91516 | 0:47c880c1463d | 1836 | theGCHeatControl->TurnHeatOff(); |
jmitc91516 | 0:47c880c1463d | 1837 | } else { |
jmitc91516 | 0:47c880c1463d | 1838 | theGCHeatControl->TurnHeatOn(); |
jmitc91516 | 0:47c880c1463d | 1839 | } |
jmitc91516 | 1:a5258871b33d | 1840 | #ifdef USE_HEAT_ONOFF_BUTTON_BITMAPS |
jmitc91516 | 1:a5258871b33d | 1841 | // If we do not do this first, we do not see the bitmap change on the button |
jmitc91516 | 1:a5258871b33d | 1842 | // (I don't understand why...) |
jmitc91516 | 1:a5258871b33d | 1843 | DisplayEasyGuiStructure(GuiStruct_HomePage_1, usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 1844 | DrawHeatOnOffButton(); |
jmitc91516 | 1:a5258871b33d | 1845 | #else |
jmitc91516 | 0:47c880c1463d | 1846 | UpdateHeatOnOffEasyGuiVariable(); |
jmitc91516 | 0:47c880c1463d | 1847 | // Make GuiVar_heatOnOffCommand update visible on screen |
jmitc91516 | 0:47c880c1463d | 1848 | DisplayEasyGuiStructure(GuiStruct_HomePage_1, usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 1849 | #endif // USE_HEAT_ONOFF_BUTTON_BITMAPS |
jmitc91516 | 0:47c880c1463d | 1850 | |
jmitc91516 | 0:47c880c1463d | 1851 | StartHeatOnOffTimeout(); |
jmitc91516 | 1:a5258871b33d | 1852 | |
jmitc91516 | 1:a5258871b33d | 1853 | // Update the door lock/unlock command colour |
jmitc91516 | 1:a5258871b33d | 1854 | // *before* we display the column page(s) |
jmitc91516 | 1:a5258871b33d | 1855 | SetupDoorActuatorCommandColour(usbDevice, usbHostGC, false); |
jmitc91516 | 0:47c880c1463d | 1856 | } |
jmitc91516 | 0:47c880c1463d | 1857 | } |
jmitc91516 | 0:47c880c1463d | 1858 | } |
jmitc91516 | 0:47c880c1463d | 1859 | |
jmitc91516 | 0:47c880c1463d | 1860 | // Whether we changed the heat or not, the user still 'touched' our area, |
jmitc91516 | 0:47c880c1463d | 1861 | // so no-one else should try and deal with this touch |
jmitc91516 | 0:47c880c1463d | 1862 | dealtWithTouch = true; |
jmitc91516 | 0:47c880c1463d | 1863 | } |
jmitc91516 | 1:a5258871b33d | 1864 | } // Heat ON/Off button |
jmitc91516 | 1:a5258871b33d | 1865 | |
jmitc91516 | 1:a5258871b33d | 1866 | if(!dealtWithTouch) { |
jmitc91516 | 1:a5258871b33d | 1867 | |
jmitc91516 | 1:a5258871b33d | 1868 | if((touchAreaIndex == COLUMN_PAGE1_EDIT_COLUMN_MAX_TEMP) || |
jmitc91516 | 1:a5258871b33d | 1869 | (touchAreaIndex == COLUMN_DH_PAGE1_EDIT_COLUMN_MAX_TEMP)) { |
jmitc91516 | 1:a5258871b33d | 1870 | |
jmitc91516 | 1:a5258871b33d | 1871 | NumericKeypadPageHandler* numericKeypadPageHandler = NumericKeypadPageHandler::GetInstance(usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 1872 | if(numericKeypadPageHandler != NULL) { |
jmitc91516 | 1:a5258871b33d | 1873 | |
jmitc91516 | 1:a5258871b33d | 1874 | // Remove units ("deg C")from the initial value to be displayed in the keypad |
jmitc91516 | 1:a5258871b33d | 1875 | char temp[50]; |
jmitc91516 | 1:a5258871b33d | 1876 | RemoveUnitsFromEasyGUIStringIfFound(temp, GuiVar_columnMaxTemp2, " deg C"); // Remove space before units as well as the units themselves |
jmitc91516 | 1:a5258871b33d | 1877 | |
jmitc91516 | 1:a5258871b33d | 1878 | numericKeypadPageHandler->StartEditing(temp); |
jmitc91516 | 1:a5258871b33d | 1879 | numericKeypadPageHandler->SetEasyGUIVariableToEdit(GuiVar_columnMaxTemp2); |
jmitc91516 | 1:a5258871b33d | 1880 | numericKeypadPageHandler->SetEasyGUICallingPage((touchAreaIndex == COLUMN_DH_PAGE1_EDIT_COLUMN_MAX_TEMP) ? GuiStruct_ColumnDHPage1_40 : GuiStruct_ColumnPage1_2); |
jmitc91516 | 1:a5258871b33d | 1881 | numericKeypadPageHandler->SetEditVariableRange(0, 500); |
jmitc91516 | 1:a5258871b33d | 1882 | numericKeypadPageHandler->SetEditVariableName("Col. Max Temp"); |
jmitc91516 | 1:a5258871b33d | 1883 | numericKeypadPageHandler->SetEditVariableUnits("deg C"); |
jmitc91516 | 1:a5258871b33d | 1884 | numericKeypadPageHandler->SetApplyFunctionPtr(&SetColumnMaxTempFromEasyGuiVariable); |
jmitc91516 | 1:a5258871b33d | 1885 | numericKeypadPageHandler->DisplayEasyGUIPage(); |
jmitc91516 | 1:a5258871b33d | 1886 | } |
jmitc91516 | 1:a5258871b33d | 1887 | |
jmitc91516 | 1:a5258871b33d | 1888 | dealtWithTouch = true; |
jmitc91516 | 1:a5258871b33d | 1889 | } |
jmitc91516 | 0:47c880c1463d | 1890 | } |
jmitc91516 | 1:a5258871b33d | 1891 | |
jmitc91516 | 1:a5258871b33d | 1892 | if(!dealtWithTouch) { |
jmitc91516 | 1:a5258871b33d | 1893 | |
jmitc91516 | 1:a5258871b33d | 1894 | if(touchAreaIndex == ENTER_ENGINEERS_LOCK_CODE) { |
jmitc91516 | 1:a5258871b33d | 1895 | |
jmitc91516 | 1:a5258871b33d | 1896 | NumericKeypadPageHandler* numericKeypadPageHandler = NumericKeypadPageHandler::GetInstance(usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 1897 | if(numericKeypadPageHandler != NULL) { |
jmitc91516 | 1:a5258871b33d | 1898 | numericKeypadPageHandler->StartEditingInLockMode(842, GuiStruct_ServicingHomePage_Def, GuiVar_engineersLockCodeMessage, "Invalid lock code"); |
jmitc91516 | 1:a5258871b33d | 1899 | numericKeypadPageHandler->SetEasyGUICallingPage(GuiStruct_EngineersLockPage_Def); |
jmitc91516 | 1:a5258871b33d | 1900 | numericKeypadPageHandler->SetEditVariableRange(0, 32767); |
jmitc91516 | 1:a5258871b33d | 1901 | numericKeypadPageHandler->SetEditVariableName("Lock Code"); |
jmitc91516 | 1:a5258871b33d | 1902 | numericKeypadPageHandler->DisplayEasyGUIPage(); |
jmitc91516 | 1:a5258871b33d | 1903 | } |
jmitc91516 | 1:a5258871b33d | 1904 | |
jmitc91516 | 1:a5258871b33d | 1905 | dealtWithTouch = true; |
jmitc91516 | 1:a5258871b33d | 1906 | } |
jmitc91516 | 1:a5258871b33d | 1907 | } |
jmitc91516 | 1:a5258871b33d | 1908 | |
jmitc91516 | 1:a5258871b33d | 1909 | if(!dealtWithTouch) { |
jmitc91516 | 1:a5258871b33d | 1910 | |
jmitc91516 | 1:a5258871b33d | 1911 | if((touchAreaIndex == DOOR_ACTUATOR_AREA_1) || (touchAreaIndex == DOOR_ACTUATOR_AREA_2)) { |
jmitc91516 | 1:a5258871b33d | 1912 | DealWithDoorActuatorButtons(touchAreaIndex, usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 1913 | |
jmitc91516 | 1:a5258871b33d | 1914 | dealtWithTouch = true; |
jmitc91516 | 1:a5258871b33d | 1915 | } |
jmitc91516 | 1:a5258871b33d | 1916 | } // Open door |
jmitc91516 | 1:a5258871b33d | 1917 | |
jmitc91516 | 1:a5258871b33d | 1918 | if(!dealtWithTouch) { |
jmitc91516 | 1:a5258871b33d | 1919 | NetworkParameters *networkParameters = NetworkParameters::GetInstance(usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 1920 | |
jmitc91516 | 1:a5258871b33d | 1921 | if(networkParameters != NULL) { |
jmitc91516 | 1:a5258871b33d | 1922 | |
jmitc91516 | 1:a5258871b33d | 1923 | if(networkParameters->TouchAreaIsNetworkParameter(touchAreaIndex)) { |
jmitc91516 | 1:a5258871b33d | 1924 | |
jmitc91516 | 1:a5258871b33d | 1925 | networkParameters->DealWithTouch(touchAreaIndex); |
jmitc91516 | 1:a5258871b33d | 1926 | |
jmitc91516 | 1:a5258871b33d | 1927 | dealtWithTouch = true; |
jmitc91516 | 1:a5258871b33d | 1928 | } |
jmitc91516 | 1:a5258871b33d | 1929 | } |
jmitc91516 | 1:a5258871b33d | 1930 | } // Network parameter |
jmitc91516 | 1:a5258871b33d | 1931 | |
jmitc91516 | 1:a5258871b33d | 1932 | #define USE_GAS_CALIBRATION_PAGE_HANDLER |
jmitc91516 | 1:a5258871b33d | 1933 | #ifdef USE_GAS_CALIBRATION_PAGE_HANDLER |
jmitc91516 | 1:a5258871b33d | 1934 | if(!dealtWithTouch) { |
jmitc91516 | 1:a5258871b33d | 1935 | GasCalibrationPageHandler *gasCalibrationPageHandler = GasCalibrationPageHandler::GetInstance(usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 1936 | |
jmitc91516 | 1:a5258871b33d | 1937 | if(gasCalibrationPageHandler != NULL) { |
jmitc91516 | 1:a5258871b33d | 1938 | |
jmitc91516 | 1:a5258871b33d | 1939 | if(gasCalibrationPageHandler->TouchAreaIsOnCalibrationPage(touchAreaIndex)) { |
jmitc91516 | 1:a5258871b33d | 1940 | |
jmitc91516 | 1:a5258871b33d | 1941 | dealtWithTouch = gasCalibrationPageHandler->DealWithTouch(touchAreaIndex); |
jmitc91516 | 1:a5258871b33d | 1942 | } |
jmitc91516 | 1:a5258871b33d | 1943 | } |
jmitc91516 | 1:a5258871b33d | 1944 | } // Touch area on Gas Calibration page |
jmitc91516 | 1:a5258871b33d | 1945 | #undef USE_GAS_CALIBRATION_PAGE_HANDLER |
jmitc91516 | 1:a5258871b33d | 1946 | #endif // USE_GAS_CALIBRATION_PAGE_HANDLER |
jmitc91516 | 1:a5258871b33d | 1947 | |
jmitc91516 | 1:a5258871b33d | 1948 | if(!dealtWithTouch) { |
jmitc91516 | 1:a5258871b33d | 1949 | ColumnDHAutoCalibrationPageHandler *columnDHAutoCalibrationPageHandler = ColumnDHAutoCalibrationPageHandler::GetInstance(usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 1950 | |
jmitc91516 | 1:a5258871b33d | 1951 | if(columnDHAutoCalibrationPageHandler != NULL) { |
jmitc91516 | 1:a5258871b33d | 1952 | |
jmitc91516 | 1:a5258871b33d | 1953 | if(columnDHAutoCalibrationPageHandler->TouchAreaIsOnCalibrationPage(touchAreaIndex)) { |
jmitc91516 | 1:a5258871b33d | 1954 | |
jmitc91516 | 1:a5258871b33d | 1955 | dealtWithTouch = columnDHAutoCalibrationPageHandler->DealWithTouch(touchAreaIndex); |
jmitc91516 | 1:a5258871b33d | 1956 | } |
jmitc91516 | 1:a5258871b33d | 1957 | } |
jmitc91516 | 1:a5258871b33d | 1958 | } // Touch area on DH Column Auto Calibration page |
jmitc91516 | 1:a5258871b33d | 1959 | |
jmitc91516 | 1:a5258871b33d | 1960 | if(!dealtWithTouch) { |
jmitc91516 | 1:a5258871b33d | 1961 | ColumnDHManualCalibrationPageHandler *columnDHManualCalibrationPageHandler = ColumnDHManualCalibrationPageHandler::GetInstance(usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 1962 | |
jmitc91516 | 1:a5258871b33d | 1963 | if(columnDHManualCalibrationPageHandler != NULL) { |
jmitc91516 | 1:a5258871b33d | 1964 | |
jmitc91516 | 1:a5258871b33d | 1965 | if(columnDHManualCalibrationPageHandler->TouchAreaIsOnCalibrationPage(touchAreaIndex)) { |
jmitc91516 | 1:a5258871b33d | 1966 | |
jmitc91516 | 1:a5258871b33d | 1967 | dealtWithTouch = columnDHManualCalibrationPageHandler->DealWithTouch(touchAreaIndex); |
jmitc91516 | 1:a5258871b33d | 1968 | } |
jmitc91516 | 1:a5258871b33d | 1969 | } |
jmitc91516 | 1:a5258871b33d | 1970 | } // Touch area on DH Column Manual Calibration page |
jmitc91516 | 1:a5258871b33d | 1971 | |
jmitc91516 | 1:a5258871b33d | 1972 | if(!dealtWithTouch) { |
jmitc91516 | 1:a5258871b33d | 1973 | ColumnDHSensorCalibrationPageHandler *columnDHSensorCalibrationPageHandler = ColumnDHSensorCalibrationPageHandler::GetInstance(usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 1974 | |
jmitc91516 | 1:a5258871b33d | 1975 | if(columnDHSensorCalibrationPageHandler != NULL) { |
jmitc91516 | 1:a5258871b33d | 1976 | |
jmitc91516 | 1:a5258871b33d | 1977 | if(columnDHSensorCalibrationPageHandler->TouchAreaIsOnCalibrationPage(touchAreaIndex)) { |
jmitc91516 | 1:a5258871b33d | 1978 | |
jmitc91516 | 1:a5258871b33d | 1979 | dealtWithTouch = columnDHSensorCalibrationPageHandler->DealWithTouch(touchAreaIndex); |
jmitc91516 | 1:a5258871b33d | 1980 | } |
jmitc91516 | 1:a5258871b33d | 1981 | } |
jmitc91516 | 1:a5258871b33d | 1982 | } // Touch area on DH Column Sensor Calibration page |
jmitc91516 | 1:a5258871b33d | 1983 | |
jmitc91516 | 1:a5258871b33d | 1984 | if(!dealtWithTouch) { |
jmitc91516 | 1:a5258871b33d | 1985 | ColumnDHPSUDACPageHandler *columnDHPSUDACPageHandler = ColumnDHPSUDACPageHandler::GetInstance(usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 1986 | |
jmitc91516 | 1:a5258871b33d | 1987 | if(columnDHPSUDACPageHandler != NULL) { |
jmitc91516 | 1:a5258871b33d | 1988 | |
jmitc91516 | 1:a5258871b33d | 1989 | if(columnDHPSUDACPageHandler->TouchAreaIsOnPSUDACPage(touchAreaIndex)) { |
jmitc91516 | 1:a5258871b33d | 1990 | |
jmitc91516 | 1:a5258871b33d | 1991 | dealtWithTouch = columnDHPSUDACPageHandler->DealWithTouch(touchAreaIndex); |
jmitc91516 | 1:a5258871b33d | 1992 | } |
jmitc91516 | 1:a5258871b33d | 1993 | } |
jmitc91516 | 1:a5258871b33d | 1994 | } // Touch area on DH PSU DAC page |
jmitc91516 | 1:a5258871b33d | 1995 | |
jmitc91516 | 1:a5258871b33d | 1996 | if(!dealtWithTouch) { |
jmitc91516 | 1:a5258871b33d | 1997 | NudgeAndDampPageHandler *nudgeAndDampPageHandler = NudgeAndDampPageHandler::GetInstance(usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 1998 | |
jmitc91516 | 1:a5258871b33d | 1999 | if(nudgeAndDampPageHandler != NULL) { |
jmitc91516 | 1:a5258871b33d | 2000 | |
jmitc91516 | 1:a5258871b33d | 2001 | if(nudgeAndDampPageHandler->TouchAreaIsOnNudgeAndDampPage(touchAreaIndex)) { |
jmitc91516 | 1:a5258871b33d | 2002 | |
jmitc91516 | 1:a5258871b33d | 2003 | dealtWithTouch = nudgeAndDampPageHandler->DealWithTouch(touchAreaIndex); |
jmitc91516 | 1:a5258871b33d | 2004 | } |
jmitc91516 | 1:a5258871b33d | 2005 | } |
jmitc91516 | 1:a5258871b33d | 2006 | } // Touch area on one of the Nudge and Damp pages |
jmitc91516 | 1:a5258871b33d | 2007 | |
jmitc91516 | 1:a5258871b33d | 2008 | if(!dealtWithTouch) { |
jmitc91516 | 1:a5258871b33d | 2009 | DebugCommandsPageHandler *debugCommandsPageHandler = DebugCommandsPageHandler::GetInstance(usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 2010 | |
jmitc91516 | 1:a5258871b33d | 2011 | if(debugCommandsPageHandler != NULL) { |
jmitc91516 | 1:a5258871b33d | 2012 | |
jmitc91516 | 1:a5258871b33d | 2013 | if(debugCommandsPageHandler->TouchAreaIsOnDebugCommandsPage(touchAreaIndex)) { |
jmitc91516 | 1:a5258871b33d | 2014 | |
jmitc91516 | 1:a5258871b33d | 2015 | dealtWithTouch = debugCommandsPageHandler->DealWithTouch(touchAreaIndex); |
jmitc91516 | 1:a5258871b33d | 2016 | } |
jmitc91516 | 1:a5258871b33d | 2017 | } |
jmitc91516 | 1:a5258871b33d | 2018 | } // Touch area on the GC (Debug) Commands page |
jmitc91516 | 1:a5258871b33d | 2019 | |
jmitc91516 | 1:a5258871b33d | 2020 | if(!dealtWithTouch) { // Try Column Oven Fan page - no 'PageHandler' class for this - |
jmitc91516 | 1:a5258871b33d | 2021 | // trivial - only two touch areas/buttons, each of which simply sends |
jmitc91516 | 1:a5258871b33d | 2022 | // a command (without arguments) to the GC - no values displayed |
jmitc91516 | 1:a5258871b33d | 2023 | if(touchAreaIndex == COLUMN_OVEN_FAN_NORMAL) { |
jmitc91516 | 1:a5258871b33d | 2024 | ExecuteGCCommand("CFNO",usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 2025 | dealtWithTouch = true; |
jmitc91516 | 1:a5258871b33d | 2026 | } else if(touchAreaIndex == COLUMN_OVEN_FAN_COOLING) { |
jmitc91516 | 1:a5258871b33d | 2027 | ExecuteGCCommand("CFCO",usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 2028 | dealtWithTouch = true; |
jmitc91516 | 1:a5258871b33d | 2029 | } |
jmitc91516 | 1:a5258871b33d | 2030 | } |
jmitc91516 | 1:a5258871b33d | 2031 | |
jmitc91516 | 1:a5258871b33d | 2032 | if(!dealtWithTouch) { |
jmitc91516 | 1:a5258871b33d | 2033 | GasBackPressureDACPageHandler *gasBackPressureDACPageHandler = GasBackPressureDACPageHandler::GetInstance(usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 2034 | |
jmitc91516 | 1:a5258871b33d | 2035 | if(gasBackPressureDACPageHandler != NULL) { |
jmitc91516 | 1:a5258871b33d | 2036 | |
jmitc91516 | 1:a5258871b33d | 2037 | if(gasBackPressureDACPageHandler->TouchAreaIsOnGasBackPressureDACPage(touchAreaIndex)) { |
jmitc91516 | 1:a5258871b33d | 2038 | |
jmitc91516 | 1:a5258871b33d | 2039 | dealtWithTouch = gasBackPressureDACPageHandler->DealWithTouch(touchAreaIndex); |
jmitc91516 | 1:a5258871b33d | 2040 | } |
jmitc91516 | 1:a5258871b33d | 2041 | } |
jmitc91516 | 1:a5258871b33d | 2042 | } // Touch area on Gas Backpressure DAC page |
jmitc91516 | 1:a5258871b33d | 2043 | |
jmitc91516 | 1:a5258871b33d | 2044 | if(!dealtWithTouch) { |
jmitc91516 | 1:a5258871b33d | 2045 | GasChannelDACAndADCPageHandler *gasChannelDACAndADCPageHandler = GasChannelDACAndADCPageHandler::GetInstance(usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 2046 | |
jmitc91516 | 1:a5258871b33d | 2047 | if(gasChannelDACAndADCPageHandler != NULL) { |
jmitc91516 | 1:a5258871b33d | 2048 | |
jmitc91516 | 1:a5258871b33d | 2049 | if(gasChannelDACAndADCPageHandler->TouchAreaIsOnGasChannelDACAndADCPage(touchAreaIndex)) { |
jmitc91516 | 1:a5258871b33d | 2050 | |
jmitc91516 | 1:a5258871b33d | 2051 | dealtWithTouch = gasChannelDACAndADCPageHandler->DealWithTouch(touchAreaIndex); |
jmitc91516 | 1:a5258871b33d | 2052 | } |
jmitc91516 | 1:a5258871b33d | 2053 | } |
jmitc91516 | 1:a5258871b33d | 2054 | } // Touch area on Gas channel DAC and ADC page |
jmitc91516 | 1:a5258871b33d | 2055 | |
jmitc91516 | 1:a5258871b33d | 2056 | if(!dealtWithTouch) { |
jmitc91516 | 1:a5258871b33d | 2057 | NumericKeypadPageHandler *numericKeypadPageHandler = NumericKeypadPageHandler::GetInstance(usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 2058 | |
jmitc91516 | 1:a5258871b33d | 2059 | if(numericKeypadPageHandler != NULL) { |
jmitc91516 | 1:a5258871b33d | 2060 | |
jmitc91516 | 1:a5258871b33d | 2061 | if(numericKeypadPageHandler->TouchAreaIsOnNumericKeypadPage(touchAreaIndex)) { |
jmitc91516 | 1:a5258871b33d | 2062 | |
jmitc91516 | 1:a5258871b33d | 2063 | dealtWithTouch = numericKeypadPageHandler->DealWithTouch(touchAreaIndex); |
jmitc91516 | 1:a5258871b33d | 2064 | } |
jmitc91516 | 1:a5258871b33d | 2065 | } |
jmitc91516 | 1:a5258871b33d | 2066 | } // Touch area on numeric keypad page |
jmitc91516 | 1:a5258871b33d | 2067 | |
jmitc91516 | 1:a5258871b33d | 2068 | if(!dealtWithTouch) { |
jmitc91516 | 1:a5258871b33d | 2069 | EthernetKeypadPageHandler *ethernetKeypadPageHandler = EthernetKeypadPageHandler::GetInstance(usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 2070 | |
jmitc91516 | 1:a5258871b33d | 2071 | if(ethernetKeypadPageHandler != NULL) { |
jmitc91516 | 1:a5258871b33d | 2072 | |
jmitc91516 | 1:a5258871b33d | 2073 | if(ethernetKeypadPageHandler->TouchAreaIsOnEthernetKeypadPage(touchAreaIndex)) { |
jmitc91516 | 1:a5258871b33d | 2074 | |
jmitc91516 | 1:a5258871b33d | 2075 | dealtWithTouch = ethernetKeypadPageHandler->DealWithTouch(touchAreaIndex); |
jmitc91516 | 1:a5258871b33d | 2076 | } |
jmitc91516 | 1:a5258871b33d | 2077 | } |
jmitc91516 | 1:a5258871b33d | 2078 | } // Touch area on numeric keypad page |
jmitc91516 | 1:a5258871b33d | 2079 | |
jmitc91516 | 1:a5258871b33d | 2080 | if(!dealtWithTouch) { |
jmitc91516 | 1:a5258871b33d | 2081 | |
jmitc91516 | 1:a5258871b33d | 2082 | DetectorIgnitionHandler *detectorIgnitionHandler = DetectorIgnitionHandler::GetInstance(usbDevice, usbHostGC); |
jmitc91516 | 1:a5258871b33d | 2083 | |
jmitc91516 | 1:a5258871b33d | 2084 | if(detectorIgnitionHandler != NULL) { |
jmitc91516 | 1:a5258871b33d | 2085 | |
jmitc91516 | 1:a5258871b33d | 2086 | if(detectorIgnitionHandler->TouchAreaIsDetectorIgniteButton(touchAreaIndex)) { |
jmitc91516 | 1:a5258871b33d | 2087 | |
jmitc91516 | 1:a5258871b33d | 2088 | dealtWithTouch = detectorIgnitionHandler->DealWithTouch(touchAreaIndex); |
jmitc91516 | 1:a5258871b33d | 2089 | } |
jmitc91516 | 1:a5258871b33d | 2090 | } |
jmitc91516 | 1:a5258871b33d | 2091 | } // Handling detector ignition |
jmitc91516 | 1:a5258871b33d | 2092 | |
jmitc91516 | 1:a5258871b33d | 2093 | if(!dealtWithTouch) { |
jmitc91516 | 1:a5258871b33d | 2094 | #ifdef SERVICE_INTERVALS_ACTIVE |
jmitc91516 | 1:a5258871b33d | 2095 | if(ServiceInterval::IsServicedTouchArea(touchAreaIndex)) { |
jmitc91516 | 1:a5258871b33d | 2096 | |
jmitc91516 | 1:a5258871b33d | 2097 | ServiceInterval::DealWithServicedTouchArea(touchAreaIndex); |
jmitc91516 | 1:a5258871b33d | 2098 | |
jmitc91516 | 1:a5258871b33d | 2099 | // This is a ServiceInterval touch area - |
jmitc91516 | 1:a5258871b33d | 2100 | // nothing else can deal with it, |
jmitc91516 | 1:a5258871b33d | 2101 | // whether we actually did anything or not |
jmitc91516 | 1:a5258871b33d | 2102 | dealtWithTouch = true; |
jmitc91516 | 1:a5258871b33d | 2103 | } |
jmitc91516 | 1:a5258871b33d | 2104 | #endif // SERVICE_INTERVALS_ACTIVE |
jmitc91516 | 1:a5258871b33d | 2105 | } // Service interval |
jmitc91516 | 0:47c880c1463d | 2106 | } |
jmitc91516 | 0:47c880c1463d | 2107 | } |
jmitc91516 | 0:47c880c1463d | 2108 | |
jmitc91516 | 1:a5258871b33d | 2109 | |
jmitc91516 | 1:a5258871b33d | 2110 | /* |
jmitc91516 | 1:a5258871b33d | 2111 | Waits (indefinitely) for a USB device to be connected - |
jmitc91516 | 1:a5258871b33d | 2112 | note that, if there is no USB device, we will hang at this point - |
jmitc91516 | 1:a5258871b33d | 2113 | there is no timeout. |
jmitc91516 | 0:47c880c1463d | 2114 | |
jmitc91516 | 1:a5258871b33d | 2115 | Args are: a pointer to the USBHost instance on which we are to look for the USB device |
jmitc91516 | 1:a5258871b33d | 2116 | |
jmitc91516 | 1:a5258871b33d | 2117 | Returns a pointer to the USB device |
jmitc91516 | 1:a5258871b33d | 2118 | */ |
jmitc91516 | 1:a5258871b33d | 2119 | USBDeviceConnected* GetUSBDevice(USBHost* usbHost) |
jmitc91516 | 1:a5258871b33d | 2120 | { |
jmitc91516 | 1:a5258871b33d | 2121 | USBDeviceConnected* usbDevice = NULL; |
jmitc91516 | 0:47c880c1463d | 2122 | |
jmitc91516 | 1:a5258871b33d | 2123 | while(usbDevice == NULL) { |
jmitc91516 | 1:a5258871b33d | 2124 | for (uint8_t i = 0; i < MAX_DEVICE_CONNECTED; ++i) { |
jmitc91516 | 1:a5258871b33d | 2125 | usbDevice = usbHost->getDevice(i); |
jmitc91516 | 1:a5258871b33d | 2126 | |
jmitc91516 | 1:a5258871b33d | 2127 | if (usbDevice) { |
jmitc91516 | 1:a5258871b33d | 2128 | return usbDevice; |
jmitc91516 | 1:a5258871b33d | 2129 | } |
jmitc91516 | 1:a5258871b33d | 2130 | } |
jmitc91516 | 0:47c880c1463d | 2131 | } |
jmitc91516 | 1:a5258871b33d | 2132 | |
jmitc91516 | 1:a5258871b33d | 2133 | return NULL; |
jmitc91516 | 0:47c880c1463d | 2134 | } |
jmitc91516 | 0:47c880c1463d | 2135 | |
jmitc91516 | 1:a5258871b33d | 2136 | /* |
jmitc91516 | 1:a5258871b33d | 2137 | Function that executes the easyGUI code in VarInit.c, to initialise all the easyGUI variables |
jmitc91516 | 1:a5258871b33d | 2138 | to the values we have specified in the easyGUI application. |
jmitc91516 | 1:a5258871b33d | 2139 | */ |
jmitc91516 | 1:a5258871b33d | 2140 | static void InitialiseAllEasyGUIVariables(void) |
jmitc91516 | 0:47c880c1463d | 2141 | { |
jmitc91516 | 1:a5258871b33d | 2142 | #include "VarInit.h" // Renamed from the easyGUI file "VarInit.c", so as not to confuse the mbed compiler |
jmitc91516 | 1:a5258871b33d | 2143 | } |
jmitc91516 | 0:47c880c1463d | 2144 | |
jmitc91516 | 1:a5258871b33d | 2145 | |
jmitc91516 | 1:a5258871b33d | 2146 | /* |
jmitc91516 | 1:a5258871b33d | 2147 | Sets up the easyGUI user interface in an acceptable initial state. |
jmitc91516 | 0:47c880c1463d | 2148 | |
jmitc91516 | 1:a5258871b33d | 2149 | No return code. |
jmitc91516 | 1:a5258871b33d | 2150 | */ |
jmitc91516 | 1:a5258871b33d | 2151 | void InitEasyGUIDisplay(int initialEasyGUIPage) |
jmitc91516 | 1:a5258871b33d | 2152 | { |
jmitc91516 | 1:a5258871b33d | 2153 | // easyGUI stuff - note function calls require 'extern "C"' in relevant header |
jmitc91516 | 0:47c880c1463d | 2154 | |
jmitc91516 | 0:47c880c1463d | 2155 | // Need to set up heat on/off command easyGUI variable |
jmitc91516 | 0:47c880c1463d | 2156 | // before we display the home page for the first time - |
jmitc91516 | 0:47c880c1463d | 2157 | // but we do not have a heat control object at this point - |
jmitc91516 | 0:47c880c1463d | 2158 | // default to 'Heat On' |
jmitc91516 | 0:47c880c1463d | 2159 | strcpy(GuiVar_heatOnOffCommand, "Heat On"); |
jmitc91516 | 1:a5258871b33d | 2160 | #ifdef USE_HEAT_ONOFF_BUTTON_BITMAPS |
jmitc91516 | 1:a5258871b33d | 2161 | DrawHeatOnOffButton(); |
jmitc91516 | 1:a5258871b33d | 2162 | #endif |
jmitc91516 | 0:47c880c1463d | 2163 | |
jmitc91516 | 0:47c880c1463d | 2164 | GuiDisplay_Lock(); |
jmitc91516 | 0:47c880c1463d | 2165 | |
jmitc91516 | 0:47c880c1463d | 2166 | GuiLib_Init(); |
jmitc91516 | 0:47c880c1463d | 2167 | |
jmitc91516 | 1:a5258871b33d | 2168 | DisplayEasyGuiStructure(initialEasyGUIPage, NULL, NULL); |
jmitc91516 | 0:47c880c1463d | 2169 | |
jmitc91516 | 0:47c880c1463d | 2170 | GuiDisplay_Unlock(); |
jmitc91516 | 1:a5258871b33d | 2171 | |
jmitc91516 | 1:a5258871b33d | 2172 | #ifdef USE_QSPI_BITMAPS |
jmitc91516 | 1:a5258871b33d | 2173 | qspiBitmaps.SetupArray(); |
jmitc91516 | 1:a5258871b33d | 2174 | #endif |
jmitc91516 | 1:a5258871b33d | 2175 | } |
jmitc91516 | 1:a5258871b33d | 2176 | |
jmitc91516 | 1:a5258871b33d | 2177 | void InitialiseLPC4088(DMBoard* board, void **frameBufferAddress1, void **frameBufferAddress2) |
jmitc91516 | 1:a5258871b33d | 2178 | { |
jmitc91516 | 1:a5258871b33d | 2179 | RtosLog* log = board->logger(); |
jmitc91516 | 1:a5258871b33d | 2180 | Display* disp = board->display(); |
jmitc91516 | 0:47c880c1463d | 2181 | |
jmitc91516 | 1:a5258871b33d | 2182 | DMBoard::BoardError err; |
jmitc91516 | 1:a5258871b33d | 2183 | |
jmitc91516 | 1:a5258871b33d | 2184 | do { |
jmitc91516 | 1:a5258871b33d | 2185 | err = board->init(); |
jmitc91516 | 1:a5258871b33d | 2186 | if (err != DMBoard::Ok) { |
jmitc91516 | 1:a5258871b33d | 2187 | log->printf("Failed to initialize the board, got error %d\r\n", err); |
jmitc91516 | 1:a5258871b33d | 2188 | break; |
jmitc91516 | 1:a5258871b33d | 2189 | } |
jmitc91516 | 1:a5258871b33d | 2190 | |
jmitc91516 | 1:a5258871b33d | 2191 | #ifdef MEMORY_TEST_OCT_2016 |
jmitc91516 | 1:a5258871b33d | 2192 | for (int ind = 0; ind < clogLength; ++ind) { |
jmitc91516 | 1:a5258871b33d | 2193 | clogUpMemory[ind] = 'A'; |
jmitc91516 | 1:a5258871b33d | 2194 | } |
jmitc91516 | 1:a5258871b33d | 2195 | #endif // MEMORY_TEST_OCT_2016 |
jmitc91516 | 1:a5258871b33d | 2196 | |
jmitc91516 | 1:a5258871b33d | 2197 | |
jmitc91516 | 1:a5258871b33d | 2198 | #define COLOR_FLICKERING_FIX_1 |
jmitc91516 | 1:a5258871b33d | 2199 | #ifdef COLOR_FLICKERING_FIX_1 |
jmitc91516 | 1:a5258871b33d | 2200 | // Possible fix for display flickering on LPC4088 |
jmitc91516 | 1:a5258871b33d | 2201 | uint32_t* reg = ((uint32_t*)0x400fc188); |
jmitc91516 | 1:a5258871b33d | 2202 | *reg |= (3<<10); |
jmitc91516 | 1:a5258871b33d | 2203 | #undef COLOR_FLICKERING_FIX_1 |
jmitc91516 | 1:a5258871b33d | 2204 | #endif |
jmitc91516 | 1:a5258871b33d | 2205 | log->printf("\n\nHello World!\n\n"); |
jmitc91516 | 1:a5258871b33d | 2206 | |
jmitc91516 | 1:a5258871b33d | 2207 | void* fb = disp->allocateFramebuffer(); |
jmitc91516 | 1:a5258871b33d | 2208 | if (fb == NULL) { |
jmitc91516 | 1:a5258871b33d | 2209 | log->printf("Failed to allocate memory for a frame buffer\r\n"); |
jmitc91516 | 1:a5258871b33d | 2210 | err = DMBoard::MemoryError; |
jmitc91516 | 1:a5258871b33d | 2211 | break; |
jmitc91516 | 1:a5258871b33d | 2212 | } |
jmitc91516 | 1:a5258871b33d | 2213 | |
jmitc91516 | 1:a5258871b33d | 2214 | *frameBufferAddress1 = fb; |
jmitc91516 | 1:a5258871b33d | 2215 | |
jmitc91516 | 1:a5258871b33d | 2216 | // Allocate a second frame buffer - what will its address be? |
jmitc91516 | 1:a5258871b33d | 2217 | void* fb2 = disp->allocateFramebuffer(); |
jmitc91516 | 1:a5258871b33d | 2218 | *frameBufferAddress2 = fb2; |
jmitc91516 | 1:a5258871b33d | 2219 | |
jmitc91516 | 1:a5258871b33d | 2220 | Display::DisplayError disperr; |
jmitc91516 | 1:a5258871b33d | 2221 | // disperr = disp->powerUp(fb, Display::Resolution_24bit_rgb888); |
jmitc91516 | 1:a5258871b33d | 2222 | // Start display in default mode (16-bit) (24-bit uses too much memory) |
jmitc91516 | 1:a5258871b33d | 2223 | #define COLOR_FLICKERING_FIX_2 |
jmitc91516 | 1:a5258871b33d | 2224 | #ifdef COLOR_FLICKERING_FIX_2 |
jmitc91516 | 1:a5258871b33d | 2225 | // Second possible fix for colour flickering problem, |
jmitc91516 | 1:a5258871b33d | 2226 | // suggested by Embedded Artists - specify low frame rate |
jmitc91516 | 1:a5258871b33d | 2227 | disp->powerDown(); |
jmitc91516 | 1:a5258871b33d | 2228 | disperr = disp->powerUp(fb, Display::Resolution_16bit_rgb565, FrameRate_Low); |
jmitc91516 | 1:a5258871b33d | 2229 | #undef COLOR_FLICKERING_FIX_2 |
jmitc91516 | 1:a5258871b33d | 2230 | #else |
jmitc91516 | 1:a5258871b33d | 2231 | disperr = disp->powerUp(fb); |
jmitc91516 | 1:a5258871b33d | 2232 | #endif |
jmitc91516 | 1:a5258871b33d | 2233 | if (disperr != Display::DisplayError_Ok) { |
jmitc91516 | 1:a5258871b33d | 2234 | log->printf("Failed to initialize the display, got error %d\r\n", disperr); |
jmitc91516 | 1:a5258871b33d | 2235 | break; |
jmitc91516 | 1:a5258871b33d | 2236 | } |
jmitc91516 | 2:6e94a7fd1e37 | 2237 | |
jmitc91516 | 2:6e94a7fd1e37 | 2238 | #define TEST_BACKLIGHT |
jmitc91516 | 2:6e94a7fd1e37 | 2239 | #ifdef TEST_BACKLIGHT |
jmitc91516 | 2:6e94a7fd1e37 | 2240 | disp->backlight(100); |
jmitc91516 | 2:6e94a7fd1e37 | 2241 | #endif // TEST_BACKLIGHT |
jmitc91516 | 1:a5258871b33d | 2242 | |
jmitc91516 | 1:a5258871b33d | 2243 | } while(false); |
jmitc91516 | 1:a5258871b33d | 2244 | |
jmitc91516 | 1:a5258871b33d | 2245 | if (err != DMBoard::Ok) { |
jmitc91516 | 1:a5258871b33d | 2246 | log->printf("\nTERMINATING\n"); |
jmitc91516 | 1:a5258871b33d | 2247 | wait_ms(2000); // allow RtosLog to flush messages |
jmitc91516 | 1:a5258871b33d | 2248 | mbed_die(); |
jmitc91516 | 1:a5258871b33d | 2249 | } |
jmitc91516 | 1:a5258871b33d | 2250 | } |
jmitc91516 | 1:a5258871b33d | 2251 | |
jmitc91516 | 1:a5258871b33d | 2252 | int main() |
jmitc91516 | 1:a5258871b33d | 2253 | { |
jmitc91516 | 1:a5258871b33d | 2254 | DMBoard* board = &DMBoard::instance(); |
jmitc91516 | 1:a5258871b33d | 2255 | void *frameBuffer1; |
jmitc91516 | 1:a5258871b33d | 2256 | void *frameBuffer2; |
jmitc91516 | 1:a5258871b33d | 2257 | InitialiseLPC4088(board, &frameBuffer1, &frameBuffer2); |
jmitc91516 | 1:a5258871b33d | 2258 | GuiDisplay_SetFrameAddress(frameBuffer1); |
jmitc91516 | 1:a5258871b33d | 2259 | |
jmitc91516 | 1:a5258871b33d | 2260 | SwimDraw* swimDrawInstance = SwimDraw::GetInstance(); |
jmitc91516 | 1:a5258871b33d | 2261 | if(swimDrawInstance != NULL) { |
jmitc91516 | 1:a5258871b33d | 2262 | swimDrawInstance->Initialise(board, frameBuffer1); |
jmitc91516 | 1:a5258871b33d | 2263 | } |
jmitc91516 | 1:a5258871b33d | 2264 | |
jmitc91516 | 1:a5258871b33d | 2265 | InitialiseAllEasyGUIVariables(); |
jmitc91516 | 1:a5258871b33d | 2266 | |
jmitc91516 | 1:a5258871b33d | 2267 | // The first thing we do is try to connect to the GC - |
jmitc91516 | 1:a5258871b33d | 2268 | // so tell the user this first of all... |
jmitc91516 | 1:a5258871b33d | 2269 | InitEasyGUIDisplay(GuiStruct_GCConnectionPage_Def); |
jmitc91516 | 1:a5258871b33d | 2270 | |
jmitc91516 | 1:a5258871b33d | 2271 | |
jmitc91516 | 1:a5258871b33d | 2272 | SetupEasyGUIBuildDateVariable(); |
jmitc91516 | 1:a5258871b33d | 2273 | |
jmitc91516 | 1:a5258871b33d | 2274 | |
jmitc91516 | 1:a5258871b33d | 2275 | char dbgBuff[100]; |
jmitc91516 | 1:a5258871b33d | 2276 | sprintf(dbgBuff, "FrameBuffers are: %X, %X", frameBuffer1, frameBuffer2); |
jmitc91516 | 1:a5258871b33d | 2277 | EasyGUIDebugPrint(dbgBuff, 100, 100); |
jmitc91516 | 0:47c880c1463d | 2278 | |
jmitc91516 | 0:47c880c1463d | 2279 | // Now the USB 'stuff' |
jmitc91516 | 0:47c880c1463d | 2280 | |
jmitc91516 | 0:47c880c1463d | 2281 | USBHost* usbHost = USBHost::getHostInst(); |
jmitc91516 | 0:47c880c1463d | 2282 | USBHostGC usbHostGC; |
jmitc91516 | 0:47c880c1463d | 2283 | |
jmitc91516 | 0:47c880c1463d | 2284 | DrawErrorMessage("Waiting for USB device..."); |
jmitc91516 | 1:a5258871b33d | 2285 | // Note that 'GetUSBDevice' will not return until it finds a USB device - |
jmitc91516 | 1:a5258871b33d | 2286 | // it does *not* timeout |
jmitc91516 | 1:a5258871b33d | 2287 | USBDeviceConnected* usbDevice = GetUSBDevice(usbHost); |
jmitc91516 | 0:47c880c1463d | 2288 | |
jmitc91516 | 0:47c880c1463d | 2289 | DrawErrorMessage(" "); |
jmitc91516 | 0:47c880c1463d | 2290 | |
jmitc91516 | 0:47c880c1463d | 2291 | if(usbDevice != NULL) { |
jmitc91516 | 0:47c880c1463d | 2292 | USB_TYPE enumerateRetVal = usbHost->enumerate(usbDevice, &usbHostGC); |
jmitc91516 | 0:47c880c1463d | 2293 | |
jmitc91516 | 0:47c880c1463d | 2294 | if (usbHostGC.DeviceIsGC()) { |
jmitc91516 | 0:47c880c1463d | 2295 | if (usbHostGC.AttachGCDevice(usbDevice)) { |
jmitc91516 | 0:47c880c1463d | 2296 | |
jmitc91516 | 0:47c880c1463d | 2297 | DrawErrorMessage("Found GC device "); |
jmitc91516 | 0:47c880c1463d | 2298 | |
jmitc91516 | 0:47c880c1463d | 2299 | |
jmitc91516 | 1:a5258871b33d | 2300 | #ifdef OLD_TOUCH_LISTENER |
jmitc91516 | 0:47c880c1463d | 2301 | SetupUSBGCTouchListener(board, usbDevice, &usbHostGC); |
jmitc91516 | 0:47c880c1463d | 2302 | |
jmitc91516 | 0:47c880c1463d | 2303 | DrawErrorMessage("After call to SetupUSBGCTouchListener "); |
jmitc91516 | 1:a5258871b33d | 2304 | #endif |
jmitc91516 | 0:47c880c1463d | 2305 | |
jmitc91516 | 0:47c880c1463d | 2306 | getGCStatusLoop = GetGCStatusLoop::GetInstance(usbDevice, &usbHostGC); |
jmitc91516 | 0:47c880c1463d | 2307 | |
jmitc91516 | 0:47c880c1463d | 2308 | DrawErrorMessage("After creation of GetGCStatusLoop instance "); |
jmitc91516 | 0:47c880c1463d | 2309 | |
jmitc91516 | 0:47c880c1463d | 2310 | |
jmitc91516 | 0:47c880c1463d | 2311 | theGCHeatControl = new GCHeatControl(usbDevice, &usbHostGC); |
jmitc91516 | 0:47c880c1463d | 2312 | |
jmitc91516 | 1:a5258871b33d | 2313 | #ifdef USE_HEAT_ONOFF_BUTTON_BITMAPS |
jmitc91516 | 1:a5258871b33d | 2314 | DrawHeatOnOffButton(); |
jmitc91516 | 1:a5258871b33d | 2315 | #else |
jmitc91516 | 0:47c880c1463d | 2316 | UpdateHeatOnOffEasyGuiVariable(); |
jmitc91516 | 1:a5258871b33d | 2317 | #endif // USE_HEAT_ONOFF_BUTTON_BITMAPS |
jmitc91516 | 1:a5258871b33d | 2318 | |
jmitc91516 | 0:47c880c1463d | 2319 | DrawErrorMessage("After UpdateHeatOnOffEasyGuiVariable "); |
jmitc91516 | 0:47c880c1463d | 2320 | |
jmitc91516 | 1:a5258871b33d | 2321 | |
jmitc91516 | 0:47c880c1463d | 2322 | getGCStatusLoop->SetHomePageGCComponentStatusColorAreas(&homePageGCComponentStatusColorAreas); |
jmitc91516 | 0:47c880c1463d | 2323 | getGCStatusLoop->SetSingleGCComponentPageStatusColorAreas(&singleGCComponentPageStatusColorAreas); |
jmitc91516 | 0:47c880c1463d | 2324 | |
jmitc91516 | 0:47c880c1463d | 2325 | DrawErrorMessage("Point 1 "); |
jmitc91516 | 0:47c880c1463d | 2326 | |
jmitc91516 | 1:a5258871b33d | 2327 | #ifdef SERVICE_INTERVALS_ACTIVE |
jmitc91516 | 1:a5258871b33d | 2328 | ServiceInterval::SetupAllServiceIntervals(); |
jmitc91516 | 1:a5258871b33d | 2329 | // Note these two functions *** have different names *** |
jmitc91516 | 1:a5258871b33d | 2330 | ServiceInterval::StartAllServiceIntervals(); |
jmitc91516 | 1:a5258871b33d | 2331 | #endif // SERVICE_INTERVALS_ACTIVE |
jmitc91516 | 1:a5258871b33d | 2332 | |
jmitc91516 | 1:a5258871b33d | 2333 | DrawErrorMessage("Point 2 "); |
jmitc91516 | 1:a5258871b33d | 2334 | |
jmitc91516 | 0:47c880c1463d | 2335 | getGCStatusLoop->SetupAllEasyGUIVariables(); |
jmitc91516 | 1:a5258871b33d | 2336 | SetupDoorActuatorCommandUserInterface(usbDevice, &usbHostGC, true); |
jmitc91516 | 1:a5258871b33d | 2337 | |
jmitc91516 | 1:a5258871b33d | 2338 | DrawErrorMessage("Point 3 "); |
jmitc91516 | 1:a5258871b33d | 2339 | #ifdef USE_QSPI_BITMAPS |
jmitc91516 | 1:a5258871b33d | 2340 | getGCStatusLoop->SetQSPIBitmaps(&qspiBitmaps); |
jmitc91516 | 1:a5258871b33d | 2341 | // Test - what does it do if it cannot find the bitmaps?? |
jmitc91516 | 1:a5258871b33d | 2342 | #endif |
jmitc91516 | 1:a5258871b33d | 2343 | DrawErrorMessage("Point 4 "); |
jmitc91516 | 0:47c880c1463d | 2344 | |
jmitc91516 | 0:47c880c1463d | 2345 | getGCStatusLoop->SetCurrentPage(GuiStruct_HomePage_1); |
jmitc91516 | 0:47c880c1463d | 2346 | |
jmitc91516 | 1:a5258871b33d | 2347 | DrawErrorMessage("Point 5 "); |
jmitc91516 | 0:47c880c1463d | 2348 | |
jmitc91516 | 1:a5258871b33d | 2349 | //DisplayEasyGuiStructure(GuiStruct_HomePage_1, usbDevice, &usbHostGC); |
jmitc91516 | 1:a5258871b33d | 2350 | |
jmitc91516 | 1:a5258871b33d | 2351 | DebugPrint("Before MainLoopWithEthernet", 100, 450); |
jmitc91516 | 1:a5258871b33d | 2352 | |
jmitc91516 | 1:a5258871b33d | 2353 | // Currently, this never returns - but it allows time for the TouchCallback function to be invoked |
jmitc91516 | 1:a5258871b33d | 2354 | //getGCStatusLoop->MainLoop(board); |
jmitc91516 | 1:a5258871b33d | 2355 | getGCStatusLoop->MainLoopWithEthernet(board); |
jmitc91516 | 0:47c880c1463d | 2356 | |
jmitc91516 | 0:47c880c1463d | 2357 | // Should never reach this code - but just in case... |
jmitc91516 | 0:47c880c1463d | 2358 | delete theGCHeatControl; |
jmitc91516 | 0:47c880c1463d | 2359 | |
jmitc91516 | 0:47c880c1463d | 2360 | } else { |
jmitc91516 | 0:47c880c1463d | 2361 | DrawErrorMessage("Failed to attach GC device to host "); |
jmitc91516 | 0:47c880c1463d | 2362 | } |
jmitc91516 | 0:47c880c1463d | 2363 | } else { |
jmitc91516 | 0:47c880c1463d | 2364 | DrawErrorMessage(" *** USB device found, is *not* a GC *** "); |
jmitc91516 | 0:47c880c1463d | 2365 | } |
jmitc91516 | 0:47c880c1463d | 2366 | } else { |
jmitc91516 | 0:47c880c1463d | 2367 | DrawErrorMessage(" *** No USB device found *** "); |
jmitc91516 | 0:47c880c1463d | 2368 | } |
jmitc91516 | 0:47c880c1463d | 2369 | |
jmitc91516 | 0:47c880c1463d | 2370 | while(true) {} |
jmitc91516 | 0:47c880c1463d | 2371 | } |
jmitc91516 | 0:47c880c1463d | 2372 | |
jmitc91516 | 0:47c880c1463d | 2373 |