Test for STM32F4
Fork of RGB_OLED_SSD1331 by
include/SGL.h@17:1bcdc92af126, 2016-12-10 (annotated)
- Committer:
- messi1
- Date:
- Sat Dec 10 22:51:06 2016 +0000
- Revision:
- 17:1bcdc92af126
- Parent:
- 15:c49040bf0e1d
removed wait(0.05); Add boundingRect function
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
messi1 | 0:6e810b5b40a3 | 1 | /* |
messi1 | 0:6e810b5b40a3 | 2 | * SGL.h |
messi1 | 0:6e810b5b40a3 | 3 | * A library for Seeed Graphical library |
messi1 | 0:6e810b5b40a3 | 4 | * |
messi1 | 0:6e810b5b40a3 | 5 | * Copyright (c) 2014 seeed technology inc. |
messi1 | 0:6e810b5b40a3 | 6 | * Author : lawliet.zou(lawliet.zou@gmail.com) |
messi1 | 0:6e810b5b40a3 | 7 | * Create Time : Jun 06, 2014 |
messi1 | 0:6e810b5b40a3 | 8 | * Change Log : |
messi1 | 0:6e810b5b40a3 | 9 | * |
messi1 | 0:6e810b5b40a3 | 10 | * The MIT License (MIT) |
messi1 | 0:6e810b5b40a3 | 11 | * |
messi1 | 0:6e810b5b40a3 | 12 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
messi1 | 0:6e810b5b40a3 | 13 | * of this software and associated documentation files (the "Software"), to deal |
messi1 | 0:6e810b5b40a3 | 14 | * in the Software without restriction, including without limitation the rights |
messi1 | 0:6e810b5b40a3 | 15 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
messi1 | 0:6e810b5b40a3 | 16 | * copies of the Software, and to permit persons to whom the Software is |
messi1 | 0:6e810b5b40a3 | 17 | * furnished to do so, subject to the following conditions: |
messi1 | 0:6e810b5b40a3 | 18 | * |
messi1 | 0:6e810b5b40a3 | 19 | * The above copyright notice and this permission notice shall be included in |
messi1 | 0:6e810b5b40a3 | 20 | * all copies or substantial portions of the Software. |
messi1 | 0:6e810b5b40a3 | 21 | * |
messi1 | 0:6e810b5b40a3 | 22 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
messi1 | 0:6e810b5b40a3 | 23 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
messi1 | 0:6e810b5b40a3 | 24 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
messi1 | 0:6e810b5b40a3 | 25 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
messi1 | 0:6e810b5b40a3 | 26 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
messi1 | 0:6e810b5b40a3 | 27 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
messi1 | 0:6e810b5b40a3 | 28 | * THE SOFTWARE. |
messi1 | 0:6e810b5b40a3 | 29 | */ |
messi1 | 0:6e810b5b40a3 | 30 | |
messi1 | 0:6e810b5b40a3 | 31 | #ifndef _SGL_H_ //Seeed Graphics Library |
messi1 | 0:6e810b5b40a3 | 32 | #define _SGL_H_ |
messi1 | 0:6e810b5b40a3 | 33 | |
messi1 | 0:6e810b5b40a3 | 34 | #include <stdint.h> |
messi1 | 15:c49040bf0e1d | 35 | #include "Rect.h" |
messi1 | 0:6e810b5b40a3 | 36 | |
messi1 | 0:6e810b5b40a3 | 37 | #define MIN(a,b) (((a)<(b))?(a):(b)) |
messi1 | 0:6e810b5b40a3 | 38 | #define MAX(a,b) (((a)>(b))?(a):(b)) |
messi1 | 0:6e810b5b40a3 | 39 | |
messi1 | 10:ef7440718431 | 40 | typedef const unsigned char** FontType; |
messi1 | 0:6e810b5b40a3 | 41 | |
messi1 | 15:c49040bf0e1d | 42 | |
messi1 | 11:162aa3e801df | 43 | template <class T> |
messi1 | 0:6e810b5b40a3 | 44 | class SGL { |
messi1 | 0:6e810b5b40a3 | 45 | |
messi1 | 0:6e810b5b40a3 | 46 | public: |
messi1 | 11:162aa3e801df | 47 | SGL(T width, T height); |
messi1 | 17:1bcdc92af126 | 48 | virtual void clearArea(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1) = 0; |
messi1 | 11:162aa3e801df | 49 | virtual void drawPixel(T x, T y, uint16_t color) = 0; // implemented by subclass |
messi1 | 11:162aa3e801df | 50 | virtual void drawLine(T x0, T y0, T x1, T y1, uint16_t color); |
messi1 | 11:162aa3e801df | 51 | virtual void drawVLine(T x, T y, T length,uint16_t color); |
messi1 | 11:162aa3e801df | 52 | virtual void drawHLine(T x, T y, T length, uint16_t color); |
messi1 | 11:162aa3e801df | 53 | virtual void drawRect(T x, T y, T width, T height, uint16_t color); |
messi1 | 11:162aa3e801df | 54 | virtual void fillRect(T x, T y, T width, T height, uint16_t color); |
messi1 | 11:162aa3e801df | 55 | virtual void drawCircle(T x, T y, T r, uint16_t color); |
messi1 | 11:162aa3e801df | 56 | virtual void fillCircle(T x, T y, T r, uint16_t color); |
messi1 | 13:8dd215952d76 | 57 | virtual void drawTriangle(T x0, T y0, T x1, T y1, T x2, T y2, uint16_t color); |
messi1 | 13:8dd215952d76 | 58 | virtual void fillTriangle(T x0, T y0, T x1, T y1, T x2, T y2, uint16_t color); |
messi1 | 10:ef7440718431 | 59 | |
messi1 | 10:ef7440718431 | 60 | // The zoom factor works at the moment only with integer values. Float values will create bad fonts |
messi1 | 11:162aa3e801df | 61 | virtual void drawChar(uint8_t ascii, T x, T y, uint16_t color, float zoom=1); |
messi1 | 17:1bcdc92af126 | 62 | virtual void drawString(const char *string, T x, T y, uint16_t color, float zoom=1, int8_t fontSpace=0); |
messi1 | 17:1bcdc92af126 | 63 | virtual Rect<T> boundingRect(const char *string, T x, T y, float zoom=1, int8_t fontSpace=0); |
messi1 | 10:ef7440718431 | 64 | |
messi1 | 11:162aa3e801df | 65 | virtual void drawBitMap(T x, T y, const uint8_t *bitmap, T width, T height, uint16_t color); |
messi1 | 0:6e810b5b40a3 | 66 | virtual void fillScreen(uint16_t color); |
messi1 | 11:162aa3e801df | 67 | virtual void setFont(FontType font, uint8_t width, uint8_t height, uint8_t asciiStart, uint8_t asciiStop); |
messi1 | 0:6e810b5b40a3 | 68 | |
messi1 | 0:6e810b5b40a3 | 69 | private: |
messi1 | 11:162aa3e801df | 70 | void swap(T* a, T* b){ |
messi1 | 11:162aa3e801df | 71 | T t = *a; *a = *b; *b = t; |
messi1 | 0:6e810b5b40a3 | 72 | }; |
messi1 | 0:6e810b5b40a3 | 73 | |
messi1 | 17:1bcdc92af126 | 74 | T _displayWidth; |
messi1 | 17:1bcdc92af126 | 75 | T _displayHeight; |
messi1 | 10:ef7440718431 | 76 | FontType _currentFont; |
messi1 | 10:ef7440718431 | 77 | uint8_t _fontWidth; |
messi1 | 10:ef7440718431 | 78 | uint8_t _fontHeight; |
messi1 | 10:ef7440718431 | 79 | uint8_t _fontStart; |
messi1 | 10:ef7440718431 | 80 | uint8_t _fontStop; |
messi1 | 0:6e810b5b40a3 | 81 | }; |
messi1 | 0:6e810b5b40a3 | 82 | |
messi1 | 0:6e810b5b40a3 | 83 | #endif |