Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of RA8875 by
Revision 25:9556a3a9b7cc, committed 2014-01-17
- Comitter:
- WiredHome
- Date:
- Fri Jan 17 03:16:51 2014 +0000
- Parent:
- 24:8ca861acf12d
- Child:
- 27:65f9f93b54dd
- Commit message:
- First copy for public viewing
Changed in this revision
| RA8875.cpp | Show annotated file Show diff for this revision Revisions of this file |
| RA8875.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/RA8875.cpp Fri Jan 17 02:10:18 2014 +0000
+++ b/RA8875.cpp Fri Jan 17 03:16:51 2014 +0000
@@ -647,30 +647,36 @@
return ret;
}
-RetCode_t RA8875::ellipse(unsigned int x, unsigned int y, unsigned int R1, unsigned int R2, color_t color, fill_t fillit)
+RetCode_t RA8875::ellipse(unsigned int x, unsigned int y, unsigned int radius1, unsigned int radius2, color_t color, fill_t fillit)
{
foreground(color);
- return ellipse(x,y,R1,R2,fillit);
+ return ellipse(x,y,radius1,radius2,fillit);
}
-RetCode_t RA8875::ellipse(unsigned int x, unsigned int y, unsigned int R1, unsigned int R2, fill_t fillit)
+RetCode_t RA8875::fillellipse(unsigned int x, unsigned int y, unsigned int radius1, unsigned int radius2, color_t color, fill_t fillit)
+{
+ foreground(color);
+ return ellipse(x,y,radius1,radius2,fillit);
+}
+
+RetCode_t RA8875::ellipse(unsigned int x, unsigned int y, unsigned int radius1, unsigned int radius2, fill_t fillit)
{
RetCode_t ret = noerror;
PERFORMANCE_RESET;
- if (R1 <= 0 || R2 <= 0) {
+ if (radius1 <= 0 || radius2 <= 0) {
; // do nothing
- } else if (R1 == 1 && R2 == 1) {
+ } else if (radius1 == 1 && radius2 == 1) {
pixel(x, y);
} else {
WriteCommand(0xA5, x & 0xFF);
WriteCommand(0xA6, x >> 8);
WriteCommand(0xA7, y & 0xFF);
WriteCommand(0xA8, y >> 8);
- WriteCommand(0xA1, R1 & 0xFF);
- WriteCommand(0xA2, R1 >> 8);
- WriteCommand(0xA3, R2 & 0xFF);
- WriteCommand(0xA4, R2 >> 8);
+ WriteCommand(0xA1, radius1 & 0xFF);
+ WriteCommand(0xA2, radius1 >> 8);
+ WriteCommand(0xA3, radius2 & 0xFF);
+ WriteCommand(0xA4, radius2 >> 8);
unsigned char drawCmd = 0x00; // Ellipse
if (fillit == FILL)
@@ -903,42 +909,6 @@
//
// Everything from here down is test code.
-void ValentineMessage(RA8875 & display, Serial & pc)
-{
- pc.printf("Write Sample text\r\n");
- display.background(BrightRed);
- display.foreground(White);
- display.cls();
- display.SetTextFontControl(NOFILL);
- for (int i=0; i<20 ; i++) {
- int sz = rand() & 1 + 1;
- int rx = rand() % 360 + 0;
- int ry = rand() % 250 + 0;
- if (sz == 1)
- rx /= 2;
- display.SetTextCursor(rx, ry);
- display.SetTextFontSize(sz, sz);
- display.puts("David loves Louize");
- wait_ms(50);
- }
- display.SetTextFontSize(2,2);
- wait_ms(1000);
- // Make a heart shape
- display.ellipse(300, 120, 40, 50, FILL);
- display.ellipse(370, 120, 40, 50, FILL);
- display.triangle(265,145, 405,145, 335,230, FILL);
- wait_ms(2500);
- display.foreground(Blue);
- display.puts(300,90, "Be My");
- wait_ms(500);
- display.puts(262,118, "Valentine");
- // put a few things back the way they were
- display.SetTextFontControl(FILL);
- display.SetTextFontSize(1,1);
- display.background(Black);
-}
-
-
void TextCursorTest(RA8875 & display, Serial & pc)
{
const char * iCursor = "The I-Beam cursor should be visible for this text, but it should not be blinking while writing this text.\r\n";
@@ -948,10 +918,10 @@
const char * p;
pc.printf("Text Cursor Test\r\n");
- display.Backlight_u8(255);
display.background(Black);
display.foreground(Blue);
display.cls();
+ display.Backlight_u8(255);
display.puts(0,0, "Text Cursor Test.");
// visible, non-blinking
@@ -1277,8 +1247,7 @@
"R - Rectangles O - rOund rectangles\r\n"
"T - Triangles \r\n"
"C - Circles E - Ellipses\r\n"
- "V - Valentine r - reset \r\n"
- "A - Auto Test mode \r\n"
+ "A - Auto Test mode r - reset \r\n"
"> ");
if (automode == -1 || pc.readable()) {
automode = -1;
@@ -1326,9 +1295,6 @@
case 'E':
EllipseTest(lcd, pc);
break;
- case 'V':
- ValentineMessage(lcd, pc);
- break;
case 'r':
pc.printf("Resetting ...\r\n");
wait_ms(20);
--- a/RA8875.h Fri Jan 17 02:10:18 2014 +0000
+++ b/RA8875.h Fri Jan 17 03:16:51 2014 +0000
@@ -4,7 +4,7 @@
#include "GraphicsDisplay.h"
-#define RA8875_DEFAULT_SPI_FREQ 1000000
+#define RA8875_DEFAULT_SPI_FREQ 2000000
// Define this to enable code that monitors the performance of various
// graphics commands.
@@ -12,7 +12,7 @@
// What better place for some test code than in here and the companion
// .cpp file. See also the bottom of this file.
-#define TESTENABLE
+//#define TESTENABLE
#define RGB(r,g,b) ( ((r<<8)&0xF800) | ((g<<3)&0x07E0) | (b>>3) )
@@ -693,6 +693,22 @@
RetCode_t ellipse(unsigned int x, unsigned int y, unsigned int radius1, unsigned int radius1,
color_t color, fill_t fillit = NOFILL);
+ /// Draw a filled Ellipse using the specified color
+ ///
+ /// @note As a side effect, this changes the current
+ /// foreground color for subsequent operations.
+ ///
+ /// @param x is the horizontal center of the ellipse.
+ /// @param y is the vertical center of the ellipse.
+ /// @param radius1 defines the horizontal radius of the ellipse.
+ /// @param radius2 defines the vertical radius of the ellipse.
+ /// @param color defines the foreground color.
+ /// @param fillit defines whether the circle is filled or not.
+ /// @returns success/failure code. @see RetCode_t.
+ ///
+ RetCode_t fillellipse(unsigned int x, unsigned int y, unsigned int radius1, unsigned int radius1,
+ color_t color, fill_t fillit = FILL);
+
/// Draw an Ellipse
///
/// Draws it using the foreground color setting.
