Test for STM32F4

Dependents:   Nucleo_SSD1331

Fork of RGB_OLED_SSD1331 by Juergen M

Revision:
11:162aa3e801df
Parent:
10:ef7440718431
Child:
13:8dd215952d76
diff -r ef7440718431 -r 162aa3e801df include/SGL.h
--- a/include/SGL.h	Tue Nov 17 21:20:37 2015 +0000
+++ b/include/SGL.h	Wed Nov 18 09:28:05 2015 +0000
@@ -33,45 +33,42 @@
 
 #include <stdint.h>
 
-#define FONT_SPACE 6
-#define FONT_X 8
-#define FONT_Y 8
-
 #define MIN(a,b) (((a)<(b))?(a):(b))
 #define MAX(a,b) (((a)>(b))?(a):(b))
 
 typedef const unsigned char** FontType;
 
+template <class T>
 class SGL {
  
 public:
-    SGL(uint8_t width, uint8_t height);
-    virtual void drawPixel(uint8_t x, uint8_t y, uint16_t color) = 0; // implemented by subclass
-    virtual void drawLine(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint16_t color);
-    virtual void drawVLine(uint8_t x, uint8_t y, uint8_t length,uint16_t color);
-    virtual void drawHLine(uint8_t x, uint8_t y, uint8_t length, uint16_t color);
-    virtual void drawRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint16_t color);
-    virtual void fillRect(uint8_t x, uint8_t y, uint8_t width, uint8_t height, uint16_t color);
-    virtual void drawCircle(uint8_t x, uint8_t y, uint8_t r, uint16_t color);
-    virtual void fillCircle(uint8_t x, uint8_t y, uint8_t r, uint16_t color);
-    virtual void drawTraingle(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint16_t color);
-    virtual void fillTraingle(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2, uint16_t color);    
+    SGL(T width, T height);
+    virtual void drawPixel(T x, T y, uint16_t color) = 0; // implemented by subclass
+    virtual void drawLine(T x0, T y0, T x1, T y1, uint16_t color);
+    virtual void drawVLine(T x, T y, T length,uint16_t color);
+    virtual void drawHLine(T x, T y, T length, uint16_t color);
+    virtual void drawRect(T x, T y, T width, T height, uint16_t color);
+    virtual void fillRect(T x, T y, T width, T height, uint16_t color);
+    virtual void drawCircle(T x, T y, T r, uint16_t color);
+    virtual void fillCircle(T x, T y, T r, uint16_t color);
+    virtual void drawTraingle(T x0, T y0, T x1, T y1, T x2, T y2, uint16_t color);
+    virtual void fillTraingle(T x0, T y0, T x1, T y1, T x2, T y2, uint16_t color);    
     
     // The zoom factor works at the moment only with integer values. Float values will create bad fonts 
-    virtual void drawChar(uint8_t ascii, uint8_t x, uint8_t y, float zoom, uint16_t color);
-    virtual void drawString(const char *string, uint8_t x, uint8_t y, float zoom, uint16_t color, uint8_t fontSpace=6);
+    virtual void drawChar(uint8_t ascii, T x, T y, uint16_t color, float zoom=1);
+    virtual void drawString(const char *string, T x, T y, uint16_t color, float zoom=1, uint8_t fontSpace=6);
     
-    virtual void drawBitMap(uint8_t x, uint8_t y, const uint8_t *bitmap, uint8_t width, uint8_t height, uint16_t color);
+    virtual void drawBitMap(T x, T y, const uint8_t *bitmap, T width, T height, uint16_t color);
     virtual void fillScreen(uint16_t color);
-    virtual void setFont(FontType font, uint8_t width, uint8_t height, uint8_t start, uint8_t stop);
+    virtual void setFont(FontType font, uint8_t width, uint8_t height, uint8_t asciiStart, uint8_t asciiStop);
     
 private:
-    void swap(uint8_t* a, uint8_t* b){ 
-        uint8_t t = *a; *a = *b; *b = t; 
+    void swap(T* a, T* b){ 
+        T t = *a; *a = *b; *b = t; 
     };
     
-    uint8_t _width;
-    uint8_t _height;
+    T _width;
+    T _height;
     FontType _currentFont;
     uint8_t _fontWidth;
     uint8_t _fontHeight;