Repository for import to local machine
Dependencies: DMBasicGUI DMSupport
Diff: main.cpp
- Revision:
- 2:6e94a7fd1e37
- Parent:
- 1:a5258871b33d
- Child:
- 3:010aeeacd7d7
--- a/main.cpp Thu Jul 20 08:42:29 2017 +0000 +++ b/main.cpp Thu Jul 20 15:31:28 2017 +0000 @@ -480,7 +480,7 @@ { #define USE_BITMAPS #ifdef USE_BITMAPS - GuiConst_INT8U bitmapIndex = GuiStruct_Bitmap_RunButton2; + GuiConst_INT8U bitmapIndex = GuiStruct_Bitmap_RunButtonBlank; if(enabled) { bitmapIndex = GuiStruct_Bitmap_RunButtonGreen; } @@ -626,100 +626,6 @@ #define USING_BACKGROUND_BITMAP -/* - Depending on the argument passed to it, this function either draws the specified text - on top of the Heat On button - i.e. at the bottom of the display, in the centre, - in the specified colour, or erases it. - - Args: boolean, true to display the text, false to erase it - pointer to the (null-terminated) text - the foregound (i.e. text) colour - the background colour - - No return code. -*/ -static void DrawTextOnHeatOnOffButton(bool drawIt, char* text, GuiConst_INTCOLOR foreColor, GuiConst_INTCOLOR backColor) -{ - if(drawIt) { - const GuiConst_INT16U fontNo = GuiFont_Helv20Bold; - - const GuiConst_INT16S X = 75; // Approx centre of button - const GuiConst_INT16S Y = 450; // 220 to put it on top of the Run button, 450 for the Heat On/Off button - - GuiLib_DrawStr( - X, //GuiConst_INT16S X, - Y, //GuiConst_INT16S Y, - fontNo, //GuiConst_INT16U FontNo, - text, //GuiConst_TEXT PrefixLocate *String, - GuiLib_ALIGN_CENTER, //GuiConst_INT8U Alignment, - GuiLib_PS_ON, //GuiConst_INT8U PsWriting, - GuiLib_TRANSPARENT_ON, //GuiConst_INT8U Transparent, - GuiLib_UNDERLINE_OFF, //GuiConst_INT8U Underlining, - 0, //GuiConst_INT16S BackBoxSizeX, - 0, //GuiConst_INT16S BackBoxSizeY1, - 0, //GuiConst_INT16S BackBoxSizeY2, - GuiLib_BBP_NONE, //GuiConst_INT8U BackBorderPixels, - foreColor, //GuiConst_INTCOLOR ForeColor, - backColor //GuiConst_INTCOLOR BackColor - ); - } else { - // TODO: Erase it somehow - } -} - - -/* - Depending on the argument passed to it,this function either draws the word "Stabilising" - at the bottom of the display, in the centre, in green, or erases it. - - Arg is: true to display the text, false to erase it - - No return code. -*/ -void DrawStabilisingMessage(bool stabilising) -{ - DrawTextOnHeatOnOffButton(stabilising, "Stabilising", SixteenBitColorValue(0, 0xFF, 0), SixteenBitColorValue(0, 0, 0)); -} - -/* - Depending on the argument passed to it,this function either draws the word "Equilibrating" - at the bottom of the display, in the centre, in amber, or erases it. - - Arg is: true to display the text, false to erase it - - No return code. -*/ -void DrawEquilibratingMessage(bool equilibrating) -{ - DrawTextOnHeatOnOffButton(equilibrating, "Equilibrating", SixteenBitColorValue(255, 255, 50), SixteenBitColorValue(0, 0, 0)); -} - -/* - Depending on the argument passed to it,this function either draws the word "Cooling" - at the bottom of the display, in the centre, in light blue, or erases it. - - Arg is: true to display the text, false to erase it - - No return code. -*/ -void DrawCoolingMessage(bool cooling) -{ - DrawTextOnHeatOnOffButton(cooling, "Cooling", SixteenBitColorValue(0, 243, 255), SixteenBitColorValue(0, 0, 0)); -} - -/* - Depending on the argument passed to it,this function either draws the word "Ready" - at the bottom of the display, in the centre, in green, or erases it. - - Arg is: true to display the text, false to erase it - - No return code. -*/ -void DrawReadyMessage(bool ready) -{ - DrawTextOnHeatOnOffButton(ready, "Ready", SixteenBitColorValue(0, 0xFF, 0), SixteenBitColorValue(0, 0, 0)); -} - /* Copies the build date (#define'd as BUILD_DATE at the top of this file) @@ -797,20 +703,10 @@ { // If required, query the GC to find out if it is ready to run, etc, *before* clearing the display - // otherwise the display remains clear while we talk to the GC - causes noticeable flickering - bool gcIsReadyToRun = false; - bool gcIsStabilising = false; - bool gcIsEquilibrating = false; - bool gcIsCooling = false; - bool gcIsRunning = false; + GCStateSimplified simplifiedGCState = GC_IDLE; if((structureIndex == GuiStruct_HomePage_1) && (usbDevice != NULL) && (usbHostGC != NULL)) { int gcStatus = GetGCStatus(usbDevice, usbHostGC); - GCStateSimplified simplifiedGCState = GCStateOrFaultCode::GetSimplifiedGCState(gcStatus); - - gcIsReadyToRun = (simplifiedGCState == GC_READY_TO_RUN); - gcIsStabilising = (simplifiedGCState == GC_STABILISING); - gcIsEquilibrating = (simplifiedGCState == GC_EQUILIBRATING); - gcIsCooling = (simplifiedGCState == GC_COOLING); - gcIsRunning = (simplifiedGCState == GC_RUNNING); + simplifiedGCState = GCStateOrFaultCode::GetSimplifiedGCState(gcStatus); } #define DEBUG_HERE @@ -996,32 +892,20 @@ // But draw the run button, if required, on top of the fixed part of the home page // Same for the Heat On/Off button, and the Stabilising or Equilibrating messages (again, if required) if(structureIndex == GuiStruct_HomePage_1) { - DrawRunButton(gcIsReadyToRun || gcIsRunning); +//#define ALWAYS_WANT_RUN_BUTTON +#ifdef ALWAYS_WANT_RUN_BUTTON + DrawRunButton((simplifiedGCState == GC_READY_TO_RUN) || (simplifiedGCState == GC_RUNNING)); +#else + if((simplifiedGCState == GC_READY_TO_RUN) || (simplifiedGCState == GC_RUNNING)) { + DrawRunButton(true); + } +#endif // ALWAYS_WANT_RUN_BUTTON + #ifdef USE_HEAT_ONOFF_BUTTON_BITMAPS DrawHeatOnOffButton(); #endif -#define USE_IF_HERE -#ifdef USE_IF_HERE - // Pointless always calling all four DrawxxxMessage functions - - // only one can be true - - if(gcIsStabilising) { - DrawStabilisingMessage(true); - } else if (gcIsEquilibrating) { - DrawEquilibratingMessage(true); - } else if (gcIsCooling) { - DrawCoolingMessage(true); - } else if (gcIsReadyToRun) { - DrawReadyMessage(true); - } -#undef USE_IF_HERE -#else - DrawStabilisingMessage(gcIsStabilising); - DrawEquilibratingMessage(gcIsEquilibrating); - DrawCoolingMessage(gcIsCooling); - DrawReadyMessage(gcIsReadyToRun); -#endif // USE_IF_HERE + GCStateOrFaultCode::DrawSimplifiedStateMessageOnHomePageRunButton(simplifiedGCState); } if(structureIndex == GuiStruct_InjectorTempProfilePage_25) { @@ -2350,6 +2234,11 @@ log->printf("Failed to initialize the display, got error %d\r\n", disperr); break; } + +#define TEST_BACKLIGHT +#ifdef TEST_BACKLIGHT + disp->backlight(100); +#endif // TEST_BACKLIGHT } while(false);