LCD "Bigfont" Numbers over 2 or 4 lines

Hello,

ive seen this in the MPGuino, and on some other Projects, they display numbers over 2 or 4 lines.

Samples:

ive read the mpguino code, but im not getting it :-[

Can somebody give me hints how i can make something like this? :-?

Custom Characters are clear to me, but how do they print "int´s" like that...

help would be highly appreciated :slight_smile:

did some play:

2 Lines:

Needed Custom Characters:

4 Lines:

Needed Custom Characters:

Thats sorted, now "only" the code is missing :-/

You could write a function like this:

void writeLargeString(char* str){
  byte index=0;
  writeLargeChar( *str, index++ );
  while (++str){
    writeLargeChar( *str, index++ );
  }
}

void writeLargeChar(char character, byte leftAdjust){
  switch (character){
    case 'A': 
    case 'a':
      //implement code
      //remember to move cursor to the correct places
      //print correct custom chars
    break;
  }
}

When implemented you could do this:

With this:

writeLargeString("12345");

Or this:

writeLargeChar('1',0);
writeLargeChar('2',1);
writeLargeChar('3',2);
writeLargeChar('4',3);
writeLargeChar('5',4);
[/code


Not very helpful, but might be an idea.

uh nice , thats a idea! :slight_smile:

will give that a try, hope to get it working

How many custom chars can the unit store?

designer2k2,

Inspired by your designs, I tweaked my 3-line large font. Here are some pictures: H I F I D U I N O: New Fonts

8 characters can be stored, and the "Everything on" Block is already there.

glt, nice to see it spreading :wink: but i think with some more custom characters you can round it even more, will try that tomorrow.

and im going to try your code, to see what works for me :slight_smile:

got it :smiley:

2line:

and showing a value (boost):

and showing it with 4line´s:

the code, for the 2lines:

(GitHub - designer2k2/multidisplay: The MultiDisplay Project, An opensource datalogger, boost controller and display for cars)

//Bigfont Code
//
//BIG parts from http://opengauge.googlecode.com/svn/trunk/mpguino/mpguino.pde

void CGRAM_BigFont2()
{

//255 is the "Full Block" Code, and 254 is blank
int data1[] = {31,31,31,0,0,0,0,0}; //Small Block on top
int data2[] = {0,0,0,0,0,31,31,31}; //Small Block on bottom
int data3[] = {31,31,31,0,0,0,31,31}; //Small Block on top and bottom
int data4[] = {28,30,31,31,31,31,30,28}; //Full Block roundet right
int data5[] = {7,15,31,31,31,31,15,7}; //Full Block roundet left
int data6[] = {0,0,0,14,14,14,12,8}; //Dot, for Decimal.

LcdUploadUdef5x8(1,data1);
LcdUploadUdef5x8(2,data2);
LcdUploadUdef5x8(3,data3);
LcdUploadUdef5x8(4,data4);
LcdUploadUdef5x8(5,data5);
LcdUploadUdef5x8(6,data6);

}

// Array index into parts of big numbers. Numbers consist of 6 custom characters in 2 lines
// 0 1 2 3 4 5 6 7 8 9
char bn12[]={255,1,255,0, 1,255,254,0, 1,3,4,0, 1,3,4,0, 255,2,2,0, 255,3,1,0, 5,3,1,0, 1,1,4,0, 5,3,4,0, 5,3,4,0};
char bn22[]={255,2,255,0, 2,255,2,0, 5,2,2,0, 2,2,4,0, 254,255,254,0, 2,2,4,0, 5,2,4,0, 254,255,254,0, 5,2,4,0, 254,254,255,0};

void printOneNumber2(uint8_t digit, byte leftAdjust, int LineOffset)
{
// LineOffset = 0, means 1 Line, LineOffset = 20 means 2 Line.
// leftAdjust = 0, means 1 Pos, leftAdjust = 1 is second Pos.

// Line 1 of the one digit number
lcd.commandWrite(0x80+LineOffset+leftAdjust3+1leftAdjust); //Line1
lcd.print(bn12[digit3]);
lcd.print(bn12[digit
3+1]);
lcd.print(bn12[digit*3+2]);

// Line 2 of the one-digit number
lcd.commandWrite(0xC0+LineOffset+leftAdjust3+1leftAdjust); // Line 2
lcd.print(bn22[digit3]);
lcd.print(bn22[digit
3+1]);
lcd.print(bn22[digit*3+2]);

}

void bigNum (unsigned long t, int LineOffset, byte leftAdjust, int d){

// LineOffset = 0, means 1 Line, LineOffset = 20 means 2 Line.
// d = 0, means no dp!

// unsigned long t = 98550ul;//number in thousandths
// unsigned long t = 9855ul;//number in thousandths
char dp = 254;
char dp2 = 254;

char * r = "009.99"; //default to 999
if(t<=99500){
r=format(t/10); //0098.6
dp=6;
}else if(t<=999500){
r=format(t/100);
}
if(t<=9950)
{
dp = 254;
dp2 = 6;
r=format(t); //009.86
}

if(d==0)
{
dp = 254;
dp2 = 254;
}

lcd.commandWrite(0x80+LineOffset+leftAdjust);
lcd.printIn(bn12+(r[2]-'0')*4);
lcd.printIn(" ");
lcd.printIn(bn12+(r[4]-'0')*4);
lcd.printIn(" ");
lcd.printIn(bn12+(r[5]-'0')*4);

lcd.commandWrite(0xC0+LineOffset+leftAdjust);
lcd.printIn(bn22+(r[2]-'0')*4);
lcd.print(dp2);
lcd.printIn(bn22+(r[4]-'0')*4);
lcd.print(dp);
lcd.printIn(bn22+(r[5]-'0')*4);

}

char fBuff[7];//used by format

char* format(unsigned long num){
byte dp = 3;

while(num > 999999){
num /= 10;
dp++;
if( dp == 5 ) break; // We'll lose the top numbers like an odometer
}
if(dp == 5) dp = 99; // We don't need a decimal point here.

// Round off the non-printed value.
if((num % 10) > 4)
num += 10;
num /= 10;
byte x = 6;
while(x > 0){
x--;
if(x==dp){ //time to poke in the decimal point?{
fBuff[x]='.';
}else{
fBuff[x]= '0' + (num % 10);//poke the ascii character for the digit.
num /= 10;
}
}
fBuff[6] = 0;
return fBuff;
}

and the other functions for the 4lines:

void CGRAM_BigFont4()
{

//255 is the "Full Block" Code, and 254 is blank
int data1[] = {0,0,0,0,3,15,15,31}; //Small Block on bottom left
int data2[] = {0,0,0,0,31,31,31,31}; //Small Block on bottom right
int data3[] = {0,0,0,0,24,30,30,31}; //Small Block on bottom full
int data4[] = {31,15,15,3,0,0,0,0}; //Small Block on top left
int data5[] = {31,30,30,24,0,0,0,0}; //Small Block on top right
int data6[] = {31,31,31,31,0,0,0,0}; //Small Block on top full
int data7[] = {14,14,14,14,12,8,0,0}; //Dot, for Decimal.

LcdUploadUdef5x8(1,data1);
LcdUploadUdef5x8(2,data2);
LcdUploadUdef5x8(3,data3);
LcdUploadUdef5x8(4,data4);
LcdUploadUdef5x8(5,data5);
LcdUploadUdef5x8(6,data6);
LcdUploadUdef5x8(7,data7);

}

// Array index into parts of big numbers. Numbers consist of 12 custom characters in 4 lines
// 0 1 2 3 4 5 6 7 8 9
char bn14[]={1,2,3,0, 2,3,254,0, 1,2,3,0, 1,2,3,0, 2,254,254,0, 2,2,2,0, 1,2,3,0, 2,2,2,0, 1,2,3,0, 1,2,3,0};
char bn24[]={255,254,255,0, 254,255,254,0, 1,2,255,0, 254,2,255,0, 255,2,2,0, 255,2,2,0, 255,2,3,0, 254,2,255,0, 255,2,255,0, 255,254,255,0};
char bn34[]={255,254,255,0, 254,255,254,0, 255,254,254,0, 254,254,255,0, 254,255,254,0, 254,254,255,0, 255,254,255,0, 254,255,254,0, 255,254,255,0, 4,6,255,0};
char bn44[]={4,6,5,0, 6,6,6,0, 4,6,6,0, 4,6,5,0, 254,6,254,0, 6,6,5,0, 4,6,5,0, 254,6,254,0, 4,6,5,0, 254,254,6,0};

void printOneNumber4(uint8_t digit, byte leftAdjust)
{
// leftAdjust = 0, means 1 Pos, leftAdjust = 1 is second Pos.

// Line 1 of the one digit number
lcd.commandWrite(0x80+leftAdjust3+1leftAdjust); //Line 1
lcd.print(bn14[digit3]);
lcd.print(bn14[digit
3+1]);
lcd.print(bn14[digit*3+2]);

// Line 2 of the one-digit number
lcd.commandWrite(0xC0+leftAdjust3+1leftAdjust); // Line 2
lcd.print(bn24[digit3]);
lcd.print(bn24[digit
3+1]);
lcd.print(bn24[digit*3+2]);

// Line 3 of the one digit number
lcd.commandWrite(0x94+leftAdjust3+1leftAdjust); //Line 3
lcd.print(bn34[digit3]);
lcd.print(bn34[digit
3+1]);
lcd.print(bn34[digit*3+2]);

// Line 4 of the one-digit number
lcd.commandWrite(0xD4+leftAdjust3+1leftAdjust); // Line 4
lcd.print(bn44[digit3]);
lcd.print(bn44[digit
3+1]);
lcd.print(bn44[digit*3+2]);

}

void bigNum4 (unsigned long t, byte leftAdjust, int d){

// LineOffset = 0, means 1 Line, LineOffset = 20 means 2 Line.
// d = 0, means no dp!

// unsigned long t = 98550ul;//number in thousandths
// unsigned long t = 9855ul;//number in thousandths
char dp = 254;
char dp2 = 254;

char * r = "009.99"; //default to 999
if(t<=99500){
r=format(t/10); //0098.6
dp=7;
}else if(t<=999500){
r=format(t/100);
}
if(t<=9950)
{
dp = 254;
dp2 = 7;
r=format(t); //009.86
}

if(d==0)
{
dp = 254;
dp2 = 254;
}

lcd.commandWrite(0x80+leftAdjust);
lcd.printIn(bn14+(r[2]-'0')*4);
lcd.printIn(" ");
lcd.printIn(bn14+(r[4]-'0')*4);
lcd.printIn(" ");
lcd.printIn(bn14+(r[5]-'0')*4);

lcd.commandWrite(0xC0+leftAdjust);
lcd.printIn(bn24+(r[2]-'0')*4);
lcd.printIn(" ");
lcd.printIn(bn24+(r[4]-'0')*4);
lcd.printIn(" ");
lcd.printIn(bn24+(r[5]-'0')*4);

lcd.commandWrite(0x94+leftAdjust);
lcd.printIn(bn34+(r[2]-'0')*4);
lcd.printIn(" ");
lcd.printIn(bn34+(r[4]-'0')*4);
lcd.printIn(" ");
lcd.printIn(bn34+(r[5]-'0')*4);

lcd.commandWrite(0xD4+leftAdjust);
lcd.printIn(bn44+(r[2]-'0')*4);
lcd.print(dp2);
lcd.printIn(bn44+(r[4]-'0')*4);
lcd.print(dp);
lcd.printIn(bn44+(r[5]-'0')*4);

}

Where is the declaration for LcdUploadUdef5x8()?

here it is:

void LcdUploadUdef5x8(int character, int *data)
{
  int c = character << 3, i;
  for (i = 0; i < 8; i++)
  {
    lcd.commandWrite(0x40 | c | i);
    lcd.print(data[i]);
  }
}

:slight_smile:

Ok, I hate LCD4Bit, here's some code to do it with LiquidCrystal:

#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7, 8);

byte custchar[8][8] = {
{
B11111,
B11111,
B11111,
B00000,
B00000,
B00000,
B00000,
B00000
}, {
B00000,
B00000,
B00000,
B00000,
B00000,
B11111,
B11111,
B11111
}, {
B11111,
B11111,
B11111,
B00000,
B00000,
B11111,
B11111,
B11111
}, {
B00000,
B00000,
B00000,
B00000,
B00000,
B01110,
B01110,
B01110
}, {
B00000,
B00000,
B00000,
B01110,
B01110,
B01110,
B00000,
B00000
}, {
B00000,
B00000,
B00000,
B00000,
B00000,
B00000,
B00000,
B00000
}, {
B00000,
B00000,
B00000,
B00000,
B00000,
B00000,
B00000,
B00000
}, {
B00000,
B00000,
B00000,
B00000,
B00000,
B00000,
B00000,
B00000
}
};

byte bignums[10][2][3] = {
{
{255, 0, 255},
{255, 1, 255}
},{
{0, 255, 254},
{1, 255, 1}
},{
{2, 2, 255},
{255, 1, 1}
},{
{0, 2, 255},
{1, 1, 255}
},{
{255, 1, 255},
{254, 254, 255}
},{
{255, 2, 2},
{1, 1, 255}
},{
{255, 2, 2},
{255, 1, 255}
},{
{0, 0, 255},
{254, 255, 254}
},{
{255, 2, 255},
{255, 1, 255}
},{
{255, 2, 255},
{254, 254, 255}
}
};

void loadchars() {
lcd.command(64);
for (int i = 0; i < 8; i++)
for (int j = 0; j < 8; j++)
lcd.write(custchar*[j]);*

  • lcd.home();*
    }
    void printbigchar(byte digit, byte col, byte row, byte symbol = 0) {
  • if (digit > 9) return;*
  • for (int i = 0; i < 2; i++) {*
  • lcd.setCursor(col, row + i);*
  • for (int j = 0; j < 3; j++) {*
    _ lcd.write(bignums[digit][j]);_
    * }*
    * lcd.write(254);*
    * }*
    * if (symbol == 1) {*
    * lcd.setCursor(col + 3, row + 1);*
    * lcd.write(3);*
    * } else if (symbol == 2) {*
    * lcd.setCursor(col + 3, row);*
    * lcd.write(4);*
    * lcd.setCursor(col + 3, row + 1);*
    * lcd.write(4);*
    * }*

* lcd.setCursor(col + 4, row);*
}
void setup() {
* pinMode(13, OUTPUT);*
* loadchars();*
* digitalWrite(13, 1);*

* printbigchar(0, 0, 0);*
* printbigchar(1, 4, 0);*
* printbigchar(2, 8, 0);*
* printbigchar(3, 12, 0);*
* printbigchar(4, 16, 0, 1);*
* printbigchar(5, 0, 2);*
* printbigchar(6, 4, 2);*
* printbigchar(7, 8, 2);*
* printbigchar(8, 12, 2);*
* printbigchar(9, 16, 2, 2);*
}
void loop() {}
[/quote]

@ whosawhatsis
thanks for the code. works wonderfull:
Ill maybe adopt it to be a lil bit more round-edged, but just maybe.

nice!

i testet rounder numbers but they are a lot harder to read, somehow this ones are easier to read :-?