├── README └── STM32F4_Discovery_demo ├── CLCD_QVGA ├── CLCDQVGA_Driver.c ├── CLCDQVGA_Driver.h ├── UI.c ├── UI.h ├── fonts.c ├── fonts.h ├── keys.c └── keys.h ├── Makefile ├── README ├── chconf.h ├── codec.h ├── codec_CS43L22.c ├── drawingApp.c ├── drawingApp.h ├── halconf.h ├── main.c ├── mcuconf.h ├── uitests.c ├── wavePlayer.c ├── wavePlayer.h ├── xprintf.c └── xprintf.h /README: -------------------------------------------------------------------------------- 1 | ***************************************************************************** 2 | ** STM32F4 Discovery GLCD UI WavePlayer Demo ** 3 | ***************************************************************************** 4 | 5 | The demo shows how to use a 2.4" LCD with the STM32F4-Discovery board. Also 6 | included is a small GUI Library I implemented using the touch panel. 7 | 8 | Demo Applications called by menus include: 9 | - 3 RGB Test Patterns 10 | - A simple 'doodle application' - that lets you draw on the screen 11 | - Wave Player 12 | 13 | The end result of my exercise will be to design a full-fledged mp3 audio player 14 | with all bells and whistles! 15 | 16 | NOTES: 17 | 18 | The LCD I use is this one: 19 | http://www.ebay.com/itm/2-4-TFT-LCD-Module-Display-Touch-Panel-PCB-adapter-/190477028273?pt=LH_DefaultDomain_0&hash=item2c5950cbb1 20 | 21 | It uses a 'new' S6D1121 controller, unlike the earlier ILI9325 variant. 22 | 23 | You will have to close jumper J3 (IM0) on the back of module PCB to enable 16-bit mode. 24 | 25 | The LCD is bitbanged and connected to the following pins: 26 | 27 | CS PD7 28 | RST PD10 29 | RS PD11 30 | WR PD8 31 | RD PD9 32 | 33 | DB[0:3] PD[0:3] 34 | DB[4:15] PE[4:15] 35 | 36 | This code runs on ChibiOS 2.4.1 37 | 38 | The UI & Text Rendering code of my library is based on the UI framework provided on this 39 | website: http://reifel.org/PICUserInterface/ . I wrote it two years ago for 40 | my AVR development platform. 41 | 42 | It also uses Chan's xprintf library. 43 | 44 | I wrote my own implementation for controlling the onboard CS43L22 DAC and sending data to it via DMA. 45 | 46 | The source files are self-explanatory. 47 | 48 | You will have to change the ChibiOS path in the makefile. 49 | 50 | For screenshots visit: 51 | 52 | http://imageshack.us/photo/my-images/844/dsc01768qf.jpg/ 53 | http://imageshack.us/photo/my-images/818/dsc01779t.jpg/ 54 | http://imageshack.us/photo/my-images/855/dsc01829w.jpg/ 55 | http://imageshack.us/photo/my-images/837/dsc01775tt.jpg/ 56 | http://imageshack.us/photo/my-images/7/image2mb.jpg/ 57 | http://imageshack.us/photo/my-images/7/image1als.jpg/ 58 | http://imageshack.us/photo/my-images/41/dsc01788ql.jpg/ 59 | http://imageshack.us/photo/my-images/259/dsc01786i.jpg/ 60 | http://imageshack.us/photo/my-images/198/dsc01784m.jpg/ 61 | 62 | Cheers! 63 | 64 | Abhishek 65 | -------------------------------------------------------------------------------- /STM32F4_Discovery_demo/CLCD_QVGA/CLCDQVGA_Driver.c: -------------------------------------------------------------------------------- 1 | #include "CLCDQVGA_Driver.h" 2 | #include "stm32f4xx.h" 3 | #include "fonts.h" 4 | 5 | #define LCD_RST_LOW palClearPad(LCD_RST_GPIO, LCD_RST_PIN) 6 | #define LCD_RST_HIGH palSetPad(LCD_RST_GPIO, LCD_RST_PIN) 7 | 8 | #define LCD_CS_LOW palClearPad(LCD_CS_GPIO, LCD_CS_PIN) 9 | #define LCD_CS_HIGH palSetPad(LCD_CS_GPIO, LCD_CS_PIN) 10 | 11 | #define LCD_RS_LOW palClearPad(LCD_RS_GPIO, LCD_RS_PIN) 12 | #define LCD_RS_HIGH palSetPad(LCD_RS_GPIO, LCD_RS_PIN) 13 | 14 | #define LCD_RD_LOW palClearPad(LCD_RD_GPIO, LCD_RD_PIN) 15 | #define LCD_RD_HIGH palSetPad(LCD_RD_GPIO, LCD_RD_PIN) 16 | 17 | #define LCD_WR_LOW palClearPad(LCD_WR_GPIO, LCD_WR_PIN) 18 | #define LCD_WR_HIGH palSetPad(LCD_WR_GPIO, LCD_WR_PIN) 19 | 20 | #define LCD_BL_LOW palClearPad(LCD_BL_GPIO, LCD_BL_PIN) 21 | #define LCD_BL_HIGH palSetPad(LCD_BL_GPIO, LCD_BL_PIN) 22 | 23 | #define USE_BITBANG 24 | 25 | #define RAMWR 0x22 26 | 27 | volatile uint16_t cx,cy; 28 | volatile uint16_t px,py; 29 | volatile uint16_t bgcolor=WHITE,fgcolor=BLACK; 30 | 31 | volatile uint8_t lcd_blstate=LCD_BL_ON; 32 | volatile uint16_t lcd_bltime=0; 33 | 34 | const uint16_t colors[]={BLACK, RED, GREEN, BLUE, CYAN, MAGENTA, YELLOW, WHITE}; 35 | 36 | const uint8_t* font; 37 | 38 | static VirtualTimer lcd_blvt; 39 | 40 | inline void lcd_lld_delay(void) 41 | { 42 | asm volatile ("nop"); 43 | asm volatile ("nop"); 44 | } 45 | 46 | inline void lcd_lld_write(uint16_t db) 47 | { 48 | LCD_D4_GPIO->BSRR.W=((~db&0xFFF0)<<16)|(db&0xFFF0); 49 | LCD_D0_GPIO->BSRR.W=((~db&0x000F)<<16)|(db&0x000F); 50 | 51 | LCD_WR_LOW; 52 | lcd_lld_delay(); 53 | LCD_WR_HIGH; 54 | } 55 | 56 | void lcd_cmd(uint16_t c) 57 | { 58 | LCD_CS_LOW; 59 | LCD_RS_LOW; 60 | 61 | lcd_lld_write(c); 62 | 63 | LCD_RS_HIGH; 64 | LCD_CS_HIGH; 65 | } 66 | 67 | void lcd_data(uint16_t d) 68 | { 69 | LCD_CS_LOW; 70 | lcd_lld_write(d); 71 | LCD_CS_HIGH; 72 | } 73 | 74 | 75 | uint16_t lcd_read(uint16_t addr) 76 | { 77 | uint16_t retval; 78 | lcd_cmd(addr); 79 | 80 | LCD_RS_HIGH; 81 | asm volatile ("nop"); 82 | asm volatile ("nop"); 83 | 84 | palSetGroupMode(LCD_D0_GPIO, 0x0000000F, 0, PAL_MODE_INPUT); 85 | palSetGroupMode(LCD_D4_GPIO, 0x0000FFF0, 0, PAL_MODE_INPUT); 86 | 87 | LCD_RD_LOW; 88 | lcd_lld_delay(); 89 | LCD_RD_HIGH; 90 | lcd_lld_delay(); 91 | 92 | 93 | retval=(GPIOE->IDR&0xFFF0)|(GPIOD->IDR&0x000F); 94 | GPIOD->ODR=GPIOD->IDR; 95 | GPIOE->ODR=GPIOE->IDR; 96 | palSetGroupMode(LCD_D0_GPIO, 0x0000000F, 0, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); 97 | palSetGroupMode(LCD_D4_GPIO, 0x0000FFF0, 0, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); 98 | 99 | asm volatile ("nop"); 100 | asm volatile ("nop"); 101 | 102 | return retval; 103 | } 104 | 105 | void lcd_writereg(uint16_t c, uint16_t d) 106 | { 107 | LCD_CS_LOW; 108 | LCD_RS_LOW; 109 | 110 | lcd_lld_write(c); 111 | 112 | LCD_RS_HIGH; 113 | 114 | lcd_lld_write(d); 115 | 116 | LCD_CS_HIGH; 117 | } 118 | 119 | 120 | void lcd_blup() 121 | { 122 | if (lcd_blstate!=LCD_BL_ONN&&lcd_blstate!=LCD_BL_ON) { 123 | lcd_blstate=LCD_BL_ONN; 124 | } else { 125 | lcd_bltime=LCD_BACKLIGHT_ON_TIME; 126 | } 127 | } 128 | 129 | // Modified to Support ChibiOS VT API 130 | void lcd_blhook(void *p) 131 | { 132 | // Silence the compiler 133 | (void*) p; 134 | 135 | 136 | // Perform action of back light 137 | switch (lcd_blstate) 138 | { 139 | case LCD_BL_ON: 140 | case LCD_BL_DIM0: 141 | if (lcd_bltime==0) { 142 | lcd_blstate=LCD_BL_DIM0; 143 | TIM4->CCR3-=10; 144 | if (TIM4->CCR3<=100) { 145 | lcd_blstate=LCD_BL_DIM; 146 | lcd_bltime=LCD_BACKLIGHT_DIM_TIME; 147 | } 148 | } else { 149 | lcd_bltime--; 150 | } 151 | break; 152 | 153 | 154 | case LCD_BL_DIM: 155 | if (lcd_bltime==0) { 156 | if (TIM4->CCR3!=0) TIM4->CCR3--; 157 | else lcd_blstate=LCD_BL_OFF; 158 | } else { 159 | lcd_bltime--; 160 | } 161 | break; 162 | 163 | case LCD_BL_OFF: 164 | break; 165 | 166 | case LCD_BL_ONN: 167 | TIM4->CCR3+=20; 168 | if (TIM4->CCR3>239) { 169 | TIM4->CCR3=255; 170 | lcd_blstate=LCD_BL_ON; 171 | lcd_bltime=LCD_BACKLIGHT_ON_TIME; 172 | } 173 | /* no break */ 174 | } 175 | 176 | // Re-arm the timer 177 | chVTSetI(&lcd_blvt, MS2ST(100), lcd_blhook, NULL); 178 | } 179 | 180 | // Initializes the LCD 181 | void lcd_init() 182 | { 183 | // IO Default Configurations 184 | palSetPadMode(LCD_CS_GPIO, LCD_CS_PIN, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); 185 | palSetPadMode(LCD_WR_GPIO, LCD_WR_PIN, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); 186 | palSetPadMode(LCD_RD_GPIO, LCD_RD_PIN, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); 187 | palSetPadMode(LCD_RST_GPIO, LCD_RST_PIN, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); 188 | palSetPadMode(LCD_RS_GPIO, LCD_RS_PIN, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); 189 | 190 | palSetGroupMode(LCD_D0_GPIO, 0x0000000F, 0, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); 191 | palSetGroupMode(LCD_D4_GPIO, 0x0000FFF0, 0, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); 192 | 193 | // Timer4 - Channel 3s 194 | palSetPadMode(LCD_BL_GPIO, LCD_BL_PIN, PAL_MODE_ALTERNATE(2)); 195 | 196 | tsc_init(); 197 | 198 | LCD_CS_HIGH; 199 | LCD_RST_HIGH; 200 | LCD_RD_HIGH; 201 | LCD_WR_HIGH; 202 | 203 | lcd_bltime=LCD_BACKLIGHT_ON_TIME; 204 | 205 | font = font_MediumBold; 206 | 207 | // Init the timer PWM without HAL 208 | // 256 Steps @ 31.25 kHz 209 | // Auto Load Configuration 210 | // TIM4 / CH3 (PB8) 211 | rccEnableTIM4(FALSE); 212 | TIM4->ARR = 255; 213 | 214 | // We prescale the clock to 8 MHz ( 8 MHz / 256 = 31.25 kHz) 215 | TIM4->PSC = (STM32_TIMCLK1 / 8000000) - 1; 216 | 217 | // Now configure OC3 in PWM Mode 1 OC3M[2:0] = 110 218 | // Enable preload 219 | TIM4->CCMR2 = TIM_CCMR2_OC3M_2 | TIM_CCMR2_OC3M_1 | TIM_CCMR2_OC3PE; 220 | 221 | // Enable OC4 output, active low 222 | TIM4->CCER = TIM_CCER_CC3E | TIM_CCER_CC3P; 223 | 224 | // Finally, enable auto reload and start the timer! 225 | TIM4->CR1 = TIM_CR1_ARPE | TIM_CR1_CEN; 226 | 227 | // Set initial brightness level 228 | TIM4->CCR3=255; 229 | 230 | chVTSetI(&lcd_blvt, MS2ST(100), lcd_blhook, NULL); 231 | 232 | LCD_RST_LOW; 233 | chThdSleepMilliseconds(2); 234 | LCD_RST_HIGH; // Hardware Reset 235 | chThdSleepMilliseconds(2); 236 | 237 | lcd_writereg(0x11,0x2004); 238 | lcd_writereg(0x13,0xCC00); 239 | lcd_writereg(0x15,0x2600); 240 | lcd_writereg(0x14,0x252A); 241 | lcd_writereg(0x12,0x0033); 242 | lcd_writereg(0x13,0xCC04); 243 | 244 | chThdSleepMilliseconds(1); 245 | 246 | lcd_writereg(0x13,0xCC06); 247 | 248 | chThdSleepMilliseconds(1); 249 | 250 | lcd_writereg(0x13,0xCC4F); 251 | 252 | chThdSleepMilliseconds(1); 253 | 254 | lcd_writereg(0x13,0x674F); 255 | lcd_writereg(0x11,0x2003); 256 | 257 | chThdSleepMilliseconds(1); 258 | 259 | // Gamma Setting 260 | lcd_writereg(0x30,0x2609); 261 | lcd_writereg(0x31,0x242C); 262 | lcd_writereg(0x32,0x1F23); 263 | lcd_writereg(0x33,0x2425); 264 | lcd_writereg(0x34,0x2226); 265 | lcd_writereg(0x35,0x2523); 266 | lcd_writereg(0x36,0x1C1A); 267 | lcd_writereg(0x37,0x131D); 268 | lcd_writereg(0x38,0x0B11); 269 | lcd_writereg(0x39,0x1210); 270 | lcd_writereg(0x3A,0x1315); 271 | lcd_writereg(0x3B,0x3619); 272 | lcd_writereg(0x3C,0x0D00); 273 | lcd_writereg(0x3D,0x000D); 274 | 275 | lcd_writereg(0x16,0x0007); 276 | lcd_writereg(0x02,0x0013); 277 | lcd_writereg(0x03,0x0003); 278 | lcd_writereg(0x01,0x0127); 279 | 280 | chThdSleepMilliseconds(1); 281 | 282 | lcd_writereg(0x08,0x0303); 283 | lcd_writereg(0x0A,0x000B); 284 | lcd_writereg(0x0B,0x0003); 285 | lcd_writereg(0x0C,0x0000); 286 | lcd_writereg(0x41,0x0000); 287 | lcd_writereg(0x50,0x0000); 288 | lcd_writereg(0x60,0x0005); 289 | lcd_writereg(0x70,0x000B); 290 | lcd_writereg(0x71,0x0000); 291 | lcd_writereg(0x78,0x0000); 292 | lcd_writereg(0x7A,0x0000); 293 | lcd_writereg(0x79,0x0007); 294 | lcd_writereg(0x07,0x0051); 295 | 296 | chThdSleepMilliseconds(1); 297 | 298 | lcd_writereg(0x07,0x0053); 299 | lcd_writereg(0x79,0x0000); 300 | } 301 | 302 | // Clears the screen 303 | void lcd_cls(void) 304 | { 305 | lcd_setrect(0,239,0,319); 306 | lcd_locate(0,0); 307 | lcd_cmd(RAMWR); 308 | 309 | LCD_CS_LOW; 310 | for (int i=0; i<320*240;i++) lcd_lld_write(bgcolor); 311 | LCD_CS_HIGH; 312 | } 313 | 314 | void lcd_setrect(uint16_t xs, uint16_t xe, uint16_t ys, uint16_t ye) 315 | { 316 | lcd_writereg(0x46, (xe<<8)|xs); 317 | lcd_writereg(0x48, ys); 318 | lcd_writereg(0x47, ye); 319 | } 320 | 321 | void lcd_filledrect(uint16_t clr, uint16_t xs, uint16_t ys, uint16_t w, uint16_t h) 322 | { 323 | lcd_setrect(xs,xs+w-1,ys,ys+h-1); 324 | lcd_locate(xs, ys); 325 | lcd_cmd(RAMWR); 326 | 327 | LCD_CS_LOW; 328 | for (int i=0;i0x7F) { 352 | if (c=='\n') lcd_newline(); 353 | return; 354 | } 355 | 356 | chi=*(uint16_t*)(&font[FONT_TABLE_CHAR_LOOKUP_IDX+ ((c-0x20)<<1)]); 357 | 358 | ptr=font+chi; 359 | 360 | uint8_t fontWidth=*(ptr++); 361 | 362 | if (cx+fontWidth>240) lcd_newline(); 363 | 364 | for (uint8_t x=0;x>=1; 375 | } 376 | ptr+=2; 377 | } 378 | 379 | cx+=fontWidth; 380 | if (sps!=0) { 381 | lcd_filledrect(bgcolor,cx,cy,sps,fontHeight); 382 | cx+=sps; 383 | } 384 | } 385 | 386 | void lcd_newline(void) 387 | { 388 | cx=3; 389 | cy+=*(font+FONT_TABLE_HEIGHT_IDX)+1; 390 | } 391 | 392 | void lcd_puts(char* c) 393 | { 394 | char d; 395 | while ((d=*c++)) 396 | lcd_putchar(d); 397 | } 398 | 399 | void tsc_init(void) 400 | { 401 | palSetPadMode(GPIOC, 5, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); 402 | tsc_read(0xD0); 403 | } 404 | 405 | uint16_t tsc_read(uint8_t addr) 406 | { 407 | uint16_t result; 408 | uint8_t txbuf[3]={0}, rxbuf[3]={0}; 409 | 410 | txbuf[0]=addr; 411 | 412 | spiAcquireBus(&SPID1); 413 | 414 | SPI1->CR1&=~SPI_CR1_SPE; 415 | SPI1->CR1|=(SPI_CR1_BR_2); 416 | SPI1->CR1|=SPI_CR1_SPE; 417 | 418 | palClearPad(GPIOC, 5); 419 | 420 | spiExchange(&SPID1, 3, txbuf, rxbuf); 421 | 422 | palSetPad(GPIOC, 5); 423 | 424 | result=(rxbuf[1]<<8) | rxbuf[2]; 425 | 426 | SPI1->CR1&=~SPI_CR1_SPE; 427 | SPI1->CR1&=~(SPI_CR1_BR_2); 428 | SPI1->CR1|=SPI_CR1_SPE; 429 | 430 | spiReleaseBus(&SPID1); 431 | 432 | result>>=3; 433 | return result; 434 | } 435 | 436 | int lcd_getpointraw(uint16_t* _x, uint16_t* _y) 437 | { 438 | uint16_t x[7], y[7]; 439 | 440 | tsc_read(0xD1); 441 | for (int i=0;i<7;i++) 442 | x[i]=tsc_read(0xD1); 443 | 444 | tsc_read(0x91); 445 | 446 | for (int i=0;i<7;i++) 447 | y[i]=tsc_read(0x91); 448 | 449 | tsc_read(0xD0); 450 | 451 | for (int i=0; i<6; i++) 452 | { 453 | for (int j=0; j<7; j++) 454 | { 455 | if (x[i]>x[j]) 456 | { 457 | int t=x[i]; 458 | x[i]=x[j]; 459 | x[j]=t; 460 | } 461 | if (y[i]>y[j]) 462 | { 463 | int t=y[i]; 464 | y[i]=y[j]; 465 | y[j]=t; 466 | } 467 | } 468 | } 469 | 470 | 471 | *_x=x[3]; 472 | *_y=y[3]; 473 | 474 | return 1; 475 | } 476 | 477 | int lcd_getpoint2(void) 478 | { 479 | uint16_t x1=0, y1=0, x2=0, y2=0, dx, dy; 480 | 481 | tsc_read(0xD1); 482 | tsc_read(0x91); 483 | 484 | for (int i=0;i<8;i++) 485 | { 486 | x1+=tsc_read(0xD1); 487 | y1+=tsc_read(0x91); 488 | } 489 | 490 | for (int i=0;i<8;i++) 491 | { 492 | x2+=tsc_read(0xD1); 493 | y2+=tsc_read(0x91); 494 | } 495 | 496 | tsc_read(0x90); 497 | 498 | if (palReadPad(GPIOB, 0)) return 0; 499 | 500 | x1=x1/8; 501 | y1=y1/8; 502 | 503 | x2=x2/8; 504 | y2=y2/8; 505 | 506 | dx=x1 > x2 ? x1-x2 : x2-x1; 507 | dy=y1 > y2 ? y1-y2 : y2-y1; 508 | 509 | if (dx < 3 && dy < 3) 510 | { 511 | x1=(x1+x2)/2; 512 | y1=(y1+y2)/2; 513 | 514 | px=240-((x1-330)*10/142); 515 | py=320-((y1-380)/11); 516 | 517 | return 1; 518 | } 519 | return 0; 520 | } 521 | 522 | void lcd_getpoint_int(uint16_t* lx, uint16_t* ly); 523 | 524 | int lcd_getpoint() 525 | { 526 | uint16_t x1=0, y1=0, x2=0, y2=0, dx, dy; 527 | lcd_getpoint_int(&x1, &y1); 528 | lcd_getpoint_int(&x2, &y2); 529 | 530 | dx=x2 > x1 ? x2-x1 : x1-x2; 531 | dy=y2 > y1 ? y2-y1 : y1-y2; 532 | 533 | if (dx < 3 && dy < 3) 534 | { 535 | px=(x1+x2)/2; 536 | py=(y1+y2)/2; 537 | return 1; 538 | } 539 | 540 | else 541 | return 0; 542 | } 543 | 544 | void lcd_getpoint_int(uint16_t* lx, uint16_t* ly) 545 | { 546 | uint16_t x1=0, y1=0; 547 | 548 | uint16_t x[7], y[7]; 549 | 550 | if (!tsc_isPenDown()) return; 551 | 552 | tsc_read(0xD1); 553 | tsc_read(0x91); 554 | 555 | for (int i=0;i<7;i++) 556 | { 557 | x[i]=tsc_read(0xD1); 558 | y[i]=tsc_read(0x91); 559 | } 560 | 561 | tsc_read(0x90); 562 | 563 | for (int i=0; i<6; i++) 564 | { 565 | for (int j=0; j<7; j++) 566 | { 567 | if (x[i]>x[j]) 568 | { 569 | int t=x[i]; 570 | x[i]=x[j]; 571 | x[j]=t; 572 | } 573 | if (y[i]>y[j]) 574 | { 575 | int t=y[i]; 576 | y[i]=y[j]; 577 | y[j]=t; 578 | } 579 | } 580 | } 581 | 582 | x1=x[3]; 583 | y1=y[3]; 584 | 585 | *lx=240-((x1-330)*10/142); 586 | *ly=320-((y1-380)/11); 587 | } 588 | -------------------------------------------------------------------------------- /STM32F4_Discovery_demo/CLCD_QVGA/CLCDQVGA_Driver.h: -------------------------------------------------------------------------------- 1 | #ifndef COLORLCD_H_ 2 | #define COLORLCD_H_ 3 | 4 | // ChibiOS Core Includes 5 | #include "ch.h" 6 | #include "hal.h" 7 | 8 | // Other Includes 9 | #include "fonts.h" 10 | 11 | #include 12 | 13 | 14 | enum lcd_bl_states { 15 | LCD_BL_ON, 16 | LCD_BL_DIM0, 17 | LCD_BL_DIM, 18 | LCD_BL_OFF, 19 | LCD_BL_ONN 20 | }; 21 | 22 | 23 | /* Hardware Defines */ 24 | 25 | /* 26 | * QVGA LCD Hardware Pin Assignments 27 | * 28 | * LCD_BL PB8 = TIM4:CH3 29 | * 30 | * LCD_CS PD7 * 31 | * LCD_RST PD10 32 | * LCD_RS PD11 * 33 | * 34 | * LCD_WR PD8 35 | * LCD_RD PD9 36 | * 37 | * LCD_DB[0:3] PD[0:3] 38 | * LCD_DB[4:15] PE[4:15] 39 | * 40 | */ 41 | 42 | #define LCD_BL_GPIO GPIOB 43 | #define LCD_BL_PIN 8 44 | 45 | #define LCD_CS_GPIO GPIOD 46 | #define LCD_CS_PIN 7 47 | 48 | #define LCD_RS_GPIO GPIOD 49 | #define LCD_RS_PIN 11 50 | 51 | #define LCD_RST_GPIO GPIOD 52 | #define LCD_RST_PIN 10 53 | 54 | #define LCD_RD_GPIO GPIOD 55 | #define LCD_RD_PIN 9 56 | 57 | #define LCD_WR_GPIO GPIOD 58 | #define LCD_WR_PIN 8 59 | 60 | #define LCD_D0_GPIO GPIOD 61 | #define LCD_D4_GPIO GPIOE 62 | 63 | 64 | // Colors (8-bit) RRR GGG BB -> RRRG GGBB 65 | #if 1 66 | #define BLACK 0x0000 // 00000 000000 00000 67 | #define RED 0xF800 // 11111 000000 00000 68 | #define GREEN 0x07E0 // 00000 111111 00000 69 | #define BLUE 0x001F // 00000 000000 11111 70 | #define YELLOW RED|GREEN 71 | #define CYAN GREEN|BLUE 72 | #define MAGENTA RED|BLUE 73 | #define WHITE RED|BLUE|GREEN 74 | 75 | #define PURPLE 0XE3 76 | 77 | #define GRAY1 0b00100100 // darkest 78 | #define GRAY2 0b01001001 79 | #define GRAY3 0b01101101 80 | #define GRAY4 0b10010010 81 | #define GRAY5 0b10110110 82 | #define GRAY6 0b11011011 // lightest 83 | 84 | #define BLUE1 0b0000000000000111 // darkest 85 | #define BLUE2 0b0000000000001111 86 | #define BLUE3 0b00000011 87 | #define BLUE4 0b0001100011111111 88 | #define BLUE5 0b0011100111111111 89 | #define BLUE6 0b0111101111111111 90 | #define BLUE7 0b10010011 91 | #define BLUE8 0b10110111 92 | #define BLUE9 0b11011011 // lightest 93 | 94 | #define GREEN1 0b00001000 // darkest 95 | #define GREEN2 0b00001100 96 | #define GREEN3 0b00010000 97 | #define GREEN4 0b00110100 98 | #define GREEN5 0b01011000 99 | #define GREEN6 0b01111100 100 | #define GREEN7 0b01011101 101 | #define GREEN8 0b10011110 102 | #define GREEN9 0b11011111 // lightest 103 | #endif 104 | 105 | extern const uint16_t colors[]; 106 | 107 | extern volatile uint16_t cx,cy; 108 | extern volatile uint16_t px,py; 109 | extern volatile uint16_t bgcolor,fgcolor; 110 | 111 | extern volatile uint8_t lcd_blstate; 112 | extern volatile uint16_t lcd_bltime; 113 | 114 | extern const uint8_t* font; 115 | 116 | #define lcd_initc() { lcd_init(); lcd_cls(); } 117 | #define lcd_setpixel(p) { lcd_data(p); } 118 | #define lcd_locate(x,y) { lcd_writereg(0x20, x); lcd_writereg(0x21, y); } 119 | #define lcd_gotoxy(x,y) { cx=x; cy=y; lcd_locate(x,y); } 120 | 121 | // Send a command to LCD 122 | extern void lcd_cmd(uint16_t c); 123 | 124 | // Send data to LCD 125 | extern void lcd_data(uint16_t d); 126 | 127 | // Send data to LCD (fast) 128 | extern void lcd_lld_write(uint16_t db); 129 | 130 | // Write to LCD Register 131 | extern void lcd_writereg(uint16_t c, uint16_t d); 132 | 133 | // Initialize the Color LCD 134 | extern void lcd_init(void); 135 | 136 | // Support for LCD Backlight auto-off timer - ChibiOS Integrated 137 | #define LCD_BACKLIGHT_ON_TIME 150 138 | #define LCD_BACKLIGHT_DIM_TIME 600 139 | 140 | extern void lcd_blhook(void* p); 141 | extern void lcd_blup(void); 142 | 143 | // Clear the screen 144 | extern void lcd_cls(void); 145 | 146 | // Set drawing boundary 147 | extern void lcd_setrect(uint16_t xs, uint16_t xe, uint16_t ys, uint16_t ye); 148 | 149 | // Draw a filled rectangle with a fixed color 150 | extern void lcd_filledrect(uint16_t clr, uint16_t xs, uint16_t xe, uint16_t w, uint16_t h); 151 | 152 | // Switch to the next line 153 | extern void lcd_newline(void); 154 | 155 | // Draws an ASCII Character on the screen (Compatible with GNU FILE structures) 156 | extern void lcd_putchar(char c); 157 | 158 | // Puts a string on the LCD 159 | extern void lcd_puts(char* c); 160 | 161 | // Touch Screen Function 162 | #define tsc_isPenDown() (!palReadPad(GPIOB, 0)) 163 | extern int lcd_getpointraw(uint16_t*, uint16_t*); 164 | extern void tsc_init(void); 165 | extern uint16_t tsc_read(uint8_t addr); 166 | 167 | // Point in px, py 168 | int lcd_getpoint(void); 169 | 170 | 171 | #endif /* COLORLCD_H_ */ 172 | -------------------------------------------------------------------------------- /STM32F4_Discovery_demo/CLCD_QVGA/UI.c: -------------------------------------------------------------------------------- 1 | /* 2 | * UI.c 3 | * 4 | * Created on: Jun 14, 2010 5 | * Author: Kumar Abhishek 6 | * 7 | * Initial: Code Created for my AVR ATMega32 platform 8 | * 9 | * September 2011: Ported to the STM32 Platform 10 | * 11 | * 1 June 2012: Changes made for it to run smoothly with my QVGA Display 12 | * 13 | * 8 June 2012: Major revisions, tidying the code 14 | * 15 | * The UI code as a whole, is based on the UI framework provided on 16 | * this website: http://reifel.org/PICUserInterface/ . It was actually the 17 | * first piece of code from where I learnt UI fundamentals, like event handler 18 | * mechanism. 19 | * 20 | */ 21 | 22 | #include "UI.h" 23 | #include "keys.h" 24 | 25 | pfn_T(curHandler); 26 | 27 | menuItem* currentMenu; 28 | 29 | static uint8_t curs; 30 | static uint8_t prevs; 31 | 32 | uint8_t ui_getCharWidth(uint8_t c) 33 | { 34 | const uint8_t* ptr; 35 | 36 | uint8_t sps=font[FONT_TABLE_PAD_AFTER_CHAR_IDX]; 37 | 38 | uint16_t chi; 39 | 40 | if (c<0x20||c>0x7F) { 41 | return 0; 42 | } 43 | 44 | chi=*(uint16_t*)(&font[FONT_TABLE_CHAR_LOOKUP_IDX+ ((c-0x20)<<1)]); 45 | 46 | ptr=font+chi; 47 | 48 | uint8_t fontWidth=*(ptr++); 49 | 50 | return fontWidth+sps; 51 | } 52 | 53 | uint16_t ui_getWordWidth(const char* c) 54 | { 55 | uint16_t result=0; 56 | char d; 57 | 58 | while ((d=*c++)) 59 | result+=ui_getCharWidth(d); 60 | 61 | return result; 62 | } 63 | 64 | void ui_drawString2(const char* t, uint8_t align) 65 | { 66 | switch(align) 67 | { 68 | case TEXT_ALIGN_LEFT: cx=1; 69 | break; 70 | 71 | case TEXT_ALIGN_CENTER: cx=((UI_DISPLAY_WIDTH-ui_getWordWidth(t))/2)+1; 72 | break; 73 | 74 | case TEXT_ALIGN_RIGHT: cx=(UI_DISPLAY_WIDTH-ui_getWordWidth(t)); 75 | break; 76 | } 77 | 78 | lcd_puts((char*)t); 79 | } 80 | 81 | void ui_drawString(const char* t, uint8_t align) 82 | { 83 | uint16_t _cx=cx; 84 | ui_drawString2(t,align); 85 | cx=_cx; 86 | } 87 | 88 | void ui_drawTitleBar(const char* t) 89 | { 90 | uint16_t _cx=bgcolor,_cy=fgcolor; 91 | 92 | bgcolor=UI_TBARCOLOR; fgcolor=WHITE; 93 | 94 | font=font_Larger; 95 | 96 | lcd_filledrect(bgcolor, UI_TBARSTARTX, UI_TBARSTARTY, 97 | UI_TBARWIDTH, UI_TBARHEIGHT); 98 | 99 | cy=(UI_TBARHEIGHT-ui_getCurFontHeight())/2 + 1; 100 | ui_drawString(t, TEXT_ALIGN_CENTER); 101 | 102 | font=font_MediumBold; 103 | 104 | bgcolor=_cx; 105 | fgcolor=_cy; 106 | } 107 | 108 | void ui_drawBottomBar(const char* l, const char* c, const char* r) 109 | { 110 | uint16_t _cx=bgcolor,_cy=fgcolor; 111 | 112 | bgcolor=UI_BBARCOLOR; fgcolor=WHITE; 113 | 114 | font=font_Larger; 115 | 116 | lcd_filledrect(bgcolor, UI_BBARSTARTX, UI_BBARSTARTY+2, 117 | UI_BBARWIDTH, UI_BBARHEIGHT); 118 | 119 | lcd_filledrect(UI_BBARCOLOR2, UI_BBARSTARTX, UI_BBARSTARTY, UI_BBARWIDTH, 2); 120 | 121 | font=font_Larger; 122 | 123 | cy=UI_BBARSTARTY+(UI_BBARHEIGHT-ui_getCurFontHeight())/2 + 1; 124 | 125 | if (c) ui_drawString(c, TEXT_ALIGN_CENTER); 126 | 127 | cy+=3; 128 | 129 | font=font_Small; 130 | if (l) ui_drawString(l, TEXT_ALIGN_LEFT); 131 | if (r) ui_drawString(r, TEXT_ALIGN_RIGHT); 132 | 133 | font=font_MediumBold; 134 | 135 | bgcolor=_cx; 136 | fgcolor=_cy; 137 | } 138 | 139 | void ui_getMenuItem(menuItem* it, uint8_t i) 140 | { 141 | it->name=currentMenu[i].name; 142 | it->tag=currentMenu[i].tag; 143 | it->type=currentMenu[i].type; 144 | } 145 | 146 | void ui_drawMenuItem(uint8_t ix) 147 | { 148 | uint16_t _f=fgcolor, _b=bgcolor; 149 | menuItem curItem; 150 | 151 | ui_getMenuItem(&curItem, ix); 152 | 153 | font=font_MediumBold; 154 | 155 | cx=1; 156 | cy=UI_TBARHEIGHT+(ix*20)-18; 157 | 158 | if (ix!=curs) 159 | { 160 | fgcolor=BLACK; 161 | bgcolor=WHITE; 162 | 163 | lcd_filledrect(bgcolor, cx, cy, UI_DISPLAY_WIDTH-2, 3); 164 | cy+=3; 165 | } 166 | else 167 | { 168 | bgcolor=UI_MENUSELCOLOR; 169 | fgcolor=WHITE; 170 | 171 | lcd_filledrect(UI_MSELGRD0, cx, cy, UI_DISPLAY_WIDTH-2, 1); cy++; 172 | lcd_filledrect(UI_MSELGRD1, cx, cy, UI_DISPLAY_WIDTH-2, 1); cy++; 173 | lcd_filledrect(bgcolor, cx, cy, UI_DISPLAY_WIDTH-2, 1); cy++; 174 | } 175 | 176 | lcd_filledrect(bgcolor,cx,cy,UI_DISPLAY_WIDTH-2,ui_getCurFontHeight()); 177 | ui_drawString2(curItem.name, TEXT_ALIGN_LEFT); 178 | 179 | cx=1; 180 | 181 | cy+=ui_getCurFontHeight(); 182 | 183 | if (ix!=curs) { 184 | lcd_filledrect(WHITE, cx, cy, UI_BBARWIDTH-2, 2); 185 | cy+=2; 186 | } else { 187 | lcd_filledrect(UI_MSELGRD1, cx, cy, UI_DISPLAY_WIDTH-2, 1); cy++; 188 | lcd_filledrect(UI_MSELGRD2, cx, cy, UI_DISPLAY_WIDTH-2, 1); cy++; 189 | } 190 | fgcolor=_f; bgcolor=_b; 191 | } 192 | 193 | static void menuUpdateSelection(uint8_t new) 194 | { 195 | menuItem sel; 196 | uint8_t prevSel; 197 | 198 | ui_getMenuItem(&sel, new); 199 | 200 | if ((new >= 1) && 201 | (sel.type != MENU_END) && 202 | (new !=curs)) 203 | { // 204 | // select the new menu item 205 | // 206 | prevSel = curs; 207 | curs = new; 208 | 209 | ui_drawMenuItem(curs); 210 | ui_drawMenuItem(prevSel); 211 | } 212 | } 213 | 214 | static void menuDisplayHandler(uint8_t cmd) 215 | { 216 | menuItem cur; 217 | ui_getMenuItem(&cur, curs); 218 | 219 | switch(cmd) 220 | { 221 | case BTN_MID_DOWN: 222 | menuUpdateSelection(curs+1); 223 | break; 224 | 225 | case BTN_MID_UP: 226 | menuUpdateSelection(curs-1); 227 | break; 228 | 229 | case BTN_RIGHT: 230 | ui_getMenuItem(&cur, 0); 231 | if (cur.tag && cur.type==MENU_HEADER) ((pfn)(cur.tag))(); 232 | else if (cur.tag && cur.type==MENU_SUBHEADER) { 233 | ui_clearUserArea(); 234 | ui_displayMenu((menuItem*)cur.tag,prevs); 235 | prevs=1; 236 | } 237 | break; 238 | 239 | case BTN_MID_SEL: 240 | switch(cur.type) 241 | { 242 | case MENU_ITEM: if (cur.tag) ((pfn)(cur.tag))(); 243 | break; 244 | 245 | case MENU_SUBMENU: ui_clearUserArea(); 246 | prevs=curs; 247 | ui_displayMenu((menuItem*)cur.tag,1); 248 | break; 249 | } 250 | break; 251 | } 252 | } 253 | 254 | void ui_displayMenu(const menuItem* it, uint8_t sel) 255 | { 256 | currentMenu=(menuItem*)it; 257 | curs=sel; 258 | 259 | menuItem cur; 260 | 261 | uint8_t i=0; 262 | do 263 | { 264 | ui_getMenuItem(&cur, i); 265 | 266 | if (cur.type==MENU_HEADER || cur.type==MENU_SUBHEADER) 267 | ui_drawTitleBar(it[i].name); 268 | else if (cur.type!=MENU_END) 269 | ui_drawMenuItem(i); 270 | 271 | i++; 272 | } while (cur.type != MENU_END); 273 | 274 | ui_drawBottomBar(0, (const char*)"Select", (const char*)"Exit"); 275 | 276 | ui_sethandler((pfn)menuDisplayHandler); 277 | } 278 | 279 | void ui_displayPreviousMenu() 280 | { 281 | if (currentMenu) ui_displayMenu(currentMenu, curs); 282 | } 283 | 284 | void ui_drawSlide(uint8_t clr, uint8_t max, uint8_t set) 285 | { 286 | int t=120*set/max; 287 | 288 | lcd_filledrect(clr, 3, cy, 123, 1); 289 | lcd_filledrect(clr, 3, cy, 1, 20); 290 | lcd_filledrect(clr, 3, cy+19, 123, 1); 291 | lcd_filledrect(clr, 126, cy, 1, 20); 292 | lcd_filledrect(bgcolor, 4, cy+1, 1, 18); 293 | 294 | uint8_t i=(uint8_t) t; 295 | 296 | lcd_filledrect(clr, 5, cy+2, i, 16); 297 | lcd_filledrect(bgcolor, 6+i, cy+2, 120 - i, 16); 298 | } 299 | 300 | void ui_sethandler(pfn_T(hFunc)) 301 | { 302 | curHandler=hFunc; 303 | } 304 | 305 | void ui_executecmd(uint8_t cmd) 306 | { 307 | if (curHandler) curHandler(cmd); 308 | } 309 | 310 | void ui_clearUserArea() 311 | { 312 | lcd_filledrect(WHITE,0,UI_TBARHEIGHT,240, 320-(UI_TBARHEIGHT+UI_BBARHEIGHT)); 313 | } 314 | -------------------------------------------------------------------------------- /STM32F4_Discovery_demo/CLCD_QVGA/UI.h: -------------------------------------------------------------------------------- 1 | /* 2 | * UI.h 3 | * 4 | * Created on: Jun 14, 2010 5 | * Author: Kumar Abhishek 6 | * 7 | * Initial: Code Created for my AVR ATMega32 platform 8 | * 9 | * September 2011: Ported to the STM32 Platform 10 | * 11 | * 1 June 2012: Changes made for it to run smoothly with my QVGA Display 12 | * 13 | * 8 June 2012: Major revisions, tidying the code 14 | * 15 | * The UI code as a whole, is based on the UI framework provided on 16 | * this website: http://reifel.org/PICUserInterface/ . It was actually the 17 | * first piece of code from where I learnt UI fundamentals, like event handler 18 | * mechanism. 19 | * 20 | */ 21 | 22 | #ifndef UI_H_ 23 | #define UI_H_ 24 | 25 | #include "CLCDQVGA_Driver.h" 26 | #include "fonts.h" 27 | #include "keys.h" 28 | 29 | #define UI_DISPLAY_WIDTH 240 30 | #define UI_DISPLAY_HEIGHT 320 31 | 32 | #define UI_TBARSTARTX 0 33 | #define UI_TBARSTARTY 0 34 | #define UI_TBARWIDTH UI_DISPLAY_WIDTH 35 | #define UI_TBARHEIGHT 25 36 | #define UI_TBARCOLOR BLUE1 37 | 38 | #define UI_BBARSTARTX 0 39 | #define UI_BBARSTARTY (320-UI_BBARHEIGHT) 40 | #define UI_BBARWIDTH UI_DISPLAY_WIDTH 41 | #define UI_BBARHEIGHT 20 42 | #define UI_BBARCOLOR BLUE6 43 | #define UI_BBARCOLOR2 BLUE5 44 | 45 | #define UI_MENUSELCOLOR BLUE4 46 | #define UI_MSELGRD0 BLUE2 47 | #define UI_MSELGRD1 BLUE5 48 | #define UI_MSELGRD2 BLUE2 49 | 50 | #define UI_BARFONT font_Larger 51 | #define UI_FONT font_MediumBold 52 | 53 | enum menu_types { 54 | MENU_HEADER, 55 | MENU_SUBHEADER, 56 | MENU_ITEM, 57 | MENU_SUBMENU, 58 | MENU_END 59 | }; 60 | 61 | typedef struct _menuItem{ 62 | uint8_t type; 63 | const char* name; 64 | uint8_t* tag; 65 | } menuItem; 66 | 67 | enum stringTypes { 68 | TEXT_ALIGN_LEFT, 69 | TEXT_ALIGN_CENTER, 70 | TEXT_ALIGN_RIGHT 71 | }; 72 | 73 | #define pfn void (*)(void) 74 | #define pfn_T(n) void (*n)() 75 | 76 | extern const char appTitle[]; 77 | 78 | extern FILE lcd_stream; 79 | 80 | #define ui_getCurFontHeight() (font[FONT_TABLE_HEIGHT_IDX]) 81 | extern uint8_t ui_getCharWidth(uint8_t c); 82 | extern uint16_t ui_getWordWidth(const char* c); 83 | 84 | extern void ui_drawString(const char* t, uint8_t align); 85 | extern void ui_drawTitleBar(const char* t); 86 | extern void ui_drawBottomBar(const char* l, const char* c, const char* r); 87 | 88 | extern void ui_drawMenuItem(uint8_t ix); 89 | extern void ui_displayMenu(const menuItem* it, uint8_t sel); 90 | extern void ui_displayPreviousMenu(void); 91 | 92 | extern void ui_drawSlide(uint8_t clr, uint8_t max, uint8_t set); 93 | 94 | extern void ui_sethandler(pfn_T(hFunc)); 95 | extern void ui_executecmd(uint8_t cmd); 96 | 97 | extern void ui_clearUserArea(void); 98 | 99 | #endif /* UI_H_ */ 100 | -------------------------------------------------------------------------------- /STM32F4_Discovery_demo/CLCD_QVGA/fonts.c: -------------------------------------------------------------------------------- 1 | #include "fonts.h" 2 | 3 | #if 1 // font_Small - for side buttons 4 | // 5 | // Medium bold font, height = 11 (including the decenders) 6 | // The font table contains 3 sections: Header, Table Of Character Indexes, Pixel data 7 | // 8 | // The Header contains two bytes: 9 | // Byte0 = Font height (including decenders) 10 | // Byte1 = Number of additional pixels that should be drawn right of char 11 | // Byte2 = Recommended line spacing 12 | // Byte3 = Height of decenders 13 | // Byte4 = Unused byte 14 | // 15 | // The Table Of Character Indexes, is a table of 2 byte words that index to the pixel data within this table 16 | // Word0 = Index into this table to the pixels for ASCII char 0x20 17 | // Word1 = Index into this table to the pixels for ASCII char 0x21 18 | // Word2 = Index into this table to the pixels for ASCII char 0x22 19 | // ... 20 | // Word95 = Index into this table to the pixels for ASCII char 0x7F 21 | // 22 | // The Pixel data table contains the bitmap for each character 23 | // Data is written in columns of pixels, each column is 16 bits (2 bytes) 24 | // Byte0 = width of the ASCII 0x20 character in pixels 25 | // Byte1 = pixel data for the 0x20 char's 1st top column, bit 0 is the top pixel, bit 7 is the 8th pixel down from the top 26 | // Byte2 = pixel data for the 0x20 char's 1st bottom column, bit 0 is the 9th pixel 27 | // Byte5 = pixel data for the 0x20 char's 2nd top column 28 | // Byte6 = pixel data for the 0x20 char's 2nd bottom column 29 | // ... = remaining pairs of bytes of the columns in the 0x20 char 30 | // ... = width of the 0x21 char in pixels 31 | // ... = pixel data for the 0x21 char 32 | // ... 33 | // 34 | const uint8_t font_Small[] = { 35 | 0x0B, 0x00, 0x0E, 0x02, 0x00, 36 | 37 | 0xC5, 0x00, 0xCE, 0x00, 0xD5, 0x00, 0xE2, 0x00, 0xF3, 0x00, 0x02, 0x01, 38 | 0x15, 0x01, 0x24, 0x01, 0x2B, 0x01, 0x34, 0x01, 0x3D, 0x01, 0x48, 0x01, 39 | 0x57, 0x01, 0x60, 0x01, 0x69, 0x01, 0x70, 0x01, 0x7D, 0x01, 0x8C, 0x01, 40 | 0x9B, 0x01, 0xAA, 0x01, 0xB9, 0x01, 0xC8, 0x01, 0xD7, 0x01, 0xE6, 0x01, 41 | 0xF5, 0x01, 0x04, 0x02, 0x13, 0x02, 0x1A, 0x02, 0x23, 0x02, 0x30, 0x02, 42 | 0x3F, 0x02, 0x4C, 0x02, 0x5B, 0x02, 0x74, 0x02, 0x85, 0x02, 0x94, 0x02, 43 | 0xA5, 0x02, 0xB6, 0x02, 0xC5, 0x02, 0xD4, 0x02, 0xE5, 0x02, 0xF6, 0x02, 44 | 0xFD, 0x02, 0x08, 0x03, 0x19, 0x03, 0x28, 0x03, 0x3B, 0x03, 0x4C, 0x03, 45 | 0x5D, 0x03, 0x6E, 0x03, 0x7F, 0x03, 0x90, 0x03, 0x9F, 0x03, 0xAE, 0x03, 46 | 0xBF, 0x03, 0xD0, 0x03, 0xE9, 0x03, 0xFA, 0x03, 0x0B, 0x04, 0x1C, 0x04, 47 | 0x25, 0x04, 0x32, 0x04, 0x3B, 0x04, 0x4A, 0x04, 0x59, 0x04, 0x62, 0x04, 48 | 0x71, 0x04, 0x80, 0x04, 0x8F, 0x04, 0x9E, 0x04, 0xAD, 0x04, 0xB6, 0x04, 49 | 0xC5, 0x04, 0xD4, 0x04, 0xDB, 0x04, 0xE2, 0x04, 0xF1, 0x04, 0xF8, 0x04, 50 | 0x0B, 0x05, 0x1A, 0x05, 0x29, 0x05, 0x38, 0x05, 0x47, 0x05, 0x50, 0x05, 51 | 0x5D, 0x05, 0x66, 0x05, 0x75, 0x05, 0x84, 0x05, 0x97, 0x05, 0xA4, 0x05, 52 | 0xB1, 0x05, 0xBE, 0x05, 0xC9, 0x05, 0xD0, 0x05, 0xDB, 0x05, 0xEC, 0x05, 53 | 54 | 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 55 | 0x7F, 0x01, 0x7F, 0x01, 0x06, 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 56 | 0x00, 0x07, 0x00, 0x07, 0x00, 0x08, 0x00, 0x00, 0x44, 0x00, 0xFF, 0x01, 57 | 0xFF, 0x01, 0x44, 0x00, 0xFF, 0x01, 0xFF, 0x01, 0x44, 0x00, 0x07, 0x00, 58 | 0x00, 0x8C, 0x00, 0x9E, 0x01, 0xFF, 0x03, 0xFF, 0x03, 0xE6, 0x01, 0xC4, 59 | 0x00, 0x09, 0x00, 0x00, 0x82, 0x00, 0xC7, 0x00, 0x65, 0x00, 0xB7, 0x00, 60 | 0xDA, 0x01, 0x4C, 0x01, 0xC6, 0x01, 0x82, 0x00, 0x07, 0x00, 0x00, 0xE6, 61 | 0x00, 0xFF, 0x01, 0x3F, 0x01, 0xE6, 0x01, 0xE0, 0x01, 0x20, 0x01, 0x03, 62 | 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x04, 0x00, 0x00, 0xFE, 0x03, 0xFF, 63 | 0x07, 0x01, 0x04, 0x04, 0x00, 0x00, 0x01, 0x04, 0xFF, 0x07, 0xFE, 0x03, 64 | 0x05, 0x00, 0x00, 0x0A, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x0A, 0x00, 0x07, 65 | 0x00, 0x00, 0x20, 0x00, 0x20, 0x00, 0xF8, 0x00, 0xF8, 0x00, 0x20, 0x00, 66 | 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x01, 0x04, 67 | 0x00, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x03, 0x00, 0x00, 0x00, 68 | 0x01, 0x00, 0x01, 0x06, 0x00, 0x00, 0x80, 0x01, 0xE0, 0x01, 0x78, 0x00, 69 | 0x1F, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 0xFE, 0x00, 0xFF, 0x01, 0x01, 70 | 0x01, 0x01, 0x01, 0xFF, 0x01, 0xFE, 0x00, 0x07, 0x00, 0x00, 0x02, 0x00, 71 | 0x02, 0x00, 0xFF, 0x01, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 72 | 0x00, 0x82, 0x01, 0xC3, 0x01, 0x61, 0x01, 0x31, 0x01, 0x1F, 0x01, 0x0E, 73 | 0x01, 0x07, 0x00, 0x00, 0x82, 0x00, 0x83, 0x01, 0x11, 0x01, 0x11, 0x01, 74 | 0xFF, 0x01, 0xEE, 0x00, 0x07, 0x00, 0x00, 0x60, 0x00, 0x78, 0x00, 0x5E, 75 | 0x00, 0xFF, 0x01, 0xFF, 0x01, 0x40, 0x00, 0x07, 0x00, 0x00, 0x9F, 0x00, 76 | 0x9F, 0x01, 0x09, 0x01, 0x09, 0x01, 0xF9, 0x01, 0xF1, 0x00, 0x07, 0x00, 77 | 0x00, 0xFE, 0x00, 0xFF, 0x01, 0x11, 0x01, 0x11, 0x01, 0xF3, 0x01, 0xE2, 78 | 0x00, 0x07, 0x00, 0x00, 0x01, 0x00, 0xC1, 0x01, 0xF1, 0x01, 0x3D, 0x00, 79 | 0x0F, 0x00, 0x03, 0x00, 0x07, 0x00, 0x00, 0xEE, 0x00, 0xFF, 0x01, 0x11, 80 | 0x01, 0x11, 0x01, 0xFF, 0x01, 0xEE, 0x00, 0x07, 0x00, 0x00, 0x8E, 0x00, 81 | 0x9F, 0x01, 0x11, 0x01, 0x11, 0x01, 0xFF, 0x01, 0xFE, 0x00, 0x03, 0x00, 82 | 0x00, 0x08, 0x01, 0x08, 0x01, 0x04, 0x00, 0x00, 0x00, 0x02, 0x08, 0x03, 83 | 0x08, 0x01, 0x06, 0x00, 0x00, 0x20, 0x00, 0x70, 0x00, 0xD8, 0x00, 0x8C, 84 | 0x01, 0x04, 0x01, 0x07, 0x00, 0x00, 0x50, 0x00, 0x50, 0x00, 0x50, 0x00, 85 | 0x50, 0x00, 0x50, 0x00, 0x50, 0x00, 0x06, 0x00, 0x00, 0x04, 0x01, 0x8C, 86 | 0x01, 0xD8, 0x00, 0x70, 0x00, 0x20, 0x00, 0x07, 0x00, 0x00, 0x02, 0x00, 87 | 0x03, 0x00, 0x61, 0x01, 0x71, 0x01, 0x1F, 0x00, 0x0E, 0x00, 0x0C, 0x00, 88 | 0x00, 0x78, 0x00, 0xFE, 0x01, 0x86, 0x01, 0x33, 0x03, 0x79, 0x02, 0x49, 89 | 0x02, 0x79, 0x02, 0x7B, 0x02, 0x46, 0x02, 0x7E, 0x00, 0x78, 0x00, 0x08, 90 | 0x80, 0x01, 0xF0, 0x01, 0x7C, 0x00, 0x4F, 0x00, 0x4F, 0x00, 0x7C, 0x00, 91 | 0xF0, 0x01, 0x80, 0x01, 0x07, 0x00, 0x00, 0xFF, 0x01, 0xFF, 0x01, 0x11, 92 | 0x01, 0x11, 0x01, 0xFF, 0x01, 0xEE, 0x00, 0x08, 0x00, 0x00, 0xFE, 0x00, 93 | 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x83, 0x01, 0x82, 0x00, 94 | 0x08, 0x00, 0x00, 0xFF, 0x01, 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x83, 95 | 0x01, 0xFE, 0x00, 0x7C, 0x00, 0x07, 0x00, 0x00, 0xFF, 0x01, 0xFF, 0x01, 96 | 0x11, 0x01, 0x11, 0x01, 0x11, 0x01, 0x01, 0x01, 0x07, 0x00, 0x00, 0xFF, 97 | 0x01, 0xFF, 0x01, 0x11, 0x00, 0x11, 0x00, 0x11, 0x00, 0x01, 0x00, 0x08, 98 | 0x00, 0x00, 0xFE, 0x00, 0xFF, 0x01, 0x01, 0x01, 0x11, 0x01, 0x91, 0x01, 99 | 0xF3, 0x01, 0xF2, 0x01, 0x08, 0x00, 0x00, 0xFF, 0x01, 0xFF, 0x01, 0x10, 100 | 0x00, 0x10, 0x00, 0x10, 0x00, 0xFF, 0x01, 0xFF, 0x01, 0x03, 0x00, 0x00, 101 | 0xFF, 0x01, 0xFF, 0x01, 0x05, 0xC0, 0x00, 0xC0, 0x01, 0x00, 0x01, 0xFF, 102 | 0x01, 0xFF, 0x00, 0x08, 0x00, 0x00, 0xFF, 0x01, 0xFF, 0x01, 0x3C, 0x00, 103 | 0x66, 0x00, 0xC3, 0x00, 0x81, 0x01, 0x00, 0x01, 0x07, 0x00, 0x00, 0xFF, 104 | 0x01, 0xFF, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x09, 105 | 0x00, 0x00, 0xFF, 0x01, 0xFF, 0x01, 0x3C, 0x00, 0xF0, 0x00, 0xF0, 0x00, 106 | 0x3C, 0x00, 0xFF, 0x01, 0xFF, 0x01, 0x08, 0x00, 0x00, 0xFF, 0x01, 0xFF, 107 | 0x01, 0x1E, 0x00, 0x38, 0x00, 0xE0, 0x00, 0xFF, 0x01, 0xFF, 0x01, 0x08, 108 | 0x00, 0x00, 0xFE, 0x00, 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 109 | 0xFF, 0x01, 0xFE, 0x00, 0x08, 0x00, 0x00, 0xFF, 0x01, 0xFF, 0x01, 0x11, 110 | 0x00, 0x11, 0x00, 0x11, 0x00, 0x1F, 0x00, 0x0E, 0x00, 0x08, 0x00, 0x00, 111 | 0xFE, 0x00, 0xFF, 0x01, 0x01, 0x01, 0x41, 0x01, 0xC1, 0x01, 0xFF, 0x03, 112 | 0xFE, 0x02, 0x08, 0x00, 0x00, 0xFF, 0x01, 0xFF, 0x01, 0x11, 0x00, 0x11, 113 | 0x00, 0x11, 0x00, 0xFF, 0x01, 0xEE, 0x01, 0x07, 0x00, 0x00, 0x8E, 0x00, 114 | 0x9F, 0x01, 0x11, 0x01, 0x11, 0x01, 0xF3, 0x01, 0xE2, 0x00, 0x07, 0x00, 115 | 0x00, 0x01, 0x00, 0x01, 0x00, 0xFF, 0x01, 0xFF, 0x01, 0x01, 0x00, 0x01, 116 | 0x00, 0x08, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x01, 0x00, 0x01, 0x00, 0x01, 117 | 0x00, 0x01, 0xFF, 0x01, 0xFF, 0x00, 0x08, 0x03, 0x00, 0x1F, 0x00, 0x7C, 118 | 0x00, 0xE0, 0x01, 0xE0, 0x01, 0x7C, 0x00, 0x1F, 0x00, 0x03, 0x00, 0x0C, 119 | 0x03, 0x00, 0x1F, 0x00, 0x7C, 0x00, 0xE0, 0x01, 0xE0, 0x01, 0x7C, 0x00, 120 | 0x7C, 0x00, 0xE0, 0x01, 0xE0, 0x01, 0x7C, 0x00, 0x1F, 0x00, 0x03, 0x00, 121 | 0x08, 0x83, 0x01, 0xC7, 0x01, 0x6C, 0x00, 0x38, 0x00, 0x38, 0x00, 0x6C, 122 | 0x00, 0xC7, 0x01, 0x83, 0x01, 0x08, 0x03, 0x00, 0x07, 0x00, 0x0C, 0x00, 123 | 0xF8, 0x01, 0xF8, 0x01, 0x0C, 0x00, 0x07, 0x00, 0x03, 0x00, 0x08, 0x81, 124 | 0x01, 0xC1, 0x01, 0x61, 0x01, 0x31, 0x01, 0x19, 0x01, 0x0D, 0x01, 0x07, 125 | 0x01, 0x03, 0x01, 0x04, 0x00, 0x00, 0xFF, 0x07, 0xFF, 0x07, 0x01, 0x04, 126 | 0x06, 0x00, 0x00, 0x07, 0x00, 0x1F, 0x00, 0x78, 0x00, 0xE0, 0x01, 0x80, 127 | 0x01, 0x04, 0x00, 0x00, 0x01, 0x04, 0xFF, 0x07, 0xFF, 0x07, 0x07, 0x00, 128 | 0x00, 0x02, 0x00, 0x03, 0x00, 0x01, 0x00, 0x01, 0x00, 0x03, 0x00, 0x02, 129 | 0x00, 0x07, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 130 | 0x00, 0x04, 0x00, 0x04, 0x04, 0x00, 0x00, 0x01, 0x00, 0x03, 0x00, 0x02, 131 | 0x00, 0x07, 0x00, 0x00, 0xC0, 0x00, 0xE8, 0x01, 0x28, 0x01, 0x28, 0x01, 132 | 0xF8, 0x01, 0xF0, 0x01, 0x07, 0x00, 0x00, 0xFF, 0x01, 0xFF, 0x01, 0x08, 133 | 0x01, 0x08, 0x01, 0xF8, 0x01, 0xF0, 0x00, 0x07, 0x00, 0x00, 0xF0, 0x00, 134 | 0xF8, 0x01, 0x08, 0x01, 0x08, 0x01, 0x98, 0x01, 0x90, 0x00, 0x07, 0x00, 135 | 0x00, 0xF0, 0x00, 0xF8, 0x01, 0x08, 0x01, 0x08, 0x01, 0xFF, 0x01, 0xFF, 136 | 0x01, 0x07, 0x00, 0x00, 0xF0, 0x00, 0xF8, 0x01, 0x28, 0x01, 0x28, 0x01, 137 | 0xB8, 0x01, 0xB0, 0x00, 0x04, 0x00, 0x00, 0xFE, 0x01, 0xFF, 0x01, 0x09, 138 | 0x00, 0x07, 0x00, 0x00, 0xF0, 0x04, 0xF8, 0x05, 0x08, 0x05, 0x08, 0x05, 139 | 0xF8, 0x07, 0xF8, 0x03, 0x07, 0x00, 0x00, 0xFF, 0x01, 0xFF, 0x01, 0x18, 140 | 0x00, 0x08, 0x00, 0xF8, 0x01, 0xF0, 0x01, 0x03, 0x00, 0x00, 0xF9, 0x01, 141 | 0xF9, 0x01, 0x03, 0x00, 0x00, 0xF9, 0x07, 0xF9, 0x07, 0x07, 0x00, 0x00, 142 | 0xFF, 0x01, 0xFF, 0x01, 0x70, 0x00, 0xD8, 0x00, 0x88, 0x01, 0x00, 0x01, 143 | 0x03, 0x00, 0x00, 0xFF, 0x01, 0xFF, 0x01, 0x09, 0x00, 0x00, 0xF8, 0x01, 144 | 0xF8, 0x01, 0x08, 0x00, 0xF8, 0x01, 0xF8, 0x01, 0x08, 0x00, 0xF8, 0x01, 145 | 0xF0, 0x01, 0x07, 0x00, 0x00, 0xF8, 0x01, 0xF8, 0x01, 0x18, 0x00, 0x08, 146 | 0x00, 0xF8, 0x01, 0xF0, 0x01, 0x07, 0x00, 0x00, 0xF0, 0x00, 0xF8, 0x01, 147 | 0x08, 0x01, 0x08, 0x01, 0xF8, 0x01, 0xF0, 0x00, 0x07, 0x00, 0x00, 0xF8, 148 | 0x07, 0xF8, 0x07, 0x08, 0x01, 0x08, 0x01, 0xF8, 0x01, 0xF0, 0x00, 0x07, 149 | 0x00, 0x00, 0xF0, 0x00, 0xF8, 0x01, 0x08, 0x01, 0x08, 0x01, 0xF8, 0x07, 150 | 0xF8, 0x07, 0x04, 0x00, 0x00, 0xF8, 0x01, 0xF8, 0x01, 0x08, 0x00, 0x06, 151 | 0x00, 0x00, 0x90, 0x00, 0xB8, 0x01, 0x68, 0x01, 0xD8, 0x01, 0x90, 0x00, 152 | 0x04, 0x00, 0x00, 0xFE, 0x00, 0xFE, 0x01, 0x08, 0x01, 0x07, 0x00, 0x00, 153 | 0xF8, 0x00, 0xF8, 0x01, 0x00, 0x01, 0x80, 0x01, 0xF8, 0x01, 0xF8, 0x01, 154 | 0x07, 0x00, 0x00, 0x18, 0x00, 0x78, 0x00, 0xE0, 0x01, 0xE0, 0x01, 0x78, 155 | 0x00, 0x18, 0x00, 0x09, 0x00, 0x00, 0x78, 0x00, 0xF8, 0x01, 0xE0, 0x01, 156 | 0x78, 0x00, 0x78, 0x00, 0xE0, 0x01, 0xF8, 0x01, 0x78, 0x00, 0x06, 0x00, 157 | 0x00, 0x98, 0x01, 0xF8, 0x01, 0x60, 0x00, 0xF8, 0x01, 0x98, 0x01, 0x06, 158 | 0x00, 0x04, 0x78, 0x04, 0xF8, 0x07, 0x80, 0x03, 0xF8, 0x00, 0x78, 0x00, 159 | 0x06, 0x00, 0x00, 0x88, 0x01, 0xC8, 0x01, 0x68, 0x01, 0x38, 0x01, 0x18, 160 | 0x01, 0x05, 0x00, 0x00, 0x10, 0x00, 0xFF, 0x01, 0xEF, 0x03, 0x00, 0x02, 161 | 0x03, 0x00, 0x00, 0xFF, 0x03, 0xFF, 0x03, 0x05, 0x00, 0x00, 0x00, 0x02, 162 | 0xEF, 0x03, 0xFF, 0x01, 0x10, 0x00, 0x08, 0x00, 0x00, 0x04, 0x00, 0x06, 163 | 0x00, 0x02, 0x00, 0x06, 0x00, 0x04, 0x00, 0x06, 0x00, 0x02, 0x00, 0x04, 164 | 0x00, 0x00, 0xFE, 0x03, 0xFE, 0x03, 0xFE, 0x03 165 | }; 166 | #endif 167 | 168 | #if 1 // font_Larger (Tahoma, 11Bold) 169 | // 170 | // Medium bold font, height = 11 (including the decenders) 171 | // The font table contains 3 sections: Header, Table Of Character Indexes, Pixel data 172 | // 173 | // The Header contains two bytes: 174 | // Byte0 = Font height (including decenders) 175 | // Byte1 = Number of additional pixels that should be drawn right of char 176 | // Byte2 = Recommended line spacing 177 | // Byte3 = Height of decenders 178 | // Byte4 = Unused byte 179 | // 180 | // The Table Of Character Indexes, is a table of 2 byte words that index to the pixel data within this table 181 | // Word0 = Index into this table to the pixels for ASCII char 0x20 182 | // Word1 = Index into this table to the pixels for ASCII char 0x21 183 | // Word2 = Index into this table to the pixels for ASCII char 0x22 184 | // ... 185 | // Word95 = Index into this table to the pixels for ASCII char 0x7F 186 | // 187 | // The Pixel data table contains the bitmap for each character 188 | // Data is written in columns of pixels, each column is 16 bits (2 bytes) 189 | // Byte0 = width of the ASCII 0x20 character in pixels 190 | // Byte1 = pixel data for the 0x20 char's 1st top column, bit 0 is the top pixel, bit 7 is the 8th pixel down from the top 191 | // Byte2 = pixel data for the 0x20 char's 1st bottom column, bit 0 is the 9th pixel 192 | // Byte5 = pixel data for the 0x20 char's 2nd top column 193 | // Byte6 = pixel data for the 0x20 char's 2nd bottom column 194 | // ... = remaining pairs of bytes of the columns in the 0x20 char 195 | // ... = width of the 0x21 char in pixels 196 | // ... = pixel data for the 0x21 char 197 | // ... 198 | // 199 | const uint8_t font_Larger[] = { 200 | 0x0C, 0x01, 0x0D, 0x02, 0x00, 201 | 202 | 0xC5, 0x00, 0xCE, 0x00, 0xD5, 0x00, 0xE0, 0x00, 0xF1, 0x00, 0x00, 0x01, 203 | 0x1B, 0x01, 0x2C, 0x01, 0x31, 0x01, 0x3A, 0x01, 0x43, 0x01, 0x52, 0x01, 204 | 0x63, 0x01, 0x6A, 0x01, 0x73, 0x01, 0x7A, 0x01, 0x85, 0x01, 0x94, 0x01, 205 | 0xA3, 0x01, 0xB2, 0x01, 0xC1, 0x01, 0xD0, 0x01, 0xDF, 0x01, 0xEE, 0x01, 206 | 0xFD, 0x01, 0x0C, 0x02, 0x1B, 0x02, 0x22, 0x02, 0x29, 0x02, 0x3C, 0x02, 207 | 0x4D, 0x02, 0x60, 0x02, 0x6D, 0x02, 0x80, 0x02, 0x91, 0x02, 0xA0, 0x02, 208 | 0xAF, 0x02, 0xC0, 0x02, 0xCD, 0x02, 0xD8, 0x02, 0xE7, 0x02, 0xF8, 0x02, 209 | 0x01, 0x03, 0x0C, 0x03, 0x1B, 0x03, 0x28, 0x03, 0x3D, 0x03, 0x4C, 0x03, 210 | 0x5D, 0x03, 0x6C, 0x03, 0x7D, 0x03, 0x8E, 0x03, 0x9D, 0x03, 0xAA, 0x03, 211 | 0xB9, 0x03, 0xC8, 0x03, 0xDF, 0x03, 0xEE, 0x03, 0xFB, 0x03, 0x08, 0x04, 212 | 0x11, 0x04, 0x1C, 0x04, 0x25, 0x04, 0x38, 0x04, 0x49, 0x04, 0x54, 0x04, 213 | 0x61, 0x04, 0x70, 0x04, 0x7B, 0x04, 0x8A, 0x04, 0x97, 0x04, 0xA2, 0x04, 214 | 0xB1, 0x04, 0xC0, 0x04, 0xC5, 0x04, 0xCC, 0x04, 0xD9, 0x04, 0xDE, 0x04, 215 | 0xF3, 0x04, 0x02, 0x05, 0x11, 0x05, 0x20, 0x05, 0x2F, 0x05, 0x38, 0x05, 216 | 0x43, 0x05, 0x4E, 0x05, 0x5D, 0x05, 0x6A, 0x05, 0x7F, 0x05, 0x8C, 0x05, 217 | 0x99, 0x05, 0xA4, 0x05, 0xB1, 0x05, 0xBA, 0x05, 0xC7, 0x05, 0xDA, 0x05, 218 | 219 | 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 220 | 0x7E, 0x03, 0x7E, 0x03, 0x05, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 221 | 0x00, 0x07, 0x00, 0x08, 0xC0, 0x00, 0xD8, 0x03, 0xF8, 0x00, 0xDE, 0x00, 222 | 0xD8, 0x03, 0xF8, 0x00, 0xDE, 0x00, 0x18, 0x00, 0x07, 0x18, 0x01, 0x3C, 223 | 0x02, 0x64, 0x02, 0xFF, 0x0F, 0x64, 0x02, 0xC4, 0x03, 0x88, 0x01, 0x0D, 224 | 0x1C, 0x00, 0x3E, 0x00, 0x22, 0x00, 0x3E, 0x02, 0x1C, 0x01, 0xC0, 0x00, 225 | 0x20, 0x00, 0x18, 0x00, 0xC4, 0x01, 0xE2, 0x03, 0x20, 0x02, 0xE0, 0x03, 226 | 0xC0, 0x01, 0x08, 0xCC, 0x01, 0xFE, 0x03, 0x32, 0x02, 0x72, 0x02, 0xDE, 227 | 0x03, 0x8C, 0x01, 0xE0, 0x03, 0x60, 0x02, 0x02, 0x07, 0x00, 0x07, 0x00, 228 | 0x04, 0xF8, 0x01, 0xFE, 0x07, 0x07, 0x0E, 0x01, 0x08, 0x04, 0x01, 0x08, 229 | 0x07, 0x0E, 0xFE, 0x07, 0xF8, 0x01, 0x07, 0x00, 0x00, 0x0A, 0x00, 0x04, 230 | 0x00, 0x1F, 0x00, 0x1F, 0x00, 0x04, 0x00, 0x0A, 0x00, 0x08, 0x00, 0x00, 231 | 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0xFC, 0x01, 0x20, 0x00, 0x20, 0x00, 232 | 0x20, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x07, 0x04, 0x20, 0x00, 233 | 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 234 | 0x03, 0x05, 0x00, 0x0C, 0x80, 0x03, 0x60, 0x00, 0x1C, 0x00, 0x03, 0x00, 235 | 0x07, 0xFC, 0x01, 0xFE, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0xFE, 236 | 0x03, 0xFC, 0x01, 0x07, 0x00, 0x00, 0x04, 0x02, 0x04, 0x02, 0xFE, 0x03, 237 | 0xFE, 0x03, 0x00, 0x02, 0x00, 0x02, 0x07, 0x04, 0x02, 0x02, 0x03, 0x82, 238 | 0x03, 0xC2, 0x02, 0x62, 0x02, 0x3E, 0x02, 0x1C, 0x02, 0x07, 0x04, 0x01, 239 | 0x02, 0x02, 0x22, 0x02, 0x22, 0x02, 0x22, 0x02, 0xFE, 0x03, 0xDC, 0x01, 240 | 0x07, 0x60, 0x00, 0x50, 0x00, 0x48, 0x00, 0x44, 0x00, 0xFE, 0x03, 0xFE, 241 | 0x03, 0x40, 0x00, 0x07, 0x00, 0x01, 0x1E, 0x02, 0x1E, 0x02, 0x12, 0x02, 242 | 0x12, 0x02, 0xF2, 0x03, 0xE2, 0x01, 0x07, 0xF8, 0x01, 0xFC, 0x03, 0x16, 243 | 0x02, 0x12, 0x02, 0x12, 0x02, 0xF2, 0x03, 0xE0, 0x01, 0x07, 0x02, 0x00, 244 | 0x02, 0x00, 0x82, 0x03, 0xE2, 0x03, 0x7A, 0x00, 0x1E, 0x00, 0x06, 0x00, 245 | 0x07, 0xDC, 0x01, 0xFE, 0x03, 0x22, 0x02, 0x22, 0x02, 0x22, 0x02, 0xFE, 246 | 0x03, 0xDC, 0x01, 0x07, 0x3C, 0x00, 0x7E, 0x02, 0x42, 0x02, 0x42, 0x02, 247 | 0x42, 0x03, 0xFE, 0x01, 0xFC, 0x00, 0x03, 0x00, 0x00, 0x18, 0x03, 0x18, 248 | 0x03, 0x03, 0x00, 0x00, 0x18, 0x0F, 0x18, 0x07, 0x09, 0x00, 0x00, 0x60, 249 | 0x00, 0x60, 0x00, 0x90, 0x00, 0x90, 0x00, 0x08, 0x01, 0x08, 0x01, 0x04, 250 | 0x02, 0x04, 0x02, 0x08, 0x00, 0x00, 0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 251 | 0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 0x09, 0x00, 0x00, 0x04, 252 | 0x02, 0x04, 0x02, 0x08, 0x01, 0x08, 0x01, 0x90, 0x00, 0x90, 0x00, 0x60, 253 | 0x00, 0x60, 0x00, 0x06, 0x04, 0x00, 0x02, 0x00, 0x62, 0x03, 0x72, 0x03, 254 | 0x1E, 0x00, 0x0C, 0x00, 0x09, 0xF8, 0x01, 0x04, 0x02, 0xF2, 0x04, 0xFA, 255 | 0x05, 0x0A, 0x05, 0xFA, 0x04, 0xFA, 0x05, 0x04, 0x01, 0xF8, 0x00, 0x08, 256 | 0x80, 0x03, 0xF0, 0x03, 0xFC, 0x00, 0x8E, 0x00, 0x8E, 0x00, 0xFC, 0x00, 257 | 0xF0, 0x03, 0x80, 0x03, 0x07, 0xFE, 0x03, 0xFE, 0x03, 0x22, 0x02, 0x22, 258 | 0x02, 0x22, 0x02, 0xFE, 0x03, 0xDC, 0x01, 0x07, 0xFC, 0x01, 0xFE, 0x03, 259 | 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x8C, 0x01, 0x08, 0xFE, 260 | 0x03, 0xFE, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x06, 0x03, 0xFC, 261 | 0x01, 0xF8, 0x00, 0x06, 0xFE, 0x03, 0xFE, 0x03, 0x22, 0x02, 0x22, 0x02, 262 | 0x22, 0x02, 0x22, 0x02, 0x05, 0xFE, 0x03, 0xFE, 0x03, 0x22, 0x00, 0x22, 263 | 0x00, 0x22, 0x00, 0x07, 0xFC, 0x01, 0xFE, 0x03, 0x02, 0x02, 0x02, 0x02, 264 | 0x22, 0x02, 0xE2, 0x03, 0xEC, 0x03, 0x08, 0xFE, 0x03, 0xFE, 0x03, 0x20, 265 | 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0xFE, 0x03, 0xFE, 0x03, 0x04, 266 | 0x02, 0x02, 0xFE, 0x03, 0xFE, 0x03, 0x02, 0x02, 0x05, 0x00, 0x02, 0x02, 267 | 0x02, 0x02, 0x02, 0xFE, 0x03, 0xFE, 0x01, 0x07, 0xFE, 0x03, 0xFE, 0x03, 268 | 0x70, 0x00, 0xD8, 0x00, 0x8C, 0x01, 0x06, 0x03, 0x02, 0x02, 0x06, 0xFE, 269 | 0x03, 0xFE, 0x03, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x0A, 270 | 0xFE, 0x03, 0x0E, 0x00, 0x1C, 0x00, 0x38, 0x00, 0x70, 0x00, 0x30, 0x00, 271 | 0x18, 0x00, 0x0C, 0x00, 0xFE, 0x03, 0xFE, 0x03, 0x07, 0xFE, 0x03, 0x0E, 272 | 0x00, 0x1C, 0x00, 0x70, 0x00, 0xE0, 0x01, 0x80, 0x03, 0xFE, 0x03, 0x08, 273 | 0xFC, 0x01, 0xFE, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 274 | 0xFE, 0x03, 0xFC, 0x01, 0x07, 0xFE, 0x03, 0xFE, 0x03, 0x42, 0x00, 0x42, 275 | 0x00, 0x42, 0x00, 0x7E, 0x00, 0x3C, 0x00, 0x08, 0xFC, 0x01, 0xFE, 0x03, 276 | 0x02, 0x02, 0x02, 0x02, 0x02, 0x06, 0x02, 0x0E, 0xFE, 0x0B, 0xFC, 0x09, 277 | 0x08, 0xFE, 0x03, 0xFE, 0x03, 0x22, 0x00, 0x62, 0x00, 0xE2, 0x00, 0xBE, 278 | 0x01, 0x1C, 0x03, 0x00, 0x02, 0x07, 0x9C, 0x01, 0x3E, 0x02, 0x22, 0x02, 279 | 0x22, 0x02, 0x22, 0x02, 0xE2, 0x03, 0xCC, 0x01, 0x06, 0x02, 0x00, 0x02, 280 | 0x00, 0xFE, 0x03, 0xFE, 0x03, 0x02, 0x00, 0x02, 0x00, 0x07, 0xFE, 0x01, 281 | 0xFE, 0x03, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0xFE, 0x03, 0xFE, 0x01, 282 | 0x07, 0x0E, 0x00, 0x7E, 0x00, 0xF0, 0x03, 0x80, 0x03, 0xF0, 0x03, 0x7E, 283 | 0x00, 0x0E, 0x00, 0x0B, 0x1E, 0x00, 0xFE, 0x00, 0xE0, 0x03, 0xE0, 0x03, 284 | 0xFC, 0x00, 0x0E, 0x00, 0xFC, 0x00, 0xE0, 0x03, 0xE0, 0x03, 0xFE, 0x00, 285 | 0x1E, 0x00, 0x07, 0x06, 0x03, 0x8E, 0x03, 0xF8, 0x00, 0x70, 0x00, 0xF8, 286 | 0x00, 0x8E, 0x03, 0x06, 0x03, 0x06, 0x0E, 0x00, 0x3E, 0x00, 0xF0, 0x03, 287 | 0xF0, 0x03, 0x3E, 0x00, 0x0E, 0x00, 0x06, 0x82, 0x03, 0xC2, 0x03, 0x62, 288 | 0x02, 0x32, 0x02, 0x1E, 0x02, 0x0E, 0x02, 0x04, 0xFF, 0x0F, 0xFF, 0x0F, 289 | 0x01, 0x08, 0x01, 0x08, 0x05, 0x03, 0x00, 0x1C, 0x00, 0x60, 0x00, 0x80, 290 | 0x03, 0x00, 0x0C, 0x04, 0x01, 0x08, 0x01, 0x08, 0xFF, 0x0F, 0xFF, 0x0F, 291 | 0x09, 0x00, 0x00, 0x10, 0x00, 0x08, 0x00, 0x04, 0x00, 0x02, 0x00, 0x02, 292 | 0x00, 0x04, 0x00, 0x08, 0x00, 0x10, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 293 | 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 294 | 0x05, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x00, 0x02, 0x00, 0x06, 295 | 0x80, 0x01, 0xD0, 0x03, 0x48, 0x02, 0x48, 0x02, 0xF8, 0x03, 0xF0, 0x03, 296 | 0x07, 0xFF, 0x03, 0xFF, 0x03, 0x10, 0x02, 0x08, 0x02, 0x08, 0x02, 0xF8, 297 | 0x03, 0xF0, 0x01, 0x05, 0xF0, 0x01, 0xF8, 0x03, 0x08, 0x02, 0x08, 0x02, 298 | 0x08, 0x02, 0x07, 0xF0, 0x01, 0xF8, 0x03, 0x08, 0x02, 0x08, 0x02, 0x08, 299 | 0x01, 0xFF, 0x03, 0xFF, 0x03, 0x06, 0xF0, 0x01, 0xF8, 0x03, 0x48, 0x02, 300 | 0x48, 0x02, 0x78, 0x02, 0x70, 0x01, 0x05, 0x08, 0x00, 0xFE, 0x03, 0xFF, 301 | 0x03, 0x09, 0x00, 0x01, 0x00, 0x07, 0xF0, 0x01, 0xF8, 0x0B, 0x08, 0x0A, 302 | 0x08, 0x0A, 0x08, 0x09, 0xF8, 0x0F, 0xF8, 0x07, 0x07, 0xFF, 0x03, 0xFF, 303 | 0x03, 0x10, 0x00, 0x08, 0x00, 0x08, 0x00, 0xF8, 0x03, 0xF0, 0x03, 0x02, 304 | 0xFA, 0x03, 0xFA, 0x03, 0x03, 0x08, 0x08, 0xFA, 0x0F, 0xFA, 0x07, 0x06, 305 | 0xFF, 0x03, 0xFF, 0x03, 0xE0, 0x00, 0xB0, 0x01, 0x18, 0x03, 0x08, 0x02, 306 | 0x02, 0xFF, 0x03, 0xFF, 0x03, 0x0A, 0xF8, 0x03, 0xF8, 0x03, 0x08, 0x00, 307 | 0x08, 0x00, 0xF8, 0x03, 0xF0, 0x03, 0x08, 0x00, 0x08, 0x00, 0xF8, 0x03, 308 | 0xF0, 0x03, 0x07, 0xF8, 0x03, 0xF8, 0x03, 0x10, 0x00, 0x08, 0x00, 0x08, 309 | 0x00, 0xF8, 0x03, 0xF0, 0x03, 0x07, 0xF0, 0x01, 0xF8, 0x03, 0x08, 0x02, 310 | 0x08, 0x02, 0x08, 0x02, 0xF8, 0x03, 0xF0, 0x01, 0x07, 0xF8, 0x0F, 0xF8, 311 | 0x0F, 0x10, 0x02, 0x08, 0x02, 0x08, 0x02, 0xF8, 0x03, 0xF0, 0x01, 0x07, 312 | 0xF0, 0x01, 0xF8, 0x03, 0x08, 0x02, 0x08, 0x02, 0x08, 0x01, 0xF8, 0x0F, 313 | 0xF8, 0x0F, 0x04, 0xF8, 0x03, 0xF8, 0x03, 0x10, 0x00, 0x18, 0x00, 0x05, 314 | 0x30, 0x01, 0x78, 0x02, 0x48, 0x02, 0xC8, 0x03, 0x90, 0x01, 0x05, 0x08, 315 | 0x00, 0xFE, 0x01, 0xFE, 0x03, 0x08, 0x02, 0x08, 0x02, 0x07, 0xF8, 0x01, 316 | 0xF8, 0x03, 0x00, 0x02, 0x00, 0x02, 0x00, 0x01, 0xF8, 0x03, 0xF8, 0x03, 317 | 0x06, 0x38, 0x00, 0xF8, 0x00, 0xC0, 0x03, 0xC0, 0x03, 0xF8, 0x00, 0x38, 318 | 0x00, 0x0A, 0x18, 0x00, 0xF8, 0x00, 0xE0, 0x03, 0x80, 0x03, 0xF8, 0x00, 319 | 0xF8, 0x00, 0x80, 0x03, 0xE0, 0x03, 0xF8, 0x00, 0x18, 0x00, 0x06, 0x18, 320 | 0x03, 0xB8, 0x03, 0xE0, 0x00, 0xE0, 0x00, 0xB8, 0x03, 0x18, 0x03, 0x06, 321 | 0x38, 0x00, 0xF8, 0x0C, 0xC0, 0x0F, 0xC0, 0x03, 0xF8, 0x00, 0x38, 0x00, 322 | 0x05, 0x88, 0x03, 0xC8, 0x03, 0x68, 0x02, 0x38, 0x02, 0x18, 0x02, 0x06, 323 | 0x20, 0x00, 0x20, 0x00, 0xFE, 0x07, 0xDF, 0x0F, 0x01, 0x08, 0x01, 0x08, 324 | 0x04, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x0F, 0xFF, 0x0F, 0x06, 0x01, 0x08, 325 | 0x01, 0x08, 0xDF, 0x0F, 0xFE, 0x07, 0x20, 0x00, 0x20, 0x00, 0x09, 0xE0, 326 | 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x60, 0x00, 0xC0, 0x00, 0xC0, 327 | 0x00, 0xC0, 0x00, 0x70, 0x00, 0x06, 0x00, 0x00, 0xFE, 0x03, 0xFE, 0x03, 328 | 0x02, 0x02, 0xFE, 0x03, 0xFE, 0x03 329 | }; 330 | #endif 331 | 332 | #if 1 // font_MediumBold (UI Font) 333 | // The font table contains 3 sections: Header, Table Of Character Indexes, Pixel data 334 | // 335 | // The Header contains two bytes: 336 | // Byte0 = Font height (including decenders) 337 | // Byte1 = Number of additional pixels that should be drawn right of char 338 | // Byte2 = Recommended line spacing 339 | // Byte3 = Height of decenders 340 | // Byte4 = Unused byte 341 | // 342 | // The Table Of Character Indexes, is a table of 2 byte words that index to the pixel data within this table 343 | // Word0 = Index into this table to the pixels for ASCII char 0x20 344 | // Word1 = Index into this table to the pixels for ASCII char 0x21 345 | // Word2 = Index into this table to the pixels for ASCII char 0x22 346 | // ... 347 | // Word95 = Index into this table to the pixels for ASCII char 0x7F 348 | // 349 | // The Pixel data table contains the bitmap for each character 350 | // Data is written in columns of pixels, each column is 16 bits (2 bytes) 351 | // Byte0 = width of the ASCII 0x20 character in pixels 352 | // Byte1 = pixel data for the 0x20 char's 1st top column, bit 0 is the top pixel, bit 7 is the 8th pixel down from the top 353 | // Byte2 = pixel data for the 0x20 char's 1st bottom column, bit 0 is the 9th pixel 354 | // Byte5 = pixel data for the 0x20 char's 2nd top column 355 | // Byte6 = pixel data for the 0x20 char's 2nd bottom column 356 | // ... = remaining pairs of bytes of the columns in the 0x20 char 357 | // ... = width of the 0x21 char in pixels 358 | // ... = pixel data for the 0x21 char 359 | // ... 360 | // 361 | const uint8_t font_MediumBold[] = { 362 | 0x0D, 0x00, 0x0F, 0x02, 0x00, 363 | 364 | 0xC5, 0x00, 0xD2, 0x00, 0xD9, 0x00, 0xE6, 0x00, 0xF7, 0x00, 0x06, 0x01, 365 | 0x21, 0x01, 0x34, 0x01, 0x3B, 0x01, 0x46, 0x01, 0x51, 0x01, 0x5E, 0x01, 366 | 0x6F, 0x01, 0x76, 0x01, 0x81, 0x01, 0x88, 0x01, 0x97, 0x01, 0xA6, 0x01, 367 | 0xB5, 0x01, 0xC4, 0x01, 0xD3, 0x01, 0xE2, 0x01, 0xF1, 0x01, 0x00, 0x02, 368 | 0x0F, 0x02, 0x1E, 0x02, 0x2D, 0x02, 0x34, 0x02, 0x3B, 0x02, 0x4C, 0x02, 369 | 0x5D, 0x02, 0x6E, 0x02, 0x7B, 0x02, 0x90, 0x02, 0xA1, 0x02, 0xB0, 0x02, 370 | 0xBF, 0x02, 0xD0, 0x02, 0xDF, 0x02, 0xEE, 0x02, 0xFF, 0x02, 0x10, 0x03, 371 | 0x1B, 0x03, 0x26, 0x03, 0x35, 0x03, 0x44, 0x03, 0x57, 0x03, 0x68, 0x03, 372 | 0x79, 0x03, 0x88, 0x03, 0x99, 0x03, 0xAA, 0x03, 0xB9, 0x03, 0xCA, 0x03, 373 | 0xDB, 0x03, 0xEA, 0x03, 0x01, 0x04, 0x10, 0x04, 0x1F, 0x04, 0x2E, 0x04, 374 | 0x39, 0x04, 0x48, 0x04, 0x53, 0x04, 0x66, 0x04, 0x77, 0x04, 0x82, 0x04, 375 | 0x91, 0x04, 0xA0, 0x04, 0xAD, 0x04, 0xBC, 0x04, 0xCB, 0x04, 0xD6, 0x04, 376 | 0xE5, 0x04, 0xF4, 0x04, 0xFB, 0x04, 0x04, 0x05, 0x13, 0x05, 0x1A, 0x05, 377 | 0x31, 0x05, 0x40, 0x05, 0x4F, 0x05, 0x5E, 0x05, 0x6D, 0x05, 0x7A, 0x05, 378 | 0x87, 0x05, 0x92, 0x05, 0xA1, 0x05, 0xB0, 0x05, 0xC3, 0x05, 0xD2, 0x05, 379 | 0xE1, 0x05, 0xEE, 0x05, 0xFD, 0x05, 0x06, 0x06, 0x15, 0x06, 0x26, 0x06, 380 | 381 | 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 382 | 0x00, 0x03, 0x00, 0x00, 0xFC, 0x02, 0xFC, 0x02, 0x06, 0x00, 0x00, 0x0E, 383 | 0x00, 0x0E, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x08, 0x00, 0x00, 384 | 0x80, 0x00, 0x90, 0x03, 0xF0, 0x00, 0x9C, 0x03, 0xF0, 0x00, 0x9C, 0x00, 385 | 0x10, 0x00, 0x07, 0x00, 0x00, 0x30, 0x01, 0x78, 0x02, 0xC8, 0x0F, 0x7E, 386 | 0x02, 0xC8, 0x03, 0x90, 0x01, 0x0D, 0x00, 0x00, 0x38, 0x00, 0x7C, 0x00, 387 | 0x44, 0x00, 0x7C, 0x00, 0x38, 0x03, 0xC0, 0x00, 0x30, 0x00, 0xCC, 0x01, 388 | 0xE0, 0x03, 0x20, 0x02, 0xE0, 0x03, 0xC0, 0x01, 0x09, 0x00, 0x00, 0xD8, 389 | 0x01, 0xFC, 0x03, 0x24, 0x02, 0x7C, 0x02, 0xD8, 0x02, 0x80, 0x01, 0x60, 390 | 0x03, 0x20, 0x02, 0x03, 0x00, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x05, 0x00, 391 | 0x00, 0xF0, 0x01, 0xFC, 0x07, 0x0E, 0x0E, 0x02, 0x08, 0x05, 0x00, 0x00, 392 | 0x02, 0x08, 0x0E, 0x0E, 0xFC, 0x07, 0xF0, 0x01, 0x06, 0x00, 0x00, 0x14, 393 | 0x00, 0x08, 0x00, 0x3E, 0x00, 0x08, 0x00, 0x14, 0x00, 0x08, 0x00, 0x00, 394 | 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0xF8, 0x03, 0x40, 0x00, 0x40, 0x00, 395 | 0x40, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x07, 0x05, 0x00, 0x00, 396 | 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x03, 0x00, 0x00, 0x00, 397 | 0x03, 0x00, 0x03, 0x07, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x0F, 0xE0, 0x03, 398 | 0xF8, 0x00, 0x1E, 0x00, 0x06, 0x00, 0x07, 0x00, 0x00, 0xF8, 0x01, 0xFC, 399 | 0x03, 0x04, 0x02, 0x04, 0x02, 0xFC, 0x03, 0xF8, 0x01, 0x07, 0x00, 0x00, 400 | 0x00, 0x00, 0x08, 0x02, 0xFC, 0x03, 0xFC, 0x03, 0x00, 0x02, 0x00, 0x00, 401 | 0x07, 0x00, 0x00, 0x08, 0x03, 0x8C, 0x03, 0xC4, 0x02, 0x64, 0x02, 0x3C, 402 | 0x02, 0x18, 0x02, 0x07, 0x00, 0x00, 0x08, 0x01, 0x0C, 0x03, 0x24, 0x02, 403 | 0x24, 0x02, 0xFC, 0x03, 0xD8, 0x01, 0x07, 0x00, 0x00, 0xC0, 0x00, 0xA0, 404 | 0x00, 0x90, 0x00, 0xF8, 0x03, 0xFC, 0x03, 0x80, 0x00, 0x07, 0x00, 0x00, 405 | 0x00, 0x01, 0x3C, 0x03, 0x3C, 0x02, 0x24, 0x02, 0xE4, 0x03, 0xC4, 0x01, 406 | 0x07, 0x00, 0x00, 0xF0, 0x01, 0xF8, 0x03, 0x2C, 0x02, 0x24, 0x02, 0xE4, 407 | 0x03, 0xC0, 0x01, 0x07, 0x00, 0x00, 0x04, 0x00, 0x04, 0x03, 0xC4, 0x03, 408 | 0xF4, 0x00, 0x3C, 0x00, 0x0C, 0x00, 0x07, 0x00, 0x00, 0xD8, 0x01, 0xFC, 409 | 0x03, 0x24, 0x02, 0x24, 0x02, 0xFC, 0x03, 0xD8, 0x01, 0x07, 0x00, 0x00, 410 | 0x38, 0x00, 0x7C, 0x02, 0x44, 0x02, 0x44, 0x03, 0xFC, 0x01, 0xF8, 0x00, 411 | 0x03, 0x00, 0x00, 0x30, 0x03, 0x30, 0x03, 0x03, 0x00, 0x00, 0x30, 0x0F, 412 | 0x30, 0x07, 0x08, 0x00, 0x00, 0x40, 0x00, 0xA0, 0x00, 0xA0, 0x00, 0x10, 413 | 0x01, 0x10, 0x01, 0x08, 0x02, 0x08, 0x02, 0x08, 0x00, 0x00, 0x90, 0x00, 414 | 0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 0x90, 0x00, 415 | 0x08, 0x00, 0x00, 0x08, 0x02, 0x08, 0x02, 0x10, 0x01, 0x10, 0x01, 0xA0, 416 | 0x00, 0xA0, 0x00, 0x40, 0x00, 0x06, 0x00, 0x00, 0x08, 0x00, 0xC4, 0x02, 417 | 0xE4, 0x02, 0x3C, 0x00, 0x18, 0x00, 0x0A, 0x00, 0x00, 0xF0, 0x01, 0x08, 418 | 0x02, 0xE4, 0x04, 0xF4, 0x05, 0x14, 0x05, 0xF4, 0x05, 0xF4, 0x05, 0x04, 419 | 0x01, 0xF8, 0x00, 0x08, 0x00, 0x00, 0x80, 0x03, 0xF0, 0x03, 0xFC, 0x00, 420 | 0x8C, 0x00, 0xFC, 0x00, 0xF0, 0x03, 0x80, 0x03, 0x07, 0x00, 0x00, 0xFC, 421 | 0x03, 0xFC, 0x03, 0x24, 0x02, 0x24, 0x02, 0xFC, 0x03, 0xD8, 0x01, 0x07, 422 | 0x00, 0x00, 0xF8, 0x01, 0xFC, 0x03, 0x04, 0x02, 0x04, 0x02, 0x04, 0x02, 423 | 0x08, 0x01, 0x08, 0x00, 0x00, 0xFC, 0x03, 0xFC, 0x03, 0x04, 0x02, 0x04, 424 | 0x02, 0x0C, 0x03, 0xF8, 0x01, 0xF0, 0x00, 0x07, 0x00, 0x00, 0xFC, 0x03, 425 | 0xFC, 0x03, 0x24, 0x02, 0x24, 0x02, 0x24, 0x02, 0x24, 0x02, 0x07, 0x00, 426 | 0x00, 0xFC, 0x03, 0xFC, 0x03, 0x24, 0x00, 0x24, 0x00, 0x24, 0x00, 0x24, 427 | 0x00, 0x08, 0x00, 0x00, 0xF8, 0x01, 0xFC, 0x03, 0x04, 0x02, 0x04, 0x02, 428 | 0x44, 0x02, 0xC4, 0x03, 0xC8, 0x03, 0x08, 0x00, 0x00, 0xFC, 0x03, 0xFC, 429 | 0x03, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0xFC, 0x03, 0xFC, 0x03, 0x05, 430 | 0x00, 0x00, 0x04, 0x02, 0xFC, 0x03, 0xFC, 0x03, 0x04, 0x02, 0x05, 0x00, 431 | 0x02, 0x04, 0x02, 0x04, 0x02, 0xFC, 0x03, 0xFC, 0x01, 0x07, 0x00, 0x00, 432 | 0xFC, 0x03, 0xFC, 0x03, 0xF0, 0x00, 0x98, 0x01, 0x0C, 0x03, 0x04, 0x02, 433 | 0x07, 0x00, 0x00, 0xFC, 0x03, 0xFC, 0x03, 0x00, 0x02, 0x00, 0x02, 0x00, 434 | 0x02, 0x00, 0x02, 0x09, 0x00, 0x00, 0xFC, 0x03, 0x1C, 0x00, 0x38, 0x00, 435 | 0x70, 0x00, 0x20, 0x00, 0x10, 0x00, 0xF8, 0x03, 0xFC, 0x03, 0x08, 0x00, 436 | 0x00, 0xFC, 0x03, 0x18, 0x00, 0x30, 0x00, 0x60, 0x00, 0xC0, 0x00, 0x80, 437 | 0x01, 0xFC, 0x03, 0x08, 0x00, 0x00, 0xF8, 0x01, 0xFC, 0x03, 0x04, 0x02, 438 | 0x04, 0x02, 0x04, 0x02, 0xFC, 0x03, 0xF8, 0x01, 0x07, 0x00, 0x00, 0xFC, 439 | 0x03, 0xFC, 0x03, 0x44, 0x00, 0x44, 0x00, 0x7C, 0x00, 0x38, 0x00, 0x08, 440 | 0x00, 0x00, 0xF8, 0x01, 0xFC, 0x03, 0x04, 0x02, 0x04, 0x06, 0x04, 0x0E, 441 | 0xFC, 0x0B, 0xF8, 0x09, 0x08, 0x00, 0x00, 0xFC, 0x03, 0xFC, 0x03, 0x44, 442 | 0x00, 0xC4, 0x00, 0xFC, 0x01, 0x38, 0x03, 0x00, 0x02, 0x07, 0x00, 0x00, 443 | 0x38, 0x01, 0x7C, 0x02, 0x64, 0x02, 0x64, 0x02, 0xE4, 0x03, 0xC8, 0x01, 444 | 0x08, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0xFC, 0x03, 0xFC, 0x03, 0x04, 445 | 0x00, 0x04, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0xFC, 0x01, 0xFC, 0x03, 446 | 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0xFC, 0x03, 0xFC, 0x01, 0x07, 0x00, 447 | 0x00, 0x1C, 0x00, 0xFC, 0x00, 0xE0, 0x03, 0xE0, 0x03, 0xFC, 0x00, 0x1C, 448 | 0x00, 0x0B, 0x00, 0x00, 0x1C, 0x00, 0xFC, 0x00, 0xE0, 0x03, 0xC0, 0x03, 449 | 0x7C, 0x00, 0x7C, 0x00, 0xC0, 0x03, 0xE0, 0x03, 0xFC, 0x00, 0x1C, 0x00, 450 | 0x07, 0x00, 0x00, 0x0C, 0x03, 0x9C, 0x03, 0xF0, 0x00, 0xF0, 0x00, 0x9C, 451 | 0x03, 0x0C, 0x03, 0x07, 0x00, 0x00, 0x0C, 0x00, 0x3C, 0x00, 0xF0, 0x03, 452 | 0xF0, 0x03, 0x3C, 0x00, 0x0C, 0x00, 0x07, 0x00, 0x00, 0x84, 0x03, 0xC4, 453 | 0x03, 0xE4, 0x02, 0x74, 0x02, 0x3C, 0x02, 0x1C, 0x02, 0x05, 0x00, 0x00, 454 | 0xFE, 0x0F, 0xFE, 0x0F, 0x02, 0x08, 0x02, 0x08, 0x07, 0x00, 0x00, 0x06, 455 | 0x00, 0x1E, 0x00, 0xF8, 0x00, 0xE0, 0x03, 0x00, 0x0F, 0x00, 0x0C, 0x05, 456 | 0x00, 0x00, 0x02, 0x08, 0x02, 0x08, 0xFE, 0x0F, 0xFE, 0x0F, 0x09, 0x00, 457 | 0x00, 0x20, 0x00, 0x30, 0x00, 0x18, 0x00, 0x0C, 0x00, 0x0C, 0x00, 0x18, 458 | 0x00, 0x30, 0x00, 0x20, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 459 | 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x05, 0x00, 460 | 0x00, 0x00, 0x00, 0x02, 0x00, 0x06, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 461 | 0x80, 0x01, 0xD0, 0x03, 0x50, 0x02, 0x50, 0x02, 0xF0, 0x03, 0xE0, 0x03, 462 | 0x07, 0x00, 0x00, 0xFE, 0x03, 0xFE, 0x03, 0x10, 0x02, 0x10, 0x02, 0xF0, 463 | 0x03, 0xE0, 0x01, 0x06, 0x00, 0x00, 0xE0, 0x01, 0xF0, 0x03, 0x10, 0x02, 464 | 0x10, 0x02, 0x10, 0x02, 0x07, 0x00, 0x00, 0xE0, 0x01, 0xF0, 0x03, 0x10, 465 | 0x02, 0x10, 0x02, 0xFE, 0x03, 0xFE, 0x03, 0x07, 0x00, 0x00, 0xE0, 0x01, 466 | 0xF0, 0x03, 0x50, 0x02, 0x50, 0x02, 0x70, 0x02, 0x60, 0x01, 0x05, 0x10, 467 | 0x00, 0xFC, 0x03, 0xFE, 0x03, 0x12, 0x00, 0x12, 0x00, 0x07, 0x00, 0x00, 468 | 0xE0, 0x01, 0xF0, 0x0B, 0x10, 0x0A, 0x10, 0x0A, 0xF0, 0x0F, 0xF0, 0x07, 469 | 0x07, 0x00, 0x00, 0xFE, 0x03, 0xFE, 0x03, 0x10, 0x00, 0x10, 0x00, 0xF0, 470 | 0x03, 0xE0, 0x03, 0x03, 0x00, 0x00, 0xF4, 0x03, 0xF4, 0x03, 0x04, 0x00, 471 | 0x08, 0x10, 0x08, 0xF4, 0x0F, 0xF4, 0x07, 0x07, 0x00, 0x00, 0xFE, 0x03, 472 | 0xFE, 0x03, 0xC0, 0x00, 0xE0, 0x01, 0x30, 0x03, 0x10, 0x02, 0x03, 0x00, 473 | 0x00, 0xFE, 0x03, 0xFE, 0x03, 0x0B, 0x00, 0x00, 0xF0, 0x03, 0xF0, 0x03, 474 | 0x10, 0x00, 0x10, 0x00, 0xF0, 0x03, 0xE0, 0x03, 0x10, 0x00, 0x10, 0x00, 475 | 0xF0, 0x03, 0xE0, 0x03, 0x07, 0x00, 0x00, 0xF0, 0x03, 0xF0, 0x03, 0x10, 476 | 0x00, 0x10, 0x00, 0xF0, 0x03, 0xE0, 0x03, 0x07, 0x00, 0x00, 0xE0, 0x01, 477 | 0xF0, 0x03, 0x10, 0x02, 0x10, 0x02, 0xF0, 0x03, 0xE0, 0x01, 0x07, 0x00, 478 | 0x00, 0xF0, 0x0F, 0xF0, 0x0F, 0x10, 0x02, 0x10, 0x02, 0xF0, 0x03, 0xE0, 479 | 0x01, 0x07, 0x00, 0x00, 0xE0, 0x01, 0xF0, 0x03, 0x10, 0x02, 0x10, 0x02, 480 | 0xF0, 0x0F, 0xF0, 0x0F, 0x06, 0x00, 0x00, 0xF0, 0x03, 0xF0, 0x03, 0x20, 481 | 0x00, 0x30, 0x00, 0x30, 0x00, 0x06, 0x00, 0x00, 0x60, 0x02, 0xF0, 0x02, 482 | 0xD0, 0x02, 0xD0, 0x03, 0x90, 0x01, 0x05, 0x10, 0x00, 0xFC, 0x01, 0xFC, 483 | 0x03, 0x10, 0x02, 0x10, 0x02, 0x07, 0x00, 0x00, 0xF0, 0x01, 0xF0, 0x03, 484 | 0x00, 0x02, 0x00, 0x02, 0xF0, 0x03, 0xF0, 0x03, 0x07, 0x00, 0x00, 0x70, 485 | 0x00, 0xF0, 0x01, 0x80, 0x03, 0x80, 0x03, 0xF0, 0x01, 0x70, 0x00, 0x09, 486 | 0x00, 0x00, 0xF0, 0x00, 0xF0, 0x03, 0x00, 0x03, 0xF0, 0x00, 0xF0, 0x00, 487 | 0x00, 0x03, 0xF0, 0x03, 0xF0, 0x00, 0x07, 0x00, 0x00, 0x30, 0x03, 0xF0, 488 | 0x03, 0xC0, 0x00, 0xC0, 0x00, 0xF0, 0x03, 0x30, 0x03, 0x07, 0x00, 0x00, 489 | 0x30, 0x00, 0xF0, 0x0C, 0xC0, 0x0F, 0xC0, 0x03, 0xF0, 0x00, 0x30, 0x00, 490 | 0x06, 0x00, 0x00, 0x10, 0x03, 0x90, 0x03, 0xD0, 0x02, 0x70, 0x02, 0x30, 491 | 0x02, 0x07, 0x00, 0x00, 0x40, 0x00, 0x40, 0x00, 0xFC, 0x07, 0xBE, 0x0F, 492 | 0x02, 0x08, 0x02, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x0F, 0xFE, 493 | 0x0F, 0x07, 0x00, 0x00, 0x02, 0x08, 0x02, 0x08, 0xBE, 0x0F, 0xFC, 0x07, 494 | 0x40, 0x00, 0x40, 0x00, 0x08, 0x00, 0x00, 0xC0, 0x01, 0x20, 0x00, 0x20, 495 | 0x00, 0xC0, 0x00, 0x00, 0x01, 0x00, 0x01, 0xE0, 0x00, 0x04, 0xFC, 0x03, 496 | 0xFC, 0x03, 0xFC, 0x03, 0xFC, 0x03 497 | }; 498 | #endif 499 | 500 | #if 0 // font_MediumBold (UI Font Option 2) 501 | // 502 | // Font table for Tahoma font, height = 11 (including the decenders) 503 | // The font table contains 3 sections: Header, Table Of Character Indexes, Pixel data 504 | // 505 | // The Header contains two bytes: 506 | // Byte0 = Font height (including decenders) 507 | // Byte1 = Number of additional pixels that should be drawn right of char 508 | // Byte2 = Recommended line spacing 509 | // Byte3 = Height of decenders 510 | // Byte4 = Unused byte 511 | // 512 | // The Table Of Character Indexes, is a table of 2 byte words that index to the pixel data within this table 513 | // Word0 = Index into this table to the pixels for ASCII char 0x20 514 | // Word1 = Index into this table to the pixels for ASCII char 0x21 515 | // Word2 = Index into this table to the pixels for ASCII char 0x22 516 | // ... 517 | // Word95 = Index into this table to the pixels for ASCII char 0x7F 518 | // 519 | // The Pixel data table contains the bitmap for each character 520 | // Data is written in columns of pixels, each column is 16 bits (2 bytes) 521 | // Byte0 = width of the ASCII 0x20 character in pixels 522 | // Byte1 = pixel data for the 0x20 char's 1st top column, bit 0 is the top pixel, bit 7 is the 8th pixel down from the top 523 | // Byte2 = pixel data for the 0x20 char's 1st bottom column, bit 0 is the 9th pixel 524 | // Byte5 = pixel data for the 0x20 char's 2nd top column 525 | // Byte6 = pixel data for the 0x20 char's 2nd bottom column 526 | // ... = remaining pairs of bytes of the columns in the 0x20 char 527 | // ... = width of the 0x21 char in pixels 528 | // ... = pixel data for the 0x21 char 529 | // ... 530 | // 531 | const uint8_t font_MediumBold[] = { 532 | 0x0B, 0x01, 0x0D, 0x02, 0x00, 533 | 534 | 0xC5, 0x00, 0xCE, 0x00, 0xD3, 0x00, 0xDE, 0x00, 0xEF, 0x00, 0xFC, 0x00, 535 | 0x15, 0x01, 0x26, 0x01, 0x2B, 0x01, 0x34, 0x01, 0x3D, 0x01, 0x4A, 0x01, 536 | 0x5B, 0x01, 0x60, 0x01, 0x69, 0x01, 0x6E, 0x01, 0x79, 0x01, 0x86, 0x01, 537 | 0x93, 0x01, 0xA0, 0x01, 0xAD, 0x01, 0xBA, 0x01, 0xC7, 0x01, 0xD4, 0x01, 538 | 0xE1, 0x01, 0xEE, 0x01, 0xFB, 0x01, 0x00, 0x02, 0x05, 0x02, 0x16, 0x02, 539 | 0x27, 0x02, 0x38, 0x02, 0x43, 0x02, 0x56, 0x02, 0x65, 0x02, 0x72, 0x02, 540 | 0x7F, 0x02, 0x8E, 0x02, 0x99, 0x02, 0xA4, 0x02, 0xB3, 0x02, 0xC2, 0x02, 541 | 0xCB, 0x02, 0xD6, 0x02, 0xE3, 0x02, 0xEE, 0x02, 0x01, 0x03, 0x0E, 0x03, 542 | 0x1D, 0x03, 0x2A, 0x03, 0x39, 0x03, 0x48, 0x03, 0x55, 0x03, 0x62, 0x03, 543 | 0x71, 0x03, 0x7E, 0x03, 0x93, 0x03, 0xA0, 0x03, 0xAD, 0x03, 0xBA, 0x03, 544 | 0xC3, 0x03, 0xCE, 0x03, 0xD7, 0x03, 0xE6, 0x03, 0xF5, 0x03, 0xFE, 0x03, 545 | 0x0B, 0x04, 0x18, 0x04, 0x23, 0x04, 0x30, 0x04, 0x3D, 0x04, 0x46, 0x04, 546 | 0x53, 0x04, 0x60, 0x04, 0x65, 0x04, 0x6C, 0x04, 0x79, 0x04, 0x7E, 0x04, 547 | 0x93, 0x04, 0xA0, 0x04, 0xAD, 0x04, 0xBA, 0x04, 0xC7, 0x04, 0xD0, 0x04, 548 | 0xDB, 0x04, 0xE4, 0x04, 0xF1, 0x04, 0xFE, 0x04, 0x0F, 0x05, 0x1C, 0x05, 549 | 0x29, 0x05, 0x34, 0x05, 0x41, 0x05, 0x4A, 0x05, 0x57, 0x05, 0x68, 0x05, 550 | 551 | 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x7E, 0x01, 552 | 0x7E, 0x01, 0x05, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, 553 | 0x00, 0x08, 0xC0, 0x00, 0xD8, 0x03, 0xF8, 0x00, 0xDE, 0x00, 0xD8, 0x03, 554 | 0xF8, 0x00, 0xDE, 0x00, 0x18, 0x00, 0x06, 0x98, 0x00, 0x3C, 0x01, 0xE4, 555 | 0x07, 0x3F, 0x01, 0xE4, 0x01, 0xC8, 0x00, 0x0C, 0x1C, 0x00, 0x3E, 0x00, 556 | 0x22, 0x00, 0x3E, 0x00, 0x9C, 0x01, 0x60, 0x00, 0x18, 0x00, 0xE6, 0x00, 557 | 0xF0, 0x01, 0x10, 0x01, 0xF0, 0x01, 0xE0, 0x00, 0x08, 0xEC, 0x00, 0xFE, 558 | 0x01, 0x12, 0x01, 0x3E, 0x01, 0x6C, 0x01, 0xC0, 0x00, 0xB0, 0x01, 0x10, 559 | 0x01, 0x02, 0x07, 0x00, 0x07, 0x00, 0x04, 0xF8, 0x00, 0xFE, 0x03, 0x07, 560 | 0x07, 0x01, 0x04, 0x04, 0x01, 0x04, 0x07, 0x07, 0xFE, 0x03, 0xF8, 0x00, 561 | 0x06, 0x0A, 0x00, 0x04, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0x04, 0x00, 0x0A, 562 | 0x00, 0x08, 0x00, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0xFC, 0x01, 563 | 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x02, 0x80, 0x07, 0x80, 0x03, 0x04, 564 | 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x20, 0x00, 0x02, 0x80, 0x01, 0x80, 565 | 0x01, 0x05, 0x00, 0x06, 0x80, 0x01, 0x70, 0x00, 0x0C, 0x00, 0x03, 0x00, 566 | 0x06, 0xFC, 0x00, 0xFE, 0x01, 0x02, 0x01, 0x02, 0x01, 0xFE, 0x01, 0xFC, 567 | 0x00, 0x06, 0x00, 0x00, 0x04, 0x01, 0xFE, 0x01, 0xFE, 0x01, 0x00, 0x01, 568 | 0x00, 0x00, 0x06, 0x84, 0x01, 0xC6, 0x01, 0x62, 0x01, 0x32, 0x01, 0x1E, 569 | 0x01, 0x0C, 0x01, 0x06, 0x84, 0x00, 0x86, 0x01, 0x12, 0x01, 0x12, 0x01, 570 | 0xFE, 0x01, 0xEC, 0x00, 0x06, 0x60, 0x00, 0x50, 0x00, 0x48, 0x00, 0xFC, 571 | 0x01, 0xFE, 0x01, 0x40, 0x00, 0x06, 0x80, 0x00, 0x9E, 0x01, 0x1E, 0x01, 572 | 0x12, 0x01, 0xF2, 0x01, 0xE2, 0x00, 0x06, 0xFC, 0x00, 0xFE, 0x01, 0x12, 573 | 0x01, 0x12, 0x01, 0xF2, 0x01, 0xE0, 0x00, 0x06, 0x02, 0x00, 0x02, 0x00, 574 | 0xC2, 0x01, 0xFA, 0x01, 0x3E, 0x00, 0x06, 0x00, 0x06, 0xEC, 0x00, 0xFE, 575 | 0x01, 0x12, 0x01, 0x12, 0x01, 0xFE, 0x01, 0xEC, 0x00, 0x06, 0x1C, 0x00, 576 | 0x3E, 0x01, 0x22, 0x01, 0x22, 0x01, 0xFE, 0x01, 0xFC, 0x00, 0x02, 0x98, 577 | 0x01, 0x98, 0x01, 0x02, 0x98, 0x07, 0x98, 0x03, 0x08, 0x00, 0x00, 0x20, 578 | 0x00, 0x50, 0x00, 0x50, 0x00, 0x88, 0x00, 0x88, 0x00, 0x04, 0x01, 0x04, 579 | 0x01, 0x08, 0x00, 0x00, 0x48, 0x00, 0x48, 0x00, 0x48, 0x00, 0x48, 0x00, 580 | 0x48, 0x00, 0x48, 0x00, 0x48, 0x00, 0x08, 0x00, 0x00, 0x04, 0x01, 0x04, 581 | 0x01, 0x88, 0x00, 0x88, 0x00, 0x50, 0x00, 0x50, 0x00, 0x20, 0x00, 0x05, 582 | 0x04, 0x00, 0x62, 0x01, 0x72, 0x01, 0x1E, 0x00, 0x0C, 0x00, 0x09, 0xF8, 583 | 0x00, 0x04, 0x01, 0x72, 0x02, 0xFA, 0x02, 0x8A, 0x02, 0x7A, 0x02, 0xFA, 584 | 0x02, 0x84, 0x00, 0x78, 0x00, 0x07, 0xC0, 0x01, 0xF8, 0x01, 0x7E, 0x00, 585 | 0x46, 0x00, 0x7E, 0x00, 0xF8, 0x01, 0xC0, 0x01, 0x06, 0xFE, 0x01, 0xFE, 586 | 0x01, 0x12, 0x01, 0x12, 0x01, 0xFE, 0x01, 0xEC, 0x00, 0x06, 0xFC, 0x00, 587 | 0xFE, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x07, 0xFE, 588 | 0x01, 0xFE, 0x01, 0x02, 0x01, 0x02, 0x01, 0x86, 0x01, 0xFC, 0x00, 0x78, 589 | 0x00, 0x05, 0xFE, 0x01, 0xFE, 0x01, 0x12, 0x01, 0x12, 0x01, 0x12, 0x01, 590 | 0x05, 0xFE, 0x01, 0xFE, 0x01, 0x12, 0x00, 0x12, 0x00, 0x12, 0x00, 0x07, 591 | 0xFC, 0x00, 0xFE, 0x01, 0x02, 0x01, 0x02, 0x01, 0x22, 0x01, 0xE2, 0x01, 592 | 0xE2, 0x01, 0x07, 0xFE, 0x01, 0xFE, 0x01, 0x10, 0x00, 0x10, 0x00, 0x10, 593 | 0x00, 0xFE, 0x01, 0xFE, 0x01, 0x04, 0x02, 0x01, 0xFE, 0x01, 0xFE, 0x01, 594 | 0x02, 0x01, 0x05, 0x00, 0x01, 0x02, 0x01, 0x02, 0x01, 0xFE, 0x01, 0xFE, 595 | 0x00, 0x06, 0xFE, 0x01, 0xFE, 0x01, 0x78, 0x00, 0xCC, 0x00, 0x86, 0x01, 596 | 0x02, 0x01, 0x05, 0xFE, 0x01, 0xFE, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 597 | 0x01, 0x09, 0xFE, 0x01, 0x0E, 0x00, 0x1C, 0x00, 0x38, 0x00, 0x30, 0x00, 598 | 0x18, 0x00, 0x0C, 0x00, 0xFE, 0x01, 0xFE, 0x01, 0x06, 0xFE, 0x01, 0x0E, 599 | 0x00, 0x1C, 0x00, 0x38, 0x00, 0x70, 0x00, 0xFE, 0x01, 0x07, 0xFC, 0x00, 600 | 0xFE, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0xFE, 0x01, 0xFC, 0x00, 601 | 0x06, 0xFE, 0x01, 0xFE, 0x01, 0x22, 0x00, 0x22, 0x00, 0x3E, 0x00, 0x1C, 602 | 0x00, 0x07, 0xFC, 0x00, 0xFE, 0x01, 0x02, 0x01, 0x02, 0x03, 0x02, 0x07, 603 | 0xFE, 0x05, 0xFC, 0x04, 0x07, 0xFE, 0x01, 0xFE, 0x01, 0x22, 0x00, 0x62, 604 | 0x00, 0xFE, 0x00, 0x9C, 0x01, 0x00, 0x01, 0x06, 0x1C, 0x01, 0x3E, 0x01, 605 | 0x32, 0x01, 0x32, 0x01, 0xF2, 0x01, 0xE2, 0x00, 0x06, 0x02, 0x00, 0x02, 606 | 0x00, 0xFE, 0x01, 0xFE, 0x01, 0x02, 0x00, 0x02, 0x00, 0x07, 0xFE, 0x00, 607 | 0xFE, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0xFE, 0x01, 0xFE, 0x00, 608 | 0x06, 0x0E, 0x00, 0x7E, 0x00, 0xF0, 0x01, 0xF0, 0x01, 0x7E, 0x00, 0x0E, 609 | 0x00, 0x0A, 0x0E, 0x00, 0x7E, 0x00, 0xF0, 0x01, 0xE0, 0x01, 0x3E, 0x00, 610 | 0x3E, 0x00, 0xE0, 0x01, 0xF0, 0x01, 0x7E, 0x00, 0x0E, 0x00, 0x06, 0x86, 611 | 0x01, 0xCE, 0x01, 0x78, 0x00, 0x78, 0x00, 0xCE, 0x01, 0x86, 0x01, 0x06, 612 | 0x06, 0x00, 0x1E, 0x00, 0xF8, 0x01, 0xF8, 0x01, 0x1E, 0x00, 0x06, 0x00, 613 | 0x06, 0xC2, 0x01, 0xE2, 0x01, 0x72, 0x01, 0x3A, 0x01, 0x1E, 0x01, 0x0E, 614 | 0x01, 0x04, 0xFF, 0x07, 0xFF, 0x07, 0x01, 0x04, 0x01, 0x04, 0x05, 0x03, 615 | 0x00, 0x0C, 0x00, 0x70, 0x00, 0x80, 0x01, 0x00, 0x06, 0x04, 0x01, 0x04, 616 | 0x01, 0x04, 0xFF, 0x07, 0xFF, 0x07, 0x07, 0x10, 0x00, 0x08, 0x00, 0x04, 617 | 0x00, 0x02, 0x00, 0x04, 0x00, 0x08, 0x00, 0x10, 0x00, 0x07, 0x00, 0x04, 618 | 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 0x00, 0x04, 619 | 0x04, 0x00, 0x00, 0x01, 0x00, 0x03, 0x00, 0x02, 0x00, 0x06, 0xC0, 0x00, 620 | 0xE8, 0x01, 0x28, 0x01, 0x28, 0x01, 0xF8, 0x01, 0xF0, 0x01, 0x06, 0xFF, 621 | 0x01, 0xFF, 0x01, 0x08, 0x01, 0x08, 0x01, 0xF8, 0x01, 0xF0, 0x00, 0x05, 622 | 0xF0, 0x00, 0xF8, 0x01, 0x08, 0x01, 0x08, 0x01, 0x08, 0x01, 0x06, 0xF0, 623 | 0x00, 0xF8, 0x01, 0x08, 0x01, 0x08, 0x01, 0xFF, 0x01, 0xFF, 0x01, 0x06, 624 | 0xF0, 0x00, 0xF8, 0x01, 0x28, 0x01, 0x28, 0x01, 0x38, 0x01, 0x30, 0x01, 625 | 0x04, 0xFE, 0x01, 0xFF, 0x01, 0x09, 0x00, 0x01, 0x00, 0x06, 0xF0, 0x00, 626 | 0xF8, 0x05, 0x08, 0x05, 0x08, 0x05, 0xF8, 0x07, 0xF8, 0x03, 0x06, 0xFF, 627 | 0x01, 0xFF, 0x01, 0x08, 0x00, 0x08, 0x00, 0xF8, 0x01, 0xF0, 0x01, 0x02, 628 | 0xFA, 0x01, 0xFA, 0x01, 0x03, 0x08, 0x04, 0xFA, 0x07, 0xFA, 0x03, 0x06, 629 | 0xFF, 0x01, 0xFF, 0x01, 0x60, 0x00, 0xF0, 0x00, 0x98, 0x01, 0x08, 0x01, 630 | 0x02, 0xFF, 0x01, 0xFF, 0x01, 0x0A, 0xF8, 0x01, 0xF8, 0x01, 0x08, 0x00, 631 | 0x08, 0x00, 0xF8, 0x01, 0xF0, 0x01, 0x08, 0x00, 0x08, 0x00, 0xF8, 0x01, 632 | 0xF0, 0x01, 0x06, 0xF8, 0x01, 0xF8, 0x01, 0x08, 0x00, 0x08, 0x00, 0xF8, 633 | 0x01, 0xF0, 0x01, 0x06, 0xF0, 0x00, 0xF8, 0x01, 0x08, 0x01, 0x08, 0x01, 634 | 0xF8, 0x01, 0xF0, 0x00, 0x06, 0xF8, 0x07, 0xF8, 0x07, 0x08, 0x01, 0x08, 635 | 0x01, 0xF8, 0x01, 0xF0, 0x00, 0x06, 0xF0, 0x00, 0xF8, 0x01, 0x08, 0x01, 636 | 0x08, 0x01, 0xF8, 0x07, 0xF8, 0x07, 0x04, 0xF8, 0x01, 0xF8, 0x01, 0x10, 637 | 0x00, 0x18, 0x00, 0x05, 0x30, 0x01, 0x78, 0x01, 0x68, 0x01, 0xE8, 0x01, 638 | 0xC8, 0x00, 0x04, 0xFE, 0x00, 0xFE, 0x01, 0x08, 0x01, 0x08, 0x01, 0x06, 639 | 0xF8, 0x00, 0xF8, 0x01, 0x00, 0x01, 0x00, 0x01, 0xF8, 0x01, 0xF8, 0x01, 640 | 0x06, 0x18, 0x00, 0x78, 0x00, 0xE0, 0x01, 0xE0, 0x01, 0x78, 0x00, 0x18, 641 | 0x00, 0x08, 0x78, 0x00, 0xF8, 0x01, 0xC0, 0x01, 0x78, 0x00, 0x78, 0x00, 642 | 0xC0, 0x01, 0xF8, 0x01, 0x78, 0x00, 0x06, 0x98, 0x01, 0xF8, 0x01, 0x60, 643 | 0x00, 0x60, 0x00, 0xF8, 0x01, 0x98, 0x01, 0x06, 0x18, 0x00, 0x78, 0x06, 644 | 0xE0, 0x07, 0xE0, 0x01, 0x78, 0x00, 0x18, 0x00, 0x05, 0x88, 0x01, 0xC8, 645 | 0x01, 0x68, 0x01, 0x38, 0x01, 0x18, 0x01, 0x06, 0x20, 0x00, 0x20, 0x00, 646 | 0xFE, 0x03, 0xDF, 0x07, 0x01, 0x04, 0x01, 0x04, 0x04, 0x00, 0x00, 0x00, 647 | 0x00, 0xFF, 0x07, 0xFF, 0x07, 0x06, 0x01, 0x04, 0x01, 0x04, 0xDF, 0x07, 648 | 0xFE, 0x03, 0x20, 0x00, 0x20, 0x00, 0x08, 0x60, 0x00, 0x10, 0x00, 0x10, 649 | 0x00, 0x30, 0x00, 0x60, 0x00, 0x40, 0x00, 0x40, 0x00, 0x30, 0x00, 0x04, 650 | 0xFE, 0x01, 0xFE, 0x01, 0xFE, 0x01, 0xFE, 0x01 651 | }; 652 | 653 | 654 | 655 | 656 | #endif 657 | 658 | #if 1 // font_LargeNumbers 659 | // 660 | // Large numbers font, height = 16 (including the decenders) 661 | // Characters include: 0 - 9, -, +, ., %, :, Space, Comma 662 | // The font table contains 3 sections: Header, Table Of Character Indexes, Pixel data 663 | // 664 | // The Header contains two bytes: 665 | // Byte0 = Font height (including decenders) 666 | // Byte1 = Number of additional pixels that should be drawn right of char 667 | // Byte2 = Recommended line spacing 668 | // Byte3 = Height of decenders 669 | // Byte4 = Unused byte 670 | // 671 | // The Table Of Character Indexes, is a table of 2 byte words that index to the pixel data within this table 672 | // Word0 = Index into this table to the pixels for ASCII char 0x20 673 | // Word1 = Index into this table to the pixels for ASCII char 0x21 674 | // Word2 = Index into this table to the pixels for ASCII char 0x22 675 | // ... 676 | // Word95 = Index into this table to the pixels for ASCII char 0x7F 677 | // 678 | // The Pixel data table contains the bitmap for each character 679 | // Data is written in columns of pixels, each column is 16 bits (2 bytes) 680 | // Byte0 = width of the ASCII 0x20 character in pixels 681 | // Byte1 = pixel data for the 0x20 char's 1st top column, bit 0 is the top pixel, bit 7 is the 8th pixel down from the top 682 | // Byte2 = pixel data for the 0x20 char's 1st bottom column, bit 0 is the 9th pixel 683 | // Byte5 = pixel data for the 0x20 char's 2nd top column 684 | // Byte6 = pixel data for the 0x20 char's 2nd bottom column 685 | // ... = remaining pairs of bytes of the columns in the 0x20 char 686 | // ... = width of the 0x21 char in pixels 687 | // ... = pixel data for the 0x21 char 688 | // ... 689 | // 690 | const uint8_t font_LargeNumbers[] = { 691 | 0x10, 0x02, 0x15, 0x01, 0x00, 692 | 693 | 0xC5, 0x00, 0xC6, 0x00, 0xC7, 0x00, 0xC8, 0x00, 0xC9, 0x00, 0xCA, 0x00, 694 | 0xE9, 0x00, 0xEA, 0x00, 0xEB, 0x00, 0xEC, 0x00, 0xED, 0x00, 0xEE, 0x00, 695 | 0x05, 0x01, 0x0C, 0x01, 0x19, 0x01, 0x20, 0x01, 0x21, 0x01, 0x36, 0x01, 696 | 0x4B, 0x01, 0x60, 0x01, 0x75, 0x01, 0x8A, 0x01, 0x9F, 0x01, 0xB4, 0x01, 697 | 0xC9, 0x01, 0xDE, 0x01, 698 | 699 | 0xF3, 0x01, 0xFC, 0x01, 0xFD, 0x01, 0xFE, 0x01, 700 | 701 | 0xFF, 0x01, 0x00, 0x02, 0x01, 0x02, 0x02, 0x02, 0x03, 0x02, 0x04, 0x02, 702 | 0x05, 0x02, 0x06, 0x02, 0x07, 0x02, 0x08, 0x02, 0x09, 0x02, 0x0A, 0x02, 703 | 0x0B, 0x02, 0x0C, 0x02, 0x0D, 0x02, 0x0E, 0x02, 0x0F, 0x02, 0x10, 0x02, 704 | 0x11, 0x02, 0x12, 0x02, 0x13, 0x02, 0x14, 0x02, 0x15, 0x02, 0x16, 0x02, 705 | 0x17, 0x02, 0x18, 0x02, 0x19, 0x02, 0x1A, 0x02, 0x1B, 0x02, 0x1C, 0x02, 706 | 0x1D, 0x02, 0x1E, 0x02, 0x1F, 0x02, 0x20, 0x02, 0x21, 0x02, 0x22, 0x02, 707 | 0x23, 0x02, 0x24, 0x02, 0x25, 0x02, 0x26, 0x02, 0x27, 0x02, 0x28, 0x02, 708 | 0x29, 0x02, 0x2A, 0x02, 0x2B, 0x02, 0x2C, 0x02, 0x2D, 0x02, 0x2E, 0x02, 709 | 0x2F, 0x02, 0x30, 0x02, 0x31, 0x02, 0x32, 0x02, 0x33, 0x02, 0x34, 0x02, 710 | 0x35, 0x02, 0x36, 0x02, 0x37, 0x02, 0x38, 0x02, 0x39, 0x02, 0x3A, 0x02, 711 | 0x3B, 0x02, 0x3C, 0x02, 0x3D, 0x02, 0x3E, 0x02, 0x3F, 0x02, 0x40, 0x02, 712 | 713 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x7E, 0x00, 0xFF, 0x00, 0xC3, 0x00, 714 | 0xC3, 0x80, 0xFF, 0xE0, 0x7E, 0x7C, 0x00, 0x1F, 0xC0, 0x07, 0xF0, 0x00, 715 | 0x3E, 0x7E, 0x0F, 0xFF, 0x03, 0xC3, 0x00, 0xC3, 0x00, 0xFF, 0x00, 0x7E, 716 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 717 | 0xC0, 0x01, 0xFC, 0x1F, 0xFC, 0x1F, 0xFC, 0x1F, 0xC0, 0x01, 0xC0, 0x01, 718 | 0xC0, 0x01, 0xC0, 0x01, 0x03, 0x00, 0x70, 0x00, 0x70, 0x00, 0xF0, 0x06, 719 | 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 720 | 0x03, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x0A, 0xF8, 0x0F, 0xFE, 721 | 0x3F, 0xFE, 0x3F, 0x07, 0x70, 0x03, 0x60, 0x03, 0x60, 0x07, 0x70, 0xFE, 722 | 0x3F, 0xFE, 0x3F, 0xF8, 0x0F, 0x0A, 0x00, 0x00, 0x70, 0x00, 0x38, 0x00, 723 | 0x38, 0x00, 0x1C, 0x00, 0xFF, 0x7F, 0xFF, 0x7F, 0xFF, 0x7F, 0x00, 0x00, 724 | 0x00, 0x00, 0x0A, 0x0C, 0x60, 0x0E, 0x70, 0x0F, 0x7C, 0x07, 0x7E, 0x03, 725 | 0x6F, 0x83, 0x67, 0xC7, 0x63, 0xFF, 0x61, 0xFE, 0x60, 0x3C, 0x60, 0x0A, 726 | 0x0C, 0x18, 0x0E, 0x38, 0x0F, 0x78, 0xC3, 0x70, 0xC3, 0x60, 0xE3, 0x60, 727 | 0xFF, 0x71, 0xFE, 0x3F, 0x3C, 0x3F, 0x00, 0x0E, 0x0A, 0x00, 0x0F, 0xC0, 728 | 0x0D, 0xE0, 0x0C, 0x38, 0x0C, 0x1E, 0x0C, 0xFF, 0x7F, 0xFF, 0x7F, 0xFF, 729 | 0x7F, 0x00, 0x0C, 0x00, 0x0C, 0x0A, 0xC0, 0x18, 0xFC, 0x38, 0xFF, 0x78, 730 | 0x7F, 0x70, 0x63, 0x60, 0x63, 0x60, 0xE3, 0x70, 0xE3, 0x3F, 0xC3, 0x3F, 731 | 0x80, 0x0F, 0x0A, 0xF8, 0x0F, 0xFE, 0x3F, 0xFE, 0x3F, 0xC7, 0x70, 0x63, 732 | 0x60, 0x63, 0x60, 0xE7, 0x70, 0xEF, 0x3F, 0xC6, 0x3F, 0x04, 0x0F, 0x0A, 733 | 0x03, 0x00, 0x03, 0x00, 0x03, 0x78, 0x03, 0x7F, 0xC3, 0x7F, 0xF3, 0x07, 734 | 0xFB, 0x00, 0x3F, 0x00, 0x0F, 0x00, 0x07, 0x00, 0x0A, 0x1C, 0x1E, 0x3E, 735 | 0x3F, 0xFF, 0x7F, 0xE7, 0x71, 0xC3, 0x60, 0xC3, 0x60, 0xE7, 0x71, 0xFF, 736 | 0x7F, 0x3E, 0x3F, 0x1C, 0x1E, 0x0A, 0x78, 0x10, 0xFE, 0x39, 0xFE, 0x7B, 737 | 0x87, 0x73, 0x03, 0x63, 0x03, 0x63, 0x87, 0x71, 0xFE, 0x3F, 0xFE, 0x3F, 738 | 0xF8, 0x0F, 0x04, 0x00, 0x00, 0x38, 0x0E, 0x38, 0x0E, 0x38, 0x0E, 0x00, 739 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 740 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 741 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 742 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 743 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 744 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 745 | }; 746 | #endif 747 | 748 | -------------------------------------------------------------------------------- /STM32F4_Discovery_demo/CLCD_QVGA/fonts.h: -------------------------------------------------------------------------------- 1 | /* 2 | * fonts.h 3 | * 4 | * File containing prototype of the fonts for display 5 | * 6 | * 7 | */ 8 | 9 | #include 10 | 11 | #ifndef _FONT_ 12 | #define _FONT_ 13 | 14 | #define FONT_TABLE_HEIGHT_IDX 0 15 | #define FONT_TABLE_PAD_AFTER_CHAR_IDX 1 16 | #define FONT_TABLE_LINE_SPACING_IDX 2 17 | #define FONT_TABLE_DECENDERS_HEIGHT_IDX 3 18 | #define FONT_TABLE_UNUSED_IDX 4 19 | #define FONT_TABLE_CHAR_LOOKUP_IDX 5 20 | 21 | extern const uint8_t font_Small[]; 22 | extern const uint8_t font_Larger[]; 23 | //extern const uint8_t font_Medium[]; 24 | extern const uint8_t font_MediumBold[]; 25 | extern const uint8_t font_LargeNumbers[]; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /STM32F4_Discovery_demo/CLCD_QVGA/keys.c: -------------------------------------------------------------------------------- 1 | /* 2 | * keys.c 3 | * 4 | * Created on: Jun 15, 2010 5 | * Author: Kumar Abhishek 6 | */ 7 | 8 | #include "keys.h" 9 | 10 | uint8_t key; 11 | //extern volatile uint16_t keytime; 12 | 13 | //extern void lcd_blup(void); 14 | 15 | #define MAX7329_addr 0x70 16 | 17 | #ifdef IO_EXPANDERS 18 | 19 | uint8_t readKeyPort() 20 | { 21 | i2c_start(MAX7329_addr+1); 22 | uint8_t retval=i2c_readAck(); 23 | i2c_readNak(); 24 | return retval; 25 | } 26 | 27 | #else 28 | 29 | uint8_t readKeyPort() 30 | { 31 | // asm volatile ("nop"); 32 | // return (PINC&0xFC)>>2; 33 | return 0; 34 | } 35 | 36 | #endif 37 | 38 | #ifdef IO_EXPANDERS 39 | void getKeypress() 40 | { 41 | key=BTN_NONE; 42 | 43 | static uint8_t keys=0; 44 | uint8_t keys2=(~readKeyPort())&0x7F; 45 | 46 | if (keys) 47 | { 48 | if (keys2==0) { 49 | if (keytime > 8) { 50 | switch (keys) 51 | { 52 | case 0x01: key=BTN_MID_UP; 53 | break; 54 | 55 | case 0x02: key=BTN_MID_DOWN; 56 | break; 57 | 58 | case 0x04: key=BTN_MID_LEFT; 59 | break; 60 | 61 | case 0x08: key=BTN_MID_RIGHT; 62 | break; 63 | 64 | case 0x10: key=BTN_MID_SEL; 65 | break; 66 | 67 | case 0x20: key=BTN_RIGHT; 68 | break; 69 | } 70 | keys=0; 71 | } 72 | } 73 | } 74 | else 75 | { 76 | keytime=0; 77 | keys=(~readKeyPort())&0x7F; 78 | } 79 | if (key!=0) lcd_blup(); 80 | } 81 | #else 82 | void getKeypress() 83 | { 84 | // key=BTN_NONE; 85 | // 86 | // static uint8_t keyState=0; 87 | // static uint8_t keyThres=8; 88 | // 89 | // DDRC&=0x03; PORTC|=0xFC; 90 | // 91 | // asm volatile ("nop"); 92 | // asm volatile ("nop"); 93 | // 94 | // static uint8_t keys=0; 95 | // 96 | // uint8_t t=0; 97 | // 98 | // static uint8_t key_tmp=0; 99 | // 100 | // switch (keyState) 101 | // { 102 | // case 0: keys=((~PINC&0xFC)>>2); 103 | // if (keys) keyState=1; 104 | // keyThres=8; 105 | // keytime=0; 106 | // break; 107 | // 108 | // case 1: t=((~PINC&0xFC)>>2); 109 | // if (t==0 || keys!=t ) { keyState=0; break; } 110 | // if (keytime > keyThres && keytime < keyThres+3) { 111 | // switch (keys) 112 | // { 113 | // case 0x01: key_tmp=BTN_MID_UP; 114 | // break; 115 | // 116 | // case 0x02: key_tmp=BTN_MID_DOWN; 117 | // break; 118 | // 119 | // case 0x04: key_tmp=BTN_MID_LEFT; 120 | // break; 121 | // 122 | // case 0x08: key_tmp=BTN_MID_RIGHT; 123 | // break; 124 | // 125 | // case 0x10: key_tmp=BTN_MID_SEL; 126 | // break; 127 | // 128 | // case 0x20: key_tmp=BTN_RIGHT; 129 | // break; 130 | // } 131 | // key=key_tmp; 132 | // keyState=2; 133 | // } 134 | // break; 135 | // 136 | // case 2: t=((~PINC&0xFC)>>2); 137 | // if (t==0 || keys!=t ) { keyState=0; break; } 138 | // 139 | // if (key_tmp && key_tmp <= BTN_MID_RIGHT) 140 | // { 141 | // keytime=0; 142 | // keyThres=20; 143 | // keyState=1; 144 | // } 145 | // 146 | // if (key_tmp==BTN_RIGHT && keytime > 200) 147 | // { 148 | // key=BTN_HOLD_1; 149 | // keyState=3; 150 | // } 151 | // break; 152 | // 153 | // case 3: t=((~PINC&0xFC)>>2); 154 | // if (t==0 || keys!=t ) { keyState=0; break; } 155 | // } 156 | // 157 | // if (key!=0) lcd_blup(); 158 | key=0; 159 | } 160 | 161 | #endif 162 | -------------------------------------------------------------------------------- /STM32F4_Discovery_demo/CLCD_QVGA/keys.h: -------------------------------------------------------------------------------- 1 | /* 2 | * buttons.h 3 | * 4 | * Created on: Jun 15, 2010 5 | * Author: Kumar Abhishek 6 | */ 7 | 8 | #include 9 | 10 | #ifndef BUTTONS_H_ 11 | #define BUTTONS_H_ 12 | 13 | enum BUTTONS { 14 | BTN_NONE, 15 | BTN_MID_UP, 16 | BTN_MID_DOWN, 17 | BTN_MID_LEFT, 18 | BTN_MID_RIGHT, 19 | BTN_LEFT, 20 | BTN_RIGHT, 21 | BTN_MID_SEL, 22 | BTN_HOLD_1, 23 | BTN_HOLD_2 24 | }; 25 | 26 | extern uint8_t key; 27 | extern volatile uint16_t keytime; 28 | 29 | extern void getKeypress(void); 30 | extern uint8_t readKeyPort(void); 31 | 32 | 33 | #endif /* BUTTONS_H_ */ 34 | -------------------------------------------------------------------------------- /STM32F4_Discovery_demo/Makefile: -------------------------------------------------------------------------------- 1 | ############################################################################## 2 | # Build global options 3 | # NOTE: Can be overridden externally. 4 | # 5 | 6 | # Compiler options here. 7 | ifeq ($(USE_OPT),) 8 | USE_OPT = -O2 -g2 -fomit-frame-pointer -falign-functions=16 -std=gnu99 9 | endif 10 | 11 | # C specific options here (added to USE_OPT). 12 | ifeq ($(USE_COPT),) 13 | USE_COPT = 14 | endif 15 | 16 | # C++ specific options here (added to USE_OPT). 17 | ifeq ($(USE_CPPOPT),) 18 | USE_CPPOPT = -fno-rtti 19 | endif 20 | 21 | # Enable this if you want the linker to remove unused code and data 22 | ifeq ($(USE_LINK_GC),) 23 | USE_LINK_GC = yes 24 | endif 25 | 26 | # If enabled, this option allows to compile the application in THUMB mode. 27 | ifeq ($(USE_THUMB),) 28 | USE_THUMB = yes 29 | endif 30 | 31 | # Enable this if you want to see the full log while compiling. 32 | ifeq ($(USE_VERBOSE_COMPILE),) 33 | USE_VERBOSE_COMPILE = no 34 | endif 35 | 36 | # 37 | # Build global options 38 | ############################################################################## 39 | 40 | ############################################################################## 41 | # Architecture or project specific options 42 | # 43 | 44 | # Enables the use of FPU on Cortex-M4. 45 | # Enable this if you really want to use the STM FWLib. 46 | ifeq ($(USE_FPU),) 47 | USE_FPU = no 48 | endif 49 | 50 | # Enable this if you really want to use the STM FWLib. 51 | ifeq ($(USE_FWLIB),) 52 | USE_FWLIB = no 53 | endif 54 | 55 | # 56 | # Architecture or project specific options 57 | ############################################################################## 58 | 59 | ############################################################################## 60 | # Project, sources and paths 61 | # 62 | 63 | # Define project name here 64 | PROJECT = STM32F4_Discovery_demo 65 | 66 | # Imported source files and paths 67 | CHIBIOS = D:\ChibiOS_2.4.1 68 | include $(CHIBIOS)/boards/ST_STM32F4_DISCOVERY/board.mk 69 | include $(CHIBIOS)/os/hal/platforms/STM32F4xx/platform.mk 70 | include $(CHIBIOS)/os/hal/hal.mk 71 | include $(CHIBIOS)/os/ports/GCC/ARMCMx/STM32F4xx/port.mk 72 | include $(CHIBIOS)/os/kernel/kernel.mk 73 | include $(CHIBIOS)/ext/fatfs/fatfs.mk 74 | 75 | # Define linker script file here 76 | LDSCRIPT= $(PORTLD)/STM32F407xG.ld 77 | #LDSCRIPT= $(PORTLD)/STM32F407xG_CCM.ld 78 | 79 | # C sources that can be compiled in ARM or THUMB mode depending on the global 80 | # setting. 81 | CSRC = $(PORTSRC) \ 82 | $(KERNSRC) \ 83 | $(TESTSRC) \ 84 | $(HALSRC) \ 85 | $(PLATFORMSRC) \ 86 | $(BOARDSRC) \ 87 | $(FATFSSRC) \ 88 | $(CHIBIOS)/os/various/lis302dl.c \ 89 | $(CHIBIOS)/os/various/chprintf.c \ 90 | $(CHIBIOS)/os/various/syscalls.c \ 91 | main.c \ 92 | xprintf.c \ 93 | drawingApp.c \ 94 | codec_CS43L22.c \ 95 | wavePlayer.c \ 96 | CLCD_QVGA/CLCDQVGA_Driver.c \ 97 | CLCD_QVGA/fonts.c \ 98 | CLCD_QVGA/keys.c \ 99 | CLCD_QVGA/UI.c 100 | 101 | 102 | # C++ sources that can be compiled in ARM or THUMB mode depending on the global 103 | # setting. 104 | CPPSRC = 105 | 106 | # C sources to be compiled in ARM mode regardless of the global setting. 107 | # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler 108 | # option that results in lower performance and larger code size. 109 | ACSRC = 110 | 111 | # C++ sources to be compiled in ARM mode regardless of the global setting. 112 | # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler 113 | # option that results in lower performance and larger code size. 114 | ACPPSRC = 115 | 116 | # C sources to be compiled in THUMB mode regardless of the global setting. 117 | # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler 118 | # option that results in lower performance and larger code size. 119 | TCSRC = 120 | 121 | # C sources to be compiled in THUMB mode regardless of the global setting. 122 | # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler 123 | # option that results in lower performance and larger code size. 124 | TCPPSRC = 125 | 126 | # List ASM source files here 127 | ASMSRC = $(PORTASM) 128 | 129 | INCDIR = $(PORTINC) $(KERNINC) \ 130 | $(HALINC) $(PLATFORMINC) $(BOARDINC) \ 131 | $(FATFSINC) \ 132 | $(CHIBIOS)/os/various \ 133 | 134 | 135 | # 136 | # Project, sources and paths 137 | ############################################################################## 138 | 139 | ############################################################################## 140 | # Compiler settings 141 | # 142 | 143 | MCU = cortex-m4 144 | 145 | #TRGT = arm-elf- 146 | TRGT = arm-none-eabi- 147 | CC = $(TRGT)gcc 148 | CPPC = $(TRGT)g++ 149 | # Enable loading with g++ only if you need C++ runtime support. 150 | # NOTE: You can use C++ even without C++ support if you are careful. C++ 151 | # runtime support makes code size explode. 152 | LD = $(TRGT)gcc 153 | #LD = $(TRGT)g++ 154 | CP = $(TRGT)objcopy 155 | AS = $(TRGT)gcc -x assembler-with-cpp 156 | OD = $(TRGT)objdump 157 | HEX = $(CP) -O ihex 158 | BIN = $(CP) -O binary 159 | 160 | # ARM-specific options here 161 | AOPT = 162 | 163 | # THUMB-specific options here 164 | TOPT = -mthumb -DTHUMB 165 | 166 | # Define C warning options here 167 | CWARN = -Wall -Wextra -Wstrict-prototypes 168 | 169 | # Define C++ warning options here 170 | CPPWARN = -Wall -Wextra 171 | 172 | # 173 | # Compiler settings 174 | ############################################################################## 175 | 176 | ############################################################################## 177 | # Start of default section 178 | # 179 | 180 | # List all default C defines here, like -D_DEBUG=1 181 | DDEFS = 182 | 183 | # List all default ASM defines here, like -D_DEBUG=1 184 | DADEFS = 185 | 186 | # List all default directories to look for include files here 187 | DINCDIR = 188 | 189 | # List the default directory to look for the libraries here 190 | DLIBDIR = 191 | 192 | # List all default libraries here 193 | DLIBS = 194 | 195 | # 196 | # End of default section 197 | ############################################################################## 198 | 199 | ############################################################################## 200 | # Start of user section 201 | # 202 | 203 | # List all user C define here, like -D_DEBUG=1 204 | UDEFS = 205 | 206 | # Define ASM defines here 207 | UADEFS = 208 | 209 | # List all user directories here 210 | UINCDIR = ./CLCD_QVGA 211 | 212 | # List the user directory to look for the libraries here 213 | ULIBDIR = 214 | 215 | # List all user libraries here 216 | ULIBS = 217 | 218 | # 219 | # End of user defines 220 | ############################################################################## 221 | 222 | ifeq ($(USE_FPU),yes) 223 | USE_OPT += -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -fsingle-precision-constant 224 | DDEFS += -DCORTEX_USE_FPU=TRUE 225 | else 226 | DDEFS += -DCORTEX_USE_FPU=FALSE 227 | endif 228 | 229 | ifeq ($(USE_FWLIB),yes) 230 | include $(CHIBIOS)/ext/stm32lib/stm32lib.mk 231 | CSRC += $(STM32SRC) 232 | INCDIR += $(STM32INC) 233 | USE_OPT += -DUSE_STDPERIPH_DRIVER 234 | endif 235 | 236 | include $(CHIBIOS)/os/ports/GCC/ARMCMx/rules.mk 237 | -------------------------------------------------------------------------------- /STM32F4_Discovery_demo/README: -------------------------------------------------------------------------------- 1 | ***************************************************************************** 2 | ** STM32F4 Discovery GLCD UI WavePlayer Demo ** 3 | ***************************************************************************** 4 | 5 | The demo shows how to use a 2.4" LCD with the STM32F4-Discovery board. Also 6 | included is a small GUI Library I implemented using the touch panel. 7 | 8 | Demo Applications called by menus include: 9 | - 3 RGB Test Patterns 10 | - A simple 'doodle application' - that lets you draw on the screen 11 | - Wave Player 12 | 13 | The end result of my exercise will be to design a full-fledged mp3 audio player 14 | with all bells and whistles! 15 | 16 | NOTES: 17 | 18 | The LCD I use is this one: 19 | http://www.ebay.com/itm/2-4-TFT-LCD-Module-Display-Touch-Panel-PCB-adapter-/190477028273?pt=LH_DefaultDomain_0&hash=item2c5950cbb1 20 | 21 | It uses a 'new' S6D1121 controller, unlike the earlier ILI9325 variant. 22 | 23 | You will have to close jumper J3 (IM0) on the back of module PCB to enable 16-bit mode. 24 | 25 | The LCD is bitbanged and connected to the following pins: 26 | 27 | CS PD7 28 | RST PD10 29 | RS PD11 30 | WR PD8 31 | RD PD9 32 | 33 | DB[0:3] PD[0:3] 34 | DB[4:15] PE[4:15] 35 | 36 | This code runs on ChibiOS 2.4.1 37 | 38 | The UI & Text Rendering code of my library is based on the UI framework provided on this 39 | website: http://reifel.org/PICUserInterface/ . I wrote it two years ago for 40 | my AVR development platform. 41 | 42 | It also uses Chan's xprintf library. 43 | 44 | I wrote my own implementation for controlling the onboard CS43L22 DAC and sending data to it via DMA. 45 | 46 | The source files are self-explanatory. 47 | 48 | You will have to change the ChibiOS path in the makefile. 49 | 50 | For screenshots visit: 51 | 52 | http://imageshack.us/photo/my-images/844/dsc01768qf.jpg/ 53 | http://imageshack.us/photo/my-images/818/dsc01779t.jpg/ 54 | http://imageshack.us/photo/my-images/855/dsc01829w.jpg/ 55 | http://imageshack.us/photo/my-images/837/dsc01775tt.jpg/ 56 | http://imageshack.us/photo/my-images/7/image2mb.jpg/ 57 | http://imageshack.us/photo/my-images/7/image1als.jpg/ 58 | http://imageshack.us/photo/my-images/41/dsc01788ql.jpg/ 59 | http://imageshack.us/photo/my-images/259/dsc01786i.jpg/ 60 | http://imageshack.us/photo/my-images/198/dsc01784m.jpg/ 61 | 62 | Cheers! 63 | 64 | Abhishek 65 | -------------------------------------------------------------------------------- /STM32F4_Discovery_demo/chconf.h: -------------------------------------------------------------------------------- 1 | /* 2 | ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, 3 | 2011,2012 Giovanni Di Sirio. 4 | 5 | This file is part of ChibiOS/RT. 6 | 7 | ChibiOS/RT is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | ChibiOS/RT is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | 20 | --- 21 | 22 | A special exception to the GPL can be applied should you wish to distribute 23 | a combined work that includes ChibiOS/RT, without being obliged to provide 24 | the source code for any proprietary components. See the file exception.txt 25 | for full details of how and when the exception can be applied. 26 | */ 27 | 28 | /** 29 | * @file templates/chconf.h 30 | * @brief Configuration file template. 31 | * @details A copy of this file must be placed in each project directory, it 32 | * contains the application specific kernel settings. 33 | * 34 | * @addtogroup config 35 | * @details Kernel related settings and hooks. 36 | * @{ 37 | */ 38 | 39 | #ifndef _CHCONF_H_ 40 | #define _CHCONF_H_ 41 | 42 | /*===========================================================================*/ 43 | /** 44 | * @name Kernel parameters and options 45 | * @{ 46 | */ 47 | /*===========================================================================*/ 48 | 49 | /** 50 | * @brief System tick frequency. 51 | * @details Frequency of the system timer that drives the system ticks. This 52 | * setting also defines the system tick time unit. 53 | */ 54 | #if !defined(CH_FREQUENCY) || defined(__DOXYGEN__) 55 | #define CH_FREQUENCY 1000 56 | #endif 57 | 58 | /** 59 | * @brief Round robin interval. 60 | * @details This constant is the number of system ticks allowed for the 61 | * threads before preemption occurs. Setting this value to zero 62 | * disables the preemption for threads with equal priority and the 63 | * round robin becomes cooperative. Note that higher priority 64 | * threads can still preempt, the kernel is always preemptive. 65 | * 66 | * @note Disabling the round robin preemption makes the kernel more compact 67 | * and generally faster. 68 | */ 69 | #if !defined(CH_TIME_QUANTUM) || defined(__DOXYGEN__) 70 | #define CH_TIME_QUANTUM 20 71 | #endif 72 | 73 | /** 74 | * @brief Managed RAM size. 75 | * @details Size of the RAM area to be managed by the OS. If set to zero 76 | * then the whole available RAM is used. The core memory is made 77 | * available to the heap allocator and/or can be used directly through 78 | * the simplified core memory allocator. 79 | * 80 | * @note In order to let the OS manage the whole RAM the linker script must 81 | * provide the @p __heap_base__ and @p __heap_end__ symbols. 82 | * @note Requires @p CH_USE_MEMCORE. 83 | */ 84 | #if !defined(CH_MEMCORE_SIZE) || defined(__DOXYGEN__) 85 | #define CH_MEMCORE_SIZE 0 86 | #endif 87 | 88 | /** 89 | * @brief Idle thread automatic spawn suppression. 90 | * @details When this option is activated the function @p chSysInit() 91 | * does not spawn the idle thread automatically. The application has 92 | * then the responsibility to do one of the following: 93 | * - Spawn a custom idle thread at priority @p IDLEPRIO. 94 | * - Change the main() thread priority to @p IDLEPRIO then enter 95 | * an endless loop. In this scenario the @p main() thread acts as 96 | * the idle thread. 97 | * . 98 | * @note Unless an idle thread is spawned the @p main() thread must not 99 | * enter a sleep state. 100 | */ 101 | #if !defined(CH_NO_IDLE_THREAD) || defined(__DOXYGEN__) 102 | #define CH_NO_IDLE_THREAD FALSE 103 | #endif 104 | 105 | /** @} */ 106 | 107 | /*===========================================================================*/ 108 | /** 109 | * @name Performance options 110 | * @{ 111 | */ 112 | /*===========================================================================*/ 113 | 114 | /** 115 | * @brief OS optimization. 116 | * @details If enabled then time efficient rather than space efficient code 117 | * is used when two possible implementations exist. 118 | * 119 | * @note This is not related to the compiler optimization options. 120 | * @note The default is @p TRUE. 121 | */ 122 | #if !defined(CH_OPTIMIZE_SPEED) || defined(__DOXYGEN__) 123 | #define CH_OPTIMIZE_SPEED TRUE 124 | #endif 125 | 126 | /** @} */ 127 | 128 | /*===========================================================================*/ 129 | /** 130 | * @name Subsystem options 131 | * @{ 132 | */ 133 | /*===========================================================================*/ 134 | 135 | /** 136 | * @brief Threads registry APIs. 137 | * @details If enabled then the registry APIs are included in the kernel. 138 | * 139 | * @note The default is @p TRUE. 140 | */ 141 | #if !defined(CH_USE_REGISTRY) || defined(__DOXYGEN__) 142 | #define CH_USE_REGISTRY TRUE 143 | #endif 144 | 145 | /** 146 | * @brief Threads synchronization APIs. 147 | * @details If enabled then the @p chThdWait() function is included in 148 | * the kernel. 149 | * 150 | * @note The default is @p TRUE. 151 | */ 152 | #if !defined(CH_USE_WAITEXIT) || defined(__DOXYGEN__) 153 | #define CH_USE_WAITEXIT TRUE 154 | #endif 155 | 156 | /** 157 | * @brief Semaphores APIs. 158 | * @details If enabled then the Semaphores APIs are included in the kernel. 159 | * 160 | * @note The default is @p TRUE. 161 | */ 162 | #if !defined(CH_USE_SEMAPHORES) || defined(__DOXYGEN__) 163 | #define CH_USE_SEMAPHORES TRUE 164 | #endif 165 | 166 | /** 167 | * @brief Semaphores queuing mode. 168 | * @details If enabled then the threads are enqueued on semaphores by 169 | * priority rather than in FIFO order. 170 | * 171 | * @note The default is @p FALSE. Enable this if you have special requirements. 172 | * @note Requires @p CH_USE_SEMAPHORES. 173 | */ 174 | #if !defined(CH_USE_SEMAPHORES_PRIORITY) || defined(__DOXYGEN__) 175 | #define CH_USE_SEMAPHORES_PRIORITY FALSE 176 | #endif 177 | 178 | /** 179 | * @brief Atomic semaphore API. 180 | * @details If enabled then the semaphores the @p chSemSignalWait() API 181 | * is included in the kernel. 182 | * 183 | * @note The default is @p TRUE. 184 | * @note Requires @p CH_USE_SEMAPHORES. 185 | */ 186 | #if !defined(CH_USE_SEMSW) || defined(__DOXYGEN__) 187 | #define CH_USE_SEMSW TRUE 188 | #endif 189 | 190 | /** 191 | * @brief Mutexes APIs. 192 | * @details If enabled then the mutexes APIs are included in the kernel. 193 | * 194 | * @note The default is @p TRUE. 195 | */ 196 | #if !defined(CH_USE_MUTEXES) || defined(__DOXYGEN__) 197 | #define CH_USE_MUTEXES TRUE 198 | #endif 199 | 200 | /** 201 | * @brief Conditional Variables APIs. 202 | * @details If enabled then the conditional variables APIs are included 203 | * in the kernel. 204 | * 205 | * @note The default is @p TRUE. 206 | * @note Requires @p CH_USE_MUTEXES. 207 | */ 208 | #if !defined(CH_USE_CONDVARS) || defined(__DOXYGEN__) 209 | #define CH_USE_CONDVARS TRUE 210 | #endif 211 | 212 | /** 213 | * @brief Conditional Variables APIs with timeout. 214 | * @details If enabled then the conditional variables APIs with timeout 215 | * specification are included in the kernel. 216 | * 217 | * @note The default is @p TRUE. 218 | * @note Requires @p CH_USE_CONDVARS. 219 | */ 220 | #if !defined(CH_USE_CONDVARS_TIMEOUT) || defined(__DOXYGEN__) 221 | #define CH_USE_CONDVARS_TIMEOUT TRUE 222 | #endif 223 | 224 | /** 225 | * @brief Events Flags APIs. 226 | * @details If enabled then the event flags APIs are included in the kernel. 227 | * 228 | * @note The default is @p TRUE. 229 | */ 230 | #if !defined(CH_USE_EVENTS) || defined(__DOXYGEN__) 231 | #define CH_USE_EVENTS TRUE 232 | #endif 233 | 234 | /** 235 | * @brief Events Flags APIs with timeout. 236 | * @details If enabled then the events APIs with timeout specification 237 | * are included in the kernel. 238 | * 239 | * @note The default is @p TRUE. 240 | * @note Requires @p CH_USE_EVENTS. 241 | */ 242 | #if !defined(CH_USE_EVENTS_TIMEOUT) || defined(__DOXYGEN__) 243 | #define CH_USE_EVENTS_TIMEOUT TRUE 244 | #endif 245 | 246 | /** 247 | * @brief Synchronous Messages APIs. 248 | * @details If enabled then the synchronous messages APIs are included 249 | * in the kernel. 250 | * 251 | * @note The default is @p TRUE. 252 | */ 253 | #if !defined(CH_USE_MESSAGES) || defined(__DOXYGEN__) 254 | #define CH_USE_MESSAGES TRUE 255 | #endif 256 | 257 | /** 258 | * @brief Synchronous Messages queuing mode. 259 | * @details If enabled then messages are served by priority rather than in 260 | * FIFO order. 261 | * 262 | * @note The default is @p FALSE. Enable this if you have special requirements. 263 | * @note Requires @p CH_USE_MESSAGES. 264 | */ 265 | #if !defined(CH_USE_MESSAGES_PRIORITY) || defined(__DOXYGEN__) 266 | #define CH_USE_MESSAGES_PRIORITY FALSE 267 | #endif 268 | 269 | /** 270 | * @brief Mailboxes APIs. 271 | * @details If enabled then the asynchronous messages (mailboxes) APIs are 272 | * included in the kernel. 273 | * 274 | * @note The default is @p TRUE. 275 | * @note Requires @p CH_USE_SEMAPHORES. 276 | */ 277 | #if !defined(CH_USE_MAILBOXES) || defined(__DOXYGEN__) 278 | #define CH_USE_MAILBOXES TRUE 279 | #endif 280 | 281 | /** 282 | * @brief I/O Queues APIs. 283 | * @details If enabled then the I/O queues APIs are included in the kernel. 284 | * 285 | * @note The default is @p TRUE. 286 | */ 287 | #if !defined(CH_USE_QUEUES) || defined(__DOXYGEN__) 288 | #define CH_USE_QUEUES TRUE 289 | #endif 290 | 291 | /** 292 | * @brief Core Memory Manager APIs. 293 | * @details If enabled then the core memory manager APIs are included 294 | * in the kernel. 295 | * 296 | * @note The default is @p TRUE. 297 | */ 298 | #if !defined(CH_USE_MEMCORE) || defined(__DOXYGEN__) 299 | #define CH_USE_MEMCORE TRUE 300 | #endif 301 | 302 | /** 303 | * @brief Heap Allocator APIs. 304 | * @details If enabled then the memory heap allocator APIs are included 305 | * in the kernel. 306 | * 307 | * @note The default is @p TRUE. 308 | * @note Requires @p CH_USE_MEMCORE and either @p CH_USE_MUTEXES or 309 | * @p CH_USE_SEMAPHORES. 310 | * @note Mutexes are recommended. 311 | */ 312 | #if !defined(CH_USE_HEAP) || defined(__DOXYGEN__) 313 | #define CH_USE_HEAP TRUE 314 | #endif 315 | 316 | /** 317 | * @brief C-runtime allocator. 318 | * @details If enabled the the heap allocator APIs just wrap the C-runtime 319 | * @p malloc() and @p free() functions. 320 | * 321 | * @note The default is @p FALSE. 322 | * @note Requires @p CH_USE_HEAP. 323 | * @note The C-runtime may or may not require @p CH_USE_MEMCORE, see the 324 | * appropriate documentation. 325 | */ 326 | #if !defined(CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__) 327 | #define CH_USE_MALLOC_HEAP FALSE 328 | #endif 329 | 330 | /** 331 | * @brief Memory Pools Allocator APIs. 332 | * @details If enabled then the memory pools allocator APIs are included 333 | * in the kernel. 334 | * 335 | * @note The default is @p TRUE. 336 | */ 337 | #if !defined(CH_USE_MEMPOOLS) || defined(__DOXYGEN__) 338 | #define CH_USE_MEMPOOLS TRUE 339 | #endif 340 | 341 | /** 342 | * @brief Dynamic Threads APIs. 343 | * @details If enabled then the dynamic threads creation APIs are included 344 | * in the kernel. 345 | * 346 | * @note The default is @p TRUE. 347 | * @note Requires @p CH_USE_WAITEXIT. 348 | * @note Requires @p CH_USE_HEAP and/or @p CH_USE_MEMPOOLS. 349 | */ 350 | #if !defined(CH_USE_DYNAMIC) || defined(__DOXYGEN__) 351 | #define CH_USE_DYNAMIC TRUE 352 | #endif 353 | 354 | /** @} */ 355 | 356 | /*===========================================================================*/ 357 | /** 358 | * @name Debug options 359 | * @{ 360 | */ 361 | /*===========================================================================*/ 362 | 363 | /** 364 | * @brief Debug option, system state check. 365 | * @details If enabled the correct call protocol for system APIs is checked 366 | * at runtime. 367 | * 368 | * @note The default is @p FALSE. 369 | */ 370 | #if !defined(CH_DBG_SYSTEM_STATE_CHECK) || defined(__DOXYGEN__) 371 | #define CH_DBG_SYSTEM_STATE_CHECK FALSE 372 | #endif 373 | 374 | /** 375 | * @brief Debug option, parameters checks. 376 | * @details If enabled then the checks on the API functions input 377 | * parameters are activated. 378 | * 379 | * @note The default is @p FALSE. 380 | */ 381 | #if !defined(CH_DBG_ENABLE_CHECKS) || defined(__DOXYGEN__) 382 | #define CH_DBG_ENABLE_CHECKS FALSE 383 | #endif 384 | 385 | /** 386 | * @brief Debug option, consistency checks. 387 | * @details If enabled then all the assertions in the kernel code are 388 | * activated. This includes consistency checks inside the kernel, 389 | * runtime anomalies and port-defined checks. 390 | * 391 | * @note The default is @p FALSE. 392 | */ 393 | #if !defined(CH_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__) 394 | #define CH_DBG_ENABLE_ASSERTS FALSE 395 | #endif 396 | 397 | /** 398 | * @brief Debug option, trace buffer. 399 | * @details If enabled then the context switch circular trace buffer is 400 | * activated. 401 | * 402 | * @note The default is @p FALSE. 403 | */ 404 | #if !defined(CH_DBG_ENABLE_TRACE) || defined(__DOXYGEN__) 405 | #define CH_DBG_ENABLE_TRACE FALSE 406 | #endif 407 | 408 | /** 409 | * @brief Debug option, stack checks. 410 | * @details If enabled then a runtime stack check is performed. 411 | * 412 | * @note The default is @p FALSE. 413 | * @note The stack check is performed in a architecture/port dependent way. 414 | * It may not be implemented or some ports. 415 | * @note The default failure mode is to halt the system with the global 416 | * @p panic_msg variable set to @p NULL. 417 | */ 418 | #if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXYGEN__) 419 | #define CH_DBG_ENABLE_STACK_CHECK FALSE 420 | #endif 421 | 422 | /** 423 | * @brief Debug option, stacks initialization. 424 | * @details If enabled then the threads working area is filled with a byte 425 | * value when a thread is created. This can be useful for the 426 | * runtime measurement of the used stack. 427 | * 428 | * @note The default is @p FALSE. 429 | */ 430 | #if !defined(CH_DBG_FILL_THREADS) || defined(__DOXYGEN__) 431 | #define CH_DBG_FILL_THREADS FALSE 432 | #endif 433 | 434 | /** 435 | * @brief Debug option, threads profiling. 436 | * @details If enabled then a field is added to the @p Thread structure that 437 | * counts the system ticks occurred while executing the thread. 438 | * 439 | * @note The default is @p TRUE. 440 | * @note This debug option is defaulted to TRUE because it is required by 441 | * some test cases into the test suite. 442 | */ 443 | #if !defined(CH_DBG_THREADS_PROFILING) || defined(__DOXYGEN__) 444 | #define CH_DBG_THREADS_PROFILING TRUE 445 | #endif 446 | 447 | /** @} */ 448 | 449 | /*===========================================================================*/ 450 | /** 451 | * @name Kernel hooks 452 | * @{ 453 | */ 454 | /*===========================================================================*/ 455 | 456 | /** 457 | * @brief Threads descriptor structure extension. 458 | * @details User fields added to the end of the @p Thread structure. 459 | */ 460 | #if !defined(THREAD_EXT_FIELDS) || defined(__DOXYGEN__) 461 | #define THREAD_EXT_FIELDS \ 462 | /* Add threads custom fields here.*/ 463 | #endif 464 | 465 | /** 466 | * @brief Threads initialization hook. 467 | * @details User initialization code added to the @p chThdInit() API. 468 | * 469 | * @note It is invoked from within @p chThdInit() and implicitly from all 470 | * the threads creation APIs. 471 | */ 472 | #if !defined(THREAD_EXT_INIT_HOOK) || defined(__DOXYGEN__) 473 | #define THREAD_EXT_INIT_HOOK(tp) { \ 474 | /* Add threads initialization code here.*/ \ 475 | } 476 | #endif 477 | 478 | /** 479 | * @brief Threads finalization hook. 480 | * @details User finalization code added to the @p chThdExit() API. 481 | * 482 | * @note It is inserted into lock zone. 483 | * @note It is also invoked when the threads simply return in order to 484 | * terminate. 485 | */ 486 | #if !defined(THREAD_EXT_EXIT_HOOK) || defined(__DOXYGEN__) 487 | #define THREAD_EXT_EXIT_HOOK(tp) { \ 488 | /* Add threads finalization code here.*/ \ 489 | } 490 | #endif 491 | 492 | /** 493 | * @brief Context switch hook. 494 | * @details This hook is invoked just before switching between threads. 495 | */ 496 | #if !defined(THREAD_CONTEXT_SWITCH_HOOK) || defined(__DOXYGEN__) 497 | #define THREAD_CONTEXT_SWITCH_HOOK(ntp, otp) { \ 498 | /* System halt code here.*/ \ 499 | } 500 | #endif 501 | 502 | /** 503 | * @brief Idle Loop hook. 504 | * @details This hook is continuously invoked by the idle thread loop. 505 | */ 506 | #if !defined(IDLE_LOOP_HOOK) || defined(__DOXYGEN__) 507 | #define IDLE_LOOP_HOOK() { \ 508 | /* Idle loop code here.*/ \ 509 | } 510 | #endif 511 | 512 | /** 513 | * @brief System tick event hook. 514 | * @details This hook is invoked in the system tick handler immediately 515 | * after processing the virtual timers queue. 516 | */ 517 | #if !defined(SYSTEM_TICK_EVENT_HOOK) || defined(__DOXYGEN__) 518 | #define SYSTEM_TICK_EVENT_HOOK() { \ 519 | /* System tick event code here.*/ \ 520 | } 521 | #endif 522 | 523 | /** 524 | * @brief System halt hook. 525 | * @details This hook is invoked in case to a system halting error before 526 | * the system is halted. 527 | */ 528 | #if !defined(SYSTEM_HALT_HOOK) || defined(__DOXYGEN__) 529 | #define SYSTEM_HALT_HOOK() { \ 530 | /* System halt code here.*/ \ 531 | } 532 | #endif 533 | 534 | /** @} */ 535 | 536 | /*===========================================================================*/ 537 | /* Port-specific settings (override port settings defaulted in chcore.h). */ 538 | /*===========================================================================*/ 539 | 540 | #define CORTEX_USE_FPU FALSE 541 | 542 | #endif /* _CHCONF_H_ */ 543 | 544 | /** @} */ 545 | -------------------------------------------------------------------------------- /STM32F4_Discovery_demo/codec.h: -------------------------------------------------------------------------------- 1 | /* 2 | * codec.h 3 | * 4 | * Created on: Jun 7, 2012 5 | * Author: Kumar Abhishek 6 | */ 7 | 8 | #ifndef CODEC_H_ 9 | #define CODEC_H_ 10 | 11 | #include "ch.h" 12 | #include "hal.h" 13 | 14 | #define CODEC_I2C I2CD1 15 | #define CODEC_I2S_ENABLE rccEnableSPI3(FALSE) 16 | #define CODEC_I2S_DISABLE rccDisableSPI3(FALSE) 17 | #define CODEC_I2S SPI3 18 | 19 | enum CODEC_AUDIOSRC { 20 | CODEC_AUDIOSRC_DIGITAL, 21 | CODEC_AUDIOSRC_MIC, 22 | CODEC_AUDIOSRC_FMRADIO 23 | }; 24 | 25 | 26 | #define CS43L22_ADDR (0x94 >> 1) 27 | 28 | extern void codec_hw_init(void); 29 | 30 | extern void codec_hw_reset(void); 31 | 32 | extern void codec_writeReg(uint8_t addr, uint8_t data); 33 | 34 | extern uint8_t codec_readReg(uint8_t addr); 35 | 36 | extern void codec_volCtl(uint8_t vol); 37 | 38 | extern void codec_pwrCtl(uint8_t pwr); 39 | 40 | extern void codec_muteCtl(uint8_t mute); 41 | 42 | extern void codec_sendBeep(void); 43 | 44 | extern void codec_selectAudioSource(uint8_t src); 45 | 46 | extern void codec_i2s_init(uint16_t sampleRate, uint8_t nBits); 47 | 48 | extern void codec_audio_send(void* txbuf, size_t n); 49 | 50 | extern void codec_pauseResumePlayback(uint8_t pause); 51 | 52 | #endif /* CODEC_H_ */ 53 | -------------------------------------------------------------------------------- /STM32F4_Discovery_demo/codec_CS43L22.c: -------------------------------------------------------------------------------- 1 | /* 2 | * codec_CS43L22.c 3 | * 4 | * Created on: Jun 7, 2012 5 | * Author: Kumar Abhishek 6 | */ 7 | 8 | #include "codec.h" 9 | 10 | #include "chprintf.h" 11 | 12 | const stm32_dma_stream_t* i2sdma; 13 | static uint32_t i2stxdmamode=0; 14 | 15 | extern Thread* playerThread; 16 | 17 | static const I2CConfig i2cfg = { 18 | OPMODE_I2C, 19 | 100000, 20 | FAST_DUTY_CYCLE_16_9, 21 | }; 22 | 23 | #define I2S3_TX_DMA_CHANNEL \ 24 | STM32_DMA_GETCHANNEL(STM32_SPI_SPI3_TX_DMA_STREAM, \ 25 | STM32_SPI3_TX_DMA_CHN) 26 | 27 | static uint8_t txbuf[2]={0}, rxbuf[2]={0}; 28 | 29 | void codec_hw_init(void) 30 | { 31 | // Fortunately, all pins have already been initialized in board.h 32 | 33 | // Start the i2c driver 34 | i2cStart(&CODEC_I2C, &i2cfg); 35 | 36 | // Reset the codec 37 | codec_hw_reset(); 38 | 39 | // Write init sequence 40 | // Keep codec powered down initially 41 | codec_pwrCtl(0); 42 | 43 | codec_muteCtl(0); 44 | 45 | // Auto Detect Clock, MCLK/2 46 | codec_writeReg(0x05, 0x81); 47 | 48 | // Slave Mode, I2S Data Format 49 | codec_writeReg(0x06, 0x04); 50 | 51 | codec_pwrCtl(1); 52 | 53 | codec_volCtl(200); 54 | 55 | // Adjust PCM Volume 56 | codec_writeReg(0x1A, 0x0A); 57 | codec_writeReg(0x1B, 0x0A); 58 | 59 | // Disable the analog soft ramp 60 | codec_writeReg(0x0A, 0x00); 61 | 62 | // Disable the digital soft ramp 63 | codec_writeReg(0x0E, 0x04); 64 | 65 | // Disable the limiter attack level 66 | codec_writeReg(0x27, 0x00); 67 | 68 | codec_writeReg(0x1C, 0x80); 69 | } 70 | 71 | void codec_hw_reset(void) 72 | { 73 | palClearPad(GPIOD, GPIOD_RESET); 74 | halPolledDelay(MS2RTT(10)); 75 | palSetPad(GPIOD, GPIOD_RESET); 76 | } 77 | 78 | static void dma_i2s_interrupt(void* dat, uint32_t flags) 79 | { 80 | dmaStreamDisable(i2sdma); 81 | 82 | chSysLockFromIsr(); 83 | chEvtSignalFlagsI(playerThread, 1); 84 | chSysUnlockFromIsr(); 85 | } 86 | 87 | static void codec_dma_init(void) 88 | { 89 | i2sdma=STM32_DMA_STREAM(STM32_SPI_SPI3_TX_DMA_STREAM); 90 | 91 | i2stxdmamode = STM32_DMA_CR_CHSEL(I2S3_TX_DMA_CHANNEL) | 92 | STM32_DMA_CR_PL(STM32_SPI_SPI3_DMA_PRIORITY) | 93 | STM32_DMA_CR_DIR_M2P | 94 | STM32_DMA_CR_DMEIE | 95 | STM32_DMA_CR_TEIE | 96 | STM32_DMA_CR_TCIE | 97 | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD; 98 | 99 | bool_t b = dmaStreamAllocate(i2sdma, 100 | STM32_SPI_SPI3_IRQ_PRIORITY, 101 | (stm32_dmaisr_t)dma_i2s_interrupt, 102 | (void *)&SPID3); 103 | 104 | if (!b) 105 | chprintf((BaseChannel*)&SD2, "DMA Allocated Successfully to I2S3\r\n"); 106 | 107 | dmaStreamSetPeripheral(i2sdma, &(SPI3->DR)); 108 | } 109 | 110 | void codec_i2s_init(uint16_t sampleRate, uint8_t nBits) 111 | { 112 | uint16_t prescale; 113 | uint32_t pllfreq=STM32_PLLI2SVCO / STM32_PLLI2SR_VALUE; 114 | 115 | if (nBits!=16) 116 | return; 117 | 118 | // SPI3 in I2S Mode, Master 119 | CODEC_I2S_ENABLE; 120 | 121 | CODEC_I2S->I2SCFGR=SPI_I2SCFGR_I2SMOD | SPI_I2SCFGR_I2SCFG_1; 122 | 123 | // Master clock mode Fs * 256 124 | prescale=(pllfreq*10)/(256*sampleRate) + 5; 125 | prescale/=10; 126 | 127 | chprintf((BaseChannel*)&SD2, "Prescale value:%d\r\n", prescale); 128 | 129 | if (prescale > 0xFF || prescale < 2) prescale=2; 130 | 131 | if (prescale & 0x01) 132 | CODEC_I2S->I2SPR=SPI_I2SPR_MCKOE | SPI_I2SPR_ODD | (prescale>>1); 133 | else 134 | CODEC_I2S->I2SPR=SPI_I2SPR_MCKOE | (prescale>>1); 135 | 136 | codec_dma_init(); 137 | 138 | // Enable I2S DMA Request 139 | CODEC_I2S->CR2 = SPI_CR2_TXDMAEN; 140 | 141 | // Now Enable I2S 142 | CODEC_I2S->I2SCFGR|=SPI_I2SCFGR_I2SE; 143 | } 144 | 145 | void codec_writeReg(uint8_t addr, uint8_t data) 146 | { 147 | txbuf[0]=addr; 148 | txbuf[1]=data; 149 | i2cMasterTransmitTimeout(&I2CD1, CS43L22_ADDR, txbuf, 2, NULL, 0, MS2ST(4)); 150 | } 151 | 152 | uint8_t codec_readReg(uint8_t addr) 153 | { 154 | txbuf[0]=addr; 155 | i2cMasterTransmitTimeout(&I2CD1, CS43L22_ADDR, txbuf, 1, rxbuf, 2, MS2ST(4)); 156 | return rxbuf[0]; 157 | } 158 | 159 | void codec_pwrCtl(uint8_t pwr) 160 | { 161 | if (pwr) 162 | codec_writeReg(0x02, 0x9E); 163 | else 164 | codec_writeReg(0x02, 0x01); 165 | } 166 | 167 | void codec_muteCtl(uint8_t mute) 168 | { 169 | if (mute) 170 | codec_writeReg(0x04, 0xFF); 171 | else 172 | codec_writeReg(0x04, 0xAF); 173 | } 174 | 175 | void codec_volCtl(uint8_t vol) 176 | { 177 | if (vol > 0xE6) 178 | { 179 | codec_writeReg(0x20, vol-0xE7); 180 | codec_writeReg(0x21, vol-0xE7); 181 | } 182 | else 183 | { 184 | codec_writeReg(0x20, vol+0x19); 185 | codec_writeReg(0x21, vol+0x19); 186 | } 187 | } 188 | 189 | void codec_selectAudioSource(uint8_t src) 190 | { 191 | switch (src) { 192 | case CODEC_AUDIOSRC_DIGITAL: 193 | // Disable all pass through channels 194 | codec_writeReg(0x0E, 0x04); 195 | break; 196 | 197 | case CODEC_AUDIOSRC_MIC: 198 | // Select AIN4A/B for pass through 199 | codec_writeReg(0x08, 0x08); 200 | codec_writeReg(0x09, 0x08); 201 | codec_writeReg(0x0E, 0xC4); 202 | break; 203 | 204 | case CODEC_AUDIOSRC_FMRADIO: 205 | // Select AIN2A/B for pass through 206 | codec_writeReg(0x08, 0x02); 207 | codec_writeReg(0x09, 0x02); 208 | codec_writeReg(0x0E, 0xC4); 209 | break; 210 | } 211 | } 212 | 213 | // Send data to the codec via I2S 214 | void codec_audio_send(void* txbuf, size_t n) 215 | { 216 | dmaStreamSetMemory0(i2sdma, txbuf); 217 | dmaStreamSetTransactionSize(i2sdma, n); 218 | dmaStreamSetMode(i2sdma, i2stxdmamode | STM32_DMA_CR_MINC); 219 | dmaStreamClearInterrupt(i2sdma); 220 | dmaStreamEnable(i2sdma); 221 | } 222 | 223 | void codec_pauseResumePlayback(uint8_t pause) 224 | { 225 | if (pause) { 226 | codec_muteCtl(1); 227 | codec_pwrCtl(0); 228 | 229 | CODEC_I2S->CR2=0; 230 | 231 | } else { 232 | codec_pwrCtl(1); 233 | 234 | CODEC_I2S->CR2=SPI_CR2_TXDMAEN; 235 | 236 | codec_muteCtl(0); 237 | } 238 | } 239 | 240 | void codec_sendBeep(void) 241 | { 242 | codec_writeReg(0x1E, 0x00); 243 | codec_writeReg(0x1E, 0x40); 244 | } 245 | -------------------------------------------------------------------------------- /STM32F4_Discovery_demo/drawingApp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * drawingApp.c 3 | * 4 | * Created on: Jun 5, 2012 5 | * Author: Kumar Abhishek 6 | */ 7 | 8 | #include "drawingApp.h" 9 | 10 | static WORKING_AREA(waThread2, 1024); 11 | static Thread* drawThd; 12 | 13 | static msg_t DrawingThread(void *arg); 14 | 15 | // Blocking method 16 | // Will return after thread exits 17 | void startDrawingThread(void) 18 | { 19 | ui_clearUserArea(); 20 | 21 | ui_drawTitleBar("Drawing Application"); 22 | ui_drawBottomBar(NULL, "Touch To Exit", NULL); 23 | 24 | drawThd=chThdCreateStatic(waThread2, sizeof(waThread2), NORMALPRIO-1, DrawingThread, NULL); 25 | chThdWait(drawThd); 26 | 27 | lcd_cls(); 28 | ui_displayPreviousMenu(); 29 | } 30 | 31 | // Drawing Thread 32 | 33 | #define NUM_CONVERSIONS 4 34 | 35 | static msg_t DrawingThread(void *arg) 36 | { 37 | (void)arg; 38 | chRegSetThreadName("paint"); 39 | 40 | int state=0, i, bg, fg, dx=0, dy=0; 41 | 42 | bg=7; 43 | fg=0; 44 | 45 | for (i=0;i<7;i++) 46 | { 47 | lcd_filledrect(colors[i], 3+i*22, UI_TBARHEIGHT+3, 20, 20); 48 | } 49 | 50 | i=0; 51 | while (TRUE) 52 | { 53 | if (state) 54 | { 55 | if (!tsc_isPenDown()) 56 | { 57 | state=0; 58 | // Allow time to settle 59 | chThdSleepMilliseconds(60); 60 | } 61 | else if (lcd_getpoint()) 62 | { 63 | // Keep the lcd backlight on 64 | lcd_blup(); 65 | 66 | // Check if color toolbar is hit 67 | if (py > UI_TBARHEIGHT+2 && py < 50) 68 | { 69 | int t=(px-4)/22; 70 | if (t<7) 71 | { 72 | lcd_filledrect(colors[fg], 10+fg*22, UI_TBARHEIGHT+10, 4, 4); 73 | fg=t; 74 | lcd_filledrect(fg==0 ? WHITE : BLACK, 10+fg*22, UI_TBARHEIGHT+10, 4, 4); 75 | } 76 | 77 | // Fill background with selected color 78 | else if (t==7) 79 | { 80 | bg=fg; 81 | lcd_filledrect(colors[bg], 0, UI_TBARHEIGHT+3+20+1, 240, 320-(UI_TBARHEIGHT+3+20+3+UI_BBARHEIGHT)); 82 | } 83 | } 84 | 85 | // If within boundary, plot the point 86 | if (py > 50 && py < 285 && px > 2 && px < 315) { 87 | if (i==NUM_CONVERSIONS) { 88 | lcd_filledrect(colors[fg], dx/NUM_CONVERSIONS, dy/NUM_CONVERSIONS, 2, 2); 89 | i=dx=dy=0; 90 | } else { 91 | dx+=px; 92 | dy+=py; 93 | i++; 94 | } 95 | } 96 | 97 | // If exit button clicked 98 | if (py > 290 && py < 320 && px > 200 && px < 240) 99 | return 0; 100 | } 101 | } 102 | else if (tsc_isPenDown()) 103 | { 104 | state=1; 105 | // Allow time to settle 106 | chThdSleepMilliseconds(60); 107 | } 108 | } 109 | 110 | return 0; 111 | } 112 | -------------------------------------------------------------------------------- /STM32F4_Discovery_demo/drawingApp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * drawingApp.h 3 | * 4 | * Created on: Jun 5, 2012 5 | * Author: Kumar Abhishek 6 | */ 7 | 8 | #ifndef DRAWINGAPP_H_ 9 | #define DRAWINGAPP_H_ 10 | 11 | #include "ch.h" 12 | #include "hal.h" 13 | 14 | #include "CLCDQVGA_Driver.h" 15 | 16 | #include "UI.h" 17 | #include "keys.h" 18 | #include "xprintf.h" 19 | 20 | extern void startDrawingThread(void); 21 | 22 | #endif /* DRAWINGAPP_H_ */ 23 | -------------------------------------------------------------------------------- /STM32F4_Discovery_demo/halconf.h: -------------------------------------------------------------------------------- 1 | /* 2 | ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, 3 | 2011,2012 Giovanni Di Sirio. 4 | 5 | This file is part of ChibiOS/RT. 6 | 7 | ChibiOS/RT is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | ChibiOS/RT is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | 20 | --- 21 | 22 | A special exception to the GPL can be applied should you wish to distribute 23 | a combined work that includes ChibiOS/RT, without being obliged to provide 24 | the source code for any proprietary components. See the file exception.txt 25 | for full details of how and when the exception can be applied. 26 | */ 27 | 28 | /** 29 | * @file templates/halconf.h 30 | * @brief HAL configuration header. 31 | * @details HAL configuration file, this file allows to enable or disable the 32 | * various device drivers from your application. You may also use 33 | * this file in order to override the device drivers default settings. 34 | * 35 | * @addtogroup HAL_CONF 36 | * @{ 37 | */ 38 | 39 | #ifndef _HALCONF_H_ 40 | #define _HALCONF_H_ 41 | 42 | #include "mcuconf.h" 43 | 44 | /** 45 | * @brief Enables the TM subsystem. 46 | */ 47 | #if !defined(HAL_USE_TM) || defined(__DOXYGEN__) 48 | #define HAL_USE_TM FALSE 49 | #endif 50 | 51 | /** 52 | * @brief Enables the PAL subsystem. 53 | */ 54 | #if !defined(HAL_USE_PAL) || defined(__DOXYGEN__) 55 | #define HAL_USE_PAL TRUE 56 | #endif 57 | 58 | /** 59 | * @brief Enables the ADC subsystem. 60 | */ 61 | #if !defined(HAL_USE_ADC) || defined(__DOXYGEN__) 62 | #define HAL_USE_ADC TRUE 63 | #endif 64 | 65 | /** 66 | * @brief Enables the CAN subsystem. 67 | */ 68 | #if !defined(HAL_USE_CAN) || defined(__DOXYGEN__) 69 | #define HAL_USE_CAN FALSE 70 | #endif 71 | 72 | /** 73 | * @brief Enables the EXT subsystem. 74 | */ 75 | #if !defined(HAL_USE_EXT) || defined(__DOXYGEN__) 76 | #define HAL_USE_EXT FALSE 77 | #endif 78 | 79 | /** 80 | * @brief Enables the GPT subsystem. 81 | */ 82 | #if !defined(HAL_USE_GPT) || defined(__DOXYGEN__) 83 | #define HAL_USE_GPT FALSE 84 | #endif 85 | 86 | /** 87 | * @brief Enables the I2C subsystem. 88 | */ 89 | #if !defined(HAL_USE_I2C) || defined(__DOXYGEN__) 90 | #define HAL_USE_I2C TRUE 91 | #endif 92 | 93 | /** 94 | * @brief Enables the ICU subsystem. 95 | */ 96 | #if !defined(HAL_USE_ICU) || defined(__DOXYGEN__) 97 | #define HAL_USE_ICU FALSE 98 | #endif 99 | 100 | /** 101 | * @brief Enables the MAC subsystem. 102 | */ 103 | #if !defined(HAL_USE_MAC) || defined(__DOXYGEN__) 104 | #define HAL_USE_MAC FALSE 105 | #endif 106 | 107 | /** 108 | * @brief Enables the MMC_SPI subsystem. 109 | */ 110 | #if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__) 111 | #define HAL_USE_MMC_SPI TRUE 112 | #endif 113 | 114 | /** 115 | * @brief Enables the PWM subsystem. 116 | */ 117 | #if !defined(HAL_USE_PWM) || defined(__DOXYGEN__) 118 | #define HAL_USE_PWM TRUE 119 | #endif 120 | 121 | /** 122 | * @brief Enables the RTC subsystem. 123 | */ 124 | #if !defined(HAL_USE_RTC) || defined(__DOXYGEN__) 125 | #define HAL_USE_RTC FALSE 126 | #endif 127 | 128 | /** 129 | * @brief Enables the SDC subsystem. 130 | */ 131 | #if !defined(HAL_USE_SDC) || defined(__DOXYGEN__) 132 | #define HAL_USE_SDC FALSE 133 | #endif 134 | 135 | /** 136 | * @brief Enables the SERIAL subsystem. 137 | */ 138 | #if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__) 139 | #define HAL_USE_SERIAL TRUE 140 | #endif 141 | 142 | /** 143 | * @brief Enables the SERIAL over USB subsystem. 144 | */ 145 | #if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__) 146 | #define HAL_USE_SERIAL_USB FALSE 147 | #endif 148 | 149 | /** 150 | * @brief Enables the SPI subsystem. 151 | */ 152 | #if !defined(HAL_USE_SPI) || defined(__DOXYGEN__) 153 | #define HAL_USE_SPI TRUE 154 | #endif 155 | 156 | /** 157 | * @brief Enables the UART subsystem. 158 | */ 159 | #if !defined(HAL_USE_UART) || defined(__DOXYGEN__) 160 | #define HAL_USE_UART FALSE 161 | #endif 162 | 163 | /** 164 | * @brief Enables the USB subsystem. 165 | */ 166 | #if !defined(HAL_USE_USB) || defined(__DOXYGEN__) 167 | #define HAL_USE_USB FALSE 168 | #endif 169 | 170 | /*===========================================================================*/ 171 | /* ADC driver related settings. */ 172 | /*===========================================================================*/ 173 | 174 | /** 175 | * @brief Enables synchronous APIs. 176 | * @note Disabling this option saves both code and data space. 177 | */ 178 | #if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__) 179 | #define ADC_USE_WAIT TRUE 180 | #endif 181 | 182 | /** 183 | * @brief Enables the @p adcAcquireBus() and @p adcReleaseBus() APIs. 184 | * @note Disabling this option saves both code and data space. 185 | */ 186 | #if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) 187 | #define ADC_USE_MUTUAL_EXCLUSION TRUE 188 | #endif 189 | 190 | /*===========================================================================*/ 191 | /* CAN driver related settings. */ 192 | /*===========================================================================*/ 193 | 194 | /** 195 | * @brief Sleep mode related APIs inclusion switch. 196 | */ 197 | #if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__) 198 | #define CAN_USE_SLEEP_MODE TRUE 199 | #endif 200 | 201 | /*===========================================================================*/ 202 | /* I2C driver related settings. */ 203 | /*===========================================================================*/ 204 | 205 | /** 206 | * @brief Enables the mutual exclusion APIs on the I2C bus. 207 | */ 208 | #if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) 209 | #define I2C_USE_MUTUAL_EXCLUSION TRUE 210 | #endif 211 | 212 | /*===========================================================================*/ 213 | /* MAC driver related settings. */ 214 | /*===========================================================================*/ 215 | 216 | /** 217 | * @brief Enables an event sources for incoming packets. 218 | */ 219 | #if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__) 220 | #define MAC_USE_EVENTS TRUE 221 | #endif 222 | 223 | /*===========================================================================*/ 224 | /* MMC_SPI driver related settings. */ 225 | /*===========================================================================*/ 226 | 227 | /** 228 | * @brief Block size for MMC transfers. 229 | */ 230 | #if !defined(MMC_SECTOR_SIZE) || defined(__DOXYGEN__) 231 | #define MMC_SECTOR_SIZE 512 232 | #endif 233 | 234 | /** 235 | * @brief Delays insertions. 236 | * @details If enabled this options inserts delays into the MMC waiting 237 | * routines releasing some extra CPU time for the threads with 238 | * lower priority, this may slow down the driver a bit however. 239 | * This option is recommended also if the SPI driver does not 240 | * use a DMA channel and heavily loads the CPU. 241 | */ 242 | #if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__) 243 | #define MMC_NICE_WAITING TRUE 244 | #endif 245 | 246 | /** 247 | * @brief Number of positive insertion queries before generating the 248 | * insertion event. 249 | */ 250 | #if !defined(MMC_POLLING_INTERVAL) || defined(__DOXYGEN__) 251 | #define MMC_POLLING_INTERVAL 10 252 | #endif 253 | 254 | /** 255 | * @brief Interval, in milliseconds, between insertion queries. 256 | */ 257 | #if !defined(MMC_POLLING_DELAY) || defined(__DOXYGEN__) 258 | #define MMC_POLLING_DELAY 10 259 | #endif 260 | 261 | /** 262 | * @brief Uses the SPI polled API for small data transfers. 263 | * @details Polled transfers usually improve performance because it 264 | * saves two context switches and interrupt servicing. Note 265 | * that this option has no effect on large transfers which 266 | * are always performed using DMAs/IRQs. 267 | */ 268 | #if !defined(MMC_USE_SPI_POLLING) || defined(__DOXYGEN__) 269 | #define MMC_USE_SPI_POLLING TRUE 270 | #endif 271 | 272 | /*===========================================================================*/ 273 | /* SDC driver related settings. */ 274 | /*===========================================================================*/ 275 | 276 | /** 277 | * @brief Number of initialization attempts before rejecting the card. 278 | * @note Attempts are performed at 10mS intervals. 279 | */ 280 | #if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__) 281 | #define SDC_INIT_RETRY 100 282 | #endif 283 | 284 | /** 285 | * @brief Include support for MMC cards. 286 | * @note MMC support is not yet implemented so this option must be kept 287 | * at @p FALSE. 288 | */ 289 | #if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__) 290 | #define SDC_MMC_SUPPORT FALSE 291 | #endif 292 | 293 | /** 294 | * @brief Delays insertions. 295 | * @details If enabled this options inserts delays into the MMC waiting 296 | * routines releasing some extra CPU time for the threads with 297 | * lower priority, this may slow down the driver a bit however. 298 | */ 299 | #if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__) 300 | #define SDC_NICE_WAITING TRUE 301 | #endif 302 | 303 | /*===========================================================================*/ 304 | /* SERIAL driver related settings. */ 305 | /*===========================================================================*/ 306 | 307 | /** 308 | * @brief Default bit rate. 309 | * @details Configuration parameter, this is the baud rate selected for the 310 | * default configuration. 311 | */ 312 | #if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__) 313 | #define SERIAL_DEFAULT_BITRATE 38400 314 | #endif 315 | 316 | /** 317 | * @brief Serial buffers size. 318 | * @details Configuration parameter, you can change the depth of the queue 319 | * buffers depending on the requirements of your application. 320 | * @note The default is 64 bytes for both the transmission and receive 321 | * buffers. 322 | */ 323 | #if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__) 324 | #define SERIAL_BUFFERS_SIZE 16 325 | #endif 326 | 327 | /*===========================================================================*/ 328 | /* SPI driver related settings. */ 329 | /*===========================================================================*/ 330 | 331 | /** 332 | * @brief Enables synchronous APIs. 333 | * @note Disabling this option saves both code and data space. 334 | */ 335 | #if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__) 336 | #define SPI_USE_WAIT TRUE 337 | #endif 338 | 339 | /** 340 | * @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs. 341 | * @note Disabling this option saves both code and data space. 342 | */ 343 | #if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) 344 | #define SPI_USE_MUTUAL_EXCLUSION TRUE 345 | #endif 346 | 347 | #endif /* _HALCONF_H_ */ 348 | 349 | /** @} */ 350 | -------------------------------------------------------------------------------- /STM32F4_Discovery_demo/main.c: -------------------------------------------------------------------------------- 1 | // File adopted from ChibiOS STM32F4Discovery Demo 2 | 3 | #include "ch.h" 4 | #include "hal.h" 5 | 6 | #include "lis302dl.h" 7 | #include "chprintf.h" 8 | #include "xprintf.h" 9 | #include "ff.h" 10 | 11 | #include "UI.h" 12 | 13 | // User Includes 14 | #include "drawingApp.h" 15 | #include "wavePlayer.h" 16 | 17 | #define USE_MMC_CARD 18 | 19 | #ifdef USE_MMC_CARD 20 | 21 | // SPI SD Card 22 | FATFS MMC_FS; 23 | 24 | MMCDriver MMCD1; 25 | 26 | static volatile bool_t fs_ready = FALSE; 27 | 28 | void display_image(char* fn, uint16_t x, uint16_t y); 29 | 30 | #endif 31 | 32 | void mainEventHandler(uint8_t evt); 33 | void displayStartUpScreen(void); 34 | void displayMainScreen(void); 35 | 36 | static void testRGB1(void); 37 | static void testRGB2(void); 38 | static void testRGB3(void); 39 | static void testEventHandler(uint8_t evt); 40 | 41 | static void testImages(void); 42 | 43 | static void displayAboutScreen(void); 44 | 45 | void playWaveFile(void); 46 | 47 | // Menu Table 48 | const menuItem subMenu1[]= { 49 | {MENU_HEADER, "Menu", (uint8_t*)displayMainScreen}, 50 | {MENU_ITEM, "Test RGB Screen 1", (uint8_t*)testRGB1}, 51 | {MENU_ITEM, "Test RGB Screen 2", (uint8_t*)testRGB2}, 52 | {MENU_ITEM, "Test RGB Screen 3", (uint8_t*)testRGB3}, 53 | {MENU_ITEM, "Test Images", (uint8_t*)testImages}, 54 | {MENU_ITEM, "Play Wave File", (uint8_t*)playWaveFile}, 55 | {MENU_ITEM, "Draw", (uint8_t*)startDrawingThread}, 56 | {MENU_ITEM, "About", (uint8_t*)displayAboutScreen}, 57 | {MENU_END, 0, 0} 58 | }; 59 | 60 | // MMC Card Code 61 | static SPIConfig hs_spicfg = {NULL, GPIOC, 4, SPI_CR1_BR_0}; 62 | #ifdef USE_MMC_CARD 63 | // High Speed and Low Speed Configuration 64 | static SPIConfig ls_spicfg = {NULL, GPIOC, 4, SPI_CR1_BR_2 | SPI_CR1_BR_1 }; 65 | 66 | // We don't have checking currently 67 | static bool_t mmc_is_inserted(void) { return TRUE; } 68 | static bool_t mmc_is_protected(void) {return FALSE; } 69 | 70 | // MMC Card Insertion Event Handler 71 | static void InsertHandler(eventid_t id) 72 | { 73 | FRESULT err; 74 | (void) id; 75 | 76 | // Try establishing link with device 77 | if(mmcConnect(&MMCD1)) 78 | { 79 | chprintf((BaseChannel *) &SD2, "SD: Failed to connect to card\r\n"); 80 | return; 81 | } 82 | else 83 | { 84 | chprintf((BaseChannel *) &SD2, "SD: Connected to card\r\n"); 85 | } 86 | 87 | // If connected, mount the volume 88 | err = f_mount(0, &MMC_FS); 89 | if(err != FR_OK) 90 | { 91 | // Successful 92 | chprintf((BaseChannel *) &SD2, "SD: f_mount() failed %d\r\n", err); 93 | mmcDisconnect(&MMCD1); 94 | return; 95 | } 96 | else 97 | { 98 | chprintf((BaseChannel *) &SD2, "SD: File system mounted\r\n"); 99 | } 100 | 101 | // Set Ready Flag 102 | fs_ready = TRUE; 103 | } 104 | 105 | // MMC Card Removal Event Handler 106 | static void RemoveHandler(eventid_t id) 107 | { 108 | (void)id; 109 | fs_ready = FALSE; 110 | } 111 | 112 | // Display a bitmap image from the SD Card 113 | void display_bitmap(char* fn, uint16_t x, uint16_t y) 114 | { 115 | FIL fil; 116 | 117 | uint16_t s; 118 | uint16_t w,h,sz; 119 | UINT dmy, i; 120 | 121 | uint8_t* buffer; 122 | 123 | buffer=chHeapAlloc(NULL, 16384); 124 | 125 | s=f_open(&fil, fn, FA_READ); 126 | 127 | cx=3; cy=3; 128 | 129 | if (!buffer) { 130 | lcd_puts("Buffer allocation failed"); 131 | return; 132 | } 133 | 134 | if (s==FR_NO_FILE) { 135 | lcd_puts("File does not exist."); 136 | return; 137 | } 138 | else if (s==FR_NOT_READY) { 139 | lcd_puts("Card not Inserted."); 140 | return; 141 | } 142 | 143 | // Read the header first 144 | f_read(&fil, buffer, 54, &dmy); 145 | 146 | s=*((uint16_t*)&buffer[0]); 147 | 148 | // Support only 24bpp bitmap 149 | if (s != 0x4D42 || buffer[28] != 24) { 150 | lcd_puts("Not a valid bitmap!"); 151 | return; 152 | } 153 | 154 | w=*((uint16_t*)&buffer[18]); 155 | h=*((uint16_t*)&buffer[22]); 156 | 157 | sz=16384-54; 158 | 159 | lcd_setrect(x, x+w-1, y, y+h-1); 160 | lcd_writereg(0x03, 0x01); 161 | 162 | lcd_locate(x,y+h-1); 163 | 164 | lcd_cmd(0x22); 165 | 166 | palClearPad(LCD_CS_GPIO, LCD_CS_PIN); 167 | 168 | uint8_t clr[3], cnt=0; 169 | do 170 | { 171 | f_read(&fil, buffer, sz, &dmy); 172 | 173 | for (i=0;i> 3 ) << 11 ) | (( clr[1] >> 2 ) << 5 ) | ( clr[0] >> 3 )); 178 | 179 | lcd_lld_write(index); 180 | cnt=0; 181 | } 182 | } 183 | 184 | if (dmy 290 && py < 320) 426 | { 427 | if (px > 0 && px < 60) key=BTN_LEFT; 428 | if (px > 80 && px < 180) key=BTN_MID_SEL; 429 | if (px > 200 && px < 240) key=BTN_RIGHT; 430 | } 431 | 432 | if (py > 200 && py < 290) 433 | { 434 | if (px > 0 && px < 60) key=BTN_MID_UP; 435 | if (px > 180 && px < 240) key=BTN_MID_DOWN; 436 | } 437 | } 438 | } 439 | state=0; 440 | } 441 | else if (tsc_isPenDown()) 442 | { 443 | state=1; 444 | } 445 | 446 | 447 | return key; 448 | } 449 | 450 | void mainEventHandler(uint8_t evt) 451 | { 452 | int8_t x, y, z; 453 | switch (evt) 454 | { 455 | case BTN_MID_SEL: ui_clearUserArea(); 456 | ui_displayMenu(subMenu1,1); 457 | break; 458 | 459 | case 0xFF: 460 | 461 | x = (int8_t)lis302dlReadRegister(&SPID1, LIS302DL_OUTX); 462 | y = (int8_t)lis302dlReadRegister(&SPID1, LIS302DL_OUTY); 463 | z = (int8_t)lis302dlReadRegister(&SPID1, LIS302DL_OUTZ); 464 | 465 | lcd_gotoxy(3, 70); 466 | xprintf("X:%3d \nY:%3d \nZ:%3d ", 467 | (int16_t)x, 468 | (int16_t)y, 469 | (int16_t)z); 470 | break; 471 | } 472 | } 473 | 474 | __attribute__ ((noreturn)) 475 | static msg_t Thread1(void *arg) { 476 | (void)arg; 477 | chRegSetThreadName("blinker"); 478 | 479 | while (TRUE) 480 | { 481 | key=getkey(); 482 | 483 | ui_executecmd(key); 484 | chThdSleep(50); 485 | } 486 | } 487 | 488 | // Hardware Initialization 489 | static void hw_init(void) 490 | { 491 | // Init Serial Port 492 | sdStart(&SD2, NULL); 493 | palSetPadMode(GPIOA, 2, PAL_MODE_ALTERNATE(7)); 494 | palSetPadMode(GPIOA, 3, PAL_MODE_ALTERNATE(7)); 495 | 496 | // Init ADC 497 | // adcStart(&ADCD1, NULL); 498 | // adcSTM32EnableTSVREFE(); 499 | // palSetPadMode(GPIOC, 1, PAL_MODE_INPUT_ANALOG); 500 | 501 | // Init LIS302DL Accelerometer 502 | spiStart(&SPID1, &hs_spicfg); 503 | lis302dlWriteRegister(&SPID1, LIS302DL_CTRL_REG1, 0x43); 504 | lis302dlWriteRegister(&SPID1, LIS302DL_CTRL_REG2, 0x00); 505 | lis302dlWriteRegister(&SPID1, LIS302DL_CTRL_REG3, 0x00); 506 | 507 | // Init LCD & TSC (with LCD) 508 | lcd_initc(); 509 | xdev_out(lcd_putchar); 510 | 511 | // Init MMC/SD Card 512 | #ifdef USE_MMC_CARD 513 | palSetPadMode(GPIOC, 4, PAL_MODE_OUTPUT_PUSHPULL); 514 | palSetPad(GPIOC, 4); 515 | mmcObjectInit(&MMCD1, &SPID1, 516 | &ls_spicfg, &hs_spicfg, 517 | mmc_is_protected, mmc_is_inserted); 518 | mmcStart(&MMCD1, NULL); 519 | #endif 520 | 521 | codec_hw_init(); 522 | } 523 | 524 | static VirtualTimer vt1; 525 | 526 | static void led_toggle(void *p) 527 | { 528 | p; 529 | palTogglePad(GPIOD, GPIOD_LED3); 530 | chVTSetI(&vt1, 500, led_toggle, NULL); 531 | } 532 | 533 | // Entry Point 534 | int main(void) 535 | { 536 | #ifdef USE_MMC_CARD 537 | // Event Handler Array 538 | static const evhandler_t evhndl[] = { 539 | InsertHandler, 540 | RemoveHandler 541 | }; 542 | struct EventListener el0, el1; 543 | #endif 544 | 545 | halInit(); 546 | chSysInit(); 547 | 548 | mainThread=chThdSelf(); 549 | 550 | hw_init(); 551 | 552 | #ifdef USE_MMC_CARD 553 | // Register the event handler 554 | chEvtRegister(&MMCD1.inserted_event, &el0, 0); 555 | chEvtRegister(&MMCD1.removed_event, &el1, 1); 556 | 557 | // Invoke event handlers for card insertion immediately 558 | chEvtDispatch(evhndl, chEvtWaitOne(ALL_EVENTS)); 559 | #endif 560 | 561 | chThdCreateFromHeap(NULL, 1024, NORMALPRIO, Thread1, NULL); 562 | 563 | lcd_gotoxy(3, 30); 564 | lcd_puts("Hello, world"); 565 | 566 | displayMainScreen(); 567 | 568 | chprintf((BaseChannel *)&SD2, "Hello World!\r\n"); 569 | 570 | chVTSetI(&vt1, 500, led_toggle, NULL); 571 | 572 | while (TRUE) { 573 | ui_executecmd(0xFF); 574 | chThdSleep(100); 575 | } 576 | } 577 | -------------------------------------------------------------------------------- /STM32F4_Discovery_demo/mcuconf.h: -------------------------------------------------------------------------------- 1 | /* 2 | ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, 3 | 2011,2012 Giovanni Di Sirio. 4 | 5 | This file is part of ChibiOS/RT. 6 | 7 | ChibiOS/RT is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | ChibiOS/RT is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | 20 | --- 21 | 22 | A special exception to the GPL can be applied should you wish to distribute 23 | a combined work that includes ChibiOS/RT, without being obliged to provide 24 | the source code for any proprietary components. See the file exception.txt 25 | for full details of how and when the exception can be applied. 26 | */ 27 | 28 | /* 29 | * STM32F4xx drivers configuration. 30 | * The following settings override the default settings present in 31 | * the various device driver implementation headers. 32 | * Note that the settings for each driver only have effect if the whole 33 | * driver is enabled in halconf.h. 34 | * 35 | * IRQ priorities: 36 | * 15...0 Lowest...Highest. 37 | * 38 | * DMA priorities: 39 | * 0...3 Lowest...Highest. 40 | */ 41 | 42 | /* 43 | * HAL driver system settings. 44 | */ 45 | #define STM32_NO_INIT FALSE 46 | #define STM32_HSI_ENABLED TRUE 47 | #define STM32_LSI_ENABLED TRUE 48 | #define STM32_HSE_ENABLED TRUE 49 | #define STM32_LSE_ENABLED FALSE 50 | #define STM32_CLOCK48_REQUIRED TRUE 51 | #define STM32_SW STM32_SW_PLL 52 | #define STM32_PLLSRC STM32_PLLSRC_HSE 53 | #define STM32_PLLM_VALUE 8 54 | #define STM32_PLLN_VALUE 336 55 | #define STM32_PLLP_VALUE 2 56 | #define STM32_PLLQ_VALUE 7 57 | #define STM32_HPRE STM32_HPRE_DIV1 58 | #define STM32_PPRE1 STM32_PPRE1_DIV4 59 | #define STM32_PPRE2 STM32_PPRE2_DIV2 60 | #define STM32_RTCSEL STM32_RTCSEL_LSI 61 | #define STM32_RTCPRE_VALUE 8 62 | #define STM32_MCO1SEL STM32_MCO1SEL_HSI 63 | #define STM32_MCO1PRE STM32_MCO1PRE_DIV1 64 | #define STM32_MCO2SEL STM32_MCO2SEL_SYSCLK 65 | #define STM32_MCO2PRE STM32_MCO2PRE_DIV5 66 | #define STM32_I2SSRC STM32_I2SSRC_PLLI2S 67 | #define STM32_PLLI2SN_VALUE 271 68 | #define STM32_PLLI2SR_VALUE 2 69 | #define STM32_VOS STM32_VOS_HIGH 70 | #define STM32_PVD_ENABLE FALSE 71 | #define STM32_PLS STM32_PLS_LEV0 72 | 73 | /* 74 | * ADC driver system settings. 75 | */ 76 | #define STM32_ADC_ADCPRE ADC_CCR_ADCPRE_DIV4 77 | #define STM32_ADC_USE_ADC1 TRUE 78 | #define STM32_ADC_USE_ADC2 TRUE 79 | #define STM32_ADC_USE_ADC3 TRUE 80 | #define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID(2, 4) 81 | #define STM32_ADC_ADC2_DMA_STREAM STM32_DMA_STREAM_ID(2, 2) 82 | #define STM32_ADC_ADC3_DMA_STREAM STM32_DMA_STREAM_ID(2, 1) 83 | #define STM32_ADC_ADC1_DMA_PRIORITY 2 84 | #define STM32_ADC_ADC2_DMA_PRIORITY 2 85 | #define STM32_ADC_ADC3_DMA_PRIORITY 2 86 | #define STM32_ADC_IRQ_PRIORITY 5 87 | #define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 5 88 | #define STM32_ADC_ADC2_DMA_IRQ_PRIORITY 5 89 | #define STM32_ADC_ADC3_DMA_IRQ_PRIORITY 5 90 | 91 | /* 92 | * CAN driver system settings. 93 | */ 94 | #define STM32_CAN_USE_CAN1 TRUE 95 | #define STM32_CAN_CAN1_IRQ_PRIORITY 11 96 | 97 | /* 98 | * EXT driver system settings. 99 | */ 100 | #define STM32_EXT_EXTI0_IRQ_PRIORITY 6 101 | #define STM32_EXT_EXTI1_IRQ_PRIORITY 6 102 | #define STM32_EXT_EXTI2_IRQ_PRIORITY 6 103 | #define STM32_EXT_EXTI3_IRQ_PRIORITY 6 104 | #define STM32_EXT_EXTI4_IRQ_PRIORITY 6 105 | #define STM32_EXT_EXTI5_9_IRQ_PRIORITY 6 106 | #define STM32_EXT_EXTI10_15_IRQ_PRIORITY 6 107 | #define STM32_EXT_EXTI16_IRQ_PRIORITY 6 108 | #define STM32_EXT_EXTI17_IRQ_PRIORITY 15 109 | #define STM32_EXT_EXTI18_IRQ_PRIORITY 6 110 | #define STM32_EXT_EXTI19_IRQ_PRIORITY 6 111 | #define STM32_EXT_EXTI20_IRQ_PRIORITY 6 112 | #define STM32_EXT_EXTI21_IRQ_PRIORITY 15 113 | #define STM32_EXT_EXTI22_IRQ_PRIORITY 15 114 | 115 | /* 116 | * GPT driver system settings. 117 | */ 118 | #define STM32_GPT_USE_TIM1 FALSE 119 | #define STM32_GPT_USE_TIM2 FALSE 120 | #define STM32_GPT_USE_TIM3 FALSE 121 | #define STM32_GPT_USE_TIM4 FALSE 122 | #define STM32_GPT_USE_TIM5 FALSE 123 | #define STM32_GPT_USE_TIM8 FALSE 124 | #define STM32_GPT_TIM1_IRQ_PRIORITY 7 125 | #define STM32_GPT_TIM2_IRQ_PRIORITY 7 126 | #define STM32_GPT_TIM3_IRQ_PRIORITY 7 127 | #define STM32_GPT_TIM4_IRQ_PRIORITY 7 128 | #define STM32_GPT_TIM5_IRQ_PRIORITY 7 129 | #define STM32_GPT_TIM8_IRQ_PRIORITY 7 130 | 131 | /* 132 | * ICU driver system settings. 133 | */ 134 | #define STM32_ICU_USE_TIM1 FALSE 135 | #define STM32_ICU_USE_TIM2 FALSE 136 | #define STM32_ICU_USE_TIM3 FALSE 137 | #define STM32_ICU_USE_TIM4 TRUE 138 | #define STM32_ICU_USE_TIM5 FALSE 139 | #define STM32_ICU_USE_TIM8 FALSE 140 | #define STM32_ICU_TIM1_IRQ_PRIORITY 7 141 | #define STM32_ICU_TIM2_IRQ_PRIORITY 7 142 | #define STM32_ICU_TIM3_IRQ_PRIORITY 7 143 | #define STM32_ICU_TIM4_IRQ_PRIORITY 7 144 | #define STM32_ICU_TIM5_IRQ_PRIORITY 7 145 | #define STM32_ICU_TIM8_IRQ_PRIORITY 7 146 | 147 | /* 148 | * PWM driver system settings. 149 | */ 150 | #define STM32_PWM_USE_ADVANCED FALSE 151 | #define STM32_PWM_USE_TIM1 FALSE 152 | #define STM32_PWM_USE_TIM2 FALSE 153 | #define STM32_PWM_USE_TIM3 FALSE 154 | #define STM32_PWM_USE_TIM4 TRUE 155 | #define STM32_PWM_USE_TIM5 FALSE 156 | #define STM32_PWM_USE_TIM8 FALSE 157 | #define STM32_PWM_TIM1_IRQ_PRIORITY 7 158 | #define STM32_PWM_TIM2_IRQ_PRIORITY 7 159 | #define STM32_PWM_TIM3_IRQ_PRIORITY 7 160 | #define STM32_PWM_TIM4_IRQ_PRIORITY 7 161 | #define STM32_PWM_TIM5_IRQ_PRIORITY 7 162 | #define STM32_PWM_TIM8_IRQ_PRIORITY 7 163 | 164 | /* 165 | * SERIAL driver system settings. 166 | */ 167 | #define STM32_SERIAL_USE_USART1 FALSE 168 | #define STM32_SERIAL_USE_USART2 TRUE 169 | #define STM32_SERIAL_USE_USART3 FALSE 170 | #define STM32_SERIAL_USE_UART4 FALSE 171 | #define STM32_SERIAL_USE_UART5 FALSE 172 | #define STM32_SERIAL_USE_USART6 FALSE 173 | #define STM32_SERIAL_USART1_PRIORITY 12 174 | #define STM32_SERIAL_USART2_PRIORITY 12 175 | #define STM32_SERIAL_USART3_PRIORITY 12 176 | #define STM32_SERIAL_UART4_PRIORITY 12 177 | #define STM32_SERIAL_UART5_PRIORITY 12 178 | #define STM32_SERIAL_USART6_PRIORITY 12 179 | 180 | /* 181 | * SPI driver system settings. 182 | */ 183 | #define STM32_SPI_USE_SPI1 TRUE 184 | #define STM32_SPI_USE_SPI2 FALSE 185 | #define STM32_SPI_USE_SPI3 TRUE 186 | #define STM32_SPI_SPI1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 0) 187 | #define STM32_SPI_SPI1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 3) 188 | #define STM32_SPI_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3) 189 | #define STM32_SPI_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4) 190 | #define STM32_SPI_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0) 191 | #define STM32_SPI_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7) 192 | #define STM32_SPI_SPI1_DMA_PRIORITY 1 193 | #define STM32_SPI_SPI2_DMA_PRIORITY 1 194 | #define STM32_SPI_SPI3_DMA_PRIORITY 3 195 | #define STM32_SPI_SPI1_IRQ_PRIORITY 10 196 | #define STM32_SPI_SPI2_IRQ_PRIORITY 10 197 | #define STM32_SPI_SPI3_IRQ_PRIORITY 4 198 | #define STM32_SPI_DMA_ERROR_HOOK(spip) chSysHalt() 199 | 200 | /* 201 | * UART driver system settings. 202 | */ 203 | #define STM32_UART_USE_USART1 FALSE 204 | #define STM32_UART_USE_USART2 TRUE 205 | #define STM32_UART_USE_USART3 FALSE 206 | #define STM32_UART_USART1_RX_DMA_STREAM STM32_DMA_STREAM_ID(2, 5) 207 | #define STM32_UART_USART1_TX_DMA_STREAM STM32_DMA_STREAM_ID(2, 7) 208 | #define STM32_UART_USART2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 5) 209 | #define STM32_UART_USART2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6) 210 | #define STM32_UART_USART3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 1) 211 | #define STM32_UART_USART3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 3) 212 | #define STM32_UART_USART1_IRQ_PRIORITY 12 213 | #define STM32_UART_USART2_IRQ_PRIORITY 12 214 | #define STM32_UART_USART3_IRQ_PRIORITY 12 215 | #define STM32_UART_USART1_DMA_PRIORITY 0 216 | #define STM32_UART_USART2_DMA_PRIORITY 0 217 | #define STM32_UART_USART3_DMA_PRIORITY 0 218 | #define STM32_UART_DMA_ERROR_HOOK(uartp) chSysHalt() 219 | 220 | /* 221 | * I2C driver system settings. 222 | */ 223 | #define STM32_I2C_USE_I2C1 TRUE 224 | #define STM32_I2C_USE_I2C2 FALSE 225 | #define STM32_I2C_USE_I2C3 FALSE 226 | #define STM32_I2C_I2C1_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 0) 227 | #define STM32_I2C_I2C1_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 6) 228 | #define STM32_I2C_I2C2_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2) 229 | #define STM32_I2C_I2C2_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 7) 230 | #define STM32_I2C_I2C3_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2) 231 | #define STM32_I2C_I2C3_TX_DMA_STREAM STM32_DMA_STREAM_ID(1, 4) 232 | #define STM32_I2C_I2C1_IRQ_PRIORITY 6 233 | #define STM32_I2C_I2C2_IRQ_PRIORITY 6 234 | #define STM32_I2C_I2C3_IRQ_PRIORITY 6 235 | #define STM32_I2C_I2C1_DMA_PRIORITY 1 236 | #define STM32_I2C_I2C2_DMA_PRIORITY 1 237 | #define STM32_I2C_I2C3_DMA_PRIORITY 1 238 | #define STM32_I2C_I2C1_DMA_ERROR_HOOK() chSysHalt() 239 | #define STM32_I2C_I2C2_DMA_ERROR_HOOK() chSysHalt() 240 | #define STM32_I2C_I2C3_DMA_ERROR_HOOK() chSysHalt() 241 | 242 | -------------------------------------------------------------------------------- /STM32F4_Discovery_demo/uitests.c: -------------------------------------------------------------------------------- 1 | /* 2 | * uitests.c 3 | * 4 | * Created on: Jun 2, 2012 5 | * Author: Kumar Abhishek 6 | */ 7 | 8 | // This file is currently not used. 9 | 10 | #include "ch.h" 11 | #include "hal.h" 12 | 13 | #include "lis302dl.h" 14 | #include "chprintf.h" 15 | 16 | #include "ff.h" 17 | 18 | #include "CLCDQVGA_Driver.h" 19 | 20 | #include "UI.h" 21 | #include "keys.h" 22 | #include "xprintf.h" 23 | 24 | 25 | static void tsc_getCalibPoint(uint16_t vx, uint16_t vy, uint16_t* x, uint16_t* y) 26 | { 27 | uint16_t _x=0,_y=0; 28 | lcd_filledrect(BLUE, vx-1, vy-1, 3, 3); 29 | lcd_filledrect(BLUE, vx-10, vy, 20, 1); 30 | lcd_filledrect(BLUE, vx, vy-10, 1, 20); 31 | 32 | while (!tsc_isPenDown()) {} 33 | 34 | for (int i=0;i<10;i++) 35 | { 36 | uint16_t tx=0,ty=0; 37 | lcd_getpointraw(&tx, &ty); 38 | _x+=tx; 39 | _y+=ty; 40 | } 41 | 42 | _x/=10; 43 | _y/=10; 44 | 45 | lcd_filledrect(WHITE, vx-1, vy-1, 3, 3); 46 | lcd_filledrect(WHITE, vx-10, vy, 20, 1); 47 | lcd_filledrect(WHITE, vx, vy-10, 1, 20); 48 | 49 | *x=_x; 50 | *y=_y; 51 | } 52 | 53 | void translate(uint16_t* x, uint16_t* y) 54 | { 55 | int16_t a=*x,b=*y; 56 | 57 | a=(int16_t)(_ax*a+_bx*b+_c); 58 | b=(int16_t)(_ay*a+_by*b+_d); 59 | 60 | *x=a; 61 | *y=b; 62 | } 63 | 64 | //void translatePrim(uint16_t* x, uint16_t* y) 65 | //{ 66 | // 67 | //} 68 | 69 | // Three point calibration 70 | void tsc_calibration(void) 71 | { 72 | uint16_t x1,y1,x2,y2,x3,y3; 73 | 74 | uint16_t X1=100, Y1=200, 75 | X2=180, Y2=160, 76 | X3=200, Y3=200; 77 | 78 | double dx, dx1, dx2, dx3, dy1, dy2, dy3; 79 | 80 | cx=3; cy=3; lcd_puts("Calibration"); 81 | cx=3; cy=20; lcd_puts("Tap the red point."); 82 | 83 | chprintf(&SD2, "Touch Panel Calibration Started\r\n"); 84 | 85 | x1=x2=x3=y1=y2=y3=0; 86 | 87 | tsc_getCalibPoint(X1, Y1, &x1, &y1); 88 | chprintf(&SD2, "X1=%d, Y1=%d\r\n", x1, y1); 89 | 90 | chThdSleepMilliseconds(1000); 91 | 92 | tsc_getCalibPoint(X2, Y2, &x2, &y2); 93 | chprintf(&SD2, "X2=%d, Y2=%d\r\n", x2, y2); 94 | 95 | chThdSleepMilliseconds(1000); 96 | 97 | tsc_getCalibPoint(X3, Y3, &x3, &y3); 98 | chprintf(&SD2, "X3=%d, Y3=%d\r\n", x3, y3); 99 | 100 | chThdSleepMilliseconds(1000); 101 | 102 | dx =((double)(x1-x3)) * ((double)(y2-y3)) - ((double)(x2-x3)) * ((double)(y1-y3)); 103 | dx1=((double)(X1-X3)) * ((double)(y2-y3)) - ((double)(X2-X3)) * ((double)(y1-y3)); 104 | dx2=((double)(x1-x3)) * ((double)(x2-x3)) - ((double)(x2-x3)) * ((double)(X1-X3)); 105 | dx3=X1*((double)x2*(double)y3 - (double)x3*(double)y2) - 106 | X2*((double)x1*(double)y3 - (double)x3*(double)y1) + 107 | X3*((double)x1*(double)y2 - (double)x2*(double)y1); 108 | 109 | dy1=((double)(Y1-Y3)) * ((double)(y2-y3)) - ((double)(Y2-Y3)) * ((double)(y1-y3)); 110 | dy2=((double)(x1-x3)) * ((double)(Y2-Y3)) - ((double)(x2-x3)) * ((double)(Y1-Y3)); 111 | dy3=Y1*((double)x2*(double)y3 - (double)x3*(double)y2) - 112 | Y2*((double)x1*(double)y3 - (double)x3*(double)y1) + 113 | Y3*((double)x1*(double)y2 - (double)x2*(double)y1); 114 | 115 | // chprintf(&SD2, "dx=%ld, dx1=%ld, dx2=%ld, dx3=%ld\r\n", dx, dx1, dx2, dx3); 116 | // chprintf(&SD2, "dy1=%ld, dy2=%ld, dy3=%ld\r\n", dy1, dy2, dy3); 117 | 118 | _ax=(double)dx1/(double)dx; 119 | _bx=(double)dx2/(double)dx; 120 | _c=(double)dx3/(double)dx; 121 | 122 | _ay=(double)dy1/(double)dx; 123 | _by=(double)dy2/(double)dx; 124 | _d=(double)dy3/(double)dx; 125 | 126 | translate(&x1, &y1); 127 | translate(&x2, &y2); 128 | translate(&x3, &y3); 129 | chprintf(&SD2, "X1=%d, Y1=%d\r\n", x1, y1); 130 | chprintf(&SD2, "X2=%d, Y2=%d\r\n", x2, y2); 131 | chprintf(&SD2, "X3=%d, Y3=%d\r\n", x3, y3); 132 | } 133 | 134 | -------------------------------------------------------------------------------- /STM32F4_Discovery_demo/wavePlayer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * wavePlayer.c 3 | * 4 | * Created on: Jun 7, 2012 5 | * Author: Kumar Abhishek 6 | */ 7 | 8 | #include "wavePlayer.h" 9 | 10 | static WORKING_AREA(waThread3, 1024); 11 | 12 | #define PLAYBACK_BUFFER_SIZE 512 13 | 14 | uint8_t buf[PLAYBACK_BUFFER_SIZE]={0}; 15 | uint8_t buf2[PLAYBACK_BUFFER_SIZE]={0}; 16 | 17 | uint32_t waveSampleLength=0, bytesToPlay; 18 | 19 | Thread* playerThread; 20 | 21 | FIL f1; 22 | 23 | extern stm32_dma_stream_t* i2sdma; 24 | 25 | uint16_t vol=200; 26 | 27 | uint8_t pause=0; 28 | 29 | static void wavePlayEventHandler(uint8_t evt) 30 | { 31 | static uint8_t prevEvt=0; 32 | 33 | if (evt && evt < 15) 34 | if (prevEvt!=evt) { 35 | prevEvt=evt; 36 | codec_sendBeep(); 37 | } 38 | 39 | switch (evt) 40 | { 41 | case BTN_RIGHT: 42 | lcd_cls(); 43 | ui_displayPreviousMenu(); 44 | break; 45 | 46 | case BTN_LEFT: 47 | chThdTerminate(playerThread); 48 | chThdWait(playerThread); 49 | playerThread=NULL; 50 | break; 51 | 52 | case BTN_MID_DOWN: 53 | vol--; 54 | if (vol < 150) vol=150; 55 | codec_volCtl(vol); 56 | break; 57 | 58 | case BTN_MID_UP: 59 | vol++; 60 | if (vol > 220) vol=220; 61 | codec_volCtl(vol); 62 | break; 63 | 64 | case BTN_MID_SEL: 65 | if (!pause) { 66 | pause=1; 67 | ui_drawBottomBar("Stop", "Play", "Exit"); 68 | } else { 69 | pause=0; 70 | ui_drawBottomBar("Stop", "Pause", "Exit"); 71 | } 72 | codec_pauseResumePlayback(pause); 73 | break; 74 | } 75 | } 76 | 77 | static msg_t wavePlayerThread(void *arg) { 78 | (void)arg; 79 | chRegSetThreadName("blinker"); 80 | 81 | UINT temp, bufSwitch=1; 82 | 83 | codec_pwrCtl(1); 84 | codec_muteCtl(0); 85 | 86 | f_read(&f1, buf, PLAYBACK_BUFFER_SIZE, &temp); 87 | bytesToPlay-=temp; 88 | 89 | chEvtAddFlags(1); 90 | 91 | while(bytesToPlay) 92 | { 93 | chEvtWaitOne(1); 94 | 95 | if (bufSwitch) 96 | { 97 | codec_audio_send(buf, temp/2); 98 | spiAcquireBus(&SPID1); 99 | f_read(&f1, buf2, PLAYBACK_BUFFER_SIZE, &temp); 100 | spiReleaseBus(&SPID1); 101 | bufSwitch=0; 102 | } 103 | else 104 | { 105 | codec_audio_send(buf2, temp/2); 106 | spiAcquireBus(&SPID1); 107 | f_read(&f1, buf, PLAYBACK_BUFFER_SIZE, &temp); 108 | spiReleaseBus(&SPID1); 109 | bufSwitch=1; 110 | } 111 | 112 | bytesToPlay-=temp; 113 | 114 | if (chThdShouldTerminate()) break; 115 | } 116 | 117 | codec_muteCtl(1); 118 | codec_pwrCtl(0); 119 | 120 | playerThread=NULL; 121 | 122 | f_close(&f1); 123 | 124 | return 0; 125 | } 126 | 127 | void playWaveFile(void) 128 | { 129 | 130 | uint8_t st; 131 | UINT btr; 132 | WAVFILE* wf; 133 | 134 | uint32_t temp, offset=44, cnt; 135 | 136 | ui_clearUserArea(); 137 | ui_drawTitleBar("Play Wave File"); 138 | ui_drawBottomBar("Stop", pause?"Play":"Pause", "Exit"); 139 | ui_sethandler((pfn)wavePlayEventHandler); 140 | 141 | cx=3; cy=UI_TBARHEIGHT+3; 142 | 143 | if (playerThread) { 144 | lcd_puts("File Already Playing!"); 145 | return; 146 | } 147 | 148 | st=f_open(&f1, "audio.wav", FA_READ); 149 | 150 | if (st) { 151 | lcd_puts("Invalid file"); 152 | return; 153 | } 154 | 155 | st=f_read(&f1, buf, 1024, &btr); 156 | 157 | wf=(WAVFILE*)&buf[0]; 158 | 159 | if (wf->riffSignature != WAVE_HEAD_RIFF || wf->fmtSignature != WAVE_HEAD_FMT || wf->format!=0x01) { 160 | lcd_puts("This is a not a wave file!"); 161 | return; 162 | } 163 | 164 | xprintf("Number of channels=%d\nSample Rate=%ld\nNumber of Bits=%d\n", wf->numChannels, wf->sampleRate, wf->numBits); 165 | 166 | temp=READ_UINT32(&buf[36]); 167 | 168 | if (temp==WAVE_HEAD_DATA) 169 | { 170 | // Got 'data' chunk, ready to play 171 | waveSampleLength=READ_UINT32(&buf[40]); 172 | lcd_puts("No Metadata. Ready to play.\n"); 173 | offset=44; 174 | } 175 | else if (temp==WAVE_META_LIST) 176 | { 177 | uint32_t msize; 178 | lcd_puts("File has metadata:"); 179 | msize=READ_UINT32(&buf[40]); 180 | offset=52+msize; 181 | xprintf("%ld bytes.\nActual Data starts at offset:%ld\n", msize, offset); 182 | 183 | cnt=0; 184 | temp=READ_UINT32(&buf[44+cnt]); 185 | 186 | // Tag Reading Supported only on Audacity Output 187 | if (temp==WAVE_META_INFO) 188 | { 189 | cnt+=4; 190 | do 191 | { 192 | temp=READ_UINT32(&buf[44+cnt]); 193 | 194 | switch (temp) 195 | { 196 | case WAVE_META_INAM: 197 | cnt+=4; 198 | temp=READ_UINT32(&buf[44+cnt]); 199 | cnt+=4; 200 | xprintf("Name: %s\n", &buf[44+cnt]); 201 | cnt+=temp; 202 | break; 203 | 204 | case WAVE_META_IART: 205 | cnt+=4; 206 | temp=READ_UINT32(&buf[44+cnt]); 207 | cnt+=4; 208 | xprintf("Artist: %s\n", &buf[44+cnt]); 209 | cnt+=temp; 210 | break; 211 | 212 | case WAVE_META_ICMT: 213 | cnt+=4; 214 | temp=READ_UINT32(&buf[44+cnt]); 215 | cnt+=4; 216 | xprintf("Composer: %s\n", &buf[44+cnt]); 217 | cnt+=temp; 218 | break; 219 | 220 | case WAVE_META_ICRD: 221 | cnt+=4; 222 | temp=READ_UINT32(&buf[44+cnt]); 223 | cnt+=4; 224 | xprintf("Release Yr: %s\n", &buf[44+cnt]); 225 | cnt+=temp; 226 | break; 227 | 228 | default: 229 | cnt+=8; // Token+Size (4 bytes each) 230 | break; 231 | } 232 | 233 | } while (cnt < msize); 234 | waveSampleLength=READ_UINT32(&buf[offset-4]); 235 | lcd_puts("Ready To Play.\n"); 236 | } 237 | } 238 | 239 | codec_i2s_init(wf->sampleRate, wf->numBits); 240 | 241 | xprintf("Sample Length:%ld bytes", waveSampleLength); 242 | 243 | bytesToPlay=waveSampleLength; 244 | 245 | f_lseek(&f1, offset); 246 | 247 | playerThread=chThdCreateStatic(waThread3, sizeof(waThread3), NORMALPRIO+2, wavePlayerThread, NULL); 248 | } 249 | -------------------------------------------------------------------------------- /STM32F4_Discovery_demo/wavePlayer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * wavePlayer.h 3 | * 4 | * Created on: Jun 8, 2012 5 | * Author: Kumar Abhishek 6 | */ 7 | 8 | #ifndef WAVEPLAYER_H_ 9 | #define WAVEPLAYER_H_ 10 | 11 | #include "ch.h" 12 | #include "hal.h" 13 | 14 | #include "UI.h" 15 | #include "ff.h" 16 | 17 | #include "codec.h" 18 | 19 | #include "chprintf.h" 20 | #include "xprintf.h" 21 | 22 | #define READ_UINT32(ptr) *((uint32_t*)ptr) 23 | #define READ_UINT16(ptr) *((uint16_t*)ptr) 24 | 25 | #define WAVE_HEAD_RIFF 0x46464952 // 'FIRR' = RIFF in Little-Endian format 26 | #define WAVE_HEAD_WAVE 0x45564157 // WAVE in Little-Endian 27 | #define WAVE_HEAD_DATA 0x61746164 // 'data' in Little-Endian 28 | #define WAVE_HEAD_FMT 0x20746D66 29 | 30 | #define WAVE_META_LIST 0x5453494C 31 | #define WAVE_META_INFO 0x4F464E49 32 | #define WAVE_META_INAM 0x4D414E49 33 | #define WAVE_META_IART 0x54524149 34 | #define WAVE_META_ICMT 0x544D4349 35 | #define WAVE_META_ICRD 0x44524349 36 | 37 | typedef struct _wavfile { 38 | uint32_t riffSignature; 39 | uint32_t fileSize; 40 | uint32_t waveSignature; 41 | uint32_t fmtSignature; 42 | uint32_t subChunk1Size; 43 | uint16_t format; 44 | uint16_t numChannels; 45 | uint32_t sampleRate; 46 | uint32_t byteRate; 47 | uint16_t blockAlign; 48 | uint16_t numBits; 49 | } WAVFILE; 50 | 51 | extern Thread* playerThread; 52 | 53 | #endif /* WAVEPLAYER_H_ */ 54 | -------------------------------------------------------------------------------- /STM32F4_Discovery_demo/xprintf.c: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------/ 2 | / Universal string handler for user console interface 3 | /-------------------------------------------------------------------------/ 4 | / 5 | / Copyright (C) 2011, ChaN, all right reserved. 6 | / 7 | / * This software is a free software and there is NO WARRANTY. 8 | / * No restriction on use. You can use, modify and redistribute it for 9 | / personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY. 10 | / * Redistributions of source code must retain the above copyright notice. 11 | / 12 | /-------------------------------------------------------------------------*/ 13 | 14 | #include "xprintf.h" 15 | 16 | 17 | #if _USE_XFUNC_OUT 18 | #include 19 | void (*xfunc_out)(unsigned char); /* Pointer to the output stream */ 20 | static char *outptr; 21 | 22 | /*----------------------------------------------*/ 23 | /* Put a character */ 24 | /*----------------------------------------------*/ 25 | 26 | void xputc (char c) 27 | { 28 | if (_CR_CRLF && c == '\n') xputc('\r'); /* CR -> CRLF */ 29 | 30 | if (outptr) { 31 | *outptr++ = (unsigned char)c; 32 | return; 33 | } 34 | 35 | if (xfunc_out) xfunc_out((unsigned char)c); 36 | } 37 | 38 | 39 | 40 | /*----------------------------------------------*/ 41 | /* Put a null-terminated string */ 42 | /*----------------------------------------------*/ 43 | 44 | void xputs ( /* Put a string to the default device */ 45 | const char* str /* Pointer to the string */ 46 | ) 47 | { 48 | while (*str) 49 | xputc(*str++); 50 | } 51 | 52 | 53 | void xfputs ( /* Put a string to the specified device */ 54 | void(*func)(unsigned char), /* Pointer to the output function */ 55 | const char* str /* Pointer to the string */ 56 | ) 57 | { 58 | void (*pf)(unsigned char); 59 | 60 | 61 | pf = xfunc_out; /* Save current output device */ 62 | xfunc_out = func; /* Switch output to specified device */ 63 | while (*str) /* Put the string */ 64 | xputc(*str++); 65 | xfunc_out = pf; /* Restore output device */ 66 | } 67 | 68 | 69 | 70 | /*----------------------------------------------*/ 71 | /* Formatted string output */ 72 | /*----------------------------------------------*/ 73 | /* xprintf("%d", 1234); "1234" 74 | xprintf("%6d,%3d%%", -200, 5); " -200, 5%" 75 | xprintf("%-6u", 100); "100 " 76 | xprintf("%ld", 12345678L); "12345678" 77 | xprintf("%04x", 0xA3); "00a3" 78 | xprintf("%08LX", 0x123ABC); "00123ABC" 79 | xprintf("%016b", 0x550F); "0101010100001111" 80 | xprintf("%s", "String"); "String" 81 | xprintf("%-4s", "abc"); "abc " 82 | xprintf("%4s", "abc"); " abc" 83 | xprintf("%c", 'a'); "a" 84 | xprintf("%f", 10.0); 85 | */ 86 | 87 | static 88 | void xvprintf ( 89 | const char* fmt, /* Pointer to the format string */ 90 | va_list arp /* Pointer to arguments */ 91 | ) 92 | { 93 | unsigned int r, i, j, w, f; 94 | unsigned long v; 95 | char s[16], c, d, *p; 96 | 97 | 98 | for (;;) { 99 | c = *fmt++; /* Get a char */ 100 | if (!c) break; /* End of format? */ 101 | if (c != '%') { /* Pass through it if not a % sequense */ 102 | xputc(c); continue; 103 | } 104 | f = 0; 105 | c = *fmt++; /* Get first char of the sequense */ 106 | if (c == '0') { /* Flag: '0' padded */ 107 | f = 1; c = *fmt++; 108 | } else { 109 | if (c == '-') { /* Flag: left justified */ 110 | f = 2; c = *fmt++; 111 | } 112 | } 113 | for (w = 0; c >= '0' && c <= '9'; c = *fmt++) /* Minimum width */ 114 | w = w * 10 + c - '0'; 115 | if (c == 'l' || c == 'L') { /* Prefix: Size is long int */ 116 | f |= 4; c = *fmt++; 117 | } 118 | if (!c) break; /* End of format? */ 119 | d = c; 120 | if (d >= 'a') d -= 0x20; 121 | switch (d) { /* Type is... */ 122 | case 'S' : /* String */ 123 | p = va_arg(arp, char*); 124 | for (j = 0; p[j]; j++) ; 125 | while (!(f & 2) && j++ < w) xputc(' '); 126 | xputs(p); 127 | while (j++ < w) xputc(' '); 128 | continue; 129 | case 'C' : /* Character */ 130 | xputc((char)va_arg(arp, int)); continue; 131 | case 'B' : /* Binary */ 132 | r = 2; break; 133 | case 'O' : /* Octal */ 134 | r = 8; break; 135 | case 'D' : /* Signed decimal */ 136 | case 'U' : /* Unsigned decimal */ 137 | r = 10; break; 138 | case 'X' : /* Hexdecimal */ 139 | r = 16; break; 140 | default: /* Unknown type (passthrough) */ 141 | xputc(c); continue; 142 | } 143 | 144 | /* Get an argument and put it in numeral */ 145 | v = (f & 4) ? va_arg(arp, long) : ((d == 'D') ? (long)va_arg(arp, int) : (long)va_arg(arp, unsigned int)); 146 | if (d == 'D' && (v & 0x80000000)) { 147 | v = 0 - v; 148 | f |= 8; 149 | } 150 | i = 0; 151 | do { 152 | d = (char)(v % r); v /= r; 153 | if (d > 9) d += (c == 'x') ? 0x27 : 0x07; 154 | s[i++] = d + '0'; 155 | } while (v && i < sizeof(s)); 156 | if (f & 8) s[i++] = '-'; 157 | j = i; d = (f & 1) ? '0' : ' '; 158 | while (!(f & 2) && j++ < w) xputc(d); 159 | do xputc(s[--i]); while(i); 160 | while (j++ < w) xputc(' '); 161 | } 162 | } 163 | 164 | 165 | void xprintf ( /* Put a formatted string to the default device */ 166 | const char* fmt, /* Pointer to the format string */ 167 | ... /* Optional arguments */ 168 | ) 169 | { 170 | va_list arp; 171 | 172 | 173 | va_start(arp, fmt); 174 | xvprintf(fmt, arp); 175 | va_end(arp); 176 | } 177 | 178 | 179 | void xsprintf ( /* Put a formatted string to the memory */ 180 | char* buff, /* Pointer to the output buffer */ 181 | const char* fmt, /* Pointer to the format string */ 182 | ... /* Optional arguments */ 183 | ) 184 | { 185 | va_list arp; 186 | 187 | 188 | outptr = buff; /* Switch destination for memory */ 189 | 190 | va_start(arp, fmt); 191 | xvprintf(fmt, arp); 192 | va_end(arp); 193 | 194 | *outptr = 0; /* Terminate output string with a \0 */ 195 | outptr = 0; /* Switch destination for device */ 196 | } 197 | 198 | 199 | void xfprintf ( /* Put a formatted string to the specified device */ 200 | void(*func)(unsigned char), /* Pointer to the output function */ 201 | const char* fmt, /* Pointer to the format string */ 202 | ... /* Optional arguments */ 203 | ) 204 | { 205 | va_list arp; 206 | void (*pf)(unsigned char); 207 | 208 | 209 | pf = xfunc_out; /* Save current output device */ 210 | xfunc_out = func; /* Switch output to specified device */ 211 | 212 | va_start(arp, fmt); 213 | xvprintf(fmt, arp); 214 | va_end(arp); 215 | 216 | xfunc_out = pf; /* Restore output device */ 217 | } 218 | 219 | 220 | 221 | /*----------------------------------------------*/ 222 | /* Dump a line of binary dump */ 223 | /*----------------------------------------------*/ 224 | 225 | void put_dump ( 226 | const void* buff, /* Pointer to the array to be dumped */ 227 | unsigned long addr, /* Heading address value */ 228 | int len, /* Number of items to be dumped */ 229 | int width /* Size of the items (DW_CHAR, DW_SHORT, DW_LONG) */ 230 | ) 231 | { 232 | int i; 233 | const unsigned char *bp; 234 | const unsigned short *sp; 235 | const unsigned long *lp; 236 | 237 | 238 | xprintf("%08lX ", addr); /* address */ 239 | 240 | switch (width) { 241 | case DW_CHAR: 242 | bp = buff; 243 | for (i = 0; i < len; i++) /* Hexdecimal dump */ 244 | xprintf(" %02X", bp[i]); 245 | xputc(' '); 246 | for (i = 0; i < len; i++) /* ASCII dump */ 247 | xputc((bp[i] >= ' ' && bp[i] <= '~') ? bp[i] : '.'); 248 | break; 249 | case DW_SHORT: 250 | sp = buff; 251 | do /* Hexdecimal dump */ 252 | xprintf(" %04X", *sp++); 253 | while (--len); 254 | break; 255 | case DW_LONG: 256 | lp = buff; 257 | do /* Hexdecimal dump */ 258 | xprintf(" %08LX", *lp++); 259 | while (--len); 260 | break; 261 | } 262 | 263 | xputc('\n'); 264 | } 265 | 266 | #endif /* _USE_XFUNC_OUT */ 267 | 268 | 269 | 270 | #if _USE_XFUNC_IN 271 | unsigned char (*xfunc_in)(void); /* Pointer to the input stream */ 272 | 273 | /*----------------------------------------------*/ 274 | /* Get a line from the input */ 275 | /*----------------------------------------------*/ 276 | 277 | int xgets ( /* 0:End of stream, 1:A line arrived */ 278 | char* buff, /* Pointer to the buffer */ 279 | int len /* Buffer length */ 280 | ) 281 | { 282 | int c, i; 283 | 284 | 285 | if (!xfunc_in) return 0; /* No input function specified */ 286 | 287 | i = 0; 288 | for (;;) { 289 | c = xfunc_in(); /* Get a char from the incoming stream */ 290 | if (!c) return 0; /* End of stream? */ 291 | if (c == '\r') break; /* End of line? */ 292 | if (c == '\b' && i) { /* Back space? */ 293 | i--; 294 | if (_LINE_ECHO) xputc(c); 295 | continue; 296 | } 297 | if (c >= ' ' && i < len - 1) { /* Visible chars */ 298 | buff[i++] = c; 299 | if (_LINE_ECHO) xputc(c); 300 | } 301 | } 302 | buff[i] = 0; /* Terminate with a \0 */ 303 | if (_LINE_ECHO) xputc('\n'); 304 | return 1; 305 | } 306 | 307 | 308 | int xfgets ( /* 0:End of stream, 1:A line arrived */ 309 | unsigned char (*func)(void), /* Pointer to the input stream function */ 310 | char* buff, /* Pointer to the buffer */ 311 | int len /* Buffer length */ 312 | ) 313 | { 314 | unsigned char (*pf)(void); 315 | int n; 316 | 317 | 318 | pf = xfunc_in; /* Save current input device */ 319 | xfunc_in = func; /* Switch input to specified device */ 320 | n = xgets(buff, len); /* Get a line */ 321 | xfunc_in = pf; /* Restore input device */ 322 | 323 | return n; 324 | } 325 | 326 | 327 | /*----------------------------------------------*/ 328 | /* Get a value of the string */ 329 | /*----------------------------------------------*/ 330 | /* "123 -5 0x3ff 0b1111 0377 w " 331 | ^ 1st call returns 123 and next ptr 332 | ^ 2nd call returns -5 and next ptr 333 | ^ 3rd call returns 1023 and next ptr 334 | ^ 4th call returns 15 and next ptr 335 | ^ 5th call returns 255 and next ptr 336 | ^ 6th call fails and returns 0 337 | */ 338 | 339 | int xatoi ( /* 0:Failed, 1:Successful */ 340 | char **str, /* Pointer to pointer to the string */ 341 | long *res /* Pointer to the valiable to store the value */ 342 | ) 343 | { 344 | unsigned long val; 345 | unsigned char c, r, s = 0; 346 | 347 | 348 | *res = 0; 349 | 350 | while ((c = **str) == ' ') (*str)++; /* Skip leading spaces */ 351 | 352 | if (c == '-') { /* negative? */ 353 | s = 1; 354 | c = *(++(*str)); 355 | } 356 | 357 | if (c == '0') { 358 | c = *(++(*str)); 359 | switch (c) { 360 | case 'x': /* hexdecimal */ 361 | r = 16; c = *(++(*str)); 362 | break; 363 | case 'b': /* binary */ 364 | r = 2; c = *(++(*str)); 365 | break; 366 | default: 367 | if (c <= ' ') return 1; /* single zero */ 368 | if (c < '0' || c > '9') return 0; /* invalid char */ 369 | r = 8; /* octal */ 370 | } 371 | } else { 372 | if (c < '0' || c > '9') return 0; /* EOL or invalid char */ 373 | r = 10; /* decimal */ 374 | } 375 | 376 | val = 0; 377 | while (c > ' ') { 378 | if (c >= 'a') c -= 0x20; 379 | c -= '0'; 380 | if (c >= 17) { 381 | c -= 7; 382 | if (c <= 9) return 0; /* invalid char */ 383 | } 384 | if (c >= r) return 0; /* invalid char for current radix */ 385 | val = val * r + c; 386 | c = *(++(*str)); 387 | } 388 | if (s) val = 0 - val; /* apply sign if needed */ 389 | 390 | *res = val; 391 | return 1; 392 | } 393 | 394 | #endif /* _USE_XFUNC_IN */ 395 | -------------------------------------------------------------------------------- /STM32F4_Discovery_demo/xprintf.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------*/ 2 | /* Universal string handler for user console interface (C)ChaN, 2011 */ 3 | /*------------------------------------------------------------------------*/ 4 | 5 | #ifndef _STRFUNC 6 | #define _STRFUNC 7 | 8 | #define _USE_XFUNC_OUT 1 /* 1: Use output functions */ 9 | #define _CR_CRLF 1 /* 1: Convert \n ==> \r\n in the output char */ 10 | 11 | #define _USE_XFUNC_IN 1 /* 1: Use input function */ 12 | #define _LINE_ECHO 1 /* 1: Echo back input chars in xgets function */ 13 | 14 | 15 | #if _USE_XFUNC_OUT 16 | #define xdev_out(func) xfunc_out = (void(*)(unsigned char))(func) 17 | extern void (*xfunc_out)(unsigned char); 18 | void xputc (char c); 19 | void xputs (const char* str); 20 | void xfputs (void (*func)(unsigned char), const char* str); 21 | void xprintf (const char* fmt, ...); 22 | void xsprintf (char* buff, const char* fmt, ...); 23 | void xfprintf (void (*func)(unsigned char), const char* fmt, ...); 24 | void put_dump (const void* buff, unsigned long addr, int len, int width); 25 | #define DW_CHAR sizeof(char) 26 | #define DW_SHORT sizeof(short) 27 | #define DW_LONG sizeof(long) 28 | #endif 29 | 30 | #if _USE_XFUNC_IN 31 | #define xdev_in(func) xfunc_in = (unsigned char(*)(void))(func) 32 | extern unsigned char (*xfunc_in)(void); 33 | int xgets (char* buff, int len); 34 | int xfgets (unsigned char (*func)(void), char* buff, int len); 35 | int xatoi (char** str, long* res); 36 | #endif 37 | 38 | #endif 39 | --------------------------------------------------------------------------------