145 lines
4.6 KiB
C++
Executable File
145 lines
4.6 KiB
C++
Executable File
// Define digital pins
|
|
|
|
#define PIN_SCE 7
|
|
#define PIN_RESET 6
|
|
#define PIN_DC 5
|
|
#define PIN_SDIN 4
|
|
#define PIN_SCLK 3
|
|
|
|
#define LCD_C LOW
|
|
#define LCD_D HIGH
|
|
|
|
// Bounds of the display
|
|
|
|
#define LCD_X 84
|
|
#define LCD_Y 48
|
|
|
|
// Bitmap definition
|
|
|
|
char tux[] = {
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0,
|
|
0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0,
|
|
0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0xFF, 0xB1, 0x5D, 0x89, 0x8F, 0x89,
|
|
0x5D, 0x11, 0x3F, 0xFF, 0xFF, 0xFF, 0xF8, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0xE0, 0xF0, 0x78, 0x3E, 0x03, 0x01,
|
|
0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01,
|
|
0x03, 0x1F, 0x7F, 0xFF, 0xFE, 0xF8, 0xF0, 0xC0,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0xC0, 0x3C, 0x3F, 0x7F, 0xC3,
|
|
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x7F,
|
|
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x26, 0x59, 0x41, 0x41, 0x80,
|
|
0x80, 0x80, 0x80, 0x00, 0x03, 0x07, 0x9E, 0xE4,
|
|
0xE0, 0xE0, 0x60, 0x60, 0x60, 0x60, 0x60, 0x70,
|
|
0x78, 0x7B, 0xFC, 0x00, 0x00, 0x01, 0x01, 0x01,
|
|
0x80, 0x47, 0x48, 0x28, 0x10, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
|
|
0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
|
|
0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
|
|
|
|
// LCD Procedures
|
|
|
|
void LcdClear(void)
|
|
{
|
|
for (int index = 0; index < LCD_X * LCD_Y / 8; index++)
|
|
{
|
|
LcdWrite(LCD_D, 0x00);
|
|
}
|
|
}
|
|
|
|
void LcdInitialise(void)
|
|
{
|
|
pinMode(PIN_SCE, OUTPUT);
|
|
pinMode(PIN_RESET, OUTPUT);
|
|
pinMode(PIN_DC, OUTPUT);
|
|
pinMode(PIN_SDIN, OUTPUT);
|
|
pinMode(PIN_SCLK, OUTPUT);
|
|
digitalWrite(PIN_RESET, LOW);
|
|
digitalWrite(PIN_RESET, HIGH);
|
|
LcdWrite(LCD_C, 0x21 ); // LCD Extended Commands.
|
|
LcdWrite(LCD_C, 0xB1 ); // Set LCD Vop (Contrast).
|
|
LcdWrite(LCD_C, 0x04 ); // Set Temp coefficent. //0x04
|
|
LcdWrite(LCD_C, 0x14 ); // LCD bias mode 1:48. //0x13
|
|
LcdWrite(LCD_C, 0x0C ); // LCD in normal mode.
|
|
LcdWrite(LCD_C, 0x20 );
|
|
LcdWrite(LCD_C, 0x0C );
|
|
}
|
|
|
|
void gotoXY(int x, int y)
|
|
{
|
|
LcdWrite( 0, 0x80 | x); // Column.
|
|
LcdWrite( 0, 0x40 | y); // Row.
|
|
|
|
}
|
|
void LcdWrite(byte dc, byte data)
|
|
{
|
|
digitalWrite(PIN_DC, dc);
|
|
digitalWrite(PIN_SCE, LOW);
|
|
shiftOut(PIN_SDIN, PIN_SCLK, MSBFIRST, data);
|
|
digitalWrite(PIN_SCE, HIGH);
|
|
}
|
|
|
|
void LcdBitmap(char my_array[]){
|
|
for (int index = 0 ; index < (LCD_X * LCD_Y / 8) ; index++)
|
|
LcdWrite(LCD_D, my_array[index]);
|
|
}
|
|
|
|
void setup(void)
|
|
{
|
|
LcdInitialise();
|
|
LcdClear();
|
|
gotoXY(0,0);
|
|
}
|
|
|
|
void loop(void)
|
|
{
|
|
LcdBitmap(tux);
|
|
while (true)
|
|
{
|
|
}
|
|
}
|