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.
Dependencies: EthernetInterface NTPClient mbed-rtos mbed
LedPanel/LedPanel_GFX.h@0:7d6abca457ee, 2015-12-23 (annotated)
- Committer:
- mbed_Cookbook_SE
- Date:
- Wed Dec 23 16:17:01 2015 +0000
- Revision:
- 0:7d6abca457ee
??
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| mbed_Cookbook_SE | 0:7d6abca457ee | 1 | /*********************************** |
| mbed_Cookbook_SE | 0:7d6abca457ee | 2 | This is a our graphics core library, for all our displays. |
| mbed_Cookbook_SE | 0:7d6abca457ee | 3 | We'll be adapting all the |
| mbed_Cookbook_SE | 0:7d6abca457ee | 4 | existing libaries to use this core to make updating, support |
| mbed_Cookbook_SE | 0:7d6abca457ee | 5 | and upgrading easier! |
| mbed_Cookbook_SE | 0:7d6abca457ee | 6 | |
| mbed_Cookbook_SE | 0:7d6abca457ee | 7 | Adafruit invests time and resources providing this open source code, |
| mbed_Cookbook_SE | 0:7d6abca457ee | 8 | please support Adafruit and open-source hardware by purchasing |
| mbed_Cookbook_SE | 0:7d6abca457ee | 9 | products from Adafruit! |
| mbed_Cookbook_SE | 0:7d6abca457ee | 10 | |
| mbed_Cookbook_SE | 0:7d6abca457ee | 11 | Written by Limor Fried/Ladyada for Adafruit Industries. |
| mbed_Cookbook_SE | 0:7d6abca457ee | 12 | BSD license, check license.txt for more information |
| mbed_Cookbook_SE | 0:7d6abca457ee | 13 | All text above must be included in any redistribution |
| mbed_Cookbook_SE | 0:7d6abca457ee | 14 | ****************************************/ |
| mbed_Cookbook_SE | 0:7d6abca457ee | 15 | |
| mbed_Cookbook_SE | 0:7d6abca457ee | 16 | /* |
| mbed_Cookbook_SE | 0:7d6abca457ee | 17 | * Modified by Neal Horman 7/14/2012 for use in LPC1768 |
| mbed_Cookbook_SE | 0:7d6abca457ee | 18 | */ |
| mbed_Cookbook_SE | 0:7d6abca457ee | 19 | |
| mbed_Cookbook_SE | 0:7d6abca457ee | 20 | /** |
| mbed_Cookbook_SE | 0:7d6abca457ee | 21 | * Matrix16x16 LEDPanel Grafix library |
| mbed_Cookbook_SE | 0:7d6abca457ee | 22 | * |
| mbed_Cookbook_SE | 0:7d6abca457ee | 23 | * @author Junichi Katsu |
| mbed_Cookbook_SE | 0:7d6abca457ee | 24 | * @version 1.0 |
| mbed_Cookbook_SE | 0:7d6abca457ee | 25 | * @date 15-April-2015 |
| mbed_Cookbook_SE | 0:7d6abca457ee | 26 | * |
| mbed_Cookbook_SE | 0:7d6abca457ee | 27 | */ |
| mbed_Cookbook_SE | 0:7d6abca457ee | 28 | |
| mbed_Cookbook_SE | 0:7d6abca457ee | 29 | #ifndef MBED_LEDPANEL_GFX_H_ |
| mbed_Cookbook_SE | 0:7d6abca457ee | 30 | #define MBED_LEDPANEL_GFX_H_ |
| mbed_Cookbook_SE | 0:7d6abca457ee | 31 | |
| mbed_Cookbook_SE | 0:7d6abca457ee | 32 | #include "font.h" |
| mbed_Cookbook_SE | 0:7d6abca457ee | 33 | |
| mbed_Cookbook_SE | 0:7d6abca457ee | 34 | static inline void swap(int16_t &a, int16_t &b) |
| mbed_Cookbook_SE | 0:7d6abca457ee | 35 | { |
| mbed_Cookbook_SE | 0:7d6abca457ee | 36 | int16_t t = a; |
| mbed_Cookbook_SE | 0:7d6abca457ee | 37 | |
| mbed_Cookbook_SE | 0:7d6abca457ee | 38 | a = b; |
| mbed_Cookbook_SE | 0:7d6abca457ee | 39 | b = t; |
| mbed_Cookbook_SE | 0:7d6abca457ee | 40 | } |
| mbed_Cookbook_SE | 0:7d6abca457ee | 41 | |
| mbed_Cookbook_SE | 0:7d6abca457ee | 42 | #ifndef _BV |
| mbed_Cookbook_SE | 0:7d6abca457ee | 43 | #define _BV(bit) (1<<(bit)) |
| mbed_Cookbook_SE | 0:7d6abca457ee | 44 | #endif |
| mbed_Cookbook_SE | 0:7d6abca457ee | 45 | |
| mbed_Cookbook_SE | 0:7d6abca457ee | 46 | #define BLACK 0 |
| mbed_Cookbook_SE | 0:7d6abca457ee | 47 | #define WHITE 1 |
| mbed_Cookbook_SE | 0:7d6abca457ee | 48 | |
| mbed_Cookbook_SE | 0:7d6abca457ee | 49 | class LedPanel_GFX : public Stream |
| mbed_Cookbook_SE | 0:7d6abca457ee | 50 | { |
| mbed_Cookbook_SE | 0:7d6abca457ee | 51 | public: |
| mbed_Cookbook_SE | 0:7d6abca457ee | 52 | LedPanel_GFX(int16_t w, int16_t h); |
| mbed_Cookbook_SE | 0:7d6abca457ee | 53 | |
| mbed_Cookbook_SE | 0:7d6abca457ee | 54 | virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0; |
| mbed_Cookbook_SE | 0:7d6abca457ee | 55 | // this is optional |
| mbed_Cookbook_SE | 0:7d6abca457ee | 56 | virtual void invertDisplay(bool i) {}; |
| mbed_Cookbook_SE | 0:7d6abca457ee | 57 | |
| mbed_Cookbook_SE | 0:7d6abca457ee | 58 | // Stream implementation - provides printf() interface |
| mbed_Cookbook_SE | 0:7d6abca457ee | 59 | // You would otherwise be forced to use writeChar() |
| mbed_Cookbook_SE | 0:7d6abca457ee | 60 | virtual int _putc(int value) { return writeChar(value); }; |
| mbed_Cookbook_SE | 0:7d6abca457ee | 61 | virtual int _getc() { return -1; }; |
| mbed_Cookbook_SE | 0:7d6abca457ee | 62 | |
| mbed_Cookbook_SE | 0:7d6abca457ee | 63 | #ifdef WANT_ABSTRACTS |
| mbed_Cookbook_SE | 0:7d6abca457ee | 64 | // these are 'generic' drawing functions, so we can share them! |
| mbed_Cookbook_SE | 0:7d6abca457ee | 65 | virtual void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color); |
| mbed_Cookbook_SE | 0:7d6abca457ee | 66 | virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color); |
| mbed_Cookbook_SE | 0:7d6abca457ee | 67 | virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color); |
| mbed_Cookbook_SE | 0:7d6abca457ee | 68 | virtual void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); |
| mbed_Cookbook_SE | 0:7d6abca457ee | 69 | virtual void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); |
| mbed_Cookbook_SE | 0:7d6abca457ee | 70 | virtual void fillScreen(uint16_t color); |
| mbed_Cookbook_SE | 0:7d6abca457ee | 71 | |
| mbed_Cookbook_SE | 0:7d6abca457ee | 72 | void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color); |
| mbed_Cookbook_SE | 0:7d6abca457ee | 73 | void drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color); |
| mbed_Cookbook_SE | 0:7d6abca457ee | 74 | void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color); |
| mbed_Cookbook_SE | 0:7d6abca457ee | 75 | void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color); |
| mbed_Cookbook_SE | 0:7d6abca457ee | 76 | |
| mbed_Cookbook_SE | 0:7d6abca457ee | 77 | void drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color); |
| mbed_Cookbook_SE | 0:7d6abca457ee | 78 | void fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color); |
| mbed_Cookbook_SE | 0:7d6abca457ee | 79 | void drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color); |
| mbed_Cookbook_SE | 0:7d6abca457ee | 80 | void fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color); |
| mbed_Cookbook_SE | 0:7d6abca457ee | 81 | #endif |
| mbed_Cookbook_SE | 0:7d6abca457ee | 82 | |
| mbed_Cookbook_SE | 0:7d6abca457ee | 83 | void drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color); |
| mbed_Cookbook_SE | 0:7d6abca457ee | 84 | void drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size); |
| mbed_Cookbook_SE | 0:7d6abca457ee | 85 | void draw2Char(int16_t x, int16_t y, unsigned char *c, uint16_t color, uint16_t bg, uint8_t size); |
| mbed_Cookbook_SE | 0:7d6abca457ee | 86 | size_t writeChar(uint8_t); |
| mbed_Cookbook_SE | 0:7d6abca457ee | 87 | |
| mbed_Cookbook_SE | 0:7d6abca457ee | 88 | int16_t width(void) { return _width; }; |
| mbed_Cookbook_SE | 0:7d6abca457ee | 89 | int16_t height(void) { return _height; }; |
| mbed_Cookbook_SE | 0:7d6abca457ee | 90 | |
| mbed_Cookbook_SE | 0:7d6abca457ee | 91 | void setCursor(int16_t x, int16_t y) { cursor_x = x; cursor_y = y; }; |
| mbed_Cookbook_SE | 0:7d6abca457ee | 92 | void setTextSize(uint8_t s) { textsize = (s > 0) ? s : 1; }; |
| mbed_Cookbook_SE | 0:7d6abca457ee | 93 | void setTextColor(uint16_t c) { textcolor = c; textbgcolor = c; } |
| mbed_Cookbook_SE | 0:7d6abca457ee | 94 | void setTextColor(uint16_t c, uint16_t b) { textcolor = c; textbgcolor = b; }; |
| mbed_Cookbook_SE | 0:7d6abca457ee | 95 | void setTextWrap(bool w) { wrap = w; }; |
| mbed_Cookbook_SE | 0:7d6abca457ee | 96 | |
| mbed_Cookbook_SE | 0:7d6abca457ee | 97 | int32_t search_font_area( uint16_t code ); |
| mbed_Cookbook_SE | 0:7d6abca457ee | 98 | int32_t get_font_pt( uint16_t code ,uint8_t *chr ); |
| mbed_Cookbook_SE | 0:7d6abca457ee | 99 | |
| mbed_Cookbook_SE | 0:7d6abca457ee | 100 | |
| mbed_Cookbook_SE | 0:7d6abca457ee | 101 | protected: |
| mbed_Cookbook_SE | 0:7d6abca457ee | 102 | int16_t _rawWidth, _rawHeight; // this is the 'raw' display w/h - never changes |
| mbed_Cookbook_SE | 0:7d6abca457ee | 103 | int16_t _width, _height; // dependent on rotation |
| mbed_Cookbook_SE | 0:7d6abca457ee | 104 | int16_t cursor_x, cursor_y; |
| mbed_Cookbook_SE | 0:7d6abca457ee | 105 | uint16_t textcolor, textbgcolor; |
| mbed_Cookbook_SE | 0:7d6abca457ee | 106 | uint8_t textsize; |
| mbed_Cookbook_SE | 0:7d6abca457ee | 107 | uint8_t rotation; |
| mbed_Cookbook_SE | 0:7d6abca457ee | 108 | bool wrap; // If set, 'wrap' text at right edge of display |
| mbed_Cookbook_SE | 0:7d6abca457ee | 109 | FONT_HEAD fnt_head; |
| mbed_Cookbook_SE | 0:7d6abca457ee | 110 | uint16_t font_head_size; |
| mbed_Cookbook_SE | 0:7d6abca457ee | 111 | uint16_t font_search_tbl[100]; |
| mbed_Cookbook_SE | 0:7d6abca457ee | 112 | }; |
| mbed_Cookbook_SE | 0:7d6abca457ee | 113 | |
| mbed_Cookbook_SE | 0:7d6abca457ee | 114 | #endif |