Hi, this is my code for writing Text to the oled display.
Controller is ioBroker and so far everything is working, but... I like to place multiple lines to the display using V_VAR1 - V_VAR5. How to use them?
And do i need a ACK Command?
Thanks for you help, sorry this is my first "self made" node.
/**
* The MySensors Arduino library handles the wireless radio link and protocol
* between your home built sensors/actuators and HA controller of choice.
* The sensors forms a self healing radio network with optional repeaters. Each
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
* network topology allowing messages to be routed to nodes.
*
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
* Copyright (C) 2013-2015 Sensnology AB
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
*
* Documentation: http://www.mysensors.org
* Support Forum: http://forum.mysensors.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
*******************************
*
* REVISION HISTORY
* Version 1.1 - Thorsten Böttcher
*
* DESCRIPTION
* Example sketch showing how to send messages to 0,96" OLED Display
*
* ****************************
*
* OLED ARDUINO
* -----1234-----
* | | 1 -> 3,3 V
* | | 2 -> GND
* | | 3 -> A5 SCL
* | | 4 -> A4 SDA
* --------------
*
* OLED ASCII Library from https://github.com/greiman/SSD1306Ascii
*
*/
// Enable debug prints to serial monitor
#define MY_DEBUG
// Enable and select radio type attached
//#define MY_RADIO_NRF24
#define MY_RADIO_RFM69
#include <SPI.h>
#include <MySensors.h>
#define CHILD_ID 0
//oled display
#include "SSD1306Ascii.h"
#include "SSD1306AsciiAvrI2c.h"
#define I2C_ADDRESS 0x3C
SSD1306AsciiAvrI2c oled;
// SketchInfo
static const char SketchName[] ="Info Display";
static const char SketchVersion[] ="1.1";
int PosX = 0;
int PosY = 0;
int ClrScr = 0;
int FontSize = 1;
// loop
static const uint64_t UPDATE_INTERVAL = 60000;
MyMessage msgText (CHILD_ID, V_TEXT); // Text
MyMessage msgVar1 (CHILD_ID, V_VAR1); // Cursor PosX
MyMessage msgVar2 (CHILD_ID, V_VAR2); // Cursor PosY
MyMessage msgVar3 (CHILD_ID, V_VAR3); // Clear Screen
MyMessage msgVar4 (CHILD_ID, V_VAR4); // FontSize
MyMessage msgVar5 (CHILD_ID, V_VAR5); // Not Used
void setup()
{
Serial.println("starting...");
ShowInfo();
}
void presentation() {
// Send the sketch version information to the gateway and Controller
sendSketchInfo(SketchName, SketchVersion);
present(CHILD_ID, S_INFO);
}
void receive(const MyMessage &mymessage)
{
if (mymessage.type==V_TEXT) {
DisplayMessage(mymessage.getString());
}
if (mymessage.type==V_VAR1) {
PosX = atoi(mymessage.getString());
}
if (mymessage.type==V_VAR2) {
PosY = atoi(mymessage.getString());
}
if (mymessage.type==V_VAR3) {
ClrScr=atoi(mymessage.getString());
if ( ClrScr > 0 )
oled.clear();
}
if (mymessage.type==V_VAR4) {
oled.set1X();
FontSize=atoi(mymessage.getString());
if ( FontSize > 1 )
oled.set2X();
}
}
void loop()
{
// Wait, but receive messages
wait(UPDATE_INTERVAL);
}
void ShowInfo()
{
oled.begin(&Adafruit128x64, I2C_ADDRESS);
oled.setFont(Arial14);
oled.setFont(Arial14);
oled.set1X();
oled.setCursor(20,1);
oled.write("* MySensors 2.0 *");
oled.setCursor(30,3);
oled.write(SketchName);
oled.write(" ");
oled.write(SketchVersion);
oled.setCursor(30,5);
oled.write("NodeID");
oled.write(" ");
oled.print(getNodeId());
sleep(3000);
oled.clear();
}
void DisplayMessage(const char Message[])
{
oled.setCursor(PosX,PosY);
oled.clearToEOL ();
oled.write(Message);
}