Extended Panel class for multiple panels
This commit is contained in:
		| @@ -16,8 +16,8 @@ IPAddress subnet(255, 255, 254, 0); | |||||||
| WebSocketsServer webSocket = WebSocketsServer(81); | WebSocketsServer webSocket = WebSocketsServer(81); | ||||||
|  |  | ||||||
| Image image; | Image image; | ||||||
| Panel panel1(22, 24, 23);       //data, clock, load | Panel panel1(22, 24, 23, 0 * PANEL_WIDTH, 0 * PANEL_HEIGHT);       //data, clock, load | ||||||
| Panel panel2(28, 29, 31); | Panel panel2(28, 29, 31, 1 * PANEL_WIDTH, 0 * PANEL_HEIGHT); | ||||||
| ProtocolDL protocol = ProtocolDL(image); | ProtocolDL protocol = ProtocolDL(image); | ||||||
|  |  | ||||||
| unsigned long last_activity = 0; | unsigned long last_activity = 0; | ||||||
|   | |||||||
| @@ -3,7 +3,7 @@ | |||||||
|  |  | ||||||
| #include <Arduino.h> | #include <Arduino.h> | ||||||
|  |  | ||||||
| #define MAX_WIDTH 32 | #define MAX_WIDTH 64 | ||||||
| #define MAX_HEIGHT 40 | #define MAX_HEIGHT 40 | ||||||
|  |  | ||||||
| class Image | class Image | ||||||
|   | |||||||
| @@ -1,10 +1,13 @@ | |||||||
| #include "panel.hpp" | #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; |   pinData = pData; | ||||||
|   pinLoad = pLoad; |   pinLoad = pLoad; | ||||||
|   pinClock = pClock; |   pinClock = pClock; | ||||||
|  |  | ||||||
|  |   posX = x; | ||||||
|  |   posY = y; | ||||||
| } | } | ||||||
|  |  | ||||||
| void Panel::init() | void Panel::init() | ||||||
| @@ -15,8 +18,11 @@ void Panel::init() | |||||||
| } | } | ||||||
|  |  | ||||||
| void Panel::send_image(Image* img) { | void Panel::send_image(Image* img) { | ||||||
|   for (int y = 0; y < MAX_HEIGHT; y += 8) { |   int endY = posY + PANEL_HEIGHT; | ||||||
|     for (int x = 0; x < MAX_WIDTH; x += 4) { |   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); |       send_block(img, x, y); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -3,10 +3,13 @@ | |||||||
|  |  | ||||||
| #include "image.hpp" | #include "image.hpp" | ||||||
|  |  | ||||||
|  | #define PANEL_WIDTH 32 | ||||||
|  | #define PANEL_HEIGHT 40 | ||||||
|  |  | ||||||
| class Panel | class Panel | ||||||
| { | { | ||||||
|     public: |     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 init(); | ||||||
|     void send_image(Image* img); |     void send_image(Image* img); | ||||||
|  |  | ||||||
| @@ -14,9 +17,14 @@ 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 pinData; | ||||||
|     uint8_t pinClock; |     uint8_t pinClock; | ||||||
|     uint8_t pinLoad; |     uint8_t pinLoad; | ||||||
|  |  | ||||||
|  |     // position of panel in image | ||||||
|  |     int posX; | ||||||
|  |     int posY; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| #endif | #endif | ||||||
		Reference in New Issue
	
	Block a user