parent
4f439dc340
commit
93be9c7910
43
main.py
43
main.py
|
@ -2,7 +2,6 @@ import time
|
||||||
import os
|
import os
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
try:
|
try:
|
||||||
import requests
|
|
||||||
from rpi_ws281x import *
|
from rpi_ws281x import *
|
||||||
import RPi.GPIO as GPIO
|
import RPi.GPIO as GPIO
|
||||||
import socket
|
import socket
|
||||||
|
@ -33,13 +32,6 @@ def debug_print(message: str):
|
||||||
current_time = now.strftime("%H:%M:%S")
|
current_time = now.strftime("%H:%M:%S")
|
||||||
print('[DEBUG]['+current_time+'] '+message)
|
print('[DEBUG]['+current_time+'] '+message)
|
||||||
|
|
||||||
def check_internet(url='http://www.google.com/', timeout=1):
|
|
||||||
try:
|
|
||||||
_ = requests.head(url, timeout=timeout)
|
|
||||||
return True
|
|
||||||
except requests.ConnectionError:
|
|
||||||
return False
|
|
||||||
|
|
||||||
def wheel(pos):
|
def wheel(pos):
|
||||||
if pos < 85:
|
if pos < 85:
|
||||||
return Color(pos * 3, 255 - pos * 3, 0)
|
return Color(pos * 3, 255 - pos * 3, 0)
|
||||||
|
@ -112,26 +104,23 @@ if __name__ == '__main__':
|
||||||
# print(socket_data)
|
# print(socket_data)
|
||||||
# print(type(socket_data))
|
# print(type(socket_data))
|
||||||
if led_power == True:
|
if led_power == True:
|
||||||
if check_internet() == False:
|
if idle_mode == 1:
|
||||||
blink(strip, Color(255,0,0), Color(255,255,255))
|
rainbowCycle(strip)
|
||||||
|
elif idle_mode == 2:
|
||||||
|
setColor(strip, Color(255,0,0))
|
||||||
|
elif idle_mode == 3:
|
||||||
|
setColor(strip, Color(0,255,0))
|
||||||
|
elif idle_mode == 4:
|
||||||
|
setColor(strip, Color(0,0,255))
|
||||||
|
elif idle_mode == 5:
|
||||||
|
setColor(strip, Color(125,245,255))
|
||||||
|
elif idle_mode == 6:
|
||||||
|
setColor(strip, Color(255,0,100))
|
||||||
|
elif idle_mode == 7:
|
||||||
|
setColor(strip, Color(0,255,255))
|
||||||
else:
|
else:
|
||||||
if idle_mode == 1:
|
blink(strip, Color(255,0,0), Color(0,0,0))
|
||||||
rainbowCycle(strip)
|
time.sleep(1)
|
||||||
elif idle_mode == 2:
|
|
||||||
setColor(strip, Color(255,0,0))
|
|
||||||
elif idle_mode == 3:
|
|
||||||
setColor(strip, Color(0,255,0))
|
|
||||||
elif idle_mode == 4:
|
|
||||||
setColor(strip, Color(0,0,255))
|
|
||||||
elif idle_mode == 5:
|
|
||||||
setColor(strip, Color(125,245,255))
|
|
||||||
elif idle_mode == 6:
|
|
||||||
setColor(strip, Color(255,0,100))
|
|
||||||
elif idle_mode == 7:
|
|
||||||
setColor(strip, Color(0,255,255))
|
|
||||||
else:
|
|
||||||
blink(strip, Color(255,0,0), Color(0,0,0))
|
|
||||||
time.sleep(1)
|
|
||||||
else:
|
else:
|
||||||
setColor(strip, Color(0,0,0))
|
setColor(strip, Color(0,0,0))
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
Loading…
Reference in New Issue