Display

Dependents:   Termocamera_ironblack

Committer:
gia95
Date:
Fri May 31 10:04:24 2019 +0000
Revision:
34:dfb770591146
Parent:
22:f9a37f22b9cb
Child:
35:ebad2ec6f903
Display_lib;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Geremia 0:75ec1b3cde17 1 /* mbed GraphicsDisplay Display Library Base Class
Geremia 0:75ec1b3cde17 2 * Copyright (c) 2007-2009 sford
Geremia 0:75ec1b3cde17 3 * Released under the MIT License: http://mbed.org/license/mit
Geremia 0:75ec1b3cde17 4 *
Geremia 0:75ec1b3cde17 5 * A library for providing a common base class for Graphics displays
Geremia 0:75ec1b3cde17 6 * To port a new display, derive from this class and implement
Geremia 0:75ec1b3cde17 7 * the constructor (setup the display), pixel (put a pixel
Geremia 0:75ec1b3cde17 8 * at a location), width and height functions. Everything else
Geremia 0:75ec1b3cde17 9 * (locate, printf, putc, cls, window, putp, fill, blit, blitbit)
Geremia 0:75ec1b3cde17 10 * will come for free. You can also provide a specialised implementation
Geremia 0:75ec1b3cde17 11 * of window and putp to speed up the results
Geremia 0:75ec1b3cde17 12 */
Geremia 0:75ec1b3cde17 13
Geremia 0:75ec1b3cde17 14 #ifndef MBED_GRAPHICSDISPLAY_H
Geremia 0:75ec1b3cde17 15 #define MBED_GRAPHICSDISPLAY_H
Geremia 0:75ec1b3cde17 16
Geremia 0:75ec1b3cde17 17 #include "TextDisplay.h"
Geremia 0:75ec1b3cde17 18 #include "Terminal6x8.h"
Geremia 0:75ec1b3cde17 19
Geremia 5:b222a9461d6b 20
Geremia 2:713844a55c4e 21
Geremia 2:713844a55c4e 22 /* some RGB color definitions */
Geremia 2:713844a55c4e 23 #define Black 0x0000 /* 0, 0, 0 */
Geremia 2:713844a55c4e 24 #define Navy 0x000F /* 0, 0, 128 */
Geremia 2:713844a55c4e 25 #define DarkGreen 0x03E0 /* 0, 128, 0 */
Geremia 2:713844a55c4e 26 #define DarkCyan 0x03EF /* 0, 128, 128 */
Geremia 2:713844a55c4e 27 #define Maroon 0x7800 /* 128, 0, 0 */
Geremia 2:713844a55c4e 28 #define Purple 0x780F /* 128, 0, 128 */
Geremia 2:713844a55c4e 29 #define Olive 0x7BE0 /* 128, 128, 0 */
Geremia 2:713844a55c4e 30 #define LightGrey 0xC618 /* 192, 192, 192 */
Geremia 2:713844a55c4e 31 #define DarkGrey 0x7BEF /* 128, 128, 128 */
Geremia 2:713844a55c4e 32 #define Blue 0x001F /* 0, 0, 255 */
Geremia 2:713844a55c4e 33 #define Green 0x07E0 /* 0, 255, 0 */
Geremia 2:713844a55c4e 34 #define Cyan 0x07FF /* 0, 255, 255 */
Geremia 2:713844a55c4e 35 #define Red 0xF800 /* 255, 0, 0 */
Geremia 2:713844a55c4e 36 #define Magenta 0xF81F /* 255, 0, 255 */
Geremia 2:713844a55c4e 37 #define Yellow 0xFFE0 /* 255, 255, 0 */
Geremia 2:713844a55c4e 38 #define White 0xFFFF /* 255, 255, 255 */
Geremia 2:713844a55c4e 39 #define Orange 0xFD20 /* 255, 165, 0 */
Geremia 2:713844a55c4e 40 #define GreenYellow 0xAFE5 /* 173, 255, 47 */
Geremia 2:713844a55c4e 41
gia95 34:dfb770591146 42 //Grey Scale color
gia95 34:dfb770591146 43
gia95 34:dfb770591146 44
gia95 34:dfb770591146 45 #define color0 0x10A2
gia95 34:dfb770591146 46 #define color1 0x18C3
gia95 34:dfb770591146 47 #define color2 0x18E3
gia95 34:dfb770591146 48 #define color3 0x2104
gia95 34:dfb770591146 49 #define color4 0x2124
gia95 34:dfb770591146 50 #define color5 0x2945
gia95 34:dfb770591146 51 #define color6 0x2965
gia95 34:dfb770591146 52 #define color7 0x3186
gia95 34:dfb770591146 53 #define color8 0x31A6
gia95 34:dfb770591146 54 #define color9 0x39C7
gia95 34:dfb770591146 55 #define color10 0x39E7
gia95 34:dfb770591146 56 #define color11 0x4208
gia95 34:dfb770591146 57 #define color12 0x4228
gia95 34:dfb770591146 58 #define color13 0x4A49
gia95 34:dfb770591146 59 #define color14 0x4A69
gia95 34:dfb770591146 60 #define color15 0x528A
gia95 34:dfb770591146 61 #define color16 0x52AA
gia95 34:dfb770591146 62 #define color17 0x5ACB
gia95 34:dfb770591146 63 #define color18 0x5AEB
gia95 34:dfb770591146 64 #define color19 0x630C
gia95 34:dfb770591146 65 #define color20 0x632C
gia95 34:dfb770591146 66 #define color21 0x6B4D
gia95 34:dfb770591146 67 #define color22 0x6B6D
gia95 34:dfb770591146 68 #define color23 0x738E
gia95 34:dfb770591146 69 #define color24 0x73AE
gia95 34:dfb770591146 70 #define color25 0x7BCF
gia95 34:dfb770591146 71 #define color26 0x7BEF
gia95 34:dfb770591146 72 #define color27 0x8410
gia95 34:dfb770591146 73 #define color28 0x8430
gia95 34:dfb770591146 74 #define color29 0x8C51
gia95 34:dfb770591146 75 #define color30 0x8C71
gia95 34:dfb770591146 76 #define color31 0x9492
gia95 34:dfb770591146 77 #define color32 0x94B2
gia95 34:dfb770591146 78 #define color33 0x9CD3
gia95 34:dfb770591146 79 #define color34 0x9CF3
gia95 34:dfb770591146 80 #define color35 0xA514
gia95 34:dfb770591146 81 #define color36 0xA534
gia95 34:dfb770591146 82 #define color37 0xAD55
gia95 34:dfb770591146 83 #define color38 0xAD75
gia95 34:dfb770591146 84 #define color39 0xB596
gia95 34:dfb770591146 85 #define color40 0xB5B6
gia95 34:dfb770591146 86 #define color41 0xBDD7
gia95 34:dfb770591146 87 #define color42 0xBDF7
gia95 34:dfb770591146 88 #define color43 0xC618
gia95 34:dfb770591146 89 #define color44 0xC638
gia95 34:dfb770591146 90 #define color45 0xCE59
gia95 34:dfb770591146 91 #define color46 0xCE79
gia95 34:dfb770591146 92 #define color47 0xD69A
gia95 34:dfb770591146 93 #define color48 0xD6BA
gia95 34:dfb770591146 94 #define color49 0xDEDB
gia95 34:dfb770591146 95 #define color50 0xDEFB
gia95 34:dfb770591146 96 #define color51 0xE71C
gia95 34:dfb770591146 97 #define color52 0xE73C
gia95 34:dfb770591146 98 #define color53 0xEF5D
gia95 34:dfb770591146 99 #define color54 0xEF7D
gia95 34:dfb770591146 100 #define color55 0xF79E
gia95 34:dfb770591146 101 #define color56 0xF7BE
gia95 34:dfb770591146 102 #define color57 0xFFDF
gia95 34:dfb770591146 103 #define color58 0xFFFF
gia95 34:dfb770591146 104
gia95 34:dfb770591146 105
gia95 34:dfb770591146 106
gia95 34:dfb770591146 107
gia95 34:dfb770591146 108
gia95 34:dfb770591146 109
gia95 34:dfb770591146 110
Geremia 0:75ec1b3cde17 111 /** Bitmap
Geremia 0:75ec1b3cde17 112 */
Geremia 0:75ec1b3cde17 113 struct Bitmap_s{
Geremia 0:75ec1b3cde17 114 int xSize;
Geremia 0:75ec1b3cde17 115 int ySize;
Geremia 0:75ec1b3cde17 116 int Byte_in_Line;
Geremia 0:75ec1b3cde17 117 char* data;
Geremia 0:75ec1b3cde17 118 };
Geremia 0:75ec1b3cde17 119
Geremia 0:75ec1b3cde17 120 /** A common base class for Graphics displays
Geremia 0:75ec1b3cde17 121 */
Geremia 0:75ec1b3cde17 122 class GraphicsDisplay : public TextDisplay {
Geremia 0:75ec1b3cde17 123
Geremia 0:75ec1b3cde17 124 public:
Geremia 0:75ec1b3cde17 125
Geremia 0:75ec1b3cde17 126 /** Create a GraphicsDisplay interface
Geremia 0:75ec1b3cde17 127 * @param name The name used by the parent class to access the interface
Geremia 0:75ec1b3cde17 128 */
Geremia 0:75ec1b3cde17 129 GraphicsDisplay(const char* name);
Geremia 0:75ec1b3cde17 130
Geremia 0:75ec1b3cde17 131 ////// functions needing implementation in derived implementation class ///////////////////////////////////////
Geremia 0:75ec1b3cde17 132 ////// ---------------------------------------------------------------- ///////////////////////////////////////
Geremia 0:75ec1b3cde17 133
Geremia 0:75ec1b3cde17 134 /** Draw a pixel in the specified color.
Geremia 0:75ec1b3cde17 135 * @note this method must be supported in the derived class.
Geremia 0:75ec1b3cde17 136 * @param x is the horizontal offset to this pixel.
Geremia 0:75ec1b3cde17 137 * @param y is the vertical offset to this pixel.
Geremia 0:75ec1b3cde17 138 * @param color defines the color for the pixel.
Geremia 0:75ec1b3cde17 139 */
Geremia 0:75ec1b3cde17 140 virtual void pixel(int x, int y, unsigned short color) = 0;
Geremia 0:75ec1b3cde17 141
Geremia 0:75ec1b3cde17 142 /** Set the window, which controls where items are written to the screen.
Geremia 0:75ec1b3cde17 143 * When something hits the window width, it wraps back to the left side
Geremia 0:75ec1b3cde17 144 * and down a row. If the initial write is outside the window, it will
Geremia 0:75ec1b3cde17 145 * be captured into the window when it crosses a boundary.
Geremia 0:75ec1b3cde17 146 * @param x is the left edge in pixels.
Geremia 0:75ec1b3cde17 147 * @param y is the top edge in pixels.
Geremia 0:75ec1b3cde17 148 * @param w is the window width in pixels.
Geremia 0:75ec1b3cde17 149 * @param h is the window height in pixels.
Geremia 0:75ec1b3cde17 150 * @note this method must be overridden in a derived class.
Geremia 0:75ec1b3cde17 151 */
Geremia 0:75ec1b3cde17 152 virtual void window(int x, int y, int w, int h) = 0;
Geremia 0:75ec1b3cde17 153
Geremia 0:75ec1b3cde17 154 /** Push a single pixel into the window and increment position.
Geremia 0:75ec1b3cde17 155 * You may first call window() then push pixels in loop.
Geremia 0:75ec1b3cde17 156 * @param color is the pixel color.
Geremia 0:75ec1b3cde17 157 * @note this method must be overridden in a derived class.
Geremia 0:75ec1b3cde17 158 */
Geremia 0:75ec1b3cde17 159 virtual void window_pushpixel(unsigned short color) = 0;
Geremia 2:713844a55c4e 160
Geremia 2:713844a55c4e 161 /** Push some pixels of the same color into the window and increment position.
Geremia 2:713844a55c4e 162 * You must first call window() then push pixels.
Geremia 2:713844a55c4e 163 * @param color is the pixel color.
Geremia 2:713844a55c4e 164 * @param count: how many
Geremia 2:713844a55c4e 165 */
Geremia 2:713844a55c4e 166 virtual void window_pushpixel(unsigned short color, unsigned int count) = 0;
Geremia 2:713844a55c4e 167
Geremia 2:713844a55c4e 168 /** Push array of pixel colors into the window and increment position.
Geremia 2:713844a55c4e 169 * You must first call window() then push pixels.
Geremia 2:713844a55c4e 170 * @param color is the pixel color.
Geremia 2:713844a55c4e 171 */
Geremia 2:713844a55c4e 172 virtual void window_pushpixelbuf(unsigned short* color, unsigned int lenght) = 0;
Geremia 0:75ec1b3cde17 173
Geremia 0:75ec1b3cde17 174 /** If framebuffer is used, it needs to be sent to LCD from time to time
Geremia 0:75ec1b3cde17 175 @note this method must be overridden in a derived class.
Geremia 0:75ec1b3cde17 176 @note real function for LCD, dummy for TFT
Geremia 0:75ec1b3cde17 177 */
Geremia 0:75ec1b3cde17 178 virtual void copy_to_lcd() = 0;
Geremia 0:75ec1b3cde17 179
Geremia 0:75ec1b3cde17 180 /////// functions that come for free, but can be overwritten///////////////////////////////////////////////////
Geremia 0:75ec1b3cde17 181 /////// ----------------------------------------------------///////////////////////////////////////////////////
Geremia 0:75ec1b3cde17 182
Geremia 0:75ec1b3cde17 183 /** Set window to max possible size
Geremia 0:75ec1b3cde17 184 * May be overridden in a derived class.
Geremia 0:75ec1b3cde17 185 */
Geremia 0:75ec1b3cde17 186 virtual void WindowMax(void);
Geremia 0:75ec1b3cde17 187
Geremia 0:75ec1b3cde17 188 /** clear the entire screen
Geremia 0:75ec1b3cde17 189 * Basically it sets windomax then fill with background color
Geremia 0:75ec1b3cde17 190 * May be overridden in a derived class.
Geremia 0:75ec1b3cde17 191 */
Geremia 0:75ec1b3cde17 192 virtual void cls();
Geremia 0:75ec1b3cde17 193
Geremia 0:75ec1b3cde17 194 /** draw a circle
Geremia 0:75ec1b3cde17 195 *
Geremia 0:75ec1b3cde17 196 * @param x0,y0 center
Geremia 0:75ec1b3cde17 197 * @param r radius
Geremia 0:75ec1b3cde17 198 * @param color 16 bit color *
Geremia 0:75ec1b3cde17 199 *
Geremia 0:75ec1b3cde17 200 */
Geremia 0:75ec1b3cde17 201 virtual void circle(int x, int y, int r, unsigned short color);
Geremia 0:75ec1b3cde17 202
Geremia 0:75ec1b3cde17 203 /** draw a filled circle
Geremia 0:75ec1b3cde17 204 *
Geremia 0:75ec1b3cde17 205 * @param x0,y0 center
Geremia 0:75ec1b3cde17 206 * @param r radius
Geremia 0:75ec1b3cde17 207 * @param color 16 bit color *
Geremia 0:75ec1b3cde17 208 */
Geremia 0:75ec1b3cde17 209 virtual void fillcircle(int x, int y, int r, unsigned short color);
Geremia 0:75ec1b3cde17 210
Geremia 0:75ec1b3cde17 211
Geremia 0:75ec1b3cde17 212 /** draw a 1 pixel line
Geremia 0:75ec1b3cde17 213 *
Geremia 0:75ec1b3cde17 214 * @param x0,y0 start point
Geremia 0:75ec1b3cde17 215 * @param x1,y1 stop point
Geremia 0:75ec1b3cde17 216 * @param color 16 bit color
Geremia 0:75ec1b3cde17 217 *
Geremia 0:75ec1b3cde17 218 */
Geremia 0:75ec1b3cde17 219 virtual void line(int x0, int y0, int x1, int y1, unsigned short color);
Geremia 0:75ec1b3cde17 220
Geremia 0:75ec1b3cde17 221 /** draw a horizontal line
Geremia 0:75ec1b3cde17 222 *
Geremia 0:75ec1b3cde17 223 * @param x0 horizontal start
Geremia 0:75ec1b3cde17 224 * @param x1 horizontal stop
Geremia 0:75ec1b3cde17 225 * @param y vertical position
Geremia 0:75ec1b3cde17 226 * @param color 16 bit color
Geremia 0:75ec1b3cde17 227 *
Geremia 0:75ec1b3cde17 228 */
Geremia 0:75ec1b3cde17 229 void hline(int x0, int x1, int y, unsigned short color);
Geremia 0:75ec1b3cde17 230
Geremia 0:75ec1b3cde17 231 /** draw a vertical line
Geremia 0:75ec1b3cde17 232 *
Geremia 0:75ec1b3cde17 233 * @param x horizontal position
Geremia 0:75ec1b3cde17 234 * @param y0 vertical start
Geremia 0:75ec1b3cde17 235 * @param y1 vertical stop
Geremia 0:75ec1b3cde17 236 * @param color 16 bit color
Geremia 0:75ec1b3cde17 237 */
Geremia 0:75ec1b3cde17 238 void vline(int y0, int y1, int x, unsigned short color);
Geremia 0:75ec1b3cde17 239
Geremia 0:75ec1b3cde17 240 /** draw a rect
Geremia 0:75ec1b3cde17 241 *
Geremia 0:75ec1b3cde17 242 * @param x0,y0 top left corner
Geremia 0:75ec1b3cde17 243 * @param x1,y1 down right corner
Geremia 0:75ec1b3cde17 244 * @param color 16 bit color
Geremia 0:75ec1b3cde17 245 * *
Geremia 0:75ec1b3cde17 246 */
Geremia 0:75ec1b3cde17 247 virtual void rect(int x0, int y0, int x1, int y1, unsigned short color);
Geremia 0:75ec1b3cde17 248
Geremia 0:75ec1b3cde17 249 /** draw a filled rect
Geremia 0:75ec1b3cde17 250 *
Geremia 0:75ec1b3cde17 251 * @param x0,y0 top left corner
Geremia 0:75ec1b3cde17 252 * @param x1,y1 down right corner
Geremia 0:75ec1b3cde17 253 * @param color 16 bit color
Geremia 0:75ec1b3cde17 254 *
Geremia 0:75ec1b3cde17 255 */
Geremia 0:75ec1b3cde17 256 virtual void fillrect(int x0, int y0, int x1, int y1, unsigned short color);
Geremia 0:75ec1b3cde17 257
Geremia 0:75ec1b3cde17 258 /** setup cursor position for text
Geremia 0:75ec1b3cde17 259 *
Geremia 0:75ec1b3cde17 260 * @param x x-position (top left)
Geremia 0:75ec1b3cde17 261 * @param y y-position
Geremia 0:75ec1b3cde17 262 */
Geremia 0:75ec1b3cde17 263 virtual void locate(int x, int y);
Geremia 0:75ec1b3cde17 264
Geremia 0:75ec1b3cde17 265 /** put a char on the screen
Geremia 0:75ec1b3cde17 266 *
Geremia 0:75ec1b3cde17 267 * @param value char to print
Geremia 0:75ec1b3cde17 268 * @returns printed char
Geremia 0:75ec1b3cde17 269 *
Geremia 0:75ec1b3cde17 270 */
Geremia 0:75ec1b3cde17 271 virtual int _putc(int value);
Geremia 0:75ec1b3cde17 272
Geremia 0:75ec1b3cde17 273 /** draw a character on given position out of the active font to the TFT
Geremia 0:75ec1b3cde17 274 *
Geremia 0:75ec1b3cde17 275 * @param x x-position of char (top left)
Geremia 0:75ec1b3cde17 276 * @param y y-position
Geremia 0:75ec1b3cde17 277 * @param c char to print
Geremia 0:75ec1b3cde17 278 *
Geremia 0:75ec1b3cde17 279 */
Geremia 0:75ec1b3cde17 280 virtual void character(int x, int y, int c);
Geremia 0:75ec1b3cde17 281
Geremia 0:75ec1b3cde17 282 /** paint a bitmap on the TFT
Geremia 0:75ec1b3cde17 283 *
Geremia 0:75ec1b3cde17 284 * @param x,y : upper left corner
Geremia 0:75ec1b3cde17 285 * @param w width of bitmap
Geremia 0:75ec1b3cde17 286 * @param h high of bitmap
Geremia 0:75ec1b3cde17 287 * @param *bitmap pointer to the bitmap data
Geremia 0:75ec1b3cde17 288 *
Geremia 0:75ec1b3cde17 289 * bitmap format: 16 bit R5 G6 B5
Geremia 0:75ec1b3cde17 290 *
Geremia 0:75ec1b3cde17 291 * use Gimp to create / load , save as BMP, option 16 bit R5 G6 B5
Geremia 0:75ec1b3cde17 292 * use winhex to load this file and mark data stating at offset 0x46 to end
Geremia 0:75ec1b3cde17 293 * use edit -> copy block -> C Source to export C array
Geremia 0:75ec1b3cde17 294 * paste this array into your program
Geremia 0:75ec1b3cde17 295 *
Geremia 0:75ec1b3cde17 296 * define the array as static const unsigned char to put it into flash memory
Geremia 0:75ec1b3cde17 297 * cast the pointer to (unsigned char *) :
Geremia 0:75ec1b3cde17 298 * tft.Bitmap(10,40,309,50,(unsigned char *)scala);
Geremia 0:75ec1b3cde17 299 */
Geremia 0:75ec1b3cde17 300 void Bitmap(int x, int y, int w, int h,unsigned char *bitmap);
Geremia 0:75ec1b3cde17 301
Geremia 0:75ec1b3cde17 302 /** paint monochrome bitmap to screen
Geremia 0:75ec1b3cde17 303 *
Geremia 0:75ec1b3cde17 304 * @param bm Bitmap in flash
Geremia 0:75ec1b3cde17 305 * @param x x start
Geremia 0:75ec1b3cde17 306 * @param y y start
Geremia 0:75ec1b3cde17 307 *
Geremia 0:75ec1b3cde17 308 */
Geremia 0:75ec1b3cde17 309 void Bitmap_BW(Bitmap_s bm, int x, int y);
Geremia 0:75ec1b3cde17 310
Geremia 0:75ec1b3cde17 311 /** paint a 16 bit BMP from filesytem on the TFT (slow)
Geremia 0:75ec1b3cde17 312 *
Geremia 0:75ec1b3cde17 313 * @param x,y : position of upper left corner
Geremia 0:75ec1b3cde17 314 * @param *Name_BMP name of the BMP file with drive: "/local/test.bmp"
Geremia 0:75ec1b3cde17 315 *
Geremia 0:75ec1b3cde17 316 * @returns 1 if bmp file was found and painted
Geremia 0:75ec1b3cde17 317 * @returns 0 if bmp file was found not found
Geremia 0:75ec1b3cde17 318 * @returns -1 if file is no bmp
Geremia 0:75ec1b3cde17 319 * @returns -2 if bmp file is no 16 bit bmp
Geremia 0:75ec1b3cde17 320 * @returns -3 if bmp file is to big for screen
Geremia 0:75ec1b3cde17 321 * @returns -4 if buffer malloc go wrong
Geremia 0:75ec1b3cde17 322 *
Geremia 0:75ec1b3cde17 323 * bitmap format: 16 bit R5 G6 B5
Geremia 0:75ec1b3cde17 324 *
Geremia 0:75ec1b3cde17 325 * use Gimp to create / load , save as BMP, option 16 bit R5 G6 B5
Geremia 0:75ec1b3cde17 326 * copy to internal file system or SD card
Geremia 0:75ec1b3cde17 327 */
Geremia 0:75ec1b3cde17 328 int BMP_16(int x, int y, const char *Name_BMP);
Geremia 0:75ec1b3cde17 329
Geremia 0:75ec1b3cde17 330
Geremia 0:75ec1b3cde17 331
Geremia 0:75ec1b3cde17 332 /** select the font to use
Geremia 0:75ec1b3cde17 333 *
Geremia 0:75ec1b3cde17 334 * @param f pointer to font array
Geremia 0:75ec1b3cde17 335 * @param firstascii first ascii code present in font array, default 32 (space)
Geremia 0:75ec1b3cde17 336 * @param lastascii last ascii code present in font array, default 127 (DEL)
Geremia 3:48f3282c2be8 337 * @param proportional enable/disable variable font width (default enabled)
Geremia 0:75ec1b3cde17 338 *
Geremia 0:75ec1b3cde17 339 * font array can created with GLCD Font Creator from http://www.mikroe.com
Geremia 0:75ec1b3cde17 340 * you have to add 4 parameter at the beginning of the font array to use:
Geremia 0:75ec1b3cde17 341 * - the number of byte / char (not used in this revision, set to whatever)
Geremia 0:75ec1b3cde17 342 * - the vertial size in pixel
Geremia 0:75ec1b3cde17 343 * - the horizontal size in pixel
Geremia 0:75ec1b3cde17 344 * - the number of byte per vertical line (not used in this revision, set to whatever)
Geremia 0:75ec1b3cde17 345 * you also have to change the array to cont unsigned char[] and __align(2)
Geremia 0:75ec1b3cde17 346 *
Geremia 0:75ec1b3cde17 347 */
Geremia 3:48f3282c2be8 348 void set_font(unsigned char* f, unsigned char firstascii=32, unsigned char lastascii=127, bool proportional = true);
Geremia 22:f9a37f22b9cb 349
Geremia 22:f9a37f22b9cb 350 /** Zoom fount
Geremia 22:f9a37f22b9cb 351 *
Geremia 22:f9a37f22b9cb 352 * @param x_mul horizontal size multiplier
Geremia 22:f9a37f22b9cb 353 * @param y_mul vertical size multiplier
Geremia 22:f9a37f22b9cb 354 */
Geremia 22:f9a37f22b9cb 355 void set_font_zoom(unsigned char x_mul, unsigned char y_mul);
Geremia 0:75ec1b3cde17 356
Geremia 0:75ec1b3cde17 357 /** Get the number of columns based on the currently active font.
Geremia 0:75ec1b3cde17 358 * @returns number of columns.
Geremia 0:75ec1b3cde17 359 * @note this method may be overridden in a derived class.
Geremia 0:75ec1b3cde17 360 */
Geremia 0:75ec1b3cde17 361 virtual int columns();
Geremia 0:75ec1b3cde17 362
Geremia 0:75ec1b3cde17 363 /** Get the number of rows based on the currently active font.
Geremia 0:75ec1b3cde17 364 * @returns number of rows.
Geremia 0:75ec1b3cde17 365 * @note this method may be overridden in a derived class.
Geremia 0:75ec1b3cde17 366 */
Geremia 0:75ec1b3cde17 367 virtual int rows();
Geremia 0:75ec1b3cde17 368
Geremia 0:75ec1b3cde17 369 /** get the current oriented screen width in pixels
Geremia 0:75ec1b3cde17 370 * @returns screen width in pixels.
Geremia 0:75ec1b3cde17 371 */
Geremia 0:75ec1b3cde17 372 int width();
Geremia 0:75ec1b3cde17 373
Geremia 0:75ec1b3cde17 374 /** get the current oriented screen height in pixels
Geremia 0:75ec1b3cde17 375 * @returns screen height in pixels.
Geremia 0:75ec1b3cde17 376 */
Geremia 0:75ec1b3cde17 377 int height();
Geremia 0:75ec1b3cde17 378
Geremia 0:75ec1b3cde17 379 /** set the current oriented screen width in pixels
Geremia 0:75ec1b3cde17 380 * @param width screen width in pixels.
Geremia 0:75ec1b3cde17 381 */
Geremia 0:75ec1b3cde17 382 void set_width(int width);
Geremia 0:75ec1b3cde17 383
Geremia 0:75ec1b3cde17 384 /** set the current oriented screen height in pixels
Geremia 0:75ec1b3cde17 385 * @param height screen height in pixels.
Geremia 0:75ec1b3cde17 386 */
Geremia 0:75ec1b3cde17 387 void set_height(int height);
Geremia 0:75ec1b3cde17 388
Geremia 2:713844a55c4e 389 /** setup auto update of screen
Geremia 2:713844a55c4e 390 *
Geremia 2:713844a55c4e 391 * @param up 1 = on , 0 = off
Geremia 2:713844a55c4e 392 * if switched off the program has to call copy_to_lcd()
Geremia 2:713844a55c4e 393 * to update screen from framebuffer
Geremia 2:713844a55c4e 394 */
Geremia 2:713844a55c4e 395 void set_auto_up(bool up);
Geremia 2:713844a55c4e 396
Geremia 2:713844a55c4e 397 /** get status of the auto update function
Geremia 2:713844a55c4e 398 *
Geremia 2:713844a55c4e 399 * @returns if auto update is on
Geremia 2:713844a55c4e 400 */
Geremia 2:713844a55c4e 401 bool get_auto_up(void);
Geremia 0:75ec1b3cde17 402
Geremia 0:75ec1b3cde17 403
Geremia 0:75ec1b3cde17 404
Geremia 0:75ec1b3cde17 405 private:
Geremia 0:75ec1b3cde17 406
Geremia 0:75ec1b3cde17 407 unsigned char* font;
Geremia 0:75ec1b3cde17 408 // display width and height related to current orientation
Geremia 0:75ec1b3cde17 409 int oriented_width;
Geremia 0:75ec1b3cde17 410 int oriented_height;
Geremia 0:75ec1b3cde17 411
Geremia 0:75ec1b3cde17 412 // text char location
Geremia 0:75ec1b3cde17 413 int char_x;
Geremia 0:75ec1b3cde17 414 int char_y;
Geremia 0:75ec1b3cde17 415
Geremia 0:75ec1b3cde17 416 int fontoffset;// bytes / char (short)
Geremia 0:75ec1b3cde17 417 int fonthor; // hor size of font (char)
Geremia 0:75ec1b3cde17 418 int fontvert; // ver size of font (char)
Geremia 0:75ec1b3cde17 419 int fontbpl; // bytes per line (char)
Geremia 22:f9a37f22b9cb 420 int fontzoomver; // size multiplier
Geremia 22:f9a37f22b9cb 421 int fontzoomhor; // size multiplier
Geremia 0:75ec1b3cde17 422 unsigned char firstch; // first ascii code present in font array (usually 32)
Geremia 0:75ec1b3cde17 423 unsigned char lastch; // last ascii code present in font array (usually 127)
Geremia 3:48f3282c2be8 424 bool auto_up; // autoupdate flag for LCD
Geremia 3:48f3282c2be8 425 bool fontprop;
Geremia 0:75ec1b3cde17 426
Geremia 0:75ec1b3cde17 427
Geremia 0:75ec1b3cde17 428 };
Geremia 0:75ec1b3cde17 429
Geremia 0:75ec1b3cde17 430 #endif