Repository for import to local machine

Dependencies:   DMBasicGUI DMSupport

Committer:
jmitc91516
Date:
Mon Jul 31 15:37:57 2017 +0000
Revision:
8:26e49e6955bd
Parent:
1:a5258871b33d
Method ramp scrolling improved, and more bitmaps moved to QSPI memory

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jmitc91516 1:a5258871b33d 1 #include "GasBackPressureDACPageHandler.h"
jmitc91516 1:a5258871b33d 2 #include "EasyGUITouchAreaIndices.h"
jmitc91516 1:a5258871b33d 3 #include "SettingsHandler.h"
jmitc91516 1:a5258871b33d 4 #include "GetGCStatusLoop.h"
jmitc91516 1:a5258871b33d 5 #include "NumericKeypadPageHandler.h"
jmitc91516 1:a5258871b33d 6
jmitc91516 1:a5258871b33d 7 #include <stdio.h>
jmitc91516 1:a5258871b33d 8 #include <stdlib.h>
jmitc91516 1:a5258871b33d 9
jmitc91516 1:a5258871b33d 10
jmitc91516 1:a5258871b33d 11
jmitc91516 1:a5258871b33d 12 /*
jmitc91516 1:a5258871b33d 13 Displays the specified easyGUI 'structure' (or page, to use a more easily understood term).
jmitc91516 1:a5258871b33d 14 Defined in main.cpp
jmitc91516 1:a5258871b33d 15 */
jmitc91516 1:a5258871b33d 16 extern void DisplayEasyGuiStructure(int structureIndex, USBDeviceConnected* usbDevice, USBHostGC* usbHostGC, bool updateEasyGUIVariables = true);
jmitc91516 1:a5258871b33d 17
jmitc91516 1:a5258871b33d 18
jmitc91516 1:a5258871b33d 19 /*
jmitc91516 1:a5258871b33d 20 Converts three eight-bit colour values to the corresponding 16-bit RGB565 value.
jmitc91516 1:a5258871b33d 21 Defined in main.cpp
jmitc91516 1:a5258871b33d 22 */
jmitc91516 1:a5258871b33d 23 extern GuiConst_INTCOLOR SixteenBitColorValue(GuiConst_INT8U red, GuiConst_INT8U green, GuiConst_INT8U blue);
jmitc91516 1:a5258871b33d 24
jmitc91516 1:a5258871b33d 25
jmitc91516 1:a5258871b33d 26 /*
jmitc91516 1:a5258871b33d 27 Note that this class is a singleton - we do not need or want there to be more than one instance of it
jmitc91516 1:a5258871b33d 28 (we do not want multiple values for the gain and offset, etc, and nor will we show
jmitc91516 1:a5258871b33d 29 more than one easyGUI 'GasBackPressureDACPage' to the user at the same time).
jmitc91516 1:a5258871b33d 30 */
jmitc91516 1:a5258871b33d 31 GasBackPressureDACPageHandler * GasBackPressureDACPageHandler::theGasBackPressureDACPageHandlerInstance = NULL;
jmitc91516 1:a5258871b33d 32
jmitc91516 1:a5258871b33d 33
jmitc91516 1:a5258871b33d 34 /*
jmitc91516 1:a5258871b33d 35 The minimum and maximum values for the gain and offset (both the same)
jmitc91516 1:a5258871b33d 36 */
jmitc91516 1:a5258871b33d 37 const int GasBackPressureDACPageHandler::minimumGainAndOffsetValue = 0;
jmitc91516 1:a5258871b33d 38 const int GasBackPressureDACPageHandler::maximumGainAndOffsetValue = 9999;
jmitc91516 1:a5258871b33d 39
jmitc91516 1:a5258871b33d 40 /*
jmitc91516 1:a5258871b33d 41 We distinguish the 'active' field - i.e. the one being edited by the user -
jmitc91516 1:a5258871b33d 42 from the inactive fields, by its background colour
jmitc91516 1:a5258871b33d 43 */
jmitc91516 1:a5258871b33d 44 const GuiConst_INTCOLOR GasBackPressureDACPageHandler::inactiveFieldBackgroundColour = SixteenBitColorValue(192, 192, 192); // Grey
jmitc91516 1:a5258871b33d 45 const GuiConst_INTCOLOR GasBackPressureDACPageHandler::activeFieldBackgroundColour = SixteenBitColorValue(255, 255, 0); // Yellow
jmitc91516 1:a5258871b33d 46
jmitc91516 1:a5258871b33d 47
jmitc91516 1:a5258871b33d 48 /*
jmitc91516 1:a5258871b33d 49 Singleton class - return the one and only instance, first creating it if necessary.
jmitc91516 1:a5258871b33d 50 */
jmitc91516 1:a5258871b33d 51 GasBackPressureDACPageHandler * GasBackPressureDACPageHandler::GetInstance(USBDeviceConnected* newUsbDevice, USBHostGC* newUsbHostGC)
jmitc91516 1:a5258871b33d 52 {
jmitc91516 1:a5258871b33d 53 if (theGasBackPressureDACPageHandlerInstance == NULL) {
jmitc91516 1:a5258871b33d 54 theGasBackPressureDACPageHandlerInstance = new GasBackPressureDACPageHandler(newUsbDevice, newUsbHostGC);
jmitc91516 1:a5258871b33d 55 }
jmitc91516 1:a5258871b33d 56
jmitc91516 1:a5258871b33d 57 return theGasBackPressureDACPageHandlerInstance;
jmitc91516 1:a5258871b33d 58 }
jmitc91516 1:a5258871b33d 59
jmitc91516 1:a5258871b33d 60 // Singleton class - private constructor
jmitc91516 1:a5258871b33d 61 GasBackPressureDACPageHandler::GasBackPressureDACPageHandler(USBDeviceConnected* newUsbDevice, USBHostGC* newUsbHostGC)
jmitc91516 1:a5258871b33d 62 {
jmitc91516 1:a5258871b33d 63 usbDevice = newUsbDevice;
jmitc91516 1:a5258871b33d 64 usbHostGC = newUsbHostGC;
jmitc91516 1:a5258871b33d 65 }
jmitc91516 1:a5258871b33d 66
jmitc91516 1:a5258871b33d 67 // Private destructor also
jmitc91516 1:a5258871b33d 68 GasBackPressureDACPageHandler::~GasBackPressureDACPageHandler()
jmitc91516 1:a5258871b33d 69 {
jmitc91516 1:a5258871b33d 70 //SaveCarrierGasSelectionToQSPISettings();
jmitc91516 1:a5258871b33d 71 }
jmitc91516 1:a5258871b33d 72
jmitc91516 1:a5258871b33d 73
jmitc91516 1:a5258871b33d 74 /*
jmitc91516 1:a5258871b33d 75 Tells the caller whether or not the specified touch index is on the easyGUI 'GasCalibrationPage',
jmitc91516 1:a5258871b33d 76 and therefore needs to be handled by this class.
jmitc91516 1:a5258871b33d 77
jmitc91516 1:a5258871b33d 78 Args: the touch area index in question
jmitc91516 1:a5258871b33d 79
jmitc91516 1:a5258871b33d 80 Return code: true if the touch area is 'one of ours', false if not
jmitc91516 1:a5258871b33d 81 */
jmitc91516 1:a5258871b33d 82 bool GasBackPressureDACPageHandler::TouchAreaIsOnGasBackPressureDACPage(int touchAreaIndex)
jmitc91516 1:a5258871b33d 83 {
jmitc91516 1:a5258871b33d 84 if((touchAreaIndex >= MIN_GAS_BACKPRESSURE_DAC_TOUCHINDEX) && (touchAreaIndex <= MAX_GAS_BACKPRESSURE_DAC_TOUCHINDEX)) {
jmitc91516 1:a5258871b33d 85 return true;
jmitc91516 1:a5258871b33d 86 }
jmitc91516 1:a5258871b33d 87
jmitc91516 1:a5258871b33d 88 // 'else'
jmitc91516 1:a5258871b33d 89 return false;
jmitc91516 1:a5258871b33d 90 }
jmitc91516 1:a5258871b33d 91
jmitc91516 1:a5258871b33d 92 /*
jmitc91516 1:a5258871b33d 93 If the specified touch area represents a key or field on the easyGUI 'GasBackPressureDACPage',
jmitc91516 1:a5258871b33d 94 this function performs whatever action is appropriate for it. Provided so that the caller
jmitc91516 1:a5258871b33d 95 can (in effect) say "if this is one of yours, deal with it", without needing to know
jmitc91516 1:a5258871b33d 96 anything about what this class does, or how it handles the touch areas on that easyGUI page.
jmitc91516 1:a5258871b33d 97
jmitc91516 1:a5258871b33d 98 Args: the touch area index in question
jmitc91516 1:a5258871b33d 99
jmitc91516 1:a5258871b33d 100 Returns true if it dealt with the touch area (so the caller need not do anything else
jmitc91516 1:a5258871b33d 101 with the value), or false if it did not deal with the touch area (implying that it
jmitc91516 1:a5258871b33d 102 was not a touch area on the easyGUI 'GasBackPressureDACPage', and so the caller
jmitc91516 1:a5258871b33d 103 must deal with it some other way).
jmitc91516 1:a5258871b33d 104 */
jmitc91516 1:a5258871b33d 105 bool GasBackPressureDACPageHandler::DealWithTouch(int touchAreaIndex)
jmitc91516 1:a5258871b33d 106 {
jmitc91516 1:a5258871b33d 107 // Note that we have only two editable fields
jmitc91516 1:a5258871b33d 108
jmitc91516 1:a5258871b33d 109 if(touchAreaIndex == GAS_BACKPRESSURE_DAC_GAIN_EDIT) {
jmitc91516 1:a5258871b33d 110 NumericKeypadPageHandler* numericKeypadPageHandler = NumericKeypadPageHandler::GetInstance(usbDevice, usbHostGC);
jmitc91516 1:a5258871b33d 111 if(numericKeypadPageHandler != NULL) {
jmitc91516 1:a5258871b33d 112 numericKeypadPageHandler->StartEditing(GuiVar_gasBackPressureDACGain);
jmitc91516 1:a5258871b33d 113 numericKeypadPageHandler->SetEasyGUIVariableToEdit(GuiVar_gasBackPressureDACGain);
jmitc91516 1:a5258871b33d 114 numericKeypadPageHandler->SetEasyGUICallingPage(GuiStruct_GasBackPressureDACPage_Def);
jmitc91516 1:a5258871b33d 115 numericKeypadPageHandler->SetEditVariableRange(minimumGainAndOffsetValue, maximumGainAndOffsetValue);
jmitc91516 1:a5258871b33d 116 numericKeypadPageHandler->SetEditVariableName("0 PSI");
jmitc91516 1:a5258871b33d 117 numericKeypadPageHandler->DisplayEasyGUIPage();
jmitc91516 1:a5258871b33d 118 }
jmitc91516 1:a5258871b33d 119
jmitc91516 1:a5258871b33d 120 return true;
jmitc91516 1:a5258871b33d 121 }
jmitc91516 1:a5258871b33d 122
jmitc91516 1:a5258871b33d 123 if(touchAreaIndex == GAS_BACKPRESSURE_DAC_OFFSET_EDIT) {
jmitc91516 1:a5258871b33d 124 NumericKeypadPageHandler* numericKeypadPageHandler = NumericKeypadPageHandler::GetInstance(usbDevice, usbHostGC);
jmitc91516 1:a5258871b33d 125 if(numericKeypadPageHandler != NULL) {
jmitc91516 1:a5258871b33d 126 numericKeypadPageHandler->StartEditing(GuiVar_gasBackPressureDACOffset);
jmitc91516 1:a5258871b33d 127 numericKeypadPageHandler->SetEasyGUIVariableToEdit(GuiVar_gasBackPressureDACOffset);
jmitc91516 1:a5258871b33d 128 numericKeypadPageHandler->SetEasyGUICallingPage(GuiStruct_GasBackPressureDACPage_Def);
jmitc91516 1:a5258871b33d 129 numericKeypadPageHandler->SetEditVariableRange(minimumGainAndOffsetValue, maximumGainAndOffsetValue);
jmitc91516 1:a5258871b33d 130 numericKeypadPageHandler->SetEditVariableName("50 PSI");
jmitc91516 1:a5258871b33d 131 numericKeypadPageHandler->DisplayEasyGUIPage();
jmitc91516 1:a5258871b33d 132 }
jmitc91516 1:a5258871b33d 133
jmitc91516 1:a5258871b33d 134 return true;
jmitc91516 1:a5258871b33d 135 }
jmitc91516 1:a5258871b33d 136
jmitc91516 1:a5258871b33d 137 if(touchAreaIndex == GAS_BACKPRESSURE_DAC_GET) {
jmitc91516 1:a5258871b33d 138
jmitc91516 1:a5258871b33d 139 GetCurrentGasBackPressureDACValuesFromGC();
jmitc91516 1:a5258871b33d 140 SetAllEditableFieldsToInactive();
jmitc91516 1:a5258871b33d 141
jmitc91516 1:a5258871b33d 142 UpdateEasyGUIPage();
jmitc91516 1:a5258871b33d 143
jmitc91516 1:a5258871b33d 144 return true;
jmitc91516 1:a5258871b33d 145 }
jmitc91516 1:a5258871b33d 146
jmitc91516 1:a5258871b33d 147 if(touchAreaIndex == GAS_BACKPRESSURE_DAC_SET) {
jmitc91516 1:a5258871b33d 148
jmitc91516 1:a5258871b33d 149 SetCurrentGasBackPressureDACValuesInGC();
jmitc91516 1:a5258871b33d 150 SetAllEditableFieldsToInactive();
jmitc91516 1:a5258871b33d 151
jmitc91516 1:a5258871b33d 152 return true;
jmitc91516 1:a5258871b33d 153 }
jmitc91516 1:a5258871b33d 154
jmitc91516 1:a5258871b33d 155 // 'else' - none of the above
jmitc91516 1:a5258871b33d 156 return false;
jmitc91516 1:a5258871b33d 157 }
jmitc91516 1:a5258871b33d 158
jmitc91516 1:a5258871b33d 159
jmitc91516 1:a5258871b33d 160 /*
jmitc91516 1:a5258871b33d 161 Gets the current gas backpressure gain and offset values from the GC,
jmitc91516 1:a5258871b33d 162 and copies them to the relevant easyGUI variables so that they can be displayed.
jmitc91516 1:a5258871b33d 163 Note that it is up to the caller to redisplay the page.
jmitc91516 1:a5258871b33d 164
jmitc91516 1:a5258871b33d 165 No arguments, no return code
jmitc91516 1:a5258871b33d 166 */
jmitc91516 1:a5258871b33d 167 bool GasBackPressureDACPageHandler::GetCurrentGasBackPressureDACValuesFromGC(void)
jmitc91516 1:a5258871b33d 168 {
jmitc91516 1:a5258871b33d 169 char response[50];
jmitc91516 1:a5258871b33d 170
jmitc91516 1:a5258871b33d 171 // Gain first
jmitc91516 1:a5258871b33d 172 while(usbHostGC->ExecutingSetDeviceReport()) {}
jmitc91516 1:a5258871b33d 173 usbHostGC->SetDeviceReport(usbDevice, "GBPG", response);
jmitc91516 1:a5258871b33d 174 // We expect a response like this: "DBPGnnnn", when nnnn is the DAC value,
jmitc91516 1:a5258871b33d 175 // or "EPKT" if something went wrong
jmitc91516 1:a5258871b33d 176 if(response[0] == 'E') {
jmitc91516 1:a5258871b33d 177 // Assume "EPKT"
jmitc91516 1:a5258871b33d 178 return false;
jmitc91516 1:a5258871b33d 179 }
jmitc91516 1:a5258871b33d 180
jmitc91516 1:a5258871b33d 181 //Ensure null terminator
jmitc91516 1:a5258871b33d 182 response[8] = '\0';
jmitc91516 1:a5258871b33d 183
jmitc91516 1:a5258871b33d 184 // Ignore leading zeroes - but make sure we leave the final digit, whether zero or not
jmitc91516 1:a5258871b33d 185 int startIndex;
jmitc91516 1:a5258871b33d 186 for(startIndex = 4; startIndex < 7; ++startIndex) {
jmitc91516 1:a5258871b33d 187 if(response[startIndex] != '0') {
jmitc91516 1:a5258871b33d 188 break;
jmitc91516 1:a5258871b33d 189 }
jmitc91516 1:a5258871b33d 190 }
jmitc91516 1:a5258871b33d 191
jmitc91516 1:a5258871b33d 192 strcpy(GuiVar_gasBackPressureDACGain, &response[startIndex]);
jmitc91516 1:a5258871b33d 193
jmitc91516 1:a5258871b33d 194
jmitc91516 1:a5258871b33d 195 // Now the offset
jmitc91516 1:a5258871b33d 196 while(usbHostGC->ExecutingSetDeviceReport()) {}
jmitc91516 1:a5258871b33d 197 usbHostGC->SetDeviceReport(usbDevice, "GBPO", response);
jmitc91516 1:a5258871b33d 198 // We expect a response like this: "DBPOnnnn", when nnnn is the DAC value,
jmitc91516 1:a5258871b33d 199 // or "EPKT" if something went wrong
jmitc91516 1:a5258871b33d 200 if(response[0] == 'E') {
jmitc91516 1:a5258871b33d 201 // Assume "EPKT"
jmitc91516 1:a5258871b33d 202 return false;
jmitc91516 1:a5258871b33d 203 }
jmitc91516 1:a5258871b33d 204
jmitc91516 1:a5258871b33d 205 //Ensure null terminator
jmitc91516 1:a5258871b33d 206 response[8] = '\0';
jmitc91516 1:a5258871b33d 207
jmitc91516 1:a5258871b33d 208 // Ignore leading zeroes - but make sure we leave the final digit, whether zero or not
jmitc91516 1:a5258871b33d 209 for(startIndex = 4; startIndex < 7; ++startIndex) {
jmitc91516 1:a5258871b33d 210 if(response[startIndex] != '0') {
jmitc91516 1:a5258871b33d 211 break;
jmitc91516 1:a5258871b33d 212 }
jmitc91516 1:a5258871b33d 213 }
jmitc91516 1:a5258871b33d 214
jmitc91516 1:a5258871b33d 215 strcpy(GuiVar_gasBackPressureDACOffset, &response[startIndex]);
jmitc91516 1:a5258871b33d 216
jmitc91516 1:a5258871b33d 217 return true;
jmitc91516 1:a5258871b33d 218 }
jmitc91516 1:a5258871b33d 219
jmitc91516 1:a5258871b33d 220
jmitc91516 1:a5258871b33d 221 /*
jmitc91516 1:a5258871b33d 222 To set the gas backpressure gain or offset, the GC expects a command of the form:
jmitc91516 1:a5258871b33d 223
jmitc91516 1:a5258871b33d 224 "SBPcnnnn"
jmitc91516 1:a5258871b33d 225
jmitc91516 1:a5258871b33d 226 where 'c' is the single character 'G' for gain or 'O' for offset, and "nnnn" is the value in question.
jmitc91516 1:a5258871b33d 227 This must be four digits, and must therefore be padded with leading zeroes if the actual value is shorter than this.
jmitc91516 1:a5258871b33d 228
jmitc91516 1:a5258871b33d 229 This function constructs the required command.
jmitc91516 1:a5258871b33d 230
jmitc91516 1:a5258871b33d 231 Arguments: a buffer to contain the command
jmitc91516 1:a5258871b33d 232 a single character for gain or offset (we leave it up to the caller to make sure this is 'G' or 'O')
jmitc91516 1:a5258871b33d 233 a pointer to the easyGUI variable containing the value (we expect this to be a null-terminated character string)
jmitc91516 1:a5258871b33d 234
jmitc91516 1:a5258871b33d 235 No return code
jmitc91516 1:a5258871b33d 236 */
jmitc91516 1:a5258871b33d 237 void GasBackPressureDACPageHandler::ConstructSetBackPressureCommand(char *command, char gainOrOffsetCharacter, GuiConst_TEXT* easyGUIVariable)
jmitc91516 1:a5258871b33d 238 {
jmitc91516 1:a5258871b33d 239 command[0] = 'S';
jmitc91516 1:a5258871b33d 240 command[1] = 'B';
jmitc91516 1:a5258871b33d 241 command[2] = 'P';
jmitc91516 1:a5258871b33d 242 command[3] = gainOrOffsetCharacter;
jmitc91516 1:a5258871b33d 243
jmitc91516 1:a5258871b33d 244 int startIndex = 8 - strlen(easyGUIVariable);
jmitc91516 1:a5258871b33d 245
jmitc91516 1:a5258871b33d 246 int index = 4;
jmitc91516 1:a5258871b33d 247 while(index < startIndex) {
jmitc91516 1:a5258871b33d 248 command[index++] = '0';
jmitc91516 1:a5258871b33d 249 }
jmitc91516 1:a5258871b33d 250 int easyGUIVariableIndex = 0;
jmitc91516 1:a5258871b33d 251 while(index < 8) {
jmitc91516 1:a5258871b33d 252 command[index++] = easyGUIVariable[easyGUIVariableIndex++];
jmitc91516 1:a5258871b33d 253 }
jmitc91516 1:a5258871b33d 254
jmitc91516 1:a5258871b33d 255 command[8] = '\0';
jmitc91516 1:a5258871b33d 256 }
jmitc91516 1:a5258871b33d 257
jmitc91516 1:a5258871b33d 258 /*
jmitc91516 1:a5258871b33d 259 Sets the Gas Backpressure DAC gain and offset values in the GC,
jmitc91516 1:a5258871b33d 260 from our easyGUIvariables.
jmitc91516 1:a5258871b33d 261
jmitc91516 1:a5258871b33d 262 No arguments
jmitc91516 1:a5258871b33d 263
jmitc91516 1:a5258871b33d 264 Returns true on success, false on failure
jmitc91516 1:a5258871b33d 265 */
jmitc91516 1:a5258871b33d 266 bool GasBackPressureDACPageHandler::SetCurrentGasBackPressureDACValuesInGC(void)
jmitc91516 1:a5258871b33d 267 {
jmitc91516 1:a5258871b33d 268 char command[10];
jmitc91516 1:a5258871b33d 269 char response[50];
jmitc91516 1:a5258871b33d 270
jmitc91516 1:a5258871b33d 271 // Gain first
jmitc91516 1:a5258871b33d 272 ConstructSetBackPressureCommand(command, 'G', GuiVar_gasBackPressureDACGain);
jmitc91516 1:a5258871b33d 273 while(usbHostGC->ExecutingSetDeviceReport()) {}
jmitc91516 1:a5258871b33d 274 usbHostGC->SetDeviceReport(usbDevice, command, response);
jmitc91516 1:a5258871b33d 275 if(response[0] == 'E') {
jmitc91516 1:a5258871b33d 276 // Assume "EPKT"
jmitc91516 1:a5258871b33d 277 return false;
jmitc91516 1:a5258871b33d 278 }
jmitc91516 1:a5258871b33d 279
jmitc91516 1:a5258871b33d 280 // Now offset
jmitc91516 1:a5258871b33d 281 ConstructSetBackPressureCommand(command, 'O', GuiVar_gasBackPressureDACOffset);
jmitc91516 1:a5258871b33d 282 while(usbHostGC->ExecutingSetDeviceReport()) {}
jmitc91516 1:a5258871b33d 283 usbHostGC->SetDeviceReport(usbDevice, command, response);
jmitc91516 1:a5258871b33d 284 if(response[0] == 'E') {
jmitc91516 1:a5258871b33d 285 // Assume "EPKT"
jmitc91516 1:a5258871b33d 286 return false;
jmitc91516 1:a5258871b33d 287 }
jmitc91516 1:a5258871b33d 288
jmitc91516 1:a5258871b33d 289 return true;
jmitc91516 1:a5258871b33d 290 }
jmitc91516 1:a5258871b33d 291
jmitc91516 1:a5258871b33d 292
jmitc91516 1:a5258871b33d 293 /*
jmitc91516 1:a5258871b33d 294 (Re)display the easyGUI 'GasBackPressureDACPage' -
jmitc91516 1:a5258871b33d 295 e.g. after the caller has updated one or more of the easyGUI variables
jmitc91516 1:a5258871b33d 296 included in the page, and wants to display the new value to the user.
jmitc91516 1:a5258871b33d 297
jmitc91516 1:a5258871b33d 298 No arguments, no return code
jmitc91516 1:a5258871b33d 299 */
jmitc91516 1:a5258871b33d 300 void GasBackPressureDACPageHandler::UpdateEasyGUIPage(void)
jmitc91516 1:a5258871b33d 301 {
jmitc91516 1:a5258871b33d 302 GetGCStatusLoop *getGCStatusLoop = GetGCStatusLoop::GetInstance();
jmitc91516 1:a5258871b33d 303
jmitc91516 1:a5258871b33d 304 if(getGCStatusLoop != NULL) {
jmitc91516 1:a5258871b33d 305 // The Gas Back Pressure DAC page has a status rectangle for the gas -
jmitc91516 1:a5258871b33d 306 // GetGCStatusLoop can display this, we cannot
jmitc91516 1:a5258871b33d 307 getGCStatusLoop->ForceUpdateOfGasBackPressureDACPage();
jmitc91516 1:a5258871b33d 308 }
jmitc91516 1:a5258871b33d 309 }
jmitc91516 1:a5258871b33d 310
jmitc91516 1:a5258871b33d 311 /*
jmitc91516 1:a5258871b33d 312 Inactivates all editable fields, i.e. sets all the background colours to the 'inactive' colour,
jmitc91516 1:a5258871b33d 313 and sets the currently active field selection to 'none'.
jmitc91516 1:a5258871b33d 314
jmitc91516 1:a5258871b33d 315 No arguments, no return code
jmitc91516 1:a5258871b33d 316 */
jmitc91516 1:a5258871b33d 317 void GasBackPressureDACPageHandler::SetAllEditableFieldsToInactive(void)
jmitc91516 1:a5258871b33d 318 {
jmitc91516 1:a5258871b33d 319 GuiVar_gasBackPressureDACGainBackgroundColour = inactiveFieldBackgroundColour;
jmitc91516 1:a5258871b33d 320 GuiVar_gasBackPressureDACOffsetBackgroundColour = inactiveFieldBackgroundColour;
jmitc91516 1:a5258871b33d 321
jmitc91516 1:a5258871b33d 322 currentlyActiveField = NONE;
jmitc91516 1:a5258871b33d 323 }
jmitc91516 1:a5258871b33d 324
jmitc91516 1:a5258871b33d 325
jmitc91516 1:a5258871b33d 326 /*
jmitc91516 1:a5258871b33d 327 Caller is telling us it is about to display the easyGUI 'GasBackPressureDACPage',
jmitc91516 1:a5258871b33d 328 and that we should do whatever we have to do to get it ready,
jmitc91516 1:a5258871b33d 329 before the caller displays it.
jmitc91516 1:a5258871b33d 330
jmitc91516 1:a5258871b33d 331 Args: a boolean set true if the easyGUI variables displayed in the page are to be updated
jmitc91516 1:a5258871b33d 332 from the GC, false if not. The expectation is that this will be true
jmitc91516 1:a5258871b33d 333 except when the user has just updated one of variables using the numeric keypad.
jmitc91516 1:a5258871b33d 334
jmitc91516 1:a5258871b33d 335 No return code
jmitc91516 1:a5258871b33d 336 */
jmitc91516 1:a5258871b33d 337 void GasBackPressureDACPageHandler::DisplayingEasyGUIPage(bool updateEasyGUIVariables)
jmitc91516 1:a5258871b33d 338 {
jmitc91516 1:a5258871b33d 339 if(updateEasyGUIVariables) {
jmitc91516 1:a5258871b33d 340 GetCurrentGasBackPressureDACValuesFromGC();
jmitc91516 1:a5258871b33d 341 }
jmitc91516 1:a5258871b33d 342
jmitc91516 1:a5258871b33d 343 SetAllEditableFieldsToInactive();
jmitc91516 1:a5258871b33d 344 }
jmitc91516 1:a5258871b33d 345
jmitc91516 1:a5258871b33d 346
jmitc91516 1:a5258871b33d 347 /*
jmitc91516 1:a5258871b33d 348 Selects one field (gain or offset) as the active field, and if the other field is currently active, inactivates it
jmitc91516 1:a5258871b33d 349
jmitc91516 1:a5258871b33d 350 Arguments: 'this' field - i.e. the field to be activated
jmitc91516 1:a5258871b33d 351 the other field
jmitc91516 1:a5258871b33d 352 pointer to the background colour easyGUI variable for 'this' field
jmitc91516 1:a5258871b33d 353 pointer to the background colour easyGUI variable for the other field
jmitc91516 1:a5258871b33d 354
jmitc91516 1:a5258871b33d 355 no return code
jmitc91516 1:a5258871b33d 356 */
jmitc91516 1:a5258871b33d 357 void GasBackPressureDACPageHandler::SelectActiveField(ActiveField thisField, ActiveField otherField, GuiConst_INTCOLOR *thisFieldBGColour, GuiConst_INTCOLOR* otherFieldBGColour)
jmitc91516 1:a5258871b33d 358 {
jmitc91516 1:a5258871b33d 359 if(currentlyActiveField == otherField) {
jmitc91516 1:a5258871b33d 360 *otherFieldBGColour = inactiveFieldBackgroundColour;
jmitc91516 1:a5258871b33d 361 }
jmitc91516 1:a5258871b33d 362
jmitc91516 1:a5258871b33d 363 *thisFieldBGColour = activeFieldBackgroundColour;
jmitc91516 1:a5258871b33d 364
jmitc91516 1:a5258871b33d 365 currentlyActiveField = thisField;
jmitc91516 1:a5258871b33d 366
jmitc91516 1:a5258871b33d 367 UpdateEasyGUIPage();
jmitc91516 1:a5258871b33d 368 }
jmitc91516 1:a5258871b33d 369