zwei Panels synchron angesteuert

This commit is contained in:
enny 2019-12-13 23:10:20 +01:00
parent db9f11f5ee
commit 8706e6dbb5
4 changed files with 34 additions and 23 deletions

View File

@ -16,7 +16,8 @@ IPAddress subnet(255, 255, 254, 0);
WebSocketsServer webSocket = WebSocketsServer(81); WebSocketsServer webSocket = WebSocketsServer(81);
Image image; Image image;
Panel panel; Panel panel1(22, 24, 23); //data, clock, load
Panel panel2(28, 29, 31);
ProtocolDL protocol = ProtocolDL(image); ProtocolDL protocol = ProtocolDL(image);
unsigned long last_activity = 0; unsigned long last_activity = 0;
@ -73,7 +74,8 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length
if(protocol.isComplete()) if(protocol.isComplete())
{ {
Serial.println("complete"); Serial.println("complete");
panel.send_image(&image); panel1.send_image(&image);
panel2.send_image(&image);
} }
break; break;
@ -106,7 +108,8 @@ void setup() {
webSocket.begin(); webSocket.begin();
webSocket.onEvent(webSocketEvent); webSocket.onEvent(webSocketEvent);
panel.init(); panel1.init();
panel2.init();
Serial.println("setup done"); Serial.println("setup done");
} }
@ -139,6 +142,7 @@ void loop() {
if (someOneIsConnected == false) { if (someOneIsConnected == false) {
default_image(&image); default_image(&image);
panel.send_image(&image); panel1.send_image(&image);
panel2.send_image(&image);
} }
} }

Binary file not shown.

View File

@ -1,14 +1,17 @@
#include "panel.hpp" #include "panel.hpp"
#define LOAD 7 Panel::Panel(uint8_t pData, uint8_t pClock, uint8_t pLoad)
#define DATA 8 {
#define CLOCK 9 pinData = pData;
pinLoad = pLoad;
pinClock = pClock;
}
void Panel::init() void Panel::init()
{ {
pinMode(DATA, OUTPUT); pinMode(pinData, OUTPUT);
pinMode(CLOCK, OUTPUT); pinMode(pinClock, OUTPUT);
pinMode(LOAD, OUTPUT); pinMode(pinLoad, OUTPUT);
} }
void Panel::send_image(Image* img) { void Panel::send_image(Image* img) {
@ -23,17 +26,17 @@ void Panel::send_image(Image* img) {
void Panel::clock() { void Panel::clock() {
PORTH |= (1 << PH6); //PORTA |= (1 << PA2);
PORTH &= ~(1 << PH6); //PORTA &= ~(1 << PA2);
//digitalWrite(CLOCK, HIGH); digitalWrite(pinClock, HIGH);
//digitalWrite(CLOCK, LOW); digitalWrite(pinClock, LOW);
} }
void Panel::load() { void Panel::load() {
PORTH |= (1 << PH4); //PORTB |= (1 << PB0);
PORTH &= ~(1 << PH4); //PORTB &= ~(1 << PB0);
//digitalWrite(LOAD, HIGH); digitalWrite(pinLoad, HIGH);
//digitalWrite(LOAD, LOW); digitalWrite(pinLoad, LOW);
} }
@ -79,16 +82,16 @@ void Panel::send_block(Image* p, int x, int y) {
byte pixel = p->get_pixel(x + x_offset, y + y_offset); byte pixel = p->get_pixel(x + x_offset, y + y_offset);
if(pixel) /*if(pixel)
{ {
PORTH |= (1 << PH5); PORTB |= (1 << PB2);
} }
else else
{ {
PORTH &= ~(1 << PH5); PORTB &= ~(1 << PB2);
} }*/
//digitalWrite(DATA, pixel); digitalWrite(pinData, pixel);
clock(); clock();
} }

View File

@ -6,6 +6,7 @@
class Panel class Panel
{ {
public: public:
Panel(uint8_t pData, uint8_t pClock, uint8_t pLoad);
void init(); void init();
void send_image(Image* img); void send_image(Image* img);
@ -13,6 +14,9 @@ class Panel
void clock(); void clock();
void load(); void load();
void send_block(Image* p, int x, int y); void send_block(Image* p, int x, int y);
uint8_t pinData;
uint8_t pinClock;
uint8_t pinLoad;
}; };
#endif #endif