Demo of RA8875 TFT touch display on Freescale FRDM-K64F Forked from David Smart https://developer.mbed.org/users/WiredHome/
Dependencies: RA8875 menu SDFileSystem mbed
Fork of PUB_RA8875_mPaint by
Diff: main.cpp
- Revision:
- 5:3afc5780b966
- Parent:
- 3:3b214426761d
--- a/main.cpp Sat Jan 03 17:25:42 2015 +0000 +++ b/main.cpp Fri Oct 02 19:47:06 2015 +0000 @@ -33,8 +33,11 @@ #include "mbed.h" // tested with v92 #include "RA8875.h" // tested with v80 #include "menu.h" +#include "SDFileSystem.h" +#include "FATFileSystem.h" -//#define DEBUG "mPaint" + +#define DEBUG "mPaint" // ... // INFO("Stuff to show %d", var); // new-line is automatically appended // @@ -52,10 +55,14 @@ // Local File System: // - Store the touch screen calibration // - Capture works of art in BMP format. -LocalFileSystem local("local"); +// LocalFileSystem local("local"); +SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd"); // The display interface -RA8875 lcd(p5, p6, p7, p12, NC, "tft"); // MOSI, MISO, SCK, /ChipSelect, /reset, name +//RA8875 lcd(p5, p6, p7, p12, NC, "tft"); // MOSI, MISO, SCK, /ChipSelect, /reset, name +RA8875 lcd(PTD2, PTD3, PTD1, PTD0, NC, "tft"); // FRDM-K64F MOSI, MISO, SCK, /ChipSelect, /reset, name + + // A monitor port for the SW developer. Serial pc(USBTX, USBRX); @@ -192,7 +199,7 @@ (void)v; INFO("rebooting now..."); wait_ms(1000); - mbed_reset(); + NVIC_SystemReset(); // Software reset. return Menu::no_action; } Menu::post_fnc_action_t Edit(uint32_t v) @@ -260,7 +267,7 @@ r = lcd.TouchPanelCalibrate("Calibrate the touch panel", &matrix); INFO(" ret: %d", r); if (r == noerror) { - fh = fopen("/local/tpcal.cfg", "wb"); + fh = fopen("/sd/tpcal.cfg", "wb"); if (fh) { fwrite(&matrix, sizeof(tpMatrix_t), 1, fh); fclose(fh); @@ -279,7 +286,7 @@ FILE * fh; tpMatrix_t matrix; - fh = fopen("/local/tpcal.cfg", "rb"); + fh = fopen("/sd/tpcal.cfg", "rb"); if (fh) { fread(&matrix, sizeof(tpMatrix_t), 1, fh); fclose(fh); @@ -296,7 +303,8 @@ lcd.SelectDrawingLayer(CANVAS); lcd.cls(); lcd.foreground(Blue); - lcd.background(Black); + lcd.background(White); + lcd.Backlight_u8(255); } int GetScreenCapture(void) @@ -306,11 +314,11 @@ INFO("Screen Capture... "); for (i=1; i< 100; i++) { - snprintf(fqfn, sizeof(fqfn), "/local/Screen%02d.bmp", i); + snprintf(fqfn, sizeof(fqfn), "/sd/Screen%02d.bmp", i); FILE * fh = fopen(fqfn, "rb"); if (!fh) { lcd.PrintScreen(0,0,lcd.width(),lcd.height(),fqfn); - INFO(" as /local/Screen%02d.bmp", i); + INFO(" as /sd/Screen%02d.bmp", i); return i; } else { fclose(fh); // close this and try the next @@ -432,7 +440,7 @@ int main() { - pc.baud(460800); // I like a snappy terminal, so crank it up! + pc.baud(115200); // I like a snappy terminal, so crank it up! pc.printf("\r\nRA8875 Menu - Build " __DATE__ " " __TIME__ "\r\n"); INFO("Turning on display"); @@ -495,12 +503,15 @@ wait_ms(500); NVIC_SystemReset(); } +/* extern "C" void NMI_Handler() { printf("\r\n\r\nNMI Fault!\r\n"); wait_ms(500); NVIC_SystemReset(); } +*/ + extern "C" void MemManage_Handler() { printf("\r\n\r\nMemManage Fault!\r\n");