Chris Favreau / Mbed 2 deprecated RETROINVADERS

Dependencies:   mbed

Revision:
0:c79e1f29f029
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Display/DisplayN18.h	Tue Mar 03 04:26:01 2015 +0000
@@ -0,0 +1,76 @@
+#include "mbed.h"
+#include "BurstSPI.h"   // Fast SPI class
+#include "font8x8.h"    // Default 8x8 Font
+
+// Colors
+#define RGB2SHORT(r, g, b) (((r & 0xF8) << 8) | ((b & 0xFC) << 3) | (g >> 3))
+#define     BLUE    RGB2SHORT(0, 0, 255)
+#define     GREEN   RGB2SHORT(0, 255, 0)
+#define     RED     RGB2SHORT(255, 0, 0)
+#define     WHITE   RGB2SHORT(255, 255, 255)
+#define     BLACK   RGB2SHORT(0, 0, 0)
+#define     MAGENTA RGB2SHORT(255, 0, 255)      
+#define     CYAN    RGB2SHORT(0, 255, 255)
+#define     YELLOW  RGB2SHORT(255, 255, 0)
+
+#define LCD_WIDTH        160
+#define LCD_HEIGHT       128
+
+#pragma once
+
+class DisplayN18 {
+protected:
+    static const unsigned char STEP = 4;
+    
+    DigitalOut resetPin;
+    DigitalOut backlightPin;
+    DigitalOut rsPin;
+    DigitalOut csPin;
+    //SPI spi;
+    BurstSPI spi;
+    
+    unsigned char *buffer;
+
+    void writeCommand(unsigned char command);
+    void writeData(unsigned char data);
+    void writeData(const unsigned char* data, unsigned int length);
+
+    void reset();
+    void initialize();
+    void setClippingArea(unsigned char x, unsigned char y, unsigned char width, unsigned char height);
+    
+    public:
+        DisplayN18();
+        
+        // Either rgbToShort is backwards OR these were backwards.. so I reorganized the byte order.
+        /*
+        static const unsigned short BLUE = 0xF800;
+        static const unsigned short GREEN = 0x07E0;
+        static const unsigned short RED = 0x001F;
+        static const unsigned short WHITE = 0xFFFF;
+        static const unsigned short BLACK = 0x0000;
+        */
+
+        unsigned short *getLineBuffer();
+        void blitLine(unsigned char line);
+        
+        static unsigned short rgbToShort(unsigned char r, unsigned char g, unsigned char b);
+
+        void clear(unsigned short backColor = BLACK);
+        void draw(const unsigned short* data, int x, int y, int width, int height);
+        void setPixel(int x, int y, unsigned short foreColor);
+        
+        void drawBitmap(int x, int y, int w, int h, unsigned char *bitmap, unsigned short foreColor, unsigned short backColor);
+
+        void fillRect(int x, int y, int width, int height, unsigned short foreColor);
+        void drawRect(int x, int y, int width, int height, unsigned short foreColor);
+
+        void fillCircle(int x, int y, int radius, unsigned short foreColor);
+        void drawCircle(int x, int y, int radius, unsigned short foreColor);
+
+        void drawLine(int x0, int y0, int x1, int y1, unsigned short foreColor);
+
+        //unsigned char *getCharBuffer();
+        //void drawCharacter(int x, int y, const char character, unsigned short foreColor, unsigned short backColor, unsigned char fontSize = 1);
+        //void drawString(int x, int y, const char* str, unsigned short foreColor, unsigned short backColor, unsigned char fontSize = 1);
+};
\ No newline at end of file