Test for STM32F4

Dependents:   Nucleo_SSD1331

Fork of RGB_OLED_SSD1331 by Juergen M

Committer:
messi1
Date:
Wed Nov 18 09:28:05 2015 +0000
Revision:
11:162aa3e801df
Parent:
10:ef7440718431
Child:
13:8dd215952d76
Rewrite SGL class to template based class

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 MIN(a,b) (((a)<(b))?(a):(b))
messi1 0:6e810b5b40a3 37 #define MAX(a,b) (((a)>(b))?(a):(b))
messi1 0:6e810b5b40a3 38
messi1 10:ef7440718431 39 typedef const unsigned char** FontType;
messi1 0:6e810b5b40a3 40
messi1 11:162aa3e801df 41 template <class T>
messi1 0:6e810b5b40a3 42 class SGL {
messi1 0:6e810b5b40a3 43
messi1 0:6e810b5b40a3 44 public:
messi1 11:162aa3e801df 45 SGL(T width, T height);
messi1 11:162aa3e801df 46 virtual void drawPixel(T x, T y, uint16_t color) = 0; // implemented by subclass
messi1 11:162aa3e801df 47 virtual void drawLine(T x0, T y0, T x1, T y1, uint16_t color);
messi1 11:162aa3e801df 48 virtual void drawVLine(T x, T y, T length,uint16_t color);
messi1 11:162aa3e801df 49 virtual void drawHLine(T x, T y, T length, uint16_t color);
messi1 11:162aa3e801df 50 virtual void drawRect(T x, T y, T width, T height, uint16_t color);
messi1 11:162aa3e801df 51 virtual void fillRect(T x, T y, T width, T height, uint16_t color);
messi1 11:162aa3e801df 52 virtual void drawCircle(T x, T y, T r, uint16_t color);
messi1 11:162aa3e801df 53 virtual void fillCircle(T x, T y, T r, uint16_t color);
messi1 11:162aa3e801df 54 virtual void drawTraingle(T x0, T y0, T x1, T y1, T x2, T y2, uint16_t color);
messi1 11:162aa3e801df 55 virtual void fillTraingle(T x0, T y0, T x1, T y1, T x2, T y2, uint16_t color);
messi1 10:ef7440718431 56
messi1 10:ef7440718431 57 // The zoom factor works at the moment only with integer values. Float values will create bad fonts
messi1 11:162aa3e801df 58 virtual void drawChar(uint8_t ascii, T x, T y, uint16_t color, float zoom=1);
messi1 11:162aa3e801df 59 virtual void drawString(const char *string, T x, T y, uint16_t color, float zoom=1, uint8_t fontSpace=6);
messi1 10:ef7440718431 60
messi1 11:162aa3e801df 61 virtual void drawBitMap(T x, T y, const uint8_t *bitmap, T width, T height, uint16_t color);
messi1 0:6e810b5b40a3 62 virtual void fillScreen(uint16_t color);
messi1 11:162aa3e801df 63 virtual void setFont(FontType font, uint8_t width, uint8_t height, uint8_t asciiStart, uint8_t asciiStop);
messi1 0:6e810b5b40a3 64
messi1 0:6e810b5b40a3 65 private:
messi1 11:162aa3e801df 66 void swap(T* a, T* b){
messi1 11:162aa3e801df 67 T t = *a; *a = *b; *b = t;
messi1 0:6e810b5b40a3 68 };
messi1 0:6e810b5b40a3 69
messi1 11:162aa3e801df 70 T _width;
messi1 11:162aa3e801df 71 T _height;
messi1 10:ef7440718431 72 FontType _currentFont;
messi1 10:ef7440718431 73 uint8_t _fontWidth;
messi1 10:ef7440718431 74 uint8_t _fontHeight;
messi1 10:ef7440718431 75 uint8_t _fontStart;
messi1 10:ef7440718431 76 uint8_t _fontStop;
messi1 0:6e810b5b40a3 77 };
messi1 0:6e810b5b40a3 78
messi1 0:6e810b5b40a3 79 #endif