![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Anim
Dependencies: BSP_DISCO_F429ZI EEPROM_DISCO_F429ZI FT810 GYRO_DISCO_F429ZI KEYPAD_DISCO_F429ZI LCD_DISCO_F429ZI PinDetect SDRAM_DISCO_F429ZI TS_DISCO_F429ZI mbed
temp.h@1:2ceb29686290, 2018-01-24 (annotated)
- Committer:
- mozillain
- Date:
- Wed Jan 24 13:10:37 2018 +0000
- Revision:
- 1:2ceb29686290
Anim
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mozillain | 1:2ceb29686290 | 1 | /* |
mozillain | 1:2ceb29686290 | 2 | #include "mbed.h" |
mozillain | 1:2ceb29686290 | 3 | #include "FT_Platform.h" |
mozillain | 1:2ceb29686290 | 4 | #include "Image.h" |
mozillain | 1:2ceb29686290 | 5 | #include "pictures.h" |
mozillain | 1:2ceb29686290 | 6 | #include "PinDetect.h" |
mozillain | 1:2ceb29686290 | 7 | #include "mbcrc.h" |
mozillain | 1:2ceb29686290 | 8 | #include <string> |
mozillain | 1:2ceb29686290 | 9 | |
mozillain | 1:2ceb29686290 | 10 | PinDetect Up(PF_4); |
mozillain | 1:2ceb29686290 | 11 | PinDetect Down(PF_5); |
mozillain | 1:2ceb29686290 | 12 | PinDetect Left(PF_2); |
mozillain | 1:2ceb29686290 | 13 | PinDetect Right(PF_3); |
mozillain | 1:2ceb29686290 | 14 | PinDetect Ok(PF_1); |
mozillain | 1:2ceb29686290 | 15 | DigitalOut ho(PF_0); |
mozillain | 1:2ceb29686290 | 16 | |
mozillain | 1:2ceb29686290 | 17 | int menuNamber = 0; |
mozillain | 1:2ceb29686290 | 18 | int virtualButtonNamber = 0; |
mozillain | 1:2ceb29686290 | 19 | |
mozillain | 1:2ceb29686290 | 20 | |
mozillain | 1:2ceb29686290 | 21 | void main_menu(uint32_t tracker, uint8_t tag); |
mozillain | 1:2ceb29686290 | 22 | void LoadImagesAndFonts(void); |
mozillain | 1:2ceb29686290 | 23 | void HandleAllBitmaps(void); |
mozillain | 1:2ceb29686290 | 24 | void StartDL(void); |
mozillain | 1:2ceb29686290 | 25 | void FinishDL(void); |
mozillain | 1:2ceb29686290 | 26 | void show_logo(void); |
mozillain | 1:2ceb29686290 | 27 | void show_logo1(void); |
mozillain | 1:2ceb29686290 | 28 | int tagoption = 0; |
mozillain | 1:2ceb29686290 | 29 | |
mozillain | 1:2ceb29686290 | 30 | unsigned char command[8]={0x03,0x06,0x20,0x00,0x00,0x01,0x00,0x00}; |
mozillain | 1:2ceb29686290 | 31 | |
mozillain | 1:2ceb29686290 | 32 | //Serial pc(SERIAL_TX, SERIAL_RX); //test |
mozillain | 1:2ceb29686290 | 33 | Serial RS485(PA_9, PA_10); |
mozillain | 1:2ceb29686290 | 34 | FT800 TFT( PE_6, PE_5, PE_2, PE_4, PC_13, PC_15); |
mozillain | 1:2ceb29686290 | 35 | // ( mosi, miso, sclk, ss, intr, pd ); |
mozillain | 1:2ceb29686290 | 36 | |
mozillain | 1:2ceb29686290 | 37 | void send_command_to_RS485(unsigned char cmd) |
mozillain | 1:2ceb29686290 | 38 | { |
mozillain | 1:2ceb29686290 | 39 | RS485.format(8, Serial::None, 1); |
mozillain | 1:2ceb29686290 | 40 | RS485.baud(9600); |
mozillain | 1:2ceb29686290 | 41 | uint16_t crc16; |
mozillain | 1:2ceb29686290 | 42 | crc16 = usMBCRC16( ( unsigned char * ) command, 6 ); |
mozillain | 1:2ceb29686290 | 43 | command[5] = cmd; |
mozillain | 1:2ceb29686290 | 44 | command[6] = ( unsigned char )( crc16 >> 8 ); |
mozillain | 1:2ceb29686290 | 45 | command[7] = ( unsigned char )( crc16 & 0xFF ); |
mozillain | 1:2ceb29686290 | 46 | |
mozillain | 1:2ceb29686290 | 47 | ho = 1; // 3.3V output from digital out pin |
mozillain | 1:2ceb29686290 | 48 | RS485.putc(command[0]); // slave add |
mozillain | 1:2ceb29686290 | 49 | RS485.putc(command[1]); // function code |
mozillain | 1:2ceb29686290 | 50 | RS485.putc(command[2]); // Hi PDU add |
mozillain | 1:2ceb29686290 | 51 | RS485.putc(command[3]); // low PDU add |
mozillain | 1:2ceb29686290 | 52 | RS485.putc(command[4]); // Hi N reg |
mozillain | 1:2ceb29686290 | 53 | RS485.putc(command[5]); // Lo N reg |
mozillain | 1:2ceb29686290 | 54 | RS485.putc(command[6]); // Hi CRC |
mozillain | 1:2ceb29686290 | 55 | RS485.putc(command[7]); // Lo CRC |
mozillain | 1:2ceb29686290 | 56 | ho=0; |
mozillain | 1:2ceb29686290 | 57 | } |
mozillain | 1:2ceb29686290 | 58 | |
mozillain | 1:2ceb29686290 | 59 | |
mozillain | 1:2ceb29686290 | 60 | void main_menu(uint32_t tracker, uint8_t tag) |
mozillain | 1:2ceb29686290 | 61 | { |
mozillain | 1:2ceb29686290 | 62 | time_t seconds = time(NULL); |
mozillain | 1:2ceb29686290 | 63 | //start new display list |
mozillain | 1:2ceb29686290 | 64 | StartDL(); |
mozillain | 1:2ceb29686290 | 65 | |
mozillain | 1:2ceb29686290 | 66 | TFT.DL(TAG(0)); // assign TAG value 0 to everything else |
mozillain | 1:2ceb29686290 | 67 | //TFT.Calibrate(0); |
mozillain | 1:2ceb29686290 | 68 | |
mozillain | 1:2ceb29686290 | 69 | //TFT.DL(BEGIN(BITMAPS)); |
mozillain | 1:2ceb29686290 | 70 | //TFT.DL(VERTEX2II(11, 15, 0, 0) ); |
mozillain | 1:2ceb29686290 | 71 | //TFT.DL(END()); |
mozillain | 1:2ceb29686290 | 72 | |
mozillain | 1:2ceb29686290 | 73 | switch(virtualButtonNamber){ |
mozillain | 1:2ceb29686290 | 74 | default: {TFT.Button(((TFT.DispWidth/2)-100), TFT.DispHeight/2, 400, 80, 30, 0, "Button1"); break; } |
mozillain | 1:2ceb29686290 | 75 | case 1: {TFT.Button(((TFT.DispWidth/2)-100), TFT.DispHeight/2, 400, 80, 30, 0, "Up"); break;} |
mozillain | 1:2ceb29686290 | 76 | case 2: {TFT.Button(((TFT.DispWidth/2)-100), TFT.DispHeight/2, 400, 80, 30, 0, "Down"); break;} |
mozillain | 1:2ceb29686290 | 77 | case 3: {TFT.Button(((TFT.DispWidth/2)-100), TFT.DispHeight/2, 400, 80, 30, 0, "Left"); break;} |
mozillain | 1:2ceb29686290 | 78 | case 4: {TFT.Button(((TFT.DispWidth/2)-100), TFT.DispHeight/2, 400, 80, 31, 0, "Right"); break;} |
mozillain | 1:2ceb29686290 | 79 | case 5: {TFT.Button(((TFT.DispWidth/2)-100), TFT.DispHeight/2, 400, 80, 31, 0, "Ok"); break;} |
mozillain | 1:2ceb29686290 | 80 | |
mozillain | 1:2ceb29686290 | 81 | } |
mozillain | 1:2ceb29686290 | 82 | |
mozillain | 1:2ceb29686290 | 83 | TFT.DL(COLOR_RGB(0, 0, 0)); |
mozillain | 1:2ceb29686290 | 84 | TFT.Text((TFT.DispWidth/2), TFT.DispHeight/24, 31, OPT_CENTERX, "Menu\0"); |
mozillain | 1:2ceb29686290 | 85 | |
mozillain | 1:2ceb29686290 | 86 | TFT.Button(100, 80, 600, 100, 31, 0, "Automatic mode"); //B1 |
mozillain | 1:2ceb29686290 | 87 | TFT.Button(100, 200, 600, 100, 31, 0, "Manual mode"); //B2 |
mozillain | 1:2ceb29686290 | 88 | |
mozillain | 1:2ceb29686290 | 89 | |
mozillain | 1:2ceb29686290 | 90 | TFT.Text((TFT.DispWidth/4), TFT.DispHeight*7/8, 28, OPT_CENTERX, "Run time [s]: \0"); // draw Text with font 31 |
mozillain | 1:2ceb29686290 | 91 | TFT.Number((TFT.DispWidth/2), (TFT.DispHeight*7/8),28,OPT_CENTERX, seconds); |
mozillain | 1:2ceb29686290 | 92 | |
mozillain | 1:2ceb29686290 | 93 | TFT.DL(COLOR_RGB(0xFF, 0x00, 0x00)); |
mozillain | 1:2ceb29686290 | 94 | TFT.Text((TFT.DispWidth*7/8)+9, (TFT.DispHeight*15/16), 28, OPT_CENTERX, "by Denis Nyzovets\0"); // draw Text with font 31 |
mozillain | 1:2ceb29686290 | 95 | |
mozillain | 1:2ceb29686290 | 96 | //display the screen |
mozillain | 1:2ceb29686290 | 97 | FinishDL(); |
mozillain | 1:2ceb29686290 | 98 | } |
mozillain | 1:2ceb29686290 | 99 | |
mozillain | 1:2ceb29686290 | 100 | void StartDL(void) |
mozillain | 1:2ceb29686290 | 101 | { |
mozillain | 1:2ceb29686290 | 102 | TFT.DLstart(); |
mozillain | 1:2ceb29686290 | 103 | TFT.DL(CLEAR_COLOR_RGB(255, 255, 255)); |
mozillain | 1:2ceb29686290 | 104 | TFT.DL(CLEAR(1, 1, 1)); |
mozillain | 1:2ceb29686290 | 105 | } |
mozillain | 1:2ceb29686290 | 106 | |
mozillain | 1:2ceb29686290 | 107 | void FinishDL(void) |
mozillain | 1:2ceb29686290 | 108 | { |
mozillain | 1:2ceb29686290 | 109 | TFT.DL(DISPLAY()); |
mozillain | 1:2ceb29686290 | 110 | TFT.Swap(); |
mozillain | 1:2ceb29686290 | 111 | TFT.Flush_Co_Buffer(); |
mozillain | 1:2ceb29686290 | 112 | TFT.WaitCmdfifo_empty(); |
mozillain | 1:2ceb29686290 | 113 | } |
mozillain | 1:2ceb29686290 | 114 | |
mozillain | 1:2ceb29686290 | 115 | void show_logo(void) |
mozillain | 1:2ceb29686290 | 116 | { |
mozillain | 1:2ceb29686290 | 117 | /* |
mozillain | 1:2ceb29686290 | 118 | TFT.WrCmd32(CMD_INFLATE); |
mozillain | 1:2ceb29686290 | 119 | TFT.WrCmd32(IMAGE_ADDR_LOGO); |
mozillain | 1:2ceb29686290 | 120 | TFT.WrCmdBufFromFlash(logo, sizeof(logo)); |
mozillain | 1:2ceb29686290 | 121 | |
mozillain | 1:2ceb29686290 | 122 | StartDL(); |
mozillain | 1:2ceb29686290 | 123 | TFT.DL(BITMAP_HANDLE(0)); |
mozillain | 1:2ceb29686290 | 124 | TFT.DL(BITMAP_SOURCE(IMAGE_ADDR_LOGO)); |
mozillain | 1:2ceb29686290 | 125 | TFT.DL(BITMAP_LAYOUT(ARGB1555, 0, 309)); |
mozillain | 1:2ceb29686290 | 126 | //TFT.DL(BITMAP_SIZE(NEAREST, BORDER, BORDER, 840, 480)); |
mozillain | 1:2ceb29686290 | 127 | TFT.DL(BITMAP_SIZE(BILINEAR, BORDER, BORDER, 0, 309)); |
mozillain | 1:2ceb29686290 | 128 | FinishDL(); |
mozillain | 1:2ceb29686290 | 129 | |
mozillain | 1:2ceb29686290 | 130 | StartDL(); |
mozillain | 1:2ceb29686290 | 131 | TFT.DL(BEGIN(BITMAPS)); |
mozillain | 1:2ceb29686290 | 132 | TFT.DL(VERTEX2II(0, 0, 0, 0)); |
mozillain | 1:2ceb29686290 | 133 | TFT.DL(END()); |
mozillain | 1:2ceb29686290 | 134 | FinishDL(); |
mozillain | 1:2ceb29686290 | 135 | */ |
mozillain | 1:2ceb29686290 | 136 | } |
mozillain | 1:2ceb29686290 | 137 | |
mozillain | 1:2ceb29686290 | 138 | void LoadImagesAndFonts(void) |
mozillain | 1:2ceb29686290 | 139 | { |
mozillain | 1:2ceb29686290 | 140 | TFT.WrCmd32(CMD_INFLATE); |
mozillain | 1:2ceb29686290 | 141 | TFT.WrCmd32(IMAGE_ADDR_HUMIDITY); |
mozillain | 1:2ceb29686290 | 142 | TFT.WrCmdBufFromFlash(hum_icon, sizeof(hum_icon)); |
mozillain | 1:2ceb29686290 | 143 | /* |
mozillain | 1:2ceb29686290 | 144 | TFT.WrCmd32(CMD_INFLATE); |
mozillain | 1:2ceb29686290 | 145 | TFT.WrCmd32(IMAGE_ADDR_TEMPERATURE); |
mozillain | 1:2ceb29686290 | 146 | TFT.WrCmdBufFromFlash(temp_icon, sizeof(temp_icon)); |
mozillain | 1:2ceb29686290 | 147 | |
mozillain | 1:2ceb29686290 | 148 | TFT.WrCmd32(CMD_INFLATE); |
mozillain | 1:2ceb29686290 | 149 | TFT.WrCmd32(IMAGE_ADDR_SENSOR); |
mozillain | 1:2ceb29686290 | 150 | TFT.WrCmdBufFromFlash(HYT_photo, sizeof(HYT_photo)); |
mozillain | 1:2ceb29686290 | 151 | |
mozillain | 1:2ceb29686290 | 152 | TFT.WrCmd32(CMD_INFLATE); |
mozillain | 1:2ceb29686290 | 153 | TFT.WrCmd32(FONT_SET_ROBOTO_REGULAR_30); |
mozillain | 1:2ceb29686290 | 154 | TFT.WrCmdBufFromFlash(font_RobotoRegular30, sizeof(font_RobotoRegular30)); |
mozillain | 1:2ceb29686290 | 155 | |
mozillain | 1:2ceb29686290 | 156 | TFT.WrCmd32(CMD_INFLATE); |
mozillain | 1:2ceb29686290 | 157 | TFT.WrCmd32(FONT_SET_ROBOTO_REGULAR_16); |
mozillain | 1:2ceb29686290 | 158 | TFT.WrCmdBufFromFlash(font_RobotoRegular16, sizeof(font_RobotoRegular16)); |
mozillain | 1:2ceb29686290 | 159 | */ |
mozillain | 1:2ceb29686290 | 160 | } |
mozillain | 1:2ceb29686290 | 161 | |
mozillain | 1:2ceb29686290 | 162 | |
mozillain | 1:2ceb29686290 | 163 | void HandleAllBitmaps(void) |
mozillain | 1:2ceb29686290 | 164 | { |
mozillain | 1:2ceb29686290 | 165 | StartDL(); |
mozillain | 1:2ceb29686290 | 166 | TFT.DL(BITMAP_HANDLE(0)); |
mozillain | 1:2ceb29686290 | 167 | TFT.DL(BITMAP_SOURCE(IMAGE_ADDR_HUMIDITY)); |
mozillain | 1:2ceb29686290 | 168 | TFT.DL(BITMAP_LAYOUT(ARGB4, 60, 38)); |
mozillain | 1:2ceb29686290 | 169 | TFT.DL(BITMAP_SIZE(NEAREST, BORDER, BORDER, 30, 38)); |
mozillain | 1:2ceb29686290 | 170 | /* |
mozillain | 1:2ceb29686290 | 171 | TFT.DL(BITMAP_HANDLE(1)); |
mozillain | 1:2ceb29686290 | 172 | TFT.DL(BITMAP_SOURCE(IMAGE_ADDR_TEMPERATURE)); |
mozillain | 1:2ceb29686290 | 173 | TFT.DL(BITMAP_LAYOUT(ARGB4, 42, 42)); |
mozillain | 1:2ceb29686290 | 174 | TFT.DL(BITMAP_SIZE(NEAREST, BORDER, BORDER, 21, 42)); |
mozillain | 1:2ceb29686290 | 175 | |
mozillain | 1:2ceb29686290 | 176 | TFT.DL(BITMAP_HANDLE(2)); |
mozillain | 1:2ceb29686290 | 177 | TFT.DL(BITMAP_SOURCE(IMAGE_ADDR_SENSOR)); |
mozillain | 1:2ceb29686290 | 178 | TFT.DL(BITMAP_LAYOUT(RGB332, 101, 147)); |
mozillain | 1:2ceb29686290 | 179 | TFT.DL(BITMAP_SIZE(NEAREST, BORDER, BORDER, 101, 147)); |
mozillain | 1:2ceb29686290 | 180 | |
mozillain | 1:2ceb29686290 | 181 | TFT.DL(BITMAP_HANDLE(3)); |
mozillain | 1:2ceb29686290 | 182 | TFT.DL(BITMAP_SOURCE(FONT_ADDR_ROBOTO_REGULAR_30)); |
mozillain | 1:2ceb29686290 | 183 | TFT.DL(BITMAP_LAYOUT(L4, 16, 33)); |
mozillain | 1:2ceb29686290 | 184 | TFT.DL(BITMAP_SIZE(NEAREST, BORDER, BORDER, 32, 33)); |
mozillain | 1:2ceb29686290 | 185 | |
mozillain | 1:2ceb29686290 | 186 | TFT.DL(BITMAP_HANDLE(4)); |
mozillain | 1:2ceb29686290 | 187 | TFT.DL(BITMAP_SOURCE(FONT_ADDR_ROBOTO_REGULAR_16)); |
mozillain | 1:2ceb29686290 | 188 | TFT.DL(BITMAP_LAYOUT(L4, 8, 20)); |
mozillain | 1:2ceb29686290 | 189 | TFT.DL(BITMAP_SIZE(NEAREST, BORDER, BORDER, 16, 20)); |
mozillain | 1:2ceb29686290 | 190 | |
mozillain | 1:2ceb29686290 | 191 | TFT.SetFont(3, FONT_SET_ROBOTO_REGULAR_30); |
mozillain | 1:2ceb29686290 | 192 | TFT.SetFont(4, FONT_SET_ROBOTO_REGULAR_16); |
mozillain | 1:2ceb29686290 | 193 | */ |
mozillain | 1:2ceb29686290 | 194 | FinishDL(); |
mozillain | 1:2ceb29686290 | 195 | } |
mozillain | 1:2ceb29686290 | 196 | |
mozillain | 1:2ceb29686290 | 197 | void up_callback (void) { |
mozillain | 1:2ceb29686290 | 198 | virtualButtonNamber=1; |
mozillain | 1:2ceb29686290 | 199 | } |
mozillain | 1:2ceb29686290 | 200 | |
mozillain | 1:2ceb29686290 | 201 | void down_callback (void) { |
mozillain | 1:2ceb29686290 | 202 | virtualButtonNamber=2; |
mozillain | 1:2ceb29686290 | 203 | } |
mozillain | 1:2ceb29686290 | 204 | |
mozillain | 1:2ceb29686290 | 205 | void left_callback (void) { |
mozillain | 1:2ceb29686290 | 206 | virtualButtonNamber=3; |
mozillain | 1:2ceb29686290 | 207 | } |
mozillain | 1:2ceb29686290 | 208 | |
mozillain | 1:2ceb29686290 | 209 | void right_callback (void) { |
mozillain | 1:2ceb29686290 | 210 | virtualButtonNamber=4; |
mozillain | 1:2ceb29686290 | 211 | } |
mozillain | 1:2ceb29686290 | 212 | |
mozillain | 1:2ceb29686290 | 213 | void ok_callback (void) { |
mozillain | 1:2ceb29686290 | 214 | virtualButtonNamber=5; |
mozillain | 1:2ceb29686290 | 215 | } |
mozillain | 1:2ceb29686290 | 216 | |
mozillain | 1:2ceb29686290 | 217 | int main(void) |
mozillain | 1:2ceb29686290 | 218 | { |
mozillain | 1:2ceb29686290 | 219 | Up.mode(PullUp); |
mozillain | 1:2ceb29686290 | 220 | Down.mode(PullUp); |
mozillain | 1:2ceb29686290 | 221 | Left.mode(PullUp); |
mozillain | 1:2ceb29686290 | 222 | Right.mode(PullUp); |
mozillain | 1:2ceb29686290 | 223 | Ok.mode(PullUp); |
mozillain | 1:2ceb29686290 | 224 | wait(.01); |
mozillain | 1:2ceb29686290 | 225 | |
mozillain | 1:2ceb29686290 | 226 | Up.attach_deasserted(&up_callback); |
mozillain | 1:2ceb29686290 | 227 | Down.attach_deasserted(&down_callback); |
mozillain | 1:2ceb29686290 | 228 | Left.attach_deasserted(&left_callback); |
mozillain | 1:2ceb29686290 | 229 | Right.attach_deasserted(&right_callback); |
mozillain | 1:2ceb29686290 | 230 | Ok.attach_deasserted(&ok_callback); |
mozillain | 1:2ceb29686290 | 231 | |
mozillain | 1:2ceb29686290 | 232 | Up.setSampleFrequency(); |
mozillain | 1:2ceb29686290 | 233 | Down.setSampleFrequency(); |
mozillain | 1:2ceb29686290 | 234 | Left.setSampleFrequency(); |
mozillain | 1:2ceb29686290 | 235 | Right.setSampleFrequency(); |
mozillain | 1:2ceb29686290 | 236 | Ok.setSampleFrequency(); |
mozillain | 1:2ceb29686290 | 237 | |
mozillain | 1:2ceb29686290 | 238 | //pc.printf("Press '1' to turn LED1 ON, '0' to turn it OFF\n"); |
mozillain | 1:2ceb29686290 | 239 | //DigitalOut led(LED1); led=1; |
mozillain | 1:2ceb29686290 | 240 | //screen1(0x0,0x0); |
mozillain | 1:2ceb29686290 | 241 | set_time(0); // Set RTC time to 0 |
mozillain | 1:2ceb29686290 | 242 | wait(1); |
mozillain | 1:2ceb29686290 | 243 | //TFT.Logo(); |
mozillain | 1:2ceb29686290 | 244 | |
mozillain | 1:2ceb29686290 | 245 | DigitalOut led2(LED2); led2=1; |
mozillain | 1:2ceb29686290 | 246 | //TFT.WaitLogo_Finish(); |
mozillain | 1:2ceb29686290 | 247 | //LoadImagesAndFonts(); |
mozillain | 1:2ceb29686290 | 248 | //HandleAllBitmaps(); |
mozillain | 1:2ceb29686290 | 249 | while(1) main_menu(0x0,0x0); |
mozillain | 1:2ceb29686290 | 250 | |
mozillain | 1:2ceb29686290 | 251 | //show_logo1(); |
mozillain | 1:2ceb29686290 | 252 | return 0; |
mozillain | 1:2ceb29686290 | 253 | } |
mozillain | 1:2ceb29686290 | 254 | */ |