// double.c - Double-Height Digit Characters for HD44780 LCD Controller
//
// Copyright (C) 1997, Ian Harries & Imperial College, London, UK
//
// compiled with Microsoft Visual C++ v4.2 under Windows95
#include "hd44780.h" // HD44780 Instructions and Parameter definitions
void Define_Doubles(void) { // uses all 8 user-defined characters in CGRAM
// save current address in DDRAM
// Ref: http://www.doc.ic.ac.uk/~ih/doc/lcd/double.html
Put_Ins(Set_CGRAM_Address + 0); // Set CGRAM address to zero'th character
// (automatically incremented after write)
// BitPattern DataByte
// Character 0 // ========== ========
Put_Data(0x01); // x x x . . . . * 00000001
Put_Data(0x01); // x x x . . . . * 00000001
Put_Data(0x01); // x x x . . . . * 00000001
Put_Data(0x01); // x x x . . . . * 00000001
Put_Data(0x01); // x x x . . . . * 00000001
Put_Data(0x01); // x x x . . . . * 00000001
Put_Data(0x01); // x x x . . . . * 00000001
Put_Data(0x01); // x x x . . . . * 00000001
// Character 1
Put_Data(0x1F); // x x x * * * * * 00011111
Put_Data(0x11); // x x x * . . . * 00010001
Put_Data(0x11); // x x x * . . . * 00010001
Put_Data(0x11); // x x x * . . . * 00010001
Put_Data(0x11); // x x x * . . . * 00010001
Put_Data(0x11); // x x x * . . . * 00010001
Put_Data(0x11); // x x x * . . . * 00010001
Put_Data(0x11); // x x x * . . . * 00010001
// Character 2
Put_Data(0x1F); // x x x * * * * * 00011111
Put_Data(0x10); // x x x * . . . . 00010000
Put_Data(0x10); // x x x * . . . . 00010000
Put_Data(0x10); // x x x * . . . . 00010000
Put_Data(0x10); // x x x * . . . . 00010000
Put_Data(0x10); // x x x * . . . . 00010000
Put_Data(0x10); // x x x * . . . . 00010000
Put_Data(0x1F); // x x x * * * * * 00011111
// Character 3
Put_Data(0x01); // x x x . . . . * 00000001
Put_Data(0x01); // x x x . . . . * 00000001
Put_Data(0x01); // x x x . . . . * 00000001
Put_Data(0x01); // x x x . . . . * 00000001
Put_Data(0x01); // x x x . . . . * 00000001
Put_Data(0x01); // x x x . . . . * 00000001
Put_Data(0x01); // x x x . . . . * 00000001
Put_Data(0x1F); // x x x * * * * * 00011111
// Character 4
Put_Data(0x1F); // x x x * * * * * 00011111
Put_Data(0x11); // x x x * . . . * 00010001
Put_Data(0x11); // x x x * . . . * 00010001
Put_Data(0x11); // x x x * . . . * 00010001
Put_Data(0x11); // x x x * . . . * 00010001
Put_Data(0x11); // x x x * . . . * 00010001
Put_Data(0x11); // x x x * . . . * 00010001
Put_Data(0x1F); // x x x * * * * * 00011111
// Character 5
Put_Data(0x11); // x x x * . . . * 00010001
Put_Data(0x11); // x x x * . . . * 00010001
Put_Data(0x11); // x x x * . . . * 00010001
Put_Data(0x11); // x x x * . . . * 00010001
Put_Data(0x11); // x x x * . . . * 00010001
Put_Data(0x11); // x x x * . . . * 00010001
Put_Data(0x11); // x x x * . . . * 00010001
Put_Data(0x1F); // x x x * * * * * 00011111
// Character 6
Put_Data(0x1F); // x x x * * * * * 00011111
Put_Data(0x01); // x x x . . . . * 00000001
Put_Data(0x01); // x x x . . . . * 00000001
Put_Data(0x01); // x x x . . . . * 00000001
Put_Data(0x01); // x x x . . . . * 00000001
Put_Data(0x01); // x x x . . . . * 00000001
Put_Data(0x01); // x x x . . . . * 00000001
Put_Data(0x1F); // x x x * * * * * 00011111
// Character 7
Put_Data(0x1F); // x x x * * * * * 00011111
Put_Data(0x01); // x x x . . . . * 00000001
Put_Data(0x01); // x x x . . . . * 00000001
Put_Data(0x01); // x x x . . . . * 00000001
Put_Data(0x01); // x x x . . . . * 00000001
Put_Data(0x01); // x x x . . . . * 00000001
Put_Data(0x01); // x x x . . . . * 00000001
Put_Data(0x01); // x x x . . . . * 00000001
// Sure I could have used loops to cut down the code,
// but would it have been as clear?
// restore current address in DDRAM
}
void Put_Upper(int num) { // Upper Half of Double-Height Digit Character
switch (num) {
case 0: Put_Char(1);
break;
case 1: Put_Char(0);
break;
case 2: Put_Char(7);
break;
case 3: Put_Char(6);
break;
case 4: Put_Char(5);
break;
case 5: Put_Char(2);
break;
case 6: Put_Char(2);
break;
case 7: Put_Char(7);
break;
case 8: Put_Char(4);
break;
case 9: Put_Char(4);
break;
default: Put_Char('?'); // shurely shome mishtake?
}
}
void Put_Lower(int num) { // Lower Half of Double-Height Digit Character
switch (num) {
case 0: Put_Char(5);
break;
case 1: Put_Char(0);
break;
case 2: Put_Char(2);
break;
case 3: Put_Char(3);
break;
case 4: Put_Char(0);
break;
case 5: Put_Char(3);
break;
case 6: Put_Char(5);
break;
case 7: Put_Char(0);
break;
case 8: Put_Char(5);
break;
case 9: Put_Char(3);
break;
default: Put_Char('?'); // shurely shome mishtake?
}
}
void Put_Double(int num, int col) { // 40 character x 2 line display
Put_Ins(Set_DDRAM_Address + col); // set DDRAM address to upper line of column
Put_Upper(num);
Put_Ins(Set_DDRAM_Address + col + Line2_Offset);
// set DDRAM address to lower line of column
Put_Lower(num);
}
void main(void) {
int i;
Init_Display();
Define_Doubles(); // one-off definition at startup
Put_Ins(Set_Display + Display_On + Cursor_Off + Blink_Off);
for (i = 0; i <= 9; i++)
Put_Double(i,i*2+1);
}
last updated: 26-Mar-97 Ian Harries <ih@doc.ic.ac.uk>