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.
Revision 131:5bd6ba2ee4a1, committed 2016-08-12
- Comitter:
- WiredHome
- Date:
- Fri Aug 12 11:30:33 2016 +0000
- Parent:
- 130:d633e80840e0
- Child:
- 132:a5d7a8541683
- Child:
- 138:61e93bed397e
- Commit message:
- Added API for BlockMove, and a minor revision to the init to accept a backlight setting directly.
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 Sat Aug 06 22:44:49 2016 +0000
+++ b/RA8875.cpp Fri Aug 12 11:30:33 2016 +0000
@@ -141,7 +141,7 @@
//{
//}
-RetCode_t RA8875::init(int width, int height, int color_bpp, bool poweron, bool keypadon, bool touchscreenon)
+RetCode_t RA8875::init(int width, int height, int color_bpp, uint8_t poweron, bool keypadon, bool touchscreenon)
{
font = NULL; // no external font, use internal.
pKeyMap = DefaultKeyMap; // set default key map
@@ -198,8 +198,7 @@
cls(3);
Power(poweron);
- if (poweron)
- Backlight_u8(255);
+ Backlight_u8(poweron);
if (keypadon)
KeypadInit();
if (touchscreenon) {
@@ -486,6 +485,22 @@
}
+bool RA8875::Intersect(rect_t rect1, rect_t rect2)
+{
+ point_t bl, tr;
+
+ bl.x = rect2.p1.x;
+ bl.y = rect2.p2.y;
+ tr.x = rect2.p2.x;
+ tr.y = rect2.p1.y;
+ if (Intersect(rect1, rect2.p1) || Intersect(rect1, rect2.p2)
+ || Intersect(rect1, bl) || Intersect(rect1, tr))
+ return true;
+ else
+ return false;
+}
+
+
RetCode_t RA8875::WriteCommandW(uint8_t command, uint16_t data)
{
@@ -1095,7 +1110,10 @@
{
PERFORMANCE_RESET;
WriteCommand(0x8E, (region == ACTIVEWINDOW) ? 0xC0 : 0x80);
- _WaitWhileReg(0x8E, 0x80);
+ if (!_WaitWhileReg(0x8E, 0x80)) {
+ REGISTERPERFORMANCE(PRF_CLS);
+ return external_abort;
+ }
REGISTERPERFORMANCE(PRF_CLS);
return noerror;
}
@@ -1281,7 +1299,10 @@
unsigned char drawCmd = 0x00; // Line
WriteCommand(0x90, drawCmd);
WriteCommand(0x90, 0x80 + drawCmd); // Start drawing.
- _WaitWhileReg(0x90, 0x80);
+ if (!_WaitWhileReg(0x90, 0x80)) {
+ REGISTERPERFORMANCE(PRF_DRAWLINE);
+ return external_abort;
+ }
}
REGISTERPERFORMANCE(PRF_DRAWLINE);
return noerror;
@@ -1340,7 +1361,10 @@
drawCmd |= 0x20;
WriteCommand(0x90, drawCmd);
ret = WriteCommand(0x90, 0x80 + drawCmd); // Start drawing.
- _WaitWhileReg(0x90, 0x80);
+ if (!_WaitWhileReg(0x90, 0x80)) {
+ REGISTERPERFORMANCE(PRF_DRAWRECTANGLE);
+ return external_abort;
+ }
}
}
REGISTERPERFORMANCE(PRF_DRAWRECTANGLE);
@@ -1409,7 +1433,10 @@
drawCmd |= 0x40;
WriteCommand(0xA0, drawCmd);
WriteCommand(0xA0, 0x80 + drawCmd); // Start drawing.
- _WaitWhileReg(0xA0, 0x80);
+ if (!_WaitWhileReg(0xA0, 0x80)) {
+ REGISTERPERFORMANCE(PRF_DRAWROUNDEDRECTANGLE);
+ return external_abort;
+ }
}
REGISTERPERFORMANCE(PRF_DRAWROUNDEDRECTANGLE);
return ret;
@@ -1465,7 +1492,10 @@
drawCmd |= 0x20;
WriteCommand(0x90, drawCmd);
WriteCommand(0x90, 0x80 + drawCmd); // Start drawing.
- _WaitWhileReg(0x90, 0x80);
+ if (!_WaitWhileReg(0x90, 0x80)) {
+ REGISTERPERFORMANCE(PRF_DRAWTRIANGLE);
+ return external_abort;
+ }
}
REGISTERPERFORMANCE(PRF_DRAWTRIANGLE);
return ret;
@@ -1529,7 +1559,10 @@
drawCmd |= 0x20;
WriteCommand(0x90, drawCmd);
WriteCommand(0x90, 0x40 + drawCmd); // Start drawing.
- _WaitWhileReg(0x90, 0x40);
+ if (!_WaitWhileReg(0x90, 0x40)) {
+ REGISTERPERFORMANCE(PRF_DRAWCIRCLE);
+ return external_abort;
+ }
}
REGISTERPERFORMANCE(PRF_DRAWCIRCLE);
return ret;
@@ -1570,7 +1603,10 @@
drawCmd |= 0x40;
WriteCommand(0xA0, drawCmd);
WriteCommand(0xA0, 0x80 + drawCmd); // Start drawing.
- _WaitWhileReg(0xA0, 0x80);
+ if (!_WaitWhileReg(0xA0, 0x80)) {
+ REGISTERPERFORMANCE(PRF_DRAWELLIPSE);
+ return external_abort;
+ }
}
REGISTERPERFORMANCE(PRF_DRAWELLIPSE);
return ret;
@@ -1604,6 +1640,38 @@
}
}
+
+
+RetCode_t RA8875::BlockMove(uint8_t dstLayer, uint8_t dstDataSelect, point_t dstPoint,
+ uint8_t srcLayer, uint8_t srcDataSelect, point_t srcPoint,
+ uint16_t bte_width, uint16_t bte_height,
+ uint8_t bte_op_code, uint8_t bte_rop_code)
+{
+ uint8_t cmd;
+
+ PERFORMANCE_RESET;
+ srcPoint.x &= 0x3FF; // prevent high bits from doing unexpected things
+ srcPoint.y &= 0x1FF;
+ dstPoint.x &= 0x3FF;
+ dstPoint.y &= 0x1FF;
+ WriteCommandW(0x54, srcPoint.x);
+ WriteCommandW(0x56, ((srcLayer & 1) << 7) | srcPoint.y);
+ WriteCommandW(0x58, dstPoint.x);
+ WriteCommandW(0x5A, ((dstLayer & 1) << 7) | dstPoint.y);
+ WriteCommandW(0x5C, bte_width);
+ WriteCommandW(0x5E, bte_height);
+ WriteCommand(0x51, ((bte_rop_code & 0x0F) << 4) | (bte_op_code & 0x0F));
+ cmd = ((srcDataSelect & 1) << 6) | ((dstDataSelect & 1) << 5);
+ WriteCommand(0x50, 0x80 | cmd); // enable the BTE
+ if (!_WaitWhileBusy(0x40)) {
+ REGISTERPERFORMANCE(PRF_BLOCKMOVE);
+ return external_abort;
+ }
+ REGISTERPERFORMANCE(PRF_BLOCKMOVE);
+ return noerror;
+}
+
+
RetCode_t RA8875::Power(bool on)
{
WriteCommand(0x01, (on) ? 0x80 : 0x00);
@@ -1611,9 +1679,10 @@
}
-RetCode_t RA8875::Backlight_u8(unsigned char brightness)
+RetCode_t RA8875::Backlight_u8(uint8_t brightness)
{
static bool is_enabled = false;
+
if (brightness == 0) {
WriteCommand(0x8a); // Disable the PWM
WriteData(0x00);
--- a/RA8875.h Sat Aug 06 22:44:49 2016 +0000
+++ b/RA8875.h Fri Aug 12 11:30:33 2016 +0000
@@ -507,9 +507,9 @@
/// @param[in] color_bpp can be either 8 or 16, but must be consistent
/// with the width and height parameters. This parameter is optional
/// and the default is 16.
- /// @param[in] poweron defines if the display should be left in the power-on or off state.
- /// If power is true (on), the backlight is set to 100%. This parameter is optional
- /// and the default is true (on). See @ref Power.
+ /// @param[in] poweron defines if the display should be initialized into the power-on or off state.
+ /// If power is non-zero(on), the backlight is set to this vale. This parameter is optional
+ /// and the default is 255 (on and full brightness). See @ref Power.
/// @param[in] keypadon defines if the keypad support should be enabled. This parameter is optional
/// and the default is true (enabled). See @ref KeypadInit.
/// @param[in] touchscreeenon defines if the touchscreen support should be enabled.
@@ -521,7 +521,7 @@
/// @returns success/failure code. See @ref RetCode_t.
///
RetCode_t init(int width = 480, int height = 272, int color_bpp = 16,
- bool poweron = true, bool keypadon = true, bool touchscreeenon = true);
+ uint8_t poweron = 255, bool keypadon = true, bool touchscreeenon = true);
/// Get a pointer to the error code.
@@ -832,7 +832,7 @@
///
point_t TouchCoordinates(uint8_t channel = 0) { return (channel < 5) ? touchInfo[channel].coordinates : touchInfo[0].coordinates; }
-
+
/// Poll the TouchPanel and on a touch event return the a to d filtered x, y coordinates.
///
/// This method reads the touch controller, which has a 10-bit range for each the
@@ -841,7 +841,8 @@
/// @note The returned values are not in display (pixel) units but are in analog to
/// digital converter units.
///
- /// @note This API is usually not needed. See @ref TouchPanelComputeCalibration.
+ /// @note This API is usually not needed and is likely to be deprecated.
+ /// See @ref TouchPanelComputeCalibration.
/// See @ref TouchPanelReadable.
///
/// @param[out] x is the x scale a/d value.
@@ -865,7 +866,8 @@
/// @note The returned values are not in display (pixel) units but are in analog to
/// digital converter units.
///
- /// @note This API is usually not needed. See @ref TouchPanelComputeCalibration.
+ /// @note This API is usually not needed and is likely to be deprecated.
+ /// See @ref TouchPanelComputeCalibration.
/// See @ref TouchPanelReadable.
///
/// @param[out] x is the x scale a/d value.
@@ -1049,7 +1051,7 @@
/// Initialize the keypad interface on the RA8875 controller.
///
/// Enables the keypad subsystem. It will scan the 4 x 5 matrix
- /// and make available key presses.
+ /// and make available key presses.
///
/// @note See section 5-13 of RAIO RA8875 data sheet for more details.
/// @note When using the display from buy-display.com, be sure that
@@ -1146,6 +1148,13 @@
///
bool Intersect(rect_t rect, point_t p);
+ /// Determine if a rectangle intersects another rectangle.
+ ///
+ /// @param[in] rect1 is a rectangular region.
+ /// @param[in] rect2 is a second rectangular region.
+ /// @returns true if rect1 and rect2 intersect.
+ ///
+ bool Intersect(rect_t rect1, rect_t rect2);
/// Write a command to the display with a word of data.
///
@@ -1754,8 +1763,8 @@
/// @returns success/failure code. See @ref RetCode_t.
///
virtual RetCode_t getPixelStream(color_t * p, uint32_t count, loc_t x, loc_t y);
-
-
+
+
/// Write a boolean stream to the display.
///
/// This takes a bit stream in memory and using the current color settings
@@ -2219,6 +2228,37 @@
RetCode_t ellipse(loc_t x, loc_t y, dim_t radius1, dim_t radius2, fill_t fillit = NOFILL);
+
+ /// Block Move
+ ///
+ /// The Block Move API activates the RA8875 Block Transfer Engine. Due to the complex
+ /// set of possible operations, the user should read the related sections of the
+ /// RA8875 user manual.
+ ///
+ /// Some operations may require that other registers are configured, such as the
+ /// foreground and background color registers, and others. Those must be set
+ /// outside of this API.
+ ///
+ /// @param[in] dstLayer layer [5B.7]. layer value is 0 or 1 repreenting layer 1 and 2.
+ /// @param[in] dstDataSelect [50.5] defines the destination data type 0: block, 1: linear.
+ /// @param[in] dstPoint [58-5B] is a point_t defining the destination coordinate.
+ /// @param[in] srcLayer layer [57.7]. layer value is 0 or 1 repreenting layer 1 and 2.
+ /// @param[in] srcDataSelect [50.6] defines the source data type 0: block, 1: linear.
+ /// @param[in] srcPoint [54-57] is a point_t defining the source coordinate.
+ /// @param[in] bte_width [5C-5D]. operation width.
+ /// @param[in] bte_height [5E-5F]. operation height.
+ /// @param[in] bte_op_code [51.3-0] defines the raster operation function
+ /// (write/read/move/...)
+ /// @param[in] bte_rop_code [51.7-4] defines what type of BTE operation to perform
+ /// (what is placed at the destination)
+ /// @returns success/failure code. See @ref RetCode_t.
+ ///
+ RetCode_t BlockMove(uint8_t dstLayer, uint8_t dstDataSelect, point_t dstPoint,
+ uint8_t srcLayer, uint8_t srcDataSelect, point_t srcPoint,
+ uint16_t bte_width, uint16_t bte_height,
+ uint8_t bte_op_code, uint8_t bte_rop_code);
+
+
/// Control display power
///
/// @param[in] on when set to true will turn on the display, when false it is turned off.
@@ -2242,7 +2282,7 @@
/// @param[in] brightness ranges from 0 (off) to 255 (full on)
/// @returns success/failure code. See @ref RetCode_t.
///
- RetCode_t Backlight_u8(unsigned char brightness);
+ RetCode_t Backlight_u8(uint8_t brightness);
/// Get backlight brightness.
@@ -2727,6 +2767,7 @@
PRF_DRAWTRIANGLE,
PRF_DRAWCIRCLE,
PRF_DRAWELLIPSE,
+ PRF_BLOCKMOVE,
METRICCOUNT
} method_e;
unsigned long metrics[METRICCOUNT];