Uno rev4 wifi telegram e matrix

Buonasera,
Sto cercando di "pasticciare" con uno r4 wifi.
Lo scopo e' creare un codice che riceva una stringa di testo su telegram e lo mostri sulla matrix led.
Lo scorrimento della stringa e' gia stato realizzato da Clemens Valens, Elektor e funziona molto bene
Non riesco pero' a realizzare la parte telegram, i vari esempi presenti su ide non funzionano.

Qualcuno ha gia' realizzato qualcosa?

Steve

Nessuno? sto provando tutte le librerie ma senza risultati.... :frowning:

... librerie che, magari, al momento NON supportano una scheda rilasciata da pochi giorni!

Guglielmo

Gia'.. Speravo che qualcuno ci stesse guardando e magari trovare assieme un workaround per ora...

Sperimento...

Che libreria stai usando?

Se ti va di provare questa libreria, posso darti un supporto diretto anche se solo per eventuali errori di compilazione perché purtroppo non ho a disposizione un Uno R4

Ciao cotestant,
In primis grazie per la disponibilità.

Ho provato tutti gli esempi disponibili, l'ultimo test proprio con asynctelegram2.

con questo parte di codice preso dall'esempio per Asynctelegram2 ho gia' errori.

/*
  Name:        OTA_password.ino
  Created:     29/03/2021
  Author:      Tolentino Cotesta <cotestatnt@yahoo.com>
  Description: an example that check for incoming messages and install update remotely.
*/

#include <AsyncTelegram2.h>
#ifndef LED_BUILTIN
#define LED_BUILTIN 2
#endif

// Timezone definition
#define MYTZ "CET-1CEST,M3.5.0,M10.5.0/3"
#include <time.h>

#ifdef ESP8266
#include <ESP8266WiFi.h>
  #include <ESP8266HTTPClient.h>
  #include <ESP8266httpUpdate.h>  
  #define UPDATER ESPhttpUpdate
  Session   session;
  X509List  certificate(telegram_cert);
#elif defined(ESP32)
  #include <HTTPClient.h>
  #include <HTTPUpdate.h>  
  #define UPDATER httpUpdate
#endif
const char* ssid  =  "xxx";     // SSID WiFi network
const char* pass  =  "yyy";     // Password  WiFi network
const char* token =  "zzz";
WiFiClientSecure client;
AsyncTelegram2 myBot(client);
------------------------

Ottengo questo errore:

'WiFiClientSecure' does not name a type WiFiClientSecure client;

puoi simularlo sceglendo la scheda arduino wi r4 e compilando il sorgente...
Se riesci a trovare l'inghippo procediamo con il resto....

Perdonami, ma stai usando un esempio che è scritto appositamente per microcontrollori ESP32 o ESP8266, è normale che non funzioni.

Devi prendere spunto dagli esempi specifici per Arduino Uno R4 per quanto riguarda le connessioni SSL e poi adattare lo sketch.

Comunque appena ho un minuto provo ad imbastire un esempio con quella board che almeno riesca a compilare correttamente cosi magari lo puoi provare e confermare su funziona o meno.

Ho fatto prima del previsto...

Allora, partendo dall'esempio incluso per il micro Arduino Uno R4 WiFi
WiFiWebClientSSL.ino

ho ottenuto questo codice che compila correttamente.
La libreria in questione funziona senza problemi con i moduli WiFiNINA che di base sono degli ESP32, quindi mi aspetto che funzioni anche con l'ESP32-S3 installato sulla R4.

N.B.
Come c'è indicato chiaramente nell'esempio in questione, per poter funzionare è necessario caricare il certificato SSL del server Telegram.

Con i moduli WiFiNINA io ho sempre usato il tool incluso nell'IDE 2.0.x "Upload SSL Root Certficates", ma non ho idea se hanno aggiunto il supporto anche per la R4,

/*
  TLS WiFi Web client

  Remeber to update the CA certificates using CertificateUploader sketch
  before using this sketch.

*/

#include "WiFiS3.h"
#include "WiFiSSLClient.h"
#include "IPAddress.h"

#include "arduino_secrets.h" 
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
char ssid[] = SECRET_SSID;        // your network SSID (name)
char pass[] = SECRET_PASS;        // your network password (use for WPA, or use as key for WEP)
int status = WL_IDLE_STATUS;

/*
  Name:        keyboards.ino
  Created:     05/03/2022
  Author:      Tolentino Cotesta <cotestatnt@yahoo.com>
  Description: a more complex example that do:
             1) if a "/inline_keyboard" text message is received, show the inline custom keyboard,
                if a "/reply_keyboard" text message is received, show the reply custom keyboard,
                otherwise reply the sender with "Try /reply_keyboard or /inline_keyboard" message
             2) if "LIGHT ON" inline keyboard button is pressed turn on the LED and show a message
             3) if "LIGHT OFF" inline keyboard button is pressed, turn off the LED and show a message
             4) if "GitHub" inline keyboard button is pressed,
                open a browser window with URL "https://github.com/cotestatnt/AsyncTelegram"
*/
#include <AsyncTelegram2.h>

// Timezone definition
#include <time.h>
#define MYTZ "CET-1CEST,M3.5.0,M10.5.0/3"


WiFiSSLClient client;
AsyncTelegram2 myBot(client);
const char* token =  "xxxxxxxxxxxx";  // Telegram token

// Check the userid with the help of bot @JsonDumpBot or @getidsbot (work also with groups)
// https://t.me/JsonDumpBot  or  https://t.me/getidsbot
int64_t userid = 123456789;

ReplyKeyboard myReplyKbd;   // reply keyboard object helper
InlineKeyboard myInlineKbd; // inline keyboard object helper
bool isKeyboardActive;      // store if the reply keyboard is shown

#define LIGHT_ON_CALLBACK  "lightON"  // callback data sent when "LIGHT ON" button is pressed
#define LIGHT_OFF_CALLBACK "lightOFF" // callback data sent when "LIGHT OFF" button is pressed
const uint8_t LED = LED_BLUE;

/* -------------------------------------------------------------------------- */
void setup() {
/* -------------------------------------------------------------------------- */  
  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(LED, OUTPUT);
  //Initialize serial and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  
  // check for the WiFi module:
  if (WiFi.status() == WL_NO_MODULE) {
    Serial.println("Communication with WiFi module failed!");
    // don't continue
    while (true);
  }
  
  String fv = WiFi.firmwareVersion();
  if (fv < WIFI_FIRMWARE_LATEST_VERSION) {
    Serial.println("Please upgrade the firmware");
  }
  
  // attempt to connect to WiFi network:
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network.
    status = WiFi.begin(ssid, pass);     
    // wait 10 seconds for connection:
    delay(10000);
  }

  // Set the Telegram bot properties
  myBot.setUpdateTime(1000);
  myBot.setTelegramToken(token);

  // Check if all things are ok
  Serial.print("\nTest Telegram connection... ");
  myBot.begin() ? Serial.println("OK") : Serial.println("NOK");
  Serial.print("Bot name: @");
  Serial.println(myBot.getBotName());

  // Add reply keyboard
  isKeyboardActive = false;
  // add a button that send a message with "Simple button" text
  myReplyKbd.addButton("Button1");
  myReplyKbd.addButton("Button2");
  myReplyKbd.addButton("Button3");
  // add a new empty button row
  myReplyKbd.addRow();
  // add another button that send the user position (location)
  myReplyKbd.addButton("Send Location", KeyboardButtonLocation);
  // add another button that send the user contact
  myReplyKbd.addButton("Send contact", KeyboardButtonContact);
  // add a new empty button row
  myReplyKbd.addRow();
  // add a button that send a message with "Hide replyKeyboard" text
  // (it will be used to hide the reply keyboard)
  myReplyKbd.addButton("/hide_keyboard");
  // resize the keyboard to fit only the needed space
  myReplyKbd.enableResize();

  // Add sample inline keyboard
  myInlineKbd.addButton("ON", LIGHT_ON_CALLBACK, KeyboardButtonQuery);
  myInlineKbd.addButton("OFF", LIGHT_OFF_CALLBACK, KeyboardButtonQuery);
  myInlineKbd.addRow();
  myInlineKbd.addButton("GitHub", "https://github.com/cotestatnt/AsyncTelegram2/", KeyboardButtonURL);

  char welcome_msg[128];
  snprintf(welcome_msg, 128, "BOT @%s online\n/help all commands avalaible.", myBot.getBotName());

  // Send a message to specific user who has started your bot
  myBot.sendTo(userid, welcome_msg);
}


/* -------------------------------------------------------------------------- */
void loop() {
/* -------------------------------------------------------------------------- */  
  // In the meantime LED_BUILTIN will blink with a fixed frequency
  // to evaluate async and non-blocking working of library
  static uint32_t ledTime = millis();
  if (millis() - ledTime > 200) {
    ledTime = millis();
    digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
  }

  // if there is an incoming message...
  // local variable to store telegram message data
  TBMessage msg;
  if (myBot.getNewMessage(msg)) {
    // check what kind of message I received
    MessageType msgType = msg.messageType;
    String msgText = msg.text;

    switch (msgType) {
      case MessageText :
        // received a text message
        Serial.print("\nText message received: ");
        Serial.println(msgText);

        // check if is show keyboard command
        if (msgText.equalsIgnoreCase("/reply_keyboard")) {
          // the user is asking to show the reply keyboard --> show it
          myBot.sendMessage(msg, "This is reply keyboard:", myReplyKbd);
          isKeyboardActive = true;
        }
        else if (msgText.equalsIgnoreCase("/inline_keyboard")) {
          myBot.sendMessage(msg, "This is inline keyboard:", myInlineKbd);
        }

        // check if the reply keyboard is active
        else if (isKeyboardActive) {
          // is active -> manage the text messages sent by pressing the reply keyboard buttons
          if (msgText.equalsIgnoreCase("/hide_keyboard")) {
            // sent the "hide keyboard" message --> hide the reply keyboard
            myBot.removeReplyKeyboard(msg, "Reply keyboard removed");
            isKeyboardActive = false;
          } else {
            // print every others messages received
            myBot.sendMessage(msg, msg.text);
          }
        }

        // the user write anything else and the reply keyboard is not active --> show a hint message
        else {
          myBot.sendMessage(msg, "Try /reply_keyboard or /inline_keyboard");
        }
        break;

      case MessageQuery:
        // received a callback query message
        msgText = msg.callbackQueryData;
        Serial.print("\nCallback query message received: ");
        Serial.println(msg.callbackQueryData);

        if (msgText.equalsIgnoreCase(LIGHT_ON_CALLBACK)) {
          // pushed "LIGHT ON" button...
          Serial.println("\nSet light ON");
          digitalWrite(LED, HIGH);
          // terminate the callback with an alert message
          myBot.endQuery(msg, "Light on", true);
        }
        else if (msgText.equalsIgnoreCase(LIGHT_OFF_CALLBACK)) {
          // pushed "LIGHT OFF" button...
          Serial.println("\nSet light OFF");
          digitalWrite(LED, LOW);
          // terminate the callback with a popup message
          myBot.endQuery(msg, "Light off");
        }
        break;

      case MessageLocation: {
          // received a location message
          String reply = "Longitude: ";
          reply += msg.location.longitude;
          reply += "; Latitude: ";
          reply += msg.location.latitude;
          Serial.println(reply);
          myBot.sendMessage(msg, reply);
          break;
        }

      case MessageContact: {
          // received a contact message
          String reply = "Contact information received:";
          reply += msg.contact.firstName;
          reply += " ";
          reply += msg.contact.lastName;
          reply += ", mobile ";
          reply += msg.contact.phoneNumber;
          Serial.println(reply);
          myBot.sendMessage(msg, reply);
          break;
        }

      default:
        break;
    }
  }
}

