Good morning,
I purchased a ESP32-2432S028R which has an ESP32-wroom_32, 2.8" display with ILI9341 driver.
I would like to see on the screen the color of each pixel that I receive in OSC.
I send the 3 data R, G, B at 254*128 pixels.
What is the correct function to use from the TFT_eSPI library?
Here the program I made but I can only see a white mouvement on the screen.
#include <OSCBoards.h>
#include <OSCBundle.h>
#include <OSCData.h>
#include <OSCMatch.h>
#include <OSCMessage.h>
#include <OSCTiming.h>
#include <SLIPEncodedSerial.h>
/*---------------------------------------------------------------------------------------------
Open Sound Control (OSC) library for the ESP8266/ESP32
Example for receiving open sound control (OSC) messages on the ESP8266/ESP32
Send integers '0' or '1' to the address "/led" to turn on/off the built-in LED of the esp8266.
This example code is in the public domain.
--------------------------------------------------------------------------------------------- */
#include <WiFi.h>
#include <WiFiUdp.h>
#include <OSCMessage.h>
#include <OSCBundle.h>
#include <OSCData.h>
#include <WiFiMulti.h>
WiFiMulti wifiMulti;
#include <TFT_eSPI.h>
TFT_eSPI tft = TFT_eSPI();
#define BLACK 0x0000
#define WHITE 0xFFFF
WiFiUDP Udp;
const unsigned int outPort = 9999; // remote port (not needed for receive)
const unsigned int localPort = 8004; // local port to listen for UDP packets (here's where we send the packets)
OSCErrorCode error;
unsigned int ledState = LOW; // LOW means led is *on*. not use
//------------ END ESP and OSC setting
#define LED_BUILTIN 16
#define BUILTIN_LED LED_BUILTIN
int numberOfPIXELS = 254*128;
#define numberOfpixels numberOfPIXELS// 64
int size;
void setup() {
//tft.init();
//tft.fillScreen(TFT_BLACK); // Background is black
Serial.begin(115200);
pinMode(BUILTIN_LED, OUTPUT);
digitalWrite(BUILTIN_LED, ledState); // turn *on* led
delay(10);
// Connect to the best WiFi network
wifiMulti.addAP("SFR_A080_EXT", "rtws8bze84czbb5aat33"); // Loic
wifiMulti.addAP("E5576_BD52_EXT", "564d76L4Mbm"); // miniBox
Serial.println("Connecting Wifi...");
if(wifiMulti.run() == WL_CONNECTED)
{
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
IPAddress local_IP(192, 168, 8, 104);// 145
// Set your Gateway IP address
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 0, 0);
WiFi.mode(WIFI_STA);
if (WiFi.config(local_IP, gateway, subnet) == false) {
Serial.print("echec de config");
}
while (WiFi.status() != WL_CONNECTED) {
//// digitalWrite(BUILTIN_LED, HIGH); // turn *on* led
delay(500);
digitalWrite(BUILTIN_LED, LOW); // turn *on* led
Serial.print(".");
}
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
Serial.println("Starting UDP");
Udp.begin(localPort);
Serial.print("Local port: ");
#ifdef ESP32
Serial.print("LocalportESP32: ");
Serial.println(localPort);
#else
Serial.println(Udp.localPort());
#endif
// turn off led when connected to a wifi network
digitalWrite(BUILTIN_LED, HIGH); // turn off* led
}
void loop() {
OSCMessage msg;
size = Udp.parsePacket();
if (size > 0) {
while (size--) {
msg.fill(Udp.read());
}
if (!msg.hasError()) {
msg.dispatch("/matrixdata",assignDataParsed); //
}
else {
error = msg.getError();
Serial.print("error: ");
Serial.println(error);
}
}
}
void assignDataParsed(OSCMessage &msg) {
for (uint8_t i = 0; i < numberOfpixels; i++) {
tft.drawPixel(msg.getInt(i*3+0), i, WHITE);
}
}