I started playing with the LCD shield that I ordered and overall it is working fine. I've set it up to do the following:
When ascii code 2 is read in, clear the display, set the cursor to 16,0
Now for each ascii code read in write that character to the display
Once ascii code 3 is read in stop writing output to the display and now wait for code 2 to come in again
The text starts working as expected. characters are written to the top right area and with each new character written they scroll to the left. The problem I'm seeing is that at character 24 the character suddenly appears at the right column, but on the next row. so you'd get something like this:
32F and cloudy in Milfor
d.
imagine it all scrolling appropriately. I've tried different strings etc and they all exhibit the same behavior.
here's the code:
#define USB_CFG_DEVICE_NAME 'D','i','g','i','B','l','i','n','k'
#define USB_CFG_DEVICE_NAME_LEN 9
#include
#include // I2C Master lib for ATTinys which use USI - comment this out to use with standard arduinos
#include // for LCD w/ GPIO MODIFIED for the ATtiny85
#define GPIO_ADDR 0x27 // (PCA8574A A0-A2 @5V) typ. A0-A3 Gnd 0x20 / 0x38 for A - 0x27 is the address of the Digispark LCD modules.
LiquidCrystal_I2C lcd(GPIO_ADDR,16,2); // set address & 16 chars / 2 lines
byte in = 0;
int readIn = 0;
String data = "";
char cIn = ' ';
void setup(){
TinyWireM.begin(); // initialize I2C lib - comment this out to use with standard arduinos
DigiUSB.begin();
lcd.init(); // initialize the lcd
lcd.begin(16,2);
lcd.backlight(); // Print a message to the LCD.
lcd.print("Digispark!");
lcd.rightToLeft();
lcd.autoscroll();
}
void loop(){
DigiUSB.refresh();
if ( DigiUSB.available() > 0 ){
in = 0;
in = DigiUSB.read();
// We use the '#002' to signify new input and we read until we find the '#003' character which represents end of input.
if ( in == 2 && readIn == 0) {
readIn = 1;
lcd.clear();
lcd.setCursor(16,0);
}
else if ( in == 3 && readIn == 1) {
readIn = 0;
}
else
{
if ( readIn == 1 ){
cIn = in;
lcd.write(cIn);
}
}
}
}