sparkfun / OpenLCD

An open source serial LCD (HD44780) controller based on the ATmega328.
Other
32 stars 16 forks source link

Turning off system messages #19

Closed jamesraylittle closed 5 years ago

jamesraylittle commented 5 years ago

I cannot find anywhere in the documentation on how to turn off system messages. I have also dig through the code a bit and at a glance it does not look like a command of that nature exists.

When using the example code below:

  Wire.beginTransmission(LCD_1_ADDR); // transmit to device   
  Wire.write('|');
  Wire.write(128);
  Wire.write('|'); 
  Wire.write(187);
  Wire.write('|'); 
  Wire.write(188);
  Wire.endTransmission(); //Stop I2C transmission

This will then display three separate messages on the LCD.

nseidle commented 5 years ago

You can turn on/off the splash screen. Are you're asking how to turn off messages like the "Contrast Set" and "New TWI: 0x52" and what not? There is not currently a way but it is a reasonable feature request.

jamesraylittle commented 5 years ago

Correct,

The system messages that happen after updating a value for a setting, such as Contrast Set...

nseidle commented 5 years ago

Should be easy enough to implement. Have you been able to update the firmware on your SerLCD? It will be a while before we get this feature rolled out onto stock units.

nseidle commented 5 years ago

Lots of changes but this commit should allow for disable/enable of system messages. If you have the chance, please try it on your hardware.

Attached is HEX file that should be loadable on your display.

OpenLCD.ino.arduino_standard.zip

jamesraylittle commented 5 years ago

I have not tried updating the LCD firmware, but after reading the instructions, it seems easy enough.

I will report back.

jamesraylittle commented 5 years ago

I had a bit of trouble updating the firmware, I had to move over to a windows machine to get the Fast LCD library to compile. I wasn't 100% sure on just uploading a the hex file using avrdude, I was getting a lot of timeouts and documentation is lacking in that area.

I looked at the last commit and I noticed this in the file OpenLCD.ino starting at line 242

//Enable or disable the displaying of system messages
    else if (incoming == 46) //. character

I made the assumption that system messages are left on by default.

Here is my test program:


#include <Wire.h>

#define DISPLAY_ADDRESS1 0x72 //This is the default address of the OpenLCD

int _calculateValue(int value, int minValue, int maxValue) {
  return minValue + round( (value / 100.0) * (maxValue - minValue));
}

void setBackground(int red, int green, int blue) {
  /*
  / 128-157 / 0x80-0x9D - Set the primary backlight brightness. 128 = Off, 157 = 100%.
  / 158-187 / 0x9E-0xBB - Set the green backlight brightness. 158 = Off, 187 = 100%.
  / 188-217 / 0xBC-0xD9 - Set the blue backlight brightness. 188 = Off, 217 = 100%.
  */
  int redValue = _calculateValue(red, 128, 157);
  int greenValue = _calculateValue(green, 158, 187);
  int blueValue = _calculateValue(blue, 188, 217);

  Wire.beginTransmission(DISPLAY_ADDRESS1);
  Wire.write('|');
  Wire.write(redValue);
  Wire.write('|');
  Wire.write(greenValue);
  Wire.write('|');
  Wire.write(blueValue);
  Wire.endTransmission();
}

void setup() {
  Wire.begin(); //Join the bus as master

  //By default .begin() will set I2C SCL to Standard Speed mode of 100kHz
  Wire.setClock(400000); //Optional - set I2C SCL to High Speed Mode of 400kHz

  Serial.begin(9600); //Start serial communication at 9600 for debug statements

  //Send the reset command to the display - this forces the cursor to return to the beginning of the display
  Wire.beginTransmission(DISPLAY_ADDRESS1);
  Wire.write('|'); //Put LCD into setting mode
  Wire.write('-'); //Send clear display command
  Wire.write('|'); //setting mode
  Wire.write(46); // disable system messages
  Wire.endTransmission();

  setBackground(0, 0, 0);

  delay(2000);
}

void loop() {
  //red
  setBackground(100, 0, 0);
  delay(10000);

  //green
  setBackground(0, 100, 0);
  delay(10000);

  //blue
  setBackground(0, 0, 100);
  delay(10000);
}

I do see a system message that does say System Messages ON

Removing the two lines from setup

  //Wire.write('|'); //setting mode
  //Wire.write(46); // disable system messages

I no longer see the message System Settings: ON, but I still see system messages.

nseidle commented 5 years ago

My bad. I thought the compiler would toggle the bool correctly. It doesn't.

New code pushed. All tested and shiny. Hex is attached (for your convenience). I've also updated the SerLCD library to support the enable/disable commands, added examples as well.

I also added discrete enableSplash() / disableSplash() commands while I was in there.

OpenLCD.ino.arduino_standard.zip

Please reopen if you have any other issues.