John Mitchell / lpc4088_displaymodule_GC500_2_5inch

Dependencies:   DMBasicGUI DMSupport

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ColumnDHAutoCalibrationPageHandler.h Source File

ColumnDHAutoCalibrationPageHandler.h

00001 #ifndef COLUMNDHAUTOCALIBRATIONPAGEHANDLER_H
00002 #define COLUMNDHAUTOCALIBRATIONPAGEHANDLER_H
00003 
00004 #include "mbed.h"
00005 #include "DMBoard.h"
00006 
00007 #include "USBHostGC.h"
00008 
00009 #include "GuiLib.h"
00010 
00011 //#define USE_STABILISATION_TIMER // #define'd if we are using our own stabilisation timer - if not, we are getting the time from the GC
00012 
00013 #define USE_ENABLE_SET_BUTTON_FLAG // else - enable/disable based on current and previous calibration state
00014 
00015 // enum to make the different calibration state values (returned in response to the GC command "QDCS") more explicit
00016 typedef enum enumCalibrationState { IDLE = 0, STAGE_1 = 1, STAGE_1A = 2, STAGE_2 = 3, STAGE_3 = 4, INVALID = -1 } CalibrationState;
00017     
00018 /*
00019     This class handles user interaction with the easyGUI "ColumnDHAutoCalibrationPage",
00020     as well as storing the values in QSPI memory.
00021     
00022     Note that this class is a singleton - we do not need or want there to be more than one instance of it
00023     (we do not want multiple values for the calibration values, etc, and nor will we show 
00024     more than one easyGUI 'ColumnDHAutoCalibrationPage' to the user at the same time).
00025 */
00026 
00027 class ColumnDHAutoCalibrationPageHandler {
00028 public:
00029     /**
00030     * Static method to create (if necessary) and retrieve the single ColumnDHAutoCalibrationPageHandler instance
00031     */
00032     static ColumnDHAutoCalibrationPageHandler * GetInstance(USBDeviceConnected* newUsbDevice, USBHostGC* newUsbHostGC);
00033     
00034     /**
00035     * Version of the above that does not create the instance. Provided for callers that do not have 
00036     * the 'usbDevice' and 'usbHostGC' pointers, and that just want access to the instance
00037     */
00038     static ColumnDHAutoCalibrationPageHandler * GetInstance(void);
00039     
00040     bool TouchAreaIsOnCalibrationPage(int touchAreaIndex);
00041 
00042     bool DealWithTouch(int touchAreaIndex);
00043     
00044     void DisplayingEasyGUIPage(void);
00045 
00046     void UpdateVolatileEasyGUIVariables(void);
00047 
00048     bool CalibratingNow(void);
00049     
00050 private:    
00051     static ColumnDHAutoCalibrationPageHandler * theColumnDHAutoCalibrationPageHandlerInstance;
00052     
00053     static const char* notAvailable;
00054     
00055     USBDeviceConnected* usbDevice;
00056     USBHostGC* usbHostGC;
00057     
00058     // singleton class -> constructor is private
00059     ColumnDHAutoCalibrationPageHandler(USBDeviceConnected* newUsbDevice, USBHostGC* newUsbHostGC);    
00060     ~ColumnDHAutoCalibrationPageHandler();
00061     
00062     void UpdateEasyGUIPage(void);
00063 
00064     float calibTemperature[3];
00065     float calibResistance[3];
00066     int stabilisationTime;
00067     
00068     float actualColumnResistance;
00069     
00070     void SetEasyGUICalibrationPointTemperatureFromInternalValue(bool updateBoth);
00071     void SetEasyGUICalibrationPointResistanceFromInternalValue(void);
00072     void SetEasyGUIStabilisationTimeFromInternalValue(void);
00073             
00074     void ConstructStartCalibrationCommand(char* commandBuffer);
00075     void ConstructStopCalibrationCommand(char* commandBuffer);
00076     
00077     void SendCommandToGCAndGetResponse(char* command, char* response);
00078     bool SendCommandToGCWithDACKResponse(char *cmd);
00079     
00080     CalibrationState GetCalibrationState(void);
00081 
00082     void SetEasyGUICalibrationState(void);
00083     void SetEasyGUIHeatState(void);
00084     void SetEasyGUIOvenTemperature(void);
00085     void ShowSetCalibrationButtonEnabledState(void);
00086     
00087     void SetEasyGUICalibrationTimeRemaining(void);
00088 
00089     int GetStabilisationTimeFromGC(void);
00090     bool SetStabilisationTimeInGC(int value);
00091     
00092     float GetColumnTemperaturePointFromGC(int pointIndex);
00093     float GetColumnResistancePointFromGC(int pointIndex);
00094     
00095     void SetColumnTemperaturePointInGC(int pointIndex, float temperatureToSet);
00096     void SetColumnResistancePointInGC(int pointIndex, float resistanceToSet);
00097     
00098     bool TellGCToMeasureColumnResistance(void);
00099     
00100     float GetActualColumnResistanceFromGC(void);
00101     
00102     float GetCurrentOvenTemperature(void);
00103     
00104     void DisplayGettingColumnResistancePage(void);
00105     void RedisplayColumnCalibrationPage();
00106 
00107     CalibrationState currentCalibrationState;
00108     CalibrationState previousCalibrationState;
00109 
00110     bool needToGetColumnResistance;
00111     
00112 #ifdef USE_STABILISATION_TIMER
00113     Timer stabilisationTimer;
00114 #else
00115     float GetTimeFromGC(void);
00116     float gcTimeStabilisationStarted;
00117 #endif
00118 
00119 #ifdef USE_ENABLE_SET_BUTTON_FLAG 
00120     bool enableSetButton;
00121 #endif
00122 };
00123 
00124 #endif // COLUMNDHAUTOCALIBRATIONPAGEHANDLER_H