Test for STM32F4

Dependents:   Nucleo_SSD1331

Fork of RGB_OLED_SSD1331 by Juergen M

Committer:
messi1
Date:
Tue Nov 17 21:20:37 2015 +0000
Revision:
10:ef7440718431
Parent:
8:ff74bd4d94d6
Child:
11:162aa3e801df
Improved the drawString function; Add setFont function

Who changed what in which revision?

UserRevisionLine numberNew 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 10:ef7440718431 43 typedef const unsigned char** FontType;
messi1 0:6e810b5b40a3 44
messi1 0:6e810b5b40a3 45 class SGL {
messi1 0:6e810b5b40a3 46
messi1 0:6e810b5b40a3 47 public:
messi1 8:ff74bd4d94d6 48 SGL(uint8_t width, uint8_t height);
messi1 3:af00512c9694 49 virtual void drawPixel(uint8_t x, uint8_t y, uint16_t color) = 0; // implemented by subclass
messi1 4:1707ca53e7d5 50 virtual void drawLine(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint16_t color);
messi1 8:ff74bd4d94d6 51 virtual void drawVLine(uint8_t x, uint8_t y, uint8_t length,uint16_t color);
messi1 8:ff74bd4d94d6 52 virtual void drawHLine(uint8_t x, uint8_t y, uint8_t length, uint16_t color);
messi1 8:ff74bd4d94d6 53 virtual void drawRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint16_t color);
messi1 8:ff74bd4d94d6 54 virtual void fillRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint16_t color);
messi1 8:ff74bd4d94d6 55 virtual void drawCircle(uint8_t x, uint8_t y, uint8_t r, uint16_t color);
messi1 8:ff74bd4d94d6 56 virtual void fillCircle(uint8_t x, uint8_t y, uint8_t r, uint16_t color);
messi1 8:ff74bd4d94d6 57 virtual void drawTraingle(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint16_t color);
messi1 8:ff74bd4d94d6 58 virtual void fillTraingle(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t x2, uint8_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 10:ef7440718431 61 virtual void drawChar(uint8_t ascii, uint8_t x, uint8_t y, float zoom, uint16_t color);
messi1 10:ef7440718431 62 virtual void drawString(const char *string, uint8_t x, uint8_t y, float zoom, uint16_t color, uint8_t fontSpace=6);
messi1 10:ef7440718431 63
messi1 8:ff74bd4d94d6 64 virtual void drawBitMap(uint8_t x, uint8_t y, const uint8_t *bitmap, uint8_t width, uint8_t height, uint16_t color);
messi1 0:6e810b5b40a3 65 virtual void fillScreen(uint16_t color);
messi1 10:ef7440718431 66 virtual void setFont(FontType font, uint8_t width, uint8_t height, uint8_t start, uint8_t stop);
messi1 0:6e810b5b40a3 67
messi1 0:6e810b5b40a3 68 private:
messi1 8:ff74bd4d94d6 69 void swap(uint8_t* a, uint8_t* b){
messi1 8:ff74bd4d94d6 70 uint8_t t = *a; *a = *b; *b = t;
messi1 0:6e810b5b40a3 71 };
messi1 0:6e810b5b40a3 72
messi1 8:ff74bd4d94d6 73 uint8_t _width;
messi1 8:ff74bd4d94d6 74 uint8_t _height;
messi1 10:ef7440718431 75 FontType _currentFont;
messi1 10:ef7440718431 76 uint8_t _fontWidth;
messi1 10:ef7440718431 77 uint8_t _fontHeight;
messi1 10:ef7440718431 78 uint8_t _fontStart;
messi1 10:ef7440718431 79 uint8_t _fontStop;
messi1 0:6e810b5b40a3 80 };
messi1 0:6e810b5b40a3 81
messi1 0:6e810b5b40a3 82 #endif