basic functional test of FT810 LCD via SPI

Dependencies:   FT810 mbed

Committer:
cratliff
Date:
Fri Mar 18 16:48:19 2016 +0000
Revision:
3:f47fe17b34a1
Parent:
2:a4c01cf97666
Touch Screen Calibration stored to SD card.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
cratliff 0:aa55c6eb6867 1 /* Demo for mbed Library for FTDI FT800 Enbedded Video Engine "EVE"
cratliff 0:aa55c6eb6867 2 Updated for FTDI FT810 driver and 800x480 display.
cratliff 0:aa55c6eb6867 3 * by Peter Drescher, DC2PD 2014
cratliff 0:aa55c6eb6867 4 * Released under the MIT License: http://mbed.org/license/mit */
cratliff 0:aa55c6eb6867 5
cratliff 0:aa55c6eb6867 6 #include "mbed.h"
cratliff 0:aa55c6eb6867 7 #include "FT_Platform.h"
cratliff 0:aa55c6eb6867 8 #include "FT_color.h"
cratliff 0:aa55c6eb6867 9 #include "stdio.h"
cratliff 3:f47fe17b34a1 10 #include "SDFileSystem.h"
cratliff 0:aa55c6eb6867 11
cratliff 2:a4c01cf97666 12
cratliff 0:aa55c6eb6867 13 #define SAMAPP_DELAY_BTW_APIS (1000)
cratliff 0:aa55c6eb6867 14 #define SAMAPP_ENABLE_DELAY() Ft_Gpu_Hal_Sleep(SAMAPP_DELAY_BTW_APIS)
cratliff 0:aa55c6eb6867 15 #define SAMAPP_ENABLE_DELAY_VALUE(x) Ft_Gpu_Hal_Sleep(x)
cratliff 0:aa55c6eb6867 16
cratliff 2:a4c01cf97666 17 //#define Nucleo_F303K8
cratliff 3:f47fe17b34a1 18 #define K20B
cratliff 0:aa55c6eb6867 19
cratliff 0:aa55c6eb6867 20
cratliff 0:aa55c6eb6867 21 #ifdef Nucleo_F303K8
cratliff 0:aa55c6eb6867 22 FT800 TFT(PB_5,PB_4,PB_3,PA_11,PA_8,PF_1); // the FT800 is connected to SPI 5-7, then we have CS, INT, PD
cratliff 3:f47fe17b34a1 23 //SDFileSystem sd(D11, D12, D13, D7, "sd");
cratliff 0:aa55c6eb6867 24 #endif
cratliff 0:aa55c6eb6867 25
cratliff 0:aa55c6eb6867 26 #ifdef K22
cratliff 0:aa55c6eb6867 27 FT800 TFT(D11,D12,D13,D10,D9,D8); // the FT800 is connected to SPI 5-7, then we have CS, INT, PD
cratliff 0:aa55c6eb6867 28 #endif
cratliff 0:aa55c6eb6867 29
cratliff 1:7952d133e78c 30
cratliff 2:a4c01cf97666 31 #ifdef K20 //this is the teensy 3.1/3.2
cratliff 3:f47fe17b34a1 32 FT800 TFT(D11,D12,D13,D9,D8,D14); // the FT800 is connected to SPI 5-7, then we have CS, INT, PD
cratliff 3:f47fe17b34a1 33 SDFileSystem sd(D11, D12, D13, D10, "sd", D7); // the pinout on the mbed Cool Components workshop board
cratliff 3:f47fe17b34a1 34 #endif
cratliff 3:f47fe17b34a1 35
cratliff 3:f47fe17b34a1 36 #ifdef K20B //this is the teensy 3.1/3.2 Bench
cratliff 2:a4c01cf97666 37 FT800 TFT(D11,D12,D13,D10,D9,D8); // the FT800 is connected to SPI 5-7, then we have CS, INT, PD
cratliff 3:f47fe17b34a1 38 SDFileSystem sd(D11, D12, D13, D6, "sd", D5); // the pinout on the mbed Cool Components workshop board
cratliff 3:f47fe17b34a1 39 #include "USBSerial.h"
cratliff 3:f47fe17b34a1 40 USBSerial spc; // Virtual serial port over USB
cratliff 2:a4c01cf97666 41 #endif
cratliff 2:a4c01cf97666 42
cratliff 1:7952d133e78c 43
cratliff 0:aa55c6eb6867 44 //Analog inputs and outputs are normalized
cratliff 3:f47fe17b34a1 45 AnalogIn Feedback(A0);
cratliff 2:a4c01cf97666 46 AnalogOut Control(DAC);
cratliff 0:aa55c6eb6867 47
cratliff 0:aa55c6eb6867 48 // global Vars
cratliff 1:7952d133e78c 49 unsigned int r,b,g,PressDown, PressUp, CalVal0, CalVal1, CalVal2, CalVal3, CalVal4 ;
cratliff 0:aa55c6eb6867 50 double xyz = 10.13;
cratliff 0:aa55c6eb6867 51 char buffer[50];
cratliff 3:f47fe17b34a1 52 uint8_t tcal[24]; //Touch screen Calibration
cratliff 3:f47fe17b34a1 53 char tstr[30]; // Temp location for Touch Screen Calibration
cratliff 0:aa55c6eb6867 54
cratliff 0:aa55c6eb6867 55 // function to convert hue , saturation and value to RGB
cratliff 0:aa55c6eb6867 56 // see http://en.wikipedia.org/wiki/HSL_and_HSV
cratliff 0:aa55c6eb6867 57 void hsv2rgb(double H,double S, double V)
cratliff 0:aa55c6eb6867 58 {
cratliff 0:aa55c6eb6867 59 double f,h,p,q,t;
cratliff 0:aa55c6eb6867 60 int i;
cratliff 0:aa55c6eb6867 61 if( S == 0.0) {
cratliff 3:f47fe17b34a1 62 r = V * 255;
cratliff 0:aa55c6eb6867 63 g = V * 255;
cratliff 0:aa55c6eb6867 64 b = V * 255;
cratliff 0:aa55c6eb6867 65 return;
cratliff 0:aa55c6eb6867 66 }
cratliff 0:aa55c6eb6867 67 if(H > 480.0) H = 0.0; // check values
cratliff 3:f47fe17b34a1 68 if(S > 1.0) S = 1.0;
cratliff 0:aa55c6eb6867 69 if(S < 0.0) S = 0.0;
cratliff 0:aa55c6eb6867 70 if(V > 1.0) V = 1.0;
cratliff 0:aa55c6eb6867 71 if(V < 0.0) V = 0.0;
cratliff 3:f47fe17b34a1 72
cratliff 0:aa55c6eb6867 73 h = H / 60.0;
cratliff 0:aa55c6eb6867 74 i = (int) h;
cratliff 0:aa55c6eb6867 75 f = h - i;
cratliff 0:aa55c6eb6867 76 p = V * (1.0 - S);
cratliff 0:aa55c6eb6867 77 q = V * (1.0 - (S * f));
cratliff 0:aa55c6eb6867 78 t = V * (1.0 - (S * (1.0 - f)));
cratliff 3:f47fe17b34a1 79
cratliff 0:aa55c6eb6867 80 switch(i) {
cratliff 0:aa55c6eb6867 81 case 0:
cratliff 3:f47fe17b34a1 82 r = V * 255;
cratliff 0:aa55c6eb6867 83 g = t * 255;
cratliff 0:aa55c6eb6867 84 b = p * 255;
cratliff 0:aa55c6eb6867 85 break;
cratliff 0:aa55c6eb6867 86 case 1:
cratliff 0:aa55c6eb6867 87 r = q * 255;
cratliff 0:aa55c6eb6867 88 g = V * 255;
cratliff 0:aa55c6eb6867 89 b = p * 255;
cratliff 0:aa55c6eb6867 90 break;
cratliff 0:aa55c6eb6867 91 case 2:
cratliff 0:aa55c6eb6867 92 r = p * 255;
cratliff 0:aa55c6eb6867 93 g = V * 255;
cratliff 0:aa55c6eb6867 94 b = t * 255;
cratliff 0:aa55c6eb6867 95 break;
cratliff 0:aa55c6eb6867 96 case 3:
cratliff 0:aa55c6eb6867 97 r = p * 255;
cratliff 0:aa55c6eb6867 98 g = q * 255;
cratliff 0:aa55c6eb6867 99 b = V * 255;
cratliff 0:aa55c6eb6867 100 break;
cratliff 0:aa55c6eb6867 101 case 4:
cratliff 0:aa55c6eb6867 102 r = t * 255;
cratliff 0:aa55c6eb6867 103 g = p * 255;
cratliff 0:aa55c6eb6867 104 b = V * 255;
cratliff 0:aa55c6eb6867 105 break;
cratliff 0:aa55c6eb6867 106 case 5:
cratliff 0:aa55c6eb6867 107 default:
cratliff 0:aa55c6eb6867 108 r = V * 255;
cratliff 0:aa55c6eb6867 109 g = p * 255;
cratliff 0:aa55c6eb6867 110 b = q * 255;
cratliff 0:aa55c6eb6867 111 break;
cratliff 3:f47fe17b34a1 112 }
cratliff 0:aa55c6eb6867 113 }
cratliff 0:aa55c6eb6867 114
cratliff 0:aa55c6eb6867 115
cratliff 0:aa55c6eb6867 116 /***************************************************************************/
cratliff 0:aa55c6eb6867 117 /* Show a Screen with Text for 5 seconds */
cratliff 0:aa55c6eb6867 118 /* A spinner shows the delay */
cratliff 0:aa55c6eb6867 119 /***************************************************************************/
cratliff 0:aa55c6eb6867 120
cratliff 0:aa55c6eb6867 121 ft_void_t Start_Screen(ft_char8_t *str)
cratliff 0:aa55c6eb6867 122 {
cratliff 0:aa55c6eb6867 123 TFT.DLstart(); // start a new display command list
cratliff 0:aa55c6eb6867 124 TFT.DL(CLEAR_COLOR_RGB(255,255,255)); // set the clear color to white
cratliff 0:aa55c6eb6867 125 TFT.DL(CLEAR(1,1,1)); // clear buffers -> color buffer,stencil buffer, tag buffer
cratliff 2:a4c01cf97666 126
cratliff 3:f47fe17b34a1 127
cratliff 0:aa55c6eb6867 128 TFT.DL(COLOR_RGB(0x80,0x80,0x00)); // set current color
cratliff 0:aa55c6eb6867 129 TFT.Text((TFT.DispWidth/2), TFT.DispHeight/2, 31, OPT_CENTERX, str); // draw Text with font 31
cratliff 0:aa55c6eb6867 130 TFT.Text((TFT.DispWidth/2), 350, 31, OPT_CENTERX, "Brew Panel!"); // draw Text with font 31
cratliff 0:aa55c6eb6867 131 TFT.DL(COLOR_RGB(0x00,0xFF,0x00)); // change current color
cratliff 0:aa55c6eb6867 132 TFT.Spinner((TFT.DispWidth/2),TFT.DispHeight/4, 0,0); // draw a animated spinner
cratliff 0:aa55c6eb6867 133
cratliff 0:aa55c6eb6867 134 TFT.DL(DISPLAY()); // Display the image
cratliff 0:aa55c6eb6867 135 TFT.Swap(); // Swap the current display list
cratliff 0:aa55c6eb6867 136 TFT.Flush_Co_Buffer(); // Download the command list into fifo
cratliff 0:aa55c6eb6867 137
cratliff 0:aa55c6eb6867 138 TFT.WaitCmdfifo_empty(); // Wait till coprocessor completes the operation
cratliff 0:aa55c6eb6867 139 TFT.Sleep(1000); // Wait 5 s to show
cratliff 0:aa55c6eb6867 140 }
cratliff 0:aa55c6eb6867 141
cratliff 0:aa55c6eb6867 142 // construct the screen and download it to the LCD
cratliff 0:aa55c6eb6867 143 void screen_1(unsigned int color,unsigned int bright)
cratliff 0:aa55c6eb6867 144 {
cratliff 0:aa55c6eb6867 145 TFT.DLstart(); // start a new display command list
cratliff 0:aa55c6eb6867 146 TFT.DL(CLEAR(1,1,1)); // clear buffers -> color buffer,stencil buffer, tag buffer
cratliff 0:aa55c6eb6867 147 TFT.DL(COLOR_RGB(0xff,0xff,0xff)); // set current color to white
cratliff 0:aa55c6eb6867 148 sprintf(buffer, "%.2f", xyz);
cratliff 0:aa55c6eb6867 149 TFT.Text(500, 71, 31, 0, buffer);
cratliff 3:f47fe17b34a1 150
cratliff 3:f47fe17b34a1 151
cratliff 0:aa55c6eb6867 152 //TFT.Number(545, 135, 31, 0, printf(buffer, "%f", xyz));
cratliff 0:aa55c6eb6867 153 TFT.DL(TAG(1)); // assign TAG value 1
cratliff 0:aa55c6eb6867 154 //TFT.FgColor(COLOR_RGB(0xff,0,0)); // forground color red
cratliff 3:f47fe17b34a1 155 TFT.Dial(249, 86, 55, 0, color); // dial for color
cratliff 0:aa55c6eb6867 156 TFT.DL(TAG(2)); // assign TAG value 2
cratliff 0:aa55c6eb6867 157 //TFT.FgColor(COLOR_RGB(0,0xff,0)); // forground color green
cratliff 3:f47fe17b34a1 158 TFT.Slider(196, 215, 236, 21, 0, bright , 255); // slider for brightness
cratliff 3:f47fe17b34a1 159 TFT.Text(22, 84, 30, 0, "Color"); // text Color
cratliff 0:aa55c6eb6867 160 TFT.Text(22, 208, 30, 0, "Brightness");// text Brightness
cratliff 3:f47fe17b34a1 161 TFT.DL(TAG(3)); // assign TAG value 2
cratliff 0:aa55c6eb6867 162 TFT.Button(22, 300,200,100,31,PressDown,"Down!"); //test button
cratliff 0:aa55c6eb6867 163 TFT.GradColor(COLOR_RGB(0xff,0,0));
cratliff 3:f47fe17b34a1 164 TFT.DL(TAG(4)); // assign TAG value 2
cratliff 0:aa55c6eb6867 165 TFT.Button(250, 300,200,100,31,PressUp,"Up!"); //test button
cratliff 0:aa55c6eb6867 166 TFT.DL(COLOR_RGB(0xff,0xff,0xff)); // set current color to white
cratliff 0:aa55c6eb6867 167
cratliff 3:f47fe17b34a1 168
cratliff 3:f47fe17b34a1 169 TFT.DL(POINT_SIZE(100)); // color point around the dial
cratliff 3:f47fe17b34a1 170 TFT.DL(BEGIN(FTPOINTS));
cratliff 3:f47fe17b34a1 171 TFT.DL(COLOR_RGB(0x0,0x0,0xff)); // color of next point
cratliff 3:f47fe17b34a1 172 TFT.DL(VERTEX2II(183,47,0,0)); // set point x,y
cratliff 3:f47fe17b34a1 173 TFT.DL(COLOR_RGB(0xff,0x0,0x0));
cratliff 0:aa55c6eb6867 174 TFT.DL(VERTEX2II(249,162,0,0));
cratliff 3:f47fe17b34a1 175 TFT.DL(COLOR_RGB(0xff,0x0,0xff));
cratliff 0:aa55c6eb6867 176 TFT.DL(VERTEX2II(183,123,0,0));
cratliff 3:f47fe17b34a1 177 TFT.DL(COLOR_RGB(0xff,0xff,0x0));
cratliff 0:aa55c6eb6867 178 TFT.DL(VERTEX2II(317,123,0,0));
cratliff 3:f47fe17b34a1 179 TFT.DL(COLOR_RGB(0x0,0xff,0xff));
cratliff 0:aa55c6eb6867 180 TFT.DL(VERTEX2II(249,11,0,0));
cratliff 3:f47fe17b34a1 181 TFT.DL(COLOR_RGB(0x0,0xff,0x00));
cratliff 0:aa55c6eb6867 182 TFT.DL(VERTEX2II(317,50,0,0));
cratliff 0:aa55c6eb6867 183
cratliff 0:aa55c6eb6867 184 TFT.DL(SCISSOR_XY(10,10)); // define sub area starting at 10,10
cratliff 3:f47fe17b34a1 185 TFT.DL(SCISSOR_SIZE(50,50)); // size 50,50
cratliff 3:f47fe17b34a1 186 hsv2rgb(color /65536.0 * 360,1.0,bright / 255.0); // calculate rgb color from settings
cratliff 0:aa55c6eb6867 187 TFT.DL(CLEAR_COLOR_RGB(r,b,g)); // set filling color to r,g,b
cratliff 3:f47fe17b34a1 188 TFT.DL(CLEAR(1,1,1)); // fill the area
cratliff 3:f47fe17b34a1 189
cratliff 3:f47fe17b34a1 190
cratliff 3:f47fe17b34a1 191
cratliff 3:f47fe17b34a1 192
cratliff 0:aa55c6eb6867 193
cratliff 3:f47fe17b34a1 194 /* TFT.DL(SCISSOR_XY(500,10)); // define sub area starting at 10,10
cratliff 3:f47fe17b34a1 195 TFT.DL(SCISSOR_SIZE(200,200)); // size 200,200
cratliff 3:f47fe17b34a1 196 hsv2rgb(color /65536.0 * 360,1.0,bright / 255.0); // calculate rgb color from settings
cratliff 3:f47fe17b34a1 197 TFT.DL(CLEAR_COLOR_RGB(r,b,g)); // set filling color to r,g,b
cratliff 3:f47fe17b34a1 198 TFT.DL(CLEAR(1,1,1)); // fill the area
cratliff 0:aa55c6eb6867 199
cratliff 3:f47fe17b34a1 200 TFT.DL(SCISSOR_XY(500,210)); // define sub area starting at 10,10
cratliff 3:f47fe17b34a1 201 TFT.DL(SCISSOR_SIZE(200,200)); // size 200,200
cratliff 3:f47fe17b34a1 202 hsv2rgb(color /65536.0 * 360,1.0,bright / 255.0); // calculate rgb color from settings
cratliff 3:f47fe17b34a1 203 TFT.DL(CLEAR_COLOR_RGB(r,b,g)); // set filling color to r,g,b
cratliff 3:f47fe17b34a1 204 TFT.DL(CLEAR(1,1,1)); // fill the area
cratliff 3:f47fe17b34a1 205 */
cratliff 0:aa55c6eb6867 206 TFT.DL(DISPLAY()); // Display the image
cratliff 0:aa55c6eb6867 207 TFT.Swap(); // Swap the current display list
cratliff 0:aa55c6eb6867 208 TFT.Flush_Co_Buffer(); // Download the command list into fifo
cratliff 0:aa55c6eb6867 209 TFT.WaitCmdfifo_empty(); // Wait till coprocessor completes the operation
cratliff 0:aa55c6eb6867 210 }
cratliff 0:aa55c6eb6867 211
cratliff 0:aa55c6eb6867 212
cratliff 0:aa55c6eb6867 213
cratliff 0:aa55c6eb6867 214 int main()
cratliff 0:aa55c6eb6867 215 {
cratliff 0:aa55c6eb6867 216
cratliff 0:aa55c6eb6867 217
cratliff 2:a4c01cf97666 218
cratliff 0:aa55c6eb6867 219 unsigned int color = 0,bright = 0;
cratliff 0:aa55c6eb6867 220 ft_uint32_t TrackRegisterVal = 0; // touch track
cratliff 3:f47fe17b34a1 221
cratliff 3:f47fe17b34a1 222 // Flip Screen 180 degree so viewing angle is better
cratliff 2:a4c01cf97666 223 TFT.MemWrite(REG_ROTATE, 1);
cratliff 3:f47fe17b34a1 224 TFT.Rotate(1);
cratliff 3:f47fe17b34a1 225
cratliff 3:f47fe17b34a1 226
cratliff 0:aa55c6eb6867 227
cratliff 0:aa55c6eb6867 228 Start_Screen("5"); // Show start screen
cratliff 0:aa55c6eb6867 229 Start_Screen("4"); // Show start screen
cratliff 0:aa55c6eb6867 230 Start_Screen("3"); // Show start screen
cratliff 0:aa55c6eb6867 231 Start_Screen("2"); // Show start screen
cratliff 0:aa55c6eb6867 232 Start_Screen("1"); // Show start screen
cratliff 2:a4c01cf97666 233
cratliff 3:f47fe17b34a1 234
cratliff 3:f47fe17b34a1 235 int i;
cratliff 3:f47fe17b34a1 236
cratliff 3:f47fe17b34a1 237
cratliff 3:f47fe17b34a1 238 // Open Touch Screen Calibration data
cratliff 3:f47fe17b34a1 239 FILE *fp = fopen("/sd/TCal/TCalData.txt", "a");
cratliff 3:f47fe17b34a1 240 fp= fopen("/sd/TCal/TCalData.txt", "r");
cratliff 3:f47fe17b34a1 241 if(!fp) {
cratliff 3:f47fe17b34a1 242 spc.printf("Could not open file for read\n");
cratliff 3:f47fe17b34a1 243 //Could not open file for read
cratliff 3:f47fe17b34a1 244
cratliff 3:f47fe17b34a1 245 TFT.Calibrate(); // calibrate the touch screen
cratliff 3:f47fe17b34a1 246 spc.printf("Calibrating\n");
cratliff 3:f47fe17b34a1 247 TFT.read_calibrate(tcal); // Read in cal data from screen
cratliff 3:f47fe17b34a1 248 //fclose(fp);
cratliff 3:f47fe17b34a1 249 //Convert from Int to Char to save to SD card
cratliff 3:f47fe17b34a1 250 for (i = 0; i < 25; i++) {
cratliff 3:f47fe17b34a1 251 tstr[i] = tcal[i];
cratliff 3:f47fe17b34a1 252 }
cratliff 3:f47fe17b34a1 253
cratliff 3:f47fe17b34a1 254 //Open file for to save calibration data
cratliff 3:f47fe17b34a1 255 mkdir("/sd/TCal", 0777);
cratliff 3:f47fe17b34a1 256 FILE *fp = fopen("/sd/TCal/TCalData.txt", "w");
cratliff 3:f47fe17b34a1 257 fprintf(fp, tstr);
cratliff 3:f47fe17b34a1 258 fclose(fp);
cratliff 3:f47fe17b34a1 259 }
cratliff 3:f47fe17b34a1 260 else {
cratliff 3:f47fe17b34a1 261 spc.printf("Reading in Data\n");
cratliff 3:f47fe17b34a1 262 //Read in calibration Data
cratliff 3:f47fe17b34a1 263 fread(tstr,24,1,fp);
cratliff 3:f47fe17b34a1 264 //Convert from Char to Int
cratliff 3:f47fe17b34a1 265 for (i = 0; i < 24; i++) {
cratliff 3:f47fe17b34a1 266 tcal[i] = tstr[i];
cratliff 3:f47fe17b34a1 267 }
cratliff 3:f47fe17b34a1 268 TFT.write_calibrate(tcal); // write cal data to screen
cratliff 3:f47fe17b34a1 269
cratliff 3:f47fe17b34a1 270 }
cratliff 3:f47fe17b34a1 271
cratliff 2:a4c01cf97666 272 //if we have calibration data then write else calibrate
cratliff 2:a4c01cf97666 273 //Read from SD
cratliff 2:a4c01cf97666 274 //if good{
cratliff 2:a4c01cf97666 275 //TFT.write_calibrate(cali); }
cratliff 2:a4c01cf97666 276 //else
cratliff 3:f47fe17b34a1 277 //TFT.Calibrate(); // calibrate the touch screen
cratliff 3:f47fe17b34a1 278 //TFT.read_calibrate(cali);
cratliff 2:a4c01cf97666 279 //save cal to SD card
cratliff 3:f47fe17b34a1 280
cratliff 0:aa55c6eb6867 281
cratliff 0:aa55c6eb6867 282 /* Set the tracker for the dial - define the Area for touching */
cratliff 0:aa55c6eb6867 283 TFT.Track(249, 86, 1, 1, 1); // Dial - dimension 1,1 means rotary
cratliff 0:aa55c6eb6867 284 TFT.Track(179, 199, 277, 48, 2); // Slider
cratliff 0:aa55c6eb6867 285 TFT.Flush_Co_Buffer(); // Download the commands into fifo
cratliff 0:aa55c6eb6867 286 TFT.WaitCmdfifo_empty(); // Wait till coprocessor completes the operation
cratliff 1:7952d133e78c 287 TFT.RegRead(0x8001,CalVal0); // Read Calibration Value
cratliff 2:a4c01cf97666 288 TFT.RegRead(0x8002,CalVal1); // Read Calibration Value
cratliff 2:a4c01cf97666 289 TFT.RegRead(0x8003,CalVal2); // Read Calibration Value
cratliff 3:f47fe17b34a1 290
cratliff 3:f47fe17b34a1 291
cratliff 0:aa55c6eb6867 292 screen_1(color,bright); // paint screen
cratliff 0:aa55c6eb6867 293
cratliff 0:aa55c6eb6867 294 /* the demo is updating the screen in a endless loop */
cratliff 0:aa55c6eb6867 295 while(1) {
cratliff 0:aa55c6eb6867 296 ft_uint8_t tagval = 0;
cratliff 0:aa55c6eb6867 297 TrackRegisterVal = TFT.Rd32(REG_TRACKER); // check if one of the two tracking fields is touched
cratliff 0:aa55c6eb6867 298 tagval = TrackRegisterVal & 0xff;
cratliff 0:aa55c6eb6867 299 if(0 != tagval) { // touch -> get new values
cratliff 0:aa55c6eb6867 300 if(1 == tagval) { // the dial touched
cratliff 0:aa55c6eb6867 301 color = TrackRegisterVal>>16; // get the new value
cratliff 0:aa55c6eb6867 302 } else if(2 == tagval) { // the slider is touched
cratliff 0:aa55c6eb6867 303 bright = TrackRegisterVal>>16; // get new slider value
cratliff 0:aa55c6eb6867 304 bright = bright * 255/65536; // scale it down to 255
cratliff 0:aa55c6eb6867 305 } else if(3 == tagval) { // the slider is touched
cratliff 0:aa55c6eb6867 306 PressDown = OPT_FLAT;
cratliff 3:f47fe17b34a1 307 if(Control <= 0) {
cratliff 0:aa55c6eb6867 308 Control = 0;
cratliff 3:f47fe17b34a1 309 } else {
cratliff 0:aa55c6eb6867 310 Control = Control - 0.01;
cratliff 0:aa55c6eb6867 311 }
cratliff 3:f47fe17b34a1 312 // bright = 0; // scale it down to 255
cratliff 3:f47fe17b34a1 313 } else if(4 == tagval) { // the slider is touched
cratliff 3:f47fe17b34a1 314 PressUp = OPT_FLAT;
cratliff 3:f47fe17b34a1 315 if(Control >= 1) {
cratliff 0:aa55c6eb6867 316 Control = 1;
cratliff 3:f47fe17b34a1 317 } else {
cratliff 0:aa55c6eb6867 318 Control = Control + 0.01;
cratliff 3:f47fe17b34a1 319 }
cratliff 3:f47fe17b34a1 320 // bright = 255; // scale it down to 255
cratliff 0:aa55c6eb6867 321 }
cratliff 3:f47fe17b34a1 322
cratliff 0:aa55c6eb6867 323 //xyz = Control;
cratliff 3:f47fe17b34a1 324 // screen_1(color,bright); // paint new screen
cratliff 3:f47fe17b34a1 325 // TFT.Sleep(10); // wait 10ms for next check
cratliff 0:aa55c6eb6867 326 }
cratliff 3:f47fe17b34a1 327
cratliff 0:aa55c6eb6867 328 xyz = Feedback;
cratliff 0:aa55c6eb6867 329 screen_1(color,bright); // paint new screen
cratliff 0:aa55c6eb6867 330 TFT.Sleep(10); // wait 10ms for next time to repaint the screen
cratliff 3:f47fe17b34a1 331 PressDown = 0; // Clear Buttons being pressed
cratliff 0:aa55c6eb6867 332 PressUp = 0;
cratliff 0:aa55c6eb6867 333 } // end of display loop
cratliff 0:aa55c6eb6867 334 }
cratliff 0:aa55c6eb6867 335
cratliff 0:aa55c6eb6867 336
cratliff 0:aa55c6eb6867 337