temp poti

Dependents:   2016-01-28_TINF_Temperatur_einlesen

Committer:
tauchi88
Date:
Thu Jan 28 19:53:13 2016 +0000
Revision:
0:4a09a5e0d6d8
temp

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tauchi88 0:4a09a5e0d6d8 1 /* mbed library for the mbed Lab Board 128*32 pixel LCD
tauchi88 0:4a09a5e0d6d8 2 * use C12832 controller
tauchi88 0:4a09a5e0d6d8 3 * Copyright (c) 2012 Peter Drescher - DC2PD
tauchi88 0:4a09a5e0d6d8 4 * Released under the MIT License: http://mbed.org/license/mit
tauchi88 0:4a09a5e0d6d8 5 *
tauchi88 0:4a09a5e0d6d8 6 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
tauchi88 0:4a09a5e0d6d8 7 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
tauchi88 0:4a09a5e0d6d8 8 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
tauchi88 0:4a09a5e0d6d8 9 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
tauchi88 0:4a09a5e0d6d8 10 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
tauchi88 0:4a09a5e0d6d8 11 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
tauchi88 0:4a09a5e0d6d8 12 * THE SOFTWARE.
tauchi88 0:4a09a5e0d6d8 13 */
tauchi88 0:4a09a5e0d6d8 14
tauchi88 0:4a09a5e0d6d8 15 #ifndef C12832_H
tauchi88 0:4a09a5e0d6d8 16 #define C12832_H
tauchi88 0:4a09a5e0d6d8 17
tauchi88 0:4a09a5e0d6d8 18 #include "mbed.h"
tauchi88 0:4a09a5e0d6d8 19 #include "GraphicsDisplay.h"
tauchi88 0:4a09a5e0d6d8 20
tauchi88 0:4a09a5e0d6d8 21
tauchi88 0:4a09a5e0d6d8 22 /** optional Defines :
tauchi88 0:4a09a5e0d6d8 23 * #define debug_lcd 1 enable infos to PC_USB
tauchi88 0:4a09a5e0d6d8 24 */
tauchi88 0:4a09a5e0d6d8 25
tauchi88 0:4a09a5e0d6d8 26 // some defines for the DMA use
tauchi88 0:4a09a5e0d6d8 27 #define DMA_CHANNEL_ENABLE 1
tauchi88 0:4a09a5e0d6d8 28 #define DMA_TRANSFER_TYPE_M2P (1UL << 11)
tauchi88 0:4a09a5e0d6d8 29 #define DMA_CHANNEL_TCIE (1UL << 31)
tauchi88 0:4a09a5e0d6d8 30 #define DMA_CHANNEL_SRC_INC (1UL << 26)
tauchi88 0:4a09a5e0d6d8 31 #define DMA_MASK_IE (1UL << 14)
tauchi88 0:4a09a5e0d6d8 32 #define DMA_MASK_ITC (1UL << 15)
tauchi88 0:4a09a5e0d6d8 33 #define DMA_SSP1_TX (1UL << 2)
tauchi88 0:4a09a5e0d6d8 34 #define DMA_SSP0_TX (0)
tauchi88 0:4a09a5e0d6d8 35 #define DMA_DEST_SSP1_TX (2UL << 6)
tauchi88 0:4a09a5e0d6d8 36 #define DMA_DEST_SSP0_TX (0UL << 6)
tauchi88 0:4a09a5e0d6d8 37
tauchi88 0:4a09a5e0d6d8 38 /** Draw mode
tauchi88 0:4a09a5e0d6d8 39 * NORMAl
tauchi88 0:4a09a5e0d6d8 40 * XOR set pixel by xor the screen
tauchi88 0:4a09a5e0d6d8 41 */
tauchi88 0:4a09a5e0d6d8 42 enum {NORMAL,XOR};
tauchi88 0:4a09a5e0d6d8 43
tauchi88 0:4a09a5e0d6d8 44 class C12832_LCD : public GraphicsDisplay
tauchi88 0:4a09a5e0d6d8 45 {
tauchi88 0:4a09a5e0d6d8 46 public:
tauchi88 0:4a09a5e0d6d8 47 /** Create a C12832_LCD object connected to SPI1
tauchi88 0:4a09a5e0d6d8 48 *
tauchi88 0:4a09a5e0d6d8 49 */
tauchi88 0:4a09a5e0d6d8 50
tauchi88 0:4a09a5e0d6d8 51 C12832_LCD(const char* name = "LCD");
tauchi88 0:4a09a5e0d6d8 52
tauchi88 0:4a09a5e0d6d8 53 /** Get the width of the screen in pixel
tauchi88 0:4a09a5e0d6d8 54 *
tauchi88 0:4a09a5e0d6d8 55 * @param
tauchi88 0:4a09a5e0d6d8 56 * @returns width of screen in pixel
tauchi88 0:4a09a5e0d6d8 57 *
tauchi88 0:4a09a5e0d6d8 58 */
tauchi88 0:4a09a5e0d6d8 59 virtual int width();
tauchi88 0:4a09a5e0d6d8 60
tauchi88 0:4a09a5e0d6d8 61 /** Get the height of the screen in pixel
tauchi88 0:4a09a5e0d6d8 62 *
tauchi88 0:4a09a5e0d6d8 63 * @returns height of screen in pixel
tauchi88 0:4a09a5e0d6d8 64 *
tauchi88 0:4a09a5e0d6d8 65 */
tauchi88 0:4a09a5e0d6d8 66 virtual int height();
tauchi88 0:4a09a5e0d6d8 67
tauchi88 0:4a09a5e0d6d8 68 /** Draw a pixel at x,y black or white
tauchi88 0:4a09a5e0d6d8 69 *
tauchi88 0:4a09a5e0d6d8 70 * @param x horizontal position
tauchi88 0:4a09a5e0d6d8 71 * @param y vertical position
tauchi88 0:4a09a5e0d6d8 72 * @param colour ,1 set pixel ,0 erase pixel
tauchi88 0:4a09a5e0d6d8 73 */
tauchi88 0:4a09a5e0d6d8 74 virtual void pixel(int x, int y,int colour);
tauchi88 0:4a09a5e0d6d8 75
tauchi88 0:4a09a5e0d6d8 76 /** draw a circle
tauchi88 0:4a09a5e0d6d8 77 *
tauchi88 0:4a09a5e0d6d8 78 * @param x0,y0 center
tauchi88 0:4a09a5e0d6d8 79 * @param r radius
tauchi88 0:4a09a5e0d6d8 80 * @param colour ,1 set pixel ,0 erase pixel
tauchi88 0:4a09a5e0d6d8 81 *
tauchi88 0:4a09a5e0d6d8 82 */
tauchi88 0:4a09a5e0d6d8 83 void circle(int x, int y, int r, int colour);
tauchi88 0:4a09a5e0d6d8 84
tauchi88 0:4a09a5e0d6d8 85 /** draw a filled circle
tauchi88 0:4a09a5e0d6d8 86 *
tauchi88 0:4a09a5e0d6d8 87 * @param x0,y0 center
tauchi88 0:4a09a5e0d6d8 88 * @param r radius
tauchi88 0:4a09a5e0d6d8 89 * @param color ,1 set pixel ,0 erase pixel
tauchi88 0:4a09a5e0d6d8 90 *
tauchi88 0:4a09a5e0d6d8 91 * use circle with different radius,
tauchi88 0:4a09a5e0d6d8 92 * can miss some pixel
tauchi88 0:4a09a5e0d6d8 93 */
tauchi88 0:4a09a5e0d6d8 94 void fillcircle(int x, int y, int r, int colour);
tauchi88 0:4a09a5e0d6d8 95
tauchi88 0:4a09a5e0d6d8 96 /** draw a 1 pixel line
tauchi88 0:4a09a5e0d6d8 97 *
tauchi88 0:4a09a5e0d6d8 98 * @param x0,y0 start point
tauchi88 0:4a09a5e0d6d8 99 * @param x1,y1 stop point
tauchi88 0:4a09a5e0d6d8 100 * @param color ,1 set pixel ,0 erase pixel
tauchi88 0:4a09a5e0d6d8 101 *
tauchi88 0:4a09a5e0d6d8 102 */
tauchi88 0:4a09a5e0d6d8 103 void line(int x0, int y0, int x1, int y1, int colour);
tauchi88 0:4a09a5e0d6d8 104
tauchi88 0:4a09a5e0d6d8 105 /** draw a rect
tauchi88 0:4a09a5e0d6d8 106 *
tauchi88 0:4a09a5e0d6d8 107 * @param x0,y0 top left corner
tauchi88 0:4a09a5e0d6d8 108 * @param x1,y1 down right corner
tauchi88 0:4a09a5e0d6d8 109 * @param color 1 set pixel ,0 erase pixel
tauchi88 0:4a09a5e0d6d8 110 * *
tauchi88 0:4a09a5e0d6d8 111 */
tauchi88 0:4a09a5e0d6d8 112 void rect(int x0, int y0, int x1, int y1, int colour);
tauchi88 0:4a09a5e0d6d8 113
tauchi88 0:4a09a5e0d6d8 114 /** draw a filled rect
tauchi88 0:4a09a5e0d6d8 115 *
tauchi88 0:4a09a5e0d6d8 116 * @param x0,y0 top left corner
tauchi88 0:4a09a5e0d6d8 117 * @param x1,y1 down right corner
tauchi88 0:4a09a5e0d6d8 118 * @param color 1 set pixel ,0 erase pixel
tauchi88 0:4a09a5e0d6d8 119 *
tauchi88 0:4a09a5e0d6d8 120 */
tauchi88 0:4a09a5e0d6d8 121 void fillrect(int x0, int y0, int x1, int y1, int colour);
tauchi88 0:4a09a5e0d6d8 122
tauchi88 0:4a09a5e0d6d8 123 /** copy display buffer to lcd
tauchi88 0:4a09a5e0d6d8 124 *
tauchi88 0:4a09a5e0d6d8 125 */
tauchi88 0:4a09a5e0d6d8 126
tauchi88 0:4a09a5e0d6d8 127 void copy_to_lcd(void);
tauchi88 0:4a09a5e0d6d8 128
tauchi88 0:4a09a5e0d6d8 129 /** set the orienation of the screen
tauchi88 0:4a09a5e0d6d8 130 *
tauchi88 0:4a09a5e0d6d8 131 */
tauchi88 0:4a09a5e0d6d8 132
tauchi88 0:4a09a5e0d6d8 133 //void set_orientation(unsigned int o);
tauchi88 0:4a09a5e0d6d8 134
tauchi88 0:4a09a5e0d6d8 135 /** set the contrast of the screen
tauchi88 0:4a09a5e0d6d8 136 *
tauchi88 0:4a09a5e0d6d8 137 * @param o contrast 0-63
tauchi88 0:4a09a5e0d6d8 138 */
tauchi88 0:4a09a5e0d6d8 139
tauchi88 0:4a09a5e0d6d8 140 void set_contrast(unsigned int o);
tauchi88 0:4a09a5e0d6d8 141
tauchi88 0:4a09a5e0d6d8 142 /** read the contrast level
tauchi88 0:4a09a5e0d6d8 143 *
tauchi88 0:4a09a5e0d6d8 144 */
tauchi88 0:4a09a5e0d6d8 145 unsigned int get_contrast(void);
tauchi88 0:4a09a5e0d6d8 146
tauchi88 0:4a09a5e0d6d8 147
tauchi88 0:4a09a5e0d6d8 148
tauchi88 0:4a09a5e0d6d8 149 /** invert the screen
tauchi88 0:4a09a5e0d6d8 150 *
tauchi88 0:4a09a5e0d6d8 151 * @param o = 0 normal, 1 invert
tauchi88 0:4a09a5e0d6d8 152 */
tauchi88 0:4a09a5e0d6d8 153 void invert(unsigned int o);
tauchi88 0:4a09a5e0d6d8 154
tauchi88 0:4a09a5e0d6d8 155 /** clear the screen
tauchi88 0:4a09a5e0d6d8 156 *
tauchi88 0:4a09a5e0d6d8 157 */
tauchi88 0:4a09a5e0d6d8 158 virtual void cls(void);
tauchi88 0:4a09a5e0d6d8 159
tauchi88 0:4a09a5e0d6d8 160 /** set the drawing mode
tauchi88 0:4a09a5e0d6d8 161 *
tauchi88 0:4a09a5e0d6d8 162 * @param mode NORMAl or XOR
tauchi88 0:4a09a5e0d6d8 163 */
tauchi88 0:4a09a5e0d6d8 164
tauchi88 0:4a09a5e0d6d8 165 void setmode(int mode);
tauchi88 0:4a09a5e0d6d8 166
tauchi88 0:4a09a5e0d6d8 167 int columns(void);
tauchi88 0:4a09a5e0d6d8 168
tauchi88 0:4a09a5e0d6d8 169 /** calculate the max number of columns
tauchi88 0:4a09a5e0d6d8 170 *
tauchi88 0:4a09a5e0d6d8 171 * @returns max column
tauchi88 0:4a09a5e0d6d8 172 * depends on actual font size
tauchi88 0:4a09a5e0d6d8 173 *
tauchi88 0:4a09a5e0d6d8 174 */
tauchi88 0:4a09a5e0d6d8 175 int rows(void);
tauchi88 0:4a09a5e0d6d8 176
tauchi88 0:4a09a5e0d6d8 177 /** put a char on the screen
tauchi88 0:4a09a5e0d6d8 178 *
tauchi88 0:4a09a5e0d6d8 179 * @param value char to print
tauchi88 0:4a09a5e0d6d8 180 * @returns printed char
tauchi88 0:4a09a5e0d6d8 181 *
tauchi88 0:4a09a5e0d6d8 182 */
tauchi88 0:4a09a5e0d6d8 183 int _putc(int value);
tauchi88 0:4a09a5e0d6d8 184
tauchi88 0:4a09a5e0d6d8 185 /** draw a character on given position out of the active font to the LCD
tauchi88 0:4a09a5e0d6d8 186 *
tauchi88 0:4a09a5e0d6d8 187 * @param x x-position of char (top left)
tauchi88 0:4a09a5e0d6d8 188 * @param y y-position
tauchi88 0:4a09a5e0d6d8 189 * @param c char to print
tauchi88 0:4a09a5e0d6d8 190 *
tauchi88 0:4a09a5e0d6d8 191 */
tauchi88 0:4a09a5e0d6d8 192 virtual void character(int x, int y, int c);
tauchi88 0:4a09a5e0d6d8 193
tauchi88 0:4a09a5e0d6d8 194 /** setup cursor position
tauchi88 0:4a09a5e0d6d8 195 *
tauchi88 0:4a09a5e0d6d8 196 * @param x x-position (top left)
tauchi88 0:4a09a5e0d6d8 197 * @param y y-position
tauchi88 0:4a09a5e0d6d8 198 */
tauchi88 0:4a09a5e0d6d8 199 void locate(int x, int y);
tauchi88 0:4a09a5e0d6d8 200
tauchi88 0:4a09a5e0d6d8 201 /** setup auto update of screen
tauchi88 0:4a09a5e0d6d8 202 *
tauchi88 0:4a09a5e0d6d8 203 * @param up 1 = on , 0 = off
tauchi88 0:4a09a5e0d6d8 204 * if switched off the program has to call copy_to_lcd()
tauchi88 0:4a09a5e0d6d8 205 * to update screen from framebuffer
tauchi88 0:4a09a5e0d6d8 206 */
tauchi88 0:4a09a5e0d6d8 207 void C12832_LCD::set_auto_up(unsigned int up);
tauchi88 0:4a09a5e0d6d8 208
tauchi88 0:4a09a5e0d6d8 209 /** get status of the auto update function
tauchi88 0:4a09a5e0d6d8 210 *
tauchi88 0:4a09a5e0d6d8 211 * @returns if auto update is on
tauchi88 0:4a09a5e0d6d8 212 */
tauchi88 0:4a09a5e0d6d8 213 unsigned int C12832_LCD::get_auto_up(void);
tauchi88 0:4a09a5e0d6d8 214
tauchi88 0:4a09a5e0d6d8 215 /** Vars */
tauchi88 0:4a09a5e0d6d8 216 SPI _spi;
tauchi88 0:4a09a5e0d6d8 217 DigitalOut _reset;
tauchi88 0:4a09a5e0d6d8 218 DigitalOut _A0;
tauchi88 0:4a09a5e0d6d8 219 DigitalOut _CS;
tauchi88 0:4a09a5e0d6d8 220 unsigned char* font;
tauchi88 0:4a09a5e0d6d8 221 unsigned int draw_mode;
tauchi88 0:4a09a5e0d6d8 222
tauchi88 0:4a09a5e0d6d8 223
tauchi88 0:4a09a5e0d6d8 224 /** select the font to use
tauchi88 0:4a09a5e0d6d8 225 *
tauchi88 0:4a09a5e0d6d8 226 * @param f pointer to font array
tauchi88 0:4a09a5e0d6d8 227 *
tauchi88 0:4a09a5e0d6d8 228 * font array can created with GLCD Font Creator from http://www.mikroe.com
tauchi88 0:4a09a5e0d6d8 229 * you have to add 4 parameter at the beginning of the font array to use:
tauchi88 0:4a09a5e0d6d8 230 * - the number of byte / char
tauchi88 0:4a09a5e0d6d8 231 * - the vertial size in pixel
tauchi88 0:4a09a5e0d6d8 232 * - the horizontal size in pixel
tauchi88 0:4a09a5e0d6d8 233 * - the number of byte per vertical line
tauchi88 0:4a09a5e0d6d8 234 * you also have to change the array to char[]
tauchi88 0:4a09a5e0d6d8 235 *
tauchi88 0:4a09a5e0d6d8 236 */
tauchi88 0:4a09a5e0d6d8 237 void set_font(unsigned char* f);
tauchi88 0:4a09a5e0d6d8 238
tauchi88 0:4a09a5e0d6d8 239
tauchi88 0:4a09a5e0d6d8 240 protected:
tauchi88 0:4a09a5e0d6d8 241
tauchi88 0:4a09a5e0d6d8 242 /** draw a horizontal line
tauchi88 0:4a09a5e0d6d8 243 *
tauchi88 0:4a09a5e0d6d8 244 * @param x0 horizontal start
tauchi88 0:4a09a5e0d6d8 245 * @param x1 horizontal stop
tauchi88 0:4a09a5e0d6d8 246 * @param y vertical position
tauchi88 0:4a09a5e0d6d8 247 * @param ,1 set pixel ,0 erase pixel
tauchi88 0:4a09a5e0d6d8 248 *
tauchi88 0:4a09a5e0d6d8 249 */
tauchi88 0:4a09a5e0d6d8 250 void hline(int x0, int x1, int y, int colour);
tauchi88 0:4a09a5e0d6d8 251
tauchi88 0:4a09a5e0d6d8 252 /** draw a vertical line
tauchi88 0:4a09a5e0d6d8 253 *
tauchi88 0:4a09a5e0d6d8 254 * @param x horizontal position
tauchi88 0:4a09a5e0d6d8 255 * @param y0 vertical start
tauchi88 0:4a09a5e0d6d8 256 * @param y1 vertical stop
tauchi88 0:4a09a5e0d6d8 257 * @param ,1 set pixel ,0 erase pixel
tauchi88 0:4a09a5e0d6d8 258 */
tauchi88 0:4a09a5e0d6d8 259 void vline(int y0, int y1, int x, int colour);
tauchi88 0:4a09a5e0d6d8 260
tauchi88 0:4a09a5e0d6d8 261 /** Init the C12832 LCD controller
tauchi88 0:4a09a5e0d6d8 262 *
tauchi88 0:4a09a5e0d6d8 263 */
tauchi88 0:4a09a5e0d6d8 264 void lcd_reset();
tauchi88 0:4a09a5e0d6d8 265
tauchi88 0:4a09a5e0d6d8 266 /** Write data to the LCD controller
tauchi88 0:4a09a5e0d6d8 267 *
tauchi88 0:4a09a5e0d6d8 268 * @param dat data written to LCD controller
tauchi88 0:4a09a5e0d6d8 269 *
tauchi88 0:4a09a5e0d6d8 270 */
tauchi88 0:4a09a5e0d6d8 271 void wr_dat(unsigned char value);
tauchi88 0:4a09a5e0d6d8 272
tauchi88 0:4a09a5e0d6d8 273 /** Write a command the LCD controller
tauchi88 0:4a09a5e0d6d8 274 *
tauchi88 0:4a09a5e0d6d8 275 * @param cmd: command to be written
tauchi88 0:4a09a5e0d6d8 276 *
tauchi88 0:4a09a5e0d6d8 277 */
tauchi88 0:4a09a5e0d6d8 278 void wr_cmd(unsigned char value);
tauchi88 0:4a09a5e0d6d8 279
tauchi88 0:4a09a5e0d6d8 280 void wr_cnt(unsigned char cmd);
tauchi88 0:4a09a5e0d6d8 281
tauchi88 0:4a09a5e0d6d8 282 unsigned int orientation;
tauchi88 0:4a09a5e0d6d8 283 unsigned int char_x;
tauchi88 0:4a09a5e0d6d8 284 unsigned int char_y;
tauchi88 0:4a09a5e0d6d8 285 unsigned char buffer[512];
tauchi88 0:4a09a5e0d6d8 286 unsigned int contrast;
tauchi88 0:4a09a5e0d6d8 287 unsigned int auto_up;
tauchi88 0:4a09a5e0d6d8 288
tauchi88 0:4a09a5e0d6d8 289 };
tauchi88 0:4a09a5e0d6d8 290
tauchi88 0:4a09a5e0d6d8 291
tauchi88 0:4a09a5e0d6d8 292
tauchi88 0:4a09a5e0d6d8 293
tauchi88 0:4a09a5e0d6d8 294 #endif