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_GFX.h
00001 /*********************************** 00002 This is a our graphics core library, for all our displays. 00003 We'll be adapting all the 00004 existing libaries to use this core to make updating, support 00005 and upgrading easier! 00006 00007 Adafruit invests time and resources providing this open source code, 00008 please support Adafruit and open-source hardware by purchasing 00009 products from Adafruit! 00010 00011 Written by Limor Fried/Ladyada for Adafruit Industries. 00012 BSD license, check license.txt for more information 00013 All text above must be included in any redistribution 00014 ****************************************/ 00015 00016 /* 00017 * Modified by Neal Horman 7/14/2012 for use in LPC1768 00018 */ 00019 00020 /** 00021 * Matrix16x16 LEDPanel Grafix library 00022 * 00023 * @author Junichi Katsu 00024 * @version 1.0 00025 * @date 15-April-2015 00026 * 00027 */ 00028 00029 #ifndef MBED_LEDPANEL_GFX_H_ 00030 #define MBED_LEDPANEL_GFX_H_ 00031 00032 #include "font.h" 00033 00034 static inline void swap(int16_t &a, int16_t &b) 00035 { 00036 int16_t t = a; 00037 00038 a = b; 00039 b = t; 00040 } 00041 00042 #ifndef _BV 00043 #define _BV(bit) (1<<(bit)) 00044 #endif 00045 00046 #define BLACK 0 00047 #define WHITE 1 00048 00049 class LedPanel_GFX : public Stream 00050 { 00051 public: 00052 LedPanel_GFX(int16_t w, int16_t h); 00053 00054 virtual void drawPixel(int16_t x, int16_t y, uint16_t color) = 0; 00055 // this is optional 00056 virtual void invertDisplay(bool i) {}; 00057 00058 // Stream implementation - provides printf() interface 00059 // You would otherwise be forced to use writeChar() 00060 virtual int _putc(int value) { return writeChar(value); }; 00061 virtual int _getc() { return -1; }; 00062 00063 #ifdef WANT_ABSTRACTS 00064 // these are 'generic' drawing functions, so we can share them! 00065 virtual void drawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color); 00066 virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color); 00067 virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color); 00068 virtual void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); 00069 virtual void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); 00070 virtual void fillScreen(uint16_t color); 00071 00072 void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color); 00073 void drawCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, uint16_t color); 00074 void fillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color); 00075 void fillCircleHelper(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta, uint16_t color); 00076 00077 void drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color); 00078 void fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t color); 00079 void drawRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color); 00080 void fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color); 00081 #endif 00082 00083 void drawBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color); 00084 void drawChar(int16_t x, int16_t y, unsigned char c, uint16_t color, uint16_t bg, uint8_t size); 00085 void draw2Char(int16_t x, int16_t y, unsigned char *c, uint16_t color, uint16_t bg, uint8_t size); 00086 size_t writeChar(uint8_t); 00087 00088 int16_t width(void) { return _width; }; 00089 int16_t height(void) { return _height; }; 00090 00091 void setCursor(int16_t x, int16_t y) { cursor_x = x; cursor_y = y; }; 00092 void setTextSize(uint8_t s) { textsize = (s > 0) ? s : 1; }; 00093 void setTextColor(uint16_t c) { textcolor = c; textbgcolor = c; } 00094 void setTextColor(uint16_t c, uint16_t b) { textcolor = c; textbgcolor = b; }; 00095 void setTextWrap(bool w) { wrap = w; }; 00096 00097 int32_t search_font_area( uint16_t code ); 00098 int32_t get_font_pt( uint16_t code ,uint8_t *chr ); 00099 00100 00101 protected: 00102 int16_t _rawWidth, _rawHeight; // this is the 'raw' display w/h - never changes 00103 int16_t _width, _height; // dependent on rotation 00104 int16_t cursor_x, cursor_y; 00105 uint16_t textcolor, textbgcolor; 00106 uint8_t textsize; 00107 uint8_t rotation; 00108 bool wrap; // If set, 'wrap' text at right edge of display 00109 FONT_HEAD fnt_head; 00110 uint16_t font_head_size; 00111 uint16_t font_search_tbl[100]; 00112 }; 00113 00114 #endif
Generated on Thu Jul 14 2022 17:34:26 by
1.7.2