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 0:47c880c1463d 1 #include "mbed.h"
jmitc91516 0:47c880c1463d 2 #include "DMBoard.h"
jmitc91516 0:47c880c1463d 3
jmitc91516 0:47c880c1463d 4 #include "GCComponentStatusColorArea.h"
jmitc91516 0:47c880c1463d 5
jmitc91516 1:a5258871b33d 6 /*
jmitc91516 1:a5258871b33d 7 Translates a 'triplet' of 8-bit RGB values to a 16-bit (5 for red, 6 for green, 5 for blue) value
jmitc91516 1:a5258871b33d 8 suitable for use on the display.
jmitc91516 1:a5258871b33d 9
jmitc91516 1:a5258871b33d 10 Defined in main.cpp.
jmitc91516 1:a5258871b33d 11 */
jmitc91516 0:47c880c1463d 12 extern GuiConst_INTCOLOR SixteenBitColorValue(GuiConst_INT8U red, GuiConst_INT8U green, GuiConst_INT8U blue);
jmitc91516 0:47c880c1463d 13
jmitc91516 1:a5258871b33d 14
jmitc91516 1:a5258871b33d 15
jmitc91516 1:a5258871b33d 16
jmitc91516 1:a5258871b33d 17 // Default constructor
jmitc91516 0:47c880c1463d 18 GCComponentStatusColorArea::GCComponentStatusColorArea()
jmitc91516 0:47c880c1463d 19 {
jmitc91516 0:47c880c1463d 20 x = 0;
jmitc91516 0:47c880c1463d 21 y = 0;
jmitc91516 0:47c880c1463d 22 w = 0;
jmitc91516 0:47c880c1463d 23 h = 0;
jmitc91516 0:47c880c1463d 24
jmitc91516 0:47c880c1463d 25 componentStatus = COLD;
jmitc91516 1:a5258871b33d 26
jmitc91516 1:a5258871b33d 27 secondAreaDefined = false;
jmitc91516 0:47c880c1463d 28 }
jmitc91516 0:47c880c1463d 29
jmitc91516 1:a5258871b33d 30 // Constructor, passed the coordinates and size of the rectangle
jmitc91516 0:47c880c1463d 31 GCComponentStatusColorArea::GCComponentStatusColorArea(GuiConst_INT16S X, GuiConst_INT16S Y, GuiConst_INT16S W, GuiConst_INT16S H)
jmitc91516 0:47c880c1463d 32 {
jmitc91516 0:47c880c1463d 33 x = X;
jmitc91516 0:47c880c1463d 34 y = Y;
jmitc91516 0:47c880c1463d 35 w = W;
jmitc91516 0:47c880c1463d 36 h = H;
jmitc91516 0:47c880c1463d 37
jmitc91516 0:47c880c1463d 38 componentStatus = COLD;
jmitc91516 1:a5258871b33d 39
jmitc91516 1:a5258871b33d 40 secondAreaDefined = false;
jmitc91516 0:47c880c1463d 41 }
jmitc91516 0:47c880c1463d 42
jmitc91516 1:a5258871b33d 43 // Displays the rectangle in the correct colour for its status.
jmitc91516 1:a5258871b33d 44 // If we have a 'second area' rectangle, display that also
jmitc91516 0:47c880c1463d 45 void GCComponentStatusColorArea::DisplayComponentStatus(void)
jmitc91516 0:47c880c1463d 46 {
jmitc91516 1:a5258871b33d 47 GuiConst_INTCOLOR componentColor = GetColorForComponentStatus(componentStatus);
jmitc91516 1:a5258871b33d 48
jmitc91516 1:a5258871b33d 49 GuiLib_FillBox(x, y, (x + w), (y + h), componentColor);
jmitc91516 1:a5258871b33d 50
jmitc91516 1:a5258871b33d 51 if(secondAreaDefined) {
jmitc91516 1:a5258871b33d 52 GuiLib_FillBox(x2, y2, (x2 + w2), (y2 + h2), componentColor);
jmitc91516 1:a5258871b33d 53 }
jmitc91516 1:a5258871b33d 54
jmitc91516 1:a5258871b33d 55 #ifdef THREE_DIMENSIONAL
jmitc91516 1:a5258871b33d 56 int boxLeft = x;
jmitc91516 1:a5258871b33d 57 int boxTop = y;
jmitc91516 1:a5258871b33d 58 int boxRight = (x + w);
jmitc91516 1:a5258871b33d 59 int boxBottom = (y + h);
jmitc91516 1:a5258871b33d 60
jmitc91516 1:a5258871b33d 61 if(secondAreaDefined) {
jmitc91516 1:a5258871b33d 62 boxLeft = (boxLeft < x2) ? boxLeft : x2;
jmitc91516 1:a5258871b33d 63 boxTop = (boxTop < y2) ? boxTop : y2;
jmitc91516 1:a5258871b33d 64 boxRight = (boxRight > (x2 + w2)) ? boxRight : (x2 + w2);
jmitc91516 1:a5258871b33d 65 boxBottom = (boxBottom > (y2 + h2)) ? boxBottom : (y2 + h2);
jmitc91516 1:a5258871b33d 66 }
jmitc91516 1:a5258871b33d 67
jmitc91516 1:a5258871b33d 68 GuiConst_INTCOLOR topBevelColour = GetTopBevelColorForComponentStatus(componentStatus);
jmitc91516 1:a5258871b33d 69 GuiConst_INTCOLOR bottomBevelColour = GetBottomBevelColorForComponentStatus(componentStatus);
jmitc91516 1:a5258871b33d 70
jmitc91516 1:a5258871b33d 71 DisplayBevelledEdgesOnRectangle(boxLeft, boxTop, boxRight, boxBottom, topBevelColour, bottomBevelColour);
jmitc91516 1:a5258871b33d 72 #endif // THREE_DIMENSIONAL
jmitc91516 0:47c880c1463d 73 }
jmitc91516 0:47c880c1463d 74
jmitc91516 1:a5258871b33d 75 // Returns the colour corresponding to the component status passed to it
jmitc91516 0:47c880c1463d 76 GuiConst_INTCOLOR GCComponentStatusColorArea::GetColorForComponentStatus(GCComponentStatus status)
jmitc91516 0:47c880c1463d 77 {
jmitc91516 0:47c880c1463d 78 switch (status) {
jmitc91516 0:47c880c1463d 79 case COLD:
jmitc91516 1:a5258871b33d 80 #define INDUCE_FLICKERING
jmitc91516 1:a5258871b33d 81 #ifdef INDUCE_FLICKERING
jmitc91516 1:a5258871b33d 82 //return SixteenBitColorValue(0, 0, 0xFF); // Plain blue - too dark to read black text on top of this
jmitc91516 1:a5258871b33d 83 return SixteenBitColorValue(0, 0xB4, 0xFF); // light blue - ** flickers on LPC4088 display **
jmitc91516 1:a5258871b33d 84 //return SixteenBitColorValue(0, 0x70, 0xFF); // light blue, attempt #2 - ** still flickers **
jmitc91516 1:a5258871b33d 85 //return SixteenBitColorValue(0, 0x40, 0xFF); // light blue, attempt #3 - ** still flickers **
jmitc91516 1:a5258871b33d 86 //return SixteenBitColorValue(0, 0xFF, 0xFF); // cyan - does not flicker - but unacceptable
jmitc91516 1:a5258871b33d 87 //return SixteenBitColorValue(0, 0x04, 0xFF); // does *not* flicker with the lowest possible non-zero green value
jmitc91516 1:a5258871b33d 88 //return SixteenBitColorValue(0, 0x20, 0xFF); // binary chop - does *not* flicker
jmitc91516 1:a5258871b33d 89 //return SixteenBitColorValue(0, 0xC0, 0xFF); // binary chop between 0x80 and 0xFF - ** flickers **
jmitc91516 1:a5258871b33d 90 //return SixteenBitColorValue(0, 0x30, 0xFF); // another binary chop below 0x40 - does *not* flicker
jmitc91516 1:a5258871b33d 91 //return SixteenBitColorValue(0, 0x38, 0xFF); // next binary chop - may flicker very slightly
jmitc91516 1:a5258871b33d 92 //return SixteenBitColorValue(0, 0x3C, 0xFF); // next binary chop - may flicker very slightly
jmitc91516 1:a5258871b33d 93 //return SixteenBitColorValue(0, 0x30, 0xFF); // Still flickers - only slightly, but enough to be noticeable
jmitc91516 1:a5258871b33d 94 #undef INDUCE_FLICKERING
jmitc91516 1:a5258871b33d 95 #else
jmitc91516 1:a5258871b33d 96 return SixteenBitColorValue(0, 0, 0xFF); // Revert to plain blue for now
jmitc91516 1:a5258871b33d 97 #endif
jmitc91516 0:47c880c1463d 98 case HEATING_UP:
jmitc91516 1:a5258871b33d 99 //return SixteenBitColorValue(0xFF, 0xFF, 0); // amber
jmitc91516 1:a5258871b33d 100 return SixteenBitColorValue(247, 148, 33); // a better amber(?)
jmitc91516 0:47c880c1463d 101 case READY:
jmitc91516 0:47c880c1463d 102 return SixteenBitColorValue(0, 0xFF, 0); // green
jmitc91516 0:47c880c1463d 103 case FAULTED:
jmitc91516 0:47c880c1463d 104 return SixteenBitColorValue(0xFF, 0, 0); // red
jmitc91516 0:47c880c1463d 105 default:
jmitc91516 0:47c880c1463d 106 return 0; // black
jmitc91516 0:47c880c1463d 107 }
jmitc91516 0:47c880c1463d 108 }
jmitc91516 1:a5258871b33d 109
jmitc91516 1:a5258871b33d 110 #ifdef THREE_DIMENSIONAL
jmitc91516 1:a5258871b33d 111 // Returns a lighter version of the main colour
jmitc91516 1:a5258871b33d 112 GuiConst_INTCOLOR GCComponentStatusColorArea::GetTopBevelColorForComponentStatus(GCComponentStatus status)
jmitc91516 1:a5258871b33d 113 {
jmitc91516 1:a5258871b33d 114 switch (status) {
jmitc91516 1:a5258871b33d 115 case COLD:
jmitc91516 1:a5258871b33d 116 return SixteenBitColorValue(68, 237, 255);
jmitc91516 1:a5258871b33d 117 case HEATING_UP:
jmitc91516 1:a5258871b33d 118 return SixteenBitColorValue(255, 198, 104);
jmitc91516 1:a5258871b33d 119 case READY:
jmitc91516 1:a5258871b33d 120 return SixteenBitColorValue(128, 255, 128);
jmitc91516 1:a5258871b33d 121 case FAULTED:
jmitc91516 1:a5258871b33d 122 return SixteenBitColorValue(255, 106, 106);
jmitc91516 1:a5258871b33d 123 default:
jmitc91516 1:a5258871b33d 124 return 0; // black
jmitc91516 1:a5258871b33d 125 }
jmitc91516 1:a5258871b33d 126 }
jmitc91516 1:a5258871b33d 127
jmitc91516 1:a5258871b33d 128 // Returns a darker version of the main colour
jmitc91516 1:a5258871b33d 129 GuiConst_INTCOLOR GCComponentStatusColorArea::GetBottomBevelColorForComponentStatus(GCComponentStatus status)
jmitc91516 1:a5258871b33d 130 {
jmitc91516 1:a5258871b33d 131 switch (status) {
jmitc91516 1:a5258871b33d 132 case COLD:
jmitc91516 1:a5258871b33d 133 return SixteenBitColorValue(0, 126, 178);
jmitc91516 1:a5258871b33d 134 case HEATING_UP:
jmitc91516 1:a5258871b33d 135 return SixteenBitColorValue(178, 107, 24);
jmitc91516 1:a5258871b33d 136 case READY:
jmitc91516 1:a5258871b33d 137 return SixteenBitColorValue(0, 64, 0); // green
jmitc91516 1:a5258871b33d 138 case FAULTED:
jmitc91516 1:a5258871b33d 139 return SixteenBitColorValue(128, 0, 0); // red
jmitc91516 1:a5258871b33d 140 default:
jmitc91516 1:a5258871b33d 141 return 0; // black
jmitc91516 1:a5258871b33d 142 }
jmitc91516 1:a5258871b33d 143 }
jmitc91516 1:a5258871b33d 144
jmitc91516 1:a5258871b33d 145 /*
jmitc91516 1:a5258871b33d 146 Adds bevelled edges to the specified rectangle, to make it look three-dimensional.
jmitc91516 1:a5258871b33d 147
jmitc91516 1:a5258871b33d 148 Args: rectangle left, top, right and bottom coords
jmitc91516 1:a5258871b33d 149 top bevel colour
jmitc91516 1:a5258871b33d 150 bottom bevel colour
jmitc91516 1:a5258871b33d 151
jmitc91516 1:a5258871b33d 152 No return code
jmitc91516 1:a5258871b33d 153 */
jmitc91516 1:a5258871b33d 154 void GCComponentStatusColorArea::DisplayBevelledEdgesOnRectangle(GuiConst_INT16S rectangleLeft, GuiConst_INT16S rectangleTop,
jmitc91516 1:a5258871b33d 155 GuiConst_INT16S rectangleRight, GuiConst_INT16S rectangleBottom,
jmitc91516 1:a5258871b33d 156 GuiConst_INTCOLOR topBevelColour, GuiConst_INTCOLOR bottomBevelColour)
jmitc91516 1:a5258871b33d 157 {
jmitc91516 1:a5258871b33d 158 // 'top bevel' to top and left
jmitc91516 1:a5258871b33d 159 GuiLib_Line(rectangleLeft, rectangleTop, rectangleRight, rectangleTop, topBevelColour);
jmitc91516 1:a5258871b33d 160 GuiLib_Line(rectangleLeft + 1, rectangleTop + 1, rectangleRight - 1, rectangleTop + 1, topBevelColour);
jmitc91516 1:a5258871b33d 161 GuiLib_Line(rectangleLeft + 2, rectangleTop + 2, rectangleRight - 2, rectangleTop + 2, topBevelColour);
jmitc91516 1:a5258871b33d 162
jmitc91516 1:a5258871b33d 163 GuiLib_Line(rectangleLeft, rectangleTop, rectangleLeft, rectangleBottom, topBevelColour);
jmitc91516 1:a5258871b33d 164 GuiLib_Line(rectangleLeft + 1, rectangleTop + 1, rectangleLeft + 1, rectangleBottom - 1, topBevelColour);
jmitc91516 1:a5258871b33d 165 GuiLib_Line(rectangleLeft + 2, rectangleTop + 2, rectangleLeft + 2, rectangleBottom - 2, topBevelColour);
jmitc91516 1:a5258871b33d 166
jmitc91516 1:a5258871b33d 167
jmitc91516 1:a5258871b33d 168 // 'bottom bevel' to bottom and right
jmitc91516 1:a5258871b33d 169 GuiLib_Line(rectangleLeft, rectangleBottom, rectangleRight, rectangleBottom, bottomBevelColour);
jmitc91516 1:a5258871b33d 170 GuiLib_Line(rectangleLeft + 1, rectangleBottom - 1, rectangleRight - 1, rectangleBottom - 1, bottomBevelColour);
jmitc91516 1:a5258871b33d 171 GuiLib_Line(rectangleLeft + 2, rectangleBottom - 2, rectangleRight - 2, rectangleBottom - 2, bottomBevelColour);
jmitc91516 1:a5258871b33d 172
jmitc91516 1:a5258871b33d 173 GuiLib_Line(rectangleRight, rectangleTop, rectangleRight, rectangleBottom, bottomBevelColour);
jmitc91516 1:a5258871b33d 174 GuiLib_Line(rectangleRight - 1, rectangleTop + 1, rectangleRight - 1, rectangleBottom - 1, bottomBevelColour);
jmitc91516 1:a5258871b33d 175 GuiLib_Line(rectangleRight - 2, rectangleTop + 2, rectangleRight - 2, rectangleBottom - 2, bottomBevelColour);
jmitc91516 1:a5258871b33d 176 }
jmitc91516 1:a5258871b33d 177 #endif // THREE_DIMENSIONAL
jmitc91516 1:a5258871b33d 178
jmitc91516 1:a5258871b33d 179
jmitc91516 1:a5258871b33d 180 /*
jmitc91516 1:a5258871b33d 181 Displays an error rectangle with the same coords, width and height as a "single component" rectangle.
jmitc91516 1:a5258871b33d 182 Draws it "three dimensional" - i.e. with bevelled edges - if that is currently #define'd.
jmitc91516 1:a5258871b33d 183 The intention is that this will be displayed on the easyGUI "GC in fault state" page.
jmitc91516 1:a5258871b33d 184
jmitc91516 1:a5258871b33d 185 No arguments, no return value
jmitc91516 1:a5258871b33d 186 */
jmitc91516 1:a5258871b33d 187 void GCComponentStatusColorArea::DisplayErrorRectangle(void)
jmitc91516 1:a5258871b33d 188 {
jmitc91516 1:a5258871b33d 189 GuiConst_INT16S X = 10;
jmitc91516 1:a5258871b33d 190 GuiConst_INT16S Y = 10;
jmitc91516 1:a5258871b33d 191 GuiConst_INT16S W = 780;
jmitc91516 1:a5258871b33d 192 GuiConst_INT16S H = 384;
jmitc91516 1:a5258871b33d 193 GuiConst_INTCOLOR componentColor = GetColorForComponentStatus(FAULTED);
jmitc91516 1:a5258871b33d 194
jmitc91516 1:a5258871b33d 195 GuiLib_FillBox(X, Y, (X + W), (Y + H), componentColor);
jmitc91516 1:a5258871b33d 196
jmitc91516 1:a5258871b33d 197 #ifdef THREE_DIMENSIONAL
jmitc91516 1:a5258871b33d 198 int boxLeft = X;
jmitc91516 1:a5258871b33d 199 int boxTop = Y;
jmitc91516 1:a5258871b33d 200 int boxRight = (X + W);
jmitc91516 1:a5258871b33d 201 int boxBottom = (Y + H);
jmitc91516 1:a5258871b33d 202
jmitc91516 1:a5258871b33d 203 GuiConst_INTCOLOR topBevelColour = GetTopBevelColorForComponentStatus(FAULTED);
jmitc91516 1:a5258871b33d 204 GuiConst_INTCOLOR bottomBevelColour = GetBottomBevelColorForComponentStatus(FAULTED);
jmitc91516 1:a5258871b33d 205
jmitc91516 1:a5258871b33d 206 DisplayBevelledEdgesOnRectangle(boxLeft, boxTop, boxRight, boxBottom, topBevelColour, bottomBevelColour);
jmitc91516 1:a5258871b33d 207 #endif // THREE_DIMENSIONAL
jmitc91516 1:a5258871b33d 208 }
jmitc91516 0:47c880c1463d 209
jmitc91516 0:47c880c1463d 210
jmitc91516 1:a5258871b33d 211 GuiConst_INTCOLOR GCComponentStatusColorArea::GetCurrentColor(void)
jmitc91516 1:a5258871b33d 212 {
jmitc91516 1:a5258871b33d 213 return GetColorForComponentStatus(componentStatus);
jmitc91516 1:a5258871b33d 214 }
jmitc91516 0:47c880c1463d 215
jmitc91516 1:a5258871b33d 216 void GCComponentStatusColorArea::SetSecondArea(GuiConst_INT16S X2, GuiConst_INT16S Y2, GuiConst_INT16S W2, GuiConst_INT16S H2)
jmitc91516 1:a5258871b33d 217 {
jmitc91516 1:a5258871b33d 218 x2 = X2;
jmitc91516 1:a5258871b33d 219 y2 = Y2;
jmitc91516 1:a5258871b33d 220 w2 = W2;
jmitc91516 1:a5258871b33d 221 h2 = H2;
jmitc91516 1:a5258871b33d 222
jmitc91516 1:a5258871b33d 223 secondAreaDefined = true;
jmitc91516 1:a5258871b33d 224 }
jmitc91516 1:a5258871b33d 225
jmitc91516 1:a5258871b33d 226
jmitc91516 1:a5258871b33d 227
jmitc91516 1:a5258871b33d 228
jmitc91516 1:a5258871b33d 229 /*
jmitc91516 1:a5258871b33d 230 HomePageGCComponentStatusColorAreas class members.
jmitc91516 1:a5258871b33d 231
jmitc91516 1:a5258871b33d 232 The home page has separate areas for the Column (top left), Injector (top right),
jmitc91516 1:a5258871b33d 233 Detector (bottom left) and Gas (bottom right).
jmitc91516 1:a5258871b33d 234 */
jmitc91516 0:47c880c1463d 235 HomePageGCComponentStatusColorAreas::HomePageGCComponentStatusColorAreas()
jmitc91516 0:47c880c1463d 236 {
jmitc91516 1:a5258871b33d 237 #define USE_TWO_AREAS
jmitc91516 1:a5258871b33d 238 #ifdef USE_TWO_AREAS
jmitc91516 1:a5258871b33d 239 // Define two 'areas'/'boxes' for each component - avoid overlapping the Run button,
jmitc91516 1:a5258871b33d 240 // making it flash unnecessarily
jmitc91516 1:a5258871b33d 241 colorAreas[0] = new GCComponentStatusColorArea( 10, 10, 380, 159);
jmitc91516 1:a5258871b33d 242 // colorAreas[0]->SetSecondArea( 10, 170, 317, 25);
jmitc91516 1:a5258871b33d 243 colorAreas[0]->SetSecondArea( 10, 170, 325, 25);
jmitc91516 1:a5258871b33d 244
jmitc91516 1:a5258871b33d 245 colorAreas[1] = new GCComponentStatusColorArea(410, 10, 380, 159);
jmitc91516 1:a5258871b33d 246 // colorAreas[1]->SetSecondArea(470, 170, 320, 25);
jmitc91516 1:a5258871b33d 247 colorAreas[1]->SetSecondArea(465, 170, 325, 25);
jmitc91516 1:a5258871b33d 248
jmitc91516 1:a5258871b33d 249 colorAreas[2] = new GCComponentStatusColorArea( 10, 240, 380, 159);
jmitc91516 1:a5258871b33d 250 // colorAreas[2]->SetSecondArea( 10, 215, 317, 35);
jmitc91516 1:a5258871b33d 251 colorAreas[2]->SetSecondArea( 10, 215, 325, 35);
jmitc91516 1:a5258871b33d 252
jmitc91516 1:a5258871b33d 253 colorAreas[3] = new GCComponentStatusColorArea(410, 240, 380, 159);
jmitc91516 1:a5258871b33d 254 // colorAreas[3]->SetSecondArea(470, 215, 320, 35);
jmitc91516 1:a5258871b33d 255 colorAreas[3]->SetSecondArea(465, 215, 325, 35);
jmitc91516 1:a5258871b33d 256 #else
jmitc91516 1:a5258871b33d 257 colorAreas[0] = new GCComponentStatusColorArea( 10, 10, 380, 195);
jmitc91516 1:a5258871b33d 258 colorAreas[1] = new GCComponentStatusColorArea(410, 10, 380, 195);
jmitc91516 1:a5258871b33d 259 colorAreas[2] = new GCComponentStatusColorArea( 10, 225, 380, 195);
jmitc91516 1:a5258871b33d 260 colorAreas[3] = new GCComponentStatusColorArea(410, 225, 380, 195);
jmitc91516 1:a5258871b33d 261 #endif // USE_TWO_AREAS
jmitc91516 0:47c880c1463d 262 }
jmitc91516 0:47c880c1463d 263
jmitc91516 1:a5258871b33d 264 /*
jmitc91516 1:a5258871b33d 265 Gets the colour area for the specified component.
jmitc91516 1:a5258871b33d 266
jmitc91516 1:a5258871b33d 267 Args: the required component, as a value in the GCComponent enumeration (see GCComponentStatusEnums.h)
jmitc91516 1:a5258871b33d 268
jmitc91516 1:a5258871b33d 269 Returns a pointer to the relevant colour area, or NULL if not found.
jmitc91516 1:a5258871b33d 270 */
jmitc91516 0:47c880c1463d 271 GCComponentStatusColorArea* HomePageGCComponentStatusColorAreas::GetColorArea(GCComponent component)
jmitc91516 0:47c880c1463d 272 {
jmitc91516 0:47c880c1463d 273 switch (component) {
jmitc91516 0:47c880c1463d 274 case COLUMN:
jmitc91516 0:47c880c1463d 275 return colorAreas[0];
jmitc91516 0:47c880c1463d 276 case INJECTOR:
jmitc91516 0:47c880c1463d 277 return colorAreas[1];
jmitc91516 0:47c880c1463d 278 case DETECTOR:
jmitc91516 0:47c880c1463d 279 return colorAreas[2];
jmitc91516 0:47c880c1463d 280 case GAS:
jmitc91516 0:47c880c1463d 281 return colorAreas[3];
jmitc91516 0:47c880c1463d 282 default: // should never happen
jmitc91516 0:47c880c1463d 283 return NULL;
jmitc91516 0:47c880c1463d 284 }
jmitc91516 0:47c880c1463d 285 }
jmitc91516 0:47c880c1463d 286
jmitc91516 1:a5258871b33d 287 /*
jmitc91516 1:a5258871b33d 288 Sets the status of the specified component.
jmitc91516 1:a5258871b33d 289
jmitc91516 1:a5258871b33d 290 Args: the component in question (value in the GCComponent enumeration)
jmitc91516 1:a5258871b33d 291 its new status (value in the GCComponentStatus enumeration)
jmitc91516 1:a5258871b33d 292 [see GCComponentStatusEnums.h for these enumerations]
jmitc91516 1:a5258871b33d 293
jmitc91516 1:a5258871b33d 294 No return code.
jmitc91516 1:a5258871b33d 295 */
jmitc91516 0:47c880c1463d 296 void HomePageGCComponentStatusColorAreas::SetGCComponentStatus(GCComponent component, GCComponentStatus newStatus)
jmitc91516 0:47c880c1463d 297 {
jmitc91516 0:47c880c1463d 298 GCComponentStatusColorArea* colorArea = GetColorArea(component);
jmitc91516 0:47c880c1463d 299
jmitc91516 0:47c880c1463d 300 if(colorArea != NULL) {
jmitc91516 0:47c880c1463d 301 colorArea->SetComponentStatus(newStatus);
jmitc91516 0:47c880c1463d 302 }
jmitc91516 0:47c880c1463d 303 }
jmitc91516 0:47c880c1463d 304
jmitc91516 1:a5258871b33d 305 /*
jmitc91516 1:a5258871b33d 306 Gets the status of the specified component.
jmitc91516 1:a5258871b33d 307
jmitc91516 1:a5258871b33d 308 Args: the component in question (value in the GCComponent enumeration)
jmitc91516 1:a5258871b33d 309
jmitc91516 1:a5258871b33d 310 Returns the status of that component (value in the GCComponentStatus enumeration)
jmitc91516 1:a5258871b33d 311
jmitc91516 1:a5258871b33d 312 See GCComponentStatusEnums.h for the relevant enumerations.
jmitc91516 1:a5258871b33d 313 */
jmitc91516 1:a5258871b33d 314 GCComponentStatus HomePageGCComponentStatusColorAreas::GetGCComponentStatus(GCComponent component)
jmitc91516 1:a5258871b33d 315 {
jmitc91516 1:a5258871b33d 316 GCComponentStatusColorArea* colorArea = GetColorArea(component);
jmitc91516 1:a5258871b33d 317
jmitc91516 1:a5258871b33d 318 if(colorArea != NULL) {
jmitc91516 1:a5258871b33d 319 return colorArea->GetComponentStatus();
jmitc91516 1:a5258871b33d 320 }
jmitc91516 1:a5258871b33d 321
jmitc91516 1:a5258871b33d 322 return FAULTED; // Invalid component
jmitc91516 1:a5258871b33d 323 }
jmitc91516 1:a5258871b33d 324
jmitc91516 1:a5258871b33d 325 /*
jmitc91516 1:a5258871b33d 326 Displays the status areas of all the home page components.
jmitc91516 1:a5258871b33d 327
jmitc91516 1:a5258871b33d 328 No return value.
jmitc91516 1:a5258871b33d 329 */
jmitc91516 0:47c880c1463d 330 void HomePageGCComponentStatusColorAreas::DisplayAll(void)
jmitc91516 0:47c880c1463d 331 {
jmitc91516 0:47c880c1463d 332 for (int i = 0; i < HOME_PAGE_COLOR_AREAS_COUNT; ++i) {
jmitc91516 0:47c880c1463d 333 colorAreas[i]->DisplayComponentStatus();
jmitc91516 0:47c880c1463d 334 }
jmitc91516 0:47c880c1463d 335 }
jmitc91516 0:47c880c1463d 336
jmitc91516 1:a5258871b33d 337 /*
jmitc91516 1:a5258871b33d 338 Displays the status areas of the selected home page components.
jmitc91516 1:a5258871b33d 339
jmitc91516 1:a5258871b33d 340 Args: a bool for each home page colour area - true to display it, false if not
jmitc91516 1:a5258871b33d 341
jmitc91516 1:a5258871b33d 342 No return value.
jmitc91516 1:a5258871b33d 343 */
jmitc91516 1:a5258871b33d 344 void HomePageGCComponentStatusColorAreas::DisplayEach(bool displayColumnArea, bool displayInjectorArea, bool displayDetectorArea, bool displayGasArea)
jmitc91516 1:a5258871b33d 345 {
jmitc91516 1:a5258871b33d 346 if(displayColumnArea) {
jmitc91516 1:a5258871b33d 347 GetColorArea(COLUMN)->DisplayComponentStatus();
jmitc91516 1:a5258871b33d 348 }
jmitc91516 1:a5258871b33d 349
jmitc91516 1:a5258871b33d 350 if(displayInjectorArea) {
jmitc91516 1:a5258871b33d 351 GetColorArea(INJECTOR)->DisplayComponentStatus();
jmitc91516 1:a5258871b33d 352 }
jmitc91516 1:a5258871b33d 353
jmitc91516 1:a5258871b33d 354 if(displayDetectorArea) {
jmitc91516 1:a5258871b33d 355 GetColorArea(DETECTOR)->DisplayComponentStatus();
jmitc91516 1:a5258871b33d 356 }
jmitc91516 1:a5258871b33d 357
jmitc91516 1:a5258871b33d 358 if(displayGasArea) {
jmitc91516 1:a5258871b33d 359 GetColorArea(GAS)->DisplayComponentStatus();
jmitc91516 1:a5258871b33d 360 }
jmitc91516 1:a5258871b33d 361
jmitc91516 1:a5258871b33d 362 }
jmitc91516 0:47c880c1463d 363
jmitc91516 1:a5258871b33d 364 /*
jmitc91516 1:a5258871b33d 365 Returns the current colour of the specified component's status area
jmitc91516 1:a5258871b33d 366 */
jmitc91516 1:a5258871b33d 367 GuiConst_INTCOLOR HomePageGCComponentStatusColorAreas::GetComponentCurrentColor(GCComponent component)
jmitc91516 1:a5258871b33d 368 {
jmitc91516 1:a5258871b33d 369 GCComponentStatusColorArea* colorArea = GetColorArea(component);
jmitc91516 1:a5258871b33d 370
jmitc91516 1:a5258871b33d 371 if(colorArea != NULL) {
jmitc91516 1:a5258871b33d 372 return colorArea->GetCurrentColor();
jmitc91516 1:a5258871b33d 373 }
jmitc91516 1:a5258871b33d 374
jmitc91516 1:a5258871b33d 375 return 0; // Black if no such component
jmitc91516 1:a5258871b33d 376 }
jmitc91516 0:47c880c1463d 377
jmitc91516 1:a5258871b33d 378
jmitc91516 1:a5258871b33d 379 /*
jmitc91516 1:a5258871b33d 380 SingleGCComponentPageStatusColorAreas members.
jmitc91516 1:a5258871b33d 381
jmitc91516 1:a5258871b33d 382 This class contains the status rectangles for all easyGUI structures/pages
jmitc91516 1:a5258871b33d 383 that correspond to a single component.
jmitc91516 1:a5258871b33d 384 */
jmitc91516 1:a5258871b33d 385
jmitc91516 1:a5258871b33d 386 /*
jmitc91516 1:a5258871b33d 387 Constructor - each status rectangle needs to cover most of the page,
jmitc91516 1:a5258871b33d 388 apart from the status bar at the bottom.
jmitc91516 1:a5258871b33d 389 */
jmitc91516 0:47c880c1463d 390 SingleGCComponentPageStatusColorAreas::SingleGCComponentPageStatusColorAreas()
jmitc91516 0:47c880c1463d 391 {
jmitc91516 1:a5258871b33d 392 colorAreas[0] = new GCComponentStatusColorArea(10, 10, 780, 384);
jmitc91516 1:a5258871b33d 393 colorAreas[1] = new GCComponentStatusColorArea(10, 10, 780, 384);
jmitc91516 1:a5258871b33d 394 colorAreas[2] = new GCComponentStatusColorArea(10, 10, 780, 384);
jmitc91516 1:a5258871b33d 395 colorAreas[3] = new GCComponentStatusColorArea(10, 10, 780, 384);
jmitc91516 0:47c880c1463d 396 }
jmitc91516 0:47c880c1463d 397
jmitc91516 1:a5258871b33d 398 /*
jmitc91516 1:a5258871b33d 399 Gets the colour area for the specified component.
jmitc91516 1:a5258871b33d 400
jmitc91516 1:a5258871b33d 401 Args: the required component, as a value in the GCComponent enumeration (see GCComponentStatusEnums.h)
jmitc91516 1:a5258871b33d 402
jmitc91516 1:a5258871b33d 403 Returns a pointer to the relevant colour area, or NULL if not found.
jmitc91516 1:a5258871b33d 404 */
jmitc91516 0:47c880c1463d 405 GCComponentStatusColorArea* SingleGCComponentPageStatusColorAreas::GetColorArea(GCComponent component)
jmitc91516 0:47c880c1463d 406 {
jmitc91516 0:47c880c1463d 407 switch (component) {
jmitc91516 0:47c880c1463d 408 case COLUMN:
jmitc91516 0:47c880c1463d 409 return colorAreas[0];
jmitc91516 0:47c880c1463d 410 case INJECTOR:
jmitc91516 0:47c880c1463d 411 return colorAreas[1];
jmitc91516 0:47c880c1463d 412 case DETECTOR:
jmitc91516 0:47c880c1463d 413 return colorAreas[2];
jmitc91516 0:47c880c1463d 414 case GAS:
jmitc91516 0:47c880c1463d 415 return colorAreas[3];
jmitc91516 0:47c880c1463d 416 default: // should never happen
jmitc91516 0:47c880c1463d 417 return NULL;
jmitc91516 0:47c880c1463d 418 }
jmitc91516 0:47c880c1463d 419 }
jmitc91516 0:47c880c1463d 420
jmitc91516 1:a5258871b33d 421 /*
jmitc91516 1:a5258871b33d 422 Sets the status of the specified component.
jmitc91516 1:a5258871b33d 423
jmitc91516 1:a5258871b33d 424 Args: the component in question (value in the GCComponent enumeration)
jmitc91516 1:a5258871b33d 425 its new status (value in the GCComponentStatus enumeration)
jmitc91516 1:a5258871b33d 426 [see GCComponentStatusEnums.h for these enumerations]
jmitc91516 1:a5258871b33d 427
jmitc91516 1:a5258871b33d 428 No return code.
jmitc91516 1:a5258871b33d 429 */
jmitc91516 0:47c880c1463d 430 void SingleGCComponentPageStatusColorAreas::SetGCComponentStatus(GCComponent component, GCComponentStatus newStatus)
jmitc91516 0:47c880c1463d 431 {
jmitc91516 0:47c880c1463d 432 GCComponentStatusColorArea* colorArea = GetColorArea(component);
jmitc91516 0:47c880c1463d 433
jmitc91516 0:47c880c1463d 434 if(colorArea != NULL) {
jmitc91516 0:47c880c1463d 435 colorArea->SetComponentStatus(newStatus);
jmitc91516 0:47c880c1463d 436 }
jmitc91516 0:47c880c1463d 437 }
jmitc91516 0:47c880c1463d 438
jmitc91516 1:a5258871b33d 439 /*
jmitc91516 1:a5258871b33d 440 Gets the status of the specified component.
jmitc91516 1:a5258871b33d 441
jmitc91516 1:a5258871b33d 442 Args: the component in question (value in the GCComponent enumeration)
jmitc91516 1:a5258871b33d 443
jmitc91516 1:a5258871b33d 444 Returns the status of that component (value in the GCComponentStatus enumeration)
jmitc91516 1:a5258871b33d 445
jmitc91516 1:a5258871b33d 446 See GCComponentStatusEnums.h for the relevant enumerations.
jmitc91516 1:a5258871b33d 447 */
jmitc91516 1:a5258871b33d 448 GCComponentStatus SingleGCComponentPageStatusColorAreas::GetGCComponentStatus(GCComponent component)
jmitc91516 1:a5258871b33d 449 {
jmitc91516 1:a5258871b33d 450 GCComponentStatusColorArea* colorArea = GetColorArea(component);
jmitc91516 1:a5258871b33d 451
jmitc91516 1:a5258871b33d 452 if(colorArea != NULL) {
jmitc91516 1:a5258871b33d 453 return colorArea->GetComponentStatus();
jmitc91516 1:a5258871b33d 454 }
jmitc91516 1:a5258871b33d 455
jmitc91516 1:a5258871b33d 456 return FAULTED; // Invalid component
jmitc91516 1:a5258871b33d 457 }
jmitc91516 1:a5258871b33d 458 /*
jmitc91516 1:a5258871b33d 459 Display the status area of the specified component
jmitc91516 1:a5258871b33d 460
jmitc91516 1:a5258871b33d 461 Args: the component in question (value in the GCComponent enumeration)
jmitc91516 1:a5258871b33d 462 [see GCComponentStatusEnums.h for this enumeration]
jmitc91516 1:a5258871b33d 463
jmitc91516 1:a5258871b33d 464 No return code.
jmitc91516 1:a5258871b33d 465 */
jmitc91516 0:47c880c1463d 466 void SingleGCComponentPageStatusColorAreas::DisplayGCComponentStatus(GCComponent component)
jmitc91516 0:47c880c1463d 467 {
jmitc91516 0:47c880c1463d 468 GCComponentStatusColorArea* colorArea = GetColorArea(component);
jmitc91516 0:47c880c1463d 469
jmitc91516 0:47c880c1463d 470 if(colorArea != NULL) {
jmitc91516 0:47c880c1463d 471 colorArea->DisplayComponentStatus();
jmitc91516 0:47c880c1463d 472 }
jmitc91516 0:47c880c1463d 473 }
jmitc91516 0:47c880c1463d 474