Hallo.
Sorry..das macht natürlich sinn.
Ich nutze als alternativer Stromversorgung ein Labornetzteil mir 2 USB Ausgängen. Das sollte genug Power haben.
Anbei mein Code:
--------------------------
#include <PxMatrix.h>
#include "ESP8266WiFi.h"
#ifdef ESP32
#define P_LAT 22
#define P_A 19
#define P_B 23
#define P_C 18
#define P_D 5
#define P_E 15
#define P_OE 2
hw_timer_t * timer = NULL;
portMUX_TYPE timerMux = portMUX_INITIALIZER_UNLOCKED;
#endif
#ifdef ESP8266
#include <Ticker.h>
Ticker display_ticker;
#define P_LAT 16
#define P_A 5
#define P_B 4
#define P_C 15
#define P_D 12
#define P_E 0
#define P_OE 2
#endif
// Pins for LED MATRIX
uint8_t display_draw_time=0;
//PxMATRIX display(32,16,P_LAT, P_OE,P_A,P_B,P_C);
//PxMATRIX display(64,32,P_LAT, P_OE,P_A,P_B,P_C,P_D);
PxMATRIX display(64,32,P_LAT, P_OE,P_A,P_B,P_C,P_D,P_E);
//PxMATRIX display(128,32,P_LAT, P_OE,P_A,P_B,P_C,P_D,P_E);
// Some standard colors
uint16_t myRED = display.color565(255, 0, 0);
uint16_t myGREEN = display.color565(0, 255, 0);
uint16_t myBLUE = display.color565(0, 0, 255);
uint16_t myWHITE = display.color565(255, 255, 255);
uint16_t myYELLOW = display.color565(255, 255, 0);
uint16_t myCYAN = display.color565(0, 255, 255);
uint16_t myMAGENTA = display.color565(255, 0, 255);
uint16_t myBLACK = display.color565(0, 0, 0);
uint8_t ATop = 0;
uint8_t ALeft = 0;
uint8_t BTop = 0;
uint8_t BLeft = 32;
uint8_t CTop = 16;
uint8_t CLeft = 0;
uint8_t DTop = 16;
uint8_t DLeft = 32;
uint16_t myCOLORS[8]={myRED,myGREEN,myBLUE,myWHITE,myYELLOW,myCYAN,myM AGENTA,myBLACK};
const char* ssid = "mySSID";
const char* password = "myPASSWORD";
WiFiServer wifiServer(80);
#ifdef ESP8266
// ISR for display refresh
void display_updater()
{
display.display(display_draw_time);
}
#endif
#ifdef ESP32
void IRAM_ATTR display_updater(){
// Increment the counter and set the time of ISR
portENTER_CRITICAL_ISR(&timerMux);
display.display(display_draw_time);
portEXIT_CRITICAL_ISR(&timerMux);
}
#endif
void display_update_enable(bool is_enable)
{
#ifdef ESP8266
if (is_enable)
display_ticker.attach(0.002, display_updater);
else
display_ticker.detach();
#endif
#ifdef ESP32
if (is_enable)
{
timer = timerBegin(0, 80, true);
timerAttachInterrupt(timer, &display_updater, true);
timerAlarmWrite(timer, 2000, true);
timerAlarmEnable(timer);
}
else
{
timerDetachInterrupt(timer);
timerAlarmDisable(timer);
}
#endif
}
void aufteilung(uint8_t draw_time)
{
display.display(draw_time);
display.clearDisplay();
for (uint8_t x=0; x<64; x++){
display.drawPixel(x, 15, myBLUE);
display.drawPixel(x, 16, myBLUE);
}
for (uint8_t x=0; x<32; x++){
display.drawPixel(31, x, myBLUE);
display.drawPixel(32, x, myBLUE);
}
for (uint8_t x=0; x<32; x++){
display.drawPixel(0, x, myBLUE);
display.drawPixel(63, x, myBLUE);
}
for (uint8_t x=0; x<64; x++){
display.drawPixel(x, 0, myBLUE);
display.drawPixel(x, 31, myBLUE);
}
display_update_enable(true);
display.setBrightness(255);
yield();
}
void clearScore(String gruppe){
uint8_t left =0;
uint8_t top =0;
if(gruppe == "A"){
left = ALeft;
top=ATop;
}
if(gruppe == "B"){
left = BLeft;
top=BTop;
}
if(gruppe == "C"){
left = CLeft;
top = CTop;
}
if(gruppe == "D"){
left = DLeft;
top = DTop;
}
uint8_t x = 0;
uint8_t y = 0;
for (x=(left+1); x<(left+31); x++){
for (y=(top+1); y<(top+15); y++){
display.drawPixel(x, y, myBLACK);
}
}
display_update_enable(true);
yield();
}
void displayScore(String gruppe, String punkte ){
display.setTextSize(1);
display.setTextColor(myRED);
uint8_t left =0;
uint8_t top =0;
if(gruppe == "A"){
left = ALeft;
top=ATop;
}
if(gruppe == "B"){
left = BLeft;
top=BTop;
}
if(gruppe == "C"){
left = CLeft;
top = CTop;
}
if(gruppe == "D"){
left = DLeft;
top = DTop;
}
display.setCursor(left+3,top+4);
display.print(gruppe);
display.setTextColor(myWHITE);
display.setCursor(left+3+8,top+4);
display.print(punkte);
display_update_enable(true);
yield();
}
void displayIP(String ip){
display.display(0);
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(myRED);
display.setCursor(1,4);
display.print("IP Adresse");
display.setTextColor(myWHITE);
display.setCursor(1,11);
display.print(ip);
display_update_enable(true);
yield();
}
void setup() {
Serial.begin(115200);
delay(1000);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting..");
}
Serial.print("Connected to WiFi. IP:");
Serial.println(WiFi.localIP());
wifiServer.begin();
// Define your display layout here, e.g. 1/8 step
display.begin(16);
display.setFastUpdate(true);
display_draw_time=0;
displayIP(WiFi.localIP().toString());
delay(5000);
aufteilung(display_draw_time);
displayScore("A", "___");
displayScore("B", "___");
displayScore("C", "___");
displayScore("D", "___");
delay(5000);
clearScore("D");
displayScore("D", "225");
}
void loop() {
WiFiClient client = wifiServer.available();
if (client) {
while (client.connected()) {
while (client.available()>0) {
char c = client.read();
Serial.write(c);
}
delay(10);
}
client.stop();
Serial.println("Client disconnected");
}
}
---------------------
Lesezeichen