Curtis Mattull
/
PANEL_GUI_hello_world
basic functional test of FT810 LCD via SPI
main.cpp@9:bf787d41b645, 2016-04-01 (annotated)
- Committer:
- montgojj
- Date:
- Fri Apr 01 19:47:39 2016 +0000
- Revision:
- 9:bf787d41b645
- Parent:
- 8:886908a6127c
- Child:
- 10:c56b7ca4805f
Added moving average filter code from Cortland's snippet.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cratliff | 5:e2e04cb5eada | 1 | /* |
cratliff | 5:e2e04cb5eada | 2 | Title Block |
cratliff | 5:e2e04cb5eada | 3 | |
cratliff | 5:e2e04cb5eada | 4 | ** Project : CLC Brew Panel |
cratliff | 6:f698d8ba4cd6 | 5 | ** Processor : MK20 |
cratliff | 5:e2e04cb5eada | 6 | ** Version : 1.0 |
cratliff | 5:e2e04cb5eada | 7 | ** Compiler : mbed |
cratliff | 5:e2e04cb5eada | 8 | ** Date/Time : 3/27/2016 |
cratliff | 5:e2e04cb5eada | 9 | ** Abstract : ? |
cratliff | 5:e2e04cb5eada | 10 | ** |
cratliff | 5:e2e04cb5eada | 11 | ** |
cratliff | 6:f698d8ba4cd6 | 12 | ** |
cratliff | 6:f698d8ba4cd6 | 13 | ** Todo : |
cratliff | 5:e2e04cb5eada | 14 | */ |
cratliff | 0:aa55c6eb6867 | 15 | #include "mbed.h" |
cratliff | 0:aa55c6eb6867 | 16 | #include "FT_Platform.h" |
cratliff | 0:aa55c6eb6867 | 17 | #include "FT_color.h" |
cratliff | 0:aa55c6eb6867 | 18 | #include "stdio.h" |
montgojj | 4:a48fc7a3bda9 | 19 | #include "float.h" |
montgojj | 4:a48fc7a3bda9 | 20 | #include "SDFileSystem.h" |
montgojj | 4:a48fc7a3bda9 | 21 | #include "MCP4725.h" |
cratliff | 0:aa55c6eb6867 | 22 | |
cratliff | 0:aa55c6eb6867 | 23 | #define SAMAPP_DELAY_BTW_APIS (1000) |
cratliff | 0:aa55c6eb6867 | 24 | #define SAMAPP_ENABLE_DELAY() Ft_Gpu_Hal_Sleep(SAMAPP_DELAY_BTW_APIS) |
cratliff | 0:aa55c6eb6867 | 25 | #define SAMAPP_ENABLE_DELAY_VALUE(x) Ft_Gpu_Hal_Sleep(x) |
cratliff | 0:aa55c6eb6867 | 26 | |
montgojj | 4:a48fc7a3bda9 | 27 | //#define Nucleo_F303K8 |
montgojj | 4:a48fc7a3bda9 | 28 | #define K20 |
cratliff | 7:e525bfa17136 | 29 | // used add easy way to reprogram without using the phsyical button. |
cratliff | 6:f698d8ba4cd6 | 30 | #define Program_Button |
montgojj | 8:886908a6127c | 31 | //#define Debug_Swipe |
cratliff | 0:aa55c6eb6867 | 32 | |
cratliff | 0:aa55c6eb6867 | 33 | #ifdef Nucleo_F303K8 |
cratliff | 0:aa55c6eb6867 | 34 | 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 | 0:aa55c6eb6867 | 35 | #endif |
cratliff | 0:aa55c6eb6867 | 36 | |
montgojj | 4:a48fc7a3bda9 | 37 | #ifdef K20 |
montgojj | 4:a48fc7a3bda9 | 38 | FT800 TFT(D11,D12,D13,D9,D8,D14); |
montgojj | 4:a48fc7a3bda9 | 39 | SDFileSystem sd(D11, D12, D13, D10, "sd"); |
montgojj | 4:a48fc7a3bda9 | 40 | MCP4725 dac1(D18, D19, MCP4725::ADDRESS_2); |
montgojj | 4:a48fc7a3bda9 | 41 | MCP4725 dac2(D18, D19, MCP4725::ADDRESS_3); |
montgojj | 4:a48fc7a3bda9 | 42 | |
montgojj | 8:886908a6127c | 43 | AnalogIn PSEpressure_raw(A9); |
montgojj | 8:886908a6127c | 44 | AnalogIn PFWflowrate_raw(A8); |
montgojj | 4:a48fc7a3bda9 | 45 | AnalogIn ITVpressure1_feedback_raw(A3); |
montgojj | 4:a48fc7a3bda9 | 46 | AnalogIn ITVpressure2_feedback_raw(A2); |
montgojj | 4:a48fc7a3bda9 | 47 | DigitalIn card_present(D7); |
cratliff | 0:aa55c6eb6867 | 48 | #endif |
cratliff | 0:aa55c6eb6867 | 49 | |
montgojj | 4:a48fc7a3bda9 | 50 | // global Vars |
cratliff | 7:e525bfa17136 | 51 | unsigned int r, b, g, CalVal0, CalVal1, CalVal2, CalVal3, CalVal4, curX, curY, pasX, pasY; |
montgojj | 8:886908a6127c | 52 | float PSEpressure, PFWflowrate = 0.0; |
cratliff | 7:e525bfa17136 | 53 | float ITVpressure1_feedback, ITVpressure2_feedback, ITVpressure1_user_input, ITVpressure2_user_input = 0.0; |
montgojj | 9:bf787d41b645 | 54 | float ITV1_pre, ITV1_fcal, ITV2_pre, ITV2_fcal, PFW_pre, PFW_fcal, PSE_pre, PSE_fcal = 0.0; |
montgojj | 9:bf787d41b645 | 55 | static float avg1 = 0.05; |
montgojj | 9:bf787d41b645 | 56 | static float avg2 = 0.95; |
montgojj | 4:a48fc7a3bda9 | 57 | uint16_t ITVpressure1_input_raw, ITVpressure2_input_raw, test = 0; |
cratliff | 7:e525bfa17136 | 58 | int16_t velocity, distance, touched, location, paslocation ; |
montgojj | 4:a48fc7a3bda9 | 59 | char buffer[50]; |
montgojj | 4:a48fc7a3bda9 | 60 | uint8_t tcal[24]; //Touch screen Calibration |
cratliff | 5:e2e04cb5eada | 61 | char tstr[40]; // Temp location for Touch Screen Calibration |
montgojj | 8:886908a6127c | 62 | ft_int16_t x_size,y_size; |
cratliff | 5:e2e04cb5eada | 63 | |
montgojj | 8:886908a6127c | 64 | unsigned int err[7]; |
cratliff | 0:aa55c6eb6867 | 65 | |
cratliff | 0:aa55c6eb6867 | 66 | /***************************************************************************/ |
cratliff | 0:aa55c6eb6867 | 67 | /* Show a Screen with Text for 5 seconds */ |
cratliff | 0:aa55c6eb6867 | 68 | /* A spinner shows the delay */ |
cratliff | 0:aa55c6eb6867 | 69 | /***************************************************************************/ |
cratliff | 0:aa55c6eb6867 | 70 | |
cratliff | 0:aa55c6eb6867 | 71 | ft_void_t Start_Screen(ft_char8_t *str) |
cratliff | 0:aa55c6eb6867 | 72 | { |
cratliff | 0:aa55c6eb6867 | 73 | TFT.DLstart(); // start a new display command list |
cratliff | 0:aa55c6eb6867 | 74 | TFT.DL(CLEAR_COLOR_RGB(255,255,255)); // set the clear color to white |
cratliff | 0:aa55c6eb6867 | 75 | TFT.DL(CLEAR(1,1,1)); // clear buffers -> color buffer,stencil buffer, tag buffer |
cratliff | 5:e2e04cb5eada | 76 | TFT.DL(COLOR_RGB(0x00,0x7C,0xC4)); |
cratliff | 5:e2e04cb5eada | 77 | |
cratliff | 5:e2e04cb5eada | 78 | TFT.DL(COLOR_RGB(0x00,0x7C,0xC4)); |
montgojj | 4:a48fc7a3bda9 | 79 | TFT.DL(BEGIN(LINES)); |
montgojj | 4:a48fc7a3bda9 | 80 | TFT.DL(LINE_WIDTH(8 * 16)); |
montgojj | 4:a48fc7a3bda9 | 81 | TFT.DL(VERTEX2F(0*16,0*16)); |
montgojj | 4:a48fc7a3bda9 | 82 | TFT.DL(VERTEX2F(799*16,0*16)); |
cratliff | 5:e2e04cb5eada | 83 | |
montgojj | 4:a48fc7a3bda9 | 84 | TFT.DL(VERTEX2F(799*16,0*16)); |
montgojj | 4:a48fc7a3bda9 | 85 | TFT.DL(VERTEX2F(799*16,479*16)); |
cratliff | 5:e2e04cb5eada | 86 | |
montgojj | 4:a48fc7a3bda9 | 87 | TFT.DL(VERTEX2F(799*16,479*16)); |
montgojj | 4:a48fc7a3bda9 | 88 | TFT.DL(VERTEX2F(0*16,479*16)); |
cratliff | 5:e2e04cb5eada | 89 | |
montgojj | 4:a48fc7a3bda9 | 90 | TFT.DL(VERTEX2F(0*16,479*16)); |
montgojj | 4:a48fc7a3bda9 | 91 | TFT.DL(VERTEX2F(0*16,0*16)); |
cratliff | 5:e2e04cb5eada | 92 | |
cratliff | 0:aa55c6eb6867 | 93 | TFT.Text((TFT.DispWidth/2), TFT.DispHeight/2, 31, OPT_CENTERX, str); // draw Text with font 31 |
montgojj | 8:886908a6127c | 94 | TFT.Text((TFT.DispWidth/2), 350, 31, OPT_CENTERX, "Brew Panel"); // draw Text with font 31 |
montgojj | 4:a48fc7a3bda9 | 95 | TFT.DL(COLOR_RGB(0x00,0x7C,0xC4)); // change current color |
cratliff | 0:aa55c6eb6867 | 96 | TFT.Spinner((TFT.DispWidth/2),TFT.DispHeight/4, 0,0); // draw a animated spinner |
cratliff | 5:e2e04cb5eada | 97 | |
cratliff | 0:aa55c6eb6867 | 98 | TFT.DL(DISPLAY()); // Display the image |
cratliff | 0:aa55c6eb6867 | 99 | TFT.Swap(); // Swap the current display list |
cratliff | 0:aa55c6eb6867 | 100 | TFT.Flush_Co_Buffer(); // Download the command list into fifo |
cratliff | 0:aa55c6eb6867 | 101 | |
cratliff | 0:aa55c6eb6867 | 102 | TFT.WaitCmdfifo_empty(); // Wait till coprocessor completes the operation |
cratliff | 0:aa55c6eb6867 | 103 | TFT.Sleep(1000); // Wait 5 s to show |
cratliff | 0:aa55c6eb6867 | 104 | } |
cratliff | 0:aa55c6eb6867 | 105 | |
cratliff | 0:aa55c6eb6867 | 106 | // construct the screen and download it to the LCD |
montgojj | 4:a48fc7a3bda9 | 107 | void screen_1() |
cratliff | 0:aa55c6eb6867 | 108 | { |
cratliff | 0:aa55c6eb6867 | 109 | TFT.DLstart(); // start a new display command list |
montgojj | 8:886908a6127c | 110 | TFT.DL(CLEAR_COLOR_RGB(255,255,255)); |
cratliff | 0:aa55c6eb6867 | 111 | TFT.DL(CLEAR(1,1,1)); // clear buffers -> color buffer,stencil buffer, tag buffer |
montgojj | 8:886908a6127c | 112 | #ifdef Program_Button |
montgojj | 8:886908a6127c | 113 | TFT.DL(TAG(200)); // assign TAG value 200 |
montgojj | 8:886908a6127c | 114 | TFT.Button(710, 10, 76, 22, 26, 0, "Reprogram"); |
montgojj | 8:886908a6127c | 115 | TFT.DL(TAG(3)); |
montgojj | 8:886908a6127c | 116 | #endif |
montgojj | 4:a48fc7a3bda9 | 117 | /***************************************************************************************************/ |
montgojj | 8:886908a6127c | 118 | // some temp location holder for each page showing the transitions |
montgojj | 8:886908a6127c | 119 | /*TFT.DL(VERTEX_TRANSLATE_X(location* 16+12800)); |
cratliff | 7:e525bfa17136 | 120 | TFT.Text(300, 200, 31, 0, "Page 2"); |
cratliff | 7:e525bfa17136 | 121 | TFT.DL(VERTEX_TRANSLATE_X(location* 16+25600)); |
cratliff | 7:e525bfa17136 | 122 | TFT.Text(300, 200, 31, 0, "Page 3"); |
cratliff | 7:e525bfa17136 | 123 | TFT.DL(VERTEX_TRANSLATE_X(location* 16+38400)); |
cratliff | 7:e525bfa17136 | 124 | TFT.Text(300, 200, 31, 0, "Page 4"); |
cratliff | 7:e525bfa17136 | 125 | TFT.DL(CLEAR_COLOR_RGB(255,255,255)); |
montgojj | 8:886908a6127c | 126 | TFT.DL(VERTEX_TRANSLATE_X(location* 16));*/ |
montgojj | 8:886908a6127c | 127 | |
montgojj | 4:a48fc7a3bda9 | 128 | /*Border Creation*/ |
montgojj | 4:a48fc7a3bda9 | 129 | TFT.DL(COLOR_RGB(0x00,0x7C,0xC4)); |
montgojj | 4:a48fc7a3bda9 | 130 | TFT.DL(BEGIN(LINES)); |
montgojj | 4:a48fc7a3bda9 | 131 | TFT.DL(LINE_WIDTH(8 * 16)); |
montgojj | 4:a48fc7a3bda9 | 132 | TFT.DL(VERTEX2F(0*16,0*16)); |
montgojj | 4:a48fc7a3bda9 | 133 | TFT.DL(VERTEX2F(799*16,0*16)); |
montgojj | 4:a48fc7a3bda9 | 134 | TFT.DL(VERTEX2F(799*16,0*16)); |
montgojj | 4:a48fc7a3bda9 | 135 | TFT.DL(VERTEX2F(799*16,479*16)); |
montgojj | 4:a48fc7a3bda9 | 136 | TFT.DL(VERTEX2F(799*16,479*16)); |
montgojj | 4:a48fc7a3bda9 | 137 | TFT.DL(VERTEX2F(0*16,479*16)); |
montgojj | 4:a48fc7a3bda9 | 138 | TFT.DL(VERTEX2F(0*16,479*16)); |
cratliff | 5:e2e04cb5eada | 139 | TFT.DL(VERTEX2F(0*16,0*16)); |
montgojj | 4:a48fc7a3bda9 | 140 | TFT.DL(END()); |
montgojj | 4:a48fc7a3bda9 | 141 | /***************************************************************************************************/ |
cratliff | 0:aa55c6eb6867 | 142 | |
montgojj | 4:a48fc7a3bda9 | 143 | /***************************************************************************************************/ |
montgojj | 8:886908a6127c | 144 | /*ITV 1 Screen Display*/ |
montgojj | 8:886908a6127c | 145 | TFT.DL(COLOR_RGB(255,255,255)); |
montgojj | 8:886908a6127c | 146 | TFT.DL(VERTEX_TRANSLATE_X(location* 16)); |
montgojj | 8:886908a6127c | 147 | |
montgojj | 8:886908a6127c | 148 | TFT.DL(BEGIN(BITMAPS)); |
montgojj | 8:886908a6127c | 149 | TFT.DL(VERTEX2II(265,50,0,0)); |
montgojj | 8:886908a6127c | 150 | TFT.DL(VERTEX2II(75,50,1,0)); |
montgojj | 8:886908a6127c | 151 | TFT.DL(VERTEX_TRANSLATE_X((149+location)*16)); |
montgojj | 8:886908a6127c | 152 | TFT.DL(VERTEX2II(511,50,2,0)); |
montgojj | 8:886908a6127c | 153 | TFT.DL(VERTEX_TRANSLATE_X((0+location)*16)); |
montgojj | 4:a48fc7a3bda9 | 154 | TFT.DL(END()); |
montgojj | 8:886908a6127c | 155 | |
montgojj | 8:886908a6127c | 156 | TFT.DL(COLOR_RGB(0x00,0x7C,0xC4)); |
montgojj | 8:886908a6127c | 157 | TFT.Text(265, 200, 31, 0, "ITV 1 Pressure"); |
montgojj | 8:886908a6127c | 158 | TFT.DL(BEGIN(RECTS)); |
montgojj | 8:886908a6127c | 159 | TFT.DL(VERTEX2F(300*16,265*16)); |
montgojj | 8:886908a6127c | 160 | TFT.DL(VERTEX2F(505*16,330*16)); |
montgojj | 8:886908a6127c | 161 | TFT.DL(END()); |
montgojj | 4:a48fc7a3bda9 | 162 | TFT.DL(COLOR_RGB(255,255,255)); |
montgojj | 8:886908a6127c | 163 | sprintf(buffer, "%.1f", ITVpressure1_feedback); |
montgojj | 8:886908a6127c | 164 | TFT.Text(325,275,31,0,buffer); |
montgojj | 8:886908a6127c | 165 | TFT.Text(415, 275, 31, 0, " PSI"); |
montgojj | 8:886908a6127c | 166 | ITVpressure1_feedback = (ITVpressure1_feedback_raw.read_u16() - 9430) * (70.0) / (48430 - 9430) + 0; |
montgojj | 9:bf787d41b645 | 167 | ITV1_fcal = ITVpressure1_feedback; |
montgojj | 9:bf787d41b645 | 168 | ITV1_fcal *= avg1; |
montgojj | 9:bf787d41b645 | 169 | ITV1_fcal += ITV1_pre * avg2; |
montgojj | 9:bf787d41b645 | 170 | ITV1_pre = ITV1_fcal; |
montgojj | 9:bf787d41b645 | 171 | ITVpressure1_feedback = ITV1_fcal; |
montgojj | 8:886908a6127c | 172 | TFT.DL(COLOR_RGB(255,255,255)); |
montgojj | 8:886908a6127c | 173 | TFT.FgColor(COLOR_RGB(0,124,196)); |
montgojj | 8:886908a6127c | 174 | TFT.BgColor(COLOR_RGB(0,124,196)); |
montgojj | 8:886908a6127c | 175 | TFT.DL(TAG(1)); // assign TAG value 1 |
montgojj | 8:886908a6127c | 176 | TFT.Slider(225,375,350,30,0,ITVpressure1_user_input,2355); |
montgojj | 8:886908a6127c | 177 | TFT.DL(TAG(3)); |
montgojj | 4:a48fc7a3bda9 | 178 | /***************************************************************************************************/ |
cratliff | 5:e2e04cb5eada | 179 | |
montgojj | 4:a48fc7a3bda9 | 180 | /***************************************************************************************************/ |
montgojj | 8:886908a6127c | 181 | /*ITV 2 and PF3W Screen Display*/ |
montgojj | 8:886908a6127c | 182 | TFT.DL(COLOR_RGB(255,255,255)); |
montgojj | 8:886908a6127c | 183 | TFT.DL(VERTEX_TRANSLATE_X(location* 16)+12800); |
montgojj | 8:886908a6127c | 184 | TFT.DL(BEGIN(BITMAPS)); |
montgojj | 8:886908a6127c | 185 | //TFT.DL(VERTEX2II(265,50,0,0)); |
montgojj | 8:886908a6127c | 186 | TFT.DL(VERTEX2II(30,75,3,0)); |
montgojj | 8:886908a6127c | 187 | TFT.DL(VERTEX_TRANSLATE_X((149+location)*16)+12800); |
montgojj | 8:886908a6127c | 188 | TFT.DL(VERTEX2II(411,75,4,0)); |
montgojj | 8:886908a6127c | 189 | TFT.DL(VERTEX_TRANSLATE_X((0+location)*16)+12800); |
montgojj | 8:886908a6127c | 190 | TFT.DL(END()); |
montgojj | 8:886908a6127c | 191 | |
montgojj | 8:886908a6127c | 192 | TFT.DL(VERTEX_TRANSLATE_X(location* 16+12800)); |
montgojj | 8:886908a6127c | 193 | // Slide |
montgojj | 8:886908a6127c | 194 | TFT.DL(COLOR_RGB(0x00,0x7C,0xC4)); |
montgojj | 8:886908a6127c | 195 | TFT.Text(265, 200, 31, 0, "ITV 2 Pressure"); |
montgojj | 8:886908a6127c | 196 | TFT.DL(BEGIN(RECTS)); |
montgojj | 8:886908a6127c | 197 | TFT.DL(VERTEX2F(300*16,265*16)); |
montgojj | 8:886908a6127c | 198 | TFT.DL(VERTEX2F(505*16,330*16)); |
montgojj | 8:886908a6127c | 199 | TFT.DL(END()); |
montgojj | 8:886908a6127c | 200 | TFT.DL(COLOR_RGB(255,255,255)); |
montgojj | 8:886908a6127c | 201 | sprintf(buffer, "%.1f", ITVpressure2_feedback); |
montgojj | 8:886908a6127c | 202 | TFT.Text(325,275,31,0,buffer); |
montgojj | 8:886908a6127c | 203 | TFT.Text(415, 275, 31, 0, " PSI"); |
montgojj | 8:886908a6127c | 204 | ITVpressure2_feedback = (ITVpressure2_feedback_raw.read_u16()- 9365) * (70.0) / (48420 - 9365) + 0; |
montgojj | 9:bf787d41b645 | 205 | ITV2_fcal = ITVpressure2_feedback; |
montgojj | 9:bf787d41b645 | 206 | ITV2_fcal *= avg1; |
montgojj | 9:bf787d41b645 | 207 | ITV2_fcal += ITV2_pre * avg2; |
montgojj | 9:bf787d41b645 | 208 | ITV2_pre = ITV2_fcal; |
montgojj | 9:bf787d41b645 | 209 | ITVpressure2_feedback = ITV2_fcal; |
montgojj | 8:886908a6127c | 210 | TFT.DL(COLOR_RGB(255,255,255)); |
montgojj | 8:886908a6127c | 211 | TFT.FgColor(COLOR_RGB(0,124,196)); |
montgojj | 8:886908a6127c | 212 | TFT.BgColor(COLOR_RGB(0,124,196)); |
montgojj | 8:886908a6127c | 213 | TFT.DL(TAG(2)); // assign TAG value 2 |
montgojj | 8:886908a6127c | 214 | TFT.Slider(225,375,350,30,0,ITVpressure2_user_input,2387); |
montgojj | 8:886908a6127c | 215 | TFT.DL(TAG(3)); |
montgojj | 8:886908a6127c | 216 | |
montgojj | 8:886908a6127c | 217 | TFT.DL(VERTEX_TRANSLATE_X(location* 16+12800)); |
montgojj | 4:a48fc7a3bda9 | 218 | TFT.DL(COLOR_RGB(0x00,0x7C,0xC4)); |
montgojj | 8:886908a6127c | 219 | TFT.Text(250, 20, 31, 0, "PF3W Flow Rate"); |
montgojj | 4:a48fc7a3bda9 | 220 | TFT.DL(BEGIN(RECTS)); |
montgojj | 8:886908a6127c | 221 | TFT.DL(VERTEX2F(300*16,85*16)); |
montgojj | 8:886908a6127c | 222 | TFT.DL(VERTEX2F(505*16,150*16)); |
montgojj | 8:886908a6127c | 223 | PFWflowrate = (PFWflowrate_raw.read_u16() - 10355) * (40.0) / (51920 - 10355) + 0; |
montgojj | 9:bf787d41b645 | 224 | PFW_fcal = PFWflowrate; |
montgojj | 9:bf787d41b645 | 225 | PFW_fcal *= avg1; |
montgojj | 9:bf787d41b645 | 226 | PFW_fcal += PFW_pre * avg2; |
montgojj | 9:bf787d41b645 | 227 | PFW_pre = PFW_fcal; |
montgojj | 9:bf787d41b645 | 228 | PFWflowrate = PFW_fcal; |
montgojj | 8:886908a6127c | 229 | TFT.DL(COLOR_RGB(255,255,255)); |
montgojj | 8:886908a6127c | 230 | sprintf(buffer, "%.1f", PFWflowrate); |
montgojj | 8:886908a6127c | 231 | TFT.Text(285,95,31,0,buffer); |
montgojj | 8:886908a6127c | 232 | TFT.Text(385, 95, 31, 0, " L/min"); |
montgojj | 8:886908a6127c | 233 | /***************************************************************************************************/ |
montgojj | 8:886908a6127c | 234 | |
montgojj | 8:886908a6127c | 235 | /***************************************************************************************************/ |
montgojj | 8:886908a6127c | 236 | /*ISE Screen Display*/ |
montgojj | 8:886908a6127c | 237 | TFT.DL(COLOR_RGB(255,255,255)); |
montgojj | 8:886908a6127c | 238 | TFT.DL(VERTEX_TRANSLATE_X(location* 16)+25600); |
montgojj | 8:886908a6127c | 239 | TFT.DL(BEGIN(BITMAPS)); |
montgojj | 8:886908a6127c | 240 | TFT.DL(TAG(3)); |
montgojj | 8:886908a6127c | 241 | TFT.DL(VERTEX2II(265,50,0,0)); |
montgojj | 8:886908a6127c | 242 | TFT.DL(VERTEX2II(75,50,5,0)); |
montgojj | 8:886908a6127c | 243 | TFT.DL(VERTEX_TRANSLATE_X((99+location)*16)+25600); |
montgojj | 8:886908a6127c | 244 | TFT.DL(VERTEX2II(511,85,6,0)); |
montgojj | 8:886908a6127c | 245 | TFT.DL(VERTEX_TRANSLATE_X((0+location)*16)+25600); |
montgojj | 8:886908a6127c | 246 | TFT.DL(END()); |
montgojj | 8:886908a6127c | 247 | |
montgojj | 8:886908a6127c | 248 | TFT.DL(VERTEX_TRANSLATE_X(location* 16+25600)); //page 3 |
montgojj | 8:886908a6127c | 249 | TFT.DL(COLOR_RGB(0x00,0x7C,0xC4)); |
montgojj | 8:886908a6127c | 250 | TFT.Text(280, 200, 31, 0, "PSE Pressure"); |
montgojj | 8:886908a6127c | 251 | TFT.DL(BEGIN(RECTS)); |
montgojj | 8:886908a6127c | 252 | TFT.DL(VERTEX2F(295*16,265*16)); |
montgojj | 8:886908a6127c | 253 | TFT.DL(VERTEX2F(505*16,330*16)); |
montgojj | 8:886908a6127c | 254 | TFT.DL(END()); |
montgojj | 9:bf787d41b645 | 255 | PSEpressure = (PSEpressure_raw.read_u16() - 10440) * (1.0) / (52350 - 10440) + 0; |
montgojj | 9:bf787d41b645 | 256 | PSE_fcal = PSEpressure; |
montgojj | 9:bf787d41b645 | 257 | PSE_fcal *= avg1; |
montgojj | 9:bf787d41b645 | 258 | PSE_fcal += PSE_pre * avg2; |
montgojj | 9:bf787d41b645 | 259 | PSE_pre = PSE_fcal; |
montgojj | 9:bf787d41b645 | 260 | PSEpressure = PSE_fcal; |
montgojj | 8:886908a6127c | 261 | TFT.DL(COLOR_RGB(255,255,255)); |
montgojj | 8:886908a6127c | 262 | sprintf(buffer, "%.2f", PSEpressure); |
montgojj | 8:886908a6127c | 263 | //test = ISEpressure_raw.read_u16(); |
montgojj | 8:886908a6127c | 264 | //sprintf(buffer, "%d", test); |
montgojj | 8:886908a6127c | 265 | TFT.Text(300,275,31,0,buffer); |
montgojj | 8:886908a6127c | 266 | TFT.Text(405, 275, 31, 0, " MPa"); |
montgojj | 8:886908a6127c | 267 | /***************************************************************************************************/ |
montgojj | 8:886908a6127c | 268 | |
montgojj | 8:886908a6127c | 269 | /***************************************************************************************************/ |
montgojj | 8:886908a6127c | 270 | /*PFM Screen Display*/ |
montgojj | 8:886908a6127c | 271 | /*TFT.DL(VERTEX_TRANSLATE_X(location* 16+38400)); // page 4 |
montgojj | 8:886908a6127c | 272 | TFT.DL(COLOR_RGB(0x00,0x7C,0xC4)); |
montgojj | 8:886908a6127c | 273 | TFT.Text(265, 200, 31, 0, "PFW Flow Rate"); |
montgojj | 8:886908a6127c | 274 | TFT.DL(BEGIN(RECTS)); |
montgojj | 8:886908a6127c | 275 | TFT.DL(VERTEX2F(300*16,265*16)); |
montgojj | 8:886908a6127c | 276 | TFT.DL(VERTEX2F(505*16,330*16)); |
montgojj | 4:a48fc7a3bda9 | 277 | TFT.DL(END()); |
montgojj | 4:a48fc7a3bda9 | 278 | PFMflowrate = (PFMflowrate_raw.read_u16() - 10355) * (40.0) / (51920 - 10355) + 0; |
montgojj | 4:a48fc7a3bda9 | 279 | TFT.DL(COLOR_RGB(255,255,255)); |
montgojj | 4:a48fc7a3bda9 | 280 | sprintf(buffer, "%.1f", PFMflowrate); |
montgojj | 8:886908a6127c | 281 | TFT.Text(295,275,31,0,buffer); |
montgojj | 8:886908a6127c | 282 | TFT.Text(385, 275, 31, 0, " L/min");*/ |
montgojj | 4:a48fc7a3bda9 | 283 | /***************************************************************************************************/ |
cratliff | 5:e2e04cb5eada | 284 | |
cratliff | 5:e2e04cb5eada | 285 | |
montgojj | 8:886908a6127c | 286 | // add button to make for easy reprogramming |
montgojj | 8:886908a6127c | 287 | |
cratliff | 6:f698d8ba4cd6 | 288 | |
cratliff | 7:e525bfa17136 | 289 | #ifdef Debug_Swipe |
cratliff | 7:e525bfa17136 | 290 | TFT.DL(COLOR_RGB(0,0,0)); |
cratliff | 7:e525bfa17136 | 291 | //sprintf(buffer, "%.2f", distance); |
cratliff | 7:e525bfa17136 | 292 | //TFT.Text(20, 450, 26, 0, buffer); |
cratliff | 7:e525bfa17136 | 293 | TFT.Number(20, 450, 26, 0, distance); |
cratliff | 7:e525bfa17136 | 294 | TFT.Number(80, 450, 26, 0, velocity); |
cratliff | 7:e525bfa17136 | 295 | #endif |
cratliff | 5:e2e04cb5eada | 296 | // Debug the touch up load |
cratliff | 5:e2e04cb5eada | 297 | #ifdef Debug_Touch_File |
cratliff | 5:e2e04cb5eada | 298 | TFT.DL(COLOR_RGB(0,0,0)); |
cratliff | 5:e2e04cb5eada | 299 | int i; |
cratliff | 5:e2e04cb5eada | 300 | for (i = 0; i < 24; i++) { |
cratliff | 5:e2e04cb5eada | 301 | TFT.Number(i*30+20, 450, 26, 0, tcal[i]); |
cratliff | 5:e2e04cb5eada | 302 | |
cratliff | 5:e2e04cb5eada | 303 | } |
cratliff | 5:e2e04cb5eada | 304 | #endif |
cratliff | 5:e2e04cb5eada | 305 | |
cratliff | 0:aa55c6eb6867 | 306 | TFT.DL(DISPLAY()); // Display the image |
cratliff | 0:aa55c6eb6867 | 307 | TFT.Swap(); // Swap the current display list |
cratliff | 0:aa55c6eb6867 | 308 | TFT.Flush_Co_Buffer(); // Download the command list into fifo |
cratliff | 0:aa55c6eb6867 | 309 | TFT.WaitCmdfifo_empty(); // Wait till coprocessor completes the operation |
cratliff | 0:aa55c6eb6867 | 310 | } |
cratliff | 0:aa55c6eb6867 | 311 | |
cratliff | 5:e2e04cb5eada | 312 | void error_screen_SD() |
cratliff | 5:e2e04cb5eada | 313 | { |
montgojj | 4:a48fc7a3bda9 | 314 | TFT.DLstart(); // start a new display command list |
montgojj | 4:a48fc7a3bda9 | 315 | TFT.DL(CLEAR_COLOR_RGB(255,242,0)); |
montgojj | 4:a48fc7a3bda9 | 316 | TFT.DL(CLEAR(1,1,1)); // clear buffers -> color buffer,stencil buffer, tag buffer |
montgojj | 4:a48fc7a3bda9 | 317 | TFT.DL(COLOR_RGB(0,0,0)); |
montgojj | 4:a48fc7a3bda9 | 318 | TFT.Text((TFT.DispWidth/2), 170, 31, OPT_CENTERX, "Error!"); // draw Text with font 31 |
montgojj | 4:a48fc7a3bda9 | 319 | TFT.Text((TFT.DispWidth/2), 215, 31, OPT_CENTERX, "Insert SD Card!"); // draw Text with font 31 |
montgojj | 4:a48fc7a3bda9 | 320 | TFT.DL(DISPLAY()); // Display the image |
montgojj | 4:a48fc7a3bda9 | 321 | TFT.Swap(); // Swap the current display list |
montgojj | 4:a48fc7a3bda9 | 322 | TFT.Flush_Co_Buffer(); // Download the command list into fifo |
montgojj | 4:a48fc7a3bda9 | 323 | TFT.WaitCmdfifo_empty(); // Wait till coprocessor completes the operation |
montgojj | 4:a48fc7a3bda9 | 324 | TFT.Sleep(1000); |
cratliff | 5:e2e04cb5eada | 325 | |
montgojj | 4:a48fc7a3bda9 | 326 | TFT.DLstart(); // start a new display command list |
montgojj | 4:a48fc7a3bda9 | 327 | TFT.DL(CLEAR_COLOR_RGB(255,255,255)); |
montgojj | 4:a48fc7a3bda9 | 328 | TFT.DL(CLEAR(1,1,1)); // clear buffers -> color buffer,stencil buffer, tag buffer; |
montgojj | 4:a48fc7a3bda9 | 329 | TFT.DL(COLOR_RGB(0,0,0)); |
montgojj | 4:a48fc7a3bda9 | 330 | TFT.Text((TFT.DispWidth/2), 170, 31, OPT_CENTERX, "Error!"); // draw Text with font 31 |
montgojj | 4:a48fc7a3bda9 | 331 | TFT.Text((TFT.DispWidth/2), 215, 31, OPT_CENTERX, "Insert SD Card!"); // draw Text with font 31 |
montgojj | 4:a48fc7a3bda9 | 332 | TFT.DL(DISPLAY()); // Display the image |
montgojj | 4:a48fc7a3bda9 | 333 | TFT.Swap(); // Swap the current display list |
montgojj | 4:a48fc7a3bda9 | 334 | TFT.Flush_Co_Buffer(); // Download the command list into fifo |
montgojj | 4:a48fc7a3bda9 | 335 | TFT.WaitCmdfifo_empty(); // Wait till coprocessor completes the operation |
montgojj | 4:a48fc7a3bda9 | 336 | TFT.Sleep(1000); |
montgojj | 4:a48fc7a3bda9 | 337 | } |
cratliff | 0:aa55c6eb6867 | 338 | |
montgojj | 8:886908a6127c | 339 | void touchscreen_Calibration() |
cratliff | 5:e2e04cb5eada | 340 | { |
cratliff | 5:e2e04cb5eada | 341 | int i = 0; |
montgojj | 4:a48fc7a3bda9 | 342 | FILE *fp = fopen("/sd/TCal/TCalData.txt", "a"); |
montgojj | 4:a48fc7a3bda9 | 343 | fp= fopen("/sd/TCal/TCalData.txt", "r"); |
montgojj | 4:a48fc7a3bda9 | 344 | if(!fp) { |
montgojj | 4:a48fc7a3bda9 | 345 | //Could not open file for read |
montgojj | 4:a48fc7a3bda9 | 346 | TFT.Calibrate(); // calibrate the touch screen |
montgojj | 4:a48fc7a3bda9 | 347 | TFT.read_calibrate(tcal); // Read in cal data from screen |
montgojj | 4:a48fc7a3bda9 | 348 | //Convert from Int to Char to save to SD card |
cratliff | 5:e2e04cb5eada | 349 | /* no longer needed |
montgojj | 4:a48fc7a3bda9 | 350 | for (i = 0; i < 25; i++) { |
montgojj | 4:a48fc7a3bda9 | 351 | tstr[i] = tcal[i]; |
montgojj | 4:a48fc7a3bda9 | 352 | } |
cratliff | 5:e2e04cb5eada | 353 | */ |
montgojj | 4:a48fc7a3bda9 | 354 | //Open file for to save calibration data |
montgojj | 4:a48fc7a3bda9 | 355 | mkdir("/sd/TCal", 0777); |
montgojj | 4:a48fc7a3bda9 | 356 | FILE *fp = fopen("/sd/TCal/TCalData.txt", "w"); |
cratliff | 5:e2e04cb5eada | 357 | //Save integers one at a time to the file |
cratliff | 5:e2e04cb5eada | 358 | for (i = 0; i < 25; i++) { |
cratliff | 5:e2e04cb5eada | 359 | fprintf(fp, "%c", tcal[i] ); |
cratliff | 5:e2e04cb5eada | 360 | } |
montgojj | 4:a48fc7a3bda9 | 361 | fclose(fp); |
cratliff | 5:e2e04cb5eada | 362 | } else { |
montgojj | 4:a48fc7a3bda9 | 363 | //Read in calibration Data |
montgojj | 4:a48fc7a3bda9 | 364 | fread(tstr,24,1,fp); |
montgojj | 4:a48fc7a3bda9 | 365 | //Convert from Char to Int |
montgojj | 4:a48fc7a3bda9 | 366 | for (i = 0; i < 24; i++) { |
montgojj | 4:a48fc7a3bda9 | 367 | tcal[i] = tstr[i]; |
montgojj | 4:a48fc7a3bda9 | 368 | } |
montgojj | 4:a48fc7a3bda9 | 369 | TFT.write_calibrate(tcal); // write cal data to screen |
montgojj | 4:a48fc7a3bda9 | 370 | } |
montgojj | 8:886908a6127c | 371 | } |
cratliff | 0:aa55c6eb6867 | 372 | |
montgojj | 8:886908a6127c | 373 | void initialize_Images() |
montgojj | 8:886908a6127c | 374 | { |
montgojj | 8:886908a6127c | 375 | TFT.DLstart(); |
montgojj | 8:886908a6127c | 376 | TFT.DL(CLEAR_COLOR_RGB(255,255,255)); |
montgojj | 8:886908a6127c | 377 | TFT.DL(CLEAR(1,1,1)); |
montgojj | 8:886908a6127c | 378 | |
montgojj | 8:886908a6127c | 379 | TFT.DL(BITMAP_HANDLE(0)); |
montgojj | 8:886908a6127c | 380 | err[0] = TFT.Load_jpg("/sd/Logo.jpg",& x_size,& y_size, 0); |
montgojj | 8:886908a6127c | 381 | TFT.DL(BITMAP_HANDLE(1)); |
montgojj | 8:886908a6127c | 382 | err[1] = TFT.Load_jpg("/sd/ITV_1.jpg",& x_size,& y_size, 45000); |
montgojj | 8:886908a6127c | 383 | TFT.DL(BITMAP_HANDLE(2)); |
montgojj | 8:886908a6127c | 384 | err[2] = TFT.Load_jpg("/sd/ITV_2.jpg",& x_size,& y_size, 60000); |
montgojj | 8:886908a6127c | 385 | TFT.DL(BITMAP_HANDLE(3)); |
montgojj | 8:886908a6127c | 386 | err[3] = TFT.Load_jpg("/sd/PF3W_1.jpg",& x_size,& y_size, 85000); |
montgojj | 8:886908a6127c | 387 | TFT.DL(BITMAP_HANDLE(4)); |
montgojj | 8:886908a6127c | 388 | err[4] = TFT.Load_jpg("/sd/PF3W_2.jpg",& x_size,& y_size, 150000); |
montgojj | 8:886908a6127c | 389 | TFT.DL(BITMAP_HANDLE(5)); |
montgojj | 8:886908a6127c | 390 | err[5] = TFT.Load_jpg("/sd/PSE_1.jpg",& x_size,& y_size, 230000); |
montgojj | 8:886908a6127c | 391 | TFT.DL(BITMAP_HANDLE(6)); |
montgojj | 8:886908a6127c | 392 | err[6] = TFT.Load_jpg("/sd/PSE_2.jpg",& x_size,& y_size, 260000); |
montgojj | 8:886908a6127c | 393 | |
montgojj | 8:886908a6127c | 394 | TFT.DL(DISPLAY()); // Display the image |
montgojj | 8:886908a6127c | 395 | TFT.Swap(); // Swap the current display list |
montgojj | 8:886908a6127c | 396 | TFT.Flush_Co_Buffer(); // Download the command list into fifo |
montgojj | 8:886908a6127c | 397 | TFT.WaitCmdfifo_empty(); |
montgojj | 8:886908a6127c | 398 | } |
montgojj | 8:886908a6127c | 399 | |
montgojj | 8:886908a6127c | 400 | int main() |
montgojj | 8:886908a6127c | 401 | { |
montgojj | 8:886908a6127c | 402 | dac1.wakeup(); |
montgojj | 8:886908a6127c | 403 | dac2.wakeup(); |
montgojj | 8:886908a6127c | 404 | dac1.write_u12(0); |
montgojj | 8:886908a6127c | 405 | dac2.write_u12(0); |
montgojj | 8:886908a6127c | 406 | ft_uint32_t TrackRegisterVal = 0; // touch track |
montgojj | 8:886908a6127c | 407 | |
montgojj | 8:886908a6127c | 408 | TFT.MemWrite(REG_ROTATE, 1); |
montgojj | 8:886908a6127c | 409 | TFT.Rotate(1); |
montgojj | 8:886908a6127c | 410 | |
montgojj | 8:886908a6127c | 411 | Start_Screen("Starting..."); // Show start screen |
montgojj | 8:886908a6127c | 412 | |
montgojj | 8:886908a6127c | 413 | while(card_present.read()) { |
montgojj | 8:886908a6127c | 414 | error_screen_SD(); |
montgojj | 8:886908a6127c | 415 | } |
montgojj | 8:886908a6127c | 416 | |
montgojj | 8:886908a6127c | 417 | touchscreen_Calibration(); |
montgojj | 8:886908a6127c | 418 | |
montgojj | 8:886908a6127c | 419 | initialize_Images(); |
montgojj | 8:886908a6127c | 420 | TFT.Track(200, 400, 375, 30, 1); |
montgojj | 8:886908a6127c | 421 | TFT.Track(200, 400, 375, 30, 2); |
cratliff | 0:aa55c6eb6867 | 422 | TFT.Flush_Co_Buffer(); // Download the commands into fifo |
montgojj | 8:886908a6127c | 423 | TFT.WaitCmdfifo_empty(); |
montgojj | 4:a48fc7a3bda9 | 424 | /* the demo is updating the screen in a endless loop*/ |
cratliff | 0:aa55c6eb6867 | 425 | while(1) { |
cratliff | 7:e525bfa17136 | 426 | // Touch position |
cratliff | 7:e525bfa17136 | 427 | curY = TFT.Rd32(REG_TOUCH_SCREEN_XY)& 0xffff; |
cratliff | 7:e525bfa17136 | 428 | curX = TFT.Rd32(REG_TOUCH_SCREEN_XY)>>16; |
cratliff | 0:aa55c6eb6867 | 429 | ft_uint8_t tagval = 0; |
cratliff | 0:aa55c6eb6867 | 430 | TrackRegisterVal = TFT.Rd32(REG_TRACKER); // check if one of the two tracking fields is touched |
cratliff | 0:aa55c6eb6867 | 431 | tagval = TrackRegisterVal & 0xff; |
montgojj | 8:886908a6127c | 432 | if(1 == tagval) { |
montgojj | 8:886908a6127c | 433 | ITVpressure1_user_input = (TrackRegisterVal>>20) * (2356.0/4095); |
montgojj | 8:886908a6127c | 434 | ITVpressure1_input_raw = (TrackRegisterVal>>20) * (2356.0/4095) + 590; |
montgojj | 8:886908a6127c | 435 | dac1.write_u12(ITVpressure1_input_raw); |
montgojj | 8:886908a6127c | 436 | } else if(2 == tagval) { // the slider is touched |
montgojj | 8:886908a6127c | 437 | ITVpressure2_user_input = (TrackRegisterVal>>20) * (2386.0/4095); |
montgojj | 8:886908a6127c | 438 | ITVpressure2_input_raw = (TrackRegisterVal>>20) * (2386.0/4095) + 585; |
montgojj | 8:886908a6127c | 439 | dac2.write_u12(ITVpressure2_input_raw); |
montgojj | 8:886908a6127c | 440 | } else if (200 == tagval) { |
montgojj | 8:886908a6127c | 441 | break; |
cratliff | 7:e525bfa17136 | 442 | } else if(curX !=0x8000 && touched>0) { |
cratliff | 7:e525bfa17136 | 443 | touched++; |
cratliff | 7:e525bfa17136 | 444 | distance = curX - pasX; |
cratliff | 7:e525bfa17136 | 445 | location = (int16_t)paslocation + distance; |
cratliff | 7:e525bfa17136 | 446 | |
cratliff | 7:e525bfa17136 | 447 | |
cratliff | 7:e525bfa17136 | 448 | } else if(curX !=0x8000 && !touched) { |
cratliff | 7:e525bfa17136 | 449 | touched++; |
cratliff | 7:e525bfa17136 | 450 | pasX = curX; |
cratliff | 7:e525bfa17136 | 451 | // |
cratliff | 7:e525bfa17136 | 452 | } else if(curX ==0x8000 && touched) { |
cratliff | 7:e525bfa17136 | 453 | velocity = distance/touched; |
cratliff | 7:e525bfa17136 | 454 | paslocation = location; |
cratliff | 7:e525bfa17136 | 455 | touched=0; |
cratliff | 7:e525bfa17136 | 456 | |
cratliff | 7:e525bfa17136 | 457 | |
cratliff | 7:e525bfa17136 | 458 | |
cratliff | 7:e525bfa17136 | 459 | } else { |
cratliff | 7:e525bfa17136 | 460 | //page 4 location |
cratliff | 7:e525bfa17136 | 461 | if (location < - 2300 && location > -2500) { |
cratliff | 7:e525bfa17136 | 462 | if (velocity) { |
cratliff | 7:e525bfa17136 | 463 | velocity = (location + 2400)/-5; |
cratliff | 7:e525bfa17136 | 464 | location += (int16_t) velocity; |
cratliff | 7:e525bfa17136 | 465 | paslocation = location; |
cratliff | 7:e525bfa17136 | 466 | } else { |
cratliff | 7:e525bfa17136 | 467 | location = -2400; |
cratliff | 7:e525bfa17136 | 468 | } |
cratliff | 7:e525bfa17136 | 469 | |
cratliff | 7:e525bfa17136 | 470 | } |
cratliff | 7:e525bfa17136 | 471 | //page 3 location |
cratliff | 7:e525bfa17136 | 472 | else if (location < - 1500 && location > -1700) { |
cratliff | 7:e525bfa17136 | 473 | if (velocity) { |
cratliff | 7:e525bfa17136 | 474 | velocity = (location + 1600)/-5; |
cratliff | 7:e525bfa17136 | 475 | location += (int16_t) velocity; |
cratliff | 7:e525bfa17136 | 476 | paslocation = location; |
cratliff | 7:e525bfa17136 | 477 | } else { |
cratliff | 7:e525bfa17136 | 478 | location = -1600; |
cratliff | 7:e525bfa17136 | 479 | } |
cratliff | 5:e2e04cb5eada | 480 | |
cratliff | 7:e525bfa17136 | 481 | } |
cratliff | 7:e525bfa17136 | 482 | //page 2 |
cratliff | 7:e525bfa17136 | 483 | else if (location < - 700 && location > -900) { |
cratliff | 7:e525bfa17136 | 484 | if (velocity) { |
cratliff | 7:e525bfa17136 | 485 | velocity = (location + 800)/-5; |
cratliff | 7:e525bfa17136 | 486 | location += (int16_t) velocity; |
cratliff | 7:e525bfa17136 | 487 | paslocation = location; |
cratliff | 7:e525bfa17136 | 488 | } else { |
cratliff | 7:e525bfa17136 | 489 | location = -800; |
cratliff | 7:e525bfa17136 | 490 | } |
cratliff | 7:e525bfa17136 | 491 | //page 1 |
cratliff | 7:e525bfa17136 | 492 | } else if (location > -100 && location < 100) { |
cratliff | 7:e525bfa17136 | 493 | |
cratliff | 7:e525bfa17136 | 494 | if (velocity) { |
cratliff | 7:e525bfa17136 | 495 | velocity = location/-5; |
cratliff | 7:e525bfa17136 | 496 | location += (int16_t) velocity; |
cratliff | 7:e525bfa17136 | 497 | paslocation = location; |
cratliff | 7:e525bfa17136 | 498 | } else { |
cratliff | 7:e525bfa17136 | 499 | location = 0; |
cratliff | 7:e525bfa17136 | 500 | } |
cratliff | 7:e525bfa17136 | 501 | //no page 0 |
cratliff | 7:e525bfa17136 | 502 | } else if (location >60) { |
cratliff | 7:e525bfa17136 | 503 | velocity = -10; |
cratliff | 7:e525bfa17136 | 504 | location += (int16_t) velocity; |
cratliff | 7:e525bfa17136 | 505 | paslocation = location; |
cratliff | 7:e525bfa17136 | 506 | //no page 5 |
montgojj | 8:886908a6127c | 507 | } else if (location <-1700) { |
cratliff | 7:e525bfa17136 | 508 | velocity = 10; |
cratliff | 7:e525bfa17136 | 509 | location += (int16_t) velocity; |
cratliff | 7:e525bfa17136 | 510 | paslocation = location; |
cratliff | 7:e525bfa17136 | 511 | //between pages |
cratliff | 7:e525bfa17136 | 512 | } else if (velocity) { |
cratliff | 7:e525bfa17136 | 513 | location += (int16_t) velocity; |
cratliff | 7:e525bfa17136 | 514 | paslocation = location; |
cratliff | 7:e525bfa17136 | 515 | //acceleration between pages |
cratliff | 7:e525bfa17136 | 516 | if (velocity >0) { |
cratliff | 7:e525bfa17136 | 517 | velocity+= 2; |
cratliff | 7:e525bfa17136 | 518 | } else { |
cratliff | 7:e525bfa17136 | 519 | velocity-= 2; |
cratliff | 7:e525bfa17136 | 520 | } |
cratliff | 7:e525bfa17136 | 521 | } |
montgojj | 8:886908a6127c | 522 | } |
cratliff | 7:e525bfa17136 | 523 | |
montgojj | 8:886908a6127c | 524 | screen_1(); // paint new screen |
montgojj | 8:886908a6127c | 525 | TFT.Sleep(10); // wait 10ms for next time to repaint the screen |
montgojj | 8:886908a6127c | 526 | } // end of display loop |
montgojj | 8:886908a6127c | 527 | } |