OK. Finally the i2c LCD adaptor has turned up and I've got it working. I am now programming in C and it's been a steep learning curve.
The pinout actually is:
PCF8574 -- LCD
-----------------
P0 -------- RS
P1 -------- R/W
P2 -------- En
P3 -------- LED on/off
P4 -------- Data pin 4
P5 -------- Data pin 5
P6 -------- Data pin 6
P7 -------- Data pin 7
ErnieM, we were discussing how to send the data to the module, you can simply send the i2c start condition, send the address and then high nibble, with enable high, then again with enable low, then the low nibble. It clocks in on the falling edge of the enable bit. You can keep sending data to it without having to send the stop condition after each byte. It really is a nice bit of gear.
However I'm a little bit stumped on something. I have a real time clock module and the LCD module both running on the i2c bus. I am reading the RTC module and storing the data in raw_seconds, raw_minutes and raw_hours. Each of these variables hold the tens in the high nibble and the units in the low nibble.
If I put them into variables like seconds_tens, second_units, minutes_tens.....etc. and want to display them on the LCD, how can I do this?
Originally I thought I would use my 'lcd_write_chars' function and simply pass it one of the variables with 0x30 added to it to give it the correct ascii code, but the compiler says: illegal conversion of integer to pointer
I Googled how I could achieve what I want and came across 'itoa', but I cant get this to work either. If I do this:
I get the seconds counting up from 0 to 9 etc.
If I try this:
I get 131 displayed and then 10 seconds later I get 232, and another 10 seconds later I get 333 etc.
I know it's something to do with the array, but I'm not sure what to do.
Is there an easier way to do what I want to do?
I thought that writing the program to send the commands over i2c to the LCD adaptor and getting it to toggle the pins correctly was going to be tricky, but it proved to be OK, even in C which I've only been on for a weeks. I never expected it to be so tricky to simply convert a few variables to ascii.
Again, thanks for any help you can give
The pinout actually is:
PCF8574 -- LCD
-----------------
P0 -------- RS
P1 -------- R/W
P2 -------- En
P3 -------- LED on/off
P4 -------- Data pin 4
P5 -------- Data pin 5
P6 -------- Data pin 6
P7 -------- Data pin 7
ErnieM, we were discussing how to send the data to the module, you can simply send the i2c start condition, send the address and then high nibble, with enable high, then again with enable low, then the low nibble. It clocks in on the falling edge of the enable bit. You can keep sending data to it without having to send the stop condition after each byte. It really is a nice bit of gear.
However I'm a little bit stumped on something. I have a real time clock module and the LCD module both running on the i2c bus. I am reading the RTC module and storing the data in raw_seconds, raw_minutes and raw_hours. Each of these variables hold the tens in the high nibble and the units in the low nibble.
If I put them into variables like seconds_tens, second_units, minutes_tens.....etc. and want to display them on the LCD, how can I do this?
Originally I thought I would use my 'lcd_write_chars' function and simply pass it one of the variables with 0x30 added to it to give it the correct ascii code, but the compiler says: illegal conversion of integer to pointer
I Googled how I could achieve what I want and came across 'itoa', but I cant get this to work either. If I do this:
Rich (BB code):
char buf[];
itoa(buf,seconds_units,16);
lcd_wr_chars(buf);
If I try this:
Rich (BB code):
char buf[];
itoa(buf,seconds_tens,16);
lcd_wr_chars(buf);
char buf[];
itoa(buf,seconds_units,16);
lcd_wr_chars(buf);
I know it's something to do with the array, but I'm not sure what to do.
Is there an easier way to do what I want to do?
I thought that writing the program to send the commands over i2c to the LCD adaptor and getting it to toggle the pins correctly was going to be tricky, but it proved to be OK, even in C which I've only been on for a weeks. I never expected it to be so tricky to simply convert a few variables to ascii.
Again, thanks for any help you can give