SPI based library for the ST7735 LCD controller.

Dependents:   RayCastingEngine RETRO_LCD_PerformanceTest RETRO_loop_test RETRO_RickGame ... more

Files at this revision

API Documentation at this revision

Comitter:
taylorza
Date:
Sat Sep 20 05:43:17 2014 +0000
Parent:
1:33ff5fad4320
Child:
3:451148656b76
Commit message:
Add color constants based on the Windows 16 color palette

Changed in this revision

Color565.cpp Show annotated file Show diff for this revision Revisions of this file
Color565.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Color565.cpp	Sat Sep 20 05:43:17 2014 +0000
@@ -0,0 +1,22 @@
+///////////////////////////////////////////////////////////////////////////////
+// LCD_ST7735 - Driver for ST7735 LCD display controller
+// Author: Chris Taylor (taylorza)
+#include "mbed.h"
+#include "Color565.h"
+
+const uint16_t Color565::White = Color565::fromRGB(0xff, 0xff, 0xff);
+const uint16_t Color565::Silver = Color565::fromRGB(0xc0, 0xc0, 0xc0);
+const uint16_t Color565::Gray = Color565::fromRGB(0x80, 0x80, 0x80);
+const uint16_t Color565::Black = Color565::fromRGB(0x00, 0x00, 0x00);
+const uint16_t Color565::Red = Color565::fromRGB(0xff, 0x00, 0x00);
+const uint16_t Color565::Maroon = Color565::fromRGB(0x80, 0x00, 0x00);
+const uint16_t Color565::Yellow = Color565::fromRGB(0xff, 0xff, 0x00);
+const uint16_t Color565::Olive = Color565::fromRGB(0x80, 0x80, 0x00);
+const uint16_t Color565::Lime = Color565::fromRGB(0x00, 0xff, 0x00);
+const uint16_t Color565::Green = Color565::fromRGB(0x00, 0x80, 0x00);
+const uint16_t Color565::Aqua = Color565::fromRGB(0x00, 0xff, 0xff);
+const uint16_t Color565::Teal = Color565::fromRGB(0x00, 0x80, 0x80);
+const uint16_t Color565::Blue = Color565::fromRGB(0x00, 0x00, 0xff);
+const uint16_t Color565::Navy = Color565::fromRGB(0x00, 0x00, 0x80);
+const uint16_t Color565::Fuchsia = Color565::fromRGB(0xff, 0x00, 0xff);
+const uint16_t Color565::Purple = Color565::fromRGB(0x80, 0x00, 0x80);
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Color565.h	Sat Sep 20 05:43:17 2014 +0000
@@ -0,0 +1,72 @@
+///////////////////////////////////////////////////////////////////////////////
+// LCD_ST7735 - Driver for ST7735 LCD display controller
+// Author: Chris Taylor (taylorza)
+
+#ifndef __COLOR565_H__
+#define __COLOR565_H__
+/** Color palete support for 16bit RGB colors with 565 color format
+*/
+class Color565
+{
+public:
+    /**White*/
+    static const uint16_t White;
+    
+    /**Silver*/
+    static const uint16_t Silver;
+    
+    /**Gray*/
+    static const uint16_t Gray;
+    
+    /**Black*/
+    static const uint16_t Black;
+    
+    /**Red*/
+    static const uint16_t Red;
+    
+    /**Maroon*/
+    static const uint16_t Maroon;
+    
+    /**Yellow*/
+    static const uint16_t Yellow;
+    
+    /**Olive*/
+    static const uint16_t Olive;
+    
+    /**Lime*/
+    static const uint16_t Lime;
+    
+    /**Green*/
+    static const uint16_t Green;
+    
+    /**Aqua*/
+    static const uint16_t Aqua;
+    
+    /**Teal*/
+    static const uint16_t Teal;
+    
+    /**Blue*/
+    static const uint16_t Blue;
+    
+    /**Navy*/
+    static const uint16_t Navy;
+    
+    /**Fuchsia*/
+    static const uint16_t Fuchsia;
+    
+    /**Purple*/
+    static const uint16_t Purple;
+
+    /**Returns a 565 RGB color built from individual RGB color components
+     * @param r Red component
+     * @param g Green component
+     * @param b Blue component
+    */    
+    static uint16_t fromRGB(uint8_t r, uint8_t g, uint8_t b)
+    {
+        return ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3)  ;
+    }
+private:
+    Color565(){};  
+};
+#endif // __COLOR565_H__
\ No newline at end of file