Hello, Blynkers!
I’d like to send a text string to a dot matrix display via Terminal Widget, but i can only send 31 cyrillic or 54 english characters (including spaces).
i spent a lot of time on THIS PROJECT, and now half of my idea is about to die, if there are limitations on string length… I’m trying to use this project to ‘page’ my hearing impaired mom using scroll bar, and 31 characters is just… well, nothing…
Is there a way to send more? Let’s say 256?
if my string exceeds the amounts i mentioned, the display remains blank…
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Max72xxPanel.h>
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "xxx";
int pinCS = 16;
int numberOfHorizontalDisplays = 1;
int numberOfVerticalDisplays = 4;
Max72xxPanel matrix = Max72xxPanel(pinCS, numberOfHorizontalDisplays, numberOfVerticalDisplays);
String tape = "";
int wait = 50; // In milliseconds
int spacer = 1; //
int width = 5 + spacer; // The font width is 5 pixels
/* Recode russian fonts from UTF-8 to Windows-1251 */
String utf8rus(String source)
{
int i,k;
String target;
unsigned char n;
char m[2] = { '0', '\0' };
k = source.length(); i = 0;
while (i < k) {
n = source[i]; i++;
if (n >= 0xC0) {
switch (n) {
case 0xD0: {
n = source[i]; i++;
if (n == 0x81) { n = 0xA8; break; }
if (n >= 0x90 && n <= 0xBF) n = n + 0x2F;
break;
}
case 0xD1: {
n = source[i]; i++;
if (n == 0x91) { n = 0xB7; break; }
if (n >= 0x80 && n <= 0x8F) n = n + 0x6F;
break;
}
}
}
m[0] = n; target = target + String(m);
}
return target;
}
String Serial_Read() {
unsigned char c; //
String Serial_string = ""; //
while (Serial.available() > 0) { //
c = Serial.read(); //
//Serial.print(c,HEX); Serial.print(" "); Serial.print(c);
if (c == '\n') { //
return Serial_string; //
}
if (c == 0xB8) c = c - 0x01; //
if (c >= 0xBF && c <= 0xFF) c = c - 0x01;
Serial_string = Serial_string + String(char(c)); //
}
return Serial_string;
}
void setup() {
Serial.begin(9600);
matrix.setIntensity(3); // Use a value between 0 and 15 for brightness
matrix.setRotation(matrix.getRotation()+1); //1 - 90 2 - 180 3 - 270
matrix.fillScreen(LOW);
matrix.write(); // Send bitmap to display
WiFi.persistent(false);
Blynk.begin(auth, "xxx", "xxx");
while (Blynk.connect() == false) {
}
}
BLYNK_WRITE(V12){
if(param.asInt()==1){
tape=utf8rus("Левая конфорка отключена");
}if(param.asInt()==2){
tape=utf8rus("Правая конфорка отключена");
}
}
BLYNK_WRITE(V28){
tape=utf8rus(param.asStr());
}
BLYNK_WRITE(V29){
if(param.asInt()==1){
tape=utf8rus(" ");
//matrix.clear();
}
}
void loop() {
if (Serial.available()){
tape=Serial_Read();
}
for ( int i = 0 ; i < width * tape.length() + matrix.width() - 1 - spacer; i++ )
{
matrix.fillScreen(LOW);
int letter = i / width; //
int x = (matrix.width() - 1) - i % width;
int y = (matrix.height() - 8) / 2; // center the text vertically
while ( x + width - spacer >= 0 && letter >= 0 ) {
if ( letter < tape.length() ) {
matrix.drawChar(x, y, tape[letter], HIGH, LOW,1);
}
letter--;
x -= width;
}
matrix.write(); // Send bitmap to display
delay(wait);
}
Blynk.run();
}