Fork of David Smart's RA8875 library for the purpose of adding touch screen support
Fork of RA8875 by
Diff: RA8875.cpp
- Revision:
- 24:8ca861acf12d
- Parent:
- 23:a50ded45dbaf
- Child:
- 25:9556a3a9b7cc
--- a/RA8875.cpp Wed Jan 15 12:24:54 2014 +0000 +++ b/RA8875.cpp Fri Jan 17 02:10:18 2014 +0000 @@ -192,20 +192,39 @@ return noerror; } -RetCode_t RA8875::SetTextCursorControl(bool visible, bool blink) +RetCode_t RA8875::SetTextCursorControl(cursor_t cursor, bool blink) { unsigned char mwcr0 = ReadCommand(0x40) & 0x0F; // retain direction, auto-increase + unsigned char horz = 0; + unsigned char vert = 0; - mwcr0 |= 0x80; // text mode - if (visible) - mwcr0 |= 0x40; + mwcr0 |= 0x80; // text mode + if (cursor != NOCURSOR) + mwcr0 |= 0x40; // visible if (blink) - mwcr0 |= 0x20; + mwcr0 |= 0x20; // blink WriteCommand(0x40, mwcr0); // configure the cursor WriteCommand(0x41, 0x00); // close the graphics cursor - WriteCommand(0x44,0x1f); //The cursor flashing cycle - WriteCommand(0x4e,0x1f); //The cursor size - WriteCommand(0x4f,0x1f); //The cursor size + WriteCommand(0x44, 0x1f); // The cursor flashing cycle + switch (cursor) { + case IBEAM: + horz = 0x01; + vert = 0x1F; + break; + case UNDER: + horz = 0x07; + vert = 0x01; + break; + case BLOCK: + horz = 0x07; + vert = 0x1F; + break; + case NOCURSOR: + default: + break; + } + WriteCommand(0x4e, horz); // The cursor size horz + WriteCommand(0x4f, vert); // The cursor size vert return noerror; } @@ -277,7 +296,10 @@ WriteCommand(0x2D, y >> 8); } else { if (font == NULL) { - WriteCommand(0x40,0x80); + unsigned char mwcr0 = ReadCommand(0x40); + + if (mwcr0 & 0x80 == 0x00) + WriteCommand(0x40,0x80); WriteCommand(0x02); select(true); WriteData(c); @@ -861,6 +883,7 @@ // Clear ram image SetWindow(0,0, width(), height()); // Initialize to full screen + SetTextCursorControl(); foreground(Black); background(Black); cls(); @@ -918,7 +941,10 @@ void TextCursorTest(RA8875 & display, Serial & pc) { - const char * visCursor = "The cursor should be visible for this text."; + 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"; + const char * uCursor = "The Underscore cursor should be visible for this text, but it should not be blinking while writing this text.\r\n"; + const char * bCursor = "The Block cursor should be visible for this text, but it should not be blinking while writing this text.\r\n"; + const char * bbCursor = "The Blinking Block cursor should be visible for this text, and it should be blinking while writing this text.\r\n"; const char * p; pc.printf("Text Cursor Test\r\n"); @@ -929,13 +955,36 @@ display.puts(0,0, "Text Cursor Test."); // visible, non-blinking - display.SetTextCursorControl(true, false); - display.SetTextCursor(0,40); - p = visCursor; + display.SetTextCursor(0,20); + display.SetTextCursorControl(IBEAM, false); + p = iCursor; while (*p) { - display.putc(*p++); + display._putc(*p++); + wait_ms(100); + } + + display.SetTextCursorControl(UNDER, false); + p = uCursor; + while (*p) { + display._putc(*p++); wait_ms(100); } + + display.SetTextCursorControl(BLOCK, false); + p = bCursor; + while (*p) { + display._putc(*p++); + wait_ms(100); + } + + display.SetTextCursorControl(BLOCK, true); + p = bbCursor; + while (*p) { + display._putc(*p++); + wait_ms(100); + } + wait_ms(2000); + display.SetTextCursorControl(NOCURSOR, false); } void BacklightTest(RA8875 & display, Serial & pc, float ramptime)