Serial debug messages added for received UDP packages
This commit is contained in:
parent
21045b1bee
commit
21d430311d
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,3 +3,4 @@
|
||||
.vscode/c_cpp_properties.json
|
||||
.vscode/launch.json
|
||||
.vscode/ipch
|
||||
todo.txt
|
||||
|
@ -10,6 +10,8 @@
|
||||
#define IMAGE_WIDTH (PANEL_WIDTH * MAXIMUM_PANELSIZE)
|
||||
#define IMAGE_HEIGHT PANEL_HEIGHT
|
||||
|
||||
#define IMAGE_BUFFER (IMAGE_WIDTH * IMAGE_HEIGHT)
|
||||
|
||||
class Image
|
||||
{
|
||||
public:
|
||||
@ -21,7 +23,7 @@ class Image
|
||||
private:
|
||||
bool check_bounds(int x, int y);
|
||||
|
||||
uint8_t data[IMAGE_WIDTH * IMAGE_HEIGHT];
|
||||
uint8_t data[IMAGE_BUFFER];
|
||||
|
||||
};
|
||||
|
||||
|
@ -59,16 +59,18 @@ void receiveUDP() {
|
||||
}
|
||||
}
|
||||
Serial.print(", port ");
|
||||
Serial.println(Udp.remotePort());
|
||||
Serial.print(Udp.remotePort());
|
||||
someOneIsConnected = true;
|
||||
if (packetSize < ((int) PACKET_LENGTH) ) {
|
||||
// read the packet into packetBufffer
|
||||
Udp.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);
|
||||
}
|
||||
Serial.println("");
|
||||
|
||||
if (packetSize == PACKET_LENGTH) {
|
||||
auto brightness = packetBuffer[0];
|
||||
//OCR5A = brightness;
|
||||
//TODO OCR5A = brightness;
|
||||
image.clear_pixels();
|
||||
int offset = 0;
|
||||
for(int i = 0; i < PACKET_LENGTH; i++){
|
||||
uint8_t value = packetBuffer[i];
|
||||
@ -100,6 +102,7 @@ void receiveUDP() {
|
||||
}
|
||||
|
||||
} else {
|
||||
Serial.println(F("Wrong size"));
|
||||
sprintf(ReplyBuffer, "Wrong packet size %d", packetSize);
|
||||
// send a reply to the IP address and port that sent us the packet we received
|
||||
Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
|
||||
@ -184,11 +187,11 @@ void loop() {
|
||||
delay(10);
|
||||
if (someOneIsConnected == false) {
|
||||
default_image(&image);
|
||||
Serial.print(F("."));
|
||||
}
|
||||
panel1.send_image(&image);
|
||||
panel2.send_image(&image);
|
||||
panel3.send_image(&image);
|
||||
panel4.send_image(&image);
|
||||
panel5.send_image(&image);
|
||||
Serial.println(F(".\n"));
|
||||
}
|
||||
}
|
||||
|
@ -25,10 +25,34 @@ void Image::set_pixel_offset(int offset, byte value) {
|
||||
int x = offset % IMAGE_WIDTH;
|
||||
int y = floor(offset / IMAGE_WIDTH);
|
||||
if (check_bounds(x, y) == false) {
|
||||
Serial.print(F("set_pixel outOfBound\n"));
|
||||
Serial.print(F("set_pixel outOfBound"));
|
||||
Serial.print(x);
|
||||
Serial.print("x");
|
||||
Serial.print(y);
|
||||
Serial.print("\r\n");
|
||||
return;
|
||||
}
|
||||
data[y * IMAGE_WIDTH + x] = value;
|
||||
|
||||
if (offset >= IMAGE_BUFFER) {
|
||||
Serial.print(F("buffer out of index ["));
|
||||
Serial.print(offset);
|
||||
Serial.print(F("] : "));
|
||||
Serial.print(x);
|
||||
Serial.print("x");
|
||||
Serial.print(y);
|
||||
Serial.print("\r\n");
|
||||
return;
|
||||
}
|
||||
if (value > 0) {
|
||||
Serial.print(F("ON : "));
|
||||
Serial.print(x);
|
||||
Serial.print("x");
|
||||
Serial.print(y);
|
||||
Serial.print("\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
data[offset] = value;
|
||||
}
|
||||
|
||||
void Image::set_pixel(int x, int y, byte value) {
|
||||
|
Loading…
Reference in New Issue
Block a user