Curtis Mattull
/
PANEL_GUI_hello_world
basic functional test of FT810 LCD via SPI
Diff: main.cpp
- Revision:
- 7:e525bfa17136
- Parent:
- 6:f698d8ba4cd6
- Child:
- 8:886908a6127c
--- a/main.cpp Wed Mar 30 15:07:54 2016 +0000 +++ b/main.cpp Thu Mar 31 17:17:30 2016 +0000 @@ -31,7 +31,9 @@ //#define Nucleo_F303K8 #define K20 +// used add easy way to reprogram without using the phsyical button. #define Program_Button +#define Debug_Swipe #ifdef Nucleo_F303K8 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 @@ -51,10 +53,11 @@ #endif // global Vars -unsigned int r, b, g, CalVal0, CalVal1, CalVal2, CalVal3, CalVal4; +unsigned int r, b, g, CalVal0, CalVal1, CalVal2, CalVal3, CalVal4, curX, curY, pasX, pasY; float ISEpressure, PFMflowrate = 0.0; -float ITVpressure1_feedback, ITVpressure2_feedback, ITVpressure1_user_input, ITVpressure2_user_input = 0.0; +float ITVpressure1_feedback, ITVpressure2_feedback, ITVpressure1_user_input, ITVpressure2_user_input = 0.0; uint16_t ITVpressure1_input_raw, ITVpressure2_input_raw, test = 0; +int16_t velocity, distance, touched, location, paslocation ; char buffer[50]; uint8_t tcal[24]; //Touch screen Calibration char tstr[40]; // Temp location for Touch Screen Calibration @@ -162,11 +165,25 @@ void screen_1() { TFT.DLstart(); // start a new display command list - TFT.DL(CLEAR_COLOR_RGB(255,255,255)); + TFT.DL(CLEAR_COLOR_RGB(0,0,0)); TFT.DL(CLEAR(1,1,1)); // clear buffers -> color buffer,stencil buffer, tag buffer /***************************************************************************************************/ + // some temp location holder for each page showing the transitions + TFT.DL(VERTEX_TRANSLATE_X(location* 16+12800)); + TFT.Text(300, 200, 31, 0, "Page 2"); + + TFT.DL(VERTEX_TRANSLATE_X(location* 16+25600)); + TFT.Text(300, 200, 31, 0, "Page 3"); + + TFT.DL(VERTEX_TRANSLATE_X(location* 16+38400)); + TFT.Text(300, 200, 31, 0, "Page 4"); + + TFT.DL(CLEAR_COLOR_RGB(255,255,255)); + + TFT.DL(VERTEX_TRANSLATE_X(location* 16)); + /*Border Creation*/ TFT.DL(COLOR_RGB(0x00,0x7C,0xC4)); TFT.DL(BEGIN(LINES)); @@ -252,7 +269,13 @@ TFT.Button(720, 1, 76, 22, 26, 0, "Reprogram"); #endif - +#ifdef Debug_Swipe + TFT.DL(COLOR_RGB(0,0,0)); + //sprintf(buffer, "%.2f", distance); + //TFT.Text(20, 450, 26, 0, buffer); + TFT.Number(20, 450, 26, 0, distance); + TFT.Number(80, 450, 26, 0, velocity); +#endif // Debug the touch up load #ifdef Debug_Touch_File TFT.DL(COLOR_RGB(0,0,0)); @@ -348,6 +371,7 @@ } /* Set the tracker for the dial - define the Area for touching */ + //TFT.Track(0, 0, 800, 480, 201); TFT.Track(70, 375, 280, 30, 1); TFT.Track(450, 375, 280, 30, 2); // Slider TFT.Flush_Co_Buffer(); // Download the commands into fifo @@ -356,6 +380,9 @@ /* the demo is updating the screen in a endless loop*/ while(1) { + // Touch position + curY = TFT.Rd32(REG_TOUCH_SCREEN_XY)& 0xffff; + curX = TFT.Rd32(REG_TOUCH_SCREEN_XY)>>16; ft_uint8_t tagval = 0; TrackRegisterVal = TFT.Rd32(REG_TRACKER); // check if one of the two tracking fields is touched tagval = TrackRegisterVal & 0xff; @@ -371,9 +398,89 @@ } else if (200 == tagval) { break; } - } + } else if(curX !=0x8000 && touched>0) { + touched++; + distance = curX - pasX; + location = (int16_t)paslocation + distance; + + + } else if(curX !=0x8000 && !touched) { + touched++; + pasX = curX; + // + } else if(curX ==0x8000 && touched) { + velocity = distance/touched; + paslocation = location; + touched=0; + + + + } else { + //page 4 location + if (location < - 2300 && location > -2500) { + if (velocity) { + velocity = (location + 2400)/-5; + location += (int16_t) velocity; + paslocation = location; + } else { + location = -2400; + } + + } + //page 3 location + else if (location < - 1500 && location > -1700) { + if (velocity) { + velocity = (location + 1600)/-5; + location += (int16_t) velocity; + paslocation = location; + } else { + location = -1600; + } - screen_1(); // paint new screen - TFT.Sleep(10); // wait 10ms for next time to repaint the screen - } // end of display loop -} \ No newline at end of file + } + //page 2 + else if (location < - 700 && location > -900) { + if (velocity) { + velocity = (location + 800)/-5; + location += (int16_t) velocity; + paslocation = location; + } else { + location = -800; + } + //page 1 + } else if (location > -100 && location < 100) { + + if (velocity) { + velocity = location/-5; + location += (int16_t) velocity; + paslocation = location; + } else { + location = 0; + } + //no page 0 + } else if (location >60) { + velocity = -10; + location += (int16_t) velocity; + paslocation = location; + //no page 5 + } else if (location <-2500) { + velocity = 10; + location += (int16_t) velocity; + paslocation = location; + //between pages + } else if (velocity) { + location += (int16_t) velocity; + paslocation = location; + //acceleration between pages + if (velocity >0) { + velocity+= 2; + } else { + velocity-= 2; + } + } + } + + screen_1(); // paint new screen + TFT.Sleep(10); // wait 10ms for next time to repaint the screen + } // end of display loop + } \ No newline at end of file