UniGraphics Library Fork to support mbed os 6.3 Release for ILI9341
Dependents: TFT_ILI9341_UniGraphic TFT_ILI9341_os6
Graphics/GraphicsDisplay.h@2:59188908eb60, 2020-10-08 (annotated)
- Committer:
- amouroug
- Date:
- Thu Oct 08 18:11:03 2020 -0500
- Revision:
- 2:59188908eb60
- Parent:
- 0:bb2bda4f5846
Added GraphicsDisplay GFX API to draw triangle.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
amouroug | 0:bb2bda4f5846 | 1 | /* mbed GraphicsDisplay Display Library Base Class |
amouroug | 0:bb2bda4f5846 | 2 | * Copyright (c) 2007-2009 sford |
amouroug | 0:bb2bda4f5846 | 3 | * Released under the MIT License: http://mbed.org/license/mit |
amouroug | 0:bb2bda4f5846 | 4 | * |
amouroug | 0:bb2bda4f5846 | 5 | * A library for providing a common base class for Graphics displays |
amouroug | 0:bb2bda4f5846 | 6 | * To port a new display, derive from this class and implement |
amouroug | 0:bb2bda4f5846 | 7 | * the constructor (setup the display), pixel (put a pixel |
amouroug | 0:bb2bda4f5846 | 8 | * at a location), width and height functions. Everything else |
amouroug | 0:bb2bda4f5846 | 9 | * (locate, printf, putc, cls, window, putp, fill, blit, blitbit) |
amouroug | 0:bb2bda4f5846 | 10 | * will come for free. You can also provide a specialised implementation |
amouroug | 0:bb2bda4f5846 | 11 | * of window and putp to speed up the results |
amouroug | 0:bb2bda4f5846 | 12 | */ |
amouroug | 0:bb2bda4f5846 | 13 | |
amouroug | 0:bb2bda4f5846 | 14 | #ifndef MBED_GRAPHICSDISPLAY_H |
amouroug | 0:bb2bda4f5846 | 15 | #define MBED_GRAPHICSDISPLAY_H |
amouroug | 0:bb2bda4f5846 | 16 | |
amouroug | 0:bb2bda4f5846 | 17 | #include "TextDisplay.h" |
amouroug | 0:bb2bda4f5846 | 18 | #include "Terminal6x8.h" |
amouroug | 0:bb2bda4f5846 | 19 | |
amouroug | 0:bb2bda4f5846 | 20 | |
amouroug | 0:bb2bda4f5846 | 21 | |
amouroug | 0:bb2bda4f5846 | 22 | /* some RGB color definitions */ |
amouroug | 0:bb2bda4f5846 | 23 | #define Black 0x0000 /* 0, 0, 0 */ |
amouroug | 0:bb2bda4f5846 | 24 | #define Navy 0x000F /* 0, 0, 128 */ |
amouroug | 0:bb2bda4f5846 | 25 | #define DarkGreen 0x03E0 /* 0, 128, 0 */ |
amouroug | 0:bb2bda4f5846 | 26 | #define DarkCyan 0x03EF /* 0, 128, 128 */ |
amouroug | 0:bb2bda4f5846 | 27 | #define Maroon 0x7800 /* 128, 0, 0 */ |
amouroug | 0:bb2bda4f5846 | 28 | #define Purple 0x780F /* 128, 0, 128 */ |
amouroug | 0:bb2bda4f5846 | 29 | #define Olive 0x7BE0 /* 128, 128, 0 */ |
amouroug | 0:bb2bda4f5846 | 30 | #define LightGrey 0xC618 /* 192, 192, 192 */ |
amouroug | 0:bb2bda4f5846 | 31 | #define DarkGrey 0x7BEF /* 128, 128, 128 */ |
amouroug | 0:bb2bda4f5846 | 32 | #define Blue 0x001F /* 0, 0, 255 */ |
amouroug | 0:bb2bda4f5846 | 33 | #define Green 0x07E0 /* 0, 255, 0 */ |
amouroug | 0:bb2bda4f5846 | 34 | #define Cyan 0x07FF /* 0, 255, 255 */ |
amouroug | 0:bb2bda4f5846 | 35 | #define Red 0xF800 /* 255, 0, 0 */ |
amouroug | 0:bb2bda4f5846 | 36 | #define Magenta 0xF81F /* 255, 0, 255 */ |
amouroug | 0:bb2bda4f5846 | 37 | #define Yellow 0xFFE0 /* 255, 255, 0 */ |
amouroug | 0:bb2bda4f5846 | 38 | #define White 0xFFFF /* 255, 255, 255 */ |
amouroug | 0:bb2bda4f5846 | 39 | #define Orange 0xFD20 /* 255, 165, 0 */ |
amouroug | 0:bb2bda4f5846 | 40 | #define GreenYellow 0xAFE5 /* 173, 255, 47 */ |
amouroug | 0:bb2bda4f5846 | 41 | |
amouroug | 0:bb2bda4f5846 | 42 | /** Bitmap |
amouroug | 0:bb2bda4f5846 | 43 | */ |
amouroug | 0:bb2bda4f5846 | 44 | struct Bitmap_s{ |
amouroug | 0:bb2bda4f5846 | 45 | int xSize; |
amouroug | 0:bb2bda4f5846 | 46 | int ySize; |
amouroug | 0:bb2bda4f5846 | 47 | int Byte_in_Line; |
amouroug | 0:bb2bda4f5846 | 48 | char* data; |
amouroug | 0:bb2bda4f5846 | 49 | }; |
amouroug | 0:bb2bda4f5846 | 50 | |
amouroug | 0:bb2bda4f5846 | 51 | /** A common base class for Graphics displays |
amouroug | 0:bb2bda4f5846 | 52 | */ |
amouroug | 0:bb2bda4f5846 | 53 | class GraphicsDisplay : public TextDisplay { |
amouroug | 0:bb2bda4f5846 | 54 | |
amouroug | 0:bb2bda4f5846 | 55 | public: |
amouroug | 0:bb2bda4f5846 | 56 | |
amouroug | 0:bb2bda4f5846 | 57 | /** Create a GraphicsDisplay interface |
amouroug | 0:bb2bda4f5846 | 58 | * @param name The name used by the parent class to access the interface |
amouroug | 0:bb2bda4f5846 | 59 | */ |
amouroug | 0:bb2bda4f5846 | 60 | GraphicsDisplay(const char* name); |
amouroug | 0:bb2bda4f5846 | 61 | |
amouroug | 0:bb2bda4f5846 | 62 | ////// functions needing implementation in derived implementation class /////////////////////////////////////// |
amouroug | 0:bb2bda4f5846 | 63 | ////// ---------------------------------------------------------------- /////////////////////////////////////// |
amouroug | 0:bb2bda4f5846 | 64 | |
amouroug | 0:bb2bda4f5846 | 65 | /** Draw a pixel in the specified color. |
amouroug | 0:bb2bda4f5846 | 66 | * @note this method must be supported in the derived class. |
amouroug | 0:bb2bda4f5846 | 67 | * @param x is the horizontal offset to this pixel. |
amouroug | 0:bb2bda4f5846 | 68 | * @param y is the vertical offset to this pixel. |
amouroug | 0:bb2bda4f5846 | 69 | * @param color defines the color for the pixel. |
amouroug | 0:bb2bda4f5846 | 70 | */ |
amouroug | 0:bb2bda4f5846 | 71 | virtual void pixel(int x, int y, unsigned short color) = 0; |
amouroug | 0:bb2bda4f5846 | 72 | |
amouroug | 0:bb2bda4f5846 | 73 | /** Set the window, which controls where items are written to the screen. |
amouroug | 0:bb2bda4f5846 | 74 | * When something hits the window width, it wraps back to the left side |
amouroug | 0:bb2bda4f5846 | 75 | * and down a row. If the initial write is outside the window, it will |
amouroug | 0:bb2bda4f5846 | 76 | * be captured into the window when it crosses a boundary. |
amouroug | 0:bb2bda4f5846 | 77 | * @param x is the left edge in pixels. |
amouroug | 0:bb2bda4f5846 | 78 | * @param y is the top edge in pixels. |
amouroug | 0:bb2bda4f5846 | 79 | * @param w is the window width in pixels. |
amouroug | 0:bb2bda4f5846 | 80 | * @param h is the window height in pixels. |
amouroug | 0:bb2bda4f5846 | 81 | * @note this method must be overridden in a derived class. |
amouroug | 0:bb2bda4f5846 | 82 | */ |
amouroug | 0:bb2bda4f5846 | 83 | virtual void window(int x, int y, int w, int h) = 0; |
amouroug | 0:bb2bda4f5846 | 84 | |
amouroug | 0:bb2bda4f5846 | 85 | /** Push a single pixel into the window and increment position. |
amouroug | 0:bb2bda4f5846 | 86 | * You may first call window() then push pixels in loop. |
amouroug | 0:bb2bda4f5846 | 87 | * @param color is the pixel color. |
amouroug | 0:bb2bda4f5846 | 88 | * @note this method must be overridden in a derived class. |
amouroug | 0:bb2bda4f5846 | 89 | */ |
amouroug | 0:bb2bda4f5846 | 90 | virtual void window_pushpixel(unsigned short color) = 0; |
amouroug | 0:bb2bda4f5846 | 91 | |
amouroug | 0:bb2bda4f5846 | 92 | /** Push some pixels of the same color into the window and increment position. |
amouroug | 0:bb2bda4f5846 | 93 | * You must first call window() then push pixels. |
amouroug | 0:bb2bda4f5846 | 94 | * @param color is the pixel color. |
amouroug | 0:bb2bda4f5846 | 95 | * @param count: how many |
amouroug | 0:bb2bda4f5846 | 96 | */ |
amouroug | 0:bb2bda4f5846 | 97 | virtual void window_pushpixel(unsigned short color, unsigned int count) = 0; |
amouroug | 0:bb2bda4f5846 | 98 | |
amouroug | 0:bb2bda4f5846 | 99 | /** Push array of pixel colors into the window and increment position. |
amouroug | 0:bb2bda4f5846 | 100 | * You must first call window() then push pixels. |
amouroug | 0:bb2bda4f5846 | 101 | * @param color is the pixel color. |
amouroug | 0:bb2bda4f5846 | 102 | */ |
amouroug | 0:bb2bda4f5846 | 103 | virtual void window_pushpixelbuf(unsigned short* color, unsigned int lenght) = 0; |
amouroug | 0:bb2bda4f5846 | 104 | |
amouroug | 0:bb2bda4f5846 | 105 | /** If framebuffer is used, it needs to be sent to LCD from time to time |
amouroug | 0:bb2bda4f5846 | 106 | @note this method must be overridden in a derived class. |
amouroug | 0:bb2bda4f5846 | 107 | @note real function for LCD, dummy for TFT |
amouroug | 0:bb2bda4f5846 | 108 | */ |
amouroug | 0:bb2bda4f5846 | 109 | virtual void copy_to_lcd() = 0; |
amouroug | 0:bb2bda4f5846 | 110 | |
amouroug | 0:bb2bda4f5846 | 111 | /////// functions that come for free, but can be overwritten/////////////////////////////////////////////////// |
amouroug | 0:bb2bda4f5846 | 112 | /////// ----------------------------------------------------/////////////////////////////////////////////////// |
amouroug | 0:bb2bda4f5846 | 113 | |
amouroug | 0:bb2bda4f5846 | 114 | /** Set window to max possible size |
amouroug | 0:bb2bda4f5846 | 115 | * May be overridden in a derived class. |
amouroug | 0:bb2bda4f5846 | 116 | */ |
amouroug | 0:bb2bda4f5846 | 117 | virtual void WindowMax(void); |
amouroug | 0:bb2bda4f5846 | 118 | |
amouroug | 0:bb2bda4f5846 | 119 | /** clear the entire screen |
amouroug | 0:bb2bda4f5846 | 120 | * Basically it sets windomax then fill with background color |
amouroug | 0:bb2bda4f5846 | 121 | * May be overridden in a derived class. |
amouroug | 0:bb2bda4f5846 | 122 | */ |
amouroug | 0:bb2bda4f5846 | 123 | virtual void cls(); |
amouroug | 0:bb2bda4f5846 | 124 | |
amouroug | 0:bb2bda4f5846 | 125 | /** draw a circle |
amouroug | 0:bb2bda4f5846 | 126 | * |
amouroug | 0:bb2bda4f5846 | 127 | * @param x0,y0 center |
amouroug | 0:bb2bda4f5846 | 128 | * @param r radius |
amouroug | 0:bb2bda4f5846 | 129 | * @param color 16 bit color * |
amouroug | 0:bb2bda4f5846 | 130 | * |
amouroug | 0:bb2bda4f5846 | 131 | */ |
amouroug | 0:bb2bda4f5846 | 132 | virtual void circle(int x, int y, int r, unsigned short color); |
amouroug | 0:bb2bda4f5846 | 133 | |
amouroug | 0:bb2bda4f5846 | 134 | /** draw a filled circle |
amouroug | 0:bb2bda4f5846 | 135 | * |
amouroug | 0:bb2bda4f5846 | 136 | * @param x0,y0 center |
amouroug | 0:bb2bda4f5846 | 137 | * @param r radius |
amouroug | 0:bb2bda4f5846 | 138 | * @param color 16 bit color * |
amouroug | 0:bb2bda4f5846 | 139 | */ |
amouroug | 0:bb2bda4f5846 | 140 | virtual void fillcircle(int x, int y, int r, unsigned short color); |
amouroug | 0:bb2bda4f5846 | 141 | |
amouroug | 0:bb2bda4f5846 | 142 | |
amouroug | 0:bb2bda4f5846 | 143 | /** draw a 1 pixel line |
amouroug | 0:bb2bda4f5846 | 144 | * |
amouroug | 0:bb2bda4f5846 | 145 | * @param x0,y0 start point |
amouroug | 0:bb2bda4f5846 | 146 | * @param x1,y1 stop point |
amouroug | 0:bb2bda4f5846 | 147 | * @param color 16 bit color |
amouroug | 0:bb2bda4f5846 | 148 | * |
amouroug | 0:bb2bda4f5846 | 149 | */ |
amouroug | 0:bb2bda4f5846 | 150 | virtual void line(int x0, int y0, int x1, int y1, unsigned short color); |
amouroug | 0:bb2bda4f5846 | 151 | |
amouroug | 0:bb2bda4f5846 | 152 | /** draw a horizontal line |
amouroug | 0:bb2bda4f5846 | 153 | * |
amouroug | 0:bb2bda4f5846 | 154 | * @param x0 horizontal start |
amouroug | 0:bb2bda4f5846 | 155 | * @param x1 horizontal stop |
amouroug | 0:bb2bda4f5846 | 156 | * @param y vertical position |
amouroug | 0:bb2bda4f5846 | 157 | * @param color 16 bit color |
amouroug | 0:bb2bda4f5846 | 158 | * |
amouroug | 0:bb2bda4f5846 | 159 | */ |
amouroug | 0:bb2bda4f5846 | 160 | void hline(int x0, int x1, int y, unsigned short color); |
amouroug | 0:bb2bda4f5846 | 161 | |
amouroug | 0:bb2bda4f5846 | 162 | /** draw a vertical line |
amouroug | 0:bb2bda4f5846 | 163 | * |
amouroug | 0:bb2bda4f5846 | 164 | * @param x horizontal position |
amouroug | 0:bb2bda4f5846 | 165 | * @param y0 vertical start |
amouroug | 0:bb2bda4f5846 | 166 | * @param y1 vertical stop |
amouroug | 0:bb2bda4f5846 | 167 | * @param color 16 bit color |
amouroug | 0:bb2bda4f5846 | 168 | */ |
amouroug | 0:bb2bda4f5846 | 169 | void vline(int y0, int y1, int x, unsigned short color); |
amouroug | 0:bb2bda4f5846 | 170 | |
amouroug | 0:bb2bda4f5846 | 171 | /** draw a rect |
amouroug | 0:bb2bda4f5846 | 172 | * |
amouroug | 0:bb2bda4f5846 | 173 | * @param x0,y0 top left corner |
amouroug | 0:bb2bda4f5846 | 174 | * @param x1,y1 down right corner |
amouroug | 0:bb2bda4f5846 | 175 | * @param color 16 bit color |
amouroug | 0:bb2bda4f5846 | 176 | * * |
amouroug | 0:bb2bda4f5846 | 177 | */ |
amouroug | 0:bb2bda4f5846 | 178 | virtual void rect(int x0, int y0, int x1, int y1, unsigned short color); |
amouroug | 0:bb2bda4f5846 | 179 | |
amouroug | 0:bb2bda4f5846 | 180 | /** draw a filled rect |
amouroug | 0:bb2bda4f5846 | 181 | * |
amouroug | 0:bb2bda4f5846 | 182 | * @param x0,y0 top left corner |
amouroug | 0:bb2bda4f5846 | 183 | * @param x1,y1 down right corner |
amouroug | 0:bb2bda4f5846 | 184 | * @param color 16 bit color |
amouroug | 0:bb2bda4f5846 | 185 | * |
amouroug | 0:bb2bda4f5846 | 186 | */ |
amouroug | 0:bb2bda4f5846 | 187 | virtual void fillrect(int x0, int y0, int x1, int y1, unsigned short color); |
amouroug | 0:bb2bda4f5846 | 188 | |
amouroug | 2:59188908eb60 | 189 | /** draw a empty triangle |
amouroug | 2:59188908eb60 | 190 | * |
amouroug | 2:59188908eb60 | 191 | * @param x0,y0 1st vertice of triangle |
amouroug | 2:59188908eb60 | 192 | * @param x1,y1 2nd vertice of triangle |
amouroug | 2:59188908eb60 | 193 | * @param x2,y2 3rd vertice of triangle |
amouroug | 2:59188908eb60 | 194 | * @param color 16 bit color |
amouroug | 2:59188908eb60 | 195 | * |
amouroug | 2:59188908eb60 | 196 | */ |
amouroug | 2:59188908eb60 | 197 | virtual void triangle(int x0, int y0,int x1, int y1, int x2, int y2, unsigned short color); |
amouroug | 2:59188908eb60 | 198 | |
amouroug | 2:59188908eb60 | 199 | /** draw a filled triangle |
amouroug | 2:59188908eb60 | 200 | * |
amouroug | 2:59188908eb60 | 201 | * @param x0,y0 1st vertice of triangle |
amouroug | 2:59188908eb60 | 202 | * @param x1,y1 2nd vertice of triangle |
amouroug | 2:59188908eb60 | 203 | * @param x2,y2 3rd vertice of triangle |
amouroug | 2:59188908eb60 | 204 | * @param color 16 bit color |
amouroug | 2:59188908eb60 | 205 | * |
amouroug | 2:59188908eb60 | 206 | */ |
amouroug | 2:59188908eb60 | 207 | virtual void fillTriangle(int x0, int y0, int x1, int y1, int x2, int y2, unsigned short color); |
amouroug | 2:59188908eb60 | 208 | |
amouroug | 0:bb2bda4f5846 | 209 | /** setup cursor position for text |
amouroug | 0:bb2bda4f5846 | 210 | * |
amouroug | 0:bb2bda4f5846 | 211 | * @param x x-position (top left) |
amouroug | 0:bb2bda4f5846 | 212 | * @param y y-position |
amouroug | 0:bb2bda4f5846 | 213 | */ |
amouroug | 0:bb2bda4f5846 | 214 | virtual void locate(int x, int y); |
amouroug | 0:bb2bda4f5846 | 215 | |
amouroug | 0:bb2bda4f5846 | 216 | /** put a char on the screen |
amouroug | 0:bb2bda4f5846 | 217 | * |
amouroug | 0:bb2bda4f5846 | 218 | * @param value char to print |
amouroug | 0:bb2bda4f5846 | 219 | * @returns printed char |
amouroug | 0:bb2bda4f5846 | 220 | * |
amouroug | 0:bb2bda4f5846 | 221 | */ |
amouroug | 0:bb2bda4f5846 | 222 | virtual int _putc(int value); |
amouroug | 0:bb2bda4f5846 | 223 | |
amouroug | 0:bb2bda4f5846 | 224 | /** draw a character on given position out of the active font to the TFT |
amouroug | 0:bb2bda4f5846 | 225 | * |
amouroug | 0:bb2bda4f5846 | 226 | * @param x x-position of char (top left) |
amouroug | 0:bb2bda4f5846 | 227 | * @param y y-position |
amouroug | 0:bb2bda4f5846 | 228 | * @param c char to print |
amouroug | 0:bb2bda4f5846 | 229 | * |
amouroug | 0:bb2bda4f5846 | 230 | */ |
amouroug | 0:bb2bda4f5846 | 231 | virtual void character(int x, int y, int c); |
amouroug | 0:bb2bda4f5846 | 232 | |
amouroug | 0:bb2bda4f5846 | 233 | /** paint a bitmap on the TFT |
amouroug | 0:bb2bda4f5846 | 234 | * |
amouroug | 0:bb2bda4f5846 | 235 | * @param x,y : upper left corner |
amouroug | 0:bb2bda4f5846 | 236 | * @param w width of bitmap |
amouroug | 0:bb2bda4f5846 | 237 | * @param h high of bitmap |
amouroug | 0:bb2bda4f5846 | 238 | * @param *bitmap pointer to the bitmap data |
amouroug | 0:bb2bda4f5846 | 239 | * |
amouroug | 0:bb2bda4f5846 | 240 | * bitmap format: 16 bit R5 G6 B5 |
amouroug | 0:bb2bda4f5846 | 241 | * |
amouroug | 0:bb2bda4f5846 | 242 | * use Gimp to create / load , save as BMP, option 16 bit R5 G6 B5 |
amouroug | 0:bb2bda4f5846 | 243 | * use winhex to load this file and mark data stating at offset 0x46 to end |
amouroug | 0:bb2bda4f5846 | 244 | * use edit -> copy block -> C Source to export C array |
amouroug | 0:bb2bda4f5846 | 245 | * paste this array into your program |
amouroug | 0:bb2bda4f5846 | 246 | * |
amouroug | 0:bb2bda4f5846 | 247 | * define the array as static const unsigned char to put it into flash memory |
amouroug | 0:bb2bda4f5846 | 248 | * cast the pointer to (unsigned char *) : |
amouroug | 0:bb2bda4f5846 | 249 | * tft.Bitmap(10,40,309,50,(unsigned char *)scala); |
amouroug | 0:bb2bda4f5846 | 250 | */ |
amouroug | 0:bb2bda4f5846 | 251 | void Bitmap(int x, int y, int w, int h,unsigned char *bitmap); |
amouroug | 0:bb2bda4f5846 | 252 | |
amouroug | 0:bb2bda4f5846 | 253 | /** paint monochrome bitmap to screen |
amouroug | 0:bb2bda4f5846 | 254 | * |
amouroug | 0:bb2bda4f5846 | 255 | * @param bm Bitmap in flash |
amouroug | 0:bb2bda4f5846 | 256 | * @param x x start |
amouroug | 0:bb2bda4f5846 | 257 | * @param y y start |
amouroug | 0:bb2bda4f5846 | 258 | * |
amouroug | 0:bb2bda4f5846 | 259 | */ |
amouroug | 0:bb2bda4f5846 | 260 | void Bitmap_BW(Bitmap_s bm, int x, int y); |
amouroug | 0:bb2bda4f5846 | 261 | |
amouroug | 0:bb2bda4f5846 | 262 | /** paint a 16 bit BMP from filesytem on the TFT (slow) |
amouroug | 0:bb2bda4f5846 | 263 | * |
amouroug | 0:bb2bda4f5846 | 264 | * @param x,y : position of upper left corner |
amouroug | 0:bb2bda4f5846 | 265 | * @param *Name_BMP name of the BMP file with drive: "/local/test.bmp" |
amouroug | 0:bb2bda4f5846 | 266 | * |
amouroug | 0:bb2bda4f5846 | 267 | * @returns 1 if bmp file was found and painted |
amouroug | 0:bb2bda4f5846 | 268 | * @returns 0 if bmp file was found not found |
amouroug | 0:bb2bda4f5846 | 269 | * @returns -1 if file is no bmp |
amouroug | 0:bb2bda4f5846 | 270 | * @returns -2 if bmp file is no 16 bit bmp |
amouroug | 0:bb2bda4f5846 | 271 | * @returns -3 if bmp file is to big for screen |
amouroug | 0:bb2bda4f5846 | 272 | * @returns -4 if buffer malloc go wrong |
amouroug | 0:bb2bda4f5846 | 273 | * |
amouroug | 0:bb2bda4f5846 | 274 | * bitmap format: 16 bit R5 G6 B5 |
amouroug | 0:bb2bda4f5846 | 275 | * |
amouroug | 0:bb2bda4f5846 | 276 | * use Gimp to create / load , save as BMP, option 16 bit R5 G6 B5 |
amouroug | 0:bb2bda4f5846 | 277 | * copy to internal file system or SD card |
amouroug | 0:bb2bda4f5846 | 278 | */ |
amouroug | 0:bb2bda4f5846 | 279 | int BMP_16(int x, int y, const char *Name_BMP); |
amouroug | 0:bb2bda4f5846 | 280 | |
amouroug | 0:bb2bda4f5846 | 281 | |
amouroug | 0:bb2bda4f5846 | 282 | |
amouroug | 0:bb2bda4f5846 | 283 | /** select the font to use |
amouroug | 0:bb2bda4f5846 | 284 | * |
amouroug | 0:bb2bda4f5846 | 285 | * @param f pointer to font array |
amouroug | 0:bb2bda4f5846 | 286 | * @param firstascii first ascii code present in font array, default 32 (space) |
amouroug | 0:bb2bda4f5846 | 287 | * @param lastascii last ascii code present in font array, default 127 (DEL) |
amouroug | 0:bb2bda4f5846 | 288 | * @param proportional enable/disable variable font width (default enabled) |
amouroug | 0:bb2bda4f5846 | 289 | * |
amouroug | 0:bb2bda4f5846 | 290 | * font array can created with GLCD Font Creator from http://www.mikroe.com |
amouroug | 0:bb2bda4f5846 | 291 | * you have to add 4 parameter at the beginning of the font array to use: |
amouroug | 0:bb2bda4f5846 | 292 | * - the number of byte / char (not used in this revision, set to whatever) |
amouroug | 0:bb2bda4f5846 | 293 | * - the vertial size in pixel |
amouroug | 0:bb2bda4f5846 | 294 | * - the horizontal size in pixel |
amouroug | 0:bb2bda4f5846 | 295 | * - the number of byte per vertical line (not used in this revision, set to whatever) |
amouroug | 0:bb2bda4f5846 | 296 | * you also have to change the array to cont unsigned char[] and __align(2) |
amouroug | 0:bb2bda4f5846 | 297 | * |
amouroug | 0:bb2bda4f5846 | 298 | */ |
amouroug | 0:bb2bda4f5846 | 299 | void set_font(unsigned char* f, unsigned char firstascii=32, unsigned char lastascii=127, bool proportional = true); |
amouroug | 0:bb2bda4f5846 | 300 | |
amouroug | 0:bb2bda4f5846 | 301 | /** Zoom fount |
amouroug | 0:bb2bda4f5846 | 302 | * |
amouroug | 0:bb2bda4f5846 | 303 | * @param x_mul horizontal size multiplier |
amouroug | 0:bb2bda4f5846 | 304 | * @param y_mul vertical size multiplier |
amouroug | 0:bb2bda4f5846 | 305 | */ |
amouroug | 0:bb2bda4f5846 | 306 | void set_font_zoom(unsigned char x_mul, unsigned char y_mul); |
amouroug | 0:bb2bda4f5846 | 307 | |
amouroug | 0:bb2bda4f5846 | 308 | /** Get the number of columns based on the currently active font. |
amouroug | 0:bb2bda4f5846 | 309 | * @returns number of columns. |
amouroug | 0:bb2bda4f5846 | 310 | * @note this method may be overridden in a derived class. |
amouroug | 0:bb2bda4f5846 | 311 | */ |
amouroug | 0:bb2bda4f5846 | 312 | virtual int columns(); |
amouroug | 0:bb2bda4f5846 | 313 | |
amouroug | 0:bb2bda4f5846 | 314 | /** Get the number of rows based on the currently active font. |
amouroug | 0:bb2bda4f5846 | 315 | * @returns number of rows. |
amouroug | 0:bb2bda4f5846 | 316 | * @note this method may be overridden in a derived class. |
amouroug | 0:bb2bda4f5846 | 317 | */ |
amouroug | 0:bb2bda4f5846 | 318 | virtual int rows(); |
amouroug | 0:bb2bda4f5846 | 319 | |
amouroug | 0:bb2bda4f5846 | 320 | /** get the current oriented screen width in pixels |
amouroug | 0:bb2bda4f5846 | 321 | * @returns screen width in pixels. |
amouroug | 0:bb2bda4f5846 | 322 | */ |
amouroug | 0:bb2bda4f5846 | 323 | int width(); |
amouroug | 0:bb2bda4f5846 | 324 | |
amouroug | 0:bb2bda4f5846 | 325 | /** get the current oriented screen height in pixels |
amouroug | 0:bb2bda4f5846 | 326 | * @returns screen height in pixels. |
amouroug | 0:bb2bda4f5846 | 327 | */ |
amouroug | 0:bb2bda4f5846 | 328 | int height(); |
amouroug | 0:bb2bda4f5846 | 329 | |
amouroug | 0:bb2bda4f5846 | 330 | /** set the current oriented screen width in pixels |
amouroug | 0:bb2bda4f5846 | 331 | * @param width screen width in pixels. |
amouroug | 0:bb2bda4f5846 | 332 | */ |
amouroug | 0:bb2bda4f5846 | 333 | void set_width(int width); |
amouroug | 0:bb2bda4f5846 | 334 | |
amouroug | 0:bb2bda4f5846 | 335 | /** set the current oriented screen height in pixels |
amouroug | 0:bb2bda4f5846 | 336 | * @param height screen height in pixels. |
amouroug | 0:bb2bda4f5846 | 337 | */ |
amouroug | 0:bb2bda4f5846 | 338 | void set_height(int height); |
amouroug | 0:bb2bda4f5846 | 339 | |
amouroug | 0:bb2bda4f5846 | 340 | /** setup auto update of screen |
amouroug | 0:bb2bda4f5846 | 341 | * |
amouroug | 0:bb2bda4f5846 | 342 | * @param up 1 = on , 0 = off |
amouroug | 0:bb2bda4f5846 | 343 | * if switched off the program has to call copy_to_lcd() |
amouroug | 0:bb2bda4f5846 | 344 | * to update screen from framebuffer |
amouroug | 0:bb2bda4f5846 | 345 | */ |
amouroug | 0:bb2bda4f5846 | 346 | void set_auto_up(bool up); |
amouroug | 0:bb2bda4f5846 | 347 | |
amouroug | 0:bb2bda4f5846 | 348 | /** get status of the auto update function |
amouroug | 0:bb2bda4f5846 | 349 | * |
amouroug | 0:bb2bda4f5846 | 350 | * @returns if auto update is on |
amouroug | 0:bb2bda4f5846 | 351 | */ |
amouroug | 0:bb2bda4f5846 | 352 | bool get_auto_up(void); |
amouroug | 0:bb2bda4f5846 | 353 | |
amouroug | 0:bb2bda4f5846 | 354 | |
amouroug | 0:bb2bda4f5846 | 355 | |
amouroug | 0:bb2bda4f5846 | 356 | private: |
amouroug | 0:bb2bda4f5846 | 357 | |
amouroug | 0:bb2bda4f5846 | 358 | unsigned char* font; |
amouroug | 0:bb2bda4f5846 | 359 | // display width and height related to current orientation |
amouroug | 0:bb2bda4f5846 | 360 | int oriented_width; |
amouroug | 0:bb2bda4f5846 | 361 | int oriented_height; |
amouroug | 0:bb2bda4f5846 | 362 | |
amouroug | 0:bb2bda4f5846 | 363 | // text char location |
amouroug | 0:bb2bda4f5846 | 364 | int char_x; |
amouroug | 0:bb2bda4f5846 | 365 | int char_y; |
amouroug | 0:bb2bda4f5846 | 366 | |
amouroug | 0:bb2bda4f5846 | 367 | int fontoffset;// bytes / char (short) |
amouroug | 0:bb2bda4f5846 | 368 | int fonthor; // hor size of font (char) |
amouroug | 0:bb2bda4f5846 | 369 | int fontvert; // ver size of font (char) |
amouroug | 0:bb2bda4f5846 | 370 | int fontbpl; // bytes per line (char) |
amouroug | 0:bb2bda4f5846 | 371 | int fontzoomver; // size multiplier |
amouroug | 0:bb2bda4f5846 | 372 | int fontzoomhor; // size multiplier |
amouroug | 0:bb2bda4f5846 | 373 | unsigned char firstch; // first ascii code present in font array (usually 32) |
amouroug | 0:bb2bda4f5846 | 374 | unsigned char lastch; // last ascii code present in font array (usually 127) |
amouroug | 0:bb2bda4f5846 | 375 | bool auto_up; // autoupdate flag for LCD |
amouroug | 0:bb2bda4f5846 | 376 | bool fontprop; |
amouroug | 0:bb2bda4f5846 | 377 | |
amouroug | 0:bb2bda4f5846 | 378 | |
amouroug | 0:bb2bda4f5846 | 379 | }; |
amouroug | 0:bb2bda4f5846 | 380 | |
amouroug | 0:bb2bda4f5846 | 381 | #endif |