Simple demo for the Raio RA8875 Based Display with a 4-wire SPI interface.

Dependencies:   mbed RA8875

RA8875 Based Display Controller

This page shows a simple demo program for a graphics library supporting a low cost display from buydisplay.com. While the module can be configured for support via I2C, 3-Wire SPI, 4-Wire SPI, 8-bit Parallel or 16-bit Parallel, the companion library only supports the 4-Wire SPI.

You can also find this display on the Components | RA8875 page.

Library

RA8875 Library

Display Pictures

While this image is sharp, the camera/lighting washed out the colors somewhat. /media/uploads/WiredHome/ra8875display.640x380.png

With careful study of the image below, you can see a number of solder-blob jumpers. These jumpers are described quite well in the manual, and configure the many different options. The specific unit shown here is the "entry point" model, it does not have touchscreen, SD card, extra Font memory, or the key pad interface. As you see in the top left, it is wired with an 8-signal ribbon cable (but note in the schematic that it only needs 6 as the two power and two ground are internally connected together in the module).

/media/uploads/WiredHome/ra8875displaymodulerr.jpg

Also note, that some configuration changes go beyond the jumpers. I decided to switch my configuration to 4-Wire SPI and had to remove R1, R2, and R3 (which were zero-ohm that shorted the SPI input pins to +v!). I also changed some of the solder-blob jumpers, but that was easy. Had I ordered the display with the support for 4-Wire SPI, that would not have been necessary.

Schematic

The library should be able to work with any SPI port, and the Chip Select pin is a simple DigitalOut pin, chosen from the unused pins on my baseboard.

/media/uploads/WiredHome/ra8875_display_schematic.png

Sample Program

#include "mbed.h"
#include "RA8875.h"

Serial pc(USBTX, USBRX);

