4D systems Picaso uLCD 32PTU touch display library
demo.cpp@27:dbf79d116497, 2016-09-29 (annotated)
- Committer:
- CaptainR
- Date:
- Thu Sep 29 19:40:53 2016 +0000
- Revision:
- 27:dbf79d116497
- Parent:
- 26:c6a803706a42
get word and get string
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
CaptainR | 0:a5ef6bc3c2e8 | 1 | |
CaptainR | 0:a5ef6bc3c2e8 | 2 | #include "mbed.h" |
CaptainR | 0:a5ef6bc3c2e8 | 3 | #include "Picaso_4DGL-32PTU.h" |
CaptainR | 0:a5ef6bc3c2e8 | 4 | |
CaptainR | 0:a5ef6bc3c2e8 | 5 | #define SHORT_WAIT 500 |
CaptainR | 12:29f5ad896382 | 6 | #define LONG_WAIT 1000 |
CaptainR | 0:a5ef6bc3c2e8 | 7 | |
CaptainR | 22:cea582ea74c1 | 8 | // local declarations |
CaptainR | 26:c6a803706a42 | 9 | void clearBuf(char*, int); |
CaptainR | 20:88e137b9ea46 | 10 | |
CaptainR | 20:88e137b9ea46 | 11 | //************************************************************************** |
CaptainR | 20:88e137b9ea46 | 12 | // Demo program that goes through file system based functions |
CaptainR | 20:88e137b9ea46 | 13 | //************************************************************************** |
CaptainR | 20:88e137b9ea46 | 14 | void PICASO_4DGL :: fileSystemDemo() { |
CaptainR | 20:88e137b9ea46 | 15 | |
CaptainR | 26:c6a803706a42 | 16 | short h1; |
CaptainR | 23:dd2c28fa4dfd | 17 | int i; |
CaptainR | 20:88e137b9ea46 | 18 | cls(); |
CaptainR | 20:88e137b9ea46 | 19 | screenMode(landscape); // set orientation to landscape |
CaptainR | 20:88e137b9ea46 | 20 | puts("\n\rThis is the File system functions demo"); |
CaptainR | 20:88e137b9ea46 | 21 | wait_ms(LONG_WAIT); |
CaptainR | 20:88e137b9ea46 | 22 | cls(); |
CaptainR | 20:88e137b9ea46 | 23 | |
CaptainR | 22:cea582ea74c1 | 24 | if (file_Mount()) puts("\rFAT16 Mount: OK"); |
CaptainR | 22:cea582ea74c1 | 25 | else puts("\rFAT16 Mount: FAIL"); |
CaptainR | 22:cea582ea74c1 | 26 | char buf[100]; |
CaptainR | 26:c6a803706a42 | 27 | sprintf(buf, "\n\rFAT16 Error = %i\n", file_Error()); |
CaptainR | 21:ea68a8a3cea4 | 28 | puts(buf); |
CaptainR | 26:c6a803706a42 | 29 | /* |
CaptainR | 22:cea582ea74c1 | 30 | sprintf(buf, "\n\rFile count on disc = %i\n\r", file_Count("*.*")); |
CaptainR | 22:cea582ea74c1 | 31 | puts(buf); |
CaptainR | 25:015631f9e875 | 32 | sprintf(buf, "\n\rFound %i files maching 1*.*", file_Dir("1*.*")); |
CaptainR | 22:cea582ea74c1 | 33 | puts(buf); |
CaptainR | 22:cea582ea74c1 | 34 | file_FindFirst("*.TXT"); |
CaptainR | 23:dd2c28fa4dfd | 35 | char filename[FILENAME_LENGTH]; |
CaptainR | 23:dd2c28fa4dfd | 36 | for (i = 0; i < FILENAME_LENGTH; i++) |
CaptainR | 23:dd2c28fa4dfd | 37 | filename[i] = 0; |
CaptainR | 23:dd2c28fa4dfd | 38 | short len = file_FindFirstRet("*.TXT", filename); |
CaptainR | 24:19c77967674e | 39 | sprintf(buf, "\n\rFirst filename = %s\n Length = %i", filename, len); |
CaptainR | 24:19c77967674e | 40 | puts(buf); |
CaptainR | 24:19c77967674e | 41 | for (i = 0; i < FILENAME_LENGTH; i++) |
CaptainR | 24:19c77967674e | 42 | filename[i] = 0; |
CaptainR | 24:19c77967674e | 43 | file_FindNext(); |
CaptainR | 24:19c77967674e | 44 | len = file_FindNextRet(filename); |
CaptainR | 24:19c77967674e | 45 | sprintf(buf, "\n\rNext filename = %s\n Length = %i", filename, len); |
CaptainR | 23:dd2c28fa4dfd | 46 | puts(buf); |
CaptainR | 25:015631f9e875 | 47 | file_FindNext(); |
CaptainR | 25:015631f9e875 | 48 | file_FindNext(); |
CaptainR | 25:015631f9e875 | 49 | file_FindNext(); |
CaptainR | 25:015631f9e875 | 50 | if (file_Exists("3.TXT")) puts("\n\r3.TXT : EXISTS"); |
CaptainR | 25:015631f9e875 | 51 | else puts("\n\r3.TXT : DOES NOT EXIST"); |
CaptainR | 25:015631f9e875 | 52 | if (file_Exists("4.TXT")) puts("\n\r4.TXT : EXISTS"); |
CaptainR | 25:015631f9e875 | 53 | else puts("\n\r4.TXT : DOES NOT EXIST"); |
CaptainR | 26:c6a803706a42 | 54 | wait_ms(LONG_WAIT); |
CaptainR | 26:c6a803706a42 | 55 | cls(); |
CaptainR | 26:c6a803706a42 | 56 | */ |
CaptainR | 26:c6a803706a42 | 57 | |
CaptainR | 26:c6a803706a42 | 58 | h1 = file_Open("file.txt", OPEN_READ); |
CaptainR | 26:c6a803706a42 | 59 | short err = file_Error(); |
CaptainR | 26:c6a803706a42 | 60 | if (err == 0) sprintf(buf, "\r\file.txt handle = %i", h1); |
CaptainR | 26:c6a803706a42 | 61 | else sprintf(buf, "\rFile Open error = %i", err); |
CaptainR | 26:c6a803706a42 | 62 | puts(buf); |
CaptainR | 26:c6a803706a42 | 63 | short count = file_Read(31, h1); |
CaptainR | 26:c6a803706a42 | 64 | if (count == 31) sprintf(buf, "\r\nRead %i bytes from %i", count, h1); |
CaptainR | 26:c6a803706a42 | 65 | else sprintf(buf, "\r\nError = %i\n\rMax data count = %i", file_Error(), count); |
CaptainR | 26:c6a803706a42 | 66 | puts(buf); |
CaptainR | 26:c6a803706a42 | 67 | sprintf(buf, "\r\nData: %s", fileReadBuf); |
CaptainR | 26:c6a803706a42 | 68 | puts(buf); |
CaptainR | 26:c6a803706a42 | 69 | |
CaptainR | 26:c6a803706a42 | 70 | clearBuf(fileReadBuf, BUFFER_SIZE); |
CaptainR | 26:c6a803706a42 | 71 | short hi = 0, lo = 5; |
CaptainR | 26:c6a803706a42 | 72 | sprintf(buf, "\r\nSetting pointer to %i = %s", lo, file_Seek(h1, hi, lo) ? "true" : "false"); |
CaptainR | 26:c6a803706a42 | 73 | puts(buf); |
CaptainR | 26:c6a803706a42 | 74 | file_Read(1, h1); |
CaptainR | 26:c6a803706a42 | 75 | sprintf(buf, "\r\nRead char = %c", fileReadBuf[0]); |
CaptainR | 26:c6a803706a42 | 76 | puts(buf); |
CaptainR | 26:c6a803706a42 | 77 | |
CaptainR | 26:c6a803706a42 | 78 | clearBuf(fileReadBuf, BUFFER_SIZE); |
CaptainR | 26:c6a803706a42 | 79 | short recNum = 2; |
CaptainR | 26:c6a803706a42 | 80 | sprintf(buf, "\r\nIndex pointer to %i = %s", lo, file_Index(h1, hi, lo, recNum) ? "true" : "false"); |
CaptainR | 26:c6a803706a42 | 81 | puts(buf); |
CaptainR | 26:c6a803706a42 | 82 | file_Read(1, h1); |
CaptainR | 26:c6a803706a42 | 83 | sprintf(buf, "\r\nRead char = %c", fileReadBuf[0]); |
CaptainR | 26:c6a803706a42 | 84 | puts(buf); |
CaptainR | 26:c6a803706a42 | 85 | |
CaptainR | 26:c6a803706a42 | 86 | int pointer = file_Tell(h1); |
CaptainR | 26:c6a803706a42 | 87 | if (pointer >= 0) sprintf(buf, "\r\nPointer = %i", pointer); |
CaptainR | 26:c6a803706a42 | 88 | else sprintf(buf, "\r\nError = %i", file_Error()); |
CaptainR | 26:c6a803706a42 | 89 | puts(buf); |
CaptainR | 26:c6a803706a42 | 90 | |
CaptainR | 26:c6a803706a42 | 91 | sprintf(buf, "\r\nFile %i Close = %s", h1, file_Close(h1) ? "true" : "false"); |
CaptainR | 26:c6a803706a42 | 92 | puts(buf); |
CaptainR | 26:c6a803706a42 | 93 | |
CaptainR | 26:c6a803706a42 | 94 | h1 = file_Open("newfile.txt", OPEN_READ); |
CaptainR | 26:c6a803706a42 | 95 | err = file_Error(); |
CaptainR | 26:c6a803706a42 | 96 | if (err == 0) sprintf(buf, "\r\nnewfile.txt handle = %i", h1); |
CaptainR | 26:c6a803706a42 | 97 | else sprintf(buf, "\rFile Open error = %i", err); |
CaptainR | 26:c6a803706a42 | 98 | puts(buf); |
CaptainR | 26:c6a803706a42 | 99 | |
CaptainR | 26:c6a803706a42 | 100 | clearBuf(fileReadBuf, BUFFER_SIZE); |
CaptainR | 26:c6a803706a42 | 101 | count = file_Read(18, h1); |
CaptainR | 26:c6a803706a42 | 102 | if (count == 18) sprintf(buf, "\r\nRead %i bytes from %i", count, h1); |
CaptainR | 26:c6a803706a42 | 103 | else sprintf(buf, "\r\nError = %i\n\rMax data count = %i", file_Error(), count); |
CaptainR | 26:c6a803706a42 | 104 | puts(buf); |
CaptainR | 26:c6a803706a42 | 105 | sprintf(buf, "\r\nData: %s", fileReadBuf); |
CaptainR | 26:c6a803706a42 | 106 | puts(buf); |
CaptainR | 26:c6a803706a42 | 107 | |
CaptainR | 26:c6a803706a42 | 108 | sprintf(buf, "\r\nFile %i size = %i", h1, file_Size(h1)); |
CaptainR | 26:c6a803706a42 | 109 | puts(buf); |
CaptainR | 26:c6a803706a42 | 110 | |
CaptainR | 26:c6a803706a42 | 111 | sprintf(buf, "\r\nFile %i Close = %s", h1, file_Close(h1) ? "true" : "false"); |
CaptainR | 26:c6a803706a42 | 112 | puts(buf); |
CaptainR | 27:dbf79d116497 | 113 | wait_ms(LONG_WAIT); |
CaptainR | 27:dbf79d116497 | 114 | cls(); |
CaptainR | 26:c6a803706a42 | 115 | |
CaptainR | 27:dbf79d116497 | 116 | h1 = file_Open("1.txt", OPEN_READ); |
CaptainR | 27:dbf79d116497 | 117 | err = file_Error(); |
CaptainR | 27:dbf79d116497 | 118 | if (err == 0) sprintf(buf, "\r\nnewfile.txt handle = %i", h1); |
CaptainR | 27:dbf79d116497 | 119 | else sprintf(buf, "\rFile Open error = %i", err); |
CaptainR | 27:dbf79d116497 | 120 | puts(buf); |
CaptainR | 27:dbf79d116497 | 121 | |
CaptainR | 27:dbf79d116497 | 122 | for (i = 0; i < 3; i++) { |
CaptainR | 27:dbf79d116497 | 123 | clearBuf(fileReadBuf, BUFFER_SIZE); |
CaptainR | 27:dbf79d116497 | 124 | count = file_GetS(30, h1, fileReadBuf); |
CaptainR | 27:dbf79d116497 | 125 | sprintf(buf, "\r\nRead %i bytes", count); |
CaptainR | 27:dbf79d116497 | 126 | puts(buf); |
CaptainR | 27:dbf79d116497 | 127 | sprintf(buf, "\r\nData: %s", fileReadBuf); |
CaptainR | 27:dbf79d116497 | 128 | puts(buf); |
CaptainR | 27:dbf79d116497 | 129 | } |
CaptainR | 27:dbf79d116497 | 130 | |
CaptainR | 27:dbf79d116497 | 131 | |
CaptainR | 27:dbf79d116497 | 132 | /* |
CaptainR | 26:c6a803706a42 | 133 | short h2 = file_Open("scr.png", OPEN_APPEND); |
CaptainR | 26:c6a803706a42 | 134 | file_ScreenCapture(10, 10, 200, 100, h2); |
CaptainR | 26:c6a803706a42 | 135 | file_Close(h2); |
CaptainR | 26:c6a803706a42 | 136 | |
CaptainR | 26:c6a803706a42 | 137 | wait_ms(LONG_WAIT); |
CaptainR | 26:c6a803706a42 | 138 | cls(); |
CaptainR | 26:c6a803706a42 | 139 | |
CaptainR | 26:c6a803706a42 | 140 | h2 = file_Open("pic.bmp", OPEN_READ); |
CaptainR | 26:c6a803706a42 | 141 | file_Image(5, 5, h2); |
CaptainR | 27:dbf79d116497 | 142 | */ |
CaptainR | 26:c6a803706a42 | 143 | /* |
CaptainR | 26:c6a803706a42 | 144 | h1 = file_Open("newfile.txt", OPEN_APPEND); // try appending to file |
CaptainR | 26:c6a803706a42 | 145 | err = file_Error(); |
CaptainR | 26:c6a803706a42 | 146 | if (err == 0) sprintf(buf, "\r\nnewfile.txt handle = %i", h1); |
CaptainR | 26:c6a803706a42 | 147 | else sprintf(buf, "\rFile Open error = %i", err); |
CaptainR | 26:c6a803706a42 | 148 | puts(buf); |
CaptainR | 26:c6a803706a42 | 149 | |
CaptainR | 26:c6a803706a42 | 150 | count = file_Write(13, " My Precious!", h1); // add data |
CaptainR | 26:c6a803706a42 | 151 | file_Close(h1); // close file |
CaptainR | 26:c6a803706a42 | 152 | h1 = file_Open("newfile.txt", OPEN_READ); // open in read mode again |
CaptainR | 26:c6a803706a42 | 153 | err = file_Error(); |
CaptainR | 26:c6a803706a42 | 154 | if (err != 0) { |
CaptainR | 26:c6a803706a42 | 155 | sprintf(buf, "\rFile Open error = %i", err); |
CaptainR | 26:c6a803706a42 | 156 | puts(buf); |
CaptainR | 26:c6a803706a42 | 157 | } |
CaptainR | 26:c6a803706a42 | 158 | |
CaptainR | 26:c6a803706a42 | 159 | clearBuf(fileReadBuf, BUFFER_SIZE); // clear buffer |
CaptainR | 26:c6a803706a42 | 160 | count = file_Read(18, h1); // read bytes |
CaptainR | 26:c6a803706a42 | 161 | if (count != 18) { |
CaptainR | 26:c6a803706a42 | 162 | sprintf(buf, "\r\nError = %i\n\rMax data count = %i", file_Error(), count); |
CaptainR | 26:c6a803706a42 | 163 | puts(buf); |
CaptainR | 26:c6a803706a42 | 164 | } |
CaptainR | 26:c6a803706a42 | 165 | sprintf(buf, "\r\nData: %s", fileReadBuf); |
CaptainR | 26:c6a803706a42 | 166 | puts(buf); |
CaptainR | 26:c6a803706a42 | 167 | */ |
CaptainR | 26:c6a803706a42 | 168 | |
CaptainR | 25:015631f9e875 | 169 | |
CaptainR | 20:88e137b9ea46 | 170 | } |
CaptainR | 0:a5ef6bc3c2e8 | 171 | //************************************************************************** |
CaptainR | 12:29f5ad896382 | 172 | // Demo program that goes through media based functions |
CaptainR | 12:29f5ad896382 | 173 | //************************************************************************** |
CaptainR | 12:29f5ad896382 | 174 | void PICASO_4DGL :: mediaDemo() { |
CaptainR | 12:29f5ad896382 | 175 | |
CaptainR | 12:29f5ad896382 | 176 | cls(); |
CaptainR | 12:29f5ad896382 | 177 | screenMode(landscape); // set orientation to landscape |
CaptainR | 12:29f5ad896382 | 178 | puts("\n\rThis is the Media functions demo"); |
CaptainR | 12:29f5ad896382 | 179 | wait_ms(LONG_WAIT); |
CaptainR | 12:29f5ad896382 | 180 | cls(); |
CaptainR | 12:29f5ad896382 | 181 | |
CaptainR | 12:29f5ad896382 | 182 | wait_ms(SHORT_WAIT); |
CaptainR | 12:29f5ad896382 | 183 | if (media_Init()) puts("\n\r uSD card Initialization: OK"); |
CaptainR | 12:29f5ad896382 | 184 | else puts("\n\r uSD card Initialization: FAIL"); |
CaptainR | 14:561cb06a2739 | 185 | if (media_SetAdd(513)) puts("\n\r Byte address set: OK"); |
CaptainR | 14:561cb06a2739 | 186 | else puts("\n\r Byte address set: FAIL"); |
CaptainR | 12:29f5ad896382 | 187 | if (media_SetSector(1)) puts("\n\r Sector address set: OK"); |
CaptainR | 12:29f5ad896382 | 188 | else puts("\n\r Sector address set: FAIL"); |
CaptainR | 16:cb072eea16e9 | 189 | /* |
CaptainR | 16:cb072eea16e9 | 190 | puts("\n\r Now write some data in multiple sectors"); |
CaptainR | 15:86bdf382e6f7 | 191 | |
CaptainR | 15:86bdf382e6f7 | 192 | char array[1030]; |
CaptainR | 15:86bdf382e6f7 | 193 | for (int i = 0; i < 1030; i++) |
CaptainR | 15:86bdf382e6f7 | 194 | array[i] = 1; |
CaptainR | 15:86bdf382e6f7 | 195 | |
CaptainR | 12:29f5ad896382 | 196 | wait_ms(LONG_WAIT); |
CaptainR | 15:86bdf382e6f7 | 197 | if (media_WrSector(array)) puts("\n\r Write Data: OK"); |
CaptainR | 15:86bdf382e6f7 | 198 | else puts("\n\r Write Data: FAIL"); |
CaptainR | 14:561cb06a2739 | 199 | wait_ms(LONG_WAIT); |
CaptainR | 16:cb072eea16e9 | 200 | puts("\n\r Now read the same data"); |
CaptainR | 14:561cb06a2739 | 201 | if (media_SetSector(1)) puts("\n\r Sector address set: OK"); |
CaptainR | 15:86bdf382e6f7 | 202 | if (media_RdSector()) puts("\n\r Read Sector 1: OK"); |
CaptainR | 15:86bdf382e6f7 | 203 | else puts("\n\r Read Sector 1: FAIL"); |
CaptainR | 15:86bdf382e6f7 | 204 | if (media_RdSector()) puts("\n\r Read Sector 2: OK"); |
CaptainR | 15:86bdf382e6f7 | 205 | else puts("\n\r Read Sector 2: FAIL"); |
CaptainR | 15:86bdf382e6f7 | 206 | if (media_RdSector()) puts("\n\r Read Sector 3: OK"); |
CaptainR | 15:86bdf382e6f7 | 207 | else puts("\n\r Read Sector 3: FAIL"); |
CaptainR | 15:86bdf382e6f7 | 208 | if (media_RdSector()) puts("\n\r Read Sector 4: OK"); |
CaptainR | 15:86bdf382e6f7 | 209 | else puts("\n\r Read Sector 4: FAIL"); |
CaptainR | 15:86bdf382e6f7 | 210 | if (media_RdSector()) puts("\n\r Read Sector 5: OK"); |
CaptainR | 15:86bdf382e6f7 | 211 | else puts("\n\r Read Sector 5: FAIL"); |
CaptainR | 16:cb072eea16e9 | 212 | */ |
CaptainR | 16:cb072eea16e9 | 213 | media_SetSector(1); |
CaptainR | 16:cb072eea16e9 | 214 | puts("\n\r Now write some data in one sector"); |
CaptainR | 16:cb072eea16e9 | 215 | wait_ms(LONG_WAIT); |
CaptainR | 16:cb072eea16e9 | 216 | if (media_WrSector("Such data Much WOW")) puts("\n\r Write Data: OK"); |
CaptainR | 16:cb072eea16e9 | 217 | else puts("\n\r Write Data: FAIL"); |
CaptainR | 16:cb072eea16e9 | 218 | wait_ms(LONG_WAIT); |
CaptainR | 16:cb072eea16e9 | 219 | puts("\n\r Now read the same data"); |
CaptainR | 16:cb072eea16e9 | 220 | media_SetSector(1); |
CaptainR | 16:cb072eea16e9 | 221 | if (media_RdSector()) { |
CaptainR | 16:cb072eea16e9 | 222 | puts("\n\r Read Sector : OK"); |
CaptainR | 16:cb072eea16e9 | 223 | pc.printf("\n\r Data: "); |
CaptainR | 16:cb072eea16e9 | 224 | for(int i = 0; i < BUFFER_SIZE; i++) pc.printf("%c", buffer[i]); |
CaptainR | 16:cb072eea16e9 | 225 | pc.printf("\n\r"); |
CaptainR | 16:cb072eea16e9 | 226 | } |
CaptainR | 16:cb072eea16e9 | 227 | else puts("\n\r Read Sector : FAIL"); |
CaptainR | 12:29f5ad896382 | 228 | |
CaptainR | 16:cb072eea16e9 | 229 | puts("\n\r Now read one byte"); |
CaptainR | 18:829f3e2c064c | 230 | media_SetAdd(510); |
CaptainR | 16:cb072eea16e9 | 231 | if (media_ReadByte()) puts("\n\r Read Byte : OK"); |
CaptainR | 16:cb072eea16e9 | 232 | else puts("\n\r Read Byte : FAIL"); |
CaptainR | 18:829f3e2c064c | 233 | |
CaptainR | 18:829f3e2c064c | 234 | puts("\n\r Now read one word"); |
CaptainR | 18:829f3e2c064c | 235 | if (media_ReadByte()) puts("\n\r Read word : OK"); |
CaptainR | 18:829f3e2c064c | 236 | else puts("\n\r Read word : FAIL"); |
CaptainR | 19:a259bc128867 | 237 | |
CaptainR | 19:a259bc128867 | 238 | puts("\n\r Now write one byte"); |
CaptainR | 19:a259bc128867 | 239 | media_SetSector(1); |
CaptainR | 19:a259bc128867 | 240 | if (media_WriteByte('a')) puts("\n\r Write Byte : OK"); |
CaptainR | 19:a259bc128867 | 241 | else puts("\n\r Write Byte : FAIL"); |
CaptainR | 20:88e137b9ea46 | 242 | if (media_Flush()) puts("\n\r Flush : OK"); |
CaptainR | 20:88e137b9ea46 | 243 | else puts("\n\r Flush : FAIL"); |
CaptainR | 20:88e137b9ea46 | 244 | |
CaptainR | 20:88e137b9ea46 | 245 | puts("\n\r Now write one word (2 bytes)"); |
CaptainR | 20:88e137b9ea46 | 246 | //media_SetSector(1); |
CaptainR | 20:88e137b9ea46 | 247 | if (media_WriteWord(19)) puts("\n\r Write Word : OK"); |
CaptainR | 20:88e137b9ea46 | 248 | else puts("\n\r Write Word : FAIL"); |
CaptainR | 20:88e137b9ea46 | 249 | if (media_Flush()) puts("\n\r Flush : OK"); |
CaptainR | 20:88e137b9ea46 | 250 | else puts("\n\r Flush : FAIL"); |
CaptainR | 21:ea68a8a3cea4 | 251 | wait_ms(LONG_WAIT); |
CaptainR | 19:a259bc128867 | 252 | |
CaptainR | 12:29f5ad896382 | 253 | } |
CaptainR | 12:29f5ad896382 | 254 | //************************************************************************** |
CaptainR | 0:a5ef6bc3c2e8 | 255 | // Demo program that goes through graphics based functions |
CaptainR | 0:a5ef6bc3c2e8 | 256 | //************************************************************************** |
CaptainR | 3:dcfbceb81fef | 257 | void PICASO_4DGL :: graphicsDemo() { |
CaptainR | 0:a5ef6bc3c2e8 | 258 | |
CaptainR | 12:29f5ad896382 | 259 | |
CaptainR | 12:29f5ad896382 | 260 | cls(); |
CaptainR | 11:3ebd2263f3e9 | 261 | screenMode(landscape); // set orientation to landscape |
CaptainR | 0:a5ef6bc3c2e8 | 262 | puts("This is the Graphics functions demo"); |
CaptainR | 0:a5ef6bc3c2e8 | 263 | wait_ms(LONG_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 264 | cls(); |
CaptainR | 12:29f5ad896382 | 265 | |
CaptainR | 11:3ebd2263f3e9 | 266 | puts("\nLets change background color:"); |
CaptainR | 11:3ebd2263f3e9 | 267 | bgColor(Purple); |
CaptainR | 11:3ebd2263f3e9 | 268 | cls(); |
CaptainR | 11:3ebd2263f3e9 | 269 | wait_ms(SHORT_WAIT); |
CaptainR | 11:3ebd2263f3e9 | 270 | bgColor(White); |
CaptainR | 11:3ebd2263f3e9 | 271 | cls(); |
CaptainR | 11:3ebd2263f3e9 | 272 | wait_ms(SHORT_WAIT); |
CaptainR | 11:3ebd2263f3e9 | 273 | bgColor(Blue); |
CaptainR | 11:3ebd2263f3e9 | 274 | cls(); |
CaptainR | 11:3ebd2263f3e9 | 275 | wait_ms(SHORT_WAIT); |
CaptainR | 11:3ebd2263f3e9 | 276 | bgColor(Red); |
CaptainR | 11:3ebd2263f3e9 | 277 | cls(); |
CaptainR | 11:3ebd2263f3e9 | 278 | wait_ms(SHORT_WAIT); |
CaptainR | 11:3ebd2263f3e9 | 279 | bgColor(Aqua); |
CaptainR | 11:3ebd2263f3e9 | 280 | cls(); |
CaptainR | 11:3ebd2263f3e9 | 281 | wait_ms(SHORT_WAIT); |
CaptainR | 11:3ebd2263f3e9 | 282 | bgColor(Black); |
CaptainR | 11:3ebd2263f3e9 | 283 | cls(); |
CaptainR | 12:29f5ad896382 | 284 | wait_ms(LONG_WAIT); |
CaptainR | 12:29f5ad896382 | 285 | |
CaptainR | 11:3ebd2263f3e9 | 286 | puts("\nLets change contrast"); |
CaptainR | 11:3ebd2263f3e9 | 287 | wait_ms(LONG_WAIT); |
CaptainR | 11:3ebd2263f3e9 | 288 | contrast(DISABLE); |
CaptainR | 12:29f5ad896382 | 289 | wait_ms(LONG_WAIT); |
CaptainR | 11:3ebd2263f3e9 | 290 | contrast(ENABLE); |
CaptainR | 12:29f5ad896382 | 291 | wait_ms(LONG_WAIT); |
CaptainR | 11:3ebd2263f3e9 | 292 | cls(); |
CaptainR | 12:29f5ad896382 | 293 | |
CaptainR | 11:3ebd2263f3e9 | 294 | puts("\nLets change outline color "); |
CaptainR | 11:3ebd2263f3e9 | 295 | wait_ms(LONG_WAIT); |
CaptainR | 11:3ebd2263f3e9 | 296 | drawFilledCircle(50, 50, 20, Red); |
CaptainR | 11:3ebd2263f3e9 | 297 | wait_ms(SHORT_WAIT); |
CaptainR | 11:3ebd2263f3e9 | 298 | outlineColor(White); |
CaptainR | 11:3ebd2263f3e9 | 299 | wait_ms(SHORT_WAIT); |
CaptainR | 11:3ebd2263f3e9 | 300 | drawFilledCircle(100, 50, 20, Red); |
CaptainR | 11:3ebd2263f3e9 | 301 | wait_ms(LONG_WAIT); |
CaptainR | 11:3ebd2263f3e9 | 302 | cls(); |
CaptainR | 12:29f5ad896382 | 303 | |
CaptainR | 0:a5ef6bc3c2e8 | 304 | puts("\nLets change all the "); |
CaptainR | 2:81eaaa491a02 | 305 | textFgColor(Purple); |
CaptainR | 0:a5ef6bc3c2e8 | 306 | puts("PURPLE"); |
CaptainR | 2:81eaaa491a02 | 307 | textFgColor(Yellow); |
CaptainR | 0:a5ef6bc3c2e8 | 308 | puts(" bits to yellow"); |
CaptainR | 3:dcfbceb81fef | 309 | textFgColor(Green); // set Color back to green |
CaptainR | 0:a5ef6bc3c2e8 | 310 | wait_ms(LONG_WAIT); |
CaptainR | 2:81eaaa491a02 | 311 | changeColor(Purple, Yellow); |
CaptainR | 0:a5ef6bc3c2e8 | 312 | wait_ms(LONG_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 313 | cls(); |
CaptainR | 12:29f5ad896382 | 314 | |
CaptainR | 0:a5ef6bc3c2e8 | 315 | puts("Lets draw some shapes:"); |
CaptainR | 3:dcfbceb81fef | 316 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 317 | drawCircle(100, 100, 20, Aqua); |
CaptainR | 3:dcfbceb81fef | 318 | wait_ms(SHORT_WAIT); |
CaptainR | 3:dcfbceb81fef | 319 | drawFilledCircle(50, 50, 20, Red); |
CaptainR | 3:dcfbceb81fef | 320 | wait_ms(SHORT_WAIT); |
CaptainR | 3:dcfbceb81fef | 321 | drawLine(20, 20, 100, 30, Blue); |
CaptainR | 3:dcfbceb81fef | 322 | wait_ms(SHORT_WAIT); |
CaptainR | 3:dcfbceb81fef | 323 | drawRectangle(120, 20, 200, 60, Pink); |
CaptainR | 3:dcfbceb81fef | 324 | wait_ms(SHORT_WAIT); |
CaptainR | 3:dcfbceb81fef | 325 | drawFilledRectangle(210, 0, 250, 80, Orange); |
CaptainR | 3:dcfbceb81fef | 326 | wait_ms(SHORT_WAIT); |
CaptainR | 3:dcfbceb81fef | 327 | short xPolyline[3] = {10, 80, 180}; |
CaptainR | 3:dcfbceb81fef | 328 | short yPolyline[3] = {10, 200, 80}; |
CaptainR | 3:dcfbceb81fef | 329 | drawPolyline(3, xPolyline, yPolyline, Green); |
CaptainR | 3:dcfbceb81fef | 330 | wait_ms(SHORT_WAIT); |
CaptainR | 3:dcfbceb81fef | 331 | short xPolygon[5] = {0, 30, 5, 50, 40}; |
CaptainR | 3:dcfbceb81fef | 332 | short yPolygon[5] = {50, 100, 220, 230, 170}; |
CaptainR | 3:dcfbceb81fef | 333 | drawPolygon(5, xPolygon, yPolygon, Grey); |
CaptainR | 3:dcfbceb81fef | 334 | wait_ms(SHORT_WAIT); |
CaptainR | 3:dcfbceb81fef | 335 | short xFilledPolygon[5] = {260, 280, 290, 300, 255}; |
CaptainR | 3:dcfbceb81fef | 336 | short yFilledPolygon[5] = {0, 20, 35, 55, 22}; |
CaptainR | 3:dcfbceb81fef | 337 | drawFilledPolygon(5, xFilledPolygon, yFilledPolygon, White); |
CaptainR | 3:dcfbceb81fef | 338 | wait_ms(SHORT_WAIT); |
CaptainR | 3:dcfbceb81fef | 339 | drawTriangle(70, 130, 90, 150, 110, 120, Cream); |
CaptainR | 3:dcfbceb81fef | 340 | wait_ms(SHORT_WAIT); |
CaptainR | 3:dcfbceb81fef | 341 | drawFilledTriangle(260, 50, 300, 90, 240, 120, Yellow); |
CaptainR | 3:dcfbceb81fef | 342 | wait_ms(SHORT_WAIT); |
CaptainR | 10:b959bb206e6b | 343 | drawElipse(200, 130, 20, 10, Olive); |
CaptainR | 10:b959bb206e6b | 344 | wait_ms(SHORT_WAIT); |
CaptainR | 10:b959bb206e6b | 345 | drawFilledElipse(200, 100, 30, 20, Navy); |
CaptainR | 12:29f5ad896382 | 346 | wait_ms(SHORT_WAIT); |
CaptainR | 11:3ebd2263f3e9 | 347 | linePatern(10); |
CaptainR | 11:3ebd2263f3e9 | 348 | drawLine(200, 200, 100, 300, White); |
CaptainR | 11:3ebd2263f3e9 | 349 | wait_ms(LONG_WAIT); |
CaptainR | 4:50511ed54ab4 | 350 | cls(); |
CaptainR | 12:29f5ad896382 | 351 | |
CaptainR | 6:a1a85f2bc04b | 352 | /* |
CaptainR | 6:a1a85f2bc04b | 353 | // somehow after this function display stops (but the calculation is right) |
CaptainR | 4:50511ed54ab4 | 354 | puts("Lets calculate distance from point 0,0 on angle 40, 60 pixels away:"); |
CaptainR | 4:50511ed54ab4 | 355 | wait_ms(LONG_WAIT); |
CaptainR | 4:50511ed54ab4 | 356 | cls(); |
CaptainR | 4:50511ed54ab4 | 357 | calculateOrbit(40, 60); |
CaptainR | 6:a1a85f2bc04b | 358 | wait_ms(SHORT_WAIT); |
CaptainR | 6:a1a85f2bc04b | 359 | cls(); |
CaptainR | 6:a1a85f2bc04b | 360 | */ |
CaptainR | 12:29f5ad896382 | 361 | |
CaptainR | 6:a1a85f2bc04b | 362 | puts("Lets draw some pixels:"); |
CaptainR | 6:a1a85f2bc04b | 363 | wait_ms(LONG_WAIT); |
CaptainR | 12:29f5ad896382 | 364 | cls(); |
CaptainR | 12:29f5ad896382 | 365 | for (int i = 0; i <= 10; i++) { |
CaptainR | 12:29f5ad896382 | 366 | for (int j = 0; j <= 10; j++) { |
CaptainR | 12:29f5ad896382 | 367 | putPixel(i, j, Red); |
CaptainR | 12:29f5ad896382 | 368 | } |
CaptainR | 12:29f5ad896382 | 369 | } |
CaptainR | 6:a1a85f2bc04b | 370 | wait_ms(LONG_WAIT); |
CaptainR | 6:a1a85f2bc04b | 371 | cls(); |
CaptainR | 12:29f5ad896382 | 372 | |
CaptainR | 7:f064ae670553 | 373 | puts("Lets move origin point:"); |
CaptainR | 7:f064ae670553 | 374 | wait_ms(LONG_WAIT); |
CaptainR | 7:f064ae670553 | 375 | moveOrigin(100, 100); |
CaptainR | 7:f064ae670553 | 376 | puts("This is the new origin!"); |
CaptainR | 8:b634ac9c92f8 | 377 | wait_ms(LONG_WAIT); |
CaptainR | 8:b634ac9c92f8 | 378 | cls(); |
CaptainR | 12:29f5ad896382 | 379 | |
CaptainR | 8:b634ac9c92f8 | 380 | puts("Now draw line from here:"); |
CaptainR | 8:b634ac9c92f8 | 381 | wait_ms(SHORT_WAIT); |
CaptainR | 8:b634ac9c92f8 | 382 | lineTo(100, 100); |
CaptainR | 12:29f5ad896382 | 383 | wait_ms(LONG_WAIT); |
CaptainR | 8:b634ac9c92f8 | 384 | puts("To here!"); |
CaptainR | 8:b634ac9c92f8 | 385 | wait_ms(LONG_WAIT); |
CaptainR | 9:32eb75c01e9d | 386 | cls(); |
CaptainR | 12:29f5ad896382 | 387 | |
CaptainR | 9:32eb75c01e9d | 388 | puts("Change clipping window, to test it, we use changeColor function, that works only in clipping area:"); |
CaptainR | 9:32eb75c01e9d | 389 | wait_ms(LONG_WAIT); |
CaptainR | 12:29f5ad896382 | 390 | wait_ms(LONG_WAIT); |
CaptainR | 9:32eb75c01e9d | 391 | setClipWindow(0, 0, 200, 20); |
CaptainR | 9:32eb75c01e9d | 392 | changeColor(Green, Red); |
CaptainR | 9:32eb75c01e9d | 393 | puts("\n\n\rDone!!!!"); |
CaptainR | 9:32eb75c01e9d | 394 | wait_ms(LONG_WAIT); |
CaptainR | 9:32eb75c01e9d | 395 | puts("\n\n\rNow extend to here!"); |
CaptainR | 12:29f5ad896382 | 396 | wait_ms(LONG_WAIT); |
CaptainR | 9:32eb75c01e9d | 397 | extendClipRegion(); |
CaptainR | 9:32eb75c01e9d | 398 | changeColor(Green, Red); |
CaptainR | 9:32eb75c01e9d | 399 | puts("\n\n\rHow does it look?"); |
CaptainR | 9:32eb75c01e9d | 400 | wait_ms(LONG_WAIT); |
CaptainR | 10:b959bb206e6b | 401 | cls(); |
CaptainR | 12:29f5ad896382 | 402 | |
CaptainR | 10:b959bb206e6b | 403 | puts("\nLets place a button:"); |
CaptainR | 10:b959bb206e6b | 404 | wait_ms(LONG_WAIT); |
CaptainR | 10:b959bb206e6b | 405 | cls(); |
CaptainR | 12:29f5ad896382 | 406 | drawButton(DEPRESSED, 100, 100, Aqua, Violet, 2, 2, 2, "Press Me"); |
CaptainR | 10:b959bb206e6b | 407 | puts("\n\n\n\nDid it work?"); |
CaptainR | 10:b959bb206e6b | 408 | wait_ms(LONG_WAIT); |
CaptainR | 11:3ebd2263f3e9 | 409 | cls(); |
CaptainR | 12:29f5ad896382 | 410 | |
CaptainR | 11:3ebd2263f3e9 | 411 | puts("\nNow lets change bevel width"); |
CaptainR | 11:3ebd2263f3e9 | 412 | wait_ms(LONG_WAIT); |
CaptainR | 11:3ebd2263f3e9 | 413 | if (bevelWidth(0)) { |
CaptainR | 11:3ebd2263f3e9 | 414 | puts("\nNo bevel"); |
CaptainR | 12:29f5ad896382 | 415 | drawButton(DEPRESSED, 100, 100, Aqua, Violet, 2, 2, 2, "Press Me"); |
CaptainR | 11:3ebd2263f3e9 | 416 | } |
CaptainR | 12:29f5ad896382 | 417 | wait_ms(LONG_WAIT); |
CaptainR | 11:3ebd2263f3e9 | 418 | cls(); |
CaptainR | 11:3ebd2263f3e9 | 419 | if (bevelWidth(1)) { |
CaptainR | 11:3ebd2263f3e9 | 420 | puts("\nbevel 1"); |
CaptainR | 12:29f5ad896382 | 421 | drawButton(DEPRESSED, 100, 100, Aqua, Violet, 2, 2, 2, "Press Me"); |
CaptainR | 11:3ebd2263f3e9 | 422 | } |
CaptainR | 12:29f5ad896382 | 423 | wait_ms(LONG_WAIT); |
CaptainR | 11:3ebd2263f3e9 | 424 | cls(); |
CaptainR | 11:3ebd2263f3e9 | 425 | if (bevelWidth(10)) { |
CaptainR | 11:3ebd2263f3e9 | 426 | puts("\nbevel 10"); |
CaptainR | 12:29f5ad896382 | 427 | drawButton(DEPRESSED, 100, 100, Aqua, Violet, 2, 2, 2, "Press Me"); |
CaptainR | 11:3ebd2263f3e9 | 428 | } |
CaptainR | 12:29f5ad896382 | 429 | wait_ms(LONG_WAIT); |
CaptainR | 11:3ebd2263f3e9 | 430 | cls(); |
CaptainR | 11:3ebd2263f3e9 | 431 | if (bevelWidth(16)) { |
CaptainR | 11:3ebd2263f3e9 | 432 | puts("\nbevel 16"); |
CaptainR | 12:29f5ad896382 | 433 | drawButton(DEPRESSED, 100, 100, Aqua, Violet, 2, 2, 2, "Press Me"); |
CaptainR | 11:3ebd2263f3e9 | 434 | } |
CaptainR | 12:29f5ad896382 | 435 | wait_ms(LONG_WAIT); |
CaptainR | 11:3ebd2263f3e9 | 436 | cls(); |
CaptainR | 11:3ebd2263f3e9 | 437 | if (bevelWidth(2)) { |
CaptainR | 11:3ebd2263f3e9 | 438 | puts("\nbevel 2"); |
CaptainR | 12:29f5ad896382 | 439 | drawButton(DEPRESSED, 100, 100, Aqua, Violet, 2, 2, 2, "Press Me"); |
CaptainR | 11:3ebd2263f3e9 | 440 | } |
CaptainR | 12:29f5ad896382 | 441 | wait_ms(LONG_WAIT); |
CaptainR | 11:3ebd2263f3e9 | 442 | cls(); |
CaptainR | 12:29f5ad896382 | 443 | |
CaptainR | 10:b959bb206e6b | 444 | puts("\nNow lets change bevel shadow level"); |
CaptainR | 10:b959bb206e6b | 445 | wait_ms(LONG_WAIT); |
CaptainR | 11:3ebd2263f3e9 | 446 | if (bevelShadow(0)) { |
CaptainR | 11:3ebd2263f3e9 | 447 | puts("\nNo shadow"); |
CaptainR | 12:29f5ad896382 | 448 | drawButton(DEPRESSED, 100, 100, Aqua, Violet, 2, 2, 2, "Press Me"); |
CaptainR | 11:3ebd2263f3e9 | 449 | } |
CaptainR | 10:b959bb206e6b | 450 | wait_ms(SHORT_WAIT); |
CaptainR | 11:3ebd2263f3e9 | 451 | if (bevelShadow(1)) { |
CaptainR | 11:3ebd2263f3e9 | 452 | puts("\nShadow 1"); |
CaptainR | 12:29f5ad896382 | 453 | drawButton(DEPRESSED, 100, 100, Aqua, Violet, 2, 2, 2, "Press Me"); |
CaptainR | 11:3ebd2263f3e9 | 454 | } |
CaptainR | 10:b959bb206e6b | 455 | wait_ms(SHORT_WAIT); |
CaptainR | 11:3ebd2263f3e9 | 456 | if (bevelShadow(2)) { |
CaptainR | 11:3ebd2263f3e9 | 457 | puts("\nShadow 2"); |
CaptainR | 12:29f5ad896382 | 458 | drawButton(DEPRESSED, 100, 100, Aqua, Violet, 2, 2, 2, "Press Me"); |
CaptainR | 11:3ebd2263f3e9 | 459 | } |
CaptainR | 10:b959bb206e6b | 460 | wait_ms(SHORT_WAIT); |
CaptainR | 11:3ebd2263f3e9 | 461 | if (bevelShadow(3)) { |
CaptainR | 11:3ebd2263f3e9 | 462 | puts("\nShadow 3"); |
CaptainR | 12:29f5ad896382 | 463 | drawButton(DEPRESSED, 100, 100, Aqua, Violet, 2, 2, 2, "Press Me"); |
CaptainR | 11:3ebd2263f3e9 | 464 | } |
CaptainR | 11:3ebd2263f3e9 | 465 | wait_ms(SHORT_WAIT); |
CaptainR | 11:3ebd2263f3e9 | 466 | if (bevelShadow(4)) { |
CaptainR | 11:3ebd2263f3e9 | 467 | puts("\nShadow 4"); |
CaptainR | 12:29f5ad896382 | 468 | drawButton(DEPRESSED, 100, 100, Aqua, Violet, 2, 2, 2, "Press Me"); |
CaptainR | 11:3ebd2263f3e9 | 469 | } |
CaptainR | 10:b959bb206e6b | 470 | wait_ms(SHORT_WAIT); |
CaptainR | 11:3ebd2263f3e9 | 471 | if (bevelShadow(5)) { |
CaptainR | 11:3ebd2263f3e9 | 472 | puts("\nShadow 5"); |
CaptainR | 12:29f5ad896382 | 473 | drawButton(DEPRESSED, 100, 100, Aqua, Violet, 2, 2, 2, "Press Me"); |
CaptainR | 11:3ebd2263f3e9 | 474 | } |
CaptainR | 10:b959bb206e6b | 475 | wait_ms(SHORT_WAIT); |
CaptainR | 11:3ebd2263f3e9 | 476 | if (bevelShadow(1)) { |
CaptainR | 11:3ebd2263f3e9 | 477 | puts("\nShadow 1"); |
CaptainR | 12:29f5ad896382 | 478 | drawButton(DEPRESSED, 100, 100, Aqua, Violet, 2, 2, 2, "Press Me"); |
CaptainR | 11:3ebd2263f3e9 | 479 | } |
CaptainR | 12:29f5ad896382 | 480 | wait_ms(LONG_WAIT); |
CaptainR | 11:3ebd2263f3e9 | 481 | cls(); |
CaptainR | 12:29f5ad896382 | 482 | |
CaptainR | 10:b959bb206e6b | 483 | puts("\nLets place a panel:"); |
CaptainR | 10:b959bb206e6b | 484 | wait_ms(LONG_WAIT); |
CaptainR | 10:b959bb206e6b | 485 | cls(); |
CaptainR | 12:29f5ad896382 | 486 | drawPanel(RECESSED, 0, 0, 200, 20, Cream); |
CaptainR | 12:29f5ad896382 | 487 | wait_ms(SHORT_WAIT); |
CaptainR | 10:b959bb206e6b | 488 | puts("\nDid it work?"); |
CaptainR | 10:b959bb206e6b | 489 | wait_ms(LONG_WAIT); |
CaptainR | 10:b959bb206e6b | 490 | cls(); |
CaptainR | 12:29f5ad896382 | 491 | |
CaptainR | 10:b959bb206e6b | 492 | puts("\nLets place a slider:"); |
CaptainR | 10:b959bb206e6b | 493 | wait_ms(LONG_WAIT); |
CaptainR | 10:b959bb206e6b | 494 | cls(); |
CaptainR | 10:b959bb206e6b | 495 | drawSlider(RAISED, 30, 40, 210, 90, Violet, 100, 0); |
CaptainR | 10:b959bb206e6b | 496 | puts("\nDid it work?"); |
CaptainR | 10:b959bb206e6b | 497 | wait_ms(LONG_WAIT); |
CaptainR | 10:b959bb206e6b | 498 | cls(); |
CaptainR | 12:29f5ad896382 | 499 | |
CaptainR | 10:b959bb206e6b | 500 | puts("\nThis particular function is going to copy a specified portion of the creen and paste it somewhere else!"); |
CaptainR | 10:b959bb206e6b | 501 | wait_ms(LONG_WAIT); |
CaptainR | 10:b959bb206e6b | 502 | wait_ms(LONG_WAIT); |
CaptainR | 12:29f5ad896382 | 503 | wait_ms(LONG_WAIT); |
CaptainR | 10:b959bb206e6b | 504 | //cls(); |
CaptainR | 10:b959bb206e6b | 505 | screenCopyPaste(0, 0, 50, 100, 200, 50); |
CaptainR | 10:b959bb206e6b | 506 | puts("\nDid it work?"); |
CaptainR | 10:b959bb206e6b | 507 | wait_ms(LONG_WAIT); |
CaptainR | 10:b959bb206e6b | 508 | cls(); |
CaptainR | 12:29f5ad896382 | 509 | |
CaptainR | 11:3ebd2263f3e9 | 510 | puts("\nLets get Xmax:"); |
CaptainR | 11:3ebd2263f3e9 | 511 | wait_ms(LONG_WAIT); |
CaptainR | 11:3ebd2263f3e9 | 512 | short Xmax = getGraphics(currentXMax); |
CaptainR | 11:3ebd2263f3e9 | 513 | puts("\nLets get Ymax:"); |
CaptainR | 11:3ebd2263f3e9 | 514 | wait_ms(LONG_WAIT); |
CaptainR | 11:3ebd2263f3e9 | 515 | short Ymax = getGraphics(currentYMax); |
CaptainR | 11:3ebd2263f3e9 | 516 | wait_ms(LONG_WAIT); |
CaptainR | 11:3ebd2263f3e9 | 517 | pc.printf("\nCurrent orientation xMax = %i, yMax = %i\n\r", Xmax, Ymax); |
CaptainR | 12:29f5ad896382 | 518 | cls(); |
CaptainR | 21:ea68a8a3cea4 | 519 | wait_ms(LONG_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 520 | } |
CaptainR | 0:a5ef6bc3c2e8 | 521 | |
CaptainR | 0:a5ef6bc3c2e8 | 522 | //************************************************************************** |
CaptainR | 0:a5ef6bc3c2e8 | 523 | // Demo program that goes through main functions |
CaptainR | 0:a5ef6bc3c2e8 | 524 | //************************************************************************** |
CaptainR | 3:dcfbceb81fef | 525 | void PICASO_4DGL :: mainDemo() { |
CaptainR | 0:a5ef6bc3c2e8 | 526 | |
CaptainR | 0:a5ef6bc3c2e8 | 527 | cls(); |
CaptainR | 0:a5ef6bc3c2e8 | 528 | puts("This is the main functions demo"); |
CaptainR | 0:a5ef6bc3c2e8 | 529 | wait_ms(LONG_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 530 | cls(); |
CaptainR | 12:29f5ad896382 | 531 | /* |
CaptainR | 0:a5ef6bc3c2e8 | 532 | puts("\nBaudrates:"); |
CaptainR | 0:a5ef6bc3c2e8 | 533 | wait_ms(LONG_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 534 | cls(); |
CaptainR | 12:29f5ad896382 | 535 | |
CaptainR | 0:a5ef6bc3c2e8 | 536 | baudrate(4800); |
CaptainR | 0:a5ef6bc3c2e8 | 537 | puts("\n4800"); |
CaptainR | 0:a5ef6bc3c2e8 | 538 | wait_ms(SHORT_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 539 | cls(); |
CaptainR | 0:a5ef6bc3c2e8 | 540 | baudrate(9600); |
CaptainR | 0:a5ef6bc3c2e8 | 541 | puts("\n9600"); |
CaptainR | 0:a5ef6bc3c2e8 | 542 | wait_ms(SHORT_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 543 | cls(); |
CaptainR | 0:a5ef6bc3c2e8 | 544 | baudrate(14400); |
CaptainR | 0:a5ef6bc3c2e8 | 545 | puts("\n14400"); |
CaptainR | 0:a5ef6bc3c2e8 | 546 | wait_ms(SHORT_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 547 | cls(); |
CaptainR | 0:a5ef6bc3c2e8 | 548 | baudrate(19200); |
CaptainR | 0:a5ef6bc3c2e8 | 549 | puts("\n19200"); |
CaptainR | 0:a5ef6bc3c2e8 | 550 | wait_ms(SHORT_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 551 | cls(); |
CaptainR | 0:a5ef6bc3c2e8 | 552 | baudrate(38400); |
CaptainR | 0:a5ef6bc3c2e8 | 553 | puts("\n38400"); |
CaptainR | 0:a5ef6bc3c2e8 | 554 | wait_ms(SHORT_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 555 | cls(); |
CaptainR | 0:a5ef6bc3c2e8 | 556 | baudrate(56000); |
CaptainR | 0:a5ef6bc3c2e8 | 557 | puts("\n56000"); |
CaptainR | 0:a5ef6bc3c2e8 | 558 | wait_ms(SHORT_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 559 | cls(); |
CaptainR | 0:a5ef6bc3c2e8 | 560 | baudrate(57600); |
CaptainR | 0:a5ef6bc3c2e8 | 561 | puts("\n57600"); |
CaptainR | 0:a5ef6bc3c2e8 | 562 | wait_ms(SHORT_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 563 | cls(); |
CaptainR | 12:29f5ad896382 | 564 | baudrate(9600); |
CaptainR | 12:29f5ad896382 | 565 | puts("\n9600"); |
CaptainR | 2:81eaaa491a02 | 566 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 567 | cls(); |
CaptainR | 12:29f5ad896382 | 568 | */ |
CaptainR | 0:a5ef6bc3c2e8 | 569 | puts("\nOrientation:"); |
CaptainR | 0:a5ef6bc3c2e8 | 570 | wait_ms(LONG_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 571 | cls(); |
CaptainR | 11:3ebd2263f3e9 | 572 | screenMode(landscape); |
CaptainR | 0:a5ef6bc3c2e8 | 573 | puts("landscape"); |
CaptainR | 0:a5ef6bc3c2e8 | 574 | wait_ms(SHORT_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 575 | cls(); |
CaptainR | 11:3ebd2263f3e9 | 576 | screenMode(landscapeRew); |
CaptainR | 0:a5ef6bc3c2e8 | 577 | puts("landscape rewersed"); |
CaptainR | 0:a5ef6bc3c2e8 | 578 | wait_ms(SHORT_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 579 | cls(); |
CaptainR | 11:3ebd2263f3e9 | 580 | screenMode(portrait); |
CaptainR | 0:a5ef6bc3c2e8 | 581 | puts("portrait"); |
CaptainR | 0:a5ef6bc3c2e8 | 582 | wait_ms(SHORT_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 583 | cls(); |
CaptainR | 11:3ebd2263f3e9 | 584 | screenMode(portraitRew); |
CaptainR | 0:a5ef6bc3c2e8 | 585 | puts("portrait rewersed"); |
CaptainR | 0:a5ef6bc3c2e8 | 586 | wait_ms(LONG_WAIT); |
CaptainR | 11:3ebd2263f3e9 | 587 | screenMode(landscape); // set back screen to landscape |
CaptainR | 0:a5ef6bc3c2e8 | 588 | cls(); |
CaptainR | 0:a5ef6bc3c2e8 | 589 | |
CaptainR | 0:a5ef6bc3c2e8 | 590 | } |
CaptainR | 0:a5ef6bc3c2e8 | 591 | |
CaptainR | 0:a5ef6bc3c2e8 | 592 | //************************************************************************** |
CaptainR | 0:a5ef6bc3c2e8 | 593 | // Demo program that goes through text based functions |
CaptainR | 0:a5ef6bc3c2e8 | 594 | //************************************************************************** |
CaptainR | 3:dcfbceb81fef | 595 | void PICASO_4DGL :: textDemo() { |
CaptainR | 0:a5ef6bc3c2e8 | 596 | |
CaptainR | 0:a5ef6bc3c2e8 | 597 | cls(); |
CaptainR | 11:3ebd2263f3e9 | 598 | screenMode(landscape); // set screen to landscape |
CaptainR | 0:a5ef6bc3c2e8 | 599 | puts("This is the Text functions demo"); |
CaptainR | 0:a5ef6bc3c2e8 | 600 | wait_ms(LONG_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 601 | cls(); |
CaptainR | 0:a5ef6bc3c2e8 | 602 | |
CaptainR | 0:a5ef6bc3c2e8 | 603 | puts("\nText attributes:"); |
CaptainR | 0:a5ef6bc3c2e8 | 604 | wait_ms(LONG_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 605 | //cls(); |
CaptainR | 0:a5ef6bc3c2e8 | 606 | puts("\n\n"); |
CaptainR | 2:81eaaa491a02 | 607 | textAttributes(bold); |
CaptainR | 0:a5ef6bc3c2e8 | 608 | puts("\nBOLD"); |
CaptainR | 0:a5ef6bc3c2e8 | 609 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 610 | textAttributes(bold + italic); |
CaptainR | 0:a5ef6bc3c2e8 | 611 | puts("\nBOLD & ITALIC"); |
CaptainR | 0:a5ef6bc3c2e8 | 612 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 613 | textAttributes(bold + italic + inverse); |
CaptainR | 0:a5ef6bc3c2e8 | 614 | puts("\nBOLD & ITALIC & INVERSE"); |
CaptainR | 0:a5ef6bc3c2e8 | 615 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 616 | textAttributes(bold + italic + inverse + underline); |
CaptainR | 0:a5ef6bc3c2e8 | 617 | puts("\nBOLD & ITALIC & INVERSE & UNDERLINE"); |
CaptainR | 0:a5ef6bc3c2e8 | 618 | wait_ms(LONG_WAIT); |
CaptainR | 2:81eaaa491a02 | 619 | textAttributes(DISABLE); // set everything back to normal |
CaptainR | 0:a5ef6bc3c2e8 | 620 | cls(); |
CaptainR | 0:a5ef6bc3c2e8 | 621 | |
CaptainR | 0:a5ef6bc3c2e8 | 622 | puts("\nText modes:"); |
CaptainR | 0:a5ef6bc3c2e8 | 623 | wait_ms(LONG_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 624 | cls(); |
CaptainR | 2:81eaaa491a02 | 625 | textBold(ENABLE); |
CaptainR | 0:a5ef6bc3c2e8 | 626 | puts("\nBOLD:"); |
CaptainR | 0:a5ef6bc3c2e8 | 627 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 628 | textBold(DISABLE); |
CaptainR | 2:81eaaa491a02 | 629 | textInverse(ENABLE); |
CaptainR | 0:a5ef6bc3c2e8 | 630 | puts("\nINVERSE:"); |
CaptainR | 0:a5ef6bc3c2e8 | 631 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 632 | textInverse(DISABLE); |
CaptainR | 2:81eaaa491a02 | 633 | textItalic(ENABLE); |
CaptainR | 0:a5ef6bc3c2e8 | 634 | puts("\nITALIC:"); |
CaptainR | 0:a5ef6bc3c2e8 | 635 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 636 | textItalic(DISABLE); |
CaptainR | 2:81eaaa491a02 | 637 | textUnderline(ENABLE); |
CaptainR | 0:a5ef6bc3c2e8 | 638 | puts("\nUNDERLINE:"); |
CaptainR | 0:a5ef6bc3c2e8 | 639 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 640 | textUnderline(DISABLE); |
CaptainR | 0:a5ef6bc3c2e8 | 641 | wait_ms(LONG_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 642 | cls(); |
CaptainR | 0:a5ef6bc3c2e8 | 643 | |
CaptainR | 0:a5ef6bc3c2e8 | 644 | puts("\nText gaps:"); |
CaptainR | 0:a5ef6bc3c2e8 | 645 | wait_ms(LONG_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 646 | cls(); |
CaptainR | 0:a5ef6bc3c2e8 | 647 | if (textXGap(0) == 1) puts("\nX gap: 0"); |
CaptainR | 0:a5ef6bc3c2e8 | 648 | wait_ms(SHORT_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 649 | if (textXGap(1) == 1) puts("\nX gap: 1"); |
CaptainR | 0:a5ef6bc3c2e8 | 650 | wait_ms(SHORT_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 651 | if (textXGap(2) == 1) puts("\nX gap: 2"); |
CaptainR | 0:a5ef6bc3c2e8 | 652 | wait_ms(SHORT_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 653 | if (textXGap(3) == 1) puts("\nX gap: 3"); |
CaptainR | 0:a5ef6bc3c2e8 | 654 | wait_ms(SHORT_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 655 | if (textXGap(4) == 1) puts("\nX gap: 4"); |
CaptainR | 0:a5ef6bc3c2e8 | 656 | wait_ms(SHORT_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 657 | if (textXGap(5) == 1) puts("\nX gap: 5"); |
CaptainR | 0:a5ef6bc3c2e8 | 658 | wait_ms(SHORT_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 659 | if (textXGap(6) == 1) puts("\nX gap: 6"); |
CaptainR | 0:a5ef6bc3c2e8 | 660 | wait_ms(SHORT_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 661 | puts("\n"); |
CaptainR | 0:a5ef6bc3c2e8 | 662 | textXGap(0); |
CaptainR | 0:a5ef6bc3c2e8 | 663 | if (textYGap(0) == 1) puts("\nY gap: 0"); |
CaptainR | 0:a5ef6bc3c2e8 | 664 | wait_ms(SHORT_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 665 | if (textYGap(1) == 1) puts("\nY gap: 1"); |
CaptainR | 0:a5ef6bc3c2e8 | 666 | wait_ms(SHORT_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 667 | if (textYGap(2) == 1) puts("\nY gap: 2"); |
CaptainR | 0:a5ef6bc3c2e8 | 668 | wait_ms(SHORT_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 669 | if (textYGap(3) == 1) puts("\nY gap: 3"); |
CaptainR | 0:a5ef6bc3c2e8 | 670 | wait_ms(SHORT_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 671 | if (textYGap(4) == 1) puts("\nY gap: 4"); |
CaptainR | 0:a5ef6bc3c2e8 | 672 | wait_ms(SHORT_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 673 | if (textYGap(5) == 1) puts("\nY gap: 5"); |
CaptainR | 0:a5ef6bc3c2e8 | 674 | wait_ms(SHORT_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 675 | if (textYGap(6) == 1) puts("\nY gap: 6"); |
CaptainR | 0:a5ef6bc3c2e8 | 676 | wait_ms(LONG_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 677 | textYGap(0); |
CaptainR | 0:a5ef6bc3c2e8 | 678 | cls(); |
CaptainR | 0:a5ef6bc3c2e8 | 679 | |
CaptainR | 0:a5ef6bc3c2e8 | 680 | puts("Text width:"); |
CaptainR | 0:a5ef6bc3c2e8 | 681 | wait_ms(LONG_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 682 | if (textWidth(1) == 1) puts("\nWidth: 1"); |
CaptainR | 0:a5ef6bc3c2e8 | 683 | wait_ms(SHORT_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 684 | if (textWidth(2) == 1) puts("\nWidth: 2"); |
CaptainR | 0:a5ef6bc3c2e8 | 685 | wait_ms(SHORT_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 686 | if (textWidth(3) == 1) puts("\nWidth: 3"); |
CaptainR | 0:a5ef6bc3c2e8 | 687 | wait_ms(SHORT_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 688 | if (textWidth(4) == 1) puts("\nWidth: 4"); |
CaptainR | 0:a5ef6bc3c2e8 | 689 | wait_ms(SHORT_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 690 | textWidth(1); |
CaptainR | 0:a5ef6bc3c2e8 | 691 | puts("\nText height:"); |
CaptainR | 0:a5ef6bc3c2e8 | 692 | wait_ms(LONG_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 693 | //cls(); |
CaptainR | 0:a5ef6bc3c2e8 | 694 | if (textHeight(1) == 1) puts("\nHeight: 1"); |
CaptainR | 0:a5ef6bc3c2e8 | 695 | wait_ms(SHORT_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 696 | if (textHeight(2) == 1) puts("\nHeight: 2"); |
CaptainR | 0:a5ef6bc3c2e8 | 697 | wait_ms(SHORT_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 698 | if (textHeight(3) == 1) puts("\nHeight: 3"); |
CaptainR | 0:a5ef6bc3c2e8 | 699 | wait_ms(SHORT_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 700 | if (textHeight(4) == 1) puts("\nHeight: 4"); |
CaptainR | 0:a5ef6bc3c2e8 | 701 | wait_ms(LONG_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 702 | textHeight(1); |
CaptainR | 0:a5ef6bc3c2e8 | 703 | cls(); |
CaptainR | 2:81eaaa491a02 | 704 | |
CaptainR | 0:a5ef6bc3c2e8 | 705 | puts("Fonts:"); |
CaptainR | 0:a5ef6bc3c2e8 | 706 | wait_ms(LONG_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 707 | cls(); |
CaptainR | 2:81eaaa491a02 | 708 | setFont(font1); |
CaptainR | 0:a5ef6bc3c2e8 | 709 | puts("\nThis is Font 1"); |
CaptainR | 0:a5ef6bc3c2e8 | 710 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 711 | setFont(font2); |
CaptainR | 0:a5ef6bc3c2e8 | 712 | puts("\nThis is Font 2"); |
CaptainR | 0:a5ef6bc3c2e8 | 713 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 714 | setFont(font3); |
CaptainR | 0:a5ef6bc3c2e8 | 715 | puts("\nThis is Font 3"); |
CaptainR | 0:a5ef6bc3c2e8 | 716 | wait_ms(LONG_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 717 | cls(); |
CaptainR | 0:a5ef6bc3c2e8 | 718 | |
CaptainR | 2:81eaaa491a02 | 719 | |
CaptainR | 11:3ebd2263f3e9 | 720 | screenMode(portrait); |
CaptainR | 0:a5ef6bc3c2e8 | 721 | puts("\nText Background colors:"); |
CaptainR | 0:a5ef6bc3c2e8 | 722 | wait_ms(LONG_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 723 | cls(); |
CaptainR | 2:81eaaa491a02 | 724 | textBgColor(Black); |
CaptainR | 3:dcfbceb81fef | 725 | puts("\nBG Color = BLACK"); |
CaptainR | 0:a5ef6bc3c2e8 | 726 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 727 | textBgColor(Navy); |
CaptainR | 3:dcfbceb81fef | 728 | puts("\nBG Color = NAVY"); |
CaptainR | 0:a5ef6bc3c2e8 | 729 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 730 | textFgColor(Black); |
CaptainR | 2:81eaaa491a02 | 731 | textBgColor(DGreen); |
CaptainR | 3:dcfbceb81fef | 732 | puts("\nBG Color = DARK GREEN"); |
CaptainR | 0:a5ef6bc3c2e8 | 733 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 734 | textBgColor(DCyan); |
CaptainR | 3:dcfbceb81fef | 735 | puts("\nBG Color = DARK CYAN"); |
CaptainR | 0:a5ef6bc3c2e8 | 736 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 737 | textBgColor(Purple); |
CaptainR | 3:dcfbceb81fef | 738 | puts("\nBG Color = PURPLE"); |
CaptainR | 0:a5ef6bc3c2e8 | 739 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 740 | textBgColor(Olive); |
CaptainR | 3:dcfbceb81fef | 741 | puts("\nBG Color = OLIVE"); |
CaptainR | 0:a5ef6bc3c2e8 | 742 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 743 | textBgColor(Grey); |
CaptainR | 3:dcfbceb81fef | 744 | puts("\nBG Color = GREY"); |
CaptainR | 0:a5ef6bc3c2e8 | 745 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 746 | textBgColor(Blue); |
CaptainR | 3:dcfbceb81fef | 747 | puts("\nBG Color = BLUE"); |
CaptainR | 0:a5ef6bc3c2e8 | 748 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 749 | textBgColor(Green); |
CaptainR | 3:dcfbceb81fef | 750 | puts("\nBG Color = GREEN"); |
CaptainR | 0:a5ef6bc3c2e8 | 751 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 752 | textBgColor(Red); |
CaptainR | 3:dcfbceb81fef | 753 | puts("\nBG Color = RED"); |
CaptainR | 0:a5ef6bc3c2e8 | 754 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 755 | textBgColor(Yellow); |
CaptainR | 3:dcfbceb81fef | 756 | puts("\nBG Color = YELLOW"); |
CaptainR | 0:a5ef6bc3c2e8 | 757 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 758 | textBgColor(GYellow); |
CaptainR | 3:dcfbceb81fef | 759 | puts("\nBG Color = GREEN YELLOW"); |
CaptainR | 0:a5ef6bc3c2e8 | 760 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 761 | textBgColor(White); |
CaptainR | 3:dcfbceb81fef | 762 | puts("\nBG Color = WHITE"); |
CaptainR | 0:a5ef6bc3c2e8 | 763 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 764 | textBgColor(Orange); |
CaptainR | 3:dcfbceb81fef | 765 | puts("\nBG Color = ORANGE"); |
CaptainR | 0:a5ef6bc3c2e8 | 766 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 767 | textBgColor(Pink); |
CaptainR | 3:dcfbceb81fef | 768 | puts("\nBG Color = PINK"); |
CaptainR | 0:a5ef6bc3c2e8 | 769 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 770 | textBgColor(Violet); |
CaptainR | 3:dcfbceb81fef | 771 | puts("\nBG Color = VIOLET"); |
CaptainR | 0:a5ef6bc3c2e8 | 772 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 773 | textBgColor(Aqua); |
CaptainR | 3:dcfbceb81fef | 774 | puts("\nBG Color = AQUA"); |
CaptainR | 0:a5ef6bc3c2e8 | 775 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 776 | textBgColor(Cream); |
CaptainR | 3:dcfbceb81fef | 777 | puts("\nBG Color = CREAM"); |
CaptainR | 0:a5ef6bc3c2e8 | 778 | wait_ms(LONG_WAIT); |
CaptainR | 3:dcfbceb81fef | 779 | textBgColor(Black); // set Color back |
CaptainR | 3:dcfbceb81fef | 780 | textFgColor(Green); // set Color back |
CaptainR | 0:a5ef6bc3c2e8 | 781 | cls(); |
CaptainR | 0:a5ef6bc3c2e8 | 782 | |
CaptainR | 12:29f5ad896382 | 783 | screenMode(landscape); |
CaptainR | 0:a5ef6bc3c2e8 | 784 | puts("Lets try moving cursor..."); |
CaptainR | 0:a5ef6bc3c2e8 | 785 | wait_ms(LONG_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 786 | cls(); |
CaptainR | 0:a5ef6bc3c2e8 | 787 | if (moveCursor(5, 5) == 1) puts("+"); |
CaptainR | 0:a5ef6bc3c2e8 | 788 | wait_ms(SHORT_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 789 | if (moveCursor(10, 10) == 1) puts("+"); |
CaptainR | 0:a5ef6bc3c2e8 | 790 | wait_ms(SHORT_WAIT); |
CaptainR | 12:29f5ad896382 | 791 | screenMode(portraitRew); |
CaptainR | 0:a5ef6bc3c2e8 | 792 | if (moveCursor(50, 50) == 1) puts("+"); |
CaptainR | 0:a5ef6bc3c2e8 | 793 | wait_ms(SHORT_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 794 | if (moveCursor(19, 29) == 1) puts("+"); |
CaptainR | 0:a5ef6bc3c2e8 | 795 | wait_ms(LONG_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 796 | cls(); |
CaptainR | 0:a5ef6bc3c2e8 | 797 | |
CaptainR | 0:a5ef6bc3c2e8 | 798 | |
CaptainR | 11:3ebd2263f3e9 | 799 | screenMode(portrait); |
CaptainR | 3:dcfbceb81fef | 800 | puts("\nText Foreground Colors:"); |
CaptainR | 0:a5ef6bc3c2e8 | 801 | wait_ms(LONG_WAIT); |
CaptainR | 0:a5ef6bc3c2e8 | 802 | cls(); |
CaptainR | 2:81eaaa491a02 | 803 | textBgColor(White); |
CaptainR | 2:81eaaa491a02 | 804 | textFgColor(Black); |
CaptainR | 3:dcfbceb81fef | 805 | puts("\nFG Color = BLACK"); |
CaptainR | 2:81eaaa491a02 | 806 | textBgColor(Black); |
CaptainR | 0:a5ef6bc3c2e8 | 807 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 808 | textFgColor(Navy); |
CaptainR | 3:dcfbceb81fef | 809 | puts("\nFG Color = NAVY"); |
CaptainR | 0:a5ef6bc3c2e8 | 810 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 811 | textFgColor(DGreen); |
CaptainR | 3:dcfbceb81fef | 812 | puts("\nFG Color = DARK GREEN"); |
CaptainR | 0:a5ef6bc3c2e8 | 813 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 814 | textFgColor(DCyan); |
CaptainR | 3:dcfbceb81fef | 815 | puts("\nFG Color = DARK CYAN"); |
CaptainR | 0:a5ef6bc3c2e8 | 816 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 817 | textFgColor(Purple); |
CaptainR | 3:dcfbceb81fef | 818 | puts("\nFG Color = PURPLE"); |
CaptainR | 0:a5ef6bc3c2e8 | 819 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 820 | textFgColor(Olive); |
CaptainR | 3:dcfbceb81fef | 821 | puts("\nFG Color = OLIVE"); |
CaptainR | 0:a5ef6bc3c2e8 | 822 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 823 | textFgColor(Grey); |
CaptainR | 3:dcfbceb81fef | 824 | puts("\nFG Color = GREY"); |
CaptainR | 0:a5ef6bc3c2e8 | 825 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 826 | textFgColor(Blue); |
CaptainR | 3:dcfbceb81fef | 827 | puts("\nFG Color = BLUE"); |
CaptainR | 0:a5ef6bc3c2e8 | 828 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 829 | textFgColor(Green); |
CaptainR | 3:dcfbceb81fef | 830 | puts("\nFG Color = GREEN"); |
CaptainR | 0:a5ef6bc3c2e8 | 831 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 832 | textFgColor(Red); |
CaptainR | 3:dcfbceb81fef | 833 | puts("\nFG Color = RED"); |
CaptainR | 0:a5ef6bc3c2e8 | 834 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 835 | textFgColor(Yellow); |
CaptainR | 3:dcfbceb81fef | 836 | puts("\nFG Color = YELLOW"); |
CaptainR | 0:a5ef6bc3c2e8 | 837 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 838 | textFgColor(GYellow); |
CaptainR | 3:dcfbceb81fef | 839 | puts("\nFG Color = GREEN YELLOW"); |
CaptainR | 0:a5ef6bc3c2e8 | 840 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 841 | textFgColor(White); |
CaptainR | 3:dcfbceb81fef | 842 | puts("\nFG Color = WHITE"); |
CaptainR | 0:a5ef6bc3c2e8 | 843 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 844 | textFgColor(Orange); |
CaptainR | 3:dcfbceb81fef | 845 | puts("\nFG Color = ORANGE"); |
CaptainR | 0:a5ef6bc3c2e8 | 846 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 847 | textFgColor(Pink); |
CaptainR | 3:dcfbceb81fef | 848 | puts("\nFG Color = PINK"); |
CaptainR | 0:a5ef6bc3c2e8 | 849 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 850 | textFgColor(Violet); |
CaptainR | 3:dcfbceb81fef | 851 | puts("\nFG Color = VIOLET"); |
CaptainR | 0:a5ef6bc3c2e8 | 852 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 853 | textFgColor(Aqua); |
CaptainR | 3:dcfbceb81fef | 854 | puts("\nFG Color = AQUA"); |
CaptainR | 0:a5ef6bc3c2e8 | 855 | wait_ms(SHORT_WAIT); |
CaptainR | 2:81eaaa491a02 | 856 | textFgColor(Cream); |
CaptainR | 3:dcfbceb81fef | 857 | puts("\nFG Color = CREAM"); |
CaptainR | 2:81eaaa491a02 | 858 | wait_ms(LONG_WAIT); |
CaptainR | 3:dcfbceb81fef | 859 | textFgColor(Green); // set Color back |
CaptainR | 21:ea68a8a3cea4 | 860 | wait_ms(LONG_WAIT); |
CaptainR | 2:81eaaa491a02 | 861 | |
CaptainR | 2:81eaaa491a02 | 862 | |
CaptainR | 22:cea582ea74c1 | 863 | } |
CaptainR | 22:cea582ea74c1 | 864 | |
CaptainR | 26:c6a803706a42 | 865 | void clearBuf(char *str, int size) { |
CaptainR | 22:cea582ea74c1 | 866 | int i; |
CaptainR | 26:c6a803706a42 | 867 | for (i = 0; i < size; i++) { |
CaptainR | 22:cea582ea74c1 | 868 | str[i] = 0; |
CaptainR | 26:c6a803706a42 | 869 | } |
CaptainR | 0:a5ef6bc3c2e8 | 870 | } |