/* -------------------------------------------------------------------------- */
void printWifiStatus() {
/* -------------------------------------------------------------------------- */  
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your board's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

1 Like

cotestatnt,

che posso dire... sono demoralizzato ma felice.

Funziona senza problemi, ho solo eliminato l'include ipaddress che il mio ide non digeriva.

Ho perso una giornata buona, ma quando non si conosce l'argomento e' anche giusto.

Ora cerco di accodare il codice per la scritta scorrevole realizzato da Clemens Valens, poi postero' il tutto per migliorie e aggiunte...

Grazie!!!

Altro problemino...

Ho aggiunto lo sketch per lo scorrimento del testo sulla matrice e funziona, ma non riesco a passargli la stringa ricevuta per un errore di conversione..

alla linea 440 cerco di settare la nuova stringa ma ottengo questo errore:

In function 'void loop()':
r4_telegram_testo_01.ino:440:21: error: initializer fails to determine size of 'banner_text'
             uint8_t banner_text[] = msg;
                     ^~~~~~~~~~~
r4_telegram_testo_01.ino:440:37: error: array must be initialized with a brace-enclosed initializer
             uint8_t banner_text[] = msg;
                                     ^~~
exit status 1

Compilation error: initializer fails to determine size of 'banner_text'

ecco il codice, ho spostato il token in arduino_secret.h.

/*
  TLS WiFi Web client

  Remeber to update the CA certificates using CertificateUploader sketch
  before using this sketch.

*/

#include "WiFiS3.h"
#include "WiFiSSLClient.h"
//#include "IPAddress.h"

#include "arduino_secrets.h" 
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
char ssid[] = SECRET_SSID;        // your network SSID (name)
char pass[] = SECRET_PASS;        // your network password (use for WPA, or use as key for WEP)
int status = WL_IDLE_STATUS;

/*
  Name:        keyboards.ino
  Created:     05/03/2022
  Author:      Tolentino Cotesta <cotestatnt@yahoo.com>
  Description: a more complex example that do:
             1) if a "/inline_keyboard" text message is received, show the inline custom keyboard,
                if a "/reply_keyboard" text message is received, show the reply custom keyboard,
                otherwise reply the sender with "Try /reply_keyboard or /inline_keyboard" message
             2) if "LIGHT ON" inline keyboard button is pressed turn on the LED and show a message
             3) if "LIGHT OFF" inline keyboard button is pressed, turn off the LED and show a message
             4) if "GitHub" inline keyboard button is pressed,
                open a browser window with URL "https://github.com/cotestatnt/AsyncTelegram"
*/
#include <AsyncTelegram2.h>

// Timezone definition
#include <time.h>
#define MYTZ "CET-1CEST,M3.5.0,M10.5.0/3"


WiFiSSLClient client;
AsyncTelegram2 myBot(client);
//const char* token =  "xxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxx";  // Telegram token

// Check the userid with the help of bot @JsonDumpBot or @getidsbot (work also with groups)
// https://t.me/JsonDumpBot  or  https://t.me/getidsbot
int64_t userid = 0;

ReplyKeyboard myReplyKbd;   // reply keyboard object helper
InlineKeyboard myInlineKbd; // inline keyboard object helper
bool isKeyboardActive;      // store if the reply keyboard is shown

#define LIGHT_ON_CALLBACK  "lightON"  // callback data sent when "LIGHT ON" button is pressed
#define LIGHT_OFF_CALLBACK "lightOFF" // callback data sent when "LIGHT OFF" button is pressed



 /*
 * Purpose: Display a text message scrolling from right to left 
 *          on the board's 8x12 LED matrix.
 * Board: Arduino UNO R4 WiFi
 * IDE: 1.8.19 with "Arduino Renesas Boards" version 0.8.5-ea
 *
 * Usage: Upload to the board and enjoy.
 * 
 * Provides many possibilities for doing things better and more efficiently.
 * Parts of this code work because of the way the display works. For instance,
 * there is no need to draw black pixels, only white pixels need drawing.
 * Naively porting this code to another kind of display will probably not work.
 * Buffer overflow protection is probably flawed, so don't count on it.
 *
 * By: Clemens Valens, Elektor
 * Date: 14/6/2023
 */

// Leading spaces ensure starting at the right.


const uint8_t LED = LED_BLUE;
//uint8_t banner_text[] = "   Pippo Pluto Paperino e poi chissa' ";
uint8_t banner_text[] = "   testo base ";
// First value is the width of a character in columns. This allows for
// easy tight spacing on the display (TTF kind of thing).
const uint8_t font_5x8[] = 
{
  3, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, // space
  1, 0b01011111, 0b00000000, 0b00000000, 0b00000000, 0b00000000, // !
  3, 0b00000011, 0b00000000, 0b00000011, 0b00000000, 0b00000000, // "
  5, 0b00010100, 0b00111110, 0b00010100, 0b00111110, 0b00010100, // #
  4, 0b00100100, 0b01101010, 0b00101011, 0b00010010, 0b00000000, // $
  5, 0b01100011, 0b00010011, 0b00001000, 0b01100100, 0b01100011, // %
  5, 0b00110110, 0b01001001, 0b01010110, 0b00100000, 0b01010000, // &
  1, 0b00000011, 0b00000000, 0b00000000, 0b00000000, 0b00000000, // '
  3, 0b00011100, 0b00100010, 0b01000001, 0b00000000, 0b00000000, // (
  3, 0b01000001, 0b00100010, 0b00011100, 0b00000000, 0b00000000, // )
  5, 0b00101000, 0b00011000, 0b00001110, 0b00011000, 0b00101000, // * 
  5, 0b00001000, 0b00001000, 0b00111110, 0b00001000, 0b00001000, // +
  2, 0b10110000, 0b01110000, 0b00000000, 0b00000000, 0b00000000, // ,
  4, 0b00001000, 0b00001000, 0b00001000, 0b00001000, 0b00000000, // -
  2, 0b01100000, 0b01100000, 0b00000000, 0b00000000, 0b00000000, // .
  4, 0b01100000, 0b00011000, 0b00000110, 0b00000001, 0b00000000, // /
  4, 0b00111110, 0b01000001, 0b01000001, 0b00111110, 0b00000000, // 0
  3, 0b01000010, 0b01111111, 0b01000000, 0b00000000, 0b00000000, // 1
  4, 0b01100010, 0b01010001, 0b01001001, 0b01000110, 0b00000000, // 2
  4, 0b00100010, 0b01000001, 0b01001001, 0b00110110, 0b00000000, // 3
  4, 0b00011000, 0b00010100, 0b00010010, 0b01111111, 0b00000000, // 4
  4, 0b00100111, 0b01000101, 0b01000101, 0b00111001, 0b00000000, // 5
  4, 0b00111110, 0b01001001, 0b01001001, 0b00110000, 0b00000000, // 6
  4, 0b01100001, 0b00010001, 0b00001001, 0b00000111, 0b00000000, // 7
  4, 0b00110110, 0b01001001, 0b01001001, 0b00110110, 0b00000000, // 8
  4, 0b00000110, 0b01001001, 0b01001001, 0b00111110, 0b00000000, // 9
  2, 0b01010000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, // :
  2, 0b10000000, 0b01010000, 0b00000000, 0b00000000, 0b00000000, // ;
  3, 0b00010000, 0b00101000, 0b01000100, 0b00000000, 0b00000000, // <
  3, 0b00010100, 0b00010100, 0b00010100, 0b00000000, 0b00000000, // =
  3, 0b01000100, 0b00101000, 0b00010000, 0b00000000, 0b00000000, // >
  4, 0b00000010, 0b01011001, 0b00001001, 0b00000110, 0b00000000, // ?
  5, 0b00111110, 0b01001001, 0b01010101, 0b01011101, 0b00001110, // @
  4, 0b01111110, 0b00010001, 0b00010001, 0b01111110, 0b00000000, // A
  4, 0b01111111, 0b01001001, 0b01001001, 0b00110110, 0b00000000, // B
  4, 0b00111110, 0b01000001, 0b01000001, 0b00100010, 0b00000000, // C
  4, 0b01111111, 0b01000001, 0b01000001, 0b00111110, 0b00000000, // D
  4, 0b01111111, 0b01001001, 0b01001001, 0b01000001, 0b00000000, // E
  4, 0b01111111, 0b00001001, 0b00001001, 0b00000001, 0b00000000, // F
  4, 0b00111110, 0b01000001, 0b01001001, 0b01111010, 0b00000000, // G
  4, 0b01111111, 0b00001000, 0b00001000, 0b01111111, 0b00000000, // H
  3, 0b01000001, 0b01111111, 0b01000001, 0b00000000, 0b00000000, // I
  4, 0b00110000, 0b01000000, 0b01000001, 0b00111111, 0b00000000, // J
  4, 0b01111111, 0b00001000, 0b00010100, 0b01100011, 0b00000000, // K
  4, 0b01111111, 0b01000000, 0b01000000, 0b01000000, 0b00000000, // L
  5, 0b01111111, 0b00000010, 0b00001100, 0b00000010, 0b01111111, // M
  5, 0b01111111, 0b00000100, 0b00001000, 0b00010000, 0b01111111, // N
  4, 0b00111110, 0b01000001, 0b01000001, 0b00111110, 0b00000000, // O
  4, 0b01111111, 0b00001001, 0b00001001, 0b00000110, 0b00000000, // P
  4, 0b00111110, 0b01000001, 0b01000001, 0b10111110, 0b00000000, // Q
  4, 0b01111111, 0b00001001, 0b00001001, 0b01110110, 0b00000000, // R
  4, 0b01000110, 0b01001001, 0b01001001, 0b00110010, 0b00000000, // S
  5, 0b00000001, 0b00000001, 0b01111111, 0b00000001, 0b00000001, // T
  4, 0b00111111, 0b01000000, 0b01000000, 0b00111111, 0b00000000, // U
  5, 0b00001111, 0b00110000, 0b01000000, 0b00110000, 0b00001111, // V
  5, 0b00111111, 0b01000000, 0b00111000, 0b01000000, 0b00111111, // W
  5, 0b01100011, 0b00010100, 0b00001000, 0b00010100, 0b01100011, // X
  5, 0b00000111, 0b00001000, 0b01110000, 0b00001000, 0b00000111, // Y
  4, 0b01100001, 0b01010001, 0b01001001, 0b01000111, 0b00000000, // Z
  2, 0b01111111, 0b01000001, 0b00000000, 0b00000000, 0b00000000, // [
  4, 0b00000001, 0b00000110, 0b00011000, 0b01100000, 0b00000000, // '\'
  2, 0b01000001, 0b01111111, 0b00000000, 0b00000000, 0b00000000, // ]
  3, 0b00000010, 0b00000001, 0b00000010, 0b00000000, 0b00000000, // hat
  4, 0b01000000, 0b01000000, 0b01000000, 0b01000000, 0b00000000, // _
  2, 0b00000001, 0b00000010, 0b00000000, 0b00000000, 0b00000000, // `
  4, 0b00100000, 0b01010100, 0b01010100, 0b01111000, 0b00000000, // a
  4, 0b01111111, 0b01000100, 0b01000100, 0b00111000, 0b00000000, // b
  4, 0b00111000, 0b01000100, 0b01000100, 0b00000000, 0b00000000, // c
  4, 0b00111000, 0b01000100, 0b01000100, 0b01111111, 0b00000000, // d
  4, 0b00111000, 0b01010100, 0b01010100, 0b00011000, 0b00000000, // e
  3, 0b00000100, 0b01111110, 0b00000101, 0b00000000, 0b00000000, // f
  4, 0b10011000, 0b10100100, 0b10100100, 0b01111000, 0b00000000, // g
  4, 0b01111111, 0b00000100, 0b00000100, 0b01111000, 0b00000000, // h
  3, 0b01000100, 0b01111101, 0b01000000, 0b00000000, 0b00000000, // i
  4, 0b01000000, 0b10000000, 0b10000100, 0b01111101, 0b00000000, // j
  4, 0b01111111, 0b00010000, 0b00101000, 0b01000100, 0b00000000, // k
  3, 0b01000001, 0b01111111, 0b01000000, 0b00000000, 0b00000000, // l
  5, 0b01111100, 0b00000100, 0b01111100, 0b00000100, 0b01111000, // m
  4, 0b01111100, 0b00000100, 0b00000100, 0b01111000, 0b00000000, // n
  4, 0b00111000, 0b01000100, 0b01000100, 0b00111000, 0b00000000, // o
  4, 0b11111100, 0b00100100, 0b00100100, 0b00011000, 0b00000000, // p
  4, 0b00011000, 0b00100100, 0b00100100, 0b11111100, 0b00000000, // q
  4, 0b01111100, 0b00001000, 0b00000100, 0b00000100, 0b00000000, // r
  4, 0b01001000, 0b01010100, 0b01010100, 0b00100100, 0b00000000, // s
  3, 0b00000100, 0b00111111, 0b01000100, 0b00000000, 0b00000000, // t
  4, 0b00111100, 0b01000000, 0b01000000, 0b01111100, 0b00000000, // u
  5, 0b00011100, 0b00100000, 0b01000000, 0b00100000, 0b00011100, // v
  5, 0b00111100, 0b01000000, 0b00111100, 0b01000000, 0b00111100, // w
  5, 0b01000100, 0b00101000, 0b00010000, 0b00101000, 0b01000100, // x
  4, 0b10011100, 0b10100000, 0b10100000, 0b01111100, 0b00000000, // y
  3, 0b01100100, 0b01010100, 0b01001100, 0b00000000, 0b00000000, // z
  3, 0b00001000, 0b00110110, 0b01000001, 0b00000000, 0b00000000, // {
  1, 0b01111111, 0b00000000, 0b00000000, 0b00000000, 0b00000000, // |
  3, 0b01000001, 0b00110110, 0b00001000, 0b00000000, 0b00000000, // }
  4, 0b00001000, 0b00000100, 0b00001000, 0b00000100, 0b00000000, // ~
};

// LED matrix info.
const uint8_t led_matrix_pin_first = 28;
const uint8_t led_matrix_pin_last = 38;
const uint8_t led_matrix_pin_count = led_matrix_pin_last - led_matrix_pin_first + 1;
const uint8_t led_matrix_rows = 8;
const uint8_t led_matrix_cols = 12;

// Pixel-to-pin translation table.
// A HEX value encodes two pin numbers. The MSB is to be driven LOW,
// the LSB is to be driven HIGH.
// Example: pixel (4,2) contains the value 0x60, meaning that pin 6 must
// be driven low and pin 0 must be driven high to activate the pixel.
// The pin number is an offset to the constant led_matrix_pin_first
// Note that they all appear in pairs, so you could make the table 50%
// smaller at the cost of doing some swapping for odd or even columns.
// (0,0) is upper left corner when the board's USB connector points to the left.
const uint8_t led_matrix_pins[led_matrix_rows][led_matrix_cols] =
{
  //  0     1     2     3     4     5     6     7     8     9    10     11
  { 0x37, 0x73, 0x47, 0x74, 0x43, 0x34, 0x87, 0x78, 0x83, 0x38, 0x84, 0x48 }, // 0
  { 0x07, 0x70, 0x03, 0x30, 0x04, 0x40, 0x08, 0x80, 0x67, 0x76, 0x63, 0x36 }, // 1
  { 0x64, 0x46, 0x68, 0x86, 0x60, 0x06, 0x57, 0x75, 0x53, 0x35, 0x54, 0x45 }, // 2
  { 0x58, 0x85, 0x50, 0x05, 0x56, 0x65, 0x17, 0x71, 0x13, 0x31, 0x14, 0x41 }, // 3
  { 0x18, 0x81, 0x10, 0x01, 0x16, 0x61, 0x15, 0x51, 0x27, 0x72, 0x23, 0x32 }, // 4
  { 0x24, 0x42, 0x28, 0x82, 0x20, 0x02, 0x26, 0x62, 0x25, 0x52, 0x21, 0x12 }, // 5
  { 0xa7, 0x7a, 0xa3, 0x3a, 0xa4, 0x4a, 0xa8, 0x8a, 0xa0, 0x0a, 0xa6, 0x6a }, // 6
  { 0xa5, 0x5a, 0xa1, 0x1a, 0xa2, 0x2a, 0x97, 0x79, 0x93, 0x39, 0x94, 0x49 }, // 7
};

// Every byte represents a column of the LED matrix.
// Can hold 32 5x8-font characters.
// Buffer can be smaller at the price of more code.
uint8_t led_matrix_buffer[5*128];

// Activate the pixel at (x,y) for ontime microseconds.
void put_pixel(uint8_t x, uint8_t y, uint32_t ontime)
{
  uint8_t pins = led_matrix_pins[y][x];
  uint8_t l = (pins>>4) + led_matrix_pin_first;
  uint8_t h = (pins&0xf) + led_matrix_pin_first;
  pinMode(l,OUTPUT);
  digitalWrite(l,LOW);
  pinMode(h,OUTPUT);
  digitalWrite(h,HIGH);
  // If ontime = 0, pixel remains active until it is deactivated
  // by another put_pixel that happens to use the same pin(s).
  if (ontime!=0)
  {
    delayMicroseconds(ontime);
    pinMode(l,INPUT);
    pinMode(h,INPUT);
  }
}

// Call periodically at desired fps rate.
// ontime specifies how long a pixel remains on.
void led_matrix_buffer_show(uint32_t x_offset, uint32_t ontime)
{
  for (uint8_t i=0; i<led_matrix_cols; i++)
  {
    if (i+x_offset>=sizeof(led_matrix_buffer)) return;
    uint8_t col = led_matrix_buffer[i+x_offset];
    for (uint8_t row=0; row<led_matrix_rows; row++)
    {
      if ((col&0x01)!=0)
      {
        put_pixel(i,row,ontime);
      }
      col >>= 1;
    }
  }
}

// Write a character to the buffer.
uint8_t led_matrix_putch(uint8_t *p_buffer, uint16_t buffer_size, uint8_t ch)
{
  uint8_t i;
  
  if (ch<' ') return 0;
  ch -= ' ';
  uint16_t offset = 6*ch;
  uint8_t width = font_5x8[offset];
  for (i=0; i<width; i++) 
  { 
    offset += 1;
    // This is supposed to prevent buffer overflow.
    if (i>=buffer_size) break;
    p_buffer[i] = font_5x8[offset];
  }
  return i+1;
}

// Write a string to the buffer.
uint16_t led_matrix_puts(uint8_t *p_buffer, uint16_t buffer_size, uint8_t *p_str)
{
  uint8_t *p = p_buffer;
  while (*p_str!=0)
  {
    p += led_matrix_putch(p,buffer_size-(p-p_buffer),*p_str);
    p_str++;
  }
  return p - p_buffer;
}

uint32_t t_prev = 0;
/* -------------------------------------------------------------------------- */
void setup() {
    for (uint8_t i=0; i<led_matrix_pin_count; i++)
  {
    pinMode(led_matrix_pin_first+i,INPUT); // all off
  }
  // Load text message.
  led_matrix_puts(led_matrix_buffer,sizeof(led_matrix_buffer),banner_text);
  // Ready...
  t_prev = millis();
  // Go!
/* -------------------------------------------------------------------------- */     for (uint8_t i=0; i<led_matrix_pin_count; i++)
  {
    pinMode(led_matrix_pin_first+i,INPUT); // all off
  }
  // Load text message.
  led_matrix_puts(led_matrix_buffer,sizeof(led_matrix_buffer),banner_text);
  // Ready...
  t_prev = millis();
  // Go!

  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(LED, OUTPUT);
  //Initialize serial and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  
  // check for the WiFi module:
  if (WiFi.status() == WL_NO_MODULE) {
    Serial.println("Communication with WiFi module failed!");
    // don't continue
    while (true);
  }
  
  String fv = WiFi.firmwareVersion();
  if (fv < WIFI_FIRMWARE_LATEST_VERSION) {
    Serial.println("Please upgrade the firmware");
  }
  
  // attempt to connect to WiFi network:
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network.
    status = WiFi.begin(ssid, pass);     
    // wait 10 seconds for connection:
    delay(10000);
  }

  // Set the Telegram bot properties
  myBot.setUpdateTime(1000);
  myBot.setTelegramToken(token);

  // Check if all things are ok
  Serial.print("\nTest Telegram connection... ");
  myBot.begin() ? Serial.println("OK") : Serial.println("NOK");
  Serial.print("Bot name: @");
  Serial.println(myBot.getBotName());

  // Add reply keyboard
  isKeyboardActive = false;
  // add a button that send a message with "Simple button" text
  myReplyKbd.addButton("Button1");
  myReplyKbd.addButton("Button2");
  myReplyKbd.addButton("Button3");
  // add a new empty button row
  myReplyKbd.addRow();
  // add another button that send the user position (location)
  myReplyKbd.addButton("Send Location", KeyboardButtonLocation);
  // add another button that send the user contact
  myReplyKbd.addButton("Send contact", KeyboardButtonContact);
  // add a new empty button row
  myReplyKbd.addRow();
  // add a button that send a message with "Hide replyKeyboard" text
  // (it will be used to hide the reply keyboard)
  myReplyKbd.addButton("/hide_keyboard");
  // resize the keyboard to fit only the needed space
  myReplyKbd.enableResize();

  // Add sample inline keyboard
  myInlineKbd.addButton("ON", LIGHT_ON_CALLBACK, KeyboardButtonQuery);
  myInlineKbd.addButton("OFF", LIGHT_OFF_CALLBACK, KeyboardButtonQuery);
  myInlineKbd.addRow();
  myInlineKbd.addButton("GitHub", "https://github.com/cotestatnt/AsyncTelegram2/", KeyboardButtonURL);

  char welcome_msg[128];
  snprintf(welcome_msg, 128, "BOT @%s online\n/help all commands avalaible.", myBot.getBotName());

  // Send a message to specific user who has started your bot
  myBot.sendTo(userid, welcome_msg);



}


