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.
Dependents: co657_lcdplay co657_nrf52_beacons door_lock co657_IoT
Fork of C12832 by
Revision 17:67f9ca828270, committed 2015-10-28
- Comitter:
- co657_frmb
- Date:
- Wed Oct 28 21:01:40 2015 +0000
- Parent:
- 16:7de323fa46fe
- Child:
- 18:8c294697c901
- Commit message:
- Added hline and vline [public], re-plumbed line(); cls() only flushes if auto_up.
Changed in this revision
| C12832.cpp | Show annotated file Show diff for this revision Revisions of this file |
| C12832.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/C12832.cpp Wed Feb 05 14:25:16 2014 +0000
+++ b/C12832.cpp Wed Oct 28 21:01:40 2015 +0000
@@ -204,7 +204,7 @@
void C12832::cls(void)
{
memset(buffer,0x00,512); // clear display buffer
- copy_to_lcd();
+ if (auto_up) copy_to_lcd();
}
@@ -218,22 +218,21 @@
dx = x1-x0;
dy = y1-y0;
- // if (dx == 0) { /* vertical line */
- // if (y1 > y0) vline(x0,y0,y1,color);
- // else vline(x0,y1,y0,color);
- // return;
- // }
+ if (dx == 0) { /* vertical line */
+ if (y1 > y0) vline(x0,y0,y1,color);
+ else vline(x0,y1,y0,color);
+ return;
+ } else if (dy == 0) { /* horizontal line */
+ if (x1 > x0) hline(x0,y0,x1,color);
+ else hline(x1,y0,x0,color);
+ return;
+ }
if (dx > 0) {
dx_sym = 1;
} else {
dx_sym = -1;
}
- // if (dy == 0) { /* horizontal line */
- // if (x1 > x0) hline(x0,x1,y0,color);
- // else hline(x1,x0,y0,color);
- // return;
- // }
if (dy > 0) {
dy_sym = 1;
@@ -278,6 +277,32 @@
if(auto_up) copy_to_lcd();
}
+void C12832::hline(int x0, int y0, int x1, int colour)
+{
+ int x;
+
+ /* FIXME: do this sensibly, in blocks of 8 pixels */
+ for (x=x0; x<=x1; x++) {
+ pixel (x, y0, colour);
+ }
+ if (auto_up) {
+ copy_to_lcd ();
+ }
+}
+
+void C12832::vline(int x0, int y0, int y1, int colour)
+{
+ int y;
+
+ /* FIXME: do this sensibly, computing the bit positioning once */
+ for (y=y0; y<=y1; y++) {
+ pixel (x0, y, colour);
+ }
+ if (auto_up) {
+ copy_to_lcd ();
+ }
+}
+
void C12832::rect(int x0, int y0, int x1, int y1, int color)
{
--- a/C12832.h Wed Feb 05 14:25:16 2014 +0000
+++ b/C12832.h Wed Oct 28 21:01:40 2015 +0000
@@ -107,11 +107,34 @@
*
* @param x0,y0 start point
* @param x1,y1 stop point
- * @param color ,1 set pixel ,0 erase pixel
+ * @param colour 1 set pixel, 0 erase pixel
*
*/
void line(int x0, int y0, int x1, int y1, int colour);
+
+ /** draw a horizontal line
+ *
+ * @param x0 horizontal start
+ * @param y0 vertical position
+ * @param x1 horizontal stop
+ * @param colour 1 set pixel, 0 erase pixel
+ *
+ */
+ void hline(int x0, int y0, int x1, int colour);
+
+
+ /** draw a vertical line
+ *
+ * @param x0 horizontal position
+ * @param y0 vertical start
+ * @param y1 vertical stop
+ * @param colour 1 set pixel, 0 erase pixel
+ *
+ */
+ void vline(int x0, int y0, int y1, int colour);
+
+
/** draw a rect
*
* @param x0,y0 top left corner
@@ -251,24 +274,6 @@
protected:
- /** draw a horizontal line
- *
- * @param x0 horizontal start
- * @param x1 horizontal stop
- * @param y vertical position
- * @param ,1 set pixel ,0 erase pixel
- *
- */
- void hline(int x0, int x1, int y, int colour);
-
- /** draw a vertical line
- *
- * @param x horizontal position
- * @param y0 vertical start
- * @param y1 vertical stop
- * @param ,1 set pixel ,0 erase pixel
- */
- void vline(int y0, int y1, int x, int colour);
/** Init the C12832 LCD controller
*
