Fork of https://os.mbed.com/users/sebastiken/code/Adafruit_RA8875/ ; Adapted for use with K64F and in the process of adding more functions.

Dependencies:   mbed

Revision:
3:4a3e169866a2
Parent:
2:040a687cea93
--- a/main.cpp	Fri Sep 08 16:30:24 2017 +0000
+++ b/main.cpp	Thu Mar 14 12:00:15 2019 +0000
@@ -1,78 +1,96 @@
 #include "RA8875.h"
-//#include "Adafruit_GFX.h"
 
-// Library only supports hardware SPI at this time
-// Connect SCLK to UNO Digital #13 (Hardware SPI clock)
-// Connect MISO to UNO Digital #12 (Hardware SPI MISO)
-// Connect MOSI to UNO Digital #11 (Hardware SPI MOSI)
-#define MOSI    PTD6
-#define MISO    PTD7
-#define SCLK    PTD5
-#define CS      PTD4
-#define RST     PTD2
+#define MOSI    PTD2
+#define MISO    PTD3
+#define SCLK    PTD1
+#define CS      PTD0
+#define RST     PTC4
+DigitalIn   INT(PTC12);
 
-
-Adafruit_RA8875 tft = Adafruit_RA8875(MOSI, MISO, SCLK, CS, RST);
+Adafruit_RA8875 lcd = Adafruit_RA8875(MOSI, MISO, SCLK, CS, RST);
 uint16_t tx, ty;
 
 Serial pc(USBTX, USBRX); // tx, rxSerial pc(USBTX, USBRX); // tx, rx
 
-int main() 
+void setup()
 {
-  pc.baud(9600);
-  pc.printf("RA8875 start\n");
+    pc.baud(9600);
+    pc.printf("RA8875 start\n");
+}
 
-  /* Initialise the display using 'RA8875_480x272' or 'RA8875_800x480' */
-  if (!tft.begin(RA8875_480x272)) {
-    pc.printf("RA8875 Not Found!\n");
-    while (1);
-  }
+int main()
+{
+    lcd.begin(RA8875_800x480);
+    lcd.displayOn(true);
+    lcd.GPIOX(true);      // Enable lcd - display enable tied to GPIOX
+    lcd.PWM1config(true, RA8875_PWM_CLK_DIV1024); // PWM output for backlight
+    lcd.PWM1out(255);
+    lcd.fillScreen(BLACK);
+    lcd.touchEnable(true);
 
-  tft.displayOn(true);
-  tft.GPIOX(true);      // Enable TFT - display enable tied to GPIOX
-  tft.PWM1config(true, RA8875_PWM_CLK_DIV1024); // PWM output for backlight
-  tft.PWM1out(255);
-  tft.fillScreen(RA8875_BLACK);
+    /* Render some text! */
+    lcd.textEnlarge(3);
+    lcd.textWritePro(10,30,WHITE,0,"Hello, Jacob! ");
+    lcd.textEnlarge(1.2);
+    lcd.textWritePro(10,150,WHITE,0, "I am finally working!");
+    lcd.textWritePro(10, 450, GREEN, 0, "Testing 1.. 2");
+    wait(2);
+    lcd.fillScreen(BLACK);
+    
+    lcd.graphicsMode();
+    lcd.rectHelper(0,0,800,480,WHITE,1);
+    lcd.rectHelper(5,5,794,474,BLACK,1);
+    
+    //lcd.boxDraw(0,0,400,400,10,GREEN,YELLOW);
+    lcd.boxDraw(10,10,459,459,10,GREY,ORANGE);
+    
+    
+//////// Drawing a line for a graph
 
-  /* Switch to text mode */  
-  tft.textMode();
-  
 
-  
-  /* Set a solid for + bg color ... */
-  
-  /* ... or a fore color plus a transparent background */
+    lcd.drawPixel(50,200,WHITE);
+    
+    
 
-  
-  /* Set the cursor location (in pixels) */
-  tft.textSetCursor(10, 10);
-  
-  /* Render some text! */
-  char string[] = "Hello, Nehuen! ";
-  tft.textTransparent(RA8875_WHITE);
-  tft.textWrite(string);
-  tft.textColor(RA8875_WHITE, RA8875_RED);
-  tft.textWrite(string);
-  tft.textTransparent(RA8875_CYAN);
-  tft.textWrite(string);
-  tft.textTransparent(RA8875_GREEN);
-  tft.textWrite(string);
-  tft.textColor(RA8875_YELLOW, RA8875_CYAN);
-  tft.textWrite(string);
-  tft.textColor(RA8875_BLACK, RA8875_MAGENTA);
-  tft.textWrite(string);
+    
+    
+    
+
+    /*
+    lcd.textColor(RA8875_WHITE, RA8875_RED);
+    lcd.textWrite(string);
+    lcd.textTransparent(RA8875_CYAN);
+    lcd.textWrite(string);
+    lcd.textTransparent(RA8875_GREEN);
+    lcd.textWrite(string);
+    lcd.textColor(RA8875_YELLOW, RA8875_CYAN);
+    lcd.textWrite(string);
+    //lcd.textColor(RA8875_BLACK, RA8875_MAGENTA);
+    lcd.textWrite(string);
+    */
+
+
+    //lcd.drawCircle(100, 100, 50, RA8875_RED);
+    //lcd.fillCircle(100, 100, 50, RA8875_RED);
 
-  /* Change the cursor location and color ... */  
-  //tft.textSetCursor(100, 100);
-  //tft.textTransparent(RA8875_RED);
-  /* If necessary, enlarge the font */
-  //tft.textEnlarge(1);
-  /* ... and render some more text! */
-  //tft.textWrite(string);
-  //tft.textSetCursor(100, 150);
-  //tft.textEnlarge(2);
-  //tft.textWrite(string);
-  
-  tft.drawCircle(100, 100, 50, RA8875_RED);
-  tft.fillCircle(100, 100, 50, RA8875_RED);
+    //lcd.fillCircle(200, 200, 50, RA8875_RED);
+
+
+    float xScale = 1024.0F/lcd.width();
+    float yScale = 1024.0F/lcd.height();
+    bool INT = 1;
+
+    /* Wait around for touch events */
+    while(1) {
+        if (INT == !1);
+        {
+            if (lcd.touched()) {
+                //Serial.print("Touch: ");
+                lcd.touchRead(&tx, &ty);
+                //Serial.print(tx); Serial.print(", "); Serial.println(ty);
+                /* Draw a circle */
+                lcd.fillCircle((uint16_t)(tx/xScale), (uint16_t)(ty/yScale), 1, WHITE);
+            }
+        }
+    }
 }
\ No newline at end of file