update Library and Demo Animation.
Dependencies: TFT_fonts mbed sharp_mlcd
Fork of Sharp_Memory_LCD_Test by
Diff: main.cpp
- Revision:
- 2:4d25eab8bff6
- Parent:
- 0:eb868b2d7042
diff -r 443ce3a02a88 -r 4d25eab8bff6 main.cpp --- a/main.cpp Sun May 11 14:16:10 2014 +0000 +++ b/main.cpp Sat Sep 13 05:52:33 2014 +0000 @@ -3,8 +3,13 @@ #include "Arial12x12.h" +#if defined(TARGET_NUCLEO_L152RE) sharp_mlcd lcd("LCD"); Serial pc(USBTX, USBRX); +#else +sharp_mlcd lcd(D11, D13, D2, D4, D5, "LCD"); +Serial pc(USBTX, USBRX); +#endif const static char mbedlogo128x48[768] @@ -70,6 +75,10 @@ const char target[] = #if defined(TARGET_NUCLEO_L152RE) "STM32 Nucleo L152RE" +#elif defined(TARGET_KL46Z) +"Freescale FRDM-KL46Z" +#elif defined(TARGET_KL25Z) +"Freescale FRDM-KL25Z" #elif defined(TARGET_KL05Z) "Freescale FRDM-KL05Z" #else @@ -77,6 +86,15 @@ #endif ; +#include "picture.h" +extern const uint8_t picture[]; +const struct Bitmap pic = { + 400, + 240, + 400/8, + (char*)picture, +}; + Ticker timer; void attime() { @@ -108,21 +126,21 @@ (char*)logo16_glcd_bmp, }; -#define NUMFLAKES 16 +#define NUMFLAKES 48 #define XPOS 0 #define YPOS 1 #define DELTAY 2 void testdrawbitmap(struct Bitmap bitmap) { - uint8_t icons[NUMFLAKES][3]; + int16_t icons[NUMFLAKES][3]; srand((unsigned int)time(NULL)); // srandom(666); // whatever seed int i; // initialize for (uint8_t f=0; f< NUMFLAKES; f++) { - icons[f][XPOS] = rand() % lcd.width(); // display.width(); - icons[f][YPOS] = 0; - icons[f][DELTAY] = rand() % 5 + 1; + icons[f][XPOS] = (rand() % (lcd.width() + bitmap.xSize)) - bitmap.xSize / 2; + icons[f][YPOS] = (rand() % (lcd.height() + bitmap.ySize)) - bitmap.ySize; + icons[f][DELTAY] = rand() % 5 + 2; #if 0 Serial.print("x: "); Serial.print(icons[f][XPOS], DEC); @@ -140,7 +158,7 @@ lcd.print_bm(bitmap, icons[f][XPOS], icons[f][YPOS], 1); } lcd.copy_to_lcd(); - wait(0.2); // delay(200); + //wait_ms(200); // delay(200); // then erase it + move it for (uint8_t f=0; f< NUMFLAKES; f++) { @@ -149,9 +167,9 @@ icons[f][YPOS] += icons[f][DELTAY]; // if its gone, reinit if (icons[f][YPOS] > lcd.height()) { // display.height()) { - icons[f][XPOS] = rand() % lcd.width(); // display.width(); - icons[f][YPOS] = 0; - icons[f][DELTAY] = rand() % 5 + 1; + icons[f][XPOS] = (rand() % (lcd.width() + bitmap.xSize)) - bitmap.xSize / 2; + icons[f][YPOS] = -bitmap.ySize; + icons[f][DELTAY] = rand() % 5 + 2; } } if (i++ > 100) break; @@ -161,15 +179,15 @@ void testdrawline() { - for (int16_t i=0; i<lcd.width(); i+=4) { + for (int16_t i=0; i<lcd.width(); i+=7) { lcd.line(0, 0, i, lcd.height()-1, 1); lcd.copy_to_lcd(); } - for (int16_t i=0; i<lcd.height(); i+=4) { + for (int16_t i=1; i<lcd.height(); i+=7) { lcd.line(0, 0, lcd.width()-1, i, 1); lcd.copy_to_lcd(); } - wait(0.25); // delay(250); + wait_ms(150); // delay(150); #if 0 lcd.cls(); for (int16_t i=0; i<lcd.width(); i+=4) { @@ -180,7 +198,7 @@ lcd.line(0, lcd.height()-1, lcd.width()-1, i, 1); lcd.copy_to_lcd(); } - wait(0.25); // delay(250); + wait_ms(150); // delay(150); lcd.cls(); for (int16_t i=lcd.width()-1; i>=0; i-=4) { @@ -191,7 +209,7 @@ lcd.line(lcd.width()-1, lcd.height()-1, 0, i, 1); lcd.copy_to_lcd(); } - wait(0.25); // delay(250); + wait_ms(150); // delay(150); lcd.cls(); for (int16_t i=0; i<lcd.height(); i+=4) { @@ -202,7 +220,7 @@ lcd.line(lcd.width()-1, 0, i, lcd.height()-1, 1); lcd.copy_to_lcd(); } - wait(0.25); + wait_ms(250); #endif } @@ -216,22 +234,77 @@ while (1) { lcd.cls(); lcd.locate(0,0); - pc.printf("\r\n %s!\r\n This is Sharp Memory LCD demo.", target); - lcd.printf("\r\n %s!\r\n This is Sharp Memory LCD demo.", target); - wait(1); + pc.printf("\r\n %s!\r\n This is Sharp Memory LCD demo.", target); + lcd.printf("\r\n %s!\r\n This is Sharp Memory LCD demo.", target); + lcd.printf("\r\n\r\n columns: %d rows: %d", lcd.columns(), lcd.rows()); + + lcd.print_bm(logo, 260, 178, 1); + lcd.locate(260,172); + lcd.printf("Powerd by"); + + lcd.copy_to_lcd(); + + wait_ms(1000); + lcd.line(0, 0, lcd.width()-1, 0, 1); + lcd.copy_to_lcd(); + + wait_ms(1000); + lcd.line(lcd.width()-1, 0, lcd.width()-1, lcd.height()-1, 1); + lcd.copy_to_lcd(); + + wait_ms(1000); + lcd.line(0, lcd.height()-1, lcd.width()-1, lcd.height()-1, 1); + lcd.copy_to_lcd(); + + wait_ms(1000); + lcd.line(0, 0, 0, lcd.height()-1, 1); + lcd.copy_to_lcd(); + + wait_ms(3000); + + lcd.cls(); + + lcd.locate(0,0); + lcd.printf("Copyright (c) 2014 Masato YAMANISHI or more authors, MIT License\r\n"); lcd.copy_to_lcd(); wait_ms(50); + lcd.printf("\r\n"); lcd.copy_to_lcd(); wait_ms(50); + lcd.printf("Permission is hereby granted, free of charge, to any person obtaining a copy of this software "); lcd.copy_to_lcd(); wait_ms(50); + lcd.printf("and associated documentation files (the \"Software\"), to deal in the Software without restriction, "); lcd.copy_to_lcd(); wait_ms(50); + lcd.printf("including without limitation the rights to use, copy, modify, merge, publish, distribute, "); lcd.copy_to_lcd(); wait_ms(50); + lcd.printf("sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is "); lcd.copy_to_lcd(); wait_ms(50); + lcd.printf("furnished to do so, subject to the following conditions:\r\n"); lcd.copy_to_lcd(); wait_ms(50); + lcd.printf("\r\n"); lcd.copy_to_lcd(); wait_ms(50); + lcd.printf("The above copyright notice and this permission notice shall be included in all copies or "); lcd.copy_to_lcd(); wait_ms(50); + lcd.printf("substantial portions of the Software.\r\n"); lcd.copy_to_lcd(); wait_ms(50); + lcd.printf("\r\n"); lcd.copy_to_lcd(); wait_ms(50); + lcd.printf("THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING "); lcd.copy_to_lcd(); wait_ms(50); + lcd.printf("BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND "); lcd.copy_to_lcd(); wait_ms(50); + lcd.printf("NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, "); lcd.copy_to_lcd(); wait_ms(50); + lcd.printf("DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, "); lcd.copy_to_lcd(); wait_ms(50); + lcd.printf("OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE."); lcd.copy_to_lcd(); wait_ms(50); + + lcd.copy_to_lcd(); + + wait_ms(5000); + + lcd.print_bm(pic, 0, 0, 0); + lcd.copy_to_lcd(); + + wait_ms(3000); + + for (int i=0; i<240+1; i+=2) { + lcd.copy_to_lcd(i); + } + + wait_ms(5000); + lcd.cls(); testdrawline(); - wait(1); + + wait_ms(5000); + lcd.cls(); testdrawbitmap(snow); - wait(1); - lcd.cls(); - wait(1); - lcd.print_bm(logo, 0, 0, 1); - lcd.copy_to_lcd(); - lcd.printf("\r\n\r\n %s", target); - lcd.copy_to_lcd(); - - wait(10); + + wait_ms(5000); } }