This is the same 4DGL-uLCD-SE library as what it's forked from with just an #ifndef statement.
Fork of 4DGL-uLCD-SE by
Revision 6:b759b69cbaf9, committed 2013-11-25
- Comitter:
- 4180_1
- Date:
- Mon Nov 25 04:24:22 2013 +0000
- Parent:
- 5:8936798c19a3
- Child:
- 7:e39a44de229a
- Commit message:
- ver1.4
Changed in this revision
--- a/uLCD_4DGL.h Fri Nov 22 02:44:37 2013 +0000 +++ b/uLCD_4DGL.h Mon Nov 25 04:24:22 2013 +0000 @@ -64,11 +64,26 @@ #define BLITCOM '\x0A' #define PUTCHAR '\xFE' +#define MINIT '\xB1' +#define SBADDRESS '\xB9' +#define SSADDRESS '\xB8' +#define READBYTE '\xB7' +#define READWORD '\xB6' +#define WRITEBYTE '\xB5' +#define WRITEWORD '\xB4' +#define FLUSHMEDIA '\xB2' +#define DISPLAYIMAGE '\xB3' +#define DISPLAYVIDEO '\xBB' +#define DISPLAYFRAME '\xBA' + + // Screen answers #define ACK '\x06' #define NAK '\x15' + + // Screen states #define OFF '\x00' #define ON '\x01' @@ -266,7 +281,22 @@ void putc(char); void puts(char *); - +//Media Commands + int media_init(); + void set_byte_address(int, int); + void set_sector_address(int, int); + char read_byte(); + int read_word(); + void write_byte(int); + void write_word(int); + void flush_media(); + void display_image(int, int); + void display_video(int, int); + void display_frame(int, int, int); + + + + // Touch Command void touch_mode(char); @@ -330,3 +360,4 @@ +
--- a/uLCD_4DGL_Graphics.cpp Fri Nov 22 02:44:37 2013 +0000 +++ b/uLCD_4DGL_Graphics.cpp Mon Nov 25 04:24:22 2013 +0000 @@ -1,5 +1,5 @@ // -// uLCD_4DGL is a class to drive 4D Systems TFT touch screens +// uLCD_4DGL is a class to drive 4D Systems LCD screens // // Copyright (C) <2010> Stephane ROCHON <stephane.rochon at free.fr> // @@ -307,3 +307,4 @@ writeCOMMAND(command, 2); } +
--- a/uLCD_4DGL_Touch.cpp Fri Nov 22 02:44:37 2013 +0000 +++ b/uLCD_4DGL_Touch.cpp Mon Nov 25 04:24:22 2013 +0000 @@ -1,5 +1,5 @@ // -// uLCD_4DGL is a class to drive 4D Systems TFT touch screens +// uLCD_4DGL is a class to drive 4D Systems LCD screens // // Copyright (C) <2010> Stephane ROCHON <stephane.rochon at free.fr> // @@ -20,7 +20,8 @@ #include "uLCD_4DGL.h" //****************************************************************************************************** -void uLCD_4DGL :: touch_mode(char mode) { // Send touch mode (WAIT, PRESS, RELEASE or MOVE) +void uLCD_4DGL :: touch_mode(char mode) // Send touch mode (WAIT, PRESS, RELEASE or MOVE) +{ char command[2]= ""; @@ -31,30 +32,33 @@ } //****************************************************************************************************** -void uLCD_4DGL :: get_touch(int *x, int *y) { // Get the touch coordinates +void uLCD_4DGL :: get_touch(int *x, int *y) // Get the touch coordinates +{ char command[2] = ""; - + command[0] = GETTOUCH; command[1] = GETPOSITION; - + getTOUCH(command, 2, x, y); } //****************************************************************************************************** -int uLCD_4DGL :: touch_status(void) { // Get the touch screen status +int uLCD_4DGL :: touch_status(void) // Get the touch screen status +{ char command[2] = ""; - + command[0] = GETTOUCH; command[1] = STATUS; - + return getSTATUS(command, 2); } //****************************************************************************************************** -void uLCD_4DGL :: wait_touch(int delay) { // wait until touch within a delay in milliseconds +void uLCD_4DGL :: wait_touch(int delay) // wait until touch within a delay in milliseconds +{ char command[3]= ""; @@ -67,7 +71,8 @@ } //****************************************************************************************************** -void uLCD_4DGL :: set_touch(int x1, int y1 , int x2, int y2) { // define touch area +void uLCD_4DGL :: set_touch(int x1, int y1 , int x2, int y2) // define touch area +{ char command[9]= ""; @@ -86,4 +91,157 @@ command[8] = y2 & 0xFF; writeCOMMAND(command, 9); -} \ No newline at end of file +} +//Media Commands + +//****************************************************************************************************** +int uLCD_4DGL :: media_init() +{ + int resp = 0; + char command[1] = ""; + command[0] = MINIT; + writeCOMMAND(command, 1); + while (!_cmd.readable()) wait_ms(TEMPO); // wait for screen answer + if (_cmd.readable()) { + resp = _cmd.getc(); // read response + resp = resp << 8 + _cmd.getc(); + } + return resp; +} + +//****************************************************************************************************** +void uLCD_4DGL :: set_byte_address(int hi, int lo) +{ + char command[5]= ""; + command[0] = SBADDRESS; + + command[1] = (hi >> 8) & 0xFF; + command[2] = hi & 0xFF; + + command[3] = (lo >> 8) & 0xFF; + command[4] = lo & 0xFF; + writeCOMMAND(command, 5); +} + +//****************************************************************************************************** +void uLCD_4DGL :: set_sector_address(int hi, int lo) +{ + + char command[5]= ""; + command[0] = SSADDRESS; + + command[1] = (hi >> 8) & 0xFF; + command[2] = hi & 0xFF; + + command[3] = (lo >> 8) & 0xFF; + command[4] = lo & 0xFF; + writeCOMMAND(command, 5); +} + +//****************************************************************************************************** +char uLCD_4DGL :: read_byte() +{ + char resp = 0; + char command[1] = ""; + command[0] = READBYTE; + writeCOMMAND(command, 1); + while (!_cmd.readable()) wait_ms(TEMPO); // wait for screen answer + if (_cmd.readable()) { + resp = _cmd.getc(); // read response + resp = _cmd.getc(); + } + return resp; +} + +//****************************************************************************************************** +int uLCD_4DGL :: read_word() +{ + int resp=0; + char command[1] = ""; + command[0] = READWORD; + writeCOMMAND(command, 1); + while (!_cmd.readable()) wait_ms(TEMPO); // wait for screen answer + if (_cmd.readable()) { + resp = _cmd.getc(); // read response + resp = resp << 8 + _cmd.getc(); + } + return resp; +} + +//****************************************************************************************************** +void uLCD_4DGL :: write_byte(int value) +{ + char command[3]= ""; + + command[0] = WRITEBYTE; + + command[1] = (value >> 8) & 0xFF; + command[2] = value & 0xFF; + writeCOMMAND(command,3); +} + +//****************************************************************************************************** +void uLCD_4DGL :: write_word(int value) +{ + char command[3]= ""; + + command[0] = WRITEWORD; + + command[1] = (value >> 8) & 0xFF; + command[2] = value & 0xFF; + writeCOMMAND(command,3); +} + +//****************************************************************************************************** +void uLCD_4DGL :: flush_media() +{ + char command[1] = ""; + command[0] = FLUSHMEDIA; + writeCOMMAND(command, 1); +} + +//****************************************************************************************************** +void uLCD_4DGL :: display_image(int x, int y) +{ + char command[6]= ""; + command[0] = DISPLAYIMAGE; + + command[1] = (x >> 8) & 0xFF; + command[2] = x & 0xFF; + + command[3] = (y >> 8) & 0xFF; + command[4] = y & 0xFF; + writeCOMMAND(command, 5); +} + +//****************************************************************************************************** +void uLCD_4DGL :: display_video(int x, int y) +{ + char command[5]= ""; + command[0] = DISPLAYVIDEO; + + command[1] = (x >> 8) & 0xFF; + command[2] = x & 0xFF; + + command[3] = (y >> 8) & 0xFF; + command[4] = y & 0xFF; + writeCOMMAND(command, 5); +} + +//****************************************************************************************************** +void uLCD_4DGL :: display_frame(int x, int y, int w) +{ + char command[7]= ""; + + command[0] = DISPLAYFRAME; + + command[1] = (x >> 8) & 0xFF; + command[2] = x & 0xFF; + + command[3] = (y >> 8) & 0xFF; + command[4] = y & 0xFF; + + command[5] = (w >> 8) & 0xFF; + command[6] = w & 0xFF; + writeCOMMAND(command,7); +}
--- a/uLCD_4DGL_main.cpp Fri Nov 22 02:44:37 2013 +0000 +++ b/uLCD_4DGL_main.cpp Mon Nov 25 04:24:22 2013 +0000 @@ -331,12 +331,8 @@ response[resp++] = (char)temp; } switch (resp) { - case 5 : // if OK populate data and return 1 - type = response[0]; - revision = response[1]; - firmware = response[2]; - reserved1 = response[3]; - reserved2 = response[4]; + case 2 : // if OK populate data and return 1 + revision = response[0]<<8 + response[1]; resp = 1; break; default :