4DGL-uLCD-SE with removed color defines

Fork of 4DGL-uLCD-SE by jim hamblen

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers uLCD_4DGL_Media.cpp Source File

uLCD_4DGL_Media.cpp

00001 //
00002 // uLCD_4DGL is a class to drive 4D Systems LCD screens
00003 //
00004 // Copyright (C) <2010> Stephane ROCHON <stephane.rochon at free.fr>
00005 // Modifed for Goldelox processor <2013> Jim Hamblen
00006 //
00007 // uLCD_4DGL is free software: you can redistribute it and/or modify
00008 // it under the terms of the GNU General Public License as published by
00009 // the Free Software Foundation, either version 3 of the License, or
00010 // (at your option) any later version.
00011 //
00012 // uLCD_4DGL is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 //
00017 // You should have received a copy of the GNU General Public License
00018 // along with uLCD_4DGL.  If not, see <http://www.gnu.org/licenses/>.
00019 
00020 #include "mbed.h"
00021 #include "uLCD_4DGL.h"
00022 
00023 
00024 //Media Commands
00025 
00026 //******************************************************************************************************
00027 int uLCD_4DGL :: media_init()
00028 {
00029     int resp = 0;
00030     char command[1] = "";
00031     command[0] = MINIT;
00032     writeCOMMAND(command, 1);
00033     while (!_cmd.readable()) wait_ms(TEMPO);              // wait for screen answer
00034     if (_cmd.readable()) {
00035         resp = _cmd.getc();           // read response
00036         resp = resp << 8 + _cmd.getc();
00037     }
00038     return resp;
00039 }
00040 
00041 //******************************************************************************************************
00042 void uLCD_4DGL :: set_byte_address(int hi, int lo)
00043 {
00044     char command[5]= "";
00045     command[0] = SBADDRESS;
00046 
00047     command[1] = (hi >> 8) & 0xFF;
00048     command[2] = hi & 0xFF;
00049 
00050     command[3] = (lo >> 8) & 0xFF;
00051     command[4] = lo & 0xFF;
00052     writeCOMMAND(command, 5);
00053 }
00054 
00055 //******************************************************************************************************
00056 void uLCD_4DGL :: set_sector_address(int hi, int lo)
00057 {
00058 
00059     char command[5]= "";
00060     command[0] = SSADDRESS;
00061 
00062     command[1] = (hi >> 8) & 0xFF;
00063     command[2] = hi & 0xFF;
00064 
00065     command[3] = (lo >> 8) & 0xFF;
00066     command[4] = lo & 0xFF;
00067     writeCOMMAND(command, 5);
00068 }
00069 
00070 //******************************************************************************************************
00071 char uLCD_4DGL :: read_byte()
00072 {
00073     char resp = 0;
00074     char command[1] = "";
00075     command[0] = READBYTE;
00076     writeCOMMAND(command, 1);
00077     while (!_cmd.readable()) wait_ms(TEMPO);              // wait for screen answer
00078     if (_cmd.readable()) {
00079         resp = _cmd.getc();           // read response
00080         resp = _cmd.getc();
00081     }
00082     return resp;
00083 }
00084 
00085 //******************************************************************************************************
00086 int  uLCD_4DGL :: read_word()
00087 {
00088     int resp=0;
00089     char command[1] = "";
00090     command[0] = READWORD;
00091     writeCOMMAND(command, 1);
00092     while (!_cmd.readable()) wait_ms(TEMPO);              // wait for screen answer
00093     if (_cmd.readable()) {
00094         resp = _cmd.getc();           // read response
00095         resp = resp << 8 + _cmd.getc();
00096     }
00097     return resp;
00098 }
00099 
00100 //******************************************************************************************************
00101 void uLCD_4DGL :: write_byte(int value)
00102 {
00103     char command[3]= "";
00104 
00105     command[0] = WRITEBYTE;
00106 
00107     command[1] = (value >> 8) & 0xFF;
00108     command[2] = value & 0xFF;
00109     writeCOMMAND(command,3);
00110 }
00111 
00112 //******************************************************************************************************
00113 void uLCD_4DGL :: write_word(int value)
00114 {
00115     char command[3]= "";
00116 
00117     command[0] = WRITEWORD;
00118 
00119     command[1] = (value >> 8) & 0xFF;
00120     command[2] = value & 0xFF;
00121     writeCOMMAND(command,3);
00122 }
00123 
00124 //******************************************************************************************************
00125 void uLCD_4DGL :: flush_media()
00126 {
00127     char command[1] = "";
00128     command[0] = FLUSHMEDIA;
00129     writeCOMMAND(command, 1);
00130 }
00131 
00132 //******************************************************************************************************
00133 void uLCD_4DGL :: display_image(int x, int y)
00134 {
00135     char command[6]= "";
00136     command[0] = DISPLAYIMAGE;
00137 
00138     command[1] = (x >> 8) & 0xFF;
00139     command[2] = x & 0xFF;
00140 
00141     command[3] = (y >> 8) & 0xFF;
00142     command[4] = y & 0xFF;
00143     writeCOMMAND(command, 5);
00144 }
00145 
00146 //******************************************************************************************************
00147 void uLCD_4DGL :: display_video(int x, int y)
00148 {
00149     char command[5]= "";
00150     command[0] = DISPLAYVIDEO;
00151 
00152     command[1] = (x >> 8) & 0xFF;
00153     command[2] = x & 0xFF;
00154 
00155     command[3] = (y >> 8) & 0xFF;
00156     command[4] = y & 0xFF;
00157     writeCOMMAND(command, 5);
00158 }
00159 
00160 //******************************************************************************************************
00161 void uLCD_4DGL :: display_frame(int x, int y, int w)
00162 {
00163     char command[7]= "";
00164 
00165     command[0] = DISPLAYFRAME;
00166 
00167     command[1] = (x >> 8) & 0xFF;
00168     command[2] = x & 0xFF;
00169 
00170     command[3] = (y >> 8) & 0xFF;
00171     command[4] = y & 0xFF;
00172 
00173     command[5] = (w >> 8) & 0xFF;
00174     command[6] = w & 0xFF;
00175     writeCOMMAND(command,7);
00176 }
00177