Test for STM32F4
Fork of RGB_OLED_SSD1331 by
include/SGL.h@1:b55525d2db34, 2015-11-10 (annotated)
- Committer:
- messi1
- Date:
- Tue Nov 10 23:16:37 2015 +0000
- Revision:
- 1:b55525d2db34
- Parent:
- 0:6e810b5b40a3
- Child:
- 3:af00512c9694
Removed unused includes
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 | 0:6e810b5b40a3 | 35 | |
messi1 | 0:6e810b5b40a3 | 36 | #define FONT_SPACE 6 |
messi1 | 0:6e810b5b40a3 | 37 | #define FONT_X 8 |
messi1 | 0:6e810b5b40a3 | 38 | #define FONT_Y 8 |
messi1 | 0:6e810b5b40a3 | 39 | |
messi1 | 0:6e810b5b40a3 | 40 | #define MIN(a,b) (((a)<(b))?(a):(b)) |
messi1 | 0:6e810b5b40a3 | 41 | #define MAX(a,b) (((a)>(b))?(a):(b)) |
messi1 | 0:6e810b5b40a3 | 42 | |
messi1 | 0:6e810b5b40a3 | 43 | const unsigned char simpleFont[][8] = |
messi1 | 0:6e810b5b40a3 | 44 | { |
messi1 | 0:6e810b5b40a3 | 45 | {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 46 | {0x00,0x00,0x5F,0x00,0x00,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 47 | {0x00,0x00,0x07,0x00,0x07,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 48 | {0x00,0x14,0x7F,0x14,0x7F,0x14,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 49 | {0x00,0x24,0x2A,0x7F,0x2A,0x12,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 50 | {0x00,0x23,0x13,0x08,0x64,0x62,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 51 | {0x00,0x36,0x49,0x55,0x22,0x50,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 52 | {0x00,0x00,0x05,0x03,0x00,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 53 | {0x00,0x1C,0x22,0x41,0x00,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 54 | {0x00,0x41,0x22,0x1C,0x00,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 55 | {0x00,0x08,0x2A,0x1C,0x2A,0x08,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 56 | {0x00,0x08,0x08,0x3E,0x08,0x08,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 57 | {0x00,0xA0,0x60,0x00,0x00,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 58 | {0x00,0x08,0x08,0x08,0x08,0x08,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 59 | {0x00,0x60,0x60,0x00,0x00,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 60 | {0x00,0x20,0x10,0x08,0x04,0x02,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 61 | {0x00,0x3E,0x51,0x49,0x45,0x3E,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 62 | {0x00,0x00,0x42,0x7F,0x40,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 63 | {0x00,0x62,0x51,0x49,0x49,0x46,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 64 | {0x00,0x22,0x41,0x49,0x49,0x36,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 65 | {0x00,0x18,0x14,0x12,0x7F,0x10,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 66 | {0x00,0x27,0x45,0x45,0x45,0x39,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 67 | {0x00,0x3C,0x4A,0x49,0x49,0x30,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 68 | {0x00,0x01,0x71,0x09,0x05,0x03,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 69 | {0x00,0x36,0x49,0x49,0x49,0x36,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 70 | {0x00,0x06,0x49,0x49,0x29,0x1E,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 71 | {0x00,0x00,0x36,0x36,0x00,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 72 | {0x00,0x00,0xAC,0x6C,0x00,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 73 | {0x00,0x08,0x14,0x22,0x41,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 74 | {0x00,0x14,0x14,0x14,0x14,0x14,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 75 | {0x00,0x41,0x22,0x14,0x08,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 76 | {0x00,0x02,0x01,0x51,0x09,0x06,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 77 | {0x00,0x32,0x49,0x79,0x41,0x3E,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 78 | {0x00,0x7E,0x09,0x09,0x09,0x7E,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 79 | {0x00,0x7F,0x49,0x49,0x49,0x36,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 80 | {0x00,0x3E,0x41,0x41,0x41,0x22,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 81 | {0x00,0x7F,0x41,0x41,0x22,0x1C,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 82 | {0x00,0x7F,0x49,0x49,0x49,0x41,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 83 | {0x00,0x7F,0x09,0x09,0x09,0x01,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 84 | {0x00,0x3E,0x41,0x41,0x51,0x72,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 85 | {0x00,0x7F,0x08,0x08,0x08,0x7F,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 86 | {0x00,0x41,0x7F,0x41,0x00,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 87 | {0x00,0x20,0x40,0x41,0x3F,0x01,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 88 | {0x00,0x7F,0x08,0x14,0x22,0x41,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 89 | {0x00,0x7F,0x40,0x40,0x40,0x40,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 90 | {0x00,0x7F,0x02,0x0C,0x02,0x7F,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 91 | {0x00,0x7F,0x04,0x08,0x10,0x7F,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 92 | {0x00,0x3E,0x41,0x41,0x41,0x3E,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 93 | {0x00,0x7F,0x09,0x09,0x09,0x06,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 94 | {0x00,0x3E,0x41,0x51,0x21,0x5E,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 95 | {0x00,0x7F,0x09,0x19,0x29,0x46,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 96 | {0x00,0x26,0x49,0x49,0x49,0x32,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 97 | {0x00,0x01,0x01,0x7F,0x01,0x01,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 98 | {0x00,0x3F,0x40,0x40,0x40,0x3F,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 99 | {0x00,0x1F,0x20,0x40,0x20,0x1F,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 100 | {0x00,0x3F,0x40,0x38,0x40,0x3F,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 101 | {0x00,0x63,0x14,0x08,0x14,0x63,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 102 | {0x00,0x03,0x04,0x78,0x04,0x03,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 103 | {0x00,0x61,0x51,0x49,0x45,0x43,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 104 | {0x00,0x7F,0x41,0x41,0x00,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 105 | {0x00,0x02,0x04,0x08,0x10,0x20,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 106 | {0x00,0x41,0x41,0x7F,0x00,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 107 | {0x00,0x04,0x02,0x01,0x02,0x04,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 108 | {0x00,0x80,0x80,0x80,0x80,0x80,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 109 | {0x00,0x01,0x02,0x04,0x00,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 110 | {0x00,0x20,0x54,0x54,0x54,0x78,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 111 | {0x00,0x7F,0x48,0x44,0x44,0x38,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 112 | {0x00,0x38,0x44,0x44,0x28,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 113 | {0x00,0x38,0x44,0x44,0x48,0x7F,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 114 | {0x00,0x38,0x54,0x54,0x54,0x18,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 115 | {0x00,0x08,0x7E,0x09,0x02,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 116 | {0x00,0x18,0xA4,0xA4,0xA4,0x7C,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 117 | {0x00,0x7F,0x08,0x04,0x04,0x78,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 118 | {0x00,0x00,0x7D,0x00,0x00,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 119 | {0x00,0x80,0x84,0x7D,0x00,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 120 | {0x00,0x7F,0x10,0x28,0x44,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 121 | {0x00,0x41,0x7F,0x40,0x00,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 122 | {0x00,0x7C,0x04,0x18,0x04,0x78,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 123 | {0x00,0x7C,0x08,0x04,0x7C,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 124 | {0x00,0x38,0x44,0x44,0x38,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 125 | {0x00,0xFC,0x24,0x24,0x18,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 126 | {0x00,0x18,0x24,0x24,0xFC,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 127 | {0x00,0x00,0x7C,0x08,0x04,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 128 | {0x00,0x48,0x54,0x54,0x24,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 129 | {0x00,0x04,0x7F,0x44,0x00,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 130 | {0x00,0x3C,0x40,0x40,0x7C,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 131 | {0x00,0x1C,0x20,0x40,0x20,0x1C,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 132 | {0x00,0x3C,0x40,0x30,0x40,0x3C,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 133 | {0x00,0x44,0x28,0x10,0x28,0x44,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 134 | {0x00,0x1C,0xA0,0xA0,0x7C,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 135 | {0x00,0x44,0x64,0x54,0x4C,0x44,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 136 | {0x00,0x08,0x36,0x41,0x00,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 137 | {0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 138 | {0x00,0x41,0x36,0x08,0x00,0x00,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 139 | {0x00,0x02,0x01,0x01,0x02,0x01,0x00,0x00}, |
messi1 | 0:6e810b5b40a3 | 140 | {0x00,0x02,0x05,0x05,0x02,0x00,0x00,0x00} |
messi1 | 0:6e810b5b40a3 | 141 | }; |
messi1 | 0:6e810b5b40a3 | 142 | |
messi1 | 0:6e810b5b40a3 | 143 | class SGL { |
messi1 | 0:6e810b5b40a3 | 144 | |
messi1 | 0:6e810b5b40a3 | 145 | public: |
messi1 | 0:6e810b5b40a3 | 146 | SGL(uint16_t width, uint16_t height); |
messi1 | 0:6e810b5b40a3 | 147 | virtual void drawPixel(uint16_t x, uint16_t y, uint16_t color) = 0; // implemented by subclass |
messi1 | 0:6e810b5b40a3 | 148 | virtual void drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color); |
messi1 | 0:6e810b5b40a3 | 149 | virtual void drawVerticalLine(uint16_t x, uint16_t y, uint16_t height,uint16_t color); |
messi1 | 0:6e810b5b40a3 | 150 | virtual void drawHorizontalLine(uint16_t x, uint16_t y, uint16_t width, uint16_t color); |
messi1 | 0:6e810b5b40a3 | 151 | virtual void drawRectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color); |
messi1 | 0:6e810b5b40a3 | 152 | virtual void fillRectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color); |
messi1 | 0:6e810b5b40a3 | 153 | virtual void drawCircle(uint16_t x, uint16_t y, uint16_t r, uint16_t color); |
messi1 | 0:6e810b5b40a3 | 154 | virtual void fillCircle(uint16_t x, uint16_t y, uint16_t r, uint16_t color); |
messi1 | 0:6e810b5b40a3 | 155 | virtual void drawTraingle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color); |
messi1 | 0:6e810b5b40a3 | 156 | virtual void fillTraingle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color); |
messi1 | 0:6e810b5b40a3 | 157 | virtual void drawChar(uint8_t ascii, uint16_t x, uint16_t y, uint16_t size, uint16_t color); |
messi1 | 0:6e810b5b40a3 | 158 | virtual void drawString(char *string, uint16_t x, uint16_t y, uint16_t size, uint16_t color); |
messi1 | 0:6e810b5b40a3 | 159 | virtual void drawBitMap(uint16_t x, uint16_t y, const uint8_t *bitmap, uint16_t width, int16_t height, uint16_t color); |
messi1 | 0:6e810b5b40a3 | 160 | virtual void fillScreen(uint16_t color); |
messi1 | 0:6e810b5b40a3 | 161 | |
messi1 | 0:6e810b5b40a3 | 162 | private: |
messi1 | 0:6e810b5b40a3 | 163 | void swap(uint16_t* a, uint16_t* b){ |
messi1 | 0:6e810b5b40a3 | 164 | uint16_t t = *a; *a = *b; *b = t; |
messi1 | 0:6e810b5b40a3 | 165 | }; |
messi1 | 0:6e810b5b40a3 | 166 | |
messi1 | 0:6e810b5b40a3 | 167 | uint16_t _width; |
messi1 | 0:6e810b5b40a3 | 168 | uint16_t _height; |
messi1 | 0:6e810b5b40a3 | 169 | }; |
messi1 | 0:6e810b5b40a3 | 170 | |
messi1 | 0:6e810b5b40a3 | 171 | #endif |