Game entry for the Game Programming Contest sponsored by OutrageousCircuits.com (RETRO Game Console)
Fork of Official_RETRO by
DisplayN18.h@0:21669ea33448, 2014-11-10 (annotated)
- Committer:
- john_ghielec
- Date:
- Mon Nov 10 13:04:42 2014 +0000
- Revision:
- 0:21669ea33448
- Child:
- 1:cd8a3926f263
Initial commit.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
john_ghielec | 0:21669ea33448 | 1 | #include "mbed.h" |
john_ghielec | 0:21669ea33448 | 2 | |
john_ghielec | 0:21669ea33448 | 3 | #pragma once |
john_ghielec | 0:21669ea33448 | 4 | |
john_ghielec | 0:21669ea33448 | 5 | class DisplayN18 |
john_ghielec | 0:21669ea33448 | 6 | { |
john_ghielec | 0:21669ea33448 | 7 | static const unsigned char STEP = 4; |
john_ghielec | 0:21669ea33448 | 8 | |
john_ghielec | 0:21669ea33448 | 9 | DigitalOut resetPin; |
john_ghielec | 0:21669ea33448 | 10 | DigitalOut backlightPin; |
john_ghielec | 0:21669ea33448 | 11 | DigitalOut rsPin; |
john_ghielec | 0:21669ea33448 | 12 | DigitalOut csPin; |
john_ghielec | 0:21669ea33448 | 13 | SPI spi; |
john_ghielec | 0:21669ea33448 | 14 | |
john_ghielec | 0:21669ea33448 | 15 | void writeCommand(unsigned char command); |
john_ghielec | 0:21669ea33448 | 16 | void writeData(unsigned char data); |
john_ghielec | 0:21669ea33448 | 17 | void writeData(const unsigned char* data, unsigned int length); |
john_ghielec | 0:21669ea33448 | 18 | |
john_ghielec | 0:21669ea33448 | 19 | void reset(); |
john_ghielec | 0:21669ea33448 | 20 | void initialize(); |
john_ghielec | 0:21669ea33448 | 21 | void setClippingArea(unsigned char x, unsigned char y, unsigned char width, unsigned char height); |
john_ghielec | 0:21669ea33448 | 22 | |
john_ghielec | 0:21669ea33448 | 23 | public: |
john_ghielec | 0:21669ea33448 | 24 | DisplayN18(); |
john_ghielec | 0:21669ea33448 | 25 | |
john_ghielec | 0:21669ea33448 | 26 | static const unsigned short BLUE = 0x00F8; |
john_ghielec | 0:21669ea33448 | 27 | static const unsigned short GREEN = 0xE007; |
john_ghielec | 0:21669ea33448 | 28 | static const unsigned short RED = 0x1F00; |
john_ghielec | 0:21669ea33448 | 29 | static const unsigned short WHITE = 0xFFFF; |
john_ghielec | 0:21669ea33448 | 30 | static const unsigned short BLACK = 0x0000; |
john_ghielec | 0:21669ea33448 | 31 | |
john_ghielec | 0:21669ea33448 | 32 | static const unsigned int WIDTH = 160; |
john_ghielec | 0:21669ea33448 | 33 | static const unsigned int HEIGHT = 128; |
john_ghielec | 0:21669ea33448 | 34 | static const unsigned char CHAR_WIDTH = 5; |
john_ghielec | 0:21669ea33448 | 35 | static const unsigned char CHAR_HEIGHT = 8; |
john_ghielec | 0:21669ea33448 | 36 | static const unsigned char CHAR_SPACING = 1; |
john_ghielec | 0:21669ea33448 | 37 | |
john_ghielec | 0:21669ea33448 | 38 | static unsigned short rgbToShort(unsigned char r, unsigned char g, unsigned char b); |
john_ghielec | 0:21669ea33448 | 39 | |
john_ghielec | 0:21669ea33448 | 40 | void clear(unsigned short backColor = 0x0000); |
john_ghielec | 0:21669ea33448 | 41 | void draw(const unsigned short* data, int x, int y, int width, int height); |
john_ghielec | 0:21669ea33448 | 42 | void setPixel(int x, int y, unsigned short foreColor); |
john_ghielec | 0:21669ea33448 | 43 | |
john_ghielec | 0:21669ea33448 | 44 | void fillRect(int x, int y, int width, int height, unsigned short foreColor); |
john_ghielec | 0:21669ea33448 | 45 | void drawRect(int x, int y, int width, int height, unsigned short foreColor); |
john_ghielec | 0:21669ea33448 | 46 | |
john_ghielec | 0:21669ea33448 | 47 | void fillCircle(int x, int y, int radius, unsigned short foreColor); |
john_ghielec | 0:21669ea33448 | 48 | void drawCircle(int x, int y, int radius, unsigned short foreColor); |
john_ghielec | 0:21669ea33448 | 49 | |
john_ghielec | 0:21669ea33448 | 50 | void drawLine(int x0, int y0, int x1, int y1, unsigned short foreColor); |
john_ghielec | 0:21669ea33448 | 51 | |
john_ghielec | 0:21669ea33448 | 52 | void drawCharacter(int x, int y, const char character, unsigned short foreColor, unsigned short backColor, unsigned char fontSize = 1); |
john_ghielec | 0:21669ea33448 | 53 | void drawString(int x, int y, const char* str, unsigned short foreColor, unsigned short backColor, unsigned char fontSize = 1); |
john_ghielec | 0:21669ea33448 | 54 | }; |