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);
Image image;
Panel panel;
Panel panel1(22, 24, 23); //data, clock, load
Panel panel2(28, 29, 31);
ProtocolDL protocol = ProtocolDL(image);
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())
{
Serial.println("complete");
panel.send_image(&image);
panel1.send_image(&image);
panel2.send_image(&image);
}
break;
@ -106,7 +108,8 @@ void setup() {
webSocket.begin();
webSocket.onEvent(webSocketEvent);
panel.init();
panel1.init();
panel2.init();
Serial.println("setup done");
}
@ -139,6 +142,7 @@ void loop() {
if (someOneIsConnected == false) {
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"
#define LOAD 7
#define DATA 8
#define CLOCK 9
Panel::Panel(uint8_t pData, uint8_t pClock, uint8_t pLoad)
{
pinData = pData;
pinLoad = pLoad;
pinClock = pClock;
}
void Panel::init()
{
pinMode(DATA, OUTPUT);
pinMode(CLOCK, OUTPUT);
pinMode(LOAD, OUTPUT);
pinMode(pinData, OUTPUT);
pinMode(pinClock, OUTPUT);
pinMode(pinLoad, OUTPUT);
}
void Panel::send_image(Image* img) {
@ -23,17 +26,17 @@ void Panel::send_image(Image* img) {
void Panel::clock() {
PORTH |= (1 << PH6);
PORTH &= ~(1 << PH6);
//digitalWrite(CLOCK, HIGH);
//digitalWrite(CLOCK, LOW);
//PORTA |= (1 << PA2);
//PORTA &= ~(1 << PA2);
digitalWrite(pinClock, HIGH);
digitalWrite(pinClock, LOW);
}
void Panel::load() {
PORTH |= (1 << PH4);
PORTH &= ~(1 << PH4);
//digitalWrite(LOAD, HIGH);
//digitalWrite(LOAD, LOW);
//PORTB |= (1 << PB0);
//PORTB &= ~(1 << PB0);
digitalWrite(pinLoad, HIGH);
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);
if(pixel)
/*if(pixel)
{
PORTH |= (1 << PH5);
PORTB |= (1 << PB2);
}
else
{
PORTH &= ~(1 << PH5);
}
PORTB &= ~(1 << PB2);
}*/
//digitalWrite(DATA, pixel);
digitalWrite(pinData, pixel);
clock();
}

View File

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