Hello everyone, I am new to imp and squirrel. I am having troubles with using the constants. I will let the code that I post speak.
const _A = 0x77;
const _B = 0xF4;
const _C = 0xE0;
const _D = 0xE6;
const _E = 0xF1;
etc…
Ok these bytes represent a binary value for turning on and off segments of a 7 segment 12 character display to give me a word(s). So I am writing a function to take the words I want to display and send them via spi to the LCD device.
so the call I make is: lcd_write (“LOW BATTERY”);
the function then has to iterate threw the letters in reverse (property of LCD).
function lcd_write( pcBuffer ) {// initilize the lcd
init_lcd();// Derive the number of characters to be displayed
// so that the proper position can be determined.
// Remember that the LCD starts at the right hand side,
// but our data position is from the left hand side.nChars = strlen( pcBuffer );
// The order of the digits must be reversed going in
jj = nChars - 1; // access the last digit
for ( ii=0; ii<nChars; ++ii )
{
ucChar = “_”+pcBuffer[jj]; << ------ this is the trouble line
spi.write(ucChar);
–jj;
}CS.write(0); // set CS pin to low display content
}
I need to reference the constants that have the byte value. so if the letter “A” is encountered I have to reference the constant “_A” to give me the byte 0x77. Not sure how to do this.
Any help would be appreciated.
Thanks
Brad