projects
/
led-wall.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7faf6e4
)
added button function
master
author
Russ Handorf
<rhandorf@handorf.org>
Fri, 15 Feb 2019 02:28:57 +0000
(21:28 -0500)
committer
Russ Handorf
<rhandorf@handorf.org>
Fri, 15 Feb 2019 02:28:57 +0000
(21:28 -0500)
README.md
patch
|
blob
|
history
server.py
patch
|
blob
|
history
diff --git
a/README.md
b/README.md
index a313ae795ef8ee57aac87051f5b0a0815c09b205..2482c3ad90ae17b00a5dce1492030fef96fdf197 100644
(file)
--- a/
README.md
+++ b/
README.md
@@
-23,4
+23,4
@@
sudo python server.py
*Potenial bugs*
*Potenial bugs*
-1. I'm not entirely convinced the timeout to clear a pixel is making its way over. Might have to make a double check in the Python as well
+
*Fixed?*
1. I'm not entirely convinced the timeout to clear a pixel is making its way over. Might have to make a double check in the Python as well
diff --git
a/server.py
b/server.py
index 467cf0f1c56c5704a35ad807fbf3a69136b4662e..5167904a66fddeb92cfdbee422bbd38b429967b9 100644
(file)
--- a/
server.py
+++ b/
server.py
@@
-2,6
+2,12
@@
import socket
import threading
import time
from neopixel import *
import threading
import time
from neopixel import *
+import RPi.GPIO as GPIO
+import time
+
+GPIO.setmode(GPIO.BCM)
+
+GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_UP)
LED_COUNT = 1024 # Number of LED pixels.
LED_PIN = 18 # GPIO pin connected to the pixels (18 uses PWM!).
LED_COUNT = 1024 # Number of LED pixels.
LED_PIN = 18 # GPIO pin connected to the pixels (18 uses PWM!).
@@
-12,6
+18,8
@@
LED_BRIGHTNESS = 128 # Set to 0 for darkest and 255 for brightest
LED_INVERT = False # True to invert the signal (when using NPN transistor level shift)
LED_CHANNEL = 0 # set to '1' for GPIOs 13, 19, 41, 45 or 53
LED_INVERT = False # True to invert the signal (when using NPN transistor level shift)
LED_CHANNEL = 0 # set to '1' for GPIOs 13, 19, 41, 45 or 53
+on = True
+
bind_ip = '0.0.0.0'
bind_port = 10000
strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL)
bind_ip = '0.0.0.0'
bind_port = 10000
strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL)
@@
-31,7
+39,6
@@
for i in range(1024):
pixel_status.append(0)
strip.show()
pixel_status.append(0)
strip.show()
-
print "Starting Server"
def led_timeout(strip,pixel):
print "Starting Server"
def led_timeout(strip,pixel):
@@
-41,10
+48,25
@@
def led_timeout(strip,pixel):
strip.setPixelColor(i, Color(0,0,0))
while True:
strip.setPixelColor(i, Color(0,0,0))
while True:
+ input_state = GPIO.input(17)
+ if input_state == False:
+ if on == True:
+ on = False
+ for i in range(1024):
+ strip.setPixelColor(i, Color(0,0,0))
+ strip.show()
+ else:
+ on = True
+ for i in range(1024):
+ strip.setPixelColor(i, pixels[i])
+ time.sleep(0.5)
+
data, addr = server.recvfrom(1024)
if data:
data, addr = server.recvfrom(1024)
if data:
- #print 'Received {}'.format(data)
elements=format(data).split(",")
elements=format(data).split(",")
+ if len(elements)>2:
+ print "Kill the sniffer and start over"
+ exit(0)
color=elements[0].split(":")
pixel_color=pixels[int(color[1])]
red=pixel_color[0]
color=elements[0].split(":")
pixel_color=pixels[int(color[1])]
red=pixel_color[0]
@@
-62,4
+84,6
@@
while True:
if color[0]=="B":
strip.setPixelColor(int(color[1]), Color(green, red, int(elements[1])))
pixels[int(color[1])] =(red,green,int(elements[1]))
if color[0]=="B":
strip.setPixelColor(int(color[1]), Color(green, red, int(elements[1])))
pixels[int(color[1])] =(red,green,int(elements[1]))
+
+ if on==True:
strip.show()
strip.show()