int main()
{
    pc.baud(460800);    // I like a snappy terminal, so crank it up!
    pc.printf("\r\nRA8875 Test - Build " __DATE__ " " __TIME__ "\r\n");

    RA8875 lcd(p5, p6, p7, p12, NC, "tft");    // MOSI, MISO, SCK, /ChipSelect, /reset, name

    lcd.puts(0,0,
        "RA8875 lcd(p5, p6, p7, p12, NC, \"tft\");\r\n\r\n"
        "lcd.circle(       400,25,  25,  BrightRed);\r\n"
        "lcd.fillcircle(   400,25,  15,  RGB(128,255,128));\r\n"
        "lcd.ellipse(      440,75,  35,20, BrightBlue);\r\n"
        "lcd.fillellipse(  440,75,  25,10, Blue);\r\n"
        "lcd.triangle(     440,100, 475,110, 450,125, Magenta);\r\n"
        "lcd.filltriangle( 445,105, 467,111, 452,120, Cyan);\r\n"
        "lcd.rect(         400,130, 475,155,    Brown);\r\n"
        "lcd.fillrect(     405,135, 470,150,    Pink);\r\n"
        "lcd.roundrect(    410,160, 475,190, 10,8, Yellow);\r\n"
        "lcd.fillroundrect(415,165, 470,185,  5,3, Orange);\r\n"
        "lcd.line(         430,200, 460,230, RGB(0,255,0));\r\n"
        "for (i=0; i<=30; i+=5)\r\n"
        "    lcd.pixel(435+i,200+i, White);");

    lcd.circle(       400,25,  25,               BrightRed);
    lcd.fillcircle(   400,25,  15,               RGB(128,255,128));
    lcd.ellipse(      440,75,  35,20,            BrightBlue);
    lcd.fillellipse(  440,75,  25,10,            Blue);
    lcd.triangle(     440,100, 475,110, 450,125, Magenta);
    lcd.filltriangle( 445,105, 467,111, 452,120, Cyan);
    lcd.rect(         400,130, 475,155,          Brown);
    lcd.fillrect(     405,135, 470,150,          Pink);
    lcd.roundrect(    410,160, 475,190, 10,8,    Yellow);
    lcd.fillroundrect(415,165, 470,185,  5,3,    Orange);
    lcd.line(         430,200, 460,230,          RGB(0,255,0));
    for (i=0; i<=30; i+=5) 
        lcd.pixel(435+i,200+i, White);
    while (1)
        ;
}
Committer:
WiredHome
Date:
Sun Dec 28 21:56:03 2014 +0000
Revision:
3:ca6a1026c28e
Parent:
2:2076d9cc6db9
Child:
5:bb970d40cd7d
Child:
7:1002bb8871c0
Minor updates to match the RA8875 library updates.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
WiredHome 0:037b95a5cc85 1 #include "mbed.h"
WiredHome 0:037b95a5cc85 2
WiredHome 0:037b95a5cc85 3 #include "RA8875.h"
WiredHome 0:037b95a5cc85 4
WiredHome 0:037b95a5cc85 5
WiredHome 0:037b95a5cc85 6 Serial pc(USBTX, USBRX);
WiredHome 0:037b95a5cc85 7
WiredHome 0:037b95a5cc85 8 int main()
WiredHome 0:037b95a5cc85 9 {
WiredHome 2:2076d9cc6db9 10 int i;
WiredHome 3:ca6a1026c28e 11 Timer t;
WiredHome 3:ca6a1026c28e 12 float f = 10000000;
WiredHome 2:2076d9cc6db9 13
WiredHome 0:037b95a5cc85 14 pc.baud(460800); // I like a snappy terminal, so crank it up!
WiredHome 0:037b95a5cc85 15 pc.printf("\r\nRA8875 Test - Build " __DATE__ " " __TIME__ "\r\n");
WiredHome 0:037b95a5cc85 16
WiredHome 0:037b95a5cc85 17 pc.printf("Turning on display\r\n");
WiredHome 2:2076d9cc6db9 18 RA8875 lcd(p5, p6, p7, p12, NC, "tft"); // MOSI, MISO, SCK, /ChipSelect, /reset, name
WiredHome 2:2076d9cc6db9 19
WiredHome 3:ca6a1026c28e 20 t.start();
WiredHome 3:ca6a1026c28e 21 lcd.init();
WiredHome 3:ca6a1026c28e 22 lcd.frequency(f);
WiredHome 3:ca6a1026c28e 23 lcd.cls();
WiredHome 3:ca6a1026c28e 24 wait_ms(250);
WiredHome 3:ca6a1026c28e 25 uint32_t tStart = t.read_us();
WiredHome 2:2076d9cc6db9 26 lcd.puts(0,0,
WiredHome 3:ca6a1026c28e 27 "RA8875 lcd(p5, p6, p7, p12, NC, \"tft\");\r\n"
WiredHome 3:ca6a1026c28e 28 "lcd.init(true, 480,272,16);\r\n"
WiredHome 2:2076d9cc6db9 29 "lcd.circle( 400,25, 25, BrightRed);\r\n"
WiredHome 2:2076d9cc6db9 30 "lcd.fillcircle( 400,25, 15, RGB(128,255,128));\r\n"
WiredHome 2:2076d9cc6db9 31 "lcd.ellipse( 440,75, 35,20, BrightBlue);\r\n"
WiredHome 2:2076d9cc6db9 32 "lcd.fillellipse( 440,75, 25,10, Blue);\r\n"
WiredHome 2:2076d9cc6db9 33 "lcd.triangle( 440,100, 475,110, 450,125, Magenta);\r\n"
WiredHome 2:2076d9cc6db9 34 "lcd.filltriangle( 445,105, 467,111, 452,120, Cyan);\r\n"
WiredHome 2:2076d9cc6db9 35 "lcd.rect( 400,130, 475,155, Brown);\r\n"
WiredHome 2:2076d9cc6db9 36 "lcd.fillrect( 405,135, 470,150, Pink);\r\n"
WiredHome 2:2076d9cc6db9 37 "lcd.roundrect( 410,160, 475,190, 10,8, Yellow);\r\n"
WiredHome 2:2076d9cc6db9 38 "lcd.fillroundrect(415,165, 470,185, 5,3, Orange);\r\n"
WiredHome 2:2076d9cc6db9 39 "lcd.line( 430,200, 460,230, RGB(0,255,0));\r\n"
WiredHome 2:2076d9cc6db9 40 "for (i=0; i<=30; i+=5)\r\n"
WiredHome 2:2076d9cc6db9 41 " lcd.pixel(435+i,200+i, White);");
WiredHome 0:037b95a5cc85 42
WiredHome 2:2076d9cc6db9 43 lcd.circle( 400,25, 25, BrightRed);
WiredHome 2:2076d9cc6db9 44 lcd.fillcircle( 400,25, 15, RGB(128,255,128));
WiredHome 2:2076d9cc6db9 45 lcd.ellipse( 440,75, 35,20, BrightBlue);
WiredHome 2:2076d9cc6db9 46 lcd.fillellipse( 440,75, 25,10, Blue);
WiredHome 2:2076d9cc6db9 47 lcd.triangle( 440,100, 475,110, 450,125, Magenta);
WiredHome 2:2076d9cc6db9 48 lcd.filltriangle( 445,105, 467,111, 452,120, Cyan);
WiredHome 2:2076d9cc6db9 49 lcd.rect( 400,130, 475,155, Brown);
WiredHome 2:2076d9cc6db9 50 lcd.fillrect( 405,135, 470,150, Pink);
WiredHome 2:2076d9cc6db9 51 lcd.roundrect( 410,160, 475,190, 10,8, Yellow);
WiredHome 2:2076d9cc6db9 52 lcd.fillroundrect(415,165, 470,185, 5,3, Orange);
WiredHome 2:2076d9cc6db9 53 lcd.line( 430,200, 460,230, RGB(0,255,0));
WiredHome 2:2076d9cc6db9 54 for (i=0; i<=30; i+=5)
WiredHome 2:2076d9cc6db9 55 lcd.pixel(435+i,200+i, White);
WiredHome 3:ca6a1026c28e 56 uint32_t tEnd = t.read_us();
WiredHome 3:ca6a1026c28e 57 pc.printf("@ %4.2f MHz, elapsed time is %u usec.\r\n", (float)f/1000000, tEnd-tStart);
WiredHome 3:ca6a1026c28e 58
WiredHome 3:ca6a1026c28e 59 lcd.KeypadInit();
WiredHome 3:ca6a1026c28e 60 while(1) {
WiredHome 3:ca6a1026c28e 61 while(!lcd.readable())
WiredHome 3:ca6a1026c28e 62 ;
WiredHome 3:ca6a1026c28e 63 if (lcd.readable()) {
WiredHome 3:ca6a1026c28e 64 int k = lcd.getc();
WiredHome 3:ca6a1026c28e 65 pc.printf("key: %02X \r\n", k);
WiredHome 3:ca6a1026c28e 66 }
WiredHome 3:ca6a1026c28e 67 wait_ms(50);
WiredHome 3:ca6a1026c28e 68 }
WiredHome 0:037b95a5cc85 69 }