/* -------------------------------------------------------------------------- */
void loop() {
/* -------------------------------------------------------------------------- */  
  // In the meantime LED_BUILTIN will blink with a fixed frequency
  // to evaluate async and non-blocking working of library
  static uint32_t ledTime = millis();
  if (millis() - ledTime > 200) {
    ledTime = millis();
    digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
  }

  // if there is an incoming message...
  // local variable to store telegram message data
  TBMessage msg;
  if (myBot.getNewMessage(msg)) {
    // check what kind of message I received
    MessageType msgType = msg.messageType;
    String msgText = msg.text;


 led_matrix_puts(led_matrix_buffer,sizeof(led_matrix_buffer),banner_text);

    switch (msgType) {
      case MessageText :
        // received a text message
        Serial.print("\nText message received: ");
        Serial.println(msgText);

        // check if is show keyboard command
        if (msgText.equalsIgnoreCase("/reply_keyboard")) {
          // the user is asking to show the reply keyboard --> show it
          myBot.sendMessage(msg, "This is reply keyboard:", myReplyKbd);
          isKeyboardActive = true;
        }
        else if (msgText.equalsIgnoreCase("/inline_keyboard")) {
          myBot.sendMessage(msg, "This is inline keyboard:", myInlineKbd);
        }
    
        // check if the reply keyboard is active
        else if (isKeyboardActive) {
          // is active -> manage the text messages sent by pressing the reply keyboard buttons
          if (msgText.equalsIgnoreCase("/hide_keyboard")) {
            // sent the "hide keyboard" message --> hide the reply keyboard
            myBot.removeReplyKeyboard(msg, "Reply keyboard removed");
            isKeyboardActive = false;
          } else {
            // print every others messages received
            myBot.sendMessage(msg, msg.text);
            //uint8_t banner_text[] = msg;
          }
        }

        // the user write anything else and the reply keyboard is not active --> show a hint message
        else {
          myBot.sendMessage(msg, "Try /reply_keyboard or /inline_keyboard");
          //uint8_t banner_text[] = "---------------";
            uint8_t banner_text[] = msg;
            led_matrix_puts(led_matrix_buffer,sizeof(led_matrix_buffer),banner_text);
        }
        break;

      case MessageQuery:
        // received a callback query message
        msgText = msg.callbackQueryData;
        Serial.print("\nCallback query message received: ");
        Serial.println(msg.callbackQueryData);

        if (msgText.equalsIgnoreCase(LIGHT_ON_CALLBACK)) {
          // pushed "LIGHT ON" button...
          Serial.println("\nSet light ON");
          digitalWrite(LED, HIGH);
          // terminate the callback with an alert message
          myBot.endQuery(msg, "Light on", true);
        }
        else if (msgText.equalsIgnoreCase(LIGHT_OFF_CALLBACK)) {
          // pushed "LIGHT OFF" button...
          Serial.println("\nSet light OFF");
          digitalWrite(LED, LOW);
          // terminate the callback with a popup message
          myBot.endQuery(msg, "Light off");
        }
        break;

      case MessageLocation: {
          // received a location message
          String reply = "Longitude: ";
          reply += msg.location.longitude;
          reply += "; Latitude: ";
          reply += msg.location.latitude;
          Serial.println(reply);
          myBot.sendMessage(msg, reply);
          break;
        }

      case MessageContact: {
          // received a contact message
          String reply = "Contact information received:";
          reply += msg.contact.firstName;
          reply += " ";
          reply += msg.contact.lastName;
          reply += ", mobile ";
          reply += msg.contact.phoneNumber;
          Serial.println(reply);
          myBot.sendMessage(msg, reply);
          break;
        }

      default:
        break;
    }
  }
  // Scroll speed is determined by both scroll_speed and ontime.
  const uint8_t scroll_speed = 50; // milliseconds
  const uint16_t ontime = 521; // microseconds. 521 (us) * 96 (pixels) = 50 ms frame rate if all the pixels are on.
  static uint8_t scroll = 0; // scroll position.

  // Refresh display.
  led_matrix_buffer_show(scroll,ontime);

  // Update scroll position.
  if (millis()>=t_prev+scroll_speed)
  {
    t_prev = millis();
    scroll += 1; // Scroll to the left.
    if (scroll>5*strlen((char*)banner_text)) {
      scroll = 0; // restart
      }
  }


}

