Hello,
I’m wondering if someone is able to help me resolve Blynk C coding issue with having text scroll across OLED display. It is possible similar approach can be used for Meshtastic message display on device OLED.
What I have is Wemos D1 mini with 128x64 OLED, push button, and active speaker. I’m using Blynk app to activate buzzer connected to D1 mini, Blynk terminal to send text message to OLED connected to D1 mini, and push button is used to acknowledge message is read on OLED (it drives LED in the Blynk app).
This is what the app looks like:
Everything works well if I don’t invoke scrolling text requirement. Once I put in code to scroll text, I’m having trouble compiling this. I don’t know how to properly declare ‘message’ value coming on virtual pin 1. Can someone please take a look and give me a pointer? I tried asking on Blynk forum but there is no bites.
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define BLYNK_MAX_SENDBYTES 256 // Default is 128
#define message V1
bool mssg;
String message;
int x, minX;
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "my token";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "my SSID";
char pass[] = "my password";
// Attach virtual serial terminal to Virtual Pin V1
WidgetTerminal terminal(V1);
// Select your pin with physical button
const int btnPin = 2;
WidgetLED led1(V2);
BlynkTimer timer;
// V2 LED Widget represents the physical button state
boolean btnState = false;
void buttonLedWidget()
{
// Read button
boolean isPressed = (digitalRead(btnPin) == LOW);
// If state has changed...
if (isPressed != btnState) {
if (isPressed) {
led1.on();
} else {
led1.off();
}
btnState = isPressed;
}
}
BLYNK_WRITE(V1)
{
if (String("text") == param.asStr())//Initiate OLED transfer
{
display.clearDisplay();
terminal.println(F("Enter Message"));
mssg=true;
terminal.flush();
}
if(mssg==true&&(String("text") != param.asStr()) )//Prints To OLED
{
display.clearDisplay();
display.setCursor(0,0);
display.print("message");
display.display();
x=x-2; // scroll speed, make more positive to slow down the scroll
if(--x < minX) x= display.width();
mssg=false;
}
//if(--x < minX) x = display.width();
}
void setup()
{
Serial.begin(115200);
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
Serial.println(F("SSD1306 allocation failed"));
for(;;);
}
delay(2000);
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setTextWrap(false);
//display.startscrollleft(0x00, 0x0F);
x = display.width();
minX = -12 * strlen(message); // 12 = 6 pixels/character * text size 2
Blynk.begin(auth, ssid, pass);
// You can also specify server;
//Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
// Clear the terminal content
terminal.clear();
// This will print Blynk Software version to the Terminal Widget when
// your hardware gets connected to Blynk Server
terminal.println(F("Blynk v" BLYNK_VERSION ": Device started"));
terminal.println(F("-------------"));
terminal.println(F("Type your command>"));
terminal.flush();
// Setup physical button pin (active low)
pinMode(btnPin, INPUT_PULLUP);
timer.setInterval(150L, buttonLedWidget);
}
void loop()
{
Blynk.run();
timer.run();
}
This is the error I get when compiling:
exit status 1
invalid conversion from 'int' to 'const char*' [-fpermissive]
On this line:
minX = -12 * strlen(message); // 12 = 6 pixels/character * text size 2
Thanks