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: 4180-final_project
Revision 3:9ba47197d94f, committed 2013-11-18
- Comitter:
- 4180_1
- Date:
- Mon Nov 18 03:05:40 2013 +0000
- Parent:
- 2:edae99e4abe7
- Child:
- 4:74df7fc26fef
- Commit message:
- ver 1.02
Changed in this revision
| uLCD_4DGL.h | Show annotated file Show diff for this revision Revisions of this file |
| uLCD_4DGL_Graphics.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/uLCD_4DGL.h Sun Nov 17 04:36:12 2013 +0000
+++ b/uLCD_4DGL.h Mon Nov 18 03:05:40 2013 +0000
@@ -26,7 +26,7 @@
#endif
// Common WAIT value in millisecond
-#define TEMPO 5
+#define TEMPO 0.1
// 4DGL Functions values
#define AUTOBAUD '\x55'
@@ -58,6 +58,7 @@
#define GETTOUCH '\x6F'
#define WAITTOUCH '\x77'
#define SETTOUCH '\x75'
+#define BLITCOM '\x0A'
#define PUTCHAR '\xFE'
@@ -237,6 +238,7 @@
int read_pixel(int, int);
void screen_copy(int, int, int, int, int, int);
void pen_size(char);
+ void BLIT(int x, int y, int w, int h, int *colors);
// Texts Commands
void set_font(char);
--- a/uLCD_4DGL_Graphics.cpp Sun Nov 17 04:36:12 2013 +0000
+++ b/uLCD_4DGL_Graphics.cpp Mon Nov 18 03:05:40 2013 +0000
@@ -22,7 +22,8 @@
#define ARRAY_SIZE(X) sizeof(X)/sizeof(X[0])
//****************************************************************************************************
-void uLCD_4DGL :: circle(int x, int y , int radius, int color) { // draw a circle in (x,y)
+void uLCD_4DGL :: circle(int x, int y , int radius, int color) // draw a circle in (x,y)
+{
char command[9]= "";
command[0] = CIRCLE;
@@ -47,7 +48,8 @@
}
//****************************************************************************************************
-void uLCD_4DGL :: triangle(int x1, int y1 , int x2, int y2, int x3, int y3, int color) { // draw a traingle
+void uLCD_4DGL :: triangle(int x1, int y1 , int x2, int y2, int x3, int y3, int color) // draw a traingle
+{
char command[15]= "";
command[0] = TRIANGLE;
@@ -81,7 +83,8 @@
}
//****************************************************************************************************
-void uLCD_4DGL :: line(int x1, int y1 , int x2, int y2, int color) { // draw a line
+void uLCD_4DGL :: line(int x1, int y1 , int x2, int y2, int color) // draw a line
+{
char command[11]= "";
command[0] = LINE;
@@ -109,7 +112,8 @@
}
//****************************************************************************************************
-void uLCD_4DGL :: rectangle(int x1, int y1 , int x2, int y2, int color) { // draw a rectangle
+void uLCD_4DGL :: rectangle(int x1, int y1 , int x2, int y2, int color) // draw a rectangle
+{
char command[11]= "";
command[0] = RECTANGLE;
@@ -137,7 +141,8 @@
}
//****************************************************************************************************
-void uLCD_4DGL :: ellipse(int x, int y , int radius_x, int radius_y, int color) { // draw an ellipse
+void uLCD_4DGL :: ellipse(int x, int y , int radius_x, int radius_y, int color) // draw an ellipse
+{
char command[11]= "";
command[0] = ELLIPSE;
@@ -165,7 +170,8 @@
}
//****************************************************************************************************
-void uLCD_4DGL :: pixel(int x, int y, int color) { // draw a pixel
+void uLCD_4DGL :: pixel(int x, int y, int color) // draw a pixel
+{
char command[7]= "";
command[0] = PIXEL;
@@ -185,9 +191,49 @@
writeCOMMAND(command, 7);
}
+//****************************************************************************************************
+void uLCD_4DGL :: BLIT(int x, int y, int w, int h, int *colors) // draw a block of pixels
+{
+ int red5, green6, blue5;
+ writeBYTE('\x00');
+ writeBYTE(BLITCOM);
+ writeBYTE((x >> 8) & 0xFF);
+ writeBYTE(x & 0xFF);
+ writeBYTE((y >> 8) & 0xFF);
+ writeBYTE(y & 0xFF);
+ writeBYTE((w >> 8) & 0xFF);
+ writeBYTE(w & 0xFF);
+ writeBYTE((h >> 8) & 0xFF);
+ writeBYTE(h & 0xFF);
+ for (int i=0; i<w*h; i++) {
+ red5 = (colors[i] >> (16 + 3)) & 0x1F; // get red on 5 bits
+ green6 = (colors[i] >> (8 + 2)) & 0x3F; // get green on 6 bits
+ blue5 = (colors[i] >> (0 + 3)) & 0x1F; // get blue on 5 bits
+ writeBYTE(((red5 << 3) + (green6 >> 3)) & 0xFF); // first part of 16 bits color
+ writeBYTE(((green6 << 5) + (blue5 >> 0)) & 0xFF); // second part of 16 bits color
+ }
+ int resp=0;
+ while (!_cmd.readable()) wait_ms(TEMPO); // wait for screen answer
+ if (_cmd.readable()) resp = _cmd.getc(); // read response if any
+ switch (resp) {
+ case ACK : // if OK return 1
+ resp = 1;
+ break;
+ case NAK : // if NOK return -1
+ resp = -1;
+ break;
+ default :
+ resp = 0; // else return 0
+ break;
+ }
+#if DEBUGMODE
+ pc.printf(" Answer received : %d\n",resp);
+#endif
+}
//******************************************************************************************************
-int uLCD_4DGL :: read_pixel(int x, int y) { // read screen info and populate data
+int uLCD_4DGL :: read_pixel(int x, int y) // read screen info and populate data
+{
char command[6]= "";
command[0] = 0xFF;
@@ -221,7 +267,8 @@
}
//******************************************************************************************************
-void uLCD_4DGL :: screen_copy(int xs, int ys , int xd, int yd , int width, int height) {
+void uLCD_4DGL :: screen_copy(int xs, int ys , int xd, int yd , int width, int height)
+{
char command[13]= "";
@@ -249,7 +296,8 @@
}
//****************************************************************************************************
-void uLCD_4DGL :: pen_size(char mode) { // set pen to SOLID or WIREFRAME
+void uLCD_4DGL :: pen_size(char mode) // set pen to SOLID or WIREFRAME
+{
char command[2]= "";
command[0] = PENSIZE;