Repository for import to local machine
Dependencies: DMBasicGUI DMSupport
GasCalibrationPageHandler.h@8:26e49e6955bd, 2017-07-31 (annotated)
- 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?
User | Revision | Line number | New contents of line |
---|---|---|---|
jmitc91516 | 1:a5258871b33d | 1 | #ifndef GASCALIBRATIONPAGEHANDLER_H |
jmitc91516 | 1:a5258871b33d | 2 | #define GASCALIBRATIONPAGEHANDLER_H |
jmitc91516 | 1:a5258871b33d | 3 | |
jmitc91516 | 1:a5258871b33d | 4 | #include "mbed.h" |
jmitc91516 | 1:a5258871b33d | 5 | #include "DMBoard.h" |
jmitc91516 | 1:a5258871b33d | 6 | |
jmitc91516 | 1:a5258871b33d | 7 | #include "USBHostGC.h" |
jmitc91516 | 1:a5258871b33d | 8 | |
jmitc91516 | 1:a5258871b33d | 9 | #include "GuiLib.h" |
jmitc91516 | 1:a5258871b33d | 10 | |
jmitc91516 | 1:a5258871b33d | 11 | /* |
jmitc91516 | 1:a5258871b33d | 12 | A struct to relate the index of an easyGUI touch area on the 'GasCalibrationPage', |
jmitc91516 | 1:a5258871b33d | 13 | with the easyGUI variable and our own internal variable to which it corresponds |
jmitc91516 | 1:a5258871b33d | 14 | */ |
jmitc91516 | 1:a5258871b33d | 15 | typedef struct structGasCalibrationEasyGUITouchAreaAndVariables { |
jmitc91516 | 1:a5258871b33d | 16 | int touchAreaIndex; |
jmitc91516 | 1:a5258871b33d | 17 | GuiConst_TEXT * easyGUIVariablePtr; |
jmitc91516 | 1:a5258871b33d | 18 | unsigned int maxValue; |
jmitc91516 | 1:a5258871b33d | 19 | GuiConst_INTCOLOR * easyGUIBackgroundColorVariablePtr; |
jmitc91516 | 1:a5258871b33d | 20 | char variableName[41]; |
jmitc91516 | 1:a5258871b33d | 21 | } GasCalibrationEasyGUITouchAreaAndVariables; |
jmitc91516 | 1:a5258871b33d | 22 | |
jmitc91516 | 1:a5258871b33d | 23 | |
jmitc91516 | 1:a5258871b33d | 24 | /* |
jmitc91516 | 1:a5258871b33d | 25 | This class handles user interaction with the easyGUI "GasCalibrationPage", |
jmitc91516 | 1:a5258871b33d | 26 | as well as storing the values in QSPI memory. |
jmitc91516 | 1:a5258871b33d | 27 | |
jmitc91516 | 1:a5258871b33d | 28 | 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 | 29 | (we do not want multiple values for the carrier gas selection, etc, and nor will we show |
jmitc91516 | 1:a5258871b33d | 30 | more than one easyGUI 'GasCalibrationPage' to the user at the same time). |
jmitc91516 | 1:a5258871b33d | 31 | */ |
jmitc91516 | 1:a5258871b33d | 32 | class GasCalibrationPageHandler { |
jmitc91516 | 1:a5258871b33d | 33 | public: |
jmitc91516 | 1:a5258871b33d | 34 | /** |
jmitc91516 | 1:a5258871b33d | 35 | * Static method to create (if necessary) and retrieve the single GasCalibrationPageHandler instance |
jmitc91516 | 1:a5258871b33d | 36 | */ |
jmitc91516 | 1:a5258871b33d | 37 | static GasCalibrationPageHandler * GetInstance(USBDeviceConnected* newUsbDevice, USBHostGC* newUsbHostGC); |
jmitc91516 | 1:a5258871b33d | 38 | |
jmitc91516 | 1:a5258871b33d | 39 | bool TouchAreaIsOnCalibrationPage(int touchAreaIndex); |
jmitc91516 | 1:a5258871b33d | 40 | |
jmitc91516 | 1:a5258871b33d | 41 | bool DealWithTouch(int touchAreaIndex); |
jmitc91516 | 1:a5258871b33d | 42 | |
jmitc91516 | 1:a5258871b33d | 43 | void DisplayingEasyGUIPage(bool updateEasyGUIVariables); |
jmitc91516 | 1:a5258871b33d | 44 | |
jmitc91516 | 1:a5258871b33d | 45 | private: |
jmitc91516 | 1:a5258871b33d | 46 | enum {CARRIER_GAS_HELIUM = 0, CARRIER_GAS_HYDROGEN = 1, CARRIER_GAS_NITROGEN = 2}; |
jmitc91516 | 1:a5258871b33d | 47 | |
jmitc91516 | 1:a5258871b33d | 48 | static GasCalibrationPageHandler * theGasCalibrationPageHandlerInstance; |
jmitc91516 | 1:a5258871b33d | 49 | |
jmitc91516 | 1:a5258871b33d | 50 | static const GuiConst_INTCOLOR inactiveFieldBackgroundColour; |
jmitc91516 | 1:a5258871b33d | 51 | static const GuiConst_INTCOLOR activeFieldBackgroundColour; |
jmitc91516 | 1:a5258871b33d | 52 | |
jmitc91516 | 1:a5258871b33d | 53 | USBDeviceConnected* usbDevice; |
jmitc91516 | 1:a5258871b33d | 54 | USBHostGC* usbHostGC; |
jmitc91516 | 1:a5258871b33d | 55 | |
jmitc91516 | 1:a5258871b33d | 56 | int indexOfValueCurrentlyBeingEdited; |
jmitc91516 | 1:a5258871b33d | 57 | |
jmitc91516 | 1:a5258871b33d | 58 | // singleton class -> constructor is private |
jmitc91516 | 1:a5258871b33d | 59 | GasCalibrationPageHandler(USBDeviceConnected* newUsbDevice, USBHostGC* newUsbHostGC); |
jmitc91516 | 1:a5258871b33d | 60 | ~GasCalibrationPageHandler(); |
jmitc91516 | 1:a5258871b33d | 61 | |
jmitc91516 | 1:a5258871b33d | 62 | void SaveCarrierGasSelectionToQSPISettings(void); |
jmitc91516 | 1:a5258871b33d | 63 | void ReadCarrierGasSelectionFromQSPISettings(void); |
jmitc91516 | 1:a5258871b33d | 64 | |
jmitc91516 | 1:a5258871b33d | 65 | void UpdateEasyGUIPage(void); |
jmitc91516 | 1:a5258871b33d | 66 | |
jmitc91516 | 1:a5258871b33d | 67 | void GetCurrentCalibrationFromGC(void); |
jmitc91516 | 1:a5258871b33d | 68 | void SetCurrentCalibrationInGC(void); |
jmitc91516 | 1:a5258871b33d | 69 | |
jmitc91516 | 1:a5258871b33d | 70 | bool GetCalibrationDACAndFlowValuesFromGC(int carrierGasSelection, int valueIndex, char *bufferForDACValue, char *bufferForFlowValue); |
jmitc91516 | 1:a5258871b33d | 71 | bool SetCalibrationDACAndFlowValuesInGC(int carrierGasSelection, int valueIndex, char *bufferForDACValue, char *bufferForFlowValue); |
jmitc91516 | 1:a5258871b33d | 72 | |
jmitc91516 | 1:a5258871b33d | 73 | bool ConstructGasCalibrationGCCommand(bool wantSetCommand, int carrierGasSelection, int valueIndex, bool wantDACCommand, char *commandBuffer); |
jmitc91516 | 1:a5258871b33d | 74 | void CopyBufferDigitsToCommand(char *commandBuffer, char *digitsBuffer); |
jmitc91516 | 1:a5258871b33d | 75 | |
jmitc91516 | 1:a5258871b33d | 76 | enum { COUNT_OF_VARIABLES_FOR_TOUCH_AREAS = 12 }; |
jmitc91516 | 1:a5258871b33d | 77 | GasCalibrationEasyGUITouchAreaAndVariables variablesForTouchArea[COUNT_OF_VARIABLES_FOR_TOUCH_AREAS]; |
jmitc91516 | 1:a5258871b33d | 78 | |
jmitc91516 | 1:a5258871b33d | 79 | void SetAllFieldBackgroundColoursToInactive(void); |
jmitc91516 | 1:a5258871b33d | 80 | |
jmitc91516 | 1:a5258871b33d | 81 | int GetIndexOfValueToEditForTouchArea(int touchAreaIndex); |
jmitc91516 | 1:a5258871b33d | 82 | |
jmitc91516 | 1:a5258871b33d | 83 | void CopyCommandResponseToBufferWithoutLeadingZeroes(char *commandResponse, char *buffer); |
jmitc91516 | 1:a5258871b33d | 84 | }; |
jmitc91516 | 1:a5258871b33d | 85 | |
jmitc91516 | 1:a5258871b33d | 86 | #endif // GASCALIBRATIONPAGEHANDLER_H |
jmitc91516 | 1:a5258871b33d | 87 |