Wilbert George / Mbed 2 deprecated NewOutrageousRetroSlot

Dependencies:   USBDevice mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers DisplayN18.h Source File

DisplayN18.h

00001 
00002 #include "mbed.h"
00003 
00004 #pragma once
00005 
00006 class DisplayN18 {
00007     static const unsigned char STEP = 4;
00008     
00009     DigitalOut resetPin;
00010     DigitalOut backlightPin;
00011     DigitalOut rsPin;
00012     DigitalOut csPin;
00013     SPI spi;
00014 
00015     void writeCommand(unsigned char command);
00016     void writeData(unsigned char data);
00017     void writeData(const unsigned char* data, unsigned int length);
00018 
00019     void reset();
00020     void initialize();
00021     void setClippingArea(unsigned char x, unsigned char y, unsigned char width, unsigned char height);
00022 
00023     public:
00024         DisplayN18();
00025         
00026         static const unsigned short BLUE = 0x00F8;
00027         static const unsigned short GREEN = 0xE007;
00028         static const unsigned short RED = 0x1F00;
00029         static const unsigned short WHITE = 0xFFFF;
00030         static const unsigned short BLACK = 0x0000;
00031 
00032         static const unsigned int WIDTH = 160;
00033         static const unsigned int HEIGHT = 128;
00034         static const unsigned char CHAR_WIDTH = 5;
00035         static const unsigned char CHAR_HEIGHT = 8;
00036         static const unsigned char CHAR_SPACING = 1;
00037 
00038         static unsigned short rgbToShort(unsigned char r, unsigned char g, unsigned char b);
00039 
00040         void clear(unsigned short backColor = 0x0000);
00041         void draw(const unsigned short* data, int x, int y, int width, int height);
00042         void setPixel(int x, int y, unsigned short foreColor);
00043 
00044         void fillRect(int x, int y, int width, int height, unsigned short foreColor);
00045         void drawRect(int x, int y, int width, int height, unsigned short foreColor);
00046 
00047         void fillCircle(int x, int y, int radius, unsigned short foreColor);
00048         void drawCircle(int x, int y, int radius, unsigned short foreColor);
00049 
00050         void drawLine(int x0, int y0, int x1, int y1, unsigned short foreColor);
00051 
00052         void drawCharacter(int x, int y, const char character, unsigned short foreColor, unsigned short backColor, unsigned char fontSize = 1);
00053         void drawString(int x, int y, const char* str, unsigned short foreColor, unsigned short backColor, unsigned char fontSize = 1);
00054 };