Repository for import to local machine

Dependencies:   DMBasicGUI DMSupport

Committer:
jmitc91516
Date:
Mon Jul 31 15:37:57 2017 +0000
Revision:
8:26e49e6955bd
Parent:
7:f0e645cf73a2
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 "QSPIBitmap.h"
jmitc91516 1:a5258871b33d 2
jmitc91516 1:a5258871b33d 3 #include <stdio.h>
jmitc91516 1:a5258871b33d 4 #include <string.h>
jmitc91516 1:a5258871b33d 5
jmitc91516 1:a5258871b33d 6 #include <fstream>
jmitc91516 1:a5258871b33d 7
jmitc91516 1:a5258871b33d 8
jmitc91516 1:a5258871b33d 9 // These are in main.cpp
jmitc91516 1:a5258871b33d 10 extern void DebugPrint(char *stuffToPrint, GuiConst_INT16S X, GuiConst_INT16S Y);
jmitc91516 1:a5258871b33d 11 extern bool qspiAlreadyFormatted;
jmitc91516 3:010aeeacd7d7 12 extern GuiConst_INTCOLOR SixteenBitColorValue(GuiConst_INT8U red, GuiConst_INT8U green, GuiConst_INT8U blue);
jmitc91516 1:a5258871b33d 13
jmitc91516 1:a5258871b33d 14 // QSPI utility function (for debugging)
jmitc91516 1:a5258871b33d 15 void DisplayQSPIDirectory(GuiConst_INT16S X, GuiConst_INT16S Y)
jmitc91516 1:a5258871b33d 16 {
jmitc91516 1:a5258871b33d 17 DIR *dp;
jmitc91516 1:a5258871b33d 18 dp = opendir("/qspi/");
jmitc91516 1:a5258871b33d 19
jmitc91516 1:a5258871b33d 20 if(dp != NULL) {
jmitc91516 1:a5258871b33d 21 struct dirent *dirp;
jmitc91516 1:a5258871b33d 22
jmitc91516 1:a5258871b33d 23 DebugPrint("Start of QSPI directory", X, Y);
jmitc91516 1:a5258871b33d 24 Y += 30;
jmitc91516 1:a5258871b33d 25
jmitc91516 1:a5258871b33d 26 while((dirp = readdir(dp)) != NULL) {
jmitc91516 1:a5258871b33d 27 DebugPrint(dirp->d_name, X, Y);
jmitc91516 1:a5258871b33d 28 Y += 30;
jmitc91516 1:a5258871b33d 29 }
jmitc91516 1:a5258871b33d 30 closedir(dp);
jmitc91516 1:a5258871b33d 31
jmitc91516 1:a5258871b33d 32 DebugPrint("End of QSPI directory", X, Y);
jmitc91516 1:a5258871b33d 33 } else {
jmitc91516 1:a5258871b33d 34 DebugPrint("Failed to open QSPI directory", X, Y);
jmitc91516 1:a5258871b33d 35 }
jmitc91516 1:a5258871b33d 36 }
jmitc91516 1:a5258871b33d 37 // End of QSPI utility functions
jmitc91516 1:a5258871b33d 38
jmitc91516 1:a5258871b33d 39
jmitc91516 1:a5258871b33d 40 // The default constructor exists purely to satisfy the compiler - it is not intended to be used
jmitc91516 1:a5258871b33d 41 QSPIBitmap::QSPIBitmap()
jmitc91516 1:a5258871b33d 42 {
jmitc91516 1:a5258871b33d 43 name[0] = '\0';
jmitc91516 1:a5258871b33d 44
jmitc91516 1:a5258871b33d 45 size = 0;
jmitc91516 1:a5258871b33d 46 debugVar1 = 0;
jmitc91516 1:a5258871b33d 47
jmitc91516 1:a5258871b33d 48 //data = NULL;
jmitc91516 1:a5258871b33d 49
jmitc91516 1:a5258871b33d 50 bitmapLoaded = false;
jmitc91516 1:a5258871b33d 51 }
jmitc91516 1:a5258871b33d 52
jmitc91516 1:a5258871b33d 53 QSPIBitmap::QSPIBitmap(char* bitmapName)
jmitc91516 1:a5258871b33d 54 {
jmitc91516 1:a5258871b33d 55 strcpy(name, bitmapName);
jmitc91516 1:a5258871b33d 56
jmitc91516 1:a5258871b33d 57 // Set these when we read the bitmap from the QSPI drive
jmitc91516 1:a5258871b33d 58 size = 0;
jmitc91516 1:a5258871b33d 59 debugVar1 = 0;
jmitc91516 1:a5258871b33d 60 data = NULL;
jmitc91516 1:a5258871b33d 61
jmitc91516 1:a5258871b33d 62 bitmapLoaded = GetBitmapFromQSPIDrive();
jmitc91516 1:a5258871b33d 63 }
jmitc91516 1:a5258871b33d 64
jmitc91516 1:a5258871b33d 65 QSPIBitmap::~QSPIBitmap()
jmitc91516 1:a5258871b33d 66 {
jmitc91516 1:a5258871b33d 67 if(data) {
jmitc91516 1:a5258871b33d 68 delete [] data;
jmitc91516 1:a5258871b33d 69 }
jmitc91516 1:a5258871b33d 70 }
jmitc91516 1:a5258871b33d 71
jmitc91516 1:a5258871b33d 72 bool QSPIBitmap::ReadBitmapSizeFile(void)
jmitc91516 1:a5258871b33d 73 {
jmitc91516 1:a5258871b33d 74 char bitmapSizeFilename[200];
jmitc91516 1:a5258871b33d 75 sprintf(bitmapSizeFilename, "/qspi/%s_BMP.size", name);
jmitc91516 1:a5258871b33d 76
jmitc91516 1:a5258871b33d 77 char buff[50];
jmitc91516 1:a5258871b33d 78
jmitc91516 1:a5258871b33d 79 FILE *fpsize = fopen(bitmapSizeFilename, "r");
jmitc91516 1:a5258871b33d 80 if (fpsize != NULL) {
jmitc91516 8:26e49e6955bd 81 // We allow the size value to be up to 20 digits
jmitc91516 8:26e49e6955bd 82 int numRead = fread(buff, 1, 20, fpsize);
jmitc91516 1:a5258871b33d 83 fclose(fpsize);
jmitc91516 1:a5258871b33d 84
jmitc91516 8:26e49e6955bd 85 buff[numRead] = '\0';
jmitc91516 1:a5258871b33d 86
jmitc91516 1:a5258871b33d 87 sscanf(buff, "%d", &size);
jmitc91516 1:a5258871b33d 88
jmitc91516 1:a5258871b33d 89 return true;
jmitc91516 1:a5258871b33d 90 }
jmitc91516 1:a5258871b33d 91
jmitc91516 1:a5258871b33d 92 // 'else'...
jmitc91516 1:a5258871b33d 93
jmitc91516 1:a5258871b33d 94 return false;
jmitc91516 1:a5258871b33d 95 }
jmitc91516 1:a5258871b33d 96
jmitc91516 1:a5258871b33d 97 bool QSPIBitmap::ReadBitmapDataFile(void)
jmitc91516 1:a5258871b33d 98 {
jmitc91516 1:a5258871b33d 99 char bitmapDataFilename[200];
jmitc91516 1:a5258871b33d 100 sprintf(bitmapDataFilename, "/qspi/%s_BMP.data", name);
jmitc91516 1:a5258871b33d 101
jmitc91516 1:a5258871b33d 102 FILE *fpdata = fopen(bitmapDataFilename, "rb");
jmitc91516 1:a5258871b33d 103 if (fpdata != NULL) {
jmitc91516 1:a5258871b33d 104 fread(data, size, 1, fpdata);
jmitc91516 1:a5258871b33d 105 fclose(fpdata);
jmitc91516 1:a5258871b33d 106
jmitc91516 1:a5258871b33d 107 return true;
jmitc91516 1:a5258871b33d 108 }
jmitc91516 1:a5258871b33d 109
jmitc91516 1:a5258871b33d 110 // 'else'...
jmitc91516 1:a5258871b33d 111
jmitc91516 1:a5258871b33d 112 return false;
jmitc91516 1:a5258871b33d 113 }
jmitc91516 1:a5258871b33d 114
jmitc91516 1:a5258871b33d 115 bool QSPIBitmap::GetBitmapFromQSPIDrive(void)
jmitc91516 1:a5258871b33d 116 {
jmitc91516 1:a5258871b33d 117 //TODO: Raise exceptions(?) if any of the below fails
jmitc91516 1:a5258871b33d 118
jmitc91516 1:a5258871b33d 119 debugVar1 = 1;
jmitc91516 1:a5258871b33d 120
jmitc91516 1:a5258871b33d 121 if(ReadBitmapSizeFile()) {
jmitc91516 1:a5258871b33d 122 debugVar1 = 3;
jmitc91516 1:a5258871b33d 123 } else {
jmitc91516 1:a5258871b33d 124 debugVar1 = 2;
jmitc91516 1:a5258871b33d 125 return false;
jmitc91516 1:a5258871b33d 126 }
jmitc91516 1:a5258871b33d 127
jmitc91516 1:a5258871b33d 128 debugVar1 = 4;
jmitc91516 1:a5258871b33d 129
jmitc91516 1:a5258871b33d 130 // Do not throw an exception if the allocation fails - just leave 'data' set to NULL
jmitc91516 1:a5258871b33d 131 data = new (nothrow) GuiConst_INT8U[size + 10]; // Leave a small margin 'just in case'
jmitc91516 1:a5258871b33d 132 // TEST - what if the 'new' fails??
jmitc91516 1:a5258871b33d 133 // Answer - looks same as what Andrew saw at PittCon 2017
jmitc91516 1:a5258871b33d 134
jmitc91516 1:a5258871b33d 135 if(data == NULL) {
jmitc91516 1:a5258871b33d 136 return false;
jmitc91516 1:a5258871b33d 137 }
jmitc91516 1:a5258871b33d 138
jmitc91516 1:a5258871b33d 139 if(ReadBitmapDataFile()) {
jmitc91516 1:a5258871b33d 140 debugVar1 = 5;
jmitc91516 1:a5258871b33d 141 } else {
jmitc91516 1:a5258871b33d 142 debugVar1 = 6;
jmitc91516 1:a5258871b33d 143 return false;
jmitc91516 1:a5258871b33d 144 }
jmitc91516 1:a5258871b33d 145
jmitc91516 1:a5258871b33d 146 debugVar1 = 7;
jmitc91516 1:a5258871b33d 147
jmitc91516 1:a5258871b33d 148 return true;
jmitc91516 1:a5258871b33d 149 }
jmitc91516 1:a5258871b33d 150
jmitc91516 8:26e49e6955bd 151 void QSPIBitmap::ShowAt(GuiConst_INT16S X, GuiConst_INT16S Y, GuiConst_INT32S transparentColour)
jmitc91516 1:a5258871b33d 152 {
jmitc91516 1:a5258871b33d 153 if(bitmapLoaded) {
jmitc91516 3:010aeeacd7d7 154 GuiLib_ShowBitmapAt(data, X, Y, transparentColour);
jmitc91516 1:a5258871b33d 155 } else {
jmitc91516 1:a5258871b33d 156 char buff[100];
jmitc91516 1:a5258871b33d 157 sprintf(buff, "Bitmap not loaded - size %d, debugVar1: %d", size, debugVar1);
jmitc91516 1:a5258871b33d 158 DebugPrint(buff, X, Y);
jmitc91516 1:a5258871b33d 159
jmitc91516 1:a5258871b33d 160 char bitmapSizeFilename[200];
jmitc91516 1:a5258871b33d 161 sprintf(bitmapSizeFilename, "/qspi/%s_BMP.size", name);
jmitc91516 1:a5258871b33d 162 DebugPrint(bitmapSizeFilename, X, Y+40);
jmitc91516 1:a5258871b33d 163 }
jmitc91516 1:a5258871b33d 164 }
jmitc91516 1:a5258871b33d 165
jmitc91516 8:26e49e6955bd 166 void QSPIBitmap::ShowAreaAt(GuiConst_INT16S X, GuiConst_INT16S Y, GuiConst_INT16S AX1, GuiConst_INT16S AY1, GuiConst_INT16S AX2, GuiConst_INT16S AY2, GuiConst_INT32S transparentColour)
jmitc91516 8:26e49e6955bd 167 {
jmitc91516 8:26e49e6955bd 168 if(bitmapLoaded) {
jmitc91516 8:26e49e6955bd 169 GuiLib_ShowBitmapAreaAt(data, X, Y, AX1, AY1, AX2, AY2, transparentColour);
jmitc91516 8:26e49e6955bd 170 } else {
jmitc91516 8:26e49e6955bd 171 char buff[100];
jmitc91516 8:26e49e6955bd 172 sprintf(buff, "Bitmap not loaded - size %d, debugVar1: %d", size, debugVar1);
jmitc91516 8:26e49e6955bd 173 DebugPrint(buff, X, Y);
jmitc91516 8:26e49e6955bd 174
jmitc91516 8:26e49e6955bd 175 char bitmapSizeFilename[200];
jmitc91516 8:26e49e6955bd 176 sprintf(bitmapSizeFilename, "/qspi/%s_BMP.size", name);
jmitc91516 8:26e49e6955bd 177 DebugPrint(bitmapSizeFilename, X, Y+40);
jmitc91516 8:26e49e6955bd 178 }
jmitc91516 8:26e49e6955bd 179 }
jmitc91516 1:a5258871b33d 180
jmitc91516 1:a5258871b33d 181 // QSPIBitmaps class members
jmitc91516 1:a5258871b33d 182 QSPIBitmaps::QSPIBitmaps()
jmitc91516 1:a5258871b33d 183 {
jmitc91516 1:a5258871b33d 184 qspibmArray[HOME_COLUMN_BITMAP] = NULL;
jmitc91516 1:a5258871b33d 185 qspibmArray[HOME_DETECTOR_BITMAP] = NULL;
jmitc91516 1:a5258871b33d 186 qspibmArray[HOME_INJECTOR_BITMAP] = NULL;
jmitc91516 1:a5258871b33d 187 qspibmArray[HOME_GAS_BITMAP] = NULL;
jmitc91516 1:a5258871b33d 188
jmitc91516 1:a5258871b33d 189 qspibmArray[COMPONENT_COLUMN_BITMAP] = NULL;
jmitc91516 1:a5258871b33d 190 qspibmArray[COMPONENT_DETECTOR_BITMAP] = NULL;
jmitc91516 1:a5258871b33d 191 qspibmArray[COMPONENT_INJECTOR_BITMAP] = NULL;
jmitc91516 1:a5258871b33d 192 qspibmArray[COMPONENT_GAS_BITMAP] = NULL;
jmitc91516 1:a5258871b33d 193
jmitc91516 8:26e49e6955bd 194 qspibmArray[BOOT_SCREEN_BITMAP] = NULL;
jmitc91516 8:26e49e6955bd 195 qspibmArray[BLANK_BACKGROUND_BITMAP] = NULL;
jmitc91516 8:26e49e6955bd 196 qspibmArray[UP_ARROW_BITMAP] = NULL;
jmitc91516 8:26e49e6955bd 197 qspibmArray[DOWN_ARROW_BITMAP] = NULL;
jmitc91516 8:26e49e6955bd 198
jmitc91516 1:a5258871b33d 199 arraySetUp = false;
jmitc91516 1:a5258871b33d 200 }
jmitc91516 1:a5258871b33d 201
jmitc91516 1:a5258871b33d 202 /*
jmitc91516 1:a5258871b33d 203 Sets up each of the bitmaps in the array, by reading the corresponding files
jmitc91516 1:a5258871b33d 204 from the QSPI (memory) file system.
jmitc91516 1:a5258871b33d 205
jmitc91516 1:a5258871b33d 206 *** Note that this is currently loading bitmaps specific to the Home page ***
jmitc91516 1:a5258871b33d 207
jmitc91516 1:a5258871b33d 208 Returns true if all loaded successfully, false if not
jmitc91516 1:a5258871b33d 209 */
jmitc91516 1:a5258871b33d 210 void QSPIBitmaps::SetupArray(void)
jmitc91516 1:a5258871b33d 211 {
jmitc91516 1:a5258871b33d 212 if(!arraySetUp) {
jmitc91516 1:a5258871b33d 213
jmitc91516 1:a5258871b33d 214 // Bitmap names manually copied from GuiStruct.c, and hard-coded here.
jmitc91516 1:a5258871b33d 215 // Must match those in the GC500_2_5inch_bitmap_loader.
jmitc91516 1:a5258871b33d 216
jmitc91516 1:a5258871b33d 217 qspibmArray[HOME_COLUMN_BITMAP] = new QSPIBitmap("GuiStruct_Bitmap_ColumnButton");
jmitc91516 1:a5258871b33d 218 qspibmArray[HOME_DETECTOR_BITMAP] = new QSPIBitmap("GuiStruct_Bitmap_DetectorButton");
jmitc91516 1:a5258871b33d 219 qspibmArray[HOME_INJECTOR_BITMAP] = new QSPIBitmap("GuiStruct_Bitmap_InjectorButton");
jmitc91516 1:a5258871b33d 220 qspibmArray[HOME_GAS_BITMAP] = new QSPIBitmap("GuiStruct_Bitmap_GasButton");
jmitc91516 1:a5258871b33d 221
jmitc91516 1:a5258871b33d 222 qspibmArray[COMPONENT_COLUMN_BITMAP] = new QSPIBitmap("GuiStruct_Bitmap_Column");
jmitc91516 1:a5258871b33d 223 qspibmArray[COMPONENT_DETECTOR_BITMAP] = new QSPIBitmap("GuiStruct_Bitmap_Detector");
jmitc91516 1:a5258871b33d 224 qspibmArray[COMPONENT_INJECTOR_BITMAP] = new QSPIBitmap("GuiStruct_Bitmap_Injector");
jmitc91516 1:a5258871b33d 225 qspibmArray[COMPONENT_GAS_BITMAP] = new QSPIBitmap("GuiStruct_Bitmap_Gas");
jmitc91516 1:a5258871b33d 226
jmitc91516 8:26e49e6955bd 227 qspibmArray[BOOT_SCREEN_BITMAP] = new QSPIBitmap("GuiStruct_Bitmap_BootScreen");
jmitc91516 8:26e49e6955bd 228 qspibmArray[BLANK_BACKGROUND_BITMAP] = new QSPIBitmap("GuiStruct_Bitmap_BlankBackground");
jmitc91516 8:26e49e6955bd 229
jmitc91516 8:26e49e6955bd 230 qspibmArray[UP_ARROW_BITMAP] = new QSPIBitmap("GuiStruct_Bitmap_UpArrow1point5");
jmitc91516 8:26e49e6955bd 231 qspibmArray[DOWN_ARROW_BITMAP] = new QSPIBitmap("GuiStruct_Bitmap_DownArrow1point5");
jmitc91516 8:26e49e6955bd 232
jmitc91516 1:a5258871b33d 233 arraySetUp = true;
jmitc91516 1:a5258871b33d 234 }
jmitc91516 1:a5258871b33d 235 }
jmitc91516 1:a5258871b33d 236
jmitc91516 1:a5258871b33d 237
jmitc91516 3:010aeeacd7d7 238 void QSPIBitmaps::DisplayBitmapAtIfLoaded(int bitmapIndex, GuiConst_INT16S X, GuiConst_INT16S Y, GuiConst_INT32S transparentColour)
jmitc91516 1:a5258871b33d 239 {
jmitc91516 1:a5258871b33d 240 if(qspibmArray[bitmapIndex] != NULL) {
jmitc91516 8:26e49e6955bd 241 qspibmArray[bitmapIndex]->ShowAt(X, Y, transparentColour);
jmitc91516 1:a5258871b33d 242 }
jmitc91516 1:a5258871b33d 243 }
jmitc91516 1:a5258871b33d 244
jmitc91516 1:a5258871b33d 245 void QSPIBitmaps::DisplayAllHomePageBitmaps(void)
jmitc91516 1:a5258871b33d 246 {
jmitc91516 3:010aeeacd7d7 247 // Home page component bitmaps have white corners - make them transparent
jmitc91516 7:f0e645cf73a2 248 DisplayBitmapAtIfLoaded(HOME_INJECTOR_BITMAP, 10, 10, 0xFFFF);
jmitc91516 3:010aeeacd7d7 249 DisplayBitmapAtIfLoaded(HOME_DETECTOR_BITMAP, 410, 10, 0xFFFF);
jmitc91516 7:f0e645cf73a2 250 DisplayBitmapAtIfLoaded(HOME_COLUMN_BITMAP, 10, 215, 0xFFFF);
jmitc91516 3:010aeeacd7d7 251 DisplayBitmapAtIfLoaded(HOME_GAS_BITMAP, 410, 215, 0xFFFF);
jmitc91516 1:a5258871b33d 252
jmitc91516 1:a5258871b33d 253 //DEBUG
jmitc91516 1:a5258871b33d 254 if(qspiAlreadyFormatted) {
jmitc91516 1:a5258871b33d 255 DebugPrint("QSPI formatted at start", 200, 100);
jmitc91516 1:a5258871b33d 256 } else {
jmitc91516 1:a5258871b33d 257 DebugPrint("QSPI *not* formatted at start", 200, 100);
jmitc91516 1:a5258871b33d 258 }
jmitc91516 1:a5258871b33d 259
jmitc91516 1:a5258871b33d 260 }
jmitc91516 1:a5258871b33d 261
jmitc91516 1:a5258871b33d 262 void QSPIBitmaps::DisplayColumnComponentBitmap(void)
jmitc91516 1:a5258871b33d 263 {
jmitc91516 3:010aeeacd7d7 264 // RGB(231,231,231) is the colour of the corners of the component bitmaps -
jmitc91516 3:010aeeacd7d7 265 // make them transparent
jmitc91516 3:010aeeacd7d7 266 //DisplayBitmapAtIfLoaded(COMPONENT_COLUMN_BITMAP, 85, 230, SixteenBitColorValue(231, 231, 231)); // Bottom left, next to left arrow
jmitc91516 3:010aeeacd7d7 267 DisplayBitmapAtIfLoaded(COMPONENT_COLUMN_BITMAP, 609, 19, SixteenBitColorValue(231, 231, 231)); // Top right, like the others
jmitc91516 1:a5258871b33d 268 }
jmitc91516 1:a5258871b33d 269
jmitc91516 1:a5258871b33d 270 void QSPIBitmaps::DisplayDetectorComponentBitmap(void)
jmitc91516 1:a5258871b33d 271 {
jmitc91516 3:010aeeacd7d7 272 // RGB(231,231,231) is the colour of the corners of the component bitmaps -
jmitc91516 3:010aeeacd7d7 273 // make them transparent
jmitc91516 3:010aeeacd7d7 274 DisplayBitmapAtIfLoaded(COMPONENT_DETECTOR_BITMAP, 609, 19, SixteenBitColorValue(231, 231, 231));
jmitc91516 1:a5258871b33d 275 }
jmitc91516 1:a5258871b33d 276
jmitc91516 1:a5258871b33d 277 void QSPIBitmaps::DisplayInjectorComponentBitmap(void)
jmitc91516 1:a5258871b33d 278 {
jmitc91516 3:010aeeacd7d7 279 // RGB(231,231,231) is the colour of the corners of the component bitmaps -
jmitc91516 3:010aeeacd7d7 280 // make them transparent
jmitc91516 3:010aeeacd7d7 281 DisplayBitmapAtIfLoaded(COMPONENT_INJECTOR_BITMAP, 609, 19, SixteenBitColorValue(231, 231, 231));
jmitc91516 1:a5258871b33d 282 }
jmitc91516 1:a5258871b33d 283
jmitc91516 1:a5258871b33d 284 void QSPIBitmaps::DisplayGasComponentBitmap(void)
jmitc91516 1:a5258871b33d 285 {
jmitc91516 3:010aeeacd7d7 286 // RGB(231,231,231) is the colour of the corners of the component bitmaps -
jmitc91516 3:010aeeacd7d7 287 // make them transparent
jmitc91516 3:010aeeacd7d7 288 DisplayBitmapAtIfLoaded(COMPONENT_GAS_BITMAP, 609, 19, SixteenBitColorValue(231, 231, 231));
jmitc91516 1:a5258871b33d 289 }
jmitc91516 1:a5258871b33d 290
jmitc91516 8:26e49e6955bd 291 void QSPIBitmaps::DisplayBootScreenBitmap(void)
jmitc91516 8:26e49e6955bd 292 {
jmitc91516 8:26e49e6955bd 293 // No transparency on background bitmaps
jmitc91516 8:26e49e6955bd 294 DisplayBitmapAtIfLoaded(BOOT_SCREEN_BITMAP, 0, 0, -1);
jmitc91516 8:26e49e6955bd 295 }
jmitc91516 1:a5258871b33d 296
jmitc91516 8:26e49e6955bd 297 void QSPIBitmaps::DisplayBlankBackgroundBitmap(void)
jmitc91516 8:26e49e6955bd 298 {
jmitc91516 8:26e49e6955bd 299 // No transparency on background bitmaps
jmitc91516 8:26e49e6955bd 300 DisplayBitmapAtIfLoaded(BLANK_BACKGROUND_BITMAP, 0, 0, -1);
jmitc91516 8:26e49e6955bd 301 }
jmitc91516 8:26e49e6955bd 302
jmitc91516 8:26e49e6955bd 303 void QSPIBitmaps::DisplayUpArrowBitmap(GuiConst_INT16S X, GuiConst_INT16S Y)
jmitc91516 8:26e49e6955bd 304 {
jmitc91516 8:26e49e6955bd 305 DisplayBitmapAtIfLoaded(UP_ARROW_BITMAP, X, Y, -1); // No transparency
jmitc91516 8:26e49e6955bd 306 }
jmitc91516 8:26e49e6955bd 307
jmitc91516 8:26e49e6955bd 308 void QSPIBitmaps::DisplayDownArrowBitmap(GuiConst_INT16S X, GuiConst_INT16S Y)
jmitc91516 8:26e49e6955bd 309 {
jmitc91516 8:26e49e6955bd 310 DisplayBitmapAtIfLoaded(DOWN_ARROW_BITMAP, X, Y, -1); // No transparency
jmitc91516 8:26e49e6955bd 311 }
jmitc91516 1:a5258871b33d 312
jmitc91516 1:a5258871b33d 313 void QSPIBitmaps::ClearArray(void)
jmitc91516 1:a5258871b33d 314 {
jmitc91516 1:a5258871b33d 315 for( int bitmapIndex = 0; bitmapIndex < QSPIBITMAP_COUNT; ++bitmapIndex) {
jmitc91516 1:a5258871b33d 316 if(qspibmArray[bitmapIndex] != NULL) {
jmitc91516 1:a5258871b33d 317 delete qspibmArray[bitmapIndex];
jmitc91516 1:a5258871b33d 318 qspibmArray[bitmapIndex] = NULL;
jmitc91516 1:a5258871b33d 319 }
jmitc91516 1:a5258871b33d 320 }
jmitc91516 1:a5258871b33d 321 }
jmitc91516 1:a5258871b33d 322
jmitc91516 1:a5258871b33d 323 /*
jmitc91516 1:a5258871b33d 324 Tells the caller whether or not all of the QSPI bitmaps have been loaded,
jmitc91516 1:a5258871b33d 325 false if not
jmitc91516 1:a5258871b33d 326
jmitc91516 1:a5258871b33d 327 Returns true if they are *all* loaded, false if at least one is not
jmitc91516 1:a5258871b33d 328 */
jmitc91516 1:a5258871b33d 329 bool QSPIBitmaps::AllBitmapsLoaded(void)
jmitc91516 1:a5258871b33d 330 {
jmitc91516 1:a5258871b33d 331 for(int index = 0; index < QSPIBITMAP_COUNT; ++index) {
jmitc91516 1:a5258871b33d 332 if(qspibmArray[index] == NULL) {
jmitc91516 1:a5258871b33d 333 return false;
jmitc91516 1:a5258871b33d 334 }
jmitc91516 1:a5258871b33d 335
jmitc91516 1:a5258871b33d 336 if(!qspibmArray[index]->BitmapLoaded()) {
jmitc91516 1:a5258871b33d 337 return false;
jmitc91516 1:a5258871b33d 338 }
jmitc91516 1:a5258871b33d 339 }
jmitc91516 1:a5258871b33d 340
jmitc91516 1:a5258871b33d 341 // 'else' - all loaded successfully
jmitc91516 1:a5258871b33d 342 //#define SIMULATE_ERROR_FOR_TESTING
jmitc91516 1:a5258871b33d 343 #ifdef SIMULATE_ERROR_FOR_TESTING
jmitc91516 1:a5258871b33d 344 // Pretend they did not load...
jmitc91516 1:a5258871b33d 345 return false;
jmitc91516 1:a5258871b33d 346 #else
jmitc91516 1:a5258871b33d 347 return true;
jmitc91516 1:a5258871b33d 348 #endif
jmitc91516 1:a5258871b33d 349 }
jmitc91516 1:a5258871b33d 350