Code to run the cheap 2.4" TFT made by mcufriend.com on the STM nucleo. No modifications required, this plugs into the arduino header.

Dependents:   ST7735_V2_STM32F407

Fork of TFTLCD_8bit by Thiha Electronics

Revision:
10:69571adcfad5
Parent:
9:58b328831d0a
Child:
12:d0978272a340
--- a/lcd_base.cpp	Fri Dec 07 16:14:13 2012 +0000
+++ b/lcd_base.cpp	Tue Dec 11 03:18:43 2012 +0000
@@ -71,7 +71,7 @@
     Activate();
     ClearXY();
     for ( int i = 0; i < ( ( _disp_width ) * ( _disp_height ) ); i++ )
-        WriteData( rgb );
+        SetPixelColor( rgb );
     Deactivate();
 }
 
@@ -85,7 +85,7 @@
 {
     Activate();
     SetXY( x, y, x, y );
-    WriteData( color == -1 ? _background :
+    SetPixelColor( color == -1 ? _background :
                     color == -2 ? _foreground : color );
     Deactivate();
 }
@@ -131,7 +131,7 @@
                 for ( int i = x1; i >= x2; i-- )
                 {
                     SetXY( i, int( ty + 0.5 ), i, int( ty + 0.5 ) );
-                    WriteData( usedColor );
+                    SetPixelColor( usedColor );
                     ty = ty - delta;
                 }
             }
@@ -140,7 +140,7 @@
                 for ( int i = x1; i <= x2; i++ )
                 {
                     SetXY( i, int( ty + 0.5 ), i, int( ty + 0.5 ) );
-                    WriteData( usedColor );
+                    SetPixelColor( usedColor );
                     ty = ty + delta;
                 }
             }
@@ -154,7 +154,7 @@
                 for ( int i = y2 + 1; i > y1; i-- )
                 {
                     SetXY( int( tx + 0.5 ), i, int( tx + 0.5 ), i );
-                    WriteData( usedColor );
+                    SetPixelColor( usedColor );
                     tx = tx + delta;
                 }
             }
@@ -163,7 +163,7 @@
                 for ( int i = y1; i < y2 + 1; i++ )
                 {
                     SetXY( int( tx + 0.5 ), i, int( tx + 0.5 ), i );
-                    WriteData( usedColor );
+                    SetPixelColor( usedColor );
                     tx = tx + delta;
                 }
             }
@@ -265,13 +265,13 @@
 
     Activate();
     SetXY( x, y + radius, x, y + radius );
-    WriteData( usedColor );
+    SetPixelColor( usedColor );
     SetXY( x, y - radius, x, y - radius );
-    WriteData( usedColor );
+    SetPixelColor( usedColor );
     SetXY( x + radius, y, x + radius, y );
-    WriteData( usedColor );
+    SetPixelColor( usedColor );
     SetXY( x - radius, y, x - radius, y );
-    WriteData( usedColor );
+    SetPixelColor( usedColor );
 
     while ( x1 < y1 )
     {
@@ -285,21 +285,21 @@
         ddF_x += 2;
         f += ddF_x;
         SetXY( x + x1, y + y1, x + x1, y + y1 );
-        WriteData( usedColor );
+        SetPixelColor( usedColor );
         SetXY( x - x1, y + y1, x - x1, y + y1 );
-        WriteData( usedColor );
+        SetPixelColor( usedColor );
         SetXY( x + x1, y - y1, x + x1, y - y1 );
-        WriteData( usedColor );
+        SetPixelColor( usedColor );
         SetXY( x - x1, y - y1, x - x1, y - y1 );
-        WriteData( usedColor );
+        SetPixelColor( usedColor );
         SetXY( x + y1, y + x1, x + y1, y + x1 );
-        WriteData( usedColor );
+        SetPixelColor( usedColor );
         SetXY( x - y1, y + x1, x - y1, y + x1 );
-        WriteData( usedColor );
+        SetPixelColor( usedColor );
         SetXY( x + y1, y - x1, x + y1, y - x1 );
-        WriteData( usedColor );
+        SetPixelColor( usedColor );
         SetXY( x - y1, y - x1, x - y1, y - x1 );
-        WriteData( usedColor );
+        SetPixelColor( usedColor );
     }
     Deactivate();
 }
