diff --git a/LED-Board.ino b/LED-Board.ino index 1640752..cc2a22c 100644 --- a/LED-Board.ino +++ b/LED-Board.ino @@ -16,8 +16,8 @@ IPAddress subnet(255, 255, 254, 0); WebSocketsServer webSocket = WebSocketsServer(81); Image image; -Panel panel1(22, 24, 23); //data, clock, load -Panel panel2(28, 29, 31); +Panel panel1(22, 24, 23, 0 * PANEL_WIDTH, 0 * PANEL_HEIGHT); //data, clock, load +Panel panel2(28, 29, 31, 1 * PANEL_WIDTH, 0 * PANEL_HEIGHT); ProtocolDL protocol = ProtocolDL(image); unsigned long last_activity = 0; diff --git a/src/image.hpp b/src/image.hpp index d758727..fa84a92 100644 --- a/src/image.hpp +++ b/src/image.hpp @@ -3,7 +3,7 @@ #include -#define MAX_WIDTH 32 +#define MAX_WIDTH 64 #define MAX_HEIGHT 40 class Image diff --git a/src/panel.cpp b/src/panel.cpp index 91f7ac5..abda670 100644 --- a/src/panel.cpp +++ b/src/panel.cpp @@ -1,10 +1,13 @@ #include "panel.hpp" -Panel::Panel(uint8_t pData, uint8_t pClock, uint8_t pLoad) +Panel::Panel(uint8_t pData, uint8_t pClock, uint8_t pLoad, int x, int y) { pinData = pData; pinLoad = pLoad; pinClock = pClock; + + posX = x; + posY = y; } void Panel::init() @@ -15,8 +18,11 @@ void Panel::init() } void Panel::send_image(Image* img) { - for (int y = 0; y < MAX_HEIGHT; y += 8) { - for (int x = 0; x < MAX_WIDTH; x += 4) { + int endY = posY + PANEL_HEIGHT; + int endX = posX + PANEL_WIDTH; + + for (int y = posY; y < endY; y += 8) { + for (int x = posX; x < endX; x += 4) { send_block(img, x, y); } } diff --git a/src/panel.hpp b/src/panel.hpp index b02198a..199b4fd 100644 --- a/src/panel.hpp +++ b/src/panel.hpp @@ -3,10 +3,13 @@ #include "image.hpp" +#define PANEL_WIDTH 32 +#define PANEL_HEIGHT 40 + class Panel { public: - Panel(uint8_t pData, uint8_t pClock, uint8_t pLoad); + Panel(uint8_t pData, uint8_t pClock, uint8_t pLoad, int x, int y); void init(); void send_image(Image* img); @@ -14,9 +17,14 @@ class Panel void clock(); void load(); void send_block(Image* p, int x, int y); + uint8_t pinData; uint8_t pinClock; uint8_t pinLoad; + + // position of panel in image + int posX; + int posY; }; #endif \ No newline at end of file