/* -------------------------------------------------------------------------- */
void printWifiStatus() {
/* -------------------------------------------------------------------------- */  
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your board's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}






Non puoi assegnare ad un array di interi una variabile di tipo String in questo modo.

Devi usare le funzioni C standard per la copia byte a byte, solo che da una variabile String al massimo ricavi un puntatore a char e quindi dovrai "forzare" il cast a uint8_t

Ad esempio:

size_t len = msg.length();
uint8_t banner_text[len];
memcpy(banner_text, (uint8_t *) msg.c_str(), len);

Eccomi,

ci siamo quasi, ho 2 problemini.

  1. inserendo la stringa nuova, questa viene sovrapposta al testo precedente, come se fosse sommata a quella precedente.

  2. asynctelegram2 forse ha un baco sulla funzione myBot.endQuery.

Se utilizzo la tastiera inine, va in crash arduino r4 e sulla seriale ricevo questo:

Callback query message received: lightON

Set light ON


Firmware name: "C:\Users\User\AppData\Local\Temp\arduino\sketches\CC2ED7BC414D2C5392B26DA1181CFD21/SineWave.ino", compiled on: Jul 22 2023
Fault on interrupt or bare metal(no OS) environment
Error: Main stack(20007a08) was overflow
===== Thread stack information =====
  addr: 20007b00    data: 20007c08
  addr: 20007b04    data: ffffffe9
  addr: 20007b08    data: 20003764
  addr: 20007b0c    data: 00016122
  addr: 20007b10    data: 00000073


====================================

Bus fault is caused by precise data access violation
The bus fault occurred address is ce0caa77

Credo che asynctelegram2 non sia perfetta oggi per arduino R4..

il codice attuale e' questo:

/*
  TLS WiFi Web client

  Remeber to update the CA certificates using CertificateUploader sketch
  before using this sketch.

*/

#include "WiFiS3.h"
#include "WiFiSSLClient.h"
//#include "IPAddress.h"

#include "arduino_secrets.h"
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
char ssid[] = SECRET_SSID;  // your network SSID (name)
char pass[] = SECRET_PASS;  // your network password (use for WPA, or use as key for WEP)
int status = WL_IDLE_STATUS;

/*
  Name:        keyboards.ino
  Created:     05/03/2022
  Author:      Tolentino Cotesta <cotestatnt@yahoo.com>
  Description: a more complex example that do:
             1) if a "/inline_keyboard" text message is received, show the inline custom keyboard,
                if a "/reply_keyboard" text message is received, show the reply custom keyboard,
                otherwise reply the sender with "Try /reply_keyboard or /inline_keyboard" message
             2) if "LIGHT ON" inline keyboard button is pressed turn on the LED and show a message
             3) if "LIGHT OFF" inline keyboard button is pressed, turn off the LED and show a message
             4) if "GitHub" inline keyboard button is pressed,
                open a browser window with URL "https://github.com/cotestatnt/AsyncTelegram"
*/
#include <AsyncTelegram2.h>

// Timezone definition
#include <time.h>
#define MYTZ "CET-1CEST,M3.5.0,M10.5.0/3"


WiFiSSLClient client;
AsyncTelegram2 myBot(client);
//const char* token =  "xxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxx";  // Telegram token

// Check the userid with the help of bot @JsonDumpBot or @getidsbot (work also with groups)
// https://t.me/JsonDumpBot  or  https://t.me/getidsbot
int64_t userid = 0;

ReplyKeyboard myReplyKbd;    // reply keyboard object helper
InlineKeyboard myInlineKbd;  // inline keyboard object helper
bool isKeyboardActive;       // store if the reply keyboard is shown

#define LIGHT_ON_CALLBACK "lightON"    // callback data sent when "LIGHT ON" button is pressed
#define LIGHT_OFF_CALLBACK "lightOFF"  // callback data sent when "LIGHT OFF" button is pressed



/*
 * Purpose: Display a text message scrolling from right to left 
 *          on the board's 8x12 LED matrix.
 * Board: Arduino UNO R4 WiFi
 * IDE: 1.8.19 with "Arduino Renesas Boards" version 0.8.5-ea
 *
 * Usage: Upload to the board and enjoy.
 * 
 * Provides many possibilities for doing things better and more efficiently.
 * Parts of this code work because of the way the display works. For instance,
 * there is no need to draw black pixels, only white pixels need drawing.
 * Naively porting this code to another kind of display will probably not work.
 * Buffer overflow protection is probably flawed, so don't count on it.
 *
 * By: Clemens Valens, Elektor
 * Date: 14/6/2023
 */

// Leading spaces ensure starting at the right.
const uint8_t scroll_speed = 50;  // milliseconds
const uint16_t ontime = 521;      // microseconds. 521 (us) * 96 (pixels) = 50 ms frame rate if all the pixels are on.
static uint8_t scroll = 0;        // scroll position.


const uint8_t LED = 1;
//uint8_t banner_text[] = "   Pippo Pluto Paperino e poi chissa' ";
uint8_t banner_text[] = "   testo   ";
// First value is the width of a character in columns. This allows for
// easy tight spacing on the display (TTF kind of thing).
const uint8_t font_5x8[] = {
  3, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000,  // space
  1, 0b01011111, 0b00000000, 0b00000000, 0b00000000, 0b00000000,  // !
  3, 0b00000011, 0b00000000, 0b00000011, 0b00000000, 0b00000000,  // "
  5, 0b00010100, 0b00111110, 0b00010100, 0b00111110, 0b00010100,  // #
  4, 0b00100100, 0b01101010, 0b00101011, 0b00010010, 0b00000000,  // $
  5, 0b01100011, 0b00010011, 0b00001000, 0b01100100, 0b01100011,  // %
  5, 0b00110110, 0b01001001, 0b01010110, 0b00100000, 0b01010000,  // &
  1, 0b00000011, 0b00000000, 0b00000000, 0b00000000, 0b00000000,  // '
  3, 0b00011100, 0b00100010, 0b01000001, 0b00000000, 0b00000000,  // (
  3, 0b01000001, 0b00100010, 0b00011100, 0b00000000, 0b00000000,  // )
  5, 0b00101000, 0b00011000, 0b00001110, 0b00011000, 0b00101000,  // *
  5, 0b00001000, 0b00001000, 0b00111110, 0b00001000, 0b00001000,  // +
  2, 0b10110000, 0b01110000, 0b00000000, 0b00000000, 0b00000000,  // ,
  4, 0b00001000, 0b00001000, 0b00001000, 0b00001000, 0b00000000,  // -
  2, 0b01100000, 0b01100000, 0b00000000, 0b00000000, 0b00000000,  // .
  4, 0b01100000, 0b00011000, 0b00000110, 0b00000001, 0b00000000,  // /
  4, 0b00111110, 0b01000001, 0b01000001, 0b00111110, 0b00000000,  // 0
  3, 0b01000010, 0b01111111, 0b01000000, 0b00000000, 0b00000000,  // 1
  4, 0b01100010, 0b01010001, 0b01001001, 0b01000110, 0b00000000,  // 2
  4, 0b00100010, 0b01000001, 0b01001001, 0b00110110, 0b00000000,  // 3
  4, 0b00011000, 0b00010100, 0b00010010, 0b01111111, 0b00000000,  // 4
  4, 0b00100111, 0b01000101, 0b01000101, 0b00111001, 0b00000000,  // 5
  4, 0b00111110, 0b01001001, 0b01001001, 0b00110000, 0b00000000,  // 6
  4, 0b01100001, 0b00010001, 0b00001001, 0b00000111, 0b00000000,  // 7
  4, 0b00110110, 0b01001001, 0b01001001, 0b00110110, 0b00000000,  // 8
  4, 0b00000110, 0b01001001, 0b01001001, 0b00111110, 0b00000000,  // 9
  2, 0b01010000, 0b00000000, 0b00000000, 0b00000000, 0b00000000,  // :
  2, 0b10000000, 0b01010000, 0b00000000, 0b00000000, 0b00000000,  // ;
  3, 0b00010000, 0b00101000, 0b01000100, 0b00000000, 0b00000000,  // <
  3, 0b00010100, 0b00010100, 0b00010100, 0b00000000, 0b00000000,  // =
  3, 0b01000100, 0b00101000, 0b00010000, 0b00000000, 0b00000000,  // >
  4, 0b00000010, 0b01011001, 0b00001001, 0b00000110, 0b00000000,  // ?
  5, 0b00111110, 0b01001001, 0b01010101, 0b01011101, 0b00001110,  // @
  4, 0b01111110, 0b00010001, 0b00010001, 0b01111110, 0b00000000,  // A
  4, 0b01111111, 0b01001001, 0b01001001, 0b00110110, 0b00000000,  // B
  4, 0b00111110, 0b01000001, 0b01000001, 0b00100010, 0b00000000,  // C
  4, 0b01111111, 0b01000001, 0b01000001, 0b00111110, 0b00000000,  // D
  4, 0b01111111, 0b01001001, 0b01001001, 0b01000001, 0b00000000,  // E
  4, 0b01111111, 0b00001001, 0b00001001, 0b00000001, 0b00000000,  // F
  4, 0b00111110, 0b01000001, 0b01001001, 0b01111010, 0b00000000,  // G
  4, 0b01111111, 0b00001000, 0b00001000, 0b01111111, 0b00000000,  // H
  3, 0b01000001, 0b01111111, 0b01000001, 0b00000000, 0b00000000,  // I
  4, 0b00110000, 0b01000000, 0b01000001, 0b00111111, 0b00000000,  // J
  4, 0b01111111, 0b00001000, 0b00010100, 0b01100011, 0b00000000,  // K
  4, 0b01111111, 0b01000000, 0b01000000, 0b01000000, 0b00000000,  // L
  5, 0b01111111, 0b00000010, 0b00001100, 0b00000010, 0b01111111,  // M
  5, 0b01111111, 0b00000100, 0b00001000, 0b00010000, 0b01111111,  // N
  4, 0b00111110, 0b01000001, 0b01000001, 0b00111110, 0b00000000,  // O
  4, 0b01111111, 0b00001001, 0b00001001, 0b00000110, 0b00000000,  // P
  4, 0b00111110, 0b01000001, 0b01000001, 0b10111110, 0b00000000,  // Q
  4, 0b01111111, 0b00001001, 0b00001001, 0b01110110, 0b00000000,  // R
  4, 0b01000110, 0b01001001, 0b01001001, 0b00110010, 0b00000000,  // S
  5, 0b00000001, 0b00000001, 0b01111111, 0b00000001, 0b00000001,  // T
  4, 0b00111111, 0b01000000, 0b01000000, 0b00111111, 0b00000000,  // U
  5, 0b00001111, 0b00110000, 0b01000000, 0b00110000, 0b00001111,  // V
  5, 0b00111111, 0b01000000, 0b00111000, 0b01000000, 0b00111111,  // W
  5, 0b01100011, 0b00010100, 0b00001000, 0b00010100, 0b01100011,  // X
  5, 0b00000111, 0b00001000, 0b01110000, 0b00001000, 0b00000111,  // Y
  4, 0b01100001, 0b01010001, 0b01001001, 0b01000111, 0b00000000,  // Z
  2, 0b01111111, 0b01000001, 0b00000000, 0b00000000, 0b00000000,  // [
  4, 0b00000001, 0b00000110, 0b00011000, 0b01100000, 0b00000000,  // '\'
  2, 0b01000001, 0b01111111, 0b00000000, 0b00000000, 0b00000000,  // ]
  3, 0b00000010, 0b00000001, 0b00000010, 0b00000000, 0b00000000,  // hat
  4, 0b01000000, 0b01000000, 0b01000000, 0b01000000, 0b00000000,  // _
  2, 0b00000001, 0b00000010, 0b00000000, 0b00000000, 0b00000000,  // `
  4, 0b00100000, 0b01010100, 0b01010100, 0b01111000, 0b00000000,  // a
  4, 0b01111111, 0b01000100, 0b01000100, 0b00111000, 0b00000000,  // b
  4, 0b00111000, 0b01000100, 0b01000100, 0b00000000, 0b00000000,  // c
  4, 0b00111000, 0b01000100, 0b01000100, 0b01111111, 0b00000000,  // d
  4, 0b00111000, 0b01010100, 0b01010100, 0b00011000, 0b00000000,  // e
  3, 0b00000100, 0b01111110, 0b00000101, 0b00000000, 0b00000000,  // f
  4, 0b10011000, 0b10100100, 0b10100100, 0b01111000, 0b00000000,  // g
  4, 0b01111111, 0b00000100, 0b00000100, 0b01111000, 0b00000000,  // h
  3, 0b01000100, 0b01111101, 0b01000000, 0b00000000, 0b00000000,  // i
  4, 0b01000000, 0b10000000, 0b10000100, 0b01111101, 0b00000000,  // j
  4, 0b01111111, 0b00010000, 0b00101000, 0b01000100, 0b00000000,  // k
  3, 0b01000001, 0b01111111, 0b01000000, 0b00000000, 0b00000000,  // l
  5, 0b01111100, 0b00000100, 0b01111100, 0b00000100, 0b01111000,  // m
  4, 0b01111100, 0b00000100, 0b00000100, 0b01111000, 0b00000000,  // n
  4, 0b00111000, 0b01000100, 0b01000100, 0b00111000, 0b00000000,  // o
  4, 0b11111100, 0b00100100, 0b00100100, 0b00011000, 0b00000000,  // p
  4, 0b00011000, 0b00100100, 0b00100100, 0b11111100, 0b00000000,  // q
  4, 0b01111100, 0b00001000, 0b00000100, 0b00000100, 0b00000000,  // r
  4, 0b01001000, 0b01010100, 0b01010100, 0b00100100, 0b00000000,  // s
  3, 0b00000100, 0b00111111, 0b01000100, 0b00000000, 0b00000000,  // t
  4, 0b00111100, 0b01000000, 0b01000000, 0b01111100, 0b00000000,  // u
  5, 0b00011100, 0b00100000, 0b01000000, 0b00100000, 0b00011100,  // v
  5, 0b00111100, 0b01000000, 0b00111100, 0b01000000, 0b00111100,  // w
  5, 0b01000100, 0b00101000, 0b00010000, 0b00101000, 0b01000100,  // x
  4, 0b10011100, 0b10100000, 0b10100000, 0b01111100, 0b00000000,  // y
  3, 0b01100100, 0b01010100, 0b01001100, 0b00000000, 0b00000000,  // z
  3, 0b00001000, 0b00110110, 0b01000001, 0b00000000, 0b00000000,  // {
  1, 0b01111111, 0b00000000, 0b00000000, 0b00000000, 0b00000000,  // |
  3, 0b01000001, 0b00110110, 0b00001000, 0b00000000, 0b00000000,  // }
  4, 0b00001000, 0b00000100, 0b00001000, 0b00000100, 0b00000000,  // ~
};

// LED matrix info.
const uint8_t led_matrix_pin_first = 28;
const uint8_t led_matrix_pin_last = 38;
const uint8_t led_matrix_pin_count = led_matrix_pin_last - led_matrix_pin_first + 1;
const uint8_t led_matrix_rows = 8;
const uint8_t led_matrix_cols = 12;

// Pixel-to-pin translation table.
// A HEX value encodes two pin numbers. The MSB is to be driven LOW,
// the LSB is to be driven HIGH.
// Example: pixel (4,2) contains the value 0x60, meaning that pin 6 must
// be driven low and pin 0 must be driven high to activate the pixel.
// The pin number is an offset to the constant led_matrix_pin_first
// Note that they all appear in pairs, so you could make the table 50%
// smaller at the cost of doing some swapping for odd or even columns.
// (0,0) is upper left corner when the board's USB connector points to the left.
const uint8_t led_matrix_pins[led_matrix_rows][led_matrix_cols] = {
  //  0     1     2     3     4     5     6     7     8     9    10     11
  { 0x37, 0x73, 0x47, 0x74, 0x43, 0x34, 0x87, 0x78, 0x83, 0x38, 0x84, 0x48 },  // 0
  { 0x07, 0x70, 0x03, 0x30, 0x04, 0x40, 0x08, 0x80, 0x67, 0x76, 0x63, 0x36 },  // 1
  { 0x64, 0x46, 0x68, 0x86, 0x60, 0x06, 0x57, 0x75, 0x53, 0x35, 0x54, 0x45 },  // 2
  { 0x58, 0x85, 0x50, 0x05, 0x56, 0x65, 0x17, 0x71, 0x13, 0x31, 0x14, 0x41 },  // 3
  { 0x18, 0x81, 0x10, 0x01, 0x16, 0x61, 0x15, 0x51, 0x27, 0x72, 0x23, 0x32 },  // 4
  { 0x24, 0x42, 0x28, 0x82, 0x20, 0x02, 0x26, 0x62, 0x25, 0x52, 0x21, 0x12 },  // 5
  { 0xa7, 0x7a, 0xa3, 0x3a, 0xa4, 0x4a, 0xa8, 0x8a, 0xa0, 0x0a, 0xa6, 0x6a },  // 6
  { 0xa5, 0x5a, 0xa1, 0x1a, 0xa2, 0x2a, 0x97, 0x79, 0x93, 0x39, 0x94, 0x49 },  // 7
};

// Every byte represents a column of the LED matrix.
// Can hold 32 5x8-font characters.
// Buffer can be smaller at the price of more code.
uint8_t led_matrix_buffer[5 * 128];

// Activate the pixel at (x,y) for ontime microseconds.
void put_pixel(uint8_t x, uint8_t y, uint32_t ontime) {
  uint8_t pins = led_matrix_pins[y][x];
  uint8_t l = (pins >> 4) + led_matrix_pin_first;
  uint8_t h = (pins & 0xf) + led_matrix_pin_first;
  pinMode(l, OUTPUT);
  digitalWrite(l, LOW);
  pinMode(h, OUTPUT);
  digitalWrite(h, HIGH);
  // If ontime = 0, pixel remains active until it is deactivated
  // by another put_pixel that happens to use the same pin(s).
  if (ontime != 0) {
    delayMicroseconds(ontime);
    pinMode(l, INPUT);
    pinMode(h, INPUT);
  }
}

// Call periodically at desired fps rate.
// ontime specifies how long a pixel remains on.
void led_matrix_buffer_show(uint32_t x_offset, uint32_t ontime) {
  for (uint8_t i = 0; i < led_matrix_cols; i++) {
    if (i + x_offset >= sizeof(led_matrix_buffer)) return;
    uint8_t col = led_matrix_buffer[i + x_offset];
    for (uint8_t row = 0; row < led_matrix_rows; row++) {
      if ((col & 0x01) != 0) {
        put_pixel(i, row, ontime);
      }
      col >>= 1;
    }
  }
}

// Write a character to the buffer.
uint8_t led_matrix_putch(uint8_t *p_buffer, uint16_t buffer_size, uint8_t ch) {
  uint8_t i;

  if (ch < ' ') return 0;
  ch -= ' ';
  uint16_t offset = 6 * ch;
  uint8_t width = font_5x8[offset];
  for (i = 0; i < width; i++) {
    offset += 1;
    // This is supposed to prevent buffer overflow.
    if (i >= buffer_size) break;
    p_buffer[i] = font_5x8[offset];
  }
  return i + 1;
}

// Write a string to the buffer.
uint16_t led_matrix_puts(uint8_t *p_buffer, uint16_t buffer_size, uint8_t *p_str) {
  uint8_t *p = p_buffer;
  while (*p_str != 0) {
    p += led_matrix_putch(p, buffer_size - (p - p_buffer), *p_str);
    p_str++;
  }
  return p - p_buffer;
}

uint32_t t_prev = 0;
/* -------------------------------------------------------------------------- */
void setup() {
  for (uint8_t i = 0; i < led_matrix_pin_count; i++) {
    pinMode(led_matrix_pin_first + i, INPUT);  // all off
  }
  // Load text message.
  led_matrix_puts(led_matrix_buffer, sizeof(led_matrix_buffer), banner_text);
  // Ready...
  t_prev = millis();
  // Go!
  /* -------------------------------------------------------------------------- */ for (uint8_t i = 0; i < led_matrix_pin_count; i++) {
    pinMode(led_matrix_pin_first + i, INPUT);  // all off
  }
  // Load text message.
  led_matrix_puts(led_matrix_buffer, sizeof(led_matrix_buffer), banner_text);
  // Ready...
  t_prev = millis();
  // Go!

  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(LED, OUTPUT);
  //Initialize serial and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ;  // wait for serial port to connect. Needed for native USB port only
  }

  // check for the WiFi module:
  if (WiFi.status() == WL_NO_MODULE) {
    Serial.println("Communication with WiFi module failed!");
    // don't continue
    while (true)
      ;
  }

  String fv = WiFi.firmwareVersion();
  if (fv < WIFI_FIRMWARE_LATEST_VERSION) {
    Serial.println("Please upgrade the firmware");
  }

  // attempt to connect to WiFi network:
  while (status != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network.
    status = WiFi.begin(ssid, pass);
    // wait 10 seconds for connection:
    delay(10000);
  }

  // Set the Telegram bot properties
  myBot.setUpdateTime(1000);
  myBot.setTelegramToken(token);

  // Check if all things are ok
  Serial.print("\nTest Telegram connection... ");
  myBot.begin() ? Serial.println("OK") : Serial.println("NOK");
  Serial.print("Bot name: @");
  Serial.println(myBot.getBotName());

  // Add reply keyboard
  isKeyboardActive = false;
  // add a button that send a message with "Simple button" text
  myReplyKbd.addButton("Button1");
  myReplyKbd.addButton("Button2");
  myReplyKbd.addButton("Button3");
  // add a new empty button row
  myReplyKbd.addRow();
  // add another button that send the user position (location)
  myReplyKbd.addButton("Send Location", KeyboardButtonLocation);
  // add another button that send the user contact
  myReplyKbd.addButton("Send contact", KeyboardButtonContact);
  // add a new empty button row
  myReplyKbd.addRow();
  // add a button that send a message with "Hide replyKeyboard" text
  // (it will be used to hide the reply keyboard)
  myReplyKbd.addButton("/hide_keyboard");
  // resize the keyboard to fit only the needed space
  myReplyKbd.enableResize();

  // Add sample inline keyboard
  myInlineKbd.addButton("ON", LIGHT_ON_CALLBACK, KeyboardButtonQuery);
  myInlineKbd.addButton("OFF", LIGHT_OFF_CALLBACK, KeyboardButtonQuery);
  myInlineKbd.addRow();
  myInlineKbd.addButton("GitHub", "https://github.com/cotestatnt/AsyncTelegram2/", KeyboardButtonURL);

  char welcome_msg[128];
  snprintf(welcome_msg, 128, "BOT @%s online\n/help all commands avalaible.", myBot.getBotName());

  // Send a message to specific user who has started your bot
  myBot.sendTo(userid, welcome_msg);
}


