Source code of my entry for Retro gaming contest (www.outrageouscircuits.com)

Dependencies:   MMA8453 mbed

Fork of LCD_DEMO by Chris Taylor

NOTE: I don't why mbed says that it's a fork form LCD_DEMO by Chris Taylor -> I don't use that library

SHAKE THE MAZE!!!

Shake your RETRO board and solve the maze!!! /media/uploads/gbr1mbed/dscn0738.jpg

Different maze everytime! /media/uploads/gbr1mbed/dscn0739.jpg

Here a case I built. /media/uploads/gbr1mbed/dscn0742.jpg

More details in main.cpp comments

video:

DisplayN18.h

Committer:
gbr1mbed
Date:
2015-03-01
Revision:
1:600980390cf7

File content as of revision 1:600980390cf7:

#include "mbed.h"

#pragma once

class DisplayN18 {
    static const unsigned char STEP = 4;
    
    DigitalOut resetPin;
    DigitalOut backlightPin;
    DigitalOut rsPin;
    DigitalOut csPin;
    SPI spi;

    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();
        
        static const unsigned short BLUE = 0x00F8;
        static const unsigned short GREEN = 0xE007;
        static const unsigned short RED = 0x1F00;
        static const unsigned short WHITE = 0xFFFF;
        static const unsigned short BLACK = 0x0000;

        static const unsigned int WIDTH = 160;
        static const unsigned int HEIGHT = 128;
        static const unsigned char CHAR_WIDTH = 5;
        static const unsigned char CHAR_HEIGHT = 8;
        static const unsigned char CHAR_SPACING = 1;

        static unsigned short rgbToShort(unsigned char r, unsigned char g, unsigned char b);

        void clear(unsigned short backColor = 0x0000);
        void draw(const unsigned short* data, int x, int y, int width, int height);
        void setPixel(int x, int y, unsigned short foreColor);

        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);

        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);
};