Added a status indicator LED that blinks when command is received

This commit is contained in:
Scott Lawson 2016-12-24 20:37:43 -07:00
parent 2a87d040a7
commit e677742584
2 changed files with 15 additions and 14 deletions

View File

@ -5,7 +5,7 @@
#include <WiFiUdp.h>
#include <ws2812_i2s.h>
#define NUM_LEDS 240
#define NUM_LEDS 260
#define BUFFER_LEN 1024
// Wifi and socket settings
@ -21,8 +21,10 @@ static Pixel_t pixels[NUM_LEDS];
WiFiUDP port;
// Network information
IPAddress ip(192, 168, 1, 150);
IPAddress gateway(192, 168, 1, 1);
IPAddress ip(192, 168, 137, 150);
IPAddress gateway(192, 168, 137, 1);
//IPAddress ip(192, 168, 0, 150);
//IPAddress gateway(192, 168, 0, 1);
IPAddress subnet(255, 255, 255, 0);
void setup() {
@ -42,6 +44,7 @@ void setup() {
Serial.println(WiFi.localIP());
port.begin(localPort);
ledstrip.init(NUM_LEDS);
pinMode(0, OUTPUT);
}
uint8_t N = 0;
@ -52,17 +55,16 @@ void loop() {
// If packets have been received, interpret the command
if (packetSize) {
int len = port.read(packetBuffer, BUFFER_LEN);
digitalWrite(0, 1);
int len = port.read(packetBuffer, BUFFER_LEN);
for(int i = 0; i < len; i+=4){
packetBuffer[len] = 0;
N = packetBuffer[i];
pixels[N].R = (uint8_t)packetBuffer[i+1];
pixels[N].G = (uint8_t)packetBuffer[i+2];
pixels[N].B = (uint8_t)packetBuffer[i+3];
}
//ledstrip.show(pixels);
}
// Always update strip to improve temporal dithering performance
ledstrip.show(pixels);
}
ledstrip.show(pixels);
digitalWrite(0, 0);
}
}

View File

@ -1,4 +1,5 @@
from __future__ import print_function
from __future__ import division
import socket
import numpy as np
import config
@ -26,7 +27,5 @@ def update():
if __name__ == '__main__':
pixels = pixels * 0
pixels = pixels
update()
pixels *= 0
update()