Ethernetwebsoc
Dependencies: C12832_lcd LM75B WebSocketClient mbed-rtos mbed Socket lwip-eth lwip-sys lwip
C12832_lcd.h
00001 /* mbed library for the mbed Lab Board 128*32 pixel LCD 00002 * use C12832 controller 00003 * Copyright (c) 2012 Peter Drescher - DC2PD 00004 * Released under the MIT License: http://mbed.org/license/mit 00005 * 00006 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00007 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00008 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00009 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00010 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00011 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00012 * THE SOFTWARE. 00013 */ 00014 00015 #ifndef C12832_H 00016 #define C12832_H 00017 00018 #include "mbed.h" 00019 #include "GraphicsDisplay.h" 00020 00021 00022 /** optional Defines : 00023 * #define debug_lcd 1 enable infos to PC_USB 00024 */ 00025 00026 // some defines for the DMA use 00027 #define DMA_CHANNEL_ENABLE 1 00028 #define DMA_TRANSFER_TYPE_M2P (1UL << 11) 00029 #define DMA_CHANNEL_TCIE (1UL << 31) 00030 #define DMA_CHANNEL_SRC_INC (1UL << 26) 00031 #define DMA_MASK_IE (1UL << 14) 00032 #define DMA_MASK_ITC (1UL << 15) 00033 #define DMA_SSP1_TX (1UL << 2) 00034 #define DMA_SSP0_TX (0) 00035 #define DMA_DEST_SSP1_TX (2UL << 6) 00036 #define DMA_DEST_SSP0_TX (0UL << 6) 00037 00038 /** Draw mode 00039 * NORMAl 00040 * XOR set pixel by xor the screen 00041 */ 00042 enum {NORMAL,XOR}; 00043 00044 class C12832_LCD : public GraphicsDisplay 00045 { 00046 public: 00047 /** Create a C12832_LCD object connected to SPI1 00048 * 00049 */ 00050 00051 C12832_LCD(const char* name = "LCD"); 00052 00053 /** Get the width of the screen in pixel 00054 * 00055 * @param 00056 * @returns width of screen in pixel 00057 * 00058 */ 00059 virtual int width(); 00060 00061 /** Get the height of the screen in pixel 00062 * 00063 * @returns height of screen in pixel 00064 * 00065 */ 00066 virtual int height(); 00067 00068 /** Draw a pixel at x,y black or white 00069 * 00070 * @param x horizontal position 00071 * @param y vertical position 00072 * @param colour ,1 set pixel ,0 erase pixel 00073 */ 00074 virtual void pixel(int x, int y,int colour); 00075 00076 /** draw a circle 00077 * 00078 * @param x0,y0 center 00079 * @param r radius 00080 * @param colour ,1 set pixel ,0 erase pixel 00081 * 00082 */ 00083 void circle(int x, int y, int r, int colour); 00084 00085 /** draw a filled circle 00086 * 00087 * @param x0,y0 center 00088 * @param r radius 00089 * @param color ,1 set pixel ,0 erase pixel 00090 * 00091 * use circle with different radius, 00092 * can miss some pixel 00093 */ 00094 void fillcircle(int x, int y, int r, int colour); 00095 00096 /** draw a 1 pixel line 00097 * 00098 * @param x0,y0 start point 00099 * @param x1,y1 stop point 00100 * @param color ,1 set pixel ,0 erase pixel 00101 * 00102 */ 00103 void line(int x0, int y0, int x1, int y1, int colour); 00104 00105 /** draw a rect 00106 * 00107 * @param x0,y0 top left corner 00108 * @param x1,y1 down right corner 00109 * @param color 1 set pixel ,0 erase pixel 00110 * * 00111 */ 00112 void rect(int x0, int y0, int x1, int y1, int colour); 00113 00114 /** draw a filled rect 00115 * 00116 * @param x0,y0 top left corner 00117 * @param x1,y1 down right corner 00118 * @param color 1 set pixel ,0 erase pixel 00119 * 00120 */ 00121 void fillrect(int x0, int y0, int x1, int y1, int colour); 00122 00123 /** copy display buffer to lcd 00124 * 00125 */ 00126 00127 void copy_to_lcd(void); 00128 00129 /** set the orienation of the screen 00130 * 00131 */ 00132 00133 //void set_orientation(unsigned int o); 00134 00135 /** set the contrast of the screen 00136 * 00137 * @param o contrast 0-63 00138 */ 00139 00140 void set_contrast(unsigned int o); 00141 00142 /** read the contrast level 00143 * 00144 */ 00145 unsigned int get_contrast(void); 00146 00147 00148 00149 /** invert the screen 00150 * 00151 * @param o = 0 normal, 1 invert 00152 */ 00153 void invert(unsigned int o); 00154 00155 /** clear the screen 00156 * 00157 */ 00158 virtual void cls(void); 00159 00160 /** set the drawing mode 00161 * 00162 * @param mode NORMAl or XOR 00163 */ 00164 00165 void setmode(int mode); 00166 00167 int columns(void); 00168 00169 /** calculate the max number of columns 00170 * 00171 * @returns max column 00172 * depends on actual font size 00173 * 00174 */ 00175 int rows(void); 00176 00177 /** put a char on the screen 00178 * 00179 * @param value char to print 00180 * @returns printed char 00181 * 00182 */ 00183 int _putc(int value); 00184 00185 /** draw a character on given position out of the active font to the LCD 00186 * 00187 * @param x x-position of char (top left) 00188 * @param y y-position 00189 * @param c char to print 00190 * 00191 */ 00192 virtual void character(int x, int y, int c); 00193 00194 /** setup cursor position 00195 * 00196 * @param x x-position (top left) 00197 * @param y y-position 00198 */ 00199 void locate(int x, int y); 00200 00201 /** setup auto update of screen 00202 * 00203 * @param up 1 = on , 0 = off 00204 * if switched off the program has to call copy_to_lcd() 00205 * to update screen from framebuffer 00206 */ 00207 void C12832_LCD::set_auto_up(unsigned int up); 00208 00209 /** get status of the auto update function 00210 * 00211 * @returns if auto update is on 00212 */ 00213 unsigned int C12832_LCD::get_auto_up(void); 00214 00215 /** Vars */ 00216 SPI _spi; 00217 DigitalOut _reset; 00218 DigitalOut _A0; 00219 DigitalOut _CS; 00220 unsigned char* font; 00221 unsigned int draw_mode; 00222 00223 00224 /** select the font to use 00225 * 00226 * @param f pointer to font array 00227 * 00228 * font array can created with GLCD Font Creator from http://www.mikroe.com 00229 * you have to add 4 parameter at the beginning of the font array to use: 00230 * - the number of byte / char 00231 * - the vertial size in pixel 00232 * - the horizontal size in pixel 00233 * - the number of byte per vertical line 00234 * you also have to change the array to char[] 00235 * 00236 */ 00237 void set_font(unsigned char* f); 00238 00239 00240 protected: 00241 00242 /** draw a horizontal line 00243 * 00244 * @param x0 horizontal start 00245 * @param x1 horizontal stop 00246 * @param y vertical position 00247 * @param ,1 set pixel ,0 erase pixel 00248 * 00249 */ 00250 void hline(int x0, int x1, int y, int colour); 00251 00252 /** draw a vertical line 00253 * 00254 * @param x horizontal position 00255 * @param y0 vertical start 00256 * @param y1 vertical stop 00257 * @param ,1 set pixel ,0 erase pixel 00258 */ 00259 void vline(int y0, int y1, int x, int colour); 00260 00261 /** Init the C12832 LCD controller 00262 * 00263 */ 00264 void lcd_reset(); 00265 00266 /** Write data to the LCD controller 00267 * 00268 * @param dat data written to LCD controller 00269 * 00270 */ 00271 void wr_dat(unsigned char value); 00272 00273 /** Write a command the LCD controller 00274 * 00275 * @param cmd: command to be written 00276 * 00277 */ 00278 void wr_cmd(unsigned char value); 00279 00280 void wr_cnt(unsigned char cmd); 00281 00282 unsigned int orientation; 00283 unsigned int char_x; 00284 unsigned int char_y; 00285 unsigned char buffer[512]; 00286 unsigned int contrast; 00287 unsigned int auto_up; 00288 00289 }; 00290 00291 00292 00293 00294 #endif
Generated on Tue Jul 12 2022 19:26:06 by 1.7.2