Austria
Offline
Sr. Member
Karma: 3
Posts: 261
Arduino rocks
|
 |
« on: June 18, 2009, 02:17:33 pm » |
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 
|
|
|
|
« Last Edit: June 19, 2009, 09:40:04 am by designer2k2 »
|
Logged
|
|
|
|
|
Austria
Offline
Sr. Member
Karma: 3
Posts: 261
Arduino rocks
|
 |
« Reply #1 on: June 19, 2009, 09:39:44 am » |
did some play: 2 Lines:  Needed Custom Characters:  4 Lines:   Needed Custom Characters:  Thats sorted, now "only" the code is missing :-/
|
|
|
|
|
Logged
|
|
|
|
|
Norway@Oslo
Offline
Edison Member
Karma: 11
Posts: 2033
loveArduino(true);
|
 |
« Reply #2 on: June 19, 2009, 10:28:09 am » |
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: [code] writeLargeChar('1',0); writeLargeChar('2',1); writeLargeChar('3',2); writeLargeChar('4',3); writeLargeChar('5',4); [/code Not very helpful, but might be an idea.
|
|
|
|
« Last Edit: June 19, 2009, 10:30:17 am by AlphaBeta »
|
Logged
|
|
|
|
|
Austria
Offline
Sr. Member
Karma: 3
Posts: 261
Arduino rocks
|
 |
« Reply #3 on: June 19, 2009, 11:29:06 am » |
uh nice , thats a idea!  will give that a try, hope to get it working
|
|
|
|
|
Logged
|
|
|
|
|
London, England
Offline
Edison Member
Karma: 3
Posts: 1026
Go! Go! Arduinoooo !!!
|
 |
« Reply #4 on: June 19, 2009, 04:00:44 pm » |
How many custom chars can the unit store?
|
|
|
|
|
Logged
|
|
|
|
|
|
|
Austria
Offline
Sr. Member
Karma: 3
Posts: 261
Arduino rocks
|
 |
« Reply #6 on: June 21, 2009, 11:54:01 am » |
8 characters can be stored, and the "Everything on" Block is already there. glt, nice to see it spreading  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 
|
|
|
|
|
Logged
|
|
|
|
|
Austria
Offline
Sr. Member
Karma: 3
Posts: 261
Arduino rocks
|
 |
« Reply #7 on: June 22, 2009, 08:16:38 am » |
got it  2line:  and showing a value (boost):  and showing it with 4line´s:  the code, for the 2lines: ( http://code.google.com/p/multidisplay/source/browse/trunk/work_designer2k2_03/bigfont.pde) //Bigfont Code////BIG parts from http://opengauge.googlecode.com/svn/trunk/mpguino/mpguino.pdevoid 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+leftAdjust*3+1*leftAdjust); //Line1 lcd. print(bn12[digit*3]); lcd. print(bn12[digit*3+1]); lcd. print(bn12[digit*3+2]); // Line 2 of the one-digit number lcd. commandWrite(0xC0+LineOffset+leftAdjust*3+1*leftAdjust); // Line 2 lcd. print(bn22[digit*3]); 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 - ='.';
}else{ fBuff - = '0' + (num % 10);//poke the ascii character for the digit.
num /= 10; } } fBuff[6] = 0; return fBuff; }
|
|
|
|
|
Logged
|
|
|
|
|
Austria
Offline
Sr. Member
Karma: 3
Posts: 261
Arduino rocks
|
 |
« Reply #8 on: June 22, 2009, 08:18:43 am » |
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+leftAdjust*3+1*leftAdjust); //Line 1 lcd.print(bn14[digit*3]); lcd.print(bn14[digit*3+1]); lcd.print(bn14[digit*3+2]);
// Line 2 of the one-digit number lcd.commandWrite(0xC0+leftAdjust*3+1*leftAdjust); // Line 2 lcd.print(bn24[digit*3]); lcd.print(bn24[digit*3+1]); lcd.print(bn24[digit*3+2]);
// Line 3 of the one digit number lcd.commandWrite(0x94+leftAdjust*3+1*leftAdjust); //Line 3 lcd.print(bn34[digit*3]); lcd.print(bn34[digit*3+1]); lcd.print(bn34[digit*3+2]);
// Line 4 of the one-digit number lcd.commandWrite(0xD4+leftAdjust*3+1*leftAdjust); // Line 4 lcd.print(bn44[digit*3]); 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); }
|
|
|
|
« Last Edit: June 22, 2009, 08:46:47 am by designer2k2 »
|
Logged
|
|
|
|
|
0
Offline
Full Member
Karma: 0
Posts: 145
Arduino stones
|
 |
« Reply #9 on: July 01, 2009, 04:21:17 am » |
Where is the declaration for LcdUploadUdef5x8()?
|
|
|
|
|
Logged
|
|
|
|
|
Austria
Offline
Sr. Member
Karma: 3
Posts: 261
Arduino rocks
|
 |
« Reply #10 on: July 01, 2009, 06:10:00 am » |
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]); } } 
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Full Member
Karma: 0
Posts: 145
Arduino stones
|
 |
« Reply #11 on: July 01, 2009, 10:40:48 am » |
Ok, I hate LCD4Bit, here's some code to do it with LiquidCrystal: #include < LiquidCrystal.h> LiquidCrystal lcd(2, 3, 4, 5, 6, 7,  ; 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() {}
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 2
Arduino rocks
|
 |
« Reply #12 on: August 02, 2010, 07:46:37 pm » |
@ whosawhatsis thanks for the code. works wonderfull: Ill maybe adopt it to be a lil bit more round-edged, but just maybe. 
|
|
|
|
« Last Edit: August 02, 2010, 09:51:57 pm by fly3rman »
|
Logged
|
|
|
|
|
Austria
Offline
Sr. Member
Karma: 3
Posts: 261
Arduino rocks
|
 |
« Reply #13 on: August 04, 2010, 03:59:17 am » |
nice!
i testet rounder numbers but they are a lot harder to read, somehow this ones are easier to read :-?
|
|
|
|
|
Logged
|
|
|
|
|
|