Curtis Mattull
/
PANEL_GUI_hello_world
basic functional test of FT810 LCD via SPI
main.cpp@18:d1566d9b6ea1, 2016-08-15 (annotated)
- Committer:
- cpm219
- Date:
- Mon Aug 15 15:32:45 2016 +0000
- Revision:
- 18:d1566d9b6ea1
- Parent:
- 17:f98333612db8
- Child:
- 20:92b3e641b306
latest version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cratliff | 5:e2e04cb5eada | 1 | /* |
cratliff | 5:e2e04cb5eada | 2 | Title Block |
cpm219 | 18:d1566d9b6ea1 | 3 | ** Project : datalogger_ft810_bitmap_practice |
cpm219 | 18:d1566d9b6ea1 | 4 | ** Engineers : Curtis Mattull |
cpm219 | 18:d1566d9b6ea1 | 5 | ** Processor : MK20 |
cpm219 | 18:d1566d9b6ea1 | 6 | ** Version : 1.0 |
cpm219 | 18:d1566d9b6ea1 | 7 | ** Compiler : mbed |
cpm219 | 18:d1566d9b6ea1 | 8 | ** Date : 7/26/2016 |
cpm219 | 18:d1566d9b6ea1 | 9 | ** Abstract : This program serves as a learning aid to reading/writing to sd card. |
cpm219 | 18:d1566d9b6ea1 | 10 | Note : Thare are 2 locations to comment for changing lcd screens: |
cpm219 | 18:d1566d9b6ea1 | 11 | -line __ within main(), variable: display_type |
cpm219 | 18:d1566d9b6ea1 | 12 | -line 12 of FT_LCD_TYPE.h, definition: beyondtek |
cratliff | 5:e2e04cb5eada | 13 | */ |
cpm219 | 17:f98333612db8 | 14 | |
cpm219 | 17:f98333612db8 | 15 | #include "mbed.h" |
cratliff | 0:aa55c6eb6867 | 16 | #include "FT_Platform.h" |
cpm219 | 18:d1566d9b6ea1 | 17 | #include "FT_color.h" |
cratliff | 0:aa55c6eb6867 | 18 | #include "stdio.h" |
cpm219 | 18:d1566d9b6ea1 | 19 | #include "string.h" |
montgojj | 4:a48fc7a3bda9 | 20 | #include "float.h" |
montgojj | 4:a48fc7a3bda9 | 21 | #include "SDFileSystem.h" |
cpm219 | 18:d1566d9b6ea1 | 22 | #include "FATFileSystem.h" |
cpm219 | 17:f98333612db8 | 23 | |
cpm219 | 17:f98333612db8 | 24 | /************************ |
cpm219 | 17:f98333612db8 | 25 | function prototypes |
cpm219 | 17:f98333612db8 | 26 | *************************/ |
cpm219 | 17:f98333612db8 | 27 | |
cpm219 | 18:d1566d9b6ea1 | 28 | //for display type |
cpm219 | 18:d1566d9b6ea1 | 29 | void rotate_newhaven(void); |
cpm219 | 18:d1566d9b6ea1 | 30 | void rotate_beyondtek(void); |
cpm219 | 18:d1566d9b6ea1 | 31 | //for gui states |
cpm219 | 18:d1566d9b6ea1 | 32 | void gui_manager(void); |
cpm219 | 18:d1566d9b6ea1 | 33 | void main_menu(uint32_t tracker, uint8_t tag); // main menu 0 |
cpm219 | 18:d1566d9b6ea1 | 34 | void mode_a(uint32_t tracker, uint8_t tag); // mode A 1 |
cpm219 | 18:d1566d9b6ea1 | 35 | void mode_b(uint32_t tracker, uint8_t tag); // mode B 2 |
cpm219 | 18:d1566d9b6ea1 | 36 | void mode_c(uint32_t tracker, uint8_t tag); // mode C 3 |
cpm219 | 18:d1566d9b6ea1 | 37 | //for plot states |
cpm219 | 17:f98333612db8 | 38 | void plot_nothing(void); |
cpm219 | 17:f98333612db8 | 39 | void plot_square(void); |
cpm219 | 17:f98333612db8 | 40 | void plot_triangle(void); |
cpm219 | 17:f98333612db8 | 41 | void plot_sine(void); |
cpm219 | 18:d1566d9b6ea1 | 42 | void collect_data(void); |
cpm219 | 18:d1566d9b6ea1 | 43 | //for sd card |
cpm219 | 18:d1566d9b6ea1 | 44 | uint8_t read_calibration(void); |
cpm219 | 18:d1566d9b6ea1 | 45 | uint8_t sd_test(void); |
cpm219 | 18:d1566d9b6ea1 | 46 | uint8_t bitmap_test(uint16_t x,uint16_t y); |
cpm219 | 18:d1566d9b6ea1 | 47 | int8_t Load_jpg(char* filename, ft_int16_t* x_size, ft_int16_t* y_size, ft_uint32_t address); |
cpm219 | 18:d1566d9b6ea1 | 48 | //general use |
cpm219 | 18:d1566d9b6ea1 | 49 | void display_message(uint8_t error, const ft_char8_t *pass, const ft_char8_t *fail); |
cpm219 | 18:d1566d9b6ea1 | 50 | void start_screen(ft_char8_t *str); |
cpm219 | 18:d1566d9b6ea1 | 51 | void error_screen(ft_char8_t *str1, ft_char8_t *str2); |
cpm219 | 17:f98333612db8 | 52 | |
cpm219 | 17:f98333612db8 | 53 | /************************ |
cpm219 | 17:f98333612db8 | 54 | function pointers |
cpm219 | 17:f98333612db8 | 55 | *************************/ |
cpm219 | 17:f98333612db8 | 56 | |
cpm219 | 18:d1566d9b6ea1 | 57 | void (*draw_screen[4])(uint32_t tracker, uint8_t tag) = { main_menu, // 0 |
cpm219 | 18:d1566d9b6ea1 | 58 | mode_a, // 1 |
cpm219 | 18:d1566d9b6ea1 | 59 | mode_b, // 2 |
cpm219 | 18:d1566d9b6ea1 | 60 | mode_c |
cpm219 | 18:d1566d9b6ea1 | 61 | }; // 3 |
cpm219 | 17:f98333612db8 | 62 | |
cpm219 | 17:f98333612db8 | 63 | void (*plot[4])(void) = { plot_nothing, // 0 |
cpm219 | 17:f98333612db8 | 64 | plot_square, // 1 |
cpm219 | 17:f98333612db8 | 65 | plot_triangle, // 2 |
cpm219 | 18:d1566d9b6ea1 | 66 | // plot_sine |
cpm219 | 18:d1566d9b6ea1 | 67 | collect_data |
cpm219 | 18:d1566d9b6ea1 | 68 | }; // 3 |
cpm219 | 18:d1566d9b6ea1 | 69 | |
cratliff | 0:aa55c6eb6867 | 70 | |
cpm219 | 17:f98333612db8 | 71 | |
cpm219 | 18:d1566d9b6ea1 | 72 | void (*display_rotate[2])() = { rotate_newhaven, // 0 |
cpm219 | 18:d1566d9b6ea1 | 73 | rotate_beyondtek |
cpm219 | 18:d1566d9b6ea1 | 74 | }; // 1 |
cpm219 | 17:f98333612db8 | 75 | |
cpm219 | 17:f98333612db8 | 76 | /************************ |
cpm219 | 18:d1566d9b6ea1 | 77 | global objects and variables |
cpm219 | 17:f98333612db8 | 78 | *************************/ |
cpm219 | 17:f98333612db8 | 79 | |
cpm219 | 18:d1566d9b6ea1 | 80 | // create an LCD object |
cpm219 | 18:d1566d9b6ea1 | 81 | FT800 TFT ( D11, D12, D13, D9, D8, D14 ); |
cpm219 | 18:d1566d9b6ea1 | 82 | // ( mosi, miso, sclk, ss, intr, pd ); |
cpm219 | 18:d1566d9b6ea1 | 83 | //Create an SDFileSystem object |
cpm219 | 18:d1566d9b6ea1 | 84 | SDFileSystem sd ( D11, D12, D13, D10, "sd"); |
cpm219 | 18:d1566d9b6ea1 | 85 | //SDFileSystem ( mosi, miso, sclk, ss, name); |
cpm219 | 18:d1566d9b6ea1 | 86 | |
cpm219 | 18:d1566d9b6ea1 | 87 | DigitalIn sdcard_present(D7); // SD card detect input pin. card_present() is the name of a function within the SDFileSystem Class!!! |
cpm219 | 18:d1566d9b6ea1 | 88 | AnalogIn analog_in9(A9); // analog 9 pin connected to the PSE input 4 |
cpm219 | 18:d1566d9b6ea1 | 89 | AnalogIn analog_in8(A8); // analog 9 pin connected to the PFW input 5 |
cpm219 | 18:d1566d9b6ea1 | 90 | AnalogIn analog_in3(A3); // analog 9 pin connected to the ITV1 input 10 |
cpm219 | 18:d1566d9b6ea1 | 91 | AnalogIn analog_in2(A2); // analog 9 pin connected to the ITV2 input 11 from usb, starting at 1 |
cpm219 | 17:f98333612db8 | 92 | |
cpm219 | 18:d1566d9b6ea1 | 93 | const uint8_t font_button = 28, |
cpm219 | 18:d1566d9b6ea1 | 94 | font_title = 31, |
cpm219 | 18:d1566d9b6ea1 | 95 | font_author = 21; |
cpm219 | 18:d1566d9b6ea1 | 96 | |
cpm219 | 18:d1566d9b6ea1 | 97 | const ft_char8_t text_menu[32] = {"Data Logger\0"}, |
cpm219 | 18:d1566d9b6ea1 | 98 | text_a[32] = {"Plot adc\0"}, |
cpm219 | 18:d1566d9b6ea1 | 99 | text_b[32] = {"Settings\0"}, |
cpm219 | 18:d1566d9b6ea1 | 100 | text_c[32] = {"ISE40A\0"}, |
cpm219 | 18:d1566d9b6ea1 | 101 | text_back[32] = {"Back\0"}, |
cpm219 | 18:d1566d9b6ea1 | 102 | text_author[32] = {"by Curtis Mattull\0"}; |
cpm219 | 18:d1566d9b6ea1 | 103 | |
cpm219 | 18:d1566d9b6ea1 | 104 | int16_t i = 0x00; |
cpm219 | 18:d1566d9b6ea1 | 105 | static const uint32_t mask_reg_tracker_tag = 0x0000FFFF; |
cpm219 | 18:d1566d9b6ea1 | 106 | static const uint32_t mask_reg_tracker_tracker = 0xFFFF0000; |
cpm219 | 18:d1566d9b6ea1 | 107 | static const uint8_t mask_tag = 0xFF; |
cpm219 | 18:d1566d9b6ea1 | 108 | |
cpm219 | 18:d1566d9b6ea1 | 109 | char buffer[50]; // temporary buffer for writing characters to the LCD |
cpm219 | 18:d1566d9b6ea1 | 110 | |
cpm219 | 18:d1566d9b6ea1 | 111 | ft_int16_t x_size, y_size; // stores size data for loaded jpegs, not currently used |
cpm219 | 17:f98333612db8 | 112 | |
cpm219 | 18:d1566d9b6ea1 | 113 | /************************ |
cpm219 | 18:d1566d9b6ea1 | 114 | function: main() |
cpm219 | 18:d1566d9b6ea1 | 115 | description: |
cpm219 | 18:d1566d9b6ea1 | 116 | -calibrate touch screen |
cpm219 | 18:d1566d9b6ea1 | 117 | -display welcome screen |
cpm219 | 18:d1566d9b6ea1 | 118 | -manages touch screen input, system states, and calls draw_screen functions |
cpm219 | 18:d1566d9b6ea1 | 119 | *************************/ |
cpm219 | 18:d1566d9b6ea1 | 120 | int main() |
cpm219 | 18:d1566d9b6ea1 | 121 | { |
cpm219 | 18:d1566d9b6ea1 | 122 | // static const uint8_t display_type = 0x00; //not beyondtek display |
cpm219 | 18:d1566d9b6ea1 | 123 | static const uint8_t display_type = 0x01; |
cpm219 | 18:d1566d9b6ea1 | 124 | uint8_t error[4] = { 0x00, // sd_test error |
cpm219 | 18:d1566d9b6ea1 | 125 | 0x00, // load_bitmap error |
cpm219 | 18:d1566d9b6ea1 | 126 | 0x00, // bitmap write error |
cpm219 | 18:d1566d9b6ea1 | 127 | 0x00 |
cpm219 | 18:d1566d9b6ea1 | 128 | }; // gui_manager error |
cpm219 | 17:f98333612db8 | 129 | |
cpm219 | 18:d1566d9b6ea1 | 130 | (*display_rotate[display_type])(); // for proper orientation |
cpm219 | 18:d1566d9b6ea1 | 131 | error[3] = read_calibration(); |
cpm219 | 18:d1566d9b6ea1 | 132 | display_message( error[3], "touch calibration load success!\0", "touch calibration save success!\0"); |
cpm219 | 18:d1566d9b6ea1 | 133 | TFT.Sleep(100); // Wait ___ to show |
cpm219 | 17:f98333612db8 | 134 | |
cpm219 | 18:d1566d9b6ea1 | 135 | //load jpg into graphics ram |
cpm219 | 18:d1566d9b6ea1 | 136 | error[1] = Load_jpg("/sd/Logo.jpg", &x_size, &y_size, RAM_G); |
cpm219 | 18:d1566d9b6ea1 | 137 | display_message( error[1], "load jpg success!\0", "load jpg failed!\0"); |
cpm219 | 18:d1566d9b6ea1 | 138 | TFT.Sleep(100); // Wait ___ to show |
cpm219 | 17:f98333612db8 | 139 | |
cpm219 | 18:d1566d9b6ea1 | 140 | start_screen("gui by\0"); //unneccessary.. |
cpm219 | 18:d1566d9b6ea1 | 141 | TFT.Sleep(100); // Wait ___ to show |
cpm219 | 18:d1566d9b6ea1 | 142 | |
cpm219 | 18:d1566d9b6ea1 | 143 | // //sd card test |
cpm219 | 18:d1566d9b6ea1 | 144 | // error[0] = sd_test(); |
cpm219 | 18:d1566d9b6ea1 | 145 | // display_message( error[0], "sd test passed!\0", "sd test failed!\0"); |
cpm219 | 18:d1566d9b6ea1 | 146 | // TFT.Sleep(250); // Wait ___ to show |
cpm219 | 18:d1566d9b6ea1 | 147 | |
cpm219 | 18:d1566d9b6ea1 | 148 | // //display bitmap |
cpm219 | 18:d1566d9b6ea1 | 149 | // error[2] = draw_bitmap(25,25); |
cpm219 | 18:d1566d9b6ea1 | 150 | // TFT.Sleep(250); // Wait ___ to show |
cpm219 | 18:d1566d9b6ea1 | 151 | // display_message( error[2], "draw_bitmap success!\0", "draw_bitmap failed!\0"); |
cpm219 | 18:d1566d9b6ea1 | 152 | // TFT.Sleep(250); // Wait ___ to show |
cpm219 | 17:f98333612db8 | 153 | |
cpm219 | 18:d1566d9b6ea1 | 154 | //draw initial screen |
cpm219 | 18:d1566d9b6ea1 | 155 | main_menu(0x0,0x0); |
cpm219 | 18:d1566d9b6ea1 | 156 | //program should not return from gui_manager... |
cpm219 | 18:d1566d9b6ea1 | 157 | gui_manager(); |
cpm219 | 17:f98333612db8 | 158 | |
cpm219 | 18:d1566d9b6ea1 | 159 | // Wait ___ to show |
cpm219 | 18:d1566d9b6ea1 | 160 | display_message( 0x1, "\0", "gui_manager failed!\0"); |
cpm219 | 18:d1566d9b6ea1 | 161 | while(1) { |
cpm219 | 18:d1566d9b6ea1 | 162 | TFT.Sleep(1000); |
cpm219 | 18:d1566d9b6ea1 | 163 | } |
cpm219 | 17:f98333612db8 | 164 | |
cpm219 | 18:d1566d9b6ea1 | 165 | return 0; |
cpm219 | 18:d1566d9b6ea1 | 166 | } |
cpm219 | 17:f98333612db8 | 167 | |
cpm219 | 17:f98333612db8 | 168 | |
cpm219 | 17:f98333612db8 | 169 | |
cpm219 | 17:f98333612db8 | 170 | |
cpm219 | 17:f98333612db8 | 171 | /************************ |
cpm219 | 18:d1566d9b6ea1 | 172 | function: rotate_newhaven |
cpm219 | 18:d1566d9b6ea1 | 173 | description: rotates |
cpm219 | 17:f98333612db8 | 174 | *************************/ |
cpm219 | 18:d1566d9b6ea1 | 175 | void rotate_newhaven(void) |
cpm219 | 17:f98333612db8 | 176 | { |
cpm219 | 18:d1566d9b6ea1 | 177 | TFT.MemWrite(REG_ROTATE, 1); // rotate screen |
cpm219 | 18:d1566d9b6ea1 | 178 | TFT.Rotate(1); |
cpm219 | 18:d1566d9b6ea1 | 179 | TFT.Flush_Co_Buffer(); // Download the command list into fifo |
cpm219 | 18:d1566d9b6ea1 | 180 | TFT.WaitCmdfifo_empty(); // Wait till coprocessor completes the operation |
cpm219 | 18:d1566d9b6ea1 | 181 | } |
cpm219 | 18:d1566d9b6ea1 | 182 | |
cpm219 | 18:d1566d9b6ea1 | 183 | |
cpm219 | 17:f98333612db8 | 184 | |
cpm219 | 18:d1566d9b6ea1 | 185 | /************************ |
cpm219 | 18:d1566d9b6ea1 | 186 | function: rotate_beyondtek |
cpm219 | 18:d1566d9b6ea1 | 187 | description: rotates |
cpm219 | 18:d1566d9b6ea1 | 188 | *************************/ |
cpm219 | 18:d1566d9b6ea1 | 189 | void rotate_beyondtek(void) |
cpm219 | 18:d1566d9b6ea1 | 190 | { |
cpm219 | 18:d1566d9b6ea1 | 191 | //dont rotate |
cpm219 | 17:f98333612db8 | 192 | } |
cpm219 | 18:d1566d9b6ea1 | 193 | |
cpm219 | 17:f98333612db8 | 194 | |
cpm219 | 17:f98333612db8 | 195 | |
cpm219 | 17:f98333612db8 | 196 | /************************ |
cpm219 | 18:d1566d9b6ea1 | 197 | function: gui_manager() |
cpm219 | 18:d1566d9b6ea1 | 198 | description: tracks input data and updates screen accordingly |
cpm219 | 17:f98333612db8 | 199 | *************************/ |
cpm219 | 18:d1566d9b6ea1 | 200 | void gui_manager(void) |
cpm219 | 17:f98333612db8 | 201 | { |
cpm219 | 18:d1566d9b6ea1 | 202 | static const uint8_t state_lookup[32] = {0x0, 0x1, 0x2, 0x3, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x1, 0x1, 0x1, |
cpm219 | 18:d1566d9b6ea1 | 203 | 0x2, 0x2, 0x2, 0x2, 0x0, 0x2, 0x2, 0x2, 0x3, 0x3, 0x3, 0x3, 0x0, 0x3, 0x3, 0x3, |
cpm219 | 18:d1566d9b6ea1 | 204 | }; |
cpm219 | 18:d1566d9b6ea1 | 205 | /* array index values: { 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
cpm219 | 18:d1566d9b6ea1 | 206 | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31}; |
cpm219 | 18:d1566d9b6ea1 | 207 | */ |
cpm219 | 18:d1566d9b6ea1 | 208 | |
cpm219 | 18:d1566d9b6ea1 | 209 | static uint8_t present_state = 0x00, |
cpm219 | 18:d1566d9b6ea1 | 210 | tag = 0x00, |
cpm219 | 18:d1566d9b6ea1 | 211 | combo_input = 0x00; |
cpm219 | 18:d1566d9b6ea1 | 212 | |
cpm219 | 18:d1566d9b6ea1 | 213 | static uint16_t tracker = 0x00; |
cpm219 | 18:d1566d9b6ea1 | 214 | |
cpm219 | 18:d1566d9b6ea1 | 215 | static uint32_t reg32 = 0x00; |
cpm219 | 18:d1566d9b6ea1 | 216 | |
cpm219 | 18:d1566d9b6ea1 | 217 | //start of gui_manager() |
cpm219 | 18:d1566d9b6ea1 | 218 | while(1) { |
cpm219 | 18:d1566d9b6ea1 | 219 | tag = 0x0; |
cpm219 | 18:d1566d9b6ea1 | 220 | //while(0x0 == tag) |
cpm219 | 18:d1566d9b6ea1 | 221 | // { |
cpm219 | 18:d1566d9b6ea1 | 222 | reg32 = TFT.Rd32(REG_TRACKER); |
cpm219 | 18:d1566d9b6ea1 | 223 | tag = reg32 & mask_reg_tracker_tag; //read tag register, update tag variable |
cpm219 | 18:d1566d9b6ea1 | 224 | tracker = ( reg32 & mask_reg_tracker_tracker)>> 16; //read tracker |
cpm219 | 18:d1566d9b6ea1 | 225 | // } |
cpm219 | 18:d1566d9b6ea1 | 226 | combo_input = ( present_state << 3) + tag; // concatenate present_state with tag to form combo input |
cpm219 | 18:d1566d9b6ea1 | 227 | present_state = state_lookup[combo_input]; // based on combo input, update present state |
cpm219 | 18:d1566d9b6ea1 | 228 | (*draw_screen[present_state])(tracker,tag); // use present_state as operand to draw screen function |
cpm219 | 17:f98333612db8 | 229 | } |
cpm219 | 17:f98333612db8 | 230 | } |
cpm219 | 17:f98333612db8 | 231 | |
montgojj | 4:a48fc7a3bda9 | 232 | |
cpm219 | 18:d1566d9b6ea1 | 233 | |
cpm219 | 17:f98333612db8 | 234 | /************************ |
cpm219 | 17:f98333612db8 | 235 | function: main menu |
cpm219 | 17:f98333612db8 | 236 | description: draw main menu screen |
cpm219 | 17:f98333612db8 | 237 | *************************/ |
cpm219 | 18:d1566d9b6ea1 | 238 | void main_menu(uint32_t tracker, uint8_t tag) |
cpm219 | 17:f98333612db8 | 239 | { |
cpm219 | 18:d1566d9b6ea1 | 240 | // TFT.Wr16(REG_PWM_DUTY, 100); |
cpm219 | 18:d1566d9b6ea1 | 241 | |
cpm219 | 17:f98333612db8 | 242 | //start new display list |
cpm219 | 17:f98333612db8 | 243 | TFT.DLstart(); // start a new display command list |
cpm219 | 17:f98333612db8 | 244 | TFT.DL(CLEAR_COLOR_RGB(255,255,255)); // set the clear color to white |
cpm219 | 17:f98333612db8 | 245 | TFT.DL(CLEAR(1,1,1)); // clear buffers -> color buffer,stencil buffer, tag buffer |
cpm219 | 18:d1566d9b6ea1 | 246 | |
cpm219 | 18:d1566d9b6ea1 | 247 | //bitmaps |
cpm219 | 18:d1566d9b6ea1 | 248 | TFT.DL(TAG(0)); // assign TAG value 0 to bitmap |
cpm219 | 18:d1566d9b6ea1 | 249 | TFT.DL(BITMAP_SOURCE(RAM_G)); |
cpm219 | 18:d1566d9b6ea1 | 250 | TFT.DL(BITMAP_LAYOUT(RGB565,x_size*2,y_size)); |
cpm219 | 18:d1566d9b6ea1 | 251 | TFT.DL(BITMAP_SIZE(NEAREST,BORDER,BORDER,x_size,y_size)); |
cpm219 | 18:d1566d9b6ea1 | 252 | |
cpm219 | 18:d1566d9b6ea1 | 253 | TFT.DL(BEGIN(BITMAPS)); //start drawing bitmaps |
cpm219 | 18:d1566d9b6ea1 | 254 | TFT.DL(VERTEX2II(10,10,0,0)); // draw logo image with bit handle 0 |
cpm219 | 18:d1566d9b6ea1 | 255 | TFT.DL(END()); |
cpm219 | 18:d1566d9b6ea1 | 256 | |
cpm219 | 17:f98333612db8 | 257 | //buttons |
cpm219 | 18:d1566d9b6ea1 | 258 | TFT.DL(COLOR_RGB(0xFF, 0xFF, 0xFF)); //this sets the button text color |
cpm219 | 18:d1566d9b6ea1 | 259 | TFT.FgColor(0x007CC4); // this sets the button color |
cpm219 | 18:d1566d9b6ea1 | 260 | |
cpm219 | 17:f98333612db8 | 261 | //button A |
cpm219 | 17:f98333612db8 | 262 | TFT.Track( 50, 165, 200, 150, 1); // track aree of button A |
cpm219 | 18:d1566d9b6ea1 | 263 | TFT.DL(TAG(1)); // assign TAG value 1 to "mode A" button |
cpm219 | 18:d1566d9b6ea1 | 264 | TFT.Button(50, 165, 200, 150, font_title, 0, text_a); |
cpm219 | 18:d1566d9b6ea1 | 265 | |
cpm219 | 17:f98333612db8 | 266 | //button B |
cpm219 | 17:f98333612db8 | 267 | TFT.Track( 300, 165, 200, 150, 2); // track aree of button B |
cpm219 | 17:f98333612db8 | 268 | TFT.DL(TAG(2)); // assign TAG value 2 to "mode B" button |
cpm219 | 18:d1566d9b6ea1 | 269 | TFT.Button(300, 165, 200, 150, font_title, 0, text_b); |
cpm219 | 18:d1566d9b6ea1 | 270 | |
cpm219 | 17:f98333612db8 | 271 | //button C |
cpm219 | 18:d1566d9b6ea1 | 272 | TFT.Track( 550, 165, 200, 150, 3); // track aree of button C |
cpm219 | 17:f98333612db8 | 273 | TFT.DL(TAG(3)); // assign TAG value 3 to "mode C" button |
cpm219 | 18:d1566d9b6ea1 | 274 | TFT.Button(550, 165, 200, 150, font_title, 0, text_c); |
cpm219 | 18:d1566d9b6ea1 | 275 | |
cpm219 | 17:f98333612db8 | 276 | TFT.DL(TAG(0)); // assign TAG value 0 to everything else |
cpm219 | 18:d1566d9b6ea1 | 277 | |
cpm219 | 18:d1566d9b6ea1 | 278 | //title text |
cpm219 | 17:f98333612db8 | 279 | TFT.DL(COLOR_RGB(0x00, 0x7C, 0xC4)); |
cpm219 | 17:f98333612db8 | 280 | TFT.Text((TFT.DispWidth/2), TFT.DispHeight/8, font_title, OPT_CENTERX, text_menu); // draw Text with font 31 |
cpm219 | 18:d1566d9b6ea1 | 281 | |
cpm219 | 17:f98333612db8 | 282 | //author text |
cpm219 | 18:d1566d9b6ea1 | 283 | TFT.DL(COLOR_RGB(0x00, 0x00, 0x00)); |
cpm219 | 18:d1566d9b6ea1 | 284 | TFT.Text((TFT.DispWidth*7/8)+9, (TFT.DispHeight*15/16), font_button, OPT_CENTERX, text_author); // draw Text with font 31 |
cpm219 | 18:d1566d9b6ea1 | 285 | |
cpm219 | 17:f98333612db8 | 286 | //display the screen |
cpm219 | 17:f98333612db8 | 287 | TFT.DL(DISPLAY()); // display the image |
cpm219 | 17:f98333612db8 | 288 | TFT.Swap(); // swap the current display list |
cpm219 | 17:f98333612db8 | 289 | TFT.Flush_Co_Buffer(); // download the command list into fifo |
cpm219 | 17:f98333612db8 | 290 | TFT.WaitCmdfifo_empty(); // wait till coprocessor completes the operation |
cpm219 | 17:f98333612db8 | 291 | |
cpm219 | 18:d1566d9b6ea1 | 292 | } |
cpm219 | 18:d1566d9b6ea1 | 293 | |
cpm219 | 17:f98333612db8 | 294 | |
cratliff | 0:aa55c6eb6867 | 295 | |
cpm219 | 17:f98333612db8 | 296 | /************************ |
cpm219 | 17:f98333612db8 | 297 | function: mode_a |
cpm219 | 17:f98333612db8 | 298 | description: draws mode a screen |
cpm219 | 17:f98333612db8 | 299 | *************************/ |
cpm219 | 18:d1566d9b6ea1 | 300 | void mode_a(uint32_t tracker, uint8_t tag) |
cpm219 | 18:d1566d9b6ea1 | 301 | { |
cpm219 | 18:d1566d9b6ea1 | 302 | static const uint8_t plot_lookup[32] = {0x0, 0x0, 0x2, 0x3, 0x0, 0x0, 0x1, 0x0, 0x1, 0x1, 0x2, 0x3, 0x1, 0x0, 0x1, 0x1, |
cpm219 | 18:d1566d9b6ea1 | 303 | 0x2, 0x2, 0x2, 0x3, 0x2, 0x0, 0x1, 0x2, 0x3, 0x3, 0x2, 0x3, 0x3, 0x0, 0x1, 0x3 }; |
cpm219 | 18:d1566d9b6ea1 | 304 | static const uint8_t col_div = 10, |
cpm219 | 18:d1566d9b6ea1 | 305 | row_div = 8; |
cpm219 | 18:d1566d9b6ea1 | 306 | static const uint8_t col_step = (TFT.DispWidth/col_div), |
cpm219 | 18:d1566d9b6ea1 | 307 | row_step = (TFT.DispHeight/row_div); |
cpm219 | 18:d1566d9b6ea1 | 308 | int8_t row = 0, |
cpm219 | 18:d1566d9b6ea1 | 309 | col = 0; |
cpm219 | 18:d1566d9b6ea1 | 310 | |
cpm219 | 18:d1566d9b6ea1 | 311 | // array index values: { 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
cpm219 | 18:d1566d9b6ea1 | 312 | // 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31}; |
cpm219 | 18:d1566d9b6ea1 | 313 | static uint8_t plot_state = 0x00, |
cpm219 | 18:d1566d9b6ea1 | 314 | plot_combo = 0x00; |
cpm219 | 18:d1566d9b6ea1 | 315 | |
cpm219 | 18:d1566d9b6ea1 | 316 | plot_combo = ( plot_state << 3) + tag; // concatenate present_state with tag to form combo input |
cpm219 | 18:d1566d9b6ea1 | 317 | plot_state = plot_lookup[plot_combo]; // based on present state and touch input, update present state |
cpm219 | 18:d1566d9b6ea1 | 318 | |
cpm219 | 17:f98333612db8 | 319 | //start new display list |
cpm219 | 17:f98333612db8 | 320 | TFT.DLstart(); // start a new display command list |
cpm219 | 18:d1566d9b6ea1 | 321 | TFT.DL(CLEAR_COLOR_RGB(0,0,0)); // set the clear color to dark grey |
cpm219 | 17:f98333612db8 | 322 | TFT.DL(CLEAR(1,1,1)); // clear buffers -> color buffer,stencil buffer, tag buffer |
cpm219 | 18:d1566d9b6ea1 | 323 | |
cpm219 | 18:d1566d9b6ea1 | 324 | TFT.DL(TAG(0)); // assign TAG value 0 to everything else |
cpm219 | 18:d1566d9b6ea1 | 325 | //plot grid |
cpm219 | 18:d1566d9b6ea1 | 326 | TFT.DL(COLOR_RGB(75,75,75)); |
cpm219 | 18:d1566d9b6ea1 | 327 | TFT.DL(BEGIN(LINES)); |
cpm219 | 18:d1566d9b6ea1 | 328 | TFT.DL(LINE_WIDTH(1 * 16)); |
cpm219 | 18:d1566d9b6ea1 | 329 | |
cpm219 | 18:d1566d9b6ea1 | 330 | //draw plot grid |
cpm219 | 18:d1566d9b6ea1 | 331 | //draw row lines |
cpm219 | 18:d1566d9b6ea1 | 332 | for(row = 0;row < row_div-1; row++) |
cpm219 | 18:d1566d9b6ea1 | 333 | { |
cpm219 | 18:d1566d9b6ea1 | 334 | TFT.DL(VERTEX2F(0,row_step*16 + row*row_step*16)); |
cpm219 | 18:d1566d9b6ea1 | 335 | TFT.DL(VERTEX2F(800*16,row_step*16 + row*row_step*16)); |
cpm219 | 18:d1566d9b6ea1 | 336 | } |
cpm219 | 18:d1566d9b6ea1 | 337 | |
cpm219 | 18:d1566d9b6ea1 | 338 | //draw col lines |
cpm219 | 18:d1566d9b6ea1 | 339 | for(col = 0;col < col_div-1; col++) |
cpm219 | 18:d1566d9b6ea1 | 340 | { |
cpm219 | 18:d1566d9b6ea1 | 341 | TFT.DL(VERTEX2F(col_step*16 + col*col_step*16, 0)); |
cpm219 | 18:d1566d9b6ea1 | 342 | TFT.DL(VERTEX2F(col_step*16 + col*col_step*16, 480*16)); |
cpm219 | 18:d1566d9b6ea1 | 343 | } |
cpm219 | 18:d1566d9b6ea1 | 344 | |
cpm219 | 18:d1566d9b6ea1 | 345 | // //bitmaps |
cpm219 | 18:d1566d9b6ea1 | 346 | // TFT.DL(TAG(0)); // assign TAG value 0 to bitmap |
cpm219 | 18:d1566d9b6ea1 | 347 | // TFT.DL(BITMAP_SOURCE(RAM_G)); |
cpm219 | 18:d1566d9b6ea1 | 348 | // TFT.DL(BITMAP_LAYOUT(RGB565,x_size*2,y_size)); |
cpm219 | 18:d1566d9b6ea1 | 349 | // TFT.DL(BITMAP_SIZE(NEAREST,BORDER,BORDER,x_size,y_size)); |
cpm219 | 18:d1566d9b6ea1 | 350 | // |
cpm219 | 18:d1566d9b6ea1 | 351 | // TFT.DL(BEGIN(BITMAPS)); //start drawing bitmaps |
cpm219 | 18:d1566d9b6ea1 | 352 | // TFT.DL(VERTEX2II(10,10,0,0)); // draw logo image with bit handle 0 |
cpm219 | 18:d1566d9b6ea1 | 353 | // TFT.DL(END()); |
cpm219 | 18:d1566d9b6ea1 | 354 | |
cpm219 | 18:d1566d9b6ea1 | 355 | //buttons |
cpm219 | 18:d1566d9b6ea1 | 356 | TFT.DL(COLOR_RGB(0xFF, 0xFF, 0xFF)); //this sets the button text color |
cpm219 | 18:d1566d9b6ea1 | 357 | TFT.FgColor(0x007CC4); // this sets the button color |
cpm219 | 17:f98333612db8 | 358 | |
cpm219 | 17:f98333612db8 | 359 | //back button |
cpm219 | 17:f98333612db8 | 360 | TFT.Track( 50, 355, 100, 75, 4); // track aree of button back |
cpm219 | 17:f98333612db8 | 361 | TFT.DL(TAG(4)); |
cpm219 | 17:f98333612db8 | 362 | TFT.Button(50, 355, 100, 75, font_button, 4, text_back); // assign TAG value 4 to text_back button |
cpm219 | 18:d1566d9b6ea1 | 363 | |
cpm219 | 18:d1566d9b6ea1 | 364 | ////plot square button |
cpm219 | 18:d1566d9b6ea1 | 365 | // TFT.Track( 200, 355, 100, 75, 6); // track aree of button square |
cpm219 | 18:d1566d9b6ea1 | 366 | // TFT.DL(TAG(6)); |
cpm219 | 18:d1566d9b6ea1 | 367 | // TFT.Button(200, 355, 100, 75, font_button, 6, "square"); // assign TAG value 1 to text_back button//back button |
cpm219 | 18:d1566d9b6ea1 | 368 | // |
cpm219 | 18:d1566d9b6ea1 | 369 | // //plot triangle button |
cpm219 | 18:d1566d9b6ea1 | 370 | // TFT.Track( 350, 355, 100, 75, 2); // track aree of button triangle |
cpm219 | 18:d1566d9b6ea1 | 371 | // TFT.DL(TAG(2)); |
cpm219 | 18:d1566d9b6ea1 | 372 | // TFT.Button(350, 355, 100, 75, font_button, 2, "triangle"); // assign TAG value 2 to text_back button//back button |
cpm219 | 18:d1566d9b6ea1 | 373 | |
cpm219 | 17:f98333612db8 | 374 | //plot sine button |
cpm219 | 17:f98333612db8 | 375 | TFT.Track( 500, 355, 100, 75, 3); // track aree of button sine |
cpm219 | 17:f98333612db8 | 376 | TFT.DL(TAG(3)); |
cpm219 | 18:d1566d9b6ea1 | 377 | TFT.Button(500, 355, 100, 75, font_button, 3, "adc in"); // assign TAG value 3 to text_back button//back button |
cpm219 | 18:d1566d9b6ea1 | 378 | |
cpm219 | 17:f98333612db8 | 379 | //plot nothing button |
cpm219 | 17:f98333612db8 | 380 | TFT.Track( 650, 355, 100, 75, 5); // track aree of button square |
cpm219 | 17:f98333612db8 | 381 | TFT.DL(TAG(5)); |
cpm219 | 17:f98333612db8 | 382 | TFT.Button(650, 355, 100, 75, font_button, 5, "clear"); // assign TAG value 1 to text_back button//back button |
cpm219 | 17:f98333612db8 | 383 | |
cpm219 | 18:d1566d9b6ea1 | 384 | |
cpm219 | 17:f98333612db8 | 385 | TFT.DL(TAG(0)); // assign TAG value 0 to everything else |
cpm219 | 18:d1566d9b6ea1 | 386 | //author text |
cpm219 | 18:d1566d9b6ea1 | 387 | TFT.DL(COLOR_RGB(0xFF, 0xFF, 0xFF)); |
cpm219 | 18:d1566d9b6ea1 | 388 | TFT.Text((TFT.DispWidth*7/8)+9, (TFT.DispHeight*15/16), font_button, OPT_CENTERX, text_author); // draw Text with font 31 |
cpm219 | 18:d1566d9b6ea1 | 389 | //plot algorithm |
cpm219 | 18:d1566d9b6ea1 | 390 | // TFT.DL( BEGIN(LINE_STRIP) ); //works okay.. |
cpm219 | 18:d1566d9b6ea1 | 391 | TFT.DL( BEGIN(LINE_STRIP) ); |
cpm219 | 17:f98333612db8 | 392 | |
cpm219 | 17:f98333612db8 | 393 | TFT.DL(LINE_WIDTH(3 * 16)); |
cpm219 | 18:d1566d9b6ea1 | 394 | (*plot[plot_state])(); // use present_state as operand to draw screen function |
cpm219 | 17:f98333612db8 | 395 | |
cpm219 | 17:f98333612db8 | 396 | //display the screen |
cpm219 | 17:f98333612db8 | 397 | TFT.DL(DISPLAY()); // display the image |
cpm219 | 17:f98333612db8 | 398 | TFT.Swap(); // swap the current display list |
cpm219 | 17:f98333612db8 | 399 | TFT.Flush_Co_Buffer(); // download the command list into fifo |
cpm219 | 17:f98333612db8 | 400 | TFT.WaitCmdfifo_empty(); // wait till coprocessor completes the operation |
cpm219 | 17:f98333612db8 | 401 | } |
cpm219 | 17:f98333612db8 | 402 | |
cpm219 | 17:f98333612db8 | 403 | |
cratliff | 5:e2e04cb5eada | 404 | |
cpm219 | 17:f98333612db8 | 405 | /************************ |
cpm219 | 17:f98333612db8 | 406 | function: mode b |
cpm219 | 17:f98333612db8 | 407 | description: draws mode b screen. |
cpm219 | 17:f98333612db8 | 408 | *************************/ |
cpm219 | 18:d1566d9b6ea1 | 409 | void mode_b(uint32_t tracker, uint8_t tag) |
cpm219 | 17:f98333612db8 | 410 | { |
cpm219 | 18:d1566d9b6ea1 | 411 | static uint8_t val = 50; |
cpm219 | 17:f98333612db8 | 412 | |
cpm219 | 17:f98333612db8 | 413 | //start new display list |
cpm219 | 17:f98333612db8 | 414 | TFT.DLstart(); // start a new display command list |
cpm219 | 17:f98333612db8 | 415 | TFT.DL(CLEAR_COLOR_RGB(255,255,255)); // set the clear color to white |
cpm219 | 17:f98333612db8 | 416 | TFT.DL(CLEAR(1,1,1)); // clear buffers -> color buffer,stencil buffer, tag buffer |
cpm219 | 18:d1566d9b6ea1 | 417 | |
cpm219 | 18:d1566d9b6ea1 | 418 | |
cpm219 | 18:d1566d9b6ea1 | 419 | //bitmaps |
cpm219 | 18:d1566d9b6ea1 | 420 | TFT.DL(TAG(0)); // assign TAG value 0 to bitmap |
cpm219 | 18:d1566d9b6ea1 | 421 | TFT.DL(BITMAP_SOURCE(RAM_G)); |
cpm219 | 18:d1566d9b6ea1 | 422 | TFT.DL(BITMAP_LAYOUT(RGB565,x_size*2,y_size)); |
cpm219 | 18:d1566d9b6ea1 | 423 | TFT.DL(BITMAP_SIZE(NEAREST,BORDER,BORDER,x_size,y_size)); |
cpm219 | 18:d1566d9b6ea1 | 424 | |
cpm219 | 18:d1566d9b6ea1 | 425 | TFT.DL(BEGIN(BITMAPS)); //start drawing bitmaps |
cpm219 | 18:d1566d9b6ea1 | 426 | TFT.DL(VERTEX2II(10,10,0,0)); // draw logo image with bit handle 0 |
cpm219 | 18:d1566d9b6ea1 | 427 | TFT.DL(END()); |
cpm219 | 18:d1566d9b6ea1 | 428 | |
cpm219 | 18:d1566d9b6ea1 | 429 | //buttons |
cpm219 | 18:d1566d9b6ea1 | 430 | TFT.DL(COLOR_RGB(0xFF, 0xFF, 0xFF)); //this sets the button text color |
cpm219 | 18:d1566d9b6ea1 | 431 | TFT.FgColor(0x007CC4); // this sets the button color |
cpm219 | 18:d1566d9b6ea1 | 432 | |
cpm219 | 18:d1566d9b6ea1 | 433 | |
cpm219 | 17:f98333612db8 | 434 | //back button |
cpm219 | 17:f98333612db8 | 435 | TFT.Track( 50, 355, 100, 75, 4); // track aree of button back |
cpm219 | 17:f98333612db8 | 436 | TFT.DL(TAG(4)); |
cpm219 | 17:f98333612db8 | 437 | TFT.Button(50, 355, 100, 75, font_button, 0, text_back); // assign TAG value 4 to text_back button |
cpm219 | 18:d1566d9b6ea1 | 438 | |
cpm219 | 18:d1566d9b6ea1 | 439 | //backlight slider |
cpm219 | 18:d1566d9b6ea1 | 440 | TFT.Track( (TFT.DispWidth*1/3), 200, (TFT.DispWidth*1/3), 50, 1); // track aree of backlight slider |
cpm219 | 18:d1566d9b6ea1 | 441 | TFT.DL(TAG(1)); |
cpm219 | 18:d1566d9b6ea1 | 442 | TFT.Slider((TFT.DispWidth*1/3), 200, (TFT.DispWidth*1/3), 50,0, val , 127 ); // assign TAG value 5 to text_back button |
cpm219 | 18:d1566d9b6ea1 | 443 | |
cpm219 | 18:d1566d9b6ea1 | 444 | //check if slider is touched |
cpm219 | 18:d1566d9b6ea1 | 445 | if (tag == 1) { |
cpm219 | 18:d1566d9b6ea1 | 446 | |
cpm219 | 18:d1566d9b6ea1 | 447 | val = tracker/512; |
cpm219 | 18:d1566d9b6ea1 | 448 | |
cpm219 | 18:d1566d9b6ea1 | 449 | //limit the backlight to <91 |
cpm219 | 18:d1566d9b6ea1 | 450 | // if(val > 90) |
cpm219 | 18:d1566d9b6ea1 | 451 | // { |
cpm219 | 18:d1566d9b6ea1 | 452 | // val = 90; |
cpm219 | 18:d1566d9b6ea1 | 453 | // } |
cpm219 | 18:d1566d9b6ea1 | 454 | |
cpm219 | 18:d1566d9b6ea1 | 455 | TFT.Wr16(REG_PWM_DUTY, (val)); |
cpm219 | 18:d1566d9b6ea1 | 456 | } |
cpm219 | 18:d1566d9b6ea1 | 457 | |
cpm219 | 17:f98333612db8 | 458 | |
cpm219 | 18:d1566d9b6ea1 | 459 | TFT.DL(TAG(0)); // assign TAG value 0 to bitmap |
cpm219 | 18:d1566d9b6ea1 | 460 | //backlight text |
cpm219 | 18:d1566d9b6ea1 | 461 | TFT.DL(COLOR_RGB(0x00, 0x00, 0x00)); |
cpm219 | 18:d1566d9b6ea1 | 462 | TFT.Text((TFT.DispWidth/2), (TFT.DispHeight*5/8), font_button, OPT_CENTERX, "backlight pwm value:"); // draw Text with font 31 |
cpm219 | 18:d1566d9b6ea1 | 463 | |
cpm219 | 18:d1566d9b6ea1 | 464 | //sprintf(buffer, "%.1i", val+1); // write val to buffer |
cpm219 | 18:d1566d9b6ea1 | 465 | // TFT.Text((TFT.DispWidth*3/4)-20, (TFT.DispHeight*5/8), font_title, OPT_CENTERX, buffer); // draw Text with font 31 |
cpm219 | 18:d1566d9b6ea1 | 466 | |
cpm219 | 18:d1566d9b6ea1 | 467 | TFT.Number((TFT.DispWidth*3/4)-40, (TFT.DispHeight*5/8)-15,font_title,0, val); |
cpm219 | 18:d1566d9b6ea1 | 468 | |
cpm219 | 18:d1566d9b6ea1 | 469 | |
cpm219 | 17:f98333612db8 | 470 | TFT.DL(TAG(0)); // assign TAG value 0 to everything else |
cpm219 | 18:d1566d9b6ea1 | 471 | |
cpm219 | 18:d1566d9b6ea1 | 472 | //title text |
cpm219 | 17:f98333612db8 | 473 | TFT.DL(COLOR_RGB(0x00, 0x7C, 0xC4)); |
cpm219 | 17:f98333612db8 | 474 | TFT.Text((TFT.DispWidth/2), TFT.DispHeight/8, font_title, OPT_CENTERX, text_b); // draw Text with font 31 |
cpm219 | 18:d1566d9b6ea1 | 475 | |
cpm219 | 17:f98333612db8 | 476 | //author text |
cpm219 | 17:f98333612db8 | 477 | TFT.DL(COLOR_RGB(0x00, 0x00, 0x00)); |
cpm219 | 18:d1566d9b6ea1 | 478 | TFT.Text((TFT.DispWidth*7/8)+9, (TFT.DispHeight*15/16), font_button, OPT_CENTERX, text_author); // draw Text with font 31 |
cpm219 | 18:d1566d9b6ea1 | 479 | |
cpm219 | 18:d1566d9b6ea1 | 480 | //display the screen |
cpm219 | 18:d1566d9b6ea1 | 481 | TFT.DL(DISPLAY()); // display the image |
cpm219 | 18:d1566d9b6ea1 | 482 | TFT.Swap(); // swap the current display list |
cpm219 | 18:d1566d9b6ea1 | 483 | TFT.Flush_Co_Buffer(); // download the command list into fifo |
cpm219 | 18:d1566d9b6ea1 | 484 | TFT.WaitCmdfifo_empty(); // wait till coprocessor completes the operation |
cpm219 | 18:d1566d9b6ea1 | 485 | } |
cpm219 | 18:d1566d9b6ea1 | 486 | |
cpm219 | 18:d1566d9b6ea1 | 487 | |
cpm219 | 18:d1566d9b6ea1 | 488 | |
cpm219 | 18:d1566d9b6ea1 | 489 | /************************ |
cpm219 | 18:d1566d9b6ea1 | 490 | function: mode_c |
cpm219 | 18:d1566d9b6ea1 | 491 | description: draws mode C screen |
cpm219 | 18:d1566d9b6ea1 | 492 | *************************/ |
cpm219 | 18:d1566d9b6ea1 | 493 | void mode_c(uint32_t tracker, uint8_t tag) |
cpm219 | 18:d1566d9b6ea1 | 494 | { |
cpm219 | 18:d1566d9b6ea1 | 495 | //ISE40 STATUS DISPLAY |
cpm219 | 18:d1566d9b6ea1 | 496 | static uint16_t data_raw_a9 = 0x0000; |
cpm219 | 18:d1566d9b6ea1 | 497 | data_raw_a9 = ((analog_in9.read_u16()>>7) & 0x1FF ); |
cpm219 | 18:d1566d9b6ea1 | 498 | |
cpm219 | 18:d1566d9b6ea1 | 499 | //start new display list |
cpm219 | 18:d1566d9b6ea1 | 500 | TFT.DLstart(); // start a new display command list |
cpm219 | 18:d1566d9b6ea1 | 501 | |
cpm219 | 18:d1566d9b6ea1 | 502 | TFT.DL(TAG(0)); // assign TAG value 0 to everything else |
cpm219 | 18:d1566d9b6ea1 | 503 | |
cpm219 | 17:f98333612db8 | 504 | |
cpm219 | 18:d1566d9b6ea1 | 505 | if (data_raw_a9 > 0xFF) // if greater than half of max input |
cpm219 | 18:d1566d9b6ea1 | 506 | { |
cpm219 | 18:d1566d9b6ea1 | 507 | //then ise40 "switch on!" |
cpm219 | 18:d1566d9b6ea1 | 508 | TFT.DL(CLEAR_COLOR_RGB(0,0xFF,0)); // set the clear color to green |
cpm219 | 18:d1566d9b6ea1 | 509 | TFT.DL(CLEAR(1,1,1)); // clear buffers -> color buffer,stencil buffer, tag buffer |
cpm219 | 18:d1566d9b6ea1 | 510 | |
cpm219 | 18:d1566d9b6ea1 | 511 | //message text |
cpm219 | 18:d1566d9b6ea1 | 512 | TFT.DL(COLOR_RGB(0,0,0)); // set text color to white |
cpm219 | 18:d1566d9b6ea1 | 513 | TFT.Text((TFT.DispWidth/2), (TFT.DispHeight/2), font_title, OPT_CENTERX, "SWITCH ON!"); // draw Text with font 31 |
cpm219 | 18:d1566d9b6ea1 | 514 | } |
cpm219 | 18:d1566d9b6ea1 | 515 | else |
cpm219 | 18:d1566d9b6ea1 | 516 | { |
cpm219 | 18:d1566d9b6ea1 | 517 | //then ies40 "switch off!" |
cpm219 | 18:d1566d9b6ea1 | 518 | |
cpm219 | 18:d1566d9b6ea1 | 519 | TFT.DL(CLEAR_COLOR_RGB(0xFF,0,0)); // set the clear color to green |
cpm219 | 18:d1566d9b6ea1 | 520 | TFT.DL(CLEAR(1,1,1)); // clear buffers -> color buffer,stencil buffer, tag buffer |
cpm219 | 18:d1566d9b6ea1 | 521 | |
cpm219 | 18:d1566d9b6ea1 | 522 | //message text |
cpm219 | 18:d1566d9b6ea1 | 523 | TFT.DL(COLOR_RGB(0,0,0)); // set text color to white |
cpm219 | 18:d1566d9b6ea1 | 524 | TFT.Text((TFT.DispWidth/2), (TFT.DispHeight/2), font_title, OPT_CENTERX, "SWITCH OFF!"); // draw Text with font 31 |
cpm219 | 18:d1566d9b6ea1 | 525 | } |
cpm219 | 18:d1566d9b6ea1 | 526 | |
cpm219 | 18:d1566d9b6ea1 | 527 | TFT.Text((TFT.DispWidth/2), (TFT.DispHeight/8), font_title, OPT_CENTERX, "ISE40A"); // draw Text with font 31 |
cpm219 | 18:d1566d9b6ea1 | 528 | |
cpm219 | 18:d1566d9b6ea1 | 529 | //buttons |
cpm219 | 18:d1566d9b6ea1 | 530 | TFT.DL(COLOR_RGB(0xFF, 0xFF, 0xFF)); //this sets the button text color |
cpm219 | 18:d1566d9b6ea1 | 531 | TFT.FgColor(0x007CC4); // this sets the button color |
cpm219 | 18:d1566d9b6ea1 | 532 | |
cpm219 | 18:d1566d9b6ea1 | 533 | //back button |
cpm219 | 18:d1566d9b6ea1 | 534 | TFT.Track( 50, 355, 100, 75, 4); // track aree of button back |
cpm219 | 18:d1566d9b6ea1 | 535 | TFT.DL(TAG(4)); |
cpm219 | 18:d1566d9b6ea1 | 536 | TFT.Button(50, 355, 100, 75, font_button, 4, text_back); // assign TAG value 4 to text_back button |
cpm219 | 18:d1566d9b6ea1 | 537 | |
cpm219 | 18:d1566d9b6ea1 | 538 | TFT.DL(TAG(0)); // assign TAG value 0 to everything else |
cpm219 | 18:d1566d9b6ea1 | 539 | //author text |
cpm219 | 18:d1566d9b6ea1 | 540 | TFT.DL(COLOR_RGB(0,0,0)); |
cpm219 | 18:d1566d9b6ea1 | 541 | TFT.Text((TFT.DispWidth*7/8)+9, (TFT.DispHeight*15/16), font_button, OPT_CENTERX, text_author); // draw Text with font 31 |
cpm219 | 18:d1566d9b6ea1 | 542 | |
cpm219 | 17:f98333612db8 | 543 | //display the screen |
cpm219 | 17:f98333612db8 | 544 | TFT.DL(DISPLAY()); // display the image |
cpm219 | 17:f98333612db8 | 545 | TFT.Swap(); // swap the current display list |
cpm219 | 17:f98333612db8 | 546 | TFT.Flush_Co_Buffer(); // download the command list into fifo |
cpm219 | 17:f98333612db8 | 547 | TFT.WaitCmdfifo_empty(); // wait till coprocessor completes the operation |
cpm219 | 17:f98333612db8 | 548 | } |
cpm219 | 17:f98333612db8 | 549 | |
cpm219 | 17:f98333612db8 | 550 | |
cpm219 | 17:f98333612db8 | 551 | |
cpm219 | 17:f98333612db8 | 552 | /************************ |
cpm219 | 17:f98333612db8 | 553 | function: plot_nothing |
cpm219 | 17:f98333612db8 | 554 | description: clears plot area |
cpm219 | 17:f98333612db8 | 555 | *************************/ |
cpm219 | 17:f98333612db8 | 556 | void plot_nothing(void) |
cpm219 | 17:f98333612db8 | 557 | { |
cpm219 | 18:d1566d9b6ea1 | 558 | TFT.DL(COLOR_RGB(0x00, 0x00, 0x00)); |
cpm219 | 17:f98333612db8 | 559 | |
cpm219 | 17:f98333612db8 | 560 | } |
cpm219 | 17:f98333612db8 | 561 | |
cpm219 | 17:f98333612db8 | 562 | |
cpm219 | 18:d1566d9b6ea1 | 563 | |
cpm219 | 17:f98333612db8 | 564 | /************************ |
cpm219 | 17:f98333612db8 | 565 | function: plot_square |
cpm219 | 17:f98333612db8 | 566 | description: plots square wave |
cpm219 | 17:f98333612db8 | 567 | *************************/ |
cpm219 | 17:f98333612db8 | 568 | void plot_square(void) |
cpm219 | 17:f98333612db8 | 569 | { |
cpm219 | 18:d1566d9b6ea1 | 570 | static const int16_t square_wave_lookup[40] = { -100,-100,-100,-100,-100, 100,100,100,100,100, |
cpm219 | 18:d1566d9b6ea1 | 571 | -100,-100,-100,-100,-100, 100,100,100,100,100, |
cpm219 | 18:d1566d9b6ea1 | 572 | -100,-100,-100,-100,-100, 100,100,100,100,100, |
cpm219 | 18:d1566d9b6ea1 | 573 | -100,-100,-100,-100,-100, 100,100,100,100,100 |
cpm219 | 18:d1566d9b6ea1 | 574 | }; |
cpm219 | 18:d1566d9b6ea1 | 575 | |
cpm219 | 18:d1566d9b6ea1 | 576 | TFT.DL(COLOR_RGB(0xFF, 0x00, 0x00)); |
cpm219 | 18:d1566d9b6ea1 | 577 | for(i = 0; i<40; i++) { |
cpm219 | 18:d1566d9b6ea1 | 578 | TFT.DL( VERTEX2F(50*16 +18*i*16, 250*16 - (square_wave_lookup[i])*16) ); |
cpm219 | 17:f98333612db8 | 579 | } |
cpm219 | 17:f98333612db8 | 580 | } |
cpm219 | 17:f98333612db8 | 581 | |
cpm219 | 17:f98333612db8 | 582 | |
cpm219 | 18:d1566d9b6ea1 | 583 | |
cpm219 | 17:f98333612db8 | 584 | /************************ |
cpm219 | 17:f98333612db8 | 585 | function: plot_triangle |
cpm219 | 17:f98333612db8 | 586 | description: plots triangle wave |
cpm219 | 17:f98333612db8 | 587 | *************************/ |
cpm219 | 17:f98333612db8 | 588 | void plot_triangle(void) |
cpm219 | 17:f98333612db8 | 589 | { |
cpm219 | 18:d1566d9b6ea1 | 590 | static const int16_t tri_wave_lookup[40] = { 100,0,-100,0, 100,0,-100,0, |
cpm219 | 18:d1566d9b6ea1 | 591 | 100,0,-100,0, 100,0,-100,0, |
cpm219 | 18:d1566d9b6ea1 | 592 | 100,0,-100,0, 100,0,-100,0, |
cpm219 | 18:d1566d9b6ea1 | 593 | 100,0,-100,0, 100,0,-100,0, |
cpm219 | 18:d1566d9b6ea1 | 594 | 100,0,-100,0, 100,0,-100,0 |
cpm219 | 18:d1566d9b6ea1 | 595 | }; |
cpm219 | 18:d1566d9b6ea1 | 596 | TFT.DL(COLOR_RGB(0xFF, 0xFF, 0x00)); |
cpm219 | 18:d1566d9b6ea1 | 597 | for(i = 0; i<40; i++) { |
cpm219 | 18:d1566d9b6ea1 | 598 | TFT.DL( VERTEX2F(50*16 +18*i*16, 250*16 - (tri_wave_lookup[i])*16) ); |
cpm219 | 17:f98333612db8 | 599 | } |
cpm219 | 17:f98333612db8 | 600 | } |
cpm219 | 18:d1566d9b6ea1 | 601 | |
cpm219 | 18:d1566d9b6ea1 | 602 | |
cpm219 | 18:d1566d9b6ea1 | 603 | |
cpm219 | 18:d1566d9b6ea1 | 604 | ///************************ |
cpm219 | 18:d1566d9b6ea1 | 605 | // function: plot_sine |
cpm219 | 18:d1566d9b6ea1 | 606 | // description: plots sine wave |
cpm219 | 18:d1566d9b6ea1 | 607 | //*************************/ |
cpm219 | 18:d1566d9b6ea1 | 608 | //void plot_sine(void) |
cpm219 | 18:d1566d9b6ea1 | 609 | //{ |
cpm219 | 18:d1566d9b6ea1 | 610 | // static const int16_t sine_wave_lookup[40] = { 0, 16, 31, 45, 59, 71, 81, 89, 95, 99, |
cpm219 | 18:d1566d9b6ea1 | 611 | // 100, 99, 95, 89, 81, 71, 59, 45, 31, 16, |
cpm219 | 18:d1566d9b6ea1 | 612 | // -0, -16, -31, -45, -59, -71, -81, -89, -95, -99, |
cpm219 | 18:d1566d9b6ea1 | 613 | // -100, -99, -95, -89, -81, -71, -59, -45, -31, -16, |
cpm219 | 18:d1566d9b6ea1 | 614 | // }; |
cpm219 | 18:d1566d9b6ea1 | 615 | // |
cpm219 | 18:d1566d9b6ea1 | 616 | // TFT.DL(COLOR_RGB(0xFF, 0x00, 0xFF)); |
cpm219 | 18:d1566d9b6ea1 | 617 | // for(i = 0; i<40; i++) { |
cpm219 | 18:d1566d9b6ea1 | 618 | // TFT.DL( VERTEX2F(50*16 +18*i*16, 250*16 + (sine_wave_lookup[i])*16) ); |
cpm219 | 18:d1566d9b6ea1 | 619 | // } |
cpm219 | 18:d1566d9b6ea1 | 620 | //} |
cpm219 | 18:d1566d9b6ea1 | 621 | |
cpm219 | 18:d1566d9b6ea1 | 622 | |
cpm219 | 18:d1566d9b6ea1 | 623 | |
cpm219 | 17:f98333612db8 | 624 | /************************ |
cpm219 | 18:d1566d9b6ea1 | 625 | function: plot_data1 |
cpm219 | 18:d1566d9b6ea1 | 626 | description: plots analog_in data1 |
cpm219 | 17:f98333612db8 | 627 | *************************/ |
cpm219 | 17:f98333612db8 | 628 | void plot_sine(void) |
cpm219 | 17:f98333612db8 | 629 | { |
cpm219 | 18:d1566d9b6ea1 | 630 | static const int16_t sine_wave_lookup[40] = { 0, 16, 31, 45, 59, 71, 81, 89, 95, 99, |
cpm219 | 18:d1566d9b6ea1 | 631 | 100, 99, 95, 89, 81, 71, 59, 45, 31, 16, |
cpm219 | 18:d1566d9b6ea1 | 632 | -0, -16, -31, -45, -59, -71, -81, -89, -95, -99, |
cpm219 | 18:d1566d9b6ea1 | 633 | -100, -99, -95, -89, -81, -71, -59, -45, -31, -16, |
cpm219 | 18:d1566d9b6ea1 | 634 | }; |
cpm219 | 18:d1566d9b6ea1 | 635 | |
cpm219 | 17:f98333612db8 | 636 | TFT.DL(COLOR_RGB(0xFF, 0x00, 0xFF)); |
cpm219 | 18:d1566d9b6ea1 | 637 | for(i = 0; i<40; i++) { |
cpm219 | 18:d1566d9b6ea1 | 638 | TFT.DL( VERTEX2F(50*16 +18*i*16, 250*16 - (sine_wave_lookup[i])*16) ); |
cpm219 | 17:f98333612db8 | 639 | } |
cpm219 | 17:f98333612db8 | 640 | } |
cpm219 | 17:f98333612db8 | 641 | |
cpm219 | 18:d1566d9b6ea1 | 642 | |
cpm219 | 18:d1566d9b6ea1 | 643 | |
cpm219 | 18:d1566d9b6ea1 | 644 | /************************ |
cpm219 | 18:d1566d9b6ea1 | 645 | function: collect_data |
cpm219 | 18:d1566d9b6ea1 | 646 | description: store ADC samples |
cpm219 | 18:d1566d9b6ea1 | 647 | *************************/ |
cpm219 | 18:d1566d9b6ea1 | 648 | void collect_data(void) |
cpm219 | 18:d1566d9b6ea1 | 649 | { |
cpm219 | 18:d1566d9b6ea1 | 650 | |
cpm219 | 18:d1566d9b6ea1 | 651 | static const uint16_t num_pts = 100; |
cpm219 | 18:d1566d9b6ea1 | 652 | |
cpm219 | 18:d1566d9b6ea1 | 653 | static float collect_time = 0, |
cpm219 | 18:d1566d9b6ea1 | 654 | plot_time = 0, |
cpm219 | 18:d1566d9b6ea1 | 655 | trigger_time = 0; |
cpm219 | 18:d1566d9b6ea1 | 656 | static uint16_t i = 0x00, |
cpm219 | 18:d1566d9b6ea1 | 657 | j = 0x00; |
cpm219 | 18:d1566d9b6ea1 | 658 | static Timer timer; |
cpm219 | 18:d1566d9b6ea1 | 659 | static float begin[3] = {0,0,0}, // {trigger, sample, plot} |
cpm219 | 18:d1566d9b6ea1 | 660 | end[3] = {0,0,0}; // {trigger, sample, plot} |
cpm219 | 18:d1566d9b6ea1 | 661 | |
cpm219 | 18:d1566d9b6ea1 | 662 | // static const uint16_t threshold = 10; |
cpm219 | 18:d1566d9b6ea1 | 663 | |
cpm219 | 18:d1566d9b6ea1 | 664 | // data sample from ADC |
cpm219 | 18:d1566d9b6ea1 | 665 | static uint16_t data_raw_a9[num_pts] = {}; |
cpm219 | 18:d1566d9b6ea1 | 666 | |
cpm219 | 18:d1566d9b6ea1 | 667 | timer.start(); |
cpm219 | 18:d1566d9b6ea1 | 668 | begin[0] = timer.read_us(); // trigger_begin |
cpm219 | 18:d1566d9b6ea1 | 669 | |
cpm219 | 18:d1566d9b6ea1 | 670 | |
cpm219 | 18:d1566d9b6ea1 | 671 | //do while trigger[0] < trigger[1] |
cpm219 | 18:d1566d9b6ea1 | 672 | //essentially find falling edge |
cpm219 | 18:d1566d9b6ea1 | 673 | do |
cpm219 | 18:d1566d9b6ea1 | 674 | { |
cpm219 | 18:d1566d9b6ea1 | 675 | data_raw_a9[0] = ((analog_in9.read_u16()>>7) & 0x1FF ); |
cpm219 | 18:d1566d9b6ea1 | 676 | data_raw_a9[1] = ((analog_in9.read_u16()>>7) & 0x1FF ); |
cpm219 | 18:d1566d9b6ea1 | 677 | } |
cpm219 | 18:d1566d9b6ea1 | 678 | while(data_raw_a9[1] < data_raw_a9[0]); |
cpm219 | 18:d1566d9b6ea1 | 679 | |
cpm219 | 18:d1566d9b6ea1 | 680 | do |
cpm219 | 18:d1566d9b6ea1 | 681 | { |
cpm219 | 18:d1566d9b6ea1 | 682 | data_raw_a9[0] = ((analog_in9.read_u16()>>7) & 0x1FF ); |
cpm219 | 18:d1566d9b6ea1 | 683 | data_raw_a9[1] = ((analog_in9.read_u16()>>7) & 0x1FF ); |
cpm219 | 18:d1566d9b6ea1 | 684 | } |
cpm219 | 18:d1566d9b6ea1 | 685 | while(data_raw_a9[1] > data_raw_a9[0]); |
cpm219 | 18:d1566d9b6ea1 | 686 | //do |
cpm219 | 18:d1566d9b6ea1 | 687 | // { |
cpm219 | 18:d1566d9b6ea1 | 688 | // data_raw_a9[0] = ((analog_in9.read_u16()>>7) & 0x1FF ); |
cpm219 | 18:d1566d9b6ea1 | 689 | // data_raw_a9[1] = ((analog_in9.read_u16()>>7) & 0x1FF ); |
cpm219 | 18:d1566d9b6ea1 | 690 | // } |
cpm219 | 18:d1566d9b6ea1 | 691 | // while(data_raw_a9[1] < data_raw_a9[0]); |
cpm219 | 18:d1566d9b6ea1 | 692 | // |
cpm219 | 18:d1566d9b6ea1 | 693 | // do |
cpm219 | 18:d1566d9b6ea1 | 694 | // { |
cpm219 | 18:d1566d9b6ea1 | 695 | // data_raw_a9[0] = ((analog_in9.read_u16()>>7) & 0x1FF ); |
cpm219 | 18:d1566d9b6ea1 | 696 | // data_raw_a9[1] = ((analog_in9.read_u16()>>7) & 0x1FF ); |
cpm219 | 18:d1566d9b6ea1 | 697 | // } |
cpm219 | 18:d1566d9b6ea1 | 698 | // while(data_raw_a9[1] > data_raw_a9[0]); |
cpm219 | 18:d1566d9b6ea1 | 699 | |
cpm219 | 18:d1566d9b6ea1 | 700 | timer.stop(); |
cpm219 | 18:d1566d9b6ea1 | 701 | end[0] = timer.read_us(); //trigger_end |
cpm219 | 18:d1566d9b6ea1 | 702 | |
cpm219 | 18:d1566d9b6ea1 | 703 | |
cpm219 | 18:d1566d9b6ea1 | 704 | timer.start(); |
cpm219 | 18:d1566d9b6ea1 | 705 | begin[1] = timer.read_us(); // sample_begin |
cpm219 | 18:d1566d9b6ea1 | 706 | //collect data |
cpm219 | 18:d1566d9b6ea1 | 707 | for(i=2;i<num_pts;i++) |
cpm219 | 18:d1566d9b6ea1 | 708 | { |
cpm219 | 18:d1566d9b6ea1 | 709 | //collect adc 9 most significant bits |
cpm219 | 18:d1566d9b6ea1 | 710 | data_raw_a9[i] = ((analog_in9.read_u16()>>7) & 0x1FF ); |
cpm219 | 18:d1566d9b6ea1 | 711 | } |
cpm219 | 18:d1566d9b6ea1 | 712 | timer.stop(); |
cpm219 | 18:d1566d9b6ea1 | 713 | end[1] = timer.read_us(); // sample_end |
cpm219 | 18:d1566d9b6ea1 | 714 | |
cpm219 | 18:d1566d9b6ea1 | 715 | |
cpm219 | 18:d1566d9b6ea1 | 716 | timer.start(); |
cpm219 | 18:d1566d9b6ea1 | 717 | begin[2] = timer.read_us(); // plot_begin |
cpm219 | 18:d1566d9b6ea1 | 718 | //green plot |
cpm219 | 18:d1566d9b6ea1 | 719 | TFT.DL(COLOR_RGB(0x00, 0xFF, 0x00)); |
cpm219 | 18:d1566d9b6ea1 | 720 | //plot data |
cpm219 | 18:d1566d9b6ea1 | 721 | for(i=0;i<num_pts;i++) |
cpm219 | 18:d1566d9b6ea1 | 722 | { |
cpm219 | 18:d1566d9b6ea1 | 723 | TFT.DL(VERTEX2F(8*i*16, TFT.DispHeight*16 - data_raw_a9[i]*15)); // 15/16 *512 = 480 which is disp_height |
cpm219 | 18:d1566d9b6ea1 | 724 | } |
cpm219 | 18:d1566d9b6ea1 | 725 | timer.stop(); |
cpm219 | 18:d1566d9b6ea1 | 726 | end[2] = timer.read_us(); // plot_end |
cpm219 | 18:d1566d9b6ea1 | 727 | |
cpm219 | 18:d1566d9b6ea1 | 728 | |
cpm219 | 18:d1566d9b6ea1 | 729 | trigger_time =(end[0]-begin[0])/1000; |
cpm219 | 18:d1566d9b6ea1 | 730 | collect_time =(end[1]-begin[1])/1000; |
cpm219 | 18:d1566d9b6ea1 | 731 | plot_time = (end[2]-begin[2])/1000; |
cpm219 | 18:d1566d9b6ea1 | 732 | |
cpm219 | 18:d1566d9b6ea1 | 733 | TFT.DL(COLOR_RGB(0xFF, 0xFF, 0xFF)); |
cpm219 | 18:d1566d9b6ea1 | 734 | //data points |
cpm219 | 18:d1566d9b6ea1 | 735 | TFT.Text((TFT.DispWidth*7/8), TFT.DispHeight/32, font_button, OPT_RIGHTX, " data points: "); // draw Text with font 31 |
cpm219 | 18:d1566d9b6ea1 | 736 | TFT.Number((TFT.DispWidth*7/8), (TFT.DispHeight/32),font_button,0,num_pts); |
cpm219 | 18:d1566d9b6ea1 | 737 | |
cpm219 | 18:d1566d9b6ea1 | 738 | //trigger time |
cpm219 | 18:d1566d9b6ea1 | 739 | TFT.Text((TFT.DispWidth*7/8), TFT.DispHeight*3/32, font_button, OPT_RIGHTX, " trigger time [ms]: "); // draw Text with font 31 |
cpm219 | 18:d1566d9b6ea1 | 740 | TFT.Number((TFT.DispWidth*7/8), (TFT.DispHeight*3/32),font_button,0,trigger_time); |
cpm219 | 18:d1566d9b6ea1 | 741 | |
cpm219 | 18:d1566d9b6ea1 | 742 | //sample time |
cpm219 | 18:d1566d9b6ea1 | 743 | TFT.Text((TFT.DispWidth*7/8), TFT.DispHeight*5/32, font_button, OPT_RIGHTX, "sample time [ms]: "); // draw Text with font 31 |
cpm219 | 18:d1566d9b6ea1 | 744 | TFT.Number((TFT.DispWidth*7/8), (TFT.DispHeight*5/32),font_button,0,collect_time); |
cpm219 | 18:d1566d9b6ea1 | 745 | |
cpm219 | 18:d1566d9b6ea1 | 746 | //plot time |
cpm219 | 18:d1566d9b6ea1 | 747 | TFT.Text((TFT.DispWidth*7/8), TFT.DispHeight*7/32, font_button, OPT_RIGHTX, "plot time [ms]: "); // draw Text with font 31 |
cpm219 | 18:d1566d9b6ea1 | 748 | TFT.Number((TFT.DispWidth*7/8), (TFT.DispHeight*7/32),font_button,0,plot_time); |
cpm219 | 18:d1566d9b6ea1 | 749 | |
cpm219 | 18:d1566d9b6ea1 | 750 | } |
cpm219 | 18:d1566d9b6ea1 | 751 | |
cpm219 | 18:d1566d9b6ea1 | 752 | |
cpm219 | 18:d1566d9b6ea1 | 753 | |
cpm219 | 18:d1566d9b6ea1 | 754 | /****************************************************************************/ |
cpm219 | 18:d1566d9b6ea1 | 755 | /* Checks for an SD card and reads/writes the calibration data */ |
cpm219 | 18:d1566d9b6ea1 | 756 | /* from the SD card */ |
cpm219 | 18:d1566d9b6ea1 | 757 | /****************************************************************************/ |
cpm219 | 18:d1566d9b6ea1 | 758 | uint8_t read_calibration() |
cpm219 | 18:d1566d9b6ea1 | 759 | { |
cpm219 | 18:d1566d9b6ea1 | 760 | static ft_char8_t temp_string[32] = {"\0"}; |
cpm219 | 18:d1566d9b6ea1 | 761 | static uint8_t tcal[24]; // touch screen Calibration |
cpm219 | 18:d1566d9b6ea1 | 762 | |
cpm219 | 18:d1566d9b6ea1 | 763 | while(sdcard_present.read()) { |
cpm219 | 18:d1566d9b6ea1 | 764 | // checks for SD card, if not present hold program until a SD card is inserted |
cpm219 | 18:d1566d9b6ea1 | 765 | error_screen("Error!","Insert SD card!"); // write error screen to LCD |
cpm219 | 18:d1566d9b6ea1 | 766 | } |
cpm219 | 18:d1566d9b6ea1 | 767 | |
cpm219 | 18:d1566d9b6ea1 | 768 | sd.mount(); |
cpm219 | 18:d1566d9b6ea1 | 769 | FILE *fp= fopen("/sd/TCal/TCalData.txt", "r"); |
cpm219 | 18:d1566d9b6ea1 | 770 | if (fp != NULL) { |
cpm219 | 18:d1566d9b6ea1 | 771 | //file successfully opened for reading! |
cpm219 | 18:d1566d9b6ea1 | 772 | fread(temp_string,24,1,fp); |
cpm219 | 18:d1566d9b6ea1 | 773 | for (i = 0; i < 24; i++) { |
cpm219 | 18:d1566d9b6ea1 | 774 | // convert from int to char |
cpm219 | 18:d1566d9b6ea1 | 775 | tcal[i] = temp_string[i]; |
cpm219 | 18:d1566d9b6ea1 | 776 | } |
cpm219 | 18:d1566d9b6ea1 | 777 | TFT.write_calibrate(tcal); // write cal data to screen |
cpm219 | 18:d1566d9b6ea1 | 778 | fclose(fp); |
cpm219 | 18:d1566d9b6ea1 | 779 | sd.unmount(); |
cpm219 | 18:d1566d9b6ea1 | 780 | return 0; |
cpm219 | 18:d1566d9b6ea1 | 781 | } else { |
cpm219 | 18:d1566d9b6ea1 | 782 | //file not opened. might not exist. |
cpm219 | 18:d1566d9b6ea1 | 783 | TFT.Calibrate(); // calibrate the touch screen |
cpm219 | 18:d1566d9b6ea1 | 784 | TFT.read_calibrate(tcal); // read in cal data from screen |
cpm219 | 18:d1566d9b6ea1 | 785 | mkdir("/sd/TCal", 0777); // open file for saving calibration data |
cpm219 | 18:d1566d9b6ea1 | 786 | FILE *fp = fopen("/sd/TCal/TCalData.txt", "w"); |
cpm219 | 18:d1566d9b6ea1 | 787 | for (i = 0; i < 25; i++) { // save integers one at a time to the file |
cpm219 | 18:d1566d9b6ea1 | 788 | fprintf(fp, "%c", tcal[i] ); |
cpm219 | 18:d1566d9b6ea1 | 789 | } |
cpm219 | 18:d1566d9b6ea1 | 790 | fclose(fp); |
cpm219 | 18:d1566d9b6ea1 | 791 | sd.unmount(); |
cpm219 | 18:d1566d9b6ea1 | 792 | return 1; |
cpm219 | 18:d1566d9b6ea1 | 793 | |
cpm219 | 18:d1566d9b6ea1 | 794 | } |
cpm219 | 18:d1566d9b6ea1 | 795 | } |
cpm219 | 18:d1566d9b6ea1 | 796 | |
cpm219 | 18:d1566d9b6ea1 | 797 | |
cpm219 | 18:d1566d9b6ea1 | 798 | |
cpm219 | 18:d1566d9b6ea1 | 799 | /**************************************************************************** |
cpm219 | 18:d1566d9b6ea1 | 800 | * tests functional operation of sd card by read/write |
cpm219 | 18:d1566d9b6ea1 | 801 | ****************************************************************************/ |
cpm219 | 18:d1566d9b6ea1 | 802 | uint8_t sd_test(void) |
cpm219 | 18:d1566d9b6ea1 | 803 | { |
cpm219 | 18:d1566d9b6ea1 | 804 | while(sdcard_present.read()) { |
cpm219 | 18:d1566d9b6ea1 | 805 | // checks for SD card, if not present hold program until a SD card is inserted |
cpm219 | 18:d1566d9b6ea1 | 806 | error_screen("Error!","Insert SD card!"); // write error screen to LCD |
cpm219 | 18:d1566d9b6ea1 | 807 | } |
cpm219 | 18:d1566d9b6ea1 | 808 | |
cpm219 | 18:d1566d9b6ea1 | 809 | TFT.DLstart(); // start a new display command list |
cpm219 | 18:d1566d9b6ea1 | 810 | TFT.DL(CLEAR_COLOR_RGB(0,0,0)); // clear the screen and set the background to green |
cpm219 | 18:d1566d9b6ea1 | 811 | TFT.DL(CLEAR(1,1,1)); // clear buffers -> color buffer,stencil buffer, tag buffer |
cpm219 | 18:d1566d9b6ea1 | 812 | TFT.DL(COLOR_RGB(255,255,255)); |
cpm219 | 18:d1566d9b6ea1 | 813 | |
cpm219 | 18:d1566d9b6ea1 | 814 | sd.mount(); |
cpm219 | 18:d1566d9b6ea1 | 815 | |
cpm219 | 18:d1566d9b6ea1 | 816 | //Perform a write test |
cpm219 | 18:d1566d9b6ea1 | 817 | // printf("\nWriting to SD card..."); |
cpm219 | 18:d1566d9b6ea1 | 818 | TFT.Text((TFT.DispWidth/2), 150, 28, OPT_CENTERX, "Writing to SD card...\0"); // draw Text with font 31 |
cpm219 | 18:d1566d9b6ea1 | 819 | FILE *fp = fopen("/sd/sdtest.txt", "w"); |
cpm219 | 18:d1566d9b6ea1 | 820 | if (fp != NULL) { |
cpm219 | 18:d1566d9b6ea1 | 821 | //file successfully opened for writing! |
cpm219 | 18:d1566d9b6ea1 | 822 | fprintf(fp, "We're writing to an SD card!"); |
cpm219 | 18:d1566d9b6ea1 | 823 | fclose(fp); |
cpm219 | 18:d1566d9b6ea1 | 824 | TFT.DL(CLEAR_COLOR_RGB(0,255,0)); // clear the screen and set the background to green |
cpm219 | 18:d1566d9b6ea1 | 825 | TFT.DL(CLEAR(1,1,1)); // clear buffers -> color buffer,stencil buffer, tag buffer |
cpm219 | 18:d1566d9b6ea1 | 826 | TFT.Text((TFT.DispWidth/2), 200, 28, OPT_CENTERX,"open file success\0" ); // draw Text with font 31 |
cpm219 | 18:d1566d9b6ea1 | 827 | |
cpm219 | 18:d1566d9b6ea1 | 828 | } else { |
cpm219 | 18:d1566d9b6ea1 | 829 | // printf("failed!\n"); |
cpm219 | 18:d1566d9b6ea1 | 830 | TFT.DL(CLEAR_COLOR_RGB(255,0,0)); // clear the screen and set the background to green |
cpm219 | 18:d1566d9b6ea1 | 831 | TFT.DL(CLEAR(1,1,1)); // clear buffers -> color buffer,stencil buffer, tag buffer |
cpm219 | 18:d1566d9b6ea1 | 832 | TFT.Text((TFT.DispWidth/2), 200, 28, OPT_CENTERX, "open file failed!\0"); // draw Text with font 31 |
cpm219 | 18:d1566d9b6ea1 | 833 | } |
cpm219 | 18:d1566d9b6ea1 | 834 | |
cpm219 | 18:d1566d9b6ea1 | 835 | //Perform a read test |
cpm219 | 18:d1566d9b6ea1 | 836 | // fprintf("Reading from SD card..."); |
cpm219 | 18:d1566d9b6ea1 | 837 | TFT.Text((TFT.DispWidth/2), 250, 28, OPT_CENTERX, "Reading from SD card...\0"); // draw Text with font 31 |
cpm219 | 18:d1566d9b6ea1 | 838 | |
cpm219 | 18:d1566d9b6ea1 | 839 | fp = fopen("/sd/sdtest.txt", "r"); |
cpm219 | 18:d1566d9b6ea1 | 840 | if (fp != NULL) { |
cpm219 | 18:d1566d9b6ea1 | 841 | char c = fgetc(fp); |
cpm219 | 18:d1566d9b6ea1 | 842 | if (c == 'W') { |
cpm219 | 18:d1566d9b6ea1 | 843 | // printf("success!\n"); |
cpm219 | 18:d1566d9b6ea1 | 844 | TFT.Text((TFT.DispWidth/2), 300, 28, OPT_CENTERX, "correct char!\0"); // draw Text with font 31 |
cpm219 | 18:d1566d9b6ea1 | 845 | |
cpm219 | 18:d1566d9b6ea1 | 846 | } else { |
cpm219 | 18:d1566d9b6ea1 | 847 | // fprintf("incorrect char (%c)!\n", c); |
cpm219 | 18:d1566d9b6ea1 | 848 | TFT.Text((TFT.DispWidth/2), 300, 28, OPT_CENTERX, "incorrect char!\0"); // draw Text with font 31 |
cpm219 | 18:d1566d9b6ea1 | 849 | } |
cpm219 | 18:d1566d9b6ea1 | 850 | sd.unmount(); |
cpm219 | 18:d1566d9b6ea1 | 851 | TFT.DL(DISPLAY()); // display the image |
cpm219 | 18:d1566d9b6ea1 | 852 | TFT.Swap(); // swap the current display list |
cpm219 | 18:d1566d9b6ea1 | 853 | TFT.Flush_Co_Buffer(); // download the command list into fifo |
cpm219 | 18:d1566d9b6ea1 | 854 | TFT.WaitCmdfifo_empty(); // wait till coprocessor completes the operation |
cpm219 | 18:d1566d9b6ea1 | 855 | TFT.Sleep(2000); |
cpm219 | 18:d1566d9b6ea1 | 856 | fclose(fp); |
cpm219 | 18:d1566d9b6ea1 | 857 | return 0; |
cpm219 | 18:d1566d9b6ea1 | 858 | |
cpm219 | 18:d1566d9b6ea1 | 859 | } else { |
cpm219 | 18:d1566d9b6ea1 | 860 | // printf("failed!\n"); |
cpm219 | 18:d1566d9b6ea1 | 861 | TFT.Text((TFT.DispWidth/2), 250, 31, OPT_CENTERX, "failed to read!\0"); // draw Text with font 31 |
cpm219 | 18:d1566d9b6ea1 | 862 | sd.unmount(); |
cpm219 | 18:d1566d9b6ea1 | 863 | TFT.DL(DISPLAY()); // display the image |
cpm219 | 18:d1566d9b6ea1 | 864 | TFT.Swap(); // swap the current display list |
cpm219 | 18:d1566d9b6ea1 | 865 | TFT.Flush_Co_Buffer(); // download the command list into fifo |
cpm219 | 18:d1566d9b6ea1 | 866 | TFT.WaitCmdfifo_empty(); // wait till coprocessor completes the operation |
cpm219 | 18:d1566d9b6ea1 | 867 | TFT.Sleep(2000); |
cpm219 | 18:d1566d9b6ea1 | 868 | return 1; |
cpm219 | 18:d1566d9b6ea1 | 869 | } |
cpm219 | 18:d1566d9b6ea1 | 870 | } |
cpm219 | 18:d1566d9b6ea1 | 871 | |
cpm219 | 18:d1566d9b6ea1 | 872 | |
cpm219 | 18:d1566d9b6ea1 | 873 | |
cpm219 | 18:d1566d9b6ea1 | 874 | uint8_t bitmap_test(uint16_t x,uint16_t y) |
cpm219 | 18:d1566d9b6ea1 | 875 | { |
cpm219 | 18:d1566d9b6ea1 | 876 | |
cpm219 | 18:d1566d9b6ea1 | 877 | TFT.DLstart(); // start a new display command list |
cpm219 | 18:d1566d9b6ea1 | 878 | TFT.DL(CLEAR_COLOR_RGB(0,0,0)); // clear the screen and set the background to green |
cpm219 | 18:d1566d9b6ea1 | 879 | TFT.DL(CLEAR(1,1,1)); // clear buffers -> color buffer,stencil buffer, tag buffer |
cpm219 | 18:d1566d9b6ea1 | 880 | TFT.DL(COLOR_RGB(255,255,255)); |
cpm219 | 18:d1566d9b6ea1 | 881 | |
cpm219 | 18:d1566d9b6ea1 | 882 | //following 3 lines can be replaced with TFT.set_bitmap(0x00, 0, ) |
cpm219 | 18:d1566d9b6ea1 | 883 | TFT.DL(BITMAP_SOURCE(RAM_G)); |
cpm219 | 18:d1566d9b6ea1 | 884 | TFT.DL(BITMAP_LAYOUT(ARGB1555,2*x_size,y_size)); |
cpm219 | 18:d1566d9b6ea1 | 885 | TFT.DL(BITMAP_SIZE(NEAREST,BORDER,BORDER,x_size,y_size)); |
cpm219 | 18:d1566d9b6ea1 | 886 | |
cpm219 | 18:d1566d9b6ea1 | 887 | TFT.DL(BEGIN(BITMAPS)); //start drawing bitmaps |
cpm219 | 18:d1566d9b6ea1 | 888 | TFT.DL(VERTEX2II(25,25,0,0)); // draw logo image with bit handle 0 |
cpm219 | 18:d1566d9b6ea1 | 889 | TFT.DL(END()); |
cpm219 | 18:d1566d9b6ea1 | 890 | |
cpm219 | 18:d1566d9b6ea1 | 891 | TFT.Text((TFT.DispWidth/2), 170, 31, OPT_CENTERX, "bitmap_test() called\0"); // draw Text with font 31 |
cpm219 | 18:d1566d9b6ea1 | 892 | |
cpm219 | 18:d1566d9b6ea1 | 893 | TFT.DL(DISPLAY()); // display the image |
cpm219 | 18:d1566d9b6ea1 | 894 | TFT.Swap(); // swap the current display list |
cpm219 | 18:d1566d9b6ea1 | 895 | TFT.Flush_Co_Buffer(); // download the command list into fifo |
cpm219 | 18:d1566d9b6ea1 | 896 | TFT.WaitCmdfifo_empty(); // wait till coprocessor completes the operation |
cpm219 | 18:d1566d9b6ea1 | 897 | |
cpm219 | 18:d1566d9b6ea1 | 898 | return 0; |
cpm219 | 18:d1566d9b6ea1 | 899 | } |
cpm219 | 18:d1566d9b6ea1 | 900 | |
cpm219 | 18:d1566d9b6ea1 | 901 | |
cpm219 | 18:d1566d9b6ea1 | 902 | |
cpm219 | 18:d1566d9b6ea1 | 903 | /* function to load jpg file from filesystem */ |
cpm219 | 18:d1566d9b6ea1 | 904 | /* return 0 if jpg is ok */ |
cpm219 | 18:d1566d9b6ea1 | 905 | /* also return x_size and y_size of jpg */ |
cpm219 | 18:d1566d9b6ea1 | 906 | |
cpm219 | 18:d1566d9b6ea1 | 907 | int8_t Load_jpg(char* filename, ft_int16_t* x_size, ft_int16_t* y_size, ft_uint32_t address) |
cpm219 | 18:d1566d9b6ea1 | 908 | { |
cpm219 | 18:d1566d9b6ea1 | 909 | static int8_t rval = 0x00; |
cpm219 | 18:d1566d9b6ea1 | 910 | |
cpm219 | 18:d1566d9b6ea1 | 911 | while(sdcard_present.read()) { |
cpm219 | 18:d1566d9b6ea1 | 912 | // checks for SD card, if not present hold program until a SD card is inserted |
cpm219 | 18:d1566d9b6ea1 | 913 | error_screen("Error!","Insert SD card!"); // write error screen to LCD |
cpm219 | 18:d1566d9b6ea1 | 914 | } |
cpm219 | 18:d1566d9b6ea1 | 915 | |
cpm219 | 18:d1566d9b6ea1 | 916 | sd.mount(); |
cpm219 | 18:d1566d9b6ea1 | 917 | rval = TFT.Load_jpg( filename, x_size, y_size, address); |
cpm219 | 18:d1566d9b6ea1 | 918 | sd.unmount(); |
cpm219 | 18:d1566d9b6ea1 | 919 | return rval; |
cpm219 | 18:d1566d9b6ea1 | 920 | } |
cpm219 | 18:d1566d9b6ea1 | 921 | |
cpm219 | 18:d1566d9b6ea1 | 922 | |
cpm219 | 18:d1566d9b6ea1 | 923 | |
cpm219 | 18:d1566d9b6ea1 | 924 | /************************ |
cpm219 | 18:d1566d9b6ea1 | 925 | function: display_message |
cpm219 | 18:d1566d9b6ea1 | 926 | description: draws a pass/fail type message to the screen. |
cpm219 | 18:d1566d9b6ea1 | 927 | useful for debugging return values from functions. |
cpm219 | 18:d1566d9b6ea1 | 928 | *************************/ |
cpm219 | 18:d1566d9b6ea1 | 929 | void display_message(uint8_t error, const ft_char8_t *pass, const ft_char8_t *fail) |
cpm219 | 18:d1566d9b6ea1 | 930 | { |
cpm219 | 18:d1566d9b6ea1 | 931 | TFT.DLstart(); // start a new display command list |
cpm219 | 18:d1566d9b6ea1 | 932 | TFT.DL(COLOR_RGB(0,0,0)); |
cpm219 | 18:d1566d9b6ea1 | 933 | |
cpm219 | 18:d1566d9b6ea1 | 934 | if(error == 0x00) { |
cpm219 | 18:d1566d9b6ea1 | 935 | TFT.DL(CLEAR_COLOR_RGB(0,255,0)); // clear the screen and set the background to green |
cpm219 | 18:d1566d9b6ea1 | 936 | TFT.DL(CLEAR(1,1,1)); // clear buffers -> color buffer,stencil buffer, tag buffer |
cpm219 | 18:d1566d9b6ea1 | 937 | TFT.Text((TFT.DispWidth/2), 170, 31, OPT_CENTERX, pass); // draw Text with font 31 |
cpm219 | 18:d1566d9b6ea1 | 938 | } else { |
cpm219 | 18:d1566d9b6ea1 | 939 | TFT.DL(CLEAR_COLOR_RGB(255,0,0)); // clear the screen and set the background to red |
cpm219 | 18:d1566d9b6ea1 | 940 | TFT.DL(CLEAR(1,1,1)); // clear buffers -> color buffer,stencil buffer, tag buffer |
cpm219 | 18:d1566d9b6ea1 | 941 | TFT.Text((TFT.DispWidth/2), 170, 31, OPT_CENTERX, fail); // draw Text with font 31 |
cpm219 | 18:d1566d9b6ea1 | 942 | } |
cpm219 | 18:d1566d9b6ea1 | 943 | |
cpm219 | 18:d1566d9b6ea1 | 944 | TFT.DL(DISPLAY()); // display the image |
cpm219 | 18:d1566d9b6ea1 | 945 | TFT.Swap(); // swap the current display list |
cpm219 | 18:d1566d9b6ea1 | 946 | TFT.Flush_Co_Buffer(); // download the command list into fifo |
cpm219 | 18:d1566d9b6ea1 | 947 | TFT.WaitCmdfifo_empty(); // wait till coprocessor completes the operation |
cpm219 | 18:d1566d9b6ea1 | 948 | } |
cpm219 | 18:d1566d9b6ea1 | 949 | |
cpm219 | 18:d1566d9b6ea1 | 950 | |
cpm219 | 18:d1566d9b6ea1 | 951 | |
cpm219 | 17:f98333612db8 | 952 | /************************ |
cpm219 | 17:f98333612db8 | 953 | function: Start_Screen |
cpm219 | 17:f98333612db8 | 954 | description: draws boot up screen as images are loaded from the sd card |
cpm219 | 17:f98333612db8 | 955 | *************************/ |
cpm219 | 18:d1566d9b6ea1 | 956 | ft_void_t start_screen(ft_char8_t *str) |
cratliff | 0:aa55c6eb6867 | 957 | { |
montgojj | 11:f6a146b62579 | 958 | TFT.DLstart(); // start a new display command list |
montgojj | 11:f6a146b62579 | 959 | TFT.DL(CLEAR_COLOR_RGB(255,255,255)); // set the clear color to white |
montgojj | 11:f6a146b62579 | 960 | TFT.DL(CLEAR(1,1,1)); // clear buffers -> color buffer,stencil buffer, tag buffer |
cpm219 | 18:d1566d9b6ea1 | 961 | |
cpm219 | 17:f98333612db8 | 962 | TFT.DL(COLOR_RGB(0x00, 0x7C, 0xC4)); // generate border in SMC blue, all functions are in 1/16 pixel format |
montgojj | 4:a48fc7a3bda9 | 963 | TFT.DL(BEGIN(LINES)); |
montgojj | 4:a48fc7a3bda9 | 964 | TFT.DL(LINE_WIDTH(8 * 16)); |
montgojj | 4:a48fc7a3bda9 | 965 | TFT.DL(VERTEX2F(0*16,0*16)); |
montgojj | 4:a48fc7a3bda9 | 966 | TFT.DL(VERTEX2F(799*16,0*16)); |
montgojj | 4:a48fc7a3bda9 | 967 | TFT.DL(VERTEX2F(799*16,0*16)); |
montgojj | 4:a48fc7a3bda9 | 968 | TFT.DL(VERTEX2F(799*16,479*16)); |
montgojj | 4:a48fc7a3bda9 | 969 | TFT.DL(VERTEX2F(799*16,479*16)); |
montgojj | 4:a48fc7a3bda9 | 970 | TFT.DL(VERTEX2F(0*16,479*16)); |
montgojj | 4:a48fc7a3bda9 | 971 | TFT.DL(VERTEX2F(0*16,479*16)); |
cratliff | 5:e2e04cb5eada | 972 | TFT.DL(VERTEX2F(0*16,0*16)); |
montgojj | 4:a48fc7a3bda9 | 973 | TFT.DL(END()); |
cpm219 | 18:d1566d9b6ea1 | 974 | |
cpm219 | 17:f98333612db8 | 975 | TFT.Text((TFT.DispWidth/2), TFT.DispHeight/2, 31, OPT_CENTERX, str); // draw Text with font 31 |
cpm219 | 17:f98333612db8 | 976 | TFT.Text((TFT.DispWidth/2), 350, 31, OPT_CENTERX, text_author); // draw Text with font 31 |
cpm219 | 17:f98333612db8 | 977 | TFT.Spinner((TFT.DispWidth/2),TFT.DispHeight/4, 0,0); // draw a animated spinner |
cpm219 | 18:d1566d9b6ea1 | 978 | |
cpm219 | 17:f98333612db8 | 979 | TFT.DL(DISPLAY()); // Display the image |
cpm219 | 17:f98333612db8 | 980 | TFT.Swap(); // Swap the current display list |
cpm219 | 17:f98333612db8 | 981 | TFT.Flush_Co_Buffer(); // Download the command list into fifo |
cpm219 | 17:f98333612db8 | 982 | TFT.WaitCmdfifo_empty(); // Wait till coprocessor completes the operation |
cpm219 | 18:d1566d9b6ea1 | 983 | } |
cpm219 | 18:d1566d9b6ea1 | 984 | |
cpm219 | 18:d1566d9b6ea1 | 985 | |
cpm219 | 18:d1566d9b6ea1 | 986 | |
cpm219 | 18:d1566d9b6ea1 | 987 | /****************************************************************************/ |
cpm219 | 18:d1566d9b6ea1 | 988 | /* This function displays the error screen */ |
cpm219 | 18:d1566d9b6ea1 | 989 | /* the function causes the screen to flash yellow and writes text to the LCD*/ |
cpm219 | 18:d1566d9b6ea1 | 990 | /****************************************************************************/ |
cpm219 | 18:d1566d9b6ea1 | 991 | void error_screen(ft_char8_t *str1, ft_char8_t *str2) |
cpm219 | 18:d1566d9b6ea1 | 992 | { |
cpm219 | 18:d1566d9b6ea1 | 993 | TFT.DLstart(); // start a new display command list |
cpm219 | 18:d1566d9b6ea1 | 994 | TFT.DL(CLEAR_COLOR_RGB(255,242,0)); // clear the screen and set the background to yellow |
cpm219 | 18:d1566d9b6ea1 | 995 | TFT.DL(CLEAR(1,1,1)); // clear buffers -> color buffer,stencil buffer, tag buffer |
cpm219 | 18:d1566d9b6ea1 | 996 | TFT.DL(COLOR_RGB(0,0,0)); |
cpm219 | 18:d1566d9b6ea1 | 997 | TFT.Text((TFT.DispWidth/2), 170, 31, OPT_CENTERX, str1); // draw Text with font 31 |
cpm219 | 18:d1566d9b6ea1 | 998 | TFT.Text((TFT.DispWidth/2), 215, 31, OPT_CENTERX, str2); // draw Text with font 31 |
cpm219 | 18:d1566d9b6ea1 | 999 | TFT.DL(DISPLAY()); // display the image |
cpm219 | 18:d1566d9b6ea1 | 1000 | TFT.Swap(); // swap the current display list |
cpm219 | 18:d1566d9b6ea1 | 1001 | TFT.Flush_Co_Buffer(); // download the command list into fifo |
cpm219 | 18:d1566d9b6ea1 | 1002 | TFT.WaitCmdfifo_empty(); // wait till coprocessor completes the operation |
cpm219 | 18:d1566d9b6ea1 | 1003 | TFT.Sleep(500); |
cpm219 | 18:d1566d9b6ea1 | 1004 | |
cpm219 | 18:d1566d9b6ea1 | 1005 | TFT.DLstart(); // start a new display command list |
cpm219 | 18:d1566d9b6ea1 | 1006 | TFT.DL(CLEAR_COLOR_RGB(255,255,255)); // set clear color to white |
cpm219 | 18:d1566d9b6ea1 | 1007 | TFT.DL(CLEAR(1,1,1)); // clear buffers -> color buffer,stencil buffer, tag buffer; |
cpm219 | 18:d1566d9b6ea1 | 1008 | TFT.DL(COLOR_RGB(0,0,0)); |
cpm219 | 18:d1566d9b6ea1 | 1009 | TFT.Text((TFT.DispWidth/2), 170, 31, OPT_CENTERX, str1); // draw Text with font 31 |
cpm219 | 18:d1566d9b6ea1 | 1010 | TFT.Text((TFT.DispWidth/2), 215, 31, OPT_CENTERX, str2); // draw Text with font 31 |
cpm219 | 18:d1566d9b6ea1 | 1011 | TFT.DL(DISPLAY()); // display the image |
cpm219 | 18:d1566d9b6ea1 | 1012 | TFT.Swap(); // swap the current display list |
cpm219 | 18:d1566d9b6ea1 | 1013 | TFT.Flush_Co_Buffer(); // download the command list into fifo |
cpm219 | 18:d1566d9b6ea1 | 1014 | TFT.WaitCmdfifo_empty(); // wait till coprocessor completes the operation |
cpm219 | 18:d1566d9b6ea1 | 1015 | TFT.Sleep(500); |
montgojj | 8:886908a6127c | 1016 | } |