Simple program for the RETRO to compare the performance of the DisplayN18 and LCD_ST7735 libraries.

Dependencies:   LCD_ST7735 mbed

This is a very simple program for the RETRO to compare the performance of some of the primitives of the DisplayN18 and LCD_ST7735 libraries

WARNING - WARNING - WARNING

If you're sensitive to ugly coding techniques, lack of best practice, ignorance of proper design patterns, abuse of object orientation or to total disregards of any coding guidelines, then don't - I repeat - DON'T look at this code...

P.S. Regardless the performance, I do think the N18 library has a much nicer font!

Committer:
maxint
Date:
Fri Jan 16 21:41:09 2015 +0000
Revision:
2:dcf8e6db342d
Parent:
0:59d6b70df5a4
Added bottomPrintf_xxx function to make the tests slightly more readable. Tiny bit of cleaning up the test functions.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
maxint 0:59d6b70df5a4 1 #include "mbed.h"
maxint 0:59d6b70df5a4 2
maxint 0:59d6b70df5a4 3 #pragma once
maxint 0:59d6b70df5a4 4
maxint 0:59d6b70df5a4 5 class DisplayN18 {
maxint 0:59d6b70df5a4 6 static const unsigned char STEP = 4;
maxint 0:59d6b70df5a4 7
maxint 0:59d6b70df5a4 8 DigitalOut resetPin;
maxint 0:59d6b70df5a4 9 DigitalOut backlightPin;
maxint 0:59d6b70df5a4 10 DigitalOut rsPin;
maxint 0:59d6b70df5a4 11 DigitalOut csPin;
maxint 0:59d6b70df5a4 12 SPI spi;
maxint 0:59d6b70df5a4 13
maxint 0:59d6b70df5a4 14 void writeCommand(unsigned char command);
maxint 0:59d6b70df5a4 15 void writeData(unsigned char data);
maxint 0:59d6b70df5a4 16 void writeData(const unsigned char* data, unsigned int length);
maxint 0:59d6b70df5a4 17
maxint 0:59d6b70df5a4 18 void reset();
maxint 0:59d6b70df5a4 19 void initialize();
maxint 0:59d6b70df5a4 20 void setClippingArea(unsigned char x, unsigned char y, unsigned char width, unsigned char height);
maxint 0:59d6b70df5a4 21
maxint 0:59d6b70df5a4 22 public:
maxint 0:59d6b70df5a4 23 DisplayN18();
maxint 0:59d6b70df5a4 24
maxint 0:59d6b70df5a4 25 static const unsigned short BLUE = 0x00F8;
maxint 0:59d6b70df5a4 26 static const unsigned short GREEN = 0xE007;
maxint 0:59d6b70df5a4 27 static const unsigned short RED = 0x1F00;
maxint 0:59d6b70df5a4 28 static const unsigned short WHITE = 0xFFFF;
maxint 0:59d6b70df5a4 29 static const unsigned short BLACK = 0x0000;
maxint 0:59d6b70df5a4 30
maxint 0:59d6b70df5a4 31 static const unsigned int WIDTH = 160;
maxint 0:59d6b70df5a4 32 static const unsigned int HEIGHT = 128;
maxint 0:59d6b70df5a4 33 static const unsigned char CHAR_WIDTH = 5;
maxint 0:59d6b70df5a4 34 static const unsigned char CHAR_HEIGHT = 8;
maxint 0:59d6b70df5a4 35 static const unsigned char CHAR_SPACING = 1;
maxint 0:59d6b70df5a4 36
maxint 0:59d6b70df5a4 37 static unsigned short rgbToShort(unsigned char r, unsigned char g, unsigned char b);
maxint 0:59d6b70df5a4 38
maxint 0:59d6b70df5a4 39 void clear(unsigned short backColor = 0x0000);
maxint 0:59d6b70df5a4 40 void draw(const unsigned short* data, int x, int y, int width, int height);
maxint 0:59d6b70df5a4 41 void setPixel(int x, int y, unsigned short foreColor);
maxint 0:59d6b70df5a4 42
maxint 0:59d6b70df5a4 43 void fillRect(int x, int y, int width, int height, unsigned short foreColor);
maxint 0:59d6b70df5a4 44 void drawRect(int x, int y, int width, int height, unsigned short foreColor);
maxint 0:59d6b70df5a4 45
maxint 0:59d6b70df5a4 46 void fillCircle(int x, int y, int radius, unsigned short foreColor);
maxint 0:59d6b70df5a4 47 void drawCircle(int x, int y, int radius, unsigned short foreColor);
maxint 0:59d6b70df5a4 48
maxint 0:59d6b70df5a4 49 void drawLine(int x0, int y0, int x1, int y1, unsigned short foreColor);
maxint 0:59d6b70df5a4 50
maxint 0:59d6b70df5a4 51 void drawCharacter(int x, int y, const char character, unsigned short foreColor, unsigned short backColor, unsigned char fontSize = 1);
maxint 0:59d6b70df5a4 52 void drawString(int x, int y, const char* str, unsigned short foreColor, unsigned short backColor, unsigned char fontSize = 1);
maxint 0:59d6b70df5a4 53 };