@NiklasO
Here is it.
// Enable debug prints to serial monitor
//#define MY_DEBUG
//#define MY_NODE_ID 200
#define MY_SENSOR_ID 1
// Enable and select radio type attached
#define MY_RADIO_NRF24
//#define MY_RADIO_RFM69
// Enable repeater functionality for this node
#define MY_REPEATER_FEATURE
// LCD includes
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// MYS includes
#include <SPI.h>
#include <MySensors.h>
#define LCD_ON 1 // GPIO value to write to turn on attached relay
#define LCD_OFF 0 // GPIO value to write to turn off attached relay
LiquidCrystal_I2C lcd(0x3f, 20, 4); //0x3f is the LCD address.
String LINE_BLANK = " ";
void before() {
}
void setup() {
// Set off LCD module
lcd.begin ();
lcd.backlight();
lcd.setCursor(0, 0); //
lcd.print("Ready!"); // We expect the controller to remove this from display.
}
void presentation()
{
// Send the sketch version information to the gateway and Controller
sendSketchInfo("LCD Display", "1.0");
present(MY_SENSOR_ID, S_INFO);
}
void loop()
{
// extra processing if required.
}
void receive(const MyMessage &message) {
// We only expect one type of message from controller. But we better check anyway.
if (message.type == V_STATUS) {
// Use V_STATUS to turn on/off the LCD display
// if supported by LCD.
}
// temp string, probably don't need this.
if (message.type == V_VAR1) {
writeScreen(0, message.data);
}
if (message.type == V_VAR2) {
writeScreen(1, message.data);
}
if (message.type == V_VAR3) {
writeScreen(2, message.data);
}
if (message.type == V_VAR4) {
writeScreen(3, message.data);
}
}
void writeScreen(int line, String text)
{
// Trim whitespace from incoming text.
text.trim();
// Remove anything over 20 char in text.
if(text.length() > 19)
{
text.remove(20);
}
// Clear the line
lcd.setCursor(0, line);
lcd.print(LINE_BLANK);
// Set Line
lcd.setCursor(0, line);
lcd.print(text);
}