Refactored packet length, UDP parser fixed
This commit is contained in:
parent
7bfb51bc58
commit
21045b1bee
@ -24,9 +24,8 @@ Panel panel5(47, 53, 49, 4 * PANEL_WIDTH, 0 * PANEL_HEIGHT);
|
||||
/**
|
||||
* 800 Byte describing all 5 panels in bits
|
||||
*/
|
||||
/* uint8_t packetBuffer[(PANEL_WIDTH * PANEL_HEIGHT * MAXIMUM_PANELSIZE) / sizeof(uint8_t)]; // buffer to hold incoming packet,*/
|
||||
const uint16_t packetBufferSize = (PANEL_WIDTH * PANEL_HEIGHT * MAXIMUM_PANELSIZE) / BITS_OF_BYTE + 1;
|
||||
uint8_t packetBuffer[packetBufferSize];
|
||||
#define PACKET_LENGTH (((PANEL_WIDTH * PANEL_HEIGHT * MAXIMUM_PANELSIZE) / BITS_OF_BYTE) + 1)
|
||||
uint8_t packetBuffer[PACKET_LENGTH];
|
||||
/* Reply with error messages*/
|
||||
char ReplyBuffer[UDP_TX_PACKET_MAX_SIZE]; // a string to send back
|
||||
|
||||
@ -62,40 +61,40 @@ void receiveUDP() {
|
||||
Serial.print(", port ");
|
||||
Serial.println(Udp.remotePort());
|
||||
someOneIsConnected = true;
|
||||
if (packetSize < ((int) sizeof(packetBuffer)) ) {
|
||||
if (packetSize < ((int) PACKET_LENGTH) ) {
|
||||
// read the packet into packetBufffer
|
||||
Udp.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);
|
||||
}
|
||||
|
||||
if (packetSize == sizeof(packetBuffer)) {
|
||||
if (packetSize == PACKET_LENGTH) {
|
||||
auto brightness = packetBuffer[0];
|
||||
//OCR5A = brightness;
|
||||
int offset = 0;
|
||||
for(uint16_t i = 0; i < packetBufferSize;i++){
|
||||
for(int i = 0; i < PACKET_LENGTH; i++){
|
||||
uint8_t value = packetBuffer[i];
|
||||
|
||||
uint8_t a = (value | 0xb00000001) > 0 ? 1 : 0;
|
||||
uint8_t a = (value & 0xb00000001) > 0 ? 1 : 0;
|
||||
image.set_pixel_offset(offset, a);
|
||||
offset++;
|
||||
uint8_t b = (value | 0xb00000010) > 0 ? 1 : 0;
|
||||
uint8_t b = ((value & 0xb00000010) > 0) ? 1 : 0;
|
||||
image.set_pixel_offset(offset, b);
|
||||
offset++;
|
||||
uint8_t c = (value | 0xb00000100) > 0 ? 1 : 0;
|
||||
uint8_t c = ((value & 0xb00000100) > 0) ? 1 : 0;
|
||||
image.set_pixel_offset(offset, c);
|
||||
offset++;
|
||||
uint8_t d = (value | 0xb00001000) > 0 ? 1 : 0;
|
||||
uint8_t d = ((value & 0xb00001000) > 0) ? 1 : 0;
|
||||
image.set_pixel_offset(offset, d);
|
||||
offset++;
|
||||
uint8_t e = (value | 0xb00010000) > 0 ? 1 : 0;
|
||||
uint8_t e = ((value & 0xb00010000) > 0) ? 1 : 0;
|
||||
image.set_pixel_offset(offset, e);
|
||||
offset++;
|
||||
uint8_t f = (value | 0xb00100000) > 0 ? 1 : 0;
|
||||
uint8_t f = ((value & 0xb00100000) > 0) ? 1 : 0;
|
||||
image.set_pixel_offset(offset, f);
|
||||
offset++;
|
||||
uint8_t g = (value | 0xb01000000) > 0 ? 1 : 0;
|
||||
uint8_t g = ((value & 0xb01000000) > 0) ? 1 : 0;
|
||||
image.set_pixel_offset(offset, g);
|
||||
offset++;
|
||||
uint8_t h = (value | 0xb10000000) > 0 ? 1 : 0;
|
||||
uint8_t h = ((value & 0xb10000000) > 0) ? 1 : 0;
|
||||
image.set_pixel_offset(offset, h);
|
||||
offset++;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user