@@ -313,7 +313,7 @@
             if ( x1 * x1 + y1 * y1 <= radius * radius )
             {
                 SetXY( x + x1, y + y1, x + x1, y + y1 );
-                WriteData( usedColor );
+                SetPixelColor( usedColor );
             }
     Deactivate();
 }
@@ -357,7 +357,7 @@
         {
             SetXY( x, y, x + sx - 1, y + sy - 1 );
             for ( tc = 0; tc < ( sx * sy ); tc++ )
-                WriteData( imgPixelData[ tc ] );
+                SetPixelColor( imgPixelData[ tc ] );
         }
         else
         {
@@ -365,7 +365,7 @@
             {
                 SetXY( x, y + ty, x + sx - 1, y + ty );
                 for ( tx = sx; tx >= 0; tx-- )
-                    WriteData( imgPixelData[ ( ty * sx ) + tx ] );
+                    SetPixelColor( imgPixelData[ ( ty * sx ) + tx ] );
             }
         }
     }
@@ -379,7 +379,7 @@
                 for ( tsy = 0; tsy < scale; tsy++ )
                     for ( tx = 0; tx < sx; tx++ )
                         for ( tsx = 0; tsx < scale; tsx++ )
-                            WriteData( imgPixelData[ ( ty * sx ) + tx ] );
+                            SetPixelColor( imgPixelData[ ( ty * sx ) + tx ] );
             }
         }
         else
@@ -391,7 +391,7 @@
                     SetXY( x, y + ( ty * scale ) + tsy, x + ( ( sx * scale ) - 1 ), y + ( ty * scale ) + tsy );
                     for ( tx = sx; tx >= 0; tx-- )
                         for ( tsx = 0; tsx < scale; tsx++ )
-                            WriteData( imgPixelData[ ( ty * sx ) + tx ] );
+                            SetPixelColor( imgPixelData[ ( ty * sx ) + tx ] );
                 }
             }
         }
@@ -417,7 +417,7 @@
                 newy = y + roy + ( ( ( ty - roy ) * cos( radian ) ) + ( ( tx - rox ) * sin( radian ) ) );
 
                 SetXY( newx, newy, newx, newy );
-                WriteData( imgPixelData[ ( ty * sx ) + tx ] );
+                SetPixelColor( imgPixelData[ ( ty * sx ) + tx ] );
             }
         Deactivate();
     }
@@ -496,7 +496,7 @@
     Activate();
     SetXY( x, y, x + len, y );
     for ( int i = 0; i < len + 1; i++ )
-        WriteData( usedColor );
+        SetPixelColor( usedColor );
     Deactivate();
 }
 
@@ -507,7 +507,7 @@
     Activate();
     SetXY( x, y, x, y + len );
     for ( int i = 0; i < len; i++ )
-        WriteData( usedColor );
+        SetPixelColor( usedColor );
     Deactivate();
 }
 
@@ -532,9 +532,9 @@
             for ( i = 0; i < 8; i++ )
             {
                 if ( ( ch & ( 1 << ( 7 - i ) ) ) != 0 )
-                    WriteData( usedColorFG );
+                    SetPixelColor( usedColorFG );
                 else
-                    WriteData( usedColorBG );
+                    SetPixelColor( usedColorBG );
             }
             temp++;
         }
@@ -552,9 +552,9 @@
                 for ( i = 0; i < 8; i++ )
                 {
                     if ( ( ch & ( 1 << i ) ) != 0 )
-                        WriteData( usedColorFG );
+                        SetPixelColor( usedColorFG );
                     else
-                        WriteData( usedColorBG );
+                        SetPixelColor( usedColorBG );
                 }
             }
             temp += ( _font.width / 8 );
@@ -590,9 +590,9 @@
                 SetXY( newx, newy, newx + 1, newy + 1 );
 
                 if ( ( ch & ( 1 << ( 7 - i ) ) ) != 0 )
-                    WriteData( usedColorFG );
+                    SetPixelColor( usedColorFG );
                 else
-                    WriteData( usedColorBG );
+                    SetPixelColor( usedColorBG );
             }
         }
         temp += ( _font.width / 8 );