David Smart
/
PUB_RA8875_TouchColors
An example program using the RA8875 Display controller with the touch-screen option.
Diff: main.cpp
- Revision:
- 1:47e5fbdb28f1
- Parent:
- 0:2b1669e97586
- Child:
- 3:45ef2ebfeebc
--- a/main.cpp Sun Dec 28 22:02:36 2014 +0000 +++ b/main.cpp Sun Dec 28 23:15:27 2014 +0000 @@ -21,6 +21,26 @@ return false; } +int GetScreenCapture(void) +{ + char fqfn[50]; + int i = 0; + + pc.printf("Screen Capture... "); + for (i=1; i< 100; i++) { + snprintf(fqfn, sizeof(fqfn), "/local/Screen%02d.bmp", i); + FILE * fh = fopen(fqfn, "rb"); + if (!fh) { + lcd.PrintScreen(0,0,480,272,fqfn); + pc.printf(" as /local/Screen%02d.bmp\r\n", i); + return i; + } else { + fclose(fh); // close this and try the next + } + } + return 0; +} + int main() { pc.baud(460800); // I like a snappy terminal, so crank it up! @@ -32,7 +52,7 @@ lcd.cls(); // +----------------------------------------------------+ - // | (x,y) (xxx,yyy) rgb (RR,GG,BB) | + // | (x,y) (xxx,yyy) [Capture] rgb (RR,GG,BB) | // | +------------------------------------------------+ | y = 50 // | | Sample Shown Here | | // | +------------------------------------------------+ | y = 89 @@ -53,9 +73,15 @@ { 10,200, 470,239 }, // B { 10, 50, 470, 89 } // This for the Sample }; + rect_t PrintScreenRect = { 235-30, 5, 235+30, 40}; lcd.fillrect(RGBList[0], Red); lcd.fillrect(RGBList[1], Green); lcd.fillrect(RGBList[2], Blue); + lcd.fillrect(PrintScreenRect, Gray); + lcd.foreground(Blue); + lcd.background(Gray); + lcd.puts(235-28, 15, "Capture"); + lcd.background(Black); color_t rgb = Black; uint8_t rgbVal[3] = { 0, 0, 0 }; @@ -67,6 +93,9 @@ lcd.SetTextCursor(10, 15); lcd.printf("(%3d,%3d)", p.x, p.y); + if (Intersect(PrintScreenRect, p)) { + GetScreenCapture(); + } for (int i=0; i<3; i++) { if (Intersect(RGBList[i], p)) { uint8_t mag = (255 * (p.x - RGBList[i].p1.x)) / (RGBList[i].p2.x - RGBList[i].p1.x);