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 84:e102021864b5, committed 2015-01-12
- Comitter:
- WiredHome
- Date:
- Mon Jan 12 01:10:35 2015 +0000
- Parent:
- 83:7bad0068cca0
- Child:
- 85:022bba13c5c4
- Commit message:
- Added SetOrientation method, to orient the display in one of 0, 90, 180, 270. Removed a rotation parameter from the SetTextFontControl method.
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 Thu Jan 01 20:35:37 2015 +0000
+++ b/RA8875.cpp Mon Jan 12 01:10:35 2015 +0000
@@ -671,26 +671,55 @@
}
+RetCode_t RA8875::SetOrientation(RA8875::orientation_t angle)
+{
+ uint8_t fncr1Val = ReadCommand(0x22);
+ uint8_t dpcrVal = ReadCommand(0x20);
+
+ fncr1Val &= ~0x10; // remove the old direction bit
+ dpcrVal &= ~0x0C; // remove the old scan direction bits
+ switch (angle) {
+ case RA8875::normal:
+ //fncr1Val |= 0x10;
+ //dpcrVal |= 0x00;
+ break;
+ case RA8875::rotate_90:
+ fncr1Val |= 0x10;
+ dpcrVal |= 0x08;
+ break;
+ case RA8875::rotate_180:
+ //fncr1Val |= 0x00;
+ dpcrVal |= 0x0C;
+ break;
+ case RA8875::rotate_270:
+ fncr1Val |= 0x10;
+ dpcrVal |= 0x04;
+ break;
+ default:
+ return bad_parameter;
+ }
+ WriteCommand(0x22, fncr1Val);
+ return WriteCommand(0x20, dpcrVal);
+}
+
+
RetCode_t RA8875::SetTextFontControl(fill_t fillit,
- RA8875::font_angle_t angle,
RA8875::HorizontalScale hScale,
RA8875::VerticalScale vScale,
RA8875::alignment_t alignment)
{
if (hScale >= 1 && hScale <= 4 &&
vScale >= 1 && vScale <= 4) {
- unsigned char x = 0;
-
+ uint8_t fncr1Val = ReadCommand(0x22);
+
+ fncr1Val &= ~0x10; // do not disturbe the rotate flag
if (alignment == align_full)
- x |= 0x80;
+ fncr1Val |= 0x80;
if (fillit == NOFILL)
- x |= 0x40;
- if (angle == rotated)
- x |= 0x10;
- x |= ((hScale - 1) << 2);
- x |= ((vScale - 1) << 0);
- WriteCommand(0x22, x);
- return noerror;
+ fncr1Val |= 0x40;
+ fncr1Val |= ((hScale - 1) << 2);
+ fncr1Val |= ((vScale - 1) << 0);
+ return WriteCommand(0x22, fncr1Val);
} else {
return bad_parameter;
}
--- a/RA8875.h Thu Jan 01 20:35:37 2015 +0000
+++ b/RA8875.h Mon Jan 12 01:10:35 2015 +0000
@@ -171,12 +171,15 @@
ISO8859_4 ///< ISO8859-4 font
} font_t;
- /// font rotation selection
+ /// display orientation
typedef enum
{
- normal, ///< normal orientation
- rotated ///< rotated orientation
- } font_angle_t;
+ normal, ///< normal (landscape) orientation
+ rotate_0 = normal, ///< alternate to 'normal'
+ rotate_90, ///< rotated clockwise 90 degree
+ rotate_180, ///< rotated (clockwise) 180 degree
+ rotate_270, ///< rotated clockwise 270 degree
+ } orientation_t;
/// alignment
typedef enum
@@ -965,6 +968,45 @@
///
RetCode_t SetTextFont(font_t font = ISO8859_1);
+ /// Sets the display orientation.
+ ///
+ /// @note This command does not let you "merge" text onto an existing
+ /// image, since it reuses the memory for the new orientation.
+ /// Therefore, it is recommended that you issue a cls() prior
+ /// to sending text to the screen, or you end with a blended
+ /// image that is probably not as intended.
+ ///
+ /// @code
+ /// lcd.cls();
+ /// lcd.SetOrientation(RA8875::normal);
+ /// lcd.puts(30,30, "Normal Landscape");
+ /// wait_ms(2500);
+ ///
+ /// lcd.cls();
+ /// lcd.SetOrientation(RA8875::rotate_90);
+ /// lcd.puts(30,30, "Rotated 90 Text\r\n");
+ /// wait_ms(2500);
+ ///
+ /// lcd.cls();
+ /// lcd.SetOrientation(RA8875::rotate_180);
+ /// lcd.puts(30,30, "Rotated 180 Text\r\n");
+ /// wait_ms(2500);
+ ///
+ /// lcd.cls();
+ /// lcd.SetOrientation(RA8875::rotate_270);
+ /// lcd.puts(30,30, "Rotated 270 Text\r\n");
+ /// wait_ms(2500);
+ /// @endcode
+ ///
+ /// @param[in] angle defaults to normal, but can be rotated
+ /// - normal | rotate_0
+ /// - rotate_90 (clockwise)
+ /// - rotate_180
+ /// - rotate_270 (clockwise)
+ /// @returns success/failure code. @see RetCode_t.
+ ///
+ RetCode_t SetOrientation(orientation_t angle = normal);
+
/// Control the font behavior.
///
/// This command lets you make several modifications to any text that
@@ -974,13 +1016,16 @@
/// Default:
/// @li Full alignment disabled,
/// @li Font with Background color,
- /// @li Font in normal orientiation,
- /// @li Horizontal scale x 1
- /// @li Vertical scale x 1
- /// @li alignment
+ /// @li Font in normal orientiation, or rotated 90, 180, or 270 clockwise,
+ /// @li Horizontal scale x 1, 2, 3, or 4
+ /// @li Vertical scale x 1, 2, 3, or 4
+ ///
+ /// @note alignment is a special mode for the fonts, when mixing half and
+ /// full fonts on one presentation. 'align_full' starts each full
+ /// character on an even alignment. See section 7-4-7 of the RA8875
+ /// specification.
///
/// @param[in] fillit defaults to FILL, but can be NOFILL
- /// @param[in] angle defaults to normal, but can be rotated
/// @param[in] hScale defaults to 1, but can be 1, 2, 3, or 4,
/// and scales the font size by this amount.
/// @param[in] vScale defaults to 1, but can be 1, 2, 3, or 4,
@@ -993,7 +1038,6 @@
/// @returns success/failure code. @see RetCode_t.
///
RetCode_t SetTextFontControl(fill_t fillit = FILL,
- font_angle_t angle = normal,
HorizontalScale hScale = 1,
VerticalScale vScale = 1,
alignment_t alignment = align_none);
