Hallo zusammen
ich steh einmal mehr an:) Frage in die Runde.
Ich hatte ein 16bit Bitmap und nun wollte ich es auf 8bit umstellen, da 16bit Converter nicht mehr findbar (schäm).
Habe ein 8bit .h file, aber bekomme es nicht mehr hin im Projekt.
gfx->draw16RGBBitmap(0, 0, (uint8_t*)hgrund,480,480);
und drawRGBBitmap kennt er nicht....oder mache was falsch.
Codeauszug (weil zu gross) für das Bild:
#include <stdint.h>
const uint8_t hgrund[] = {
0xf8, 0xff, 0xf8, 0xff, 0xf8, 0xff, 0xf8, 0xff, 0xf8, 0xff,
0xf8, 0xff, 0xf8, 0xff, 0xf8, 0xff, 0xf8, 0xff, 0xf8, 0xff,
0xf8, 0xff, 0xf8, 0xff, 0xf8, 0xff, 0xf8, 0xff, 0xf8, 0xff,
0xf8, 0xff, 0xf8, 0xff, 0xf8, 0xff, 0xf8, 0xff, 0xf8, 0xff,
Code
#include <PubSubClient.h> //mqtt
#include <WiFi.h>
#include <Arduino_GFX_Library.h>
#include "HWCDC.h"
//#include <stdint.h>
#include <background.c>
#include "secrets.h"
HWCDC USBSerial;
Arduino_DataBus *bus = new Arduino_SWSPI(
GFX_NOT_DEFINED /* DC */, 42 /* CS */,
2 /* SCK */, 1 /* MOSI */, GFX_NOT_DEFINED /* MISO */);
Arduino_ESP32RGBPanel *rgbpanel = new Arduino_ESP32RGBPanel(
40 /* DE */, 39 /* VSYNC */, 38 /* HSYNC */, 41 /* PCLK */,
46 /* R0 */, 3 /* R1 */, 8 /* R2 */, 18 /* R3 */, 17 /* R4 */,
14 /* G0 */, 13 /* G1 */, 12 /* G2 */, 11 /* G3 */, 10 /* G4 */, 9 /* G5 */,
5 /* B0 */, 45 /* B1 */, 48 /* B2 */, 47 /* B3 */, 21 /* B4 */,
1 /* hsync_polarity */, 10 /* hsync_front_porch */, 8 /* hsync_pulse_width */, 50 /* hsync_back_porch */,
1 /* vsync_polarity */, 10 /* vsync_front_porch */, 8 /* vsync_pulse_width */, 20 /* vsync_back_porch */);
Arduino_RGB_Display *gfx = new Arduino_RGB_Display(
480 /* width */, 480 /* height */, rgbpanel, 2 /* rotation */, true /* auto_flush */,
bus, GFX_NOT_DEFINED /* RST */, st7701_type1_init_operations, sizeof(st7701_type1_init_operations));
// Set your Static IP address
IPAddress local_IP(192, 168, 178, 111);
IPAddress gateway(192, 168, 178, 1);
IPAddress subnet(255, 255, 255, 0);
IPAddress primaryDNS(192,168,178,1);
const char* ssid = SECRET_SSID;
const char* password = SECRET_PASS;
//mqtt
const char broker[] = "192.168.178.230";
int port = 1883;
const char topic[] = "globaledaten";
//EthernetClient ethClient;
WiFiClient espClient;
PubSubClient client(espClient);
long lastMsg = 0;
char msg[50];
int value = 0;
void setup(void)
{
USBSerial.begin(115200);
USBSerial.println("begin....");
if (!gfx->begin()) USBSerial.println("gfx->begin() failed!");
//gfx->draw16bitRGBBitmap(0, 0, (uint16_t*)hgrund,480,480);
gfx->draw16RGBBitmap(0, 0, (uint8_t*)hgrund,480,480);
//gfx->schriftgrösse einstellen
gfx->setTextSize(1);
//gfx->fillScreen(RGB565_BLACK);
gfx->setTextColor(RGB565_WHITE);
//wifi-------------------------------------------------------------------------
// WIFI Configures static IP address
if (!WiFi.config(local_IP, gateway, subnet, primaryDNS)) {
gfx->setCursor(50, 10); gfx->println("WiFi Settings failed!");
USBSerial.println("WiFi Settings failed!");
}
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
gfx->setCursor(50, 10); gfx->setTextColor(RGB565_BLACK,RGB565_WHITE); gfx->println("Connecting to WiFi... ");
USBSerial.println("Connecting to WiFi..");
delay(1000);
}
if (WiFi.isConnected()){
//wlan connected
gfx->setCursor(50, 10); gfx->setTextColor(RGB565_BLACK,RGB565_WHITE); gfx->println("Connected to WiFi ");
USBSerial.println("Connected to WiFi");
}
else
{
//wlan disconnected
gfx->setCursor(50, 10); gfx->setTextColor(RGB565_BLACK,RGB565_WHITE); gfx->println("Connected to WiFi failed!");
USBSerial.println("Connecting to WiFi failed*");
}
//mqtt
client.setServer(broker, port);
client.setCallback(callback);
//gfx->fillScreen(RGB565_BLACK);
gfx->setTextColor(RGB565_WHITE);
}
void callback(char* topic, byte* payload, unsigned int length) {
gfx->setTextSize(3);gfx->setTextColor(RGB565_BLACK,RGB565_WHITE);
String mqttmsg;
USBSerial.print("Message arrived on topic: ");
USBSerial.print(topic);
for (int i = 0; i < length; i++) {
mqttmsg += (char) payload[i];
}
if (strcmp(topic, "globaledaten/pvtotalleistung") == 0) {gfx->setTextColor(RGB565_BLACK,RGB565_WHITE);gfx->setCursor(40, 347);gfx->println(mqttmsg);}
if (strcmp(topic, "globaledaten/batterieleistung") == 0) {gfx->setTextColor(RGB565_BLACK,RGB565_WHITE);gfx->setCursor(238, 380);gfx->println(mqttmsg);}
if (strcmp(topic, "globaledaten/batterieSOC") == 0) {gfx->setTextColor(RGB565_BLACK,RGB565_GREEN);gfx->setCursor(238, 300);gfx->println(mqttmsg);}
if (strcmp(topic, "globaledaten/shellyleistungsmessung") == 0) {gfx->setTextColor(RGB565_BLACK,RGB565_WHITE);gfx->setCursor(238, 440);gfx->println(mqttmsg);}
if (strcmp(topic, "globaledaten/temperatur") == 0) {gfx->setTextColor(RGB565_BLACK,RGB565_WHITE);gfx->setCursor(70, 70);gfx->println(mqttmsg);}
if (strcmp(topic, "globaledaten/windaktuell") == 0) {gfx->setTextColor(RGB565_BLACK,RGB565_WHITE);gfx->setCursor(200, 70);gfx->println(mqttmsg);}
if (strcmp(topic, "globaledaten/windmaximum") == 0) {gfx->setTextColor(RGB565_BLACK,RGB565_WHITE);gfx->setCursor(344, 70);gfx->println(mqttmsg);}
if (strcmp(topic, "globaledaten/boilertemperatur") == 0) {gfx->setTextColor(RGB565_BLACK,RGB565_WHITE);gfx->setCursor(375, 110);gfx->println(mqttmsg);}
//if (strcmp(topic, "globaledaten/boilerladeleistung") == 0) {gfx->setTextColor(RGB565_BLACK,RGB565_WHITE);gfx->setCursor(375, 0);gfx->println(mqttmsg);}
USBSerial.println(mqttmsg);
}
void reconnect() {
gfx->setTextSize(1);gfx->setTextColor(RGB565_BLACK,RGB565_WHITE);
// Loop until we're reconnected
while (!client.connected()) {
USBSerial.print("Attempting MQTT connection...");
gfx->setCursor(50, 20); gfx->setTextColor(RGB565_BLACK,RGB565_WHITE); gfx->println("Attempting MQTT connection...");
// Attempt to connect
if (client.connect("Globaldata")) {
USBSerial.println("connected");
gfx->setCursor(50, 20); gfx->setTextColor(RGB565_BLACK,RGB565_WHITE); gfx->println("MQTT connected. ");
// Subscribe
client.subscribe("globaledaten/pvtotalleistung");
client.subscribe("globaledaten/batterieleistung");
client.subscribe("globaledaten/batterieSOC");
client.subscribe("globaledaten/shellyleistungsmessung");
client.subscribe("globaledaten/temperatur");
client.subscribe("globaledaten/windaktuell");
client.subscribe("globaledaten/windmaximum");
client.subscribe("globaledaten/boilertemperatur");
//client.subscribe("globaledaten/boilerladeleistung");
} else {
USBSerial.print("failed, rc=");
USBSerial.print(client.state());
USBSerial.println(" try again in 5 seconds");
// Wait 5 seconds before retrying
delay(2000);
}
}
}
void loop()
{
if (!client.connected()) reconnect();
client.loop();
delay(100); // 5 seconds
}
Wäre sehr dankbar für eine Lösung ... nach 2Stunden weiss ich nicht mehr weiter.
