Dimitar Minchev / Mbed 2 deprecated SIR

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers DisplayN18.h Source File

DisplayN18.h

00001 #include "mbed.h"
00002 
00003 #pragma once
00004 
00005 class DisplayN18 {
00006     static const unsigned char STEP = 4;
00007     
00008     DigitalOut resetPin;
00009     DigitalOut backlightPin;
00010     DigitalOut rsPin;
00011     DigitalOut csPin;
00012     SPI spi;
00013 
00014     void writeCommand(unsigned char command);
00015     void writeData(unsigned char data);
00016     void writeData(const unsigned char* data, unsigned int length);
00017 
00018     void reset();
00019     void initialize();
00020     void setClippingArea(unsigned char x, unsigned char y, unsigned char width, unsigned char height);
00021 
00022     public:
00023         DisplayN18();
00024         
00025     /**White*/
00026     static const uint16_t White;
00027     
00028     /**Silver*/
00029     static const uint16_t Silver;
00030     
00031     /**Gray*/
00032     static const uint16_t Gray;
00033     
00034     /**Black*/
00035     static const uint16_t Black;
00036     
00037     /**Red*/
00038     static const uint16_t Red;
00039     
00040     /**Maroon*/
00041     static const uint16_t Maroon;
00042     
00043     /**Yellow*/
00044     static const uint16_t Yellow;
00045     
00046     /**Olive*/
00047     static const uint16_t Olive;
00048     
00049     /**Lime*/
00050     static const uint16_t Lime;
00051     
00052     /**Green*/
00053     static const uint16_t Green;
00054     
00055     /**Aqua*/
00056     static const uint16_t Aqua;
00057     
00058     /**Teal*/
00059     static const uint16_t Teal;
00060     
00061     /**Blue*/
00062     static const uint16_t Blue;
00063     
00064     /**Navy*/
00065     static const uint16_t Navy;
00066     
00067     /**Fuchsia*/
00068     static const uint16_t Fuchsia;
00069     
00070     /**Purple*/
00071     static const uint16_t Purple;
00072 
00073         static const unsigned int WIDTH = 160;
00074         static const unsigned int HEIGHT =  128;
00075         static const unsigned char CHAR_WIDTH = 5;
00076         static const unsigned char CHAR_HEIGHT = 8;
00077         static const unsigned char CHAR_SPACING = 1;
00078 
00079         static unsigned short rgbToShort(unsigned char r, unsigned char g, unsigned char b);
00080 
00081         void clear(unsigned short backColor = 0x0000);
00082         void draw(const unsigned short* data, int x, int y, int width, int height);
00083         void setPixel(int x, int y, unsigned short foreColor);
00084 
00085         void fillRect(int x, int y, int width, int height, unsigned short foreColor);
00086         void drawRect(int x, int y, int width, int height, unsigned short foreColor);
00087 
00088         void fillCircle(int x, int y, int radius, unsigned short foreColor);
00089         void drawCircle(int x, int y, int radius, unsigned short foreColor);
00090 
00091         void drawLine(int x0, int y0, int x1, int y1, unsigned short foreColor);
00092 
00093         void drawCharacter(int x, int y, const char character, unsigned short foreColor, unsigned short backColor, unsigned char fontSize = 1);
00094         void drawString(int x, int y, const char* str, unsigned short foreColor, unsigned short backColor, unsigned char fontSize = 1);
00095 };