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: ulcd_demo ulcd_accel internet_clock 4180_Final_Project ... more
Fork of 4DGL-uLCD-SE by
Revision 5:8936798c19a3, committed 2013-11-22
- Comitter:
- 4180_1
- Date:
- Fri Nov 22 02:44:37 2013 +0000
- Parent:
- 4:74df7fc26fef
- Child:
- 6:b759b69cbaf9
- Commit message:
- ver1.4
Changed in this revision
--- a/uLCD_4DGL.h Wed Nov 20 03:25:53 2013 +0000
+++ b/uLCD_4DGL.h Fri Nov 22 02:44:37 2013 +0000
@@ -48,6 +48,9 @@
#define PENSIZE '\xD8'
#define SETFONT '\x7D'
#define TEXTMODE '\x77'
+#define TEXTBOLD '\x76'
+#define TEXTITALIC '\x75'
+#define TEXTINVERSE '\x74'
#define TEXTWIDTH '\x7C'
#define TEXTHEIGHT '\x7B'
#define TEXTCHAR '\xFE'
@@ -110,6 +113,10 @@
#define BAUD_115200 25
#define BAUD_128000 22
#define BAUD_256000 11
+#define BAUD_300000 10
+#define BAUD_375000 8
+#define BAUD_500000 6
+#define BAUD_600000 4
// Defined Colors
#define WHITE 0xFFFFFF
@@ -243,6 +250,9 @@
// Texts Commands
void set_font(char);
void text_mode(char);
+ void text_bold(char);
+ void text_italic(char);
+ void text_inverse(char);
void text_width(char);
void text_height(char);
void text_char(char, char, char, int);
@@ -283,7 +293,7 @@
int current_w, current_h;
int current_fx, current_fy;
int current_wf, current_hf;
-
+
protected :
@@ -318,3 +328,5 @@
+
+
--- a/uLCD_4DGL_Text.cpp Wed Nov 20 03:25:53 2013 +0000
+++ b/uLCD_4DGL_Text.cpp Fri Nov 22 02:44:37 2013 +0000
@@ -67,6 +67,8 @@
writeCOMMAND(command, 3);
}
+
+
//****************************************************************************************************
void uLCD_4DGL :: text_mode(char mode) // set text mode
{
@@ -80,6 +82,42 @@
}
//****************************************************************************************************
+void uLCD_4DGL :: text_bold(char mode) // set text mode
+{
+ char command[3]= "";
+
+ command[0] = TEXTBOLD;
+ command[1] = 0;
+ command[2] = mode;
+
+ writeCOMMAND(command, 3);
+}
+
+//****************************************************************************************************
+void uLCD_4DGL :: text_italic(char mode) // set text mode
+{
+ char command[3]= "";
+
+ command[0] = TEXTITALIC;
+ command[1] = 0;
+ command[2] = mode;
+
+ writeCOMMAND(command, 3);
+}
+
+//****************************************************************************************************
+void uLCD_4DGL :: text_inverse(char mode) // set text mode
+{
+ char command[3]= "";
+
+ command[0] = TEXTINVERSE;
+ command[1] = 0;
+ command[2] = mode;
+
+ writeCOMMAND(command, 3);
+}
+
+//****************************************************************************************************
void uLCD_4DGL :: text_width(char width) // set text width
{
char command[3]= "";
--- a/uLCD_4DGL_main.cpp Wed Nov 20 03:25:53 2013 +0000
+++ b/uLCD_4DGL_main.cpp Fri Nov 22 02:44:37 2013 +0000
@@ -23,6 +23,7 @@
//Serial pc(USBTX,USBRX);
+
//******************************************************************************************************
uLCD_4DGL :: uLCD_4DGL(PinName tx, PinName rx, PinName rst) : _cmd(tx, rx),
_rst(rst)
@@ -42,7 +43,6 @@
#endif
_rst = 1; // put RESET pin to high to start TFT screen
-
reset();
// autobaud(); // send autobaud command
@@ -131,9 +131,9 @@
//**************************************************************************
void uLCD_4DGL :: reset() // Reset Screen
{
-
+ wait_ms(5);
_rst = 0; // put RESET pin to low
- wait_ms(TEMPO); // wait a few milliseconds for command reception
+ wait_ms(5); // wait a few milliseconds for command reception
_rst = 1; // put RESET back to high
wait(3); // wait 3s for screen to restart
@@ -264,6 +264,21 @@
case 256000 :
newbaud = BAUD_256000;
break;
+ case 300000 :
+ newbaud = BAUD_300000;
+ speed = 272727;
+ break;
+ case 375000 :
+ newbaud = BAUD_375000;
+ speed = 333333;
+ break;
+ case 500000 :
+ newbaud = BAUD_500000;
+ speed = 428571;
+ break;
+ case 600000 :
+ newbaud = BAUD_600000;
+ break;
default :
newbaud = BAUD_9600;
speed = 9600;
@@ -275,11 +290,15 @@
freeBUFFER();
command[1] = char(newbaud >>8);
command[2] = char(newbaud % 256);
- for (i = 0; i <3; i++) writeBYTE(command[i]); // send command to serial port
+ wait_ms(1);
+ for (i = 0; i <3; i++) writeBYTEfast(command[i]); // send command to serial port
+ wait_ms(10); //dont change baud until all characters get sent out
_cmd.baud(speed); // set mbed to same speed
-
- while (!_cmd.readable()) wait_ms(TEMPO); // wait for screen answer
-
+ i=0;
+ while ((!_cmd.readable()) && (i<25000)) {
+ wait_ms(TEMPO); // wait for screen answer - comes 100ms after change
+ i++; //timeout if ack character missed by baud change
+ }
if (_cmd.readable()) resp = _cmd.getc(); // read response if any
switch (resp) {
case ACK : // if OK return 1
