help.. 16x2 custom chracters... :(

here

I can create my own character..

But how do I convert the full result into decimal...???

for example from that link i posted one full block is 31,31,31,31,31,31,31,31
whereas in decimal 255 = one full block..

I would like to print in this way.. lcd.print((char)255)

so I want to convert my custom character into decimal like 255..
How do I do it...??

I am asking about all these because I would like to modify the custom characters here..

byte bignums[10][2][3] = {
// Define which characters to use for each number. 255 is a solid block; 254 is a space  
// The format is { {TopLeft, TopMiddle, TopRight}, {BottomLeft, BottomMiddle, BottomRight} }
 { {255, 0, 255}, {255, 1, 255} },	  // data to display "0"
 { {0, 255, 254}, {1, 255, 1} },	    // data to display "1"
 { {2, 2, 255}, {255, 1, 1} },		// data to display "2"
 { {0, 2, 255}, {1, 1, 255} },		// data to display "3"
 { {255, 1, 255}, {254, 254, 255} },	// data to display "4"
 { {255, 2, 2}, {1, 1, 255} },		// data to display "5"
 { {255, 2, 2}, {255, 1, 255} },	    // data to display "6"
 { {0, 0, 255}, {254, 255, 254} },	  // data to display "7"
 { {255, 2, 255}, {255, 1, 255} },	  // data to display "8"
 { {255, 2, 255}, {254, 254, 255} }	 // data to display "9"
};

Please help me in converting my custom characters to decimals...

But how do I convert the full result into decimal...???

In the long run you really would be better off learning how to deal with binary numbers and their hexadecimal equivalents.

If a value is derived from a bitmap (such as custom characters) then binary is the appropriate radix to use. If you express the values in decimal then anyone trying to help you with a problem is going to have to convert your decimal values back to binary in order to analyze them.

When you make unnecessary conversions from one radix to another you are just introducing the possibility of making an error. The absolute very best that you can hope for is to get he conversion done correctly.

Go back to your link and look at the values for the upper left character (the 'A'). Now take the results and arrange them in columns, like this:

    14    0x0E    00001110
    27    0x1B    00011011
    27    0x1B    00011011
    31    0x1F    00011111
    27    0x1B    00011011
    27    0x1B    00011011
    27    0x1B    00011011

There is no relationship between either the decimal numbers or the hex numbers to the character 'A', but if you look carefully at the binary numbers you will see that the '1's correspond to the dark boxes and the '0's correspond to the blank boxes. You can even see the 'A' if you eliminate the '0's and spread things out a bit.

    1 1 1
  1 1   1 1
  1 1   1 1
  1 1 1 1 1
  1 1   1 1
  1 1   1 1
  1 1   1 1

To answer your question - Try searching for a 'scientific calculator', either a real one or a program for your computer. Most of them can do the conversions for you. For a chart that may help follow the link for the Decimal - Binary - Octal - Hex - ASCII Conversion Chart at http://web.alfredstate.edu/weimandn.

Don

I just spotted what I think may be a misconception in your original post:

for example from that link i posted one full block is 31,31,31,31,31,31,31,31
whereas in decimal 255 = one full block..

If you look in the data sheet for the LCD controller you will find a chart of the ROM Characters. Each of these predefined characters is expressed by a numerical code and many of those codes (but not the one for a block) are the same as the ASCII codes. That is where the number 255 in the quote above comes from. The decimal number 255 is expressed as 11111111 in binary, and this is the in lower right corner of the chart.

There really is no reason to construct a 'custom character' for a block since a predefined one already exists but in order to do so you would need the following:

binary hex decimal
00011111 0x1F 31
00011111 0x1F 31
00011111 0x1F 31
00011111 0x1F 31
00011111 0x1F 31
00011111 0x1F 31

Don

The main thing what I am trying to do is make some modifications of the fonts in the code here..

byte bignums[10][2][3] = {
// Define which characters to use for each number. 255 is a solid block; 254 is a space  
// The format is { {TopLeft, TopMiddle, TopRight}, {BottomLeft, BottomMiddle, BottomRight} }
 { {255, 0, 255}, {255, 1, 255} },	  // data to display "0"
 { {0, 255, 254}, {1, 255, 1} },	    // data to display "1"
 { {2, 2, 255}, {255, 1, 1} },		// data to display "2"
 { {0, 2, 255}, {1, 1, 255} },		// data to display "3"
 { {255, 1, 255}, {254, 254, 255} },	// data to display "4"
 { {255, 2, 2}, {1, 1, 255} },		// data to display "5"
 { {255, 2, 2}, {255, 1, 255} },	    // data to display "6"
 { {0, 0, 255}, {254, 255, 254} },	  // data to display "7"
 { {255, 2, 255}, {255, 1, 255} },	  // data to display "8"
 { {255, 2, 255}, {254, 254, 255} }	 // data to display "9"
};

Now for example I would like to cut the corners of a zero

here is the upper right corner block of the zero how I want it to be..

which has a decimal value 28,30,31,31,31,31,31

now how do I convert this decimal value to a decimal or hex to fit in my code and replace the upper right corner block 255 here
{ {255, 0, 255}, {255, 1, 255} }, // data to display "0"

now how do I convert this decimal value to a single decimal or hex to fit in my code and replace the upper right corner block 255 here

You don't. In broad terms what you have to do is use lcd.createChar() to store the bit codes ('data') and use the address at which you stored them ('num') as the single value to fit in your code. I haven't done this using the LiquidCrystal library so I can't give you the step by step procedure.

Don

Then how do I replace those blocks with my modified blocks...??? :frowning:

Floresta gave you a very good explanation of what's going on here. You should study its posts and ask for clarifications about any particular you don't fully understand. Meanwhile, please have a look at LiquidCrystal - Arduino Reference where a code example is given.

I can't get it to work for me either.

I have the following before set up:

byte frost[8] = {
  B01010,
  B00100,
  B10101,
  B01110,
  B10101,
  B00100,
  B01010,
};

and the following in set up:

lcd.createChar(0, frost);

and finally In the loop:

lcd.write(0);

Im getting the following error when compiling:

LDR_PWM_LED_WITH_TEMP_v3_begin_move_temp_select_custom_char.cpp: In function 'void loop()':
LDR_PWM_LED_WITH_TEMP_v3_begin_move_temp_select_custom_char:202: error: call of overloaded 'write(int)' is ambiguous
K:\Arduino\arduino-1.0\libraries\LiquidCrystal/LiquidCrystal.h:82: note: candidates are: virtual size_t LiquidCrystal::write(uint8_t)
K:\Arduino\arduino-1.0\hardware\arduino\cores\arduino/Print.h:49: note: size_t Print::write(const char*)

So all the numbers here are pre defined numbers...??
and hence no modifications can be done in here...??

byte bignums[10][2][3] = {
// Define which characters to use for each number. 255 is a solid block; 254 is a space  
// The format is { {TopLeft, TopMiddle, TopRight}, {BottomLeft, BottomMiddle, BottomRight} }
 { {255, 0, 255}, {255, 1, 255} },	  // data to display "0"
 { {0, 255, 254}, {1, 255, 1} },	    // data to display "1"
 { {2, 2, 255}, {255, 1, 1} },		// data to display "2"
 { {0, 2, 255}, {1, 1, 255} },		// data to display "3"
 { {255, 1, 255}, {254, 254, 255} },	// data to display "4"
 { {255, 2, 2}, {1, 1, 255} },		// data to display "5"
 { {255, 2, 2}, {255, 1, 255} },	    // data to display "6"
 { {0, 0, 255}, {254, 255, 254} },	  // data to display "7"
 { {255, 2, 255}, {255, 1, 255} },	  // data to display "8"
 { {255, 2, 255}, {254, 254, 255} }	 // data to display "9"
};

So all the numbers here are pre defined numbers...??
and hence no modifications can be done in here...??

No and No.

From reply #2:

If a value is derived from a bitmap (such as custom characters) then binary is the appropriate radix to use. If you express the values in decimal then anyone trying to help you with a problem is going to have to convert your decimal values back to binary in order to analyze them.

Convert those decimal numbers back to binary and see where they show up on the chart of ROM characters. The ones in the left hand column are the 'custom characters' and they can be modified. The ones in any of the other columns are pre defined characters (I think this is what you mean by pre defined numbers) and they cannot be modified.

Don

lcd.write(0);

Im getting the following error when compiling:

LDR_PWM_LED_WITH_TEMP_v3_begin_move_temp_select_custom_char.cpp: In function 'void loop()':
LDR_PWM_LED_WITH_TEMP_v3_begin_move_temp_select_custom_char:202: error: call of overloaded 'write(int)' is ambiguous
K:\Arduino\arduino-1.0\libraries\LiquidCrystal/LiquidCrystal.h:82: note: candidates are: virtual size_t LiquidCrystal::write(uint8_t)
K:\Arduino\arduino-1.0\hardware\arduino\cores\arduino/Print.h:49: note: size_t Print::write(const char*)

Perhaps

lcd.write((byte)0);

Convert those decimal numbers back to binary and see where they show up on the chart of ROM characters. The ones in the left hand column are the 'custom characters' and they can be modified. The ones in any of the other columns are pre defined characters (I think this is what you mean by pre defined numbers) and they cannot be modified.

I am not getting properly..

{ {255, 0, 255}, {255, 1, 255} }, // data to display "0"
this prints the zero 0 in this way

Please show me with an example that with what numbers will I have to replace 255 to print the zero 0 in this way

Those numbers inside braces seem to be indexes into a predefined character set...

Also, you keep posting the same code over and over... where did you get that from ? Can you post the whole code ?

tuxduino:
Those numbers inside braces seem to be indexes into a predefined character set...

Also, you keep posting the same code over and over... where did you get that from ? Can you post the whole code ?

I got the code for big numbers from here...

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1293959726/all

Read this thread carefully, and you should be able to understand how the whole thing works:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1245352653

So 255 is an LCD predefined character which has all the pixel set (i.e. black). Small numbers, like 1 and 2, identify custom characters (there can be 8, numbered from 0 to 7). To print a bigchar, you think in terms of groups of 2x2 cells or 3x2 cells.

So back to your last question, you have to define at least 4 custom chars to represent the corners of the rounded zero. Then you have to look at the LCD predefined charset if there are already the top and bottom symbols. If not, you have to define them too. Then you substitute the numbers in the code you posted with the indexes of the custom chars you just defined.

HTH

Then you substitute the numbers in the code you posted with the indexes of the custom chars you just defined

Will you please show me with one small example... ??

I think you should be able to expand this example to suit your needs...

// bignum lcd

#include <LiquidCrystal.h>

#define ARY_LEN(a) (sizeof(a)/sizeof(a[0]))


// nuelectronics lcd+keypad shield has 5x8 px cells
byte customChars[][8] = {
    {
        B11111111,
        B11111111,
        B11111111,
        B00000000,
        B00000000,
        B00000000,
        B00000000,
        B00000000
    },
    {
        B00000000,
        B00000000,
        B00000000,
        B00000000,
        B00000000,
        B11111111,
        B11111111,
        B11111111
    }
};

const unsigned short NUM_CUSTOM_CHARS = ARY_LEN(customChars);


#define BRICK 255    // lcd char with all pixels black

unsigned short bigNum[][6] = {
    { BRICK, 0, BRICK, BRICK, 1, BRICK }
};



LiquidCrystal lcd(8, 9, 4, 5, 6, 7);    // lcd pins for nuelectronics lcd+keypad shield
const unsigned short LCD_ROWS = 2;
const unsigned short LCD_COLS = 16;


// uses global variable "customChars" and global variable "lcd"
void lcdSetCustomChars() {
    unsigned short i;

    for (i = 0; i < NUM_CUSTOM_CHARS; i++) {
        lcd.createChar(i, customChars[i]);
    }
}


// prints the "big" cypher n starting from column col
void lcdPrintBigNum(unsigned short n, unsigned short col) {
    unsigned short i;
    
    if (n > 9) {                // silently ignore invalid requests
        return;
    }
    
    lcd.setCursor(col, 0);
    for (i = 0; i < 3; i++) {
        lcd.write((byte)bigNum[n][i]);
    }
    lcd.setCursor(col, 1);
    for (i = 0; i < 3; i++) {
        lcd.write((byte)bigNum[n][i+3]);
    }
}


void lcdShowCustomChars() {
    unsigned short i;
    
    lcd.clear();
    lcd.print("Num c.c.: ");
    lcd.print(NUM_CUSTOM_CHARS);
    lcd.setCursor(0, 1);
    for (i = 0; i < NUM_CUSTOM_CHARS; i++) {
        lcd.write((byte)i);
    }
}


void setup() {
    Serial.begin(9600);
    lcd.begin(LCD_COLS, LCD_ROWS);
    lcdSetCustomChars();
    lcdShowCustomChars();
    delay(3000);
}


void loop() {
    lcd.clear();
    lcd.print(millis(), DEC);
    delay(1000);
    lcd.clear();
    lcdPrintBigNum(0, 0);
    delay(1000);
}

Joy:
I hope you understand that there are only eight memory locations available to store custom characters. By the time you get done with your nicely shaped '0' you will have used six of them. That leaves two additional custom characters to fix up the other nine digits. That is the reason that the 'big' fonts look so awful, they have to reuse as many of the custom characters as possible even if they don't look too nice.

Don

I was wondering how feasible it would be to dynamically redefine some custom chars "at runtime", i.e. not just at the start of a program, but "as need arises". Probably not worth the effort (graphics lcds are the way to go to get bignums that look "nice"), but still an idea...