Go Down

Topic: Print degree symbol ° on LCD (Read 199377 times) previous topic - next topic

anachrocomputer

The calls to 'defChar' take three arguments, the 'lcd' object, an ASCII code and an array of pixels.  The ASCII code specifies which of the user-defined characters we want to redefine (there are eight of them). Then the array of pixels specifies which pixels are lit (ones) and un-lit (zeroes).

flyboy

#16
Apr 28, 2009, 03:06 am Last Edit: Apr 28, 2009, 03:34 pm by flyboy Reason: 1
A strange thing to note that I followed the same format and could only get the first array to print when I called it by name.  In my case, it was called up_arrow and down_arrow.  The second array, named down_arrow, would not print, only up_arrow.  When I called the memory location (0x01), it printed just fine.

Here is my code from void setup:

Code: [Select]
void setup
static unsigned char up_arrow[8] = {0x04, 0x0E, 0x15, 0x04, 0x04, 0x04, 0x04, 0x00};
static unsigned char down_arrow[8] = {0x00, 0x04, 0x04, 0x04, 0x04, 0x15, 0x0E, 0x04};

lcd.clear();

defChar (lcd, 0x00, up_arrow);
defChar (lcd, 0x01, down_arrow);

void DRAW_UP_ARROW()
   {
     int up_arrow;
     lcd.write(up_arrow);
   }
   

void DRAW_DOWN_ARROW()
   {
     int down_arrow;
     lcd.write(down_arrow);
   }


When I call DRAW_UP_ARROW, it will print the up arrow.  When I call DRAW_DOWN_ARROW, it prints an up arrow.  If I tell it lcd.write(0x01) instead, it will then print a down arrow.  Any ideas?

flyboy

I was able to make it work correctly by changing the code a little.  I'm still not sure why it wouldn't work without equating the variable to a value, but it did the trick nonetheless.

Code: [Select]
void DRAW_UP_ARROW()
   {
     int up_arrow = 0x00;
     lcd.write(up_arrow);
   }
   

void DRAW_DOWN_ARROW()
   {
     int down_arrow = 0x01;
     lcd.write(down_arrow);
   }

anachrocomputer

In your original code, up_arrow and down_arrow are local variables that have the same name as the static arrays (presumably within the 'setup' function, but you have omitted some of the code there it seems).  That is, they only exist within the function(s).  They are unitialised, which means they have no defined value.  In your second version, you've fixed that by initialising them to 0x00 and 0x01.  If you want to keep consistent names throughout your code, you could try:

Code: [Select]
const int UP_ARROW = 0x00;
const int DOWN_ARROW = 0x01;

void setup ()
{
static unsigned char up_arrow[8] = {0x04, 0x0E, 0x15, 0x04, 0x04, 0x04, 0x04, 0x00};
static unsigned char down_arrow[8] = {0x00, 0x04, 0x04, 0x04, 0x04, 0x15, 0x0E, 0x04};

...

defChar (lcd, UP_ARROW, up_arrow);
defChar (lcd, DOWN_ARROW, down_arrow);

...
}

void DrawUpArrow()
{
    lcd.write (UP_ARROW);
}

void DrawDownArrow()
{
    lcd.write (DOWN_ARROW);
}

BetterSense

#19
Aug 05, 2010, 11:36 pm Last Edit: Aug 05, 2010, 11:38 pm by BetterSense Reason: 1

Quote
[ch12450][ch12523][ch12485][ch12452][ch12494] (a ru du i no)



what you have there is actually (a ru dzu i no). Is that actually what what actual japanese people say for "arduino"? I would google it but I can't do japanese typing at work. There really is no 'du' in japanese.  

Go Up