/* -------------------------------------------------------------------------- */
void loop() {
  /* -------------------------------------------------------------------------- */
  // In the meantime LED_BUILTIN will blink with a fixed frequency
  // to evaluate async and non-blocking working of library
  static uint32_t ledTime = millis();
  if (millis() - ledTime > 200) {
    ledTime = millis();
    //digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
  }

  // if there is an incoming message...
  // local variable to store telegram message data
  TBMessage msg;
  if (myBot.getNewMessage(msg)) {
    // check what kind of message I received
    MessageType msgType = msg.messageType;
    String msgText = msg.text;


    led_matrix_puts(led_matrix_buffer, sizeof(led_matrix_buffer), banner_text);

    switch (msgType) {
      case MessageText:
        // received a text message
        Serial.print("\nText message received: ");
        Serial.println(msgText);

        // check if is show keyboard command
        if (msgText.equalsIgnoreCase("/reply_keyboard")) {
          // the user is asking to show the reply keyboard --> show it
          myBot.sendMessage(msg, "This is reply keyboard:", myReplyKbd);
          isKeyboardActive = true;
        } else if (msgText.equalsIgnoreCase("/inline_keyboard")) {
          myBot.sendMessage(msg, "This is inline keyboard:", myInlineKbd);
        }

        // check if the reply keyboard is active
        else if (isKeyboardActive) {
          // is active -> manage the text messages sent by pressing the reply keyboard buttons
          if (msgText.equalsIgnoreCase("/hide_keyboard")) {
            // sent the "hide keyboard" message --> hide the reply keyboard
            myBot.removeReplyKeyboard(msg, "Reply keyboard removed");
            isKeyboardActive = false;
          } else {
            // print every others messages received
            myBot.sendMessage(msg, msg.text);
            //uint8_t banner_text[] = msg;
          }
        }

        // the user write anything else and the reply keyboard is not active --> show a hint message
        else {
          myBot.sendMessage(msg, "Try /reply_keyboard or /inline_keyboard");

          //uint8_t banner_text[] = "---------------";

          uint8_t banner_text[] = " ";

          size_t len = msgText.length();

          memcpy(banner_text, (uint8_t *)msgText.c_str(), len);

          led_matrix_puts(led_matrix_buffer, sizeof(led_matrix_buffer), banner_text);
          led_matrix_buffer_show(0, 510);
        }
        break;

      case MessageQuery:
        // received a callback query message
        msgText = msg.callbackQueryData;
        Serial.print("\nCallback query message received: ");
        Serial.println(msg.callbackQueryData);

        if (msgText.equalsIgnoreCase(LIGHT_ON_CALLBACK)) {
          // pushed "LIGHT ON" button...
          Serial.println("\nSet light ON");
          digitalWrite(LED_BUILTIN, HIGH);
          // terminate the callback with an alert message
          myBot.endQuery(msg, "Light on", true);
        } else if (msgText.equalsIgnoreCase(LIGHT_OFF_CALLBACK)) {
          // pushed "LIGHT OFF" button...
          Serial.println("\nSet light OFF");
          digitalWrite(LED_BUILTIN, LOW);
          // terminate the callback with a popup message
          myBot.endQuery(msg, "Light off");
        }
        break;

      case MessageLocation:
        {
          // received a location message
          String reply = "Longitude: ";
          reply += msg.location.longitude;
          reply += "; Latitude: ";
          reply += msg.location.latitude;
          Serial.println(reply);
          myBot.sendMessage(msg, reply);
          break;
        }

      case MessageContact:
        {
          // received a contact message
          String reply = "Contact information received:";
          reply += msg.contact.firstName;
          reply += " ";
          reply += msg.contact.lastName;
          reply += ", mobile ";
          reply += msg.contact.phoneNumber;
          Serial.println(reply);
          myBot.sendMessage(msg, reply);
          break;
        }

      default:
        break;
    }
  }
  // Scroll speed is determined by both scroll_speed and ontime.

  // Refresh display.
  led_matrix_buffer_show(scroll, ontime);

  // Update scroll position.
  if (millis() >= t_prev + scroll_speed) {
    t_prev = millis();
    scroll += 1;  // Scroll to the left.
    if (scroll > 5 * strlen((char *)banner_text)) {
      scroll = 0;  // restart
    }
  }
}

