Repository for import to local machine
Dependencies: DMBasicGUI DMSupport
QSPIBitmap.cpp@1:a5258871b33d, 2017-07-20 (annotated)
- Committer:
- jmitc91516
- Date:
- Thu Jul 20 08:42:29 2017 +0000
- Revision:
- 1:a5258871b33d
- Child:
- 3:010aeeacd7d7
Version before re-layout (July 2017). Also for mbed CLI import to local machine.
Who changed what in which revision?
User | Revision | Line number | New 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 | 1:a5258871b33d | 12 | |
jmitc91516 | 1:a5258871b33d | 13 | // QSPI utility function (for debugging) |
jmitc91516 | 1:a5258871b33d | 14 | void DisplayQSPIDirectory(GuiConst_INT16S X, GuiConst_INT16S Y) |
jmitc91516 | 1:a5258871b33d | 15 | { |
jmitc91516 | 1:a5258871b33d | 16 | DIR *dp; |
jmitc91516 | 1:a5258871b33d | 17 | dp = opendir("/qspi/"); |
jmitc91516 | 1:a5258871b33d | 18 | |
jmitc91516 | 1:a5258871b33d | 19 | if(dp != NULL) { |
jmitc91516 | 1:a5258871b33d | 20 | struct dirent *dirp; |
jmitc91516 | 1:a5258871b33d | 21 | |
jmitc91516 | 1:a5258871b33d | 22 | DebugPrint("Start of QSPI directory", X, Y); |
jmitc91516 | 1:a5258871b33d | 23 | Y += 30; |
jmitc91516 | 1:a5258871b33d | 24 | |
jmitc91516 | 1:a5258871b33d | 25 | while((dirp = readdir(dp)) != NULL) { |
jmitc91516 | 1:a5258871b33d | 26 | DebugPrint(dirp->d_name, X, Y); |
jmitc91516 | 1:a5258871b33d | 27 | Y += 30; |
jmitc91516 | 1:a5258871b33d | 28 | } |
jmitc91516 | 1:a5258871b33d | 29 | closedir(dp); |
jmitc91516 | 1:a5258871b33d | 30 | |
jmitc91516 | 1:a5258871b33d | 31 | DebugPrint("End of QSPI directory", X, Y); |
jmitc91516 | 1:a5258871b33d | 32 | } else { |
jmitc91516 | 1:a5258871b33d | 33 | DebugPrint("Failed to open QSPI directory", X, Y); |
jmitc91516 | 1:a5258871b33d | 34 | } |
jmitc91516 | 1:a5258871b33d | 35 | } |
jmitc91516 | 1:a5258871b33d | 36 | // End of QSPI utility functions |
jmitc91516 | 1:a5258871b33d | 37 | |
jmitc91516 | 1:a5258871b33d | 38 | |
jmitc91516 | 1:a5258871b33d | 39 | // The default constructor exists purely to satisfy the compiler - it is not intended to be used |
jmitc91516 | 1:a5258871b33d | 40 | QSPIBitmap::QSPIBitmap() |
jmitc91516 | 1:a5258871b33d | 41 | { |
jmitc91516 | 1:a5258871b33d | 42 | name[0] = '\0'; |
jmitc91516 | 1:a5258871b33d | 43 | |
jmitc91516 | 1:a5258871b33d | 44 | size = 0; |
jmitc91516 | 1:a5258871b33d | 45 | debugVar1 = 0; |
jmitc91516 | 1:a5258871b33d | 46 | |
jmitc91516 | 1:a5258871b33d | 47 | //data = NULL; |
jmitc91516 | 1:a5258871b33d | 48 | |
jmitc91516 | 1:a5258871b33d | 49 | bitmapLoaded = false; |
jmitc91516 | 1:a5258871b33d | 50 | } |
jmitc91516 | 1:a5258871b33d | 51 | |
jmitc91516 | 1:a5258871b33d | 52 | QSPIBitmap::QSPIBitmap(char* bitmapName) |
jmitc91516 | 1:a5258871b33d | 53 | { |
jmitc91516 | 1:a5258871b33d | 54 | strcpy(name, bitmapName); |
jmitc91516 | 1:a5258871b33d | 55 | |
jmitc91516 | 1:a5258871b33d | 56 | // Set these when we read the bitmap from the QSPI drive |
jmitc91516 | 1:a5258871b33d | 57 | size = 0; |
jmitc91516 | 1:a5258871b33d | 58 | debugVar1 = 0; |
jmitc91516 | 1:a5258871b33d | 59 | data = NULL; |
jmitc91516 | 1:a5258871b33d | 60 | |
jmitc91516 | 1:a5258871b33d | 61 | bitmapLoaded = GetBitmapFromQSPIDrive(); |
jmitc91516 | 1:a5258871b33d | 62 | } |
jmitc91516 | 1:a5258871b33d | 63 | |
jmitc91516 | 1:a5258871b33d | 64 | QSPIBitmap::~QSPIBitmap() |
jmitc91516 | 1:a5258871b33d | 65 | { |
jmitc91516 | 1:a5258871b33d | 66 | if(data) { |
jmitc91516 | 1:a5258871b33d | 67 | delete [] data; |
jmitc91516 | 1:a5258871b33d | 68 | } |
jmitc91516 | 1:a5258871b33d | 69 | } |
jmitc91516 | 1:a5258871b33d | 70 | |
jmitc91516 | 1:a5258871b33d | 71 | bool QSPIBitmap::ReadBitmapSizeFile(void) |
jmitc91516 | 1:a5258871b33d | 72 | { |
jmitc91516 | 1:a5258871b33d | 73 | char bitmapSizeFilename[200]; |
jmitc91516 | 1:a5258871b33d | 74 | sprintf(bitmapSizeFilename, "/qspi/%s_BMP.size", name); |
jmitc91516 | 1:a5258871b33d | 75 | |
jmitc91516 | 1:a5258871b33d | 76 | char buff[50]; |
jmitc91516 | 1:a5258871b33d | 77 | |
jmitc91516 | 1:a5258871b33d | 78 | FILE *fpsize = fopen(bitmapSizeFilename, "r"); |
jmitc91516 | 1:a5258871b33d | 79 | if (fpsize != NULL) { |
jmitc91516 | 1:a5258871b33d | 80 | // We expect the size value to be 5 digits |
jmitc91516 | 1:a5258871b33d | 81 | fread(buff, 5, 1, fpsize); |
jmitc91516 | 1:a5258871b33d | 82 | fclose(fpsize); |
jmitc91516 | 1:a5258871b33d | 83 | |
jmitc91516 | 1:a5258871b33d | 84 | buff[5] = '\0'; |
jmitc91516 | 1:a5258871b33d | 85 | |
jmitc91516 | 1:a5258871b33d | 86 | sscanf(buff, "%d", &size); |
jmitc91516 | 1:a5258871b33d | 87 | |
jmitc91516 | 1:a5258871b33d | 88 | return true; |
jmitc91516 | 1:a5258871b33d | 89 | } |
jmitc91516 | 1:a5258871b33d | 90 | |
jmitc91516 | 1:a5258871b33d | 91 | // 'else'... |
jmitc91516 | 1:a5258871b33d | 92 | |
jmitc91516 | 1:a5258871b33d | 93 | return false; |
jmitc91516 | 1:a5258871b33d | 94 | } |
jmitc91516 | 1:a5258871b33d | 95 | |
jmitc91516 | 1:a5258871b33d | 96 | bool QSPIBitmap::ReadBitmapDataFile(void) |
jmitc91516 | 1:a5258871b33d | 97 | { |
jmitc91516 | 1:a5258871b33d | 98 | char bitmapDataFilename[200]; |
jmitc91516 | 1:a5258871b33d | 99 | sprintf(bitmapDataFilename, "/qspi/%s_BMP.data", name); |
jmitc91516 | 1:a5258871b33d | 100 | |
jmitc91516 | 1:a5258871b33d | 101 | FILE *fpdata = fopen(bitmapDataFilename, "rb"); |
jmitc91516 | 1:a5258871b33d | 102 | if (fpdata != NULL) { |
jmitc91516 | 1:a5258871b33d | 103 | fread(data, size, 1, fpdata); |
jmitc91516 | 1:a5258871b33d | 104 | fclose(fpdata); |
jmitc91516 | 1:a5258871b33d | 105 | |
jmitc91516 | 1:a5258871b33d | 106 | return true; |
jmitc91516 | 1:a5258871b33d | 107 | } |
jmitc91516 | 1:a5258871b33d | 108 | |
jmitc91516 | 1:a5258871b33d | 109 | // 'else'... |
jmitc91516 | 1:a5258871b33d | 110 | |
jmitc91516 | 1:a5258871b33d | 111 | return false; |
jmitc91516 | 1:a5258871b33d | 112 | } |
jmitc91516 | 1:a5258871b33d | 113 | |
jmitc91516 | 1:a5258871b33d | 114 | bool QSPIBitmap::GetBitmapFromQSPIDrive(void) |
jmitc91516 | 1:a5258871b33d | 115 | { |
jmitc91516 | 1:a5258871b33d | 116 | //TODO: Raise exceptions(?) if any of the below fails |
jmitc91516 | 1:a5258871b33d | 117 | |
jmitc91516 | 1:a5258871b33d | 118 | debugVar1 = 1; |
jmitc91516 | 1:a5258871b33d | 119 | |
jmitc91516 | 1:a5258871b33d | 120 | if(ReadBitmapSizeFile()) { |
jmitc91516 | 1:a5258871b33d | 121 | debugVar1 = 3; |
jmitc91516 | 1:a5258871b33d | 122 | } else { |
jmitc91516 | 1:a5258871b33d | 123 | debugVar1 = 2; |
jmitc91516 | 1:a5258871b33d | 124 | return false; |
jmitc91516 | 1:a5258871b33d | 125 | } |
jmitc91516 | 1:a5258871b33d | 126 | |
jmitc91516 | 1:a5258871b33d | 127 | debugVar1 = 4; |
jmitc91516 | 1:a5258871b33d | 128 | |
jmitc91516 | 1:a5258871b33d | 129 | // Do not throw an exception if the allocation fails - just leave 'data' set to NULL |
jmitc91516 | 1:a5258871b33d | 130 | data = new (nothrow) GuiConst_INT8U[size + 10]; // Leave a small margin 'just in case' |
jmitc91516 | 1:a5258871b33d | 131 | // TEST - what if the 'new' fails?? |
jmitc91516 | 1:a5258871b33d | 132 | // Answer - looks same as what Andrew saw at PittCon 2017 |
jmitc91516 | 1:a5258871b33d | 133 | |
jmitc91516 | 1:a5258871b33d | 134 | if(data == NULL) { |
jmitc91516 | 1:a5258871b33d | 135 | return false; |
jmitc91516 | 1:a5258871b33d | 136 | } |
jmitc91516 | 1:a5258871b33d | 137 | |
jmitc91516 | 1:a5258871b33d | 138 | if(ReadBitmapDataFile()) { |
jmitc91516 | 1:a5258871b33d | 139 | debugVar1 = 5; |
jmitc91516 | 1:a5258871b33d | 140 | } else { |
jmitc91516 | 1:a5258871b33d | 141 | debugVar1 = 6; |
jmitc91516 | 1:a5258871b33d | 142 | return false; |
jmitc91516 | 1:a5258871b33d | 143 | } |
jmitc91516 | 1:a5258871b33d | 144 | |
jmitc91516 | 1:a5258871b33d | 145 | debugVar1 = 7; |
jmitc91516 | 1:a5258871b33d | 146 | |
jmitc91516 | 1:a5258871b33d | 147 | return true; |
jmitc91516 | 1:a5258871b33d | 148 | } |
jmitc91516 | 1:a5258871b33d | 149 | |
jmitc91516 | 1:a5258871b33d | 150 | void QSPIBitmap::DisplayAt(GuiConst_INT16S X, GuiConst_INT16S Y) |
jmitc91516 | 1:a5258871b33d | 151 | { |
jmitc91516 | 1:a5258871b33d | 152 | if(bitmapLoaded) { |
jmitc91516 | 1:a5258871b33d | 153 | // Component bitmaps have white 'corners' - select white as transparent colour |
jmitc91516 | 1:a5258871b33d | 154 | GuiLib_ShowBitmapAt(data, X, Y, 0xFFFFFF); |
jmitc91516 | 1:a5258871b33d | 155 | // *This works* - the white corners disappear |
jmitc91516 | 1:a5258871b33d | 156 | // ****************************************** |
jmitc91516 | 1:a5258871b33d | 157 | } else { |
jmitc91516 | 1:a5258871b33d | 158 | char buff[100]; |
jmitc91516 | 1:a5258871b33d | 159 | sprintf(buff, "Bitmap not loaded - size %d, debugVar1: %d", size, debugVar1); |
jmitc91516 | 1:a5258871b33d | 160 | DebugPrint(buff, X, Y); |
jmitc91516 | 1:a5258871b33d | 161 | |
jmitc91516 | 1:a5258871b33d | 162 | char bitmapSizeFilename[200]; |
jmitc91516 | 1:a5258871b33d | 163 | sprintf(bitmapSizeFilename, "/qspi/%s_BMP.size", name); |
jmitc91516 | 1:a5258871b33d | 164 | DebugPrint(bitmapSizeFilename, X, Y+40); |
jmitc91516 | 1:a5258871b33d | 165 | } |
jmitc91516 | 1:a5258871b33d | 166 | } |
jmitc91516 | 1:a5258871b33d | 167 | |
jmitc91516 | 1:a5258871b33d | 168 | |
jmitc91516 | 1:a5258871b33d | 169 | // QSPIBitmaps class members |
jmitc91516 | 1:a5258871b33d | 170 | QSPIBitmaps::QSPIBitmaps() |
jmitc91516 | 1:a5258871b33d | 171 | { |
jmitc91516 | 1:a5258871b33d | 172 | qspibmArray[HOME_COLUMN_BITMAP] = NULL; |
jmitc91516 | 1:a5258871b33d | 173 | qspibmArray[HOME_DETECTOR_BITMAP] = NULL; |
jmitc91516 | 1:a5258871b33d | 174 | qspibmArray[HOME_INJECTOR_BITMAP] = NULL; |
jmitc91516 | 1:a5258871b33d | 175 | qspibmArray[HOME_GAS_BITMAP] = NULL; |
jmitc91516 | 1:a5258871b33d | 176 | |
jmitc91516 | 1:a5258871b33d | 177 | qspibmArray[COMPONENT_COLUMN_BITMAP] = NULL; |
jmitc91516 | 1:a5258871b33d | 178 | qspibmArray[COMPONENT_DETECTOR_BITMAP] = NULL; |
jmitc91516 | 1:a5258871b33d | 179 | qspibmArray[COMPONENT_INJECTOR_BITMAP] = NULL; |
jmitc91516 | 1:a5258871b33d | 180 | qspibmArray[COMPONENT_GAS_BITMAP] = NULL; |
jmitc91516 | 1:a5258871b33d | 181 | |
jmitc91516 | 1:a5258871b33d | 182 | arraySetUp = false; |
jmitc91516 | 1:a5258871b33d | 183 | } |
jmitc91516 | 1:a5258871b33d | 184 | |
jmitc91516 | 1:a5258871b33d | 185 | /* |
jmitc91516 | 1:a5258871b33d | 186 | Sets up each of the bitmaps in the array, by reading the corresponding files |
jmitc91516 | 1:a5258871b33d | 187 | from the QSPI (memory) file system. |
jmitc91516 | 1:a5258871b33d | 188 | |
jmitc91516 | 1:a5258871b33d | 189 | *** Note that this is currently loading bitmaps specific to the Home page *** |
jmitc91516 | 1:a5258871b33d | 190 | |
jmitc91516 | 1:a5258871b33d | 191 | Returns true if all loaded successfully, false if not |
jmitc91516 | 1:a5258871b33d | 192 | */ |
jmitc91516 | 1:a5258871b33d | 193 | void QSPIBitmaps::SetupArray(void) |
jmitc91516 | 1:a5258871b33d | 194 | { |
jmitc91516 | 1:a5258871b33d | 195 | if(!arraySetUp) { |
jmitc91516 | 1:a5258871b33d | 196 | |
jmitc91516 | 1:a5258871b33d | 197 | // Bitmap names manually copied from GuiStruct.c, and hard-coded here. |
jmitc91516 | 1:a5258871b33d | 198 | // Must match those in the GC500_2_5inch_bitmap_loader. |
jmitc91516 | 1:a5258871b33d | 199 | |
jmitc91516 | 1:a5258871b33d | 200 | qspibmArray[HOME_COLUMN_BITMAP] = new QSPIBitmap("GuiStruct_Bitmap_ColumnButton"); |
jmitc91516 | 1:a5258871b33d | 201 | qspibmArray[HOME_DETECTOR_BITMAP] = new QSPIBitmap("GuiStruct_Bitmap_DetectorButton"); |
jmitc91516 | 1:a5258871b33d | 202 | qspibmArray[HOME_INJECTOR_BITMAP] = new QSPIBitmap("GuiStruct_Bitmap_InjectorButton"); |
jmitc91516 | 1:a5258871b33d | 203 | qspibmArray[HOME_GAS_BITMAP] = new QSPIBitmap("GuiStruct_Bitmap_GasButton"); |
jmitc91516 | 1:a5258871b33d | 204 | |
jmitc91516 | 1:a5258871b33d | 205 | qspibmArray[COMPONENT_COLUMN_BITMAP] = new QSPIBitmap("GuiStruct_Bitmap_Column"); |
jmitc91516 | 1:a5258871b33d | 206 | qspibmArray[COMPONENT_DETECTOR_BITMAP] = new QSPIBitmap("GuiStruct_Bitmap_Detector"); |
jmitc91516 | 1:a5258871b33d | 207 | qspibmArray[COMPONENT_INJECTOR_BITMAP] = new QSPIBitmap("GuiStruct_Bitmap_Injector"); |
jmitc91516 | 1:a5258871b33d | 208 | qspibmArray[COMPONENT_GAS_BITMAP] = new QSPIBitmap("GuiStruct_Bitmap_Gas"); |
jmitc91516 | 1:a5258871b33d | 209 | |
jmitc91516 | 1:a5258871b33d | 210 | arraySetUp = true; |
jmitc91516 | 1:a5258871b33d | 211 | } |
jmitc91516 | 1:a5258871b33d | 212 | } |
jmitc91516 | 1:a5258871b33d | 213 | |
jmitc91516 | 1:a5258871b33d | 214 | |
jmitc91516 | 1:a5258871b33d | 215 | void QSPIBitmaps::DisplayBitmapAtIfLoaded(int bitmapIndex, GuiConst_INT16S X, GuiConst_INT16S Y) |
jmitc91516 | 1:a5258871b33d | 216 | { |
jmitc91516 | 1:a5258871b33d | 217 | if(qspibmArray[bitmapIndex] != NULL) { |
jmitc91516 | 1:a5258871b33d | 218 | qspibmArray[bitmapIndex]->DisplayAt(X, Y); |
jmitc91516 | 1:a5258871b33d | 219 | } |
jmitc91516 | 1:a5258871b33d | 220 | } |
jmitc91516 | 1:a5258871b33d | 221 | |
jmitc91516 | 1:a5258871b33d | 222 | void QSPIBitmaps::DisplayAllHomePageBitmaps(void) |
jmitc91516 | 1:a5258871b33d | 223 | { |
jmitc91516 | 1:a5258871b33d | 224 | DisplayBitmapAtIfLoaded(HOME_COLUMN_BITMAP, 10, 10); |
jmitc91516 | 1:a5258871b33d | 225 | DisplayBitmapAtIfLoaded(HOME_DETECTOR_BITMAP, 410, 10); |
jmitc91516 | 1:a5258871b33d | 226 | DisplayBitmapAtIfLoaded(HOME_INJECTOR_BITMAP, 10, 215); |
jmitc91516 | 1:a5258871b33d | 227 | DisplayBitmapAtIfLoaded(HOME_GAS_BITMAP, 410, 215); |
jmitc91516 | 1:a5258871b33d | 228 | |
jmitc91516 | 1:a5258871b33d | 229 | //DEBUG |
jmitc91516 | 1:a5258871b33d | 230 | if(qspiAlreadyFormatted) { |
jmitc91516 | 1:a5258871b33d | 231 | DebugPrint("QSPI formatted at start", 200, 100); |
jmitc91516 | 1:a5258871b33d | 232 | } else { |
jmitc91516 | 1:a5258871b33d | 233 | DebugPrint("QSPI *not* formatted at start", 200, 100); |
jmitc91516 | 1:a5258871b33d | 234 | } |
jmitc91516 | 1:a5258871b33d | 235 | |
jmitc91516 | 1:a5258871b33d | 236 | } |
jmitc91516 | 1:a5258871b33d | 237 | |
jmitc91516 | 1:a5258871b33d | 238 | void QSPIBitmaps::DisplayColumnComponentBitmap(void) |
jmitc91516 | 1:a5258871b33d | 239 | { |
jmitc91516 | 1:a5258871b33d | 240 | DisplayBitmapAtIfLoaded(COMPONENT_COLUMN_BITMAP, 609, 19); |
jmitc91516 | 1:a5258871b33d | 241 | } |
jmitc91516 | 1:a5258871b33d | 242 | |
jmitc91516 | 1:a5258871b33d | 243 | void QSPIBitmaps::DisplayDetectorComponentBitmap(void) |
jmitc91516 | 1:a5258871b33d | 244 | { |
jmitc91516 | 1:a5258871b33d | 245 | DisplayBitmapAtIfLoaded(COMPONENT_DETECTOR_BITMAP, 609, 19); |
jmitc91516 | 1:a5258871b33d | 246 | } |
jmitc91516 | 1:a5258871b33d | 247 | |
jmitc91516 | 1:a5258871b33d | 248 | void QSPIBitmaps::DisplayInjectorComponentBitmap(void) |
jmitc91516 | 1:a5258871b33d | 249 | { |
jmitc91516 | 1:a5258871b33d | 250 | DisplayBitmapAtIfLoaded(COMPONENT_INJECTOR_BITMAP, 609, 19); |
jmitc91516 | 1:a5258871b33d | 251 | } |
jmitc91516 | 1:a5258871b33d | 252 | |
jmitc91516 | 1:a5258871b33d | 253 | void QSPIBitmaps::DisplayGasComponentBitmap(void) |
jmitc91516 | 1:a5258871b33d | 254 | { |
jmitc91516 | 1:a5258871b33d | 255 | DisplayBitmapAtIfLoaded(COMPONENT_GAS_BITMAP, 609, 19); |
jmitc91516 | 1:a5258871b33d | 256 | } |
jmitc91516 | 1:a5258871b33d | 257 | |
jmitc91516 | 1:a5258871b33d | 258 | |
jmitc91516 | 1:a5258871b33d | 259 | |
jmitc91516 | 1:a5258871b33d | 260 | void QSPIBitmaps::ClearArray(void) |
jmitc91516 | 1:a5258871b33d | 261 | { |
jmitc91516 | 1:a5258871b33d | 262 | for( int bitmapIndex = 0; bitmapIndex < QSPIBITMAP_COUNT; ++bitmapIndex) { |
jmitc91516 | 1:a5258871b33d | 263 | if(qspibmArray[bitmapIndex] != NULL) { |
jmitc91516 | 1:a5258871b33d | 264 | delete qspibmArray[bitmapIndex]; |
jmitc91516 | 1:a5258871b33d | 265 | qspibmArray[bitmapIndex] = NULL; |
jmitc91516 | 1:a5258871b33d | 266 | } |
jmitc91516 | 1:a5258871b33d | 267 | } |
jmitc91516 | 1:a5258871b33d | 268 | } |
jmitc91516 | 1:a5258871b33d | 269 | |
jmitc91516 | 1:a5258871b33d | 270 | /* |
jmitc91516 | 1:a5258871b33d | 271 | Tells the caller whether or not all of the QSPI bitmaps have been loaded, |
jmitc91516 | 1:a5258871b33d | 272 | false if not |
jmitc91516 | 1:a5258871b33d | 273 | |
jmitc91516 | 1:a5258871b33d | 274 | Returns true if they are *all* loaded, false if at least one is not |
jmitc91516 | 1:a5258871b33d | 275 | */ |
jmitc91516 | 1:a5258871b33d | 276 | bool QSPIBitmaps::AllBitmapsLoaded(void) |
jmitc91516 | 1:a5258871b33d | 277 | { |
jmitc91516 | 1:a5258871b33d | 278 | for(int index = 0; index < QSPIBITMAP_COUNT; ++index) { |
jmitc91516 | 1:a5258871b33d | 279 | if(qspibmArray[index] == NULL) { |
jmitc91516 | 1:a5258871b33d | 280 | return false; |
jmitc91516 | 1:a5258871b33d | 281 | } |
jmitc91516 | 1:a5258871b33d | 282 | |
jmitc91516 | 1:a5258871b33d | 283 | if(!qspibmArray[index]->BitmapLoaded()) { |
jmitc91516 | 1:a5258871b33d | 284 | return false; |
jmitc91516 | 1:a5258871b33d | 285 | } |
jmitc91516 | 1:a5258871b33d | 286 | } |
jmitc91516 | 1:a5258871b33d | 287 | |
jmitc91516 | 1:a5258871b33d | 288 | // 'else' - all loaded successfully |
jmitc91516 | 1:a5258871b33d | 289 | //#define SIMULATE_ERROR_FOR_TESTING |
jmitc91516 | 1:a5258871b33d | 290 | #ifdef SIMULATE_ERROR_FOR_TESTING |
jmitc91516 | 1:a5258871b33d | 291 | // Pretend they did not load... |
jmitc91516 | 1:a5258871b33d | 292 | return false; |
jmitc91516 | 1:a5258871b33d | 293 | #else |
jmitc91516 | 1:a5258871b33d | 294 | return true; |
jmitc91516 | 1:a5258871b33d | 295 | #endif |
jmitc91516 | 1:a5258871b33d | 296 | } |
jmitc91516 | 1:a5258871b33d | 297 |