tr
N5110.h@53:62184d04f9b5, 2021-03-30 (annotated)
- Committer:
- tangguangmin
- Date:
- Tue Mar 30 13:47:15 2021 +0000
- Revision:
- 53:62184d04f9b5
- Parent:
- 52:1210e39a4748
45
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
eencae | 25:444e55e2e419 | 1 | #ifndef N5110_H |
eencae | 25:444e55e2e419 | 2 | #define N5110_H |
eencae | 25:444e55e2e419 | 3 | |
eencae | 25:444e55e2e419 | 4 | #include "mbed.h" |
eencae | 1:df68f34cd32d | 5 | |
eencae | 25:444e55e2e419 | 6 | // Command Bytes - taken from Chris Yan's library |
eencae | 25:444e55e2e419 | 7 | // More information can be found in the display datasheet |
eencae | 25:444e55e2e419 | 8 | // H = 0 - Basic instructions |
eencae | 25:444e55e2e419 | 9 | #define CMD_DC_CLEAR_DISPLAY 0x08 |
eencae | 25:444e55e2e419 | 10 | #define CMD_DC_NORMAL_MODE 0x0C |
eencae | 25:444e55e2e419 | 11 | #define CMD_DC_FILL_DISPLAY 0x09 |
eencae | 25:444e55e2e419 | 12 | #define CMD_DC_INVERT_VIDEO 0x0D |
eencae | 25:444e55e2e419 | 13 | #define CMD_FS_HORIZONTAL_MODE 0x00 |
eencae | 25:444e55e2e419 | 14 | #define CMD_FS_VERTICAL_MODE 0x02 |
eencae | 25:444e55e2e419 | 15 | #define CMD_FS_BASIC_MODE 0x00 |
eencae | 25:444e55e2e419 | 16 | #define CMD_FS_EXTENDED_MODE 0x01 |
eencae | 25:444e55e2e419 | 17 | #define CMD_FS_ACTIVE_MODE 0x00 |
eencae | 25:444e55e2e419 | 18 | #define CMD_FS_POWER_DOWN_MODE 0x04 |
eencae | 25:444e55e2e419 | 19 | // H = 1 - Extended instructions |
eencae | 25:444e55e2e419 | 20 | #define CMD_TC_TEMP_0 0x04 |
eencae | 25:444e55e2e419 | 21 | #define CMD_TC_TEMP_1 0x05 |
eencae | 25:444e55e2e419 | 22 | #define CMD_TC_TEMP_2 0x06 |
eencae | 25:444e55e2e419 | 23 | #define CMD_TC_TEMP_3 0x07 |
eencae | 25:444e55e2e419 | 24 | #define CMD_BI_MUX_24 0x15 |
eencae | 25:444e55e2e419 | 25 | #define CMD_BI_MUX_48 0x13 |
eencae | 25:444e55e2e419 | 26 | #define CMD_BI_MUX_100 0x10 |
eencae | 25:444e55e2e419 | 27 | #define CMD_VOP_6V06 0xB2 |
eencae | 25:444e55e2e419 | 28 | #define CMD_VOP_7V38 0xC8 |
eencae | 25:444e55e2e419 | 29 | |
eencae | 25:444e55e2e419 | 30 | // number of pixels on display |
eencae | 25:444e55e2e419 | 31 | #define WIDTH 84 |
eencae | 25:444e55e2e419 | 32 | #define HEIGHT 48 |
eencae | 25:444e55e2e419 | 33 | #define BANKS 6 |
eencae | 25:444e55e2e419 | 34 | |
valavanisalex | 33:d80e568a2e18 | 35 | /// Fill types for 2D shapes |
valavanisalex | 33:d80e568a2e18 | 36 | enum FillType { |
valavanisalex | 33:d80e568a2e18 | 37 | FILL_TRANSPARENT, ///< Transparent with outline |
valavanisalex | 33:d80e568a2e18 | 38 | FILL_BLACK, ///< Filled black |
valavanisalex | 33:d80e568a2e18 | 39 | FILL_WHITE, ///< Filled white (no outline) |
valavanisalex | 33:d80e568a2e18 | 40 | }; |
valavanisalex | 33:d80e568a2e18 | 41 | |
eencae | 1:df68f34cd32d | 42 | class N5110 |
eencae | 1:df68f34cd32d | 43 | { |
valavanisalex | 29:5bc91bd44c77 | 44 | private: |
valavanisalex | 29:5bc91bd44c77 | 45 | // objects |
valavanisalex | 29:5bc91bd44c77 | 46 | SPI *_spi; |
valavanisalex | 29:5bc91bd44c77 | 47 | PwmOut *_led; |
valavanisalex | 29:5bc91bd44c77 | 48 | DigitalOut *_pwr; |
valavanisalex | 29:5bc91bd44c77 | 49 | DigitalOut *_sce; |
valavanisalex | 29:5bc91bd44c77 | 50 | DigitalOut *_rst; |
valavanisalex | 29:5bc91bd44c77 | 51 | DigitalOut *_dc; |
valavanisalex | 29:5bc91bd44c77 | 52 | |
valavanisalex | 29:5bc91bd44c77 | 53 | // variables |
valavanisalex | 29:5bc91bd44c77 | 54 | unsigned char buffer[84][6]; // screen buffer - the 6 is for the banks - each one is 8 bits; |
eencae | 0:d563e74f0ae9 | 55 | |
eencae | 1:df68f34cd32d | 56 | public: |
valavanisalex | 29:5bc91bd44c77 | 57 | /** Create a N5110 object connected to the specified pins |
valavanisalex | 29:5bc91bd44c77 | 58 | * |
valavanisalex | 29:5bc91bd44c77 | 59 | * @param pwr Pin connected to Vcc on the LCD display (pin 1) |
valavanisalex | 29:5bc91bd44c77 | 60 | * @param sce Pin connected to chip enable (pin 3) |
valavanisalex | 29:5bc91bd44c77 | 61 | * @param rst Pin connected to reset (pin 4) |
valavanisalex | 29:5bc91bd44c77 | 62 | * @param dc Pin connected to data/command select (pin 5) |
valavanisalex | 29:5bc91bd44c77 | 63 | * @param mosi Pin connected to data input (MOSI) (pin 6) |
valavanisalex | 29:5bc91bd44c77 | 64 | * @param sclk Pin connected to serial clock (SCLK) (pin 7) |
valavanisalex | 29:5bc91bd44c77 | 65 | * @param led Pin connected to LED backlight (must be PWM) (pin 8) |
valavanisalex | 29:5bc91bd44c77 | 66 | * |
valavanisalex | 29:5bc91bd44c77 | 67 | */ |
valavanisalex | 29:5bc91bd44c77 | 68 | N5110(PinName const pwrPin, |
valavanisalex | 29:5bc91bd44c77 | 69 | PinName const scePin, |
valavanisalex | 29:5bc91bd44c77 | 70 | PinName const rstPin, |
valavanisalex | 29:5bc91bd44c77 | 71 | PinName const dcPin, |
valavanisalex | 29:5bc91bd44c77 | 72 | PinName const mosiPin, |
valavanisalex | 29:5bc91bd44c77 | 73 | PinName const sclkPin, |
valavanisalex | 29:5bc91bd44c77 | 74 | PinName const ledPin); |
eencae | 17:780a542d5f8b | 75 | |
valavanisalex | 29:5bc91bd44c77 | 76 | /** Create a N5110 object connected to the specified pins (Vcc to +3V3) |
valavanisalex | 29:5bc91bd44c77 | 77 | * |
valavanisalex | 29:5bc91bd44c77 | 78 | * @param sce Pin connected to chip enable (pin 3) |
valavanisalex | 29:5bc91bd44c77 | 79 | * @param rst Pin connected to reset (pin 4) |
valavanisalex | 29:5bc91bd44c77 | 80 | * @param dc Pin connected to data/command select (pin 5) |
valavanisalex | 29:5bc91bd44c77 | 81 | * @param mosi Pin connected to data input (MOSI) (pin 6) |
valavanisalex | 29:5bc91bd44c77 | 82 | * @param sclk Pin connected to serial clock (SCLK) (pin 7) |
valavanisalex | 29:5bc91bd44c77 | 83 | * @param led Pin connected to LED backlight (must be PWM) (pin 8) |
valavanisalex | 29:5bc91bd44c77 | 84 | * |
valavanisalex | 29:5bc91bd44c77 | 85 | */ |
valavanisalex | 29:5bc91bd44c77 | 86 | N5110(PinName const scePin, |
valavanisalex | 29:5bc91bd44c77 | 87 | PinName const rstPin, |
valavanisalex | 29:5bc91bd44c77 | 88 | PinName const dcPin, |
valavanisalex | 29:5bc91bd44c77 | 89 | PinName const mosiPin, |
valavanisalex | 29:5bc91bd44c77 | 90 | PinName const sclkPin, |
valavanisalex | 29:5bc91bd44c77 | 91 | PinName const ledPin); |
eencae | 17:780a542d5f8b | 92 | |
valavanisalex | 31:8a0c21042f82 | 93 | /** |
valavanisalex | 31:8a0c21042f82 | 94 | * Free allocated memory when object goes out of scope |
valavanisalex | 31:8a0c21042f82 | 95 | */ |
valavanisalex | 31:8a0c21042f82 | 96 | ~N5110(); |
valavanisalex | 31:8a0c21042f82 | 97 | |
valavanisalex | 29:5bc91bd44c77 | 98 | /** Initialise display |
valavanisalex | 29:5bc91bd44c77 | 99 | * |
valavanisalex | 29:5bc91bd44c77 | 100 | * Powers up the display and turns on backlight (50% brightness default). |
valavanisalex | 29:5bc91bd44c77 | 101 | * Sets the display up in horizontal addressing mode and with normal video mode. |
valavanisalex | 29:5bc91bd44c77 | 102 | */ |
valavanisalex | 29:5bc91bd44c77 | 103 | void init(); |
eencae | 17:780a542d5f8b | 104 | |
valavanisalex | 29:5bc91bd44c77 | 105 | /** Turn off |
valavanisalex | 29:5bc91bd44c77 | 106 | * |
valavanisalex | 29:5bc91bd44c77 | 107 | * Powers down the display and turns of the backlight. |
valavanisalex | 29:5bc91bd44c77 | 108 | * Needs to be reinitialised before being re-used. |
valavanisalex | 29:5bc91bd44c77 | 109 | */ |
valavanisalex | 29:5bc91bd44c77 | 110 | void turnOff(); |
eencae | 17:780a542d5f8b | 111 | |
valavanisalex | 29:5bc91bd44c77 | 112 | /** Clear |
valavanisalex | 29:5bc91bd44c77 | 113 | * |
valavanisalex | 29:5bc91bd44c77 | 114 | * Clears the screen buffer. |
valavanisalex | 29:5bc91bd44c77 | 115 | */ |
valavanisalex | 29:5bc91bd44c77 | 116 | void clear(); |
eencae | 17:780a542d5f8b | 117 | |
valavanisalex | 29:5bc91bd44c77 | 118 | /** Turn on normal video mode (default) |
valavanisalex | 29:5bc91bd44c77 | 119 | * Black on white |
valavanisalex | 29:5bc91bd44c77 | 120 | */ |
valavanisalex | 29:5bc91bd44c77 | 121 | void normalMode(); |
valavanisalex | 29:5bc91bd44c77 | 122 | |
valavanisalex | 29:5bc91bd44c77 | 123 | /** Turn on inverse video mode (default) |
valavanisalex | 29:5bc91bd44c77 | 124 | * White on black |
valavanisalex | 29:5bc91bd44c77 | 125 | */ |
valavanisalex | 29:5bc91bd44c77 | 126 | void inverseMode(); |
eencae | 17:780a542d5f8b | 127 | |
valavanisalex | 29:5bc91bd44c77 | 128 | /** Set Brightness |
valavanisalex | 29:5bc91bd44c77 | 129 | * |
valavanisalex | 29:5bc91bd44c77 | 130 | * Sets brightness of LED backlight. |
valavanisalex | 29:5bc91bd44c77 | 131 | * @param brightness - float in range 0.0 to 1.0 |
valavanisalex | 29:5bc91bd44c77 | 132 | */ |
valavanisalex | 29:5bc91bd44c77 | 133 | void setBrightness(float const brightness); |
eencae | 17:780a542d5f8b | 134 | |
valavanisalex | 29:5bc91bd44c77 | 135 | /** Print String |
valavanisalex | 29:5bc91bd44c77 | 136 | * |
valavanisalex | 29:5bc91bd44c77 | 137 | * Prints a string of characters to the screen buffer. String is cut-off after the 83rd pixel. |
valavanisalex | 29:5bc91bd44c77 | 138 | * @param x - the column number (0 to 83) |
valavanisalex | 29:5bc91bd44c77 | 139 | * @param y - the row number (0 to 5) - the display is split into 6 banks - each bank can be considered a row |
valavanisalex | 29:5bc91bd44c77 | 140 | */ |
valavanisalex | 29:5bc91bd44c77 | 141 | void printString(char const *str, |
valavanisalex | 29:5bc91bd44c77 | 142 | unsigned int const x, |
valavanisalex | 29:5bc91bd44c77 | 143 | unsigned int const y); |
eencae | 17:780a542d5f8b | 144 | |
valavanisalex | 29:5bc91bd44c77 | 145 | /** Print Character |
valavanisalex | 29:5bc91bd44c77 | 146 | * |
valavanisalex | 29:5bc91bd44c77 | 147 | * Sends a character to the screen buffer. Printed at the specified location. Character is cut-off after the 83rd pixel. |
valavanisalex | 29:5bc91bd44c77 | 148 | * @param c - the character to print. Can print ASCII as so printChar('C'). |
valavanisalex | 29:5bc91bd44c77 | 149 | * @param x - the column number (0 to 83) |
valavanisalex | 29:5bc91bd44c77 | 150 | * @param y - the row number (0 to 5) - the display is split into 6 banks - each bank can be considered a row |
valavanisalex | 29:5bc91bd44c77 | 151 | */ |
valavanisalex | 29:5bc91bd44c77 | 152 | void printChar(char const c, |
valavanisalex | 29:5bc91bd44c77 | 153 | unsigned int const x, |
valavanisalex | 29:5bc91bd44c77 | 154 | unsigned int const y); |
eencae | 17:780a542d5f8b | 155 | |
valavanisalex | 29:5bc91bd44c77 | 156 | /** Set a Pixel |
valavanisalex | 29:5bc91bd44c77 | 157 | * |
valavanisalex | 29:5bc91bd44c77 | 158 | * This function sets a pixel in the screen buffer. |
valavanisalex | 29:5bc91bd44c77 | 159 | * @param x - the x co-ordinate of the pixel (0 to 83) |
valavanisalex | 29:5bc91bd44c77 | 160 | * @param y - the y co-ordinate of the pixel (0 to 47) |
valavanisalex | 29:5bc91bd44c77 | 161 | */ |
valavanisalex | 29:5bc91bd44c77 | 162 | void setPixel(unsigned int const x, |
valavanisalex | 29:5bc91bd44c77 | 163 | unsigned int const y); |
eencae | 17:780a542d5f8b | 164 | |
valavanisalex | 29:5bc91bd44c77 | 165 | /** Clear a Pixel |
valavanisalex | 29:5bc91bd44c77 | 166 | * |
valavanisalex | 29:5bc91bd44c77 | 167 | * This function clears pixel in the screen buffer |
valavanisalex | 29:5bc91bd44c77 | 168 | * @param x - the x co-ordinate of the pixel (0 to 83) |
valavanisalex | 29:5bc91bd44c77 | 169 | * @param y - the y co-ordinate of the pixel (0 to 47) |
valavanisalex | 29:5bc91bd44c77 | 170 | */ |
valavanisalex | 29:5bc91bd44c77 | 171 | void clearPixel(unsigned int const x, |
valavanisalex | 29:5bc91bd44c77 | 172 | unsigned int const y); |
eencae | 17:780a542d5f8b | 173 | |
valavanisalex | 29:5bc91bd44c77 | 174 | /** Get a Pixel |
valavanisalex | 29:5bc91bd44c77 | 175 | * |
valavanisalex | 29:5bc91bd44c77 | 176 | * This function gets the status of a pixel in the screen buffer. |
valavanisalex | 29:5bc91bd44c77 | 177 | * @param x - the x co-ordinate of the pixel (0 to 83) |
valavanisalex | 29:5bc91bd44c77 | 178 | * @param y - the y co-ordinate of the pixel (0 to 47) |
valavanisalex | 29:5bc91bd44c77 | 179 | * @returns |
valavanisalex | 29:5bc91bd44c77 | 180 | * 0 - pixel is clear |
valavanisalex | 29:5bc91bd44c77 | 181 | * 1 - pixel is set |
valavanisalex | 29:5bc91bd44c77 | 182 | */ |
valavanisalex | 29:5bc91bd44c77 | 183 | int getPixel(unsigned int const x, |
valavanisalex | 29:5bc91bd44c77 | 184 | unsigned int const y) const; |
eencae | 17:780a542d5f8b | 185 | |
valavanisalex | 29:5bc91bd44c77 | 186 | /** Refresh display |
valavanisalex | 29:5bc91bd44c77 | 187 | * |
valavanisalex | 29:5bc91bd44c77 | 188 | * This functions sends the screen buffer to the display. |
valavanisalex | 29:5bc91bd44c77 | 189 | */ |
valavanisalex | 29:5bc91bd44c77 | 190 | void refresh(); |
valavanisalex | 29:5bc91bd44c77 | 191 | |
valavanisalex | 29:5bc91bd44c77 | 192 | /** Randomise buffer |
valavanisalex | 29:5bc91bd44c77 | 193 | * |
valavanisalex | 29:5bc91bd44c77 | 194 | * This function fills the buffer with random data. Can be used to test the display. |
valavanisalex | 29:5bc91bd44c77 | 195 | * A call to refresh() must be made to update the display to reflect the change in pixels. |
valavanisalex | 29:5bc91bd44c77 | 196 | * The seed is not set and so the generated pattern will probably be the same each time. |
valavanisalex | 29:5bc91bd44c77 | 197 | * TODO: Randomise the seed - maybe using the noise on the AnalogIn pins. |
valavanisalex | 29:5bc91bd44c77 | 198 | */ |
valavanisalex | 29:5bc91bd44c77 | 199 | void randomiseBuffer(); |
eencae | 17:780a542d5f8b | 200 | |
valavanisalex | 29:5bc91bd44c77 | 201 | /** Plot Array |
valavanisalex | 29:5bc91bd44c77 | 202 | * |
valavanisalex | 29:5bc91bd44c77 | 203 | * This function plots a one-dimensional array in the buffer. |
valavanisalex | 29:5bc91bd44c77 | 204 | * @param array[] - y values of the plot. Values should be normalised in the range 0.0 to 1.0. First 84 plotted. |
valavanisalex | 29:5bc91bd44c77 | 205 | */ |
valavanisalex | 29:5bc91bd44c77 | 206 | void plotArray(float const array[]); |
eencae | 17:780a542d5f8b | 207 | |
valavanisalex | 29:5bc91bd44c77 | 208 | /** Draw Circle |
valavanisalex | 29:5bc91bd44c77 | 209 | * |
valavanisalex | 29:5bc91bd44c77 | 210 | * This function draws a circle at the specified origin with specified radius in the screen buffer |
valavanisalex | 29:5bc91bd44c77 | 211 | * Uses the midpoint circle algorithm. |
valavanisalex | 29:5bc91bd44c77 | 212 | * @see http://en.wikipedia.org/wiki/Midpoint_circle_algorithm |
valavanisalex | 33:d80e568a2e18 | 213 | * @param x0 - x-coordinate of centre |
valavanisalex | 33:d80e568a2e18 | 214 | * @param y0 - y-coordinate of centre |
valavanisalex | 29:5bc91bd44c77 | 215 | * @param radius - radius of circle in pixels |
valavanisalex | 33:d80e568a2e18 | 216 | * @param fill - fill-type for the shape |
valavanisalex | 29:5bc91bd44c77 | 217 | */ |
valavanisalex | 29:5bc91bd44c77 | 218 | void drawCircle(unsigned int const x0, |
valavanisalex | 29:5bc91bd44c77 | 219 | unsigned int const y0, |
valavanisalex | 29:5bc91bd44c77 | 220 | unsigned int const radius, |
valavanisalex | 33:d80e568a2e18 | 221 | FillType const fill); |
eencae | 1:df68f34cd32d | 222 | |
valavanisalex | 29:5bc91bd44c77 | 223 | /** Draw Line |
valavanisalex | 29:5bc91bd44c77 | 224 | * |
valavanisalex | 29:5bc91bd44c77 | 225 | * This function draws a line between the specified points using linear interpolation. |
valavanisalex | 29:5bc91bd44c77 | 226 | * @param x0 - x-coordinate of first point |
valavanisalex | 29:5bc91bd44c77 | 227 | * @param y0 - y-coordinate of first point |
valavanisalex | 29:5bc91bd44c77 | 228 | * @param x1 - x-coordinate of last point |
valavanisalex | 29:5bc91bd44c77 | 229 | * @param y1 - y-coordinate of last point |
valavanisalex | 29:5bc91bd44c77 | 230 | * @param type - 0 white,1 black,2 dotted |
valavanisalex | 29:5bc91bd44c77 | 231 | */ |
valavanisalex | 29:5bc91bd44c77 | 232 | void drawLine(unsigned int const x0, |
valavanisalex | 29:5bc91bd44c77 | 233 | unsigned int const y0, |
valavanisalex | 29:5bc91bd44c77 | 234 | unsigned int const x1, |
valavanisalex | 29:5bc91bd44c77 | 235 | unsigned int const y1, |
valavanisalex | 29:5bc91bd44c77 | 236 | unsigned int const type); |
eencae | 17:780a542d5f8b | 237 | |
valavanisalex | 29:5bc91bd44c77 | 238 | /** Draw Rectangle |
valavanisalex | 29:5bc91bd44c77 | 239 | * |
valavanisalex | 29:5bc91bd44c77 | 240 | * This function draws a rectangle. |
valavanisalex | 29:5bc91bd44c77 | 241 | * @param x0 - x-coordinate of origin (top-left) |
valavanisalex | 29:5bc91bd44c77 | 242 | * @param y0 - y-coordinate of origin (top-left) |
valavanisalex | 29:5bc91bd44c77 | 243 | * @param width - width of rectangle |
valavanisalex | 29:5bc91bd44c77 | 244 | * @param height - height of rectangle |
valavanisalex | 33:d80e568a2e18 | 245 | * @param fill - fill-type for the shape |
valavanisalex | 29:5bc91bd44c77 | 246 | */ |
valavanisalex | 29:5bc91bd44c77 | 247 | void drawRect(unsigned int const x0, |
valavanisalex | 29:5bc91bd44c77 | 248 | unsigned int const y0, |
valavanisalex | 29:5bc91bd44c77 | 249 | unsigned int const width, |
valavanisalex | 29:5bc91bd44c77 | 250 | unsigned int const height, |
valavanisalex | 33:d80e568a2e18 | 251 | FillType const fill); |
eencae | 17:780a542d5f8b | 252 | |
eencae | 36:00ebd449b6f3 | 253 | /** Draw Sprite |
eencae | 36:00ebd449b6f3 | 254 | * |
eencae | 36:00ebd449b6f3 | 255 | * This function draws a sprite as defined in a 2D array |
eencae | 36:00ebd449b6f3 | 256 | * @param x0 - x-coordinate of origin (top-left) |
eencae | 36:00ebd449b6f3 | 257 | * @param y0 - y-coordinate of origin (top-left) |
eencae | 36:00ebd449b6f3 | 258 | * @param nrows - number of rows in sprite |
eencae | 36:00ebd449b6f3 | 259 | * @param ncols - number of columns in sprite |
eencae | 36:00ebd449b6f3 | 260 | * @param sprite - 2D array representing the sprite |
eencae | 36:00ebd449b6f3 | 261 | */ |
eencae | 36:00ebd449b6f3 | 262 | void drawSprite(int x0, |
eencae | 36:00ebd449b6f3 | 263 | int y0, |
eencae | 36:00ebd449b6f3 | 264 | int nrows, |
eencae | 36:00ebd449b6f3 | 265 | int ncols, |
eencae | 36:00ebd449b6f3 | 266 | int *sprite); |
tangguangmin | 52:1210e39a4748 | 267 | |
tangguangmin | 52:1210e39a4748 | 268 | /** Draw pic |
tangguangmin | 52:1210e39a4748 | 269 | * |
tangguangmin | 52:1210e39a4748 | 270 | * 输入的图像必须宽大于84像素,高大于48像素 |
tangguangmin | 52:1210e39a4748 | 271 | * @param x0表示从图像的横坐标位置开始显示 |
tangguangmin | 52:1210e39a4748 | 272 | * @param y0表示从图像的纵坐标位置开始显示 |
tangguangmin | 52:1210e39a4748 | 273 | * @param nrowst图像的总宽度 |
tangguangmin | 52:1210e39a4748 | 274 | * @param ncolst图像的总高度 |
tangguangmin | 52:1210e39a4748 | 275 | * @param pic - 2Dt图像的输入指针 |
tangguangmin | 52:1210e39a4748 | 276 | */ |
tangguangmin | 52:1210e39a4748 | 277 | void drawPic(int x0, |
tangguangmin | 52:1210e39a4748 | 278 | int y0, |
tangguangmin | 52:1210e39a4748 | 279 | int nrows, |
tangguangmin | 52:1210e39a4748 | 280 | int ncols, |
tangguangmin | 52:1210e39a4748 | 281 | char *pic); |
tangguangmin | 52:1210e39a4748 | 282 | |
eencae | 1:df68f34cd32d | 283 | private: |
eencae | 24:342bdb6679a1 | 284 | // methods |
valavanisalex | 29:5bc91bd44c77 | 285 | void setXYAddress(unsigned int const x, |
valavanisalex | 29:5bc91bd44c77 | 286 | unsigned int const y); |
valavanisalex | 29:5bc91bd44c77 | 287 | void initSPI(); |
valavanisalex | 29:5bc91bd44c77 | 288 | void turnOn(); |
valavanisalex | 29:5bc91bd44c77 | 289 | void reset(); |
valavanisalex | 29:5bc91bd44c77 | 290 | void clearRAM(); |
valavanisalex | 29:5bc91bd44c77 | 291 | void sendCommand(unsigned char command); |
valavanisalex | 29:5bc91bd44c77 | 292 | void sendData(unsigned char data); |
eencae | 0:d563e74f0ae9 | 293 | }; |
eencae | 0:d563e74f0ae9 | 294 | |
eencae | 0:d563e74f0ae9 | 295 | const unsigned char font5x7[480] = { |
valavanisalex | 29:5bc91bd44c77 | 296 | 0x00, 0x00, 0x00, 0x00, 0x00,// (space) |
valavanisalex | 29:5bc91bd44c77 | 297 | 0x00, 0x00, 0x5F, 0x00, 0x00,// ! |
valavanisalex | 29:5bc91bd44c77 | 298 | 0x00, 0x07, 0x00, 0x07, 0x00,// " |
valavanisalex | 29:5bc91bd44c77 | 299 | 0x14, 0x7F, 0x14, 0x7F, 0x14,// # |
valavanisalex | 29:5bc91bd44c77 | 300 | 0x24, 0x2A, 0x7F, 0x2A, 0x12,// $ |
valavanisalex | 29:5bc91bd44c77 | 301 | 0x23, 0x13, 0x08, 0x64, 0x62,// % |
valavanisalex | 29:5bc91bd44c77 | 302 | 0x36, 0x49, 0x55, 0x22, 0x50,// & |
valavanisalex | 29:5bc91bd44c77 | 303 | 0x00, 0x05, 0x03, 0x00, 0x00,// ' |
valavanisalex | 29:5bc91bd44c77 | 304 | 0x00, 0x1C, 0x22, 0x41, 0x00,// ( |
valavanisalex | 29:5bc91bd44c77 | 305 | 0x00, 0x41, 0x22, 0x1C, 0x00,// ) |
valavanisalex | 29:5bc91bd44c77 | 306 | 0x08, 0x2A, 0x1C, 0x2A, 0x08,// * |
valavanisalex | 29:5bc91bd44c77 | 307 | 0x08, 0x08, 0x3E, 0x08, 0x08,// + |
valavanisalex | 29:5bc91bd44c77 | 308 | 0x00, 0x50, 0x30, 0x00, 0x00,// , |
valavanisalex | 29:5bc91bd44c77 | 309 | 0x08, 0x08, 0x08, 0x08, 0x08,// - |
valavanisalex | 29:5bc91bd44c77 | 310 | 0x00, 0x60, 0x60, 0x00, 0x00,// . |
valavanisalex | 29:5bc91bd44c77 | 311 | 0x20, 0x10, 0x08, 0x04, 0x02,// / |
valavanisalex | 29:5bc91bd44c77 | 312 | 0x3E, 0x51, 0x49, 0x45, 0x3E,// 0 |
valavanisalex | 29:5bc91bd44c77 | 313 | 0x00, 0x42, 0x7F, 0x40, 0x00,// 1 |
valavanisalex | 29:5bc91bd44c77 | 314 | 0x42, 0x61, 0x51, 0x49, 0x46,// 2 |
valavanisalex | 29:5bc91bd44c77 | 315 | 0x21, 0x41, 0x45, 0x4B, 0x31,// 3 |
valavanisalex | 29:5bc91bd44c77 | 316 | 0x18, 0x14, 0x12, 0x7F, 0x10,// 4 |
valavanisalex | 29:5bc91bd44c77 | 317 | 0x27, 0x45, 0x45, 0x45, 0x39,// 5 |
valavanisalex | 29:5bc91bd44c77 | 318 | 0x3C, 0x4A, 0x49, 0x49, 0x30,// 6 |
valavanisalex | 29:5bc91bd44c77 | 319 | 0x01, 0x71, 0x09, 0x05, 0x03,// 7 |
valavanisalex | 29:5bc91bd44c77 | 320 | 0x36, 0x49, 0x49, 0x49, 0x36,// 8 |
valavanisalex | 29:5bc91bd44c77 | 321 | 0x06, 0x49, 0x49, 0x29, 0x1E,// 9 |
valavanisalex | 29:5bc91bd44c77 | 322 | 0x00, 0x36, 0x36, 0x00, 0x00,// : |
valavanisalex | 29:5bc91bd44c77 | 323 | 0x00, 0x56, 0x36, 0x00, 0x00,// ; |
valavanisalex | 29:5bc91bd44c77 | 324 | 0x00, 0x08, 0x14, 0x22, 0x41,// < |
valavanisalex | 29:5bc91bd44c77 | 325 | 0x14, 0x14, 0x14, 0x14, 0x14,// = |
valavanisalex | 29:5bc91bd44c77 | 326 | 0x41, 0x22, 0x14, 0x08, 0x00,// > |
valavanisalex | 29:5bc91bd44c77 | 327 | 0x02, 0x01, 0x51, 0x09, 0x06,// ? |
valavanisalex | 29:5bc91bd44c77 | 328 | 0x32, 0x49, 0x79, 0x41, 0x3E,// @ |
valavanisalex | 29:5bc91bd44c77 | 329 | 0x7E, 0x11, 0x11, 0x11, 0x7E,// A |
valavanisalex | 29:5bc91bd44c77 | 330 | 0x7F, 0x49, 0x49, 0x49, 0x36,// B |
valavanisalex | 29:5bc91bd44c77 | 331 | 0x3E, 0x41, 0x41, 0x41, 0x22,// C |
valavanisalex | 29:5bc91bd44c77 | 332 | 0x7F, 0x41, 0x41, 0x22, 0x1C,// D |
valavanisalex | 29:5bc91bd44c77 | 333 | 0x7F, 0x49, 0x49, 0x49, 0x41,// E |
valavanisalex | 29:5bc91bd44c77 | 334 | 0x7F, 0x09, 0x09, 0x01, 0x01,// F |
valavanisalex | 29:5bc91bd44c77 | 335 | 0x3E, 0x41, 0x41, 0x51, 0x32,// G |
valavanisalex | 29:5bc91bd44c77 | 336 | 0x7F, 0x08, 0x08, 0x08, 0x7F,// H |
valavanisalex | 29:5bc91bd44c77 | 337 | 0x00, 0x41, 0x7F, 0x41, 0x00,// I |
valavanisalex | 29:5bc91bd44c77 | 338 | 0x20, 0x40, 0x41, 0x3F, 0x01,// J |
valavanisalex | 29:5bc91bd44c77 | 339 | 0x7F, 0x08, 0x14, 0x22, 0x41,// K |
valavanisalex | 29:5bc91bd44c77 | 340 | 0x7F, 0x40, 0x40, 0x40, 0x40,// L |
valavanisalex | 29:5bc91bd44c77 | 341 | 0x7F, 0x02, 0x04, 0x02, 0x7F,// M |
valavanisalex | 29:5bc91bd44c77 | 342 | 0x7F, 0x04, 0x08, 0x10, 0x7F,// N |
valavanisalex | 29:5bc91bd44c77 | 343 | 0x3E, 0x41, 0x41, 0x41, 0x3E,// O |
valavanisalex | 29:5bc91bd44c77 | 344 | 0x7F, 0x09, 0x09, 0x09, 0x06,// P |
valavanisalex | 29:5bc91bd44c77 | 345 | 0x3E, 0x41, 0x51, 0x21, 0x5E,// Q |
valavanisalex | 29:5bc91bd44c77 | 346 | 0x7F, 0x09, 0x19, 0x29, 0x46,// R |
valavanisalex | 29:5bc91bd44c77 | 347 | 0x46, 0x49, 0x49, 0x49, 0x31,// S |
valavanisalex | 29:5bc91bd44c77 | 348 | 0x01, 0x01, 0x7F, 0x01, 0x01,// T |
valavanisalex | 29:5bc91bd44c77 | 349 | 0x3F, 0x40, 0x40, 0x40, 0x3F,// U |
valavanisalex | 29:5bc91bd44c77 | 350 | 0x1F, 0x20, 0x40, 0x20, 0x1F,// V |
valavanisalex | 29:5bc91bd44c77 | 351 | 0x7F, 0x20, 0x18, 0x20, 0x7F,// W |
valavanisalex | 29:5bc91bd44c77 | 352 | 0x63, 0x14, 0x08, 0x14, 0x63,// X |
valavanisalex | 29:5bc91bd44c77 | 353 | 0x03, 0x04, 0x78, 0x04, 0x03,// Y |
valavanisalex | 29:5bc91bd44c77 | 354 | 0x61, 0x51, 0x49, 0x45, 0x43,// Z |
valavanisalex | 29:5bc91bd44c77 | 355 | 0x00, 0x00, 0x7F, 0x41, 0x41,// [ |
valavanisalex | 29:5bc91bd44c77 | 356 | 0x02, 0x04, 0x08, 0x10, 0x20,// "\" |
valavanisalex | 29:5bc91bd44c77 | 357 | 0x41, 0x41, 0x7F, 0x00, 0x00,// ] |
valavanisalex | 29:5bc91bd44c77 | 358 | 0x04, 0x02, 0x01, 0x02, 0x04,// ^ |
valavanisalex | 29:5bc91bd44c77 | 359 | 0x40, 0x40, 0x40, 0x40, 0x40,// _ |
valavanisalex | 29:5bc91bd44c77 | 360 | 0x00, 0x01, 0x02, 0x04, 0x00,// ` |
valavanisalex | 29:5bc91bd44c77 | 361 | 0x20, 0x54, 0x54, 0x54, 0x78,// a |
valavanisalex | 29:5bc91bd44c77 | 362 | 0x7F, 0x48, 0x44, 0x44, 0x38,// b |
valavanisalex | 29:5bc91bd44c77 | 363 | 0x38, 0x44, 0x44, 0x44, 0x20,// c |
valavanisalex | 29:5bc91bd44c77 | 364 | 0x38, 0x44, 0x44, 0x48, 0x7F,// d |
valavanisalex | 29:5bc91bd44c77 | 365 | 0x38, 0x54, 0x54, 0x54, 0x18,// e |
valavanisalex | 29:5bc91bd44c77 | 366 | 0x08, 0x7E, 0x09, 0x01, 0x02,// f |
valavanisalex | 29:5bc91bd44c77 | 367 | 0x08, 0x14, 0x54, 0x54, 0x3C,// g |
valavanisalex | 29:5bc91bd44c77 | 368 | 0x7F, 0x08, 0x04, 0x04, 0x78,// h |
valavanisalex | 29:5bc91bd44c77 | 369 | 0x00, 0x44, 0x7D, 0x40, 0x00,// i |
valavanisalex | 29:5bc91bd44c77 | 370 | 0x20, 0x40, 0x44, 0x3D, 0x00,// j |
valavanisalex | 29:5bc91bd44c77 | 371 | 0x00, 0x7F, 0x10, 0x28, 0x44,// k |
valavanisalex | 29:5bc91bd44c77 | 372 | 0x00, 0x41, 0x7F, 0x40, 0x00,// l |
valavanisalex | 29:5bc91bd44c77 | 373 | 0x7C, 0x04, 0x18, 0x04, 0x78,// m |
valavanisalex | 29:5bc91bd44c77 | 374 | 0x7C, 0x08, 0x04, 0x04, 0x78,// n |
valavanisalex | 29:5bc91bd44c77 | 375 | 0x38, 0x44, 0x44, 0x44, 0x38,// o |
valavanisalex | 29:5bc91bd44c77 | 376 | 0x7C, 0x14, 0x14, 0x14, 0x08,// p |
valavanisalex | 29:5bc91bd44c77 | 377 | 0x08, 0x14, 0x14, 0x18, 0x7C,// q |
valavanisalex | 29:5bc91bd44c77 | 378 | 0x7C, 0x08, 0x04, 0x04, 0x08,// r |
valavanisalex | 29:5bc91bd44c77 | 379 | 0x48, 0x54, 0x54, 0x54, 0x20,// s |
valavanisalex | 29:5bc91bd44c77 | 380 | 0x04, 0x3F, 0x44, 0x40, 0x20,// t |
valavanisalex | 29:5bc91bd44c77 | 381 | 0x3C, 0x40, 0x40, 0x20, 0x7C,// u |
valavanisalex | 29:5bc91bd44c77 | 382 | 0x1C, 0x20, 0x40, 0x20, 0x1C,// v |
valavanisalex | 29:5bc91bd44c77 | 383 | 0x3C, 0x40, 0x30, 0x40, 0x3C,// w |
valavanisalex | 29:5bc91bd44c77 | 384 | 0x44, 0x28, 0x10, 0x28, 0x44,// x |
valavanisalex | 29:5bc91bd44c77 | 385 | 0x0C, 0x50, 0x50, 0x50, 0x3C,// y |
valavanisalex | 29:5bc91bd44c77 | 386 | 0x44, 0x64, 0x54, 0x4C, 0x44,// z |
valavanisalex | 29:5bc91bd44c77 | 387 | 0x00, 0x08, 0x36, 0x41, 0x00,// { |
valavanisalex | 29:5bc91bd44c77 | 388 | 0x00, 0x00, 0x7F, 0x00, 0x00,// | |
valavanisalex | 29:5bc91bd44c77 | 389 | 0x00, 0x41, 0x36, 0x08, 0x00,// } |
valavanisalex | 29:5bc91bd44c77 | 390 | 0x08, 0x08, 0x2A, 0x1C, 0x08,// -> |
valavanisalex | 29:5bc91bd44c77 | 391 | 0x08, 0x1C, 0x2A, 0x08, 0x08 // <- |
eencae | 0:d563e74f0ae9 | 392 | }; |
eencae | 0:d563e74f0ae9 | 393 | |
valavanisalex | 29:5bc91bd44c77 | 394 | #endif |