for Aitendo TFT LCD (M018C7735SPI)

Dependencies:   mbed

original http://mbed.org/users/smultron1977/code/SPI18TFT/

I'd changed for Aitendo TFT LCD(M018C7735SPI). see http://mbed.org/users/masato/notebook/aitendo-graphic-lcd-m018c7735spi/

http://mbed.org/users/smultron1977/code/SPI18TFT/ を使って Aitendo の TFT-LCD (M018C7735SPI)を動かしてみると、ちょっと不具合があったので適当にいじってみました。ついでに FRDM-KL25Z 用に 8bit SPI のみにしたのがこれ。テキストが切れることがあって原因を調べたところ、printf などが 通常の PC と同じく、非同期動作するためでした。必要に応じて flush すれば良いです。こちらのページに動作中の写真とかあります。http://mbed.org/users/masato/notebook/aitendo-graphic-lcd-m018c7735spi/

Revision:
1:2357c4706f32
Parent:
0:e32728270b5b
--- a/main.cpp	Tue Mar 19 13:21:59 2013 +0000
+++ b/main.cpp	Sat Feb 13 12:29:21 2016 +0000
@@ -1,20 +1,22 @@
- #include "stdio.h"
- #include "stdlib.h"
- #include "math.h"
- #include "mbed.h"
- #include "ST7735_TFT.h"
- #include "string"
- #include "Arial12x12.h"
+#include "stdio.h"
+#include "stdlib.h"
+#include "math.h"
+#include "mbed.h"
+#include "ST7735_TFT.h"
+#include "string"
+#include "Arial12x12.h"
 
- #define SCREEN_WIDTH 160
- #define SCREEN_HEIGHT 128
+#define SCREEN_WIDTH 160
+#define SCREEN_HEIGHT 128
  
  // Antendo M018C7735SPI TFT-LCD
  // with mbed LPC1768
  // the TFT is connected to SPI pin 5-7, CS is p8, RS is p11, reset is p15 
  // ST7735_TFT TFT(p5, p6, p7, p8, p11, p15, "TFT"); // mosi, miso, sclk, cs, rs, reset
  // with FRDM-KL25Z
- ST7735_TFT TFT(PTD2, PTD3, PTD1, PTC11, PTC12, PTC13, "TFT"); // PTA13, PTD5, PTD0, "TFT"); 
+ST7735_TFT TFT(PTD2, PTD3, PTD1, PTC11, PTC12, PTC13, "TFT"); // PTA13, PTD5, PTD0, "TFT"); 
+ // with FRDM-KL05Z
+ //  ST7735_TFT TFT(D11, D12, D13, D10, D9, D8, "TFT"); // PTA13, PTD5, PTD0, "TFT"); 
  /*
  ST7735_TFT(                    // for FRDM-KL25
     PinName mosi = SDA, // p5 9    // PTD2
@@ -36,20 +38,26 @@
 Timer t;
 
 extern const unsigned char p1[];  // the mbed logo
+extern const unsigned char p2[];
+extern "C" void mbed_reset();
  
 int main() {
     
     unsigned int centerx, centery;
     int i, j; // tempx, tempy;  
     // init();
+
+    // mbed_reset();
+    // __disable_irq();
+    
     TFT.set_orientation(1);
     centerx = TFT.width() >> 1;
     centery = TFT.height() >> 1; 
     TFT.claim(stdout);      // send stdout to the TFT display 
-    //TFT.claim(stderr);      // send stderr to the TFT display
+    // TFT.claim(stderr);      // send stderr to the TFT display
 
- while (1) {   
-    fprintf(stderr, "START\r\n");
+  while (1) {   
+    fprintf(stderr, "START %d %d\r\n", TFT.width(), TFT.height());
      
     TFT.background(White);    // set background to black
     TFT.foreground(Black);    // set chars to white
@@ -63,9 +71,9 @@
     // TFT.rect(0, 0, 4, 127, Blue);
     
     for (i = 0; i < SCREEN_HEIGHT; i+=8) 
-        TFT.line(0, i, SCREEN_WIDTH - 1, i, Red);
+        TFT.line(0, i, SCREEN_WIDTH - 1, i, DarkCyan);
     for (j = 0; j < SCREEN_WIDTH; j+=8)
-        TFT.line(j, 0, j, SCREEN_HEIGHT - 1, Blue);
+        TFT.line(j, 0, j, SCREEN_HEIGHT - 1, Orange);
         
     for (i = 0; i < SCREEN_HEIGHT; i++) 
         // for (j = 0; j < SCREEN_WIDTH; j++)
@@ -79,13 +87,18 @@
     TFT.Bitmap(centerx-64,centery-24,128,47,(unsigned char*)p1);
     // TFT.locate(76,100);
     // fprintf(stdout, "ss_ABC");
-    TFT.locate(24,100);
-    fprintf(stdout, "@n24bass_ABC");
+    TFT.locate(24,90);
+    fprintf(stdout, "@n24bass_ABCD"); // fflush(stdout);
+    wait(0.1);
+    TFT.locate(70,110);
+    fprintf(stdout, "@n24bass"); // fflush(stdout);
     // TFT.locate(76,100);
     // fprintf(stdout, "ss_ABC");
     // fprintf(stderr, "END\r\n");
+    wait(3);
+    TFT.Bitmap(0,0,160,128, (unsigned char*)p2);
     break;
-}
+ }
 #if USE_LED 
     while (1) {
         myled1 = 1;