/* -------------------------------------------------------------------------- */
void printWifiStatus() {
  /* -------------------------------------------------------------------------- */
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your board's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

Posto anche il codice originale per far scorrere un testo, per chi ne avesse bisogno.

/*
 * Purpose: Display a text message scrolling from right to left 
 *          on the board's 8x12 LED matrix.
 * Board: Arduino UNO R4 WiFi
 * IDE: 1.8.19 with "Arduino Renesas Boards" version 0.8.5-ea
 *
 * Usage: Upload to the board and enjoy.
 * 
 * Provides many possibilities for doing things better and more efficiently.
 * Parts of this code work because of the way the display works. For instance,
 * there is no need to draw black pixels, only white pixels need drawing.
 * Naively porting this code to another kind of display will probably not work.
 * Buffer overflow protection is probably flawed, so don't count on it.
 *
 * By: Clemens Valens, Elektor
 * Date: 14/6/2023
 */

// Leading spaces ensure starting at the right.
uint8_t banner_text[] = "   testo scorrevole ";

// First value is the width of a character in columns. This allows for
// easy tight spacing on the display (TTF kind of thing).
const uint8_t font_5x8[] = 
{
  3, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, // space
  1, 0b01011111, 0b00000000, 0b00000000, 0b00000000, 0b00000000, // !
  3, 0b00000011, 0b00000000, 0b00000011, 0b00000000, 0b00000000, // "
  5, 0b00010100, 0b00111110, 0b00010100, 0b00111110, 0b00010100, // #
  4, 0b00100100, 0b01101010, 0b00101011, 0b00010010, 0b00000000, // $
  5, 0b01100011, 0b00010011, 0b00001000, 0b01100100, 0b01100011, // %
  5, 0b00110110, 0b01001001, 0b01010110, 0b00100000, 0b01010000, // &
  1, 0b00000011, 0b00000000, 0b00000000, 0b00000000, 0b00000000, // '
  3, 0b00011100, 0b00100010, 0b01000001, 0b00000000, 0b00000000, // (
  3, 0b01000001, 0b00100010, 0b00011100, 0b00000000, 0b00000000, // )
  5, 0b00101000, 0b00011000, 0b00001110, 0b00011000, 0b00101000, // * 
  5, 0b00001000, 0b00001000, 0b00111110, 0b00001000, 0b00001000, // +
  2, 0b10110000, 0b01110000, 0b00000000, 0b00000000, 0b00000000, // ,
  4, 0b00001000, 0b00001000, 0b00001000, 0b00001000, 0b00000000, // -
  2, 0b01100000, 0b01100000, 0b00000000, 0b00000000, 0b00000000, // .
  4, 0b01100000, 0b00011000, 0b00000110, 0b00000001, 0b00000000, // /
  4, 0b00111110, 0b01000001, 0b01000001, 0b00111110, 0b00000000, // 0
  3, 0b01000010, 0b01111111, 0b01000000, 0b00000000, 0b00000000, // 1
  4, 0b01100010, 0b01010001, 0b01001001, 0b01000110, 0b00000000, // 2
  4, 0b00100010, 0b01000001, 0b01001001, 0b00110110, 0b00000000, // 3
  4, 0b00011000, 0b00010100, 0b00010010, 0b01111111, 0b00000000, // 4
  4, 0b00100111, 0b01000101, 0b01000101, 0b00111001, 0b00000000, // 5
  4, 0b00111110, 0b01001001, 0b01001001, 0b00110000, 0b00000000, // 6
  4, 0b01100001, 0b00010001, 0b00001001, 0b00000111, 0b00000000, // 7
  4, 0b00110110, 0b01001001, 0b01001001, 0b00110110, 0b00000000, // 8
  4, 0b00000110, 0b01001001, 0b01001001, 0b00111110, 0b00000000, // 9
  2, 0b01010000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, // :
  2, 0b10000000, 0b01010000, 0b00000000, 0b00000000, 0b00000000, // ;
  3, 0b00010000, 0b00101000, 0b01000100, 0b00000000, 0b00000000, // <
  3, 0b00010100, 0b00010100, 0b00010100, 0b00000000, 0b00000000, // =
  3, 0b01000100, 0b00101000, 0b00010000, 0b00000000, 0b00000000, // >
  4, 0b00000010, 0b01011001, 0b00001001, 0b00000110, 0b00000000, // ?
  5, 0b00111110, 0b01001001, 0b01010101, 0b01011101, 0b00001110, // @
  4, 0b01111110, 0b00010001, 0b00010001, 0b01111110, 0b00000000, // A
  4, 0b01111111, 0b01001001, 0b01001001, 0b00110110, 0b00000000, // B
  4, 0b00111110, 0b01000001, 0b01000001, 0b00100010, 0b00000000, // C
  4, 0b01111111, 0b01000001, 0b01000001, 0b00111110, 0b00000000, // D
  4, 0b01111111, 0b01001001, 0b01001001, 0b01000001, 0b00000000, // E
  4, 0b01111111, 0b00001001, 0b00001001, 0b00000001, 0b00000000, // F
  4, 0b00111110, 0b01000001, 0b01001001, 0b01111010, 0b00000000, // G
  4, 0b01111111, 0b00001000, 0b00001000, 0b01111111, 0b00000000, // H
  3, 0b01000001, 0b01111111, 0b01000001, 0b00000000, 0b00000000, // I
  4, 0b00110000, 0b01000000, 0b01000001, 0b00111111, 0b00000000, // J
  4, 0b01111111, 0b00001000, 0b00010100, 0b01100011, 0b00000000, // K
  4, 0b01111111, 0b01000000, 0b01000000, 0b01000000, 0b00000000, // L
  5, 0b01111111, 0b00000010, 0b00001100, 0b00000010, 0b01111111, // M
  5, 0b01111111, 0b00000100, 0b00001000, 0b00010000, 0b01111111, // N
  4, 0b00111110, 0b01000001, 0b01000001, 0b00111110, 0b00000000, // O
  4, 0b01111111, 0b00001001, 0b00001001, 0b00000110, 0b00000000, // P
  4, 0b00111110, 0b01000001, 0b01000001, 0b10111110, 0b00000000, // Q
  4, 0b01111111, 0b00001001, 0b00001001, 0b01110110, 0b00000000, // R
  4, 0b01000110, 0b01001001, 0b01001001, 0b00110010, 0b00000000, // S
  5, 0b00000001, 0b00000001, 0b01111111, 0b00000001, 0b00000001, // T
  4, 0b00111111, 0b01000000, 0b01000000, 0b00111111, 0b00000000, // U
  5, 0b00001111, 0b00110000, 0b01000000, 0b00110000, 0b00001111, // V
  5, 0b00111111, 0b01000000, 0b00111000, 0b01000000, 0b00111111, // W
  5, 0b01100011, 0b00010100, 0b00001000, 0b00010100, 0b01100011, // X
  5, 0b00000111, 0b00001000, 0b01110000, 0b00001000, 0b00000111, // Y
  4, 0b01100001, 0b01010001, 0b01001001, 0b01000111, 0b00000000, // Z
  2, 0b01111111, 0b01000001, 0b00000000, 0b00000000, 0b00000000, // [
  4, 0b00000001, 0b00000110, 0b00011000, 0b01100000, 0b00000000, // '\'
  2, 0b01000001, 0b01111111, 0b00000000, 0b00000000, 0b00000000, // ]
  3, 0b00000010, 0b00000001, 0b00000010, 0b00000000, 0b00000000, // hat
  4, 0b01000000, 0b01000000, 0b01000000, 0b01000000, 0b00000000, // _
  2, 0b00000001, 0b00000010, 0b00000000, 0b00000000, 0b00000000, // `
  4, 0b00100000, 0b01010100, 0b01010100, 0b01111000, 0b00000000, // a
  4, 0b01111111, 0b01000100, 0b01000100, 0b00111000, 0b00000000, // b
  4, 0b00111000, 0b01000100, 0b01000100, 0b00000000, 0b00000000, // c
  4, 0b00111000, 0b01000100, 0b01000100, 0b01111111, 0b00000000, // d
  4, 0b00111000, 0b01010100, 0b01010100, 0b00011000, 0b00000000, // e
  3, 0b00000100, 0b01111110, 0b00000101, 0b00000000, 0b00000000, // f
  4, 0b10011000, 0b10100100, 0b10100100, 0b01111000, 0b00000000, // g
  4, 0b01111111, 0b00000100, 0b00000100, 0b01111000, 0b00000000, // h
  3, 0b01000100, 0b01111101, 0b01000000, 0b00000000, 0b00000000, // i
  4, 0b01000000, 0b10000000, 0b10000100, 0b01111101, 0b00000000, // j
  4, 0b01111111, 0b00010000, 0b00101000, 0b01000100, 0b00000000, // k
  3, 0b01000001, 0b01111111, 0b01000000, 0b00000000, 0b00000000, // l
  5, 0b01111100, 0b00000100, 0b01111100, 0b00000100, 0b01111000, // m
  4, 0b01111100, 0b00000100, 0b00000100, 0b01111000, 0b00000000, // n
  4, 0b00111000, 0b01000100, 0b01000100, 0b00111000, 0b00000000, // o
  4, 0b11111100, 0b00100100, 0b00100100, 0b00011000, 0b00000000, // p
  4, 0b00011000, 0b00100100, 0b00100100, 0b11111100, 0b00000000, // q
  4, 0b01111100, 0b00001000, 0b00000100, 0b00000100, 0b00000000, // r
  4, 0b01001000, 0b01010100, 0b01010100, 0b00100100, 0b00000000, // s
  3, 0b00000100, 0b00111111, 0b01000100, 0b00000000, 0b00000000, // t
  4, 0b00111100, 0b01000000, 0b01000000, 0b01111100, 0b00000000, // u
  5, 0b00011100, 0b00100000, 0b01000000, 0b00100000, 0b00011100, // v
  5, 0b00111100, 0b01000000, 0b00111100, 0b01000000, 0b00111100, // w
  5, 0b01000100, 0b00101000, 0b00010000, 0b00101000, 0b01000100, // x
  4, 0b10011100, 0b10100000, 0b10100000, 0b01111100, 0b00000000, // y
  3, 0b01100100, 0b01010100, 0b01001100, 0b00000000, 0b00000000, // z
  3, 0b00001000, 0b00110110, 0b01000001, 0b00000000, 0b00000000, // {
  1, 0b01111111, 0b00000000, 0b00000000, 0b00000000, 0b00000000, // |
  3, 0b01000001, 0b00110110, 0b00001000, 0b00000000, 0b00000000, // }
  4, 0b00001000, 0b00000100, 0b00001000, 0b00000100, 0b00000000, // ~
};

// LED matrix info.
const uint8_t led_matrix_pin_first = 28;
const uint8_t led_matrix_pin_last = 38;
const uint8_t led_matrix_pin_count = led_matrix_pin_last - led_matrix_pin_first + 1;
const uint8_t led_matrix_rows = 8;
const uint8_t led_matrix_cols = 12;

// Pixel-to-pin translation table.
// A HEX value encodes two pin numbers. The MSB is to be driven LOW,
// the LSB is to be driven HIGH.
// Example: pixel (4,2) contains the value 0x60, meaning that pin 6 must
// be driven low and pin 0 must be driven high to activate the pixel.
// The pin number is an offset to the constant led_matrix_pin_first
// Note that they all appear in pairs, so you could make the table 50%
// smaller at the cost of doing some swapping for odd or even columns.
// (0,0) is upper left corner when the board's USB connector points to the left.
const uint8_t led_matrix_pins[led_matrix_rows][led_matrix_cols] =
{
  //  0     1     2     3     4     5     6     7     8     9    10     11
  { 0x37, 0x73, 0x47, 0x74, 0x43, 0x34, 0x87, 0x78, 0x83, 0x38, 0x84, 0x48 }, // 0
  { 0x07, 0x70, 0x03, 0x30, 0x04, 0x40, 0x08, 0x80, 0x67, 0x76, 0x63, 0x36 }, // 1
  { 0x64, 0x46, 0x68, 0x86, 0x60, 0x06, 0x57, 0x75, 0x53, 0x35, 0x54, 0x45 }, // 2
  { 0x58, 0x85, 0x50, 0x05, 0x56, 0x65, 0x17, 0x71, 0x13, 0x31, 0x14, 0x41 }, // 3
  { 0x18, 0x81, 0x10, 0x01, 0x16, 0x61, 0x15, 0x51, 0x27, 0x72, 0x23, 0x32 }, // 4
  { 0x24, 0x42, 0x28, 0x82, 0x20, 0x02, 0x26, 0x62, 0x25, 0x52, 0x21, 0x12 }, // 5
  { 0xa7, 0x7a, 0xa3, 0x3a, 0xa4, 0x4a, 0xa8, 0x8a, 0xa0, 0x0a, 0xa6, 0x6a }, // 6
  { 0xa5, 0x5a, 0xa1, 0x1a, 0xa2, 0x2a, 0x97, 0x79, 0x93, 0x39, 0x94, 0x49 }, // 7
};

// Every byte represents a column of the LED matrix.
// Can hold 32 5x8-font characters.
// Buffer can be smaller at the price of more code.
uint8_t led_matrix_buffer[5*128];

// Activate the pixel at (x,y) for ontime microseconds.
void put_pixel(uint8_t x, uint8_t y, uint32_t ontime)
{
  uint8_t pins = led_matrix_pins[y][x];
  uint8_t l = (pins>>4) + led_matrix_pin_first;
  uint8_t h = (pins&0xf) + led_matrix_pin_first;
  pinMode(l,OUTPUT);
  digitalWrite(l,LOW);
  pinMode(h,OUTPUT);
  digitalWrite(h,HIGH);
  // If ontime = 0, pixel remains active until it is deactivated
  // by another put_pixel that happens to use the same pin(s).
  if (ontime!=0)
  {
    delayMicroseconds(ontime);
    pinMode(l,INPUT);
    pinMode(h,INPUT);
  }
}

// Call periodically at desired fps rate.
// ontime specifies how long a pixel remains on.
void led_matrix_buffer_show(uint32_t x_offset, uint32_t ontime)
{
  for (uint8_t i=0; i<led_matrix_cols; i++)
  {
    if (i+x_offset>=sizeof(led_matrix_buffer)) return;
    uint8_t col = led_matrix_buffer[i+x_offset];
    for (uint8_t row=0; row<led_matrix_rows; row++)
    {
      if ((col&0x01)!=0)
      {
        put_pixel(i,row,ontime);
      }
      col >>= 1;
    }
  }
}

// Write a character to the buffer.
uint8_t led_matrix_putch(uint8_t *p_buffer, uint16_t buffer_size, uint8_t ch)
{
  uint8_t i;
  
  if (ch<' ') return 0;
  ch -= ' ';
  uint16_t offset = 6*ch;
  uint8_t width = font_5x8[offset];
  for (i=0; i<width; i++) 
  { 
    offset += 1;
    // This is supposed to prevent buffer overflow.
    if (i>=buffer_size) break;
    p_buffer[i] = font_5x8[offset];
  }
  return i+1;
}

// Write a string to the buffer.
uint16_t led_matrix_puts(uint8_t *p_buffer, uint16_t buffer_size, uint8_t *p_str)
{
  uint8_t *p = p_buffer;
  while (*p_str!=0)
  {
    p += led_matrix_putch(p,buffer_size-(p-p_buffer),*p_str);
    p_str++;
  }
  return p - p_buffer;
}

uint32_t t_prev = 0;

void setup(void)
{
  // Initialize LED matrix pins.
  for (uint8_t i=0; i<led_matrix_pin_count; i++)
  {
    pinMode(led_matrix_pin_first+i,INPUT); // all off
  }
  // Load text message.
  led_matrix_puts(led_matrix_buffer,sizeof(led_matrix_buffer),banner_text);
  // Ready...
  t_prev = millis();
  // Go!
}

void loop(void)
{
  // Scroll speed is determined by both scroll_speed and ontime.
  const uint8_t scroll_speed = 50; // milliseconds
  const uint16_t ontime = 521; // microseconds. 521 (us) * 96 (pixels) = 50 ms frame rate if all the pixels are on.
  static uint8_t scroll = 0; // scroll position.

  // Refresh display.
  led_matrix_buffer_show(scroll,ontime);

  // Update scroll position.
  if (millis()>=t_prev+scroll_speed)
  {
    t_prev = millis();
    scroll += 1; // Scroll to the left.
    if (scroll>5*strlen((char*)banner_text)) {
      scroll = 0; // restart
      }
  }
}

L'unica istruzione attinente alla libreria che c'è poco prima che va in crash è questa:


myBot.endQuery(msg, "Light on", true);

Se la commenti cosa succede?
Anzi, se abiliti il log di debug della libreria sarebbe ancora meglio anche se ho già una mezza idea di cosa potrebbe essere a mandare in crisi il micro (l'istruzione snprintf() che si potrebbe sostituire con altro a dire il vero).

Se riesci prova a modificarla in questo modo:

bool AsyncTelegram2::endQuery(const TBMessage &msg, const char *message, bool alertMode)
{
    if (!msg.callbackQueryID)
        return false;
  
    DynamicJsonDocument root(m_JsonBufferSize);
    root["callback_query_id"] = msg.callbackQueryID;
    root["text"] = message;
    root["cache_time"] = 2;
    root["show_alert"] = alertMode ? "true" : "false";
    root.shrinkToFit();

    size_t len = measureJson(root);
    char payload[len];
    serializeJson(root, payload, len);

    debugJson(root, Serial);
    return sendCommand("answerCallbackQuery", payload, true);
}

Funziona!!!

Commentando la linea non si bloccava, quindi ho cercato il file asynctelegram2.cpp e rimpiazzato la endquery.

Risultato non va piu' in crash e appare un popup con scritto light on.
Il led si accende e spegne regolarmente.

Ma a tuo avviso e' un problema della scheda R4 oppure era proprio un bug della libreria?
Sarebbe forse da modificare la libreria ufficiale in questo modo ?

Rimane solo il problema della stringa che si "mergia" invece di sostituirsi...

Per risolvere questo problema devi vedere in modo approfondito come funziona il codice per la matrice led; magari c'è bisogno di invocare qualche funzione "di pulizia" prima di scrivere nuovamente nel buffer.

La libreria ha sempre funzionato con il metodo originario. L'ho testata su diversi microcontrollori fino ad ora (ESP32, ESP8266, RP2040, STM32, Arduino Nano 33 etc etc).

Evidentemente il framework per la R4 non gradisce l'istruzione snprintf() per qualche ragione a me sconosciuta e purtroppo non ho una scheda per fare delle prove.

Ad ogni modo farò una revisione di tutti i metodi della libreria uniformando un po' tutto con le istruzioni più "safe" possibili e poi rilascerò una nuova versione aggiornata.

Grazie per il tuo prezioso feedback!

Prova cosi:

          uint8_t banner_text[led_matrix_buffer] = {0};  // Inizializza banner_text con dei null chars

          size_t len = msgText.length();
          memcpy(banner_text, (uint8_t *)msgText.c_str(), len);
          led_matrix_puts(led_matrix_buffer, sizeof(led_matrix_buffer), banner_text);
          led_matrix_buffer_show(0, 510);

Hai fatto tutto te... :blush:

la modifica dava questo errore

\r4_telegram_testo_06.ino: In function 'void loop()':
\r4_telegram_testo_06.ino:424:47: error: size of array 'banner_text' has non-integral type 'uint8_t [640] {aka unsigned char [640]}'
          uint8_t banner_text[led_matrix_buffer] = {0};  // Inizializza banner_text con dei null chars
                                               ^
exit status 1

Compilation error: size of array 'banner_text' has non-integral type 'uint8_t [640] {aka unsigned char [640]}'

Ho provato in tutti i modi a risolvere l'ultimo arcano ma non riesco per ora.
Anche il reset "manuale"..

  for (uint8_t i = 0; i < 640; i++) {
       banner_text[i] = 0 ;  // all off
          }     

Purtroppo sono anni di vbstudio, mi sono rovinato....

Mea culpa, non si può inizializzare in questo modo un array per il quale è stata definita una dimensione (avrei dovuto mettere 640 volte 0).

Il ciclo for lo puoi sostituire con un memset, ma invece di riempire il buffer con dei null char, prova a mettere degli spazi cosi da "forzare" un carattere che non dovrebbe accendere nessun led.

memset(banner_text, ' ', sizeof(banner_text));
1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.