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.
Fork of C12832 by
C12832.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 #if defined(TARGET_RZ_A1H) 00043 enum {_NORMAL, _XOR}; 00044 #else 00045 enum {NORMAL, XOR}; 00046 #endif 00047 00048 /** Bitmap 00049 */ 00050 struct Bitmap{ 00051 int xSize; 00052 int ySize; 00053 int Byte_in_Line; 00054 char* data; 00055 }; 00056 00057 class C12832 : public GraphicsDisplay 00058 { 00059 public: 00060 /** Create a C12832 object connected to SPI1 00061 * 00062 */ 00063 00064 C12832(PinName mosi, PinName sck, PinName reset, PinName a0, PinName ncs, const char* name = "LCD"); 00065 00066 00067 /** Get the width of the screen in pixel 00068 * 00069 * @param 00070 * @returns width of screen in pixel 00071 * 00072 */ 00073 virtual int width(); 00074 00075 /** Get the height of the screen in pixel 00076 * 00077 * @returns height of screen in pixel 00078 * 00079 */ 00080 virtual int height(); 00081 00082 /** Draw a pixel at x,y black or white 00083 * 00084 * @param x horizontal position 00085 * @param y vertical position 00086 * @param colour ,1 set pixel ,0 erase pixel 00087 */ 00088 virtual void pixel(int x, int y,int colour); 00089 00090 /** draw a circle 00091 * 00092 * @param x0,y0 center 00093 * @param r radius 00094 * @param colour ,1 set pixel ,0 erase pixel 00095 * 00096 */ 00097 void circle(int x, int y, int r, int colour); 00098 00099 /** draw a filled circle 00100 * 00101 * @param x0,y0 center 00102 * @param r radius 00103 * @param color ,1 set pixel ,0 erase pixel 00104 * 00105 * use circle with different radius, 00106 * can miss some pixel 00107 */ 00108 void fillcircle(int x, int y, int r, int colour); 00109 00110 /** draw a 1 pixel line 00111 * 00112 * @param x0,y0 start point 00113 * @param x1,y1 stop point 00114 * @param color ,1 set pixel ,0 erase pixel 00115 * 00116 */ 00117 void line(int x0, int y0, int x1, int y1, int colour); 00118 00119 /** draw a rect 00120 * 00121 * @param x0,y0 top left corner 00122 * @param x1,y1 down right corner 00123 * @param color 1 set pixel ,0 erase pixel 00124 * * 00125 */ 00126 void rect(int x0, int y0, int x1, int y1, int colour); 00127 00128 /** draw a filled rect 00129 * 00130 * @param x0,y0 top left corner 00131 * @param x1,y1 down right corner 00132 * @param color 1 set pixel ,0 erase pixel 00133 * 00134 */ 00135 void fillrect(int x0, int y0, int x1, int y1, int colour); 00136 00137 /** copy display buffer to lcd 00138 * 00139 */ 00140 00141 void copy_to_lcd(void); 00142 00143 /** set the orienation of the screen 00144 * 00145 */ 00146 00147 00148 void set_contrast(unsigned int o); 00149 00150 /** read the contrast level 00151 * 00152 */ 00153 unsigned int get_contrast(void); 00154 00155 00156 /** invert the screen 00157 * 00158 * @param o = 0 normal, 1 invert 00159 */ 00160 void invert(unsigned int o); 00161 00162 /** clear the screen 00163 * 00164 */ 00165 virtual void cls(void); 00166 00167 /** set the drawing mode 00168 * 00169 * @param mode NORMAl or XOR 00170 */ 00171 00172 void setmode(int mode); 00173 00174 virtual int columns(void); 00175 00176 /** calculate the max number of columns 00177 * 00178 * @returns max column 00179 * depends on actual font size 00180 * 00181 */ 00182 virtual int rows(void); 00183 00184 /** put a char on the screen 00185 * 00186 * @param value char to print 00187 * @returns printed char 00188 * 00189 */ 00190 virtual int _putc(int value); 00191 00192 /** draw a character on given position out of the active font to the LCD 00193 * 00194 * @param x x-position of char (top left) 00195 * @param y y-position 00196 * @param c char to print 00197 * 00198 */ 00199 virtual void character(int x, int y, int c); 00200 00201 /** setup cursor position 00202 * 00203 * @param x x-position (top left) 00204 * @param y y-position 00205 */ 00206 virtual void locate(int x, int y); 00207 00208 /** setup auto update of screen 00209 * 00210 * @param up 1 = on , 0 = off 00211 * if switched off the program has to call copy_to_lcd() 00212 * to update screen from framebuffer 00213 */ 00214 void set_auto_up(unsigned int up); 00215 00216 /** get status of the auto update function 00217 * 00218 * @returns if auto update is on 00219 */ 00220 unsigned int get_auto_up(void); 00221 00222 /** Vars */ 00223 SPI _spi; 00224 DigitalOut _reset; 00225 DigitalOut _A0; 00226 DigitalOut _CS; 00227 unsigned char* font; 00228 unsigned int draw_mode; 00229 00230 00231 /** select the font to use 00232 * 00233 * @param f pointer to font array 00234 * 00235 * font array can created with GLCD Font Creator from http://www.mikroe.com 00236 * you have to add 4 parameter at the beginning of the font array to use: 00237 * - the number of byte / char 00238 * - the vertial size in pixel 00239 * - the horizontal size in pixel 00240 * - the number of byte per vertical line 00241 * you also have to change the array to char[] 00242 * 00243 */ 00244 void set_font(unsigned char* f); 00245 00246 /** print bitmap to buffer 00247 * 00248 * @param bm Bitmap in flash 00249 * @param x x start 00250 * @param y y start 00251 * 00252 */ 00253 00254 void print_bm(Bitmap bm, int x, int y); 00255 00256 protected: 00257 00258 /** draw a horizontal line 00259 * 00260 * @param x0 horizontal start 00261 * @param x1 horizontal stop 00262 * @param y vertical position 00263 * @param ,1 set pixel ,0 erase pixel 00264 * 00265 */ 00266 void hline(int x0, int x1, int y, int colour); 00267 00268 /** draw a vertical line 00269 * 00270 * @param x horizontal position 00271 * @param y0 vertical start 00272 * @param y1 vertical stop 00273 * @param ,1 set pixel ,0 erase pixel 00274 */ 00275 void vline(int y0, int y1, int x, int colour); 00276 00277 /** Init the C12832 LCD controller 00278 * 00279 */ 00280 void lcd_reset(); 00281 00282 /** Write data to the LCD controller 00283 * 00284 * @param dat data written to LCD controller 00285 * 00286 */ 00287 void wr_dat(unsigned char value); 00288 00289 /** Write a command the LCD controller 00290 * 00291 * @param cmd: command to be written 00292 * 00293 */ 00294 void wr_cmd(unsigned char value); 00295 00296 void wr_cnt(unsigned char cmd); 00297 00298 unsigned int orientation; 00299 unsigned int char_x; 00300 unsigned int char_y; 00301 unsigned char buffer[512]; 00302 unsigned int contrast; 00303 unsigned int auto_up; 00304 00305 }; 00306 00307 00308 00309 00310 #endif
Generated on Thu Jul 14 2022 14:39:40 by
1.7.2
