Update main.py
parent
2a15a35814
commit
84334e14fd
26
main.py
26
main.py
|
@ -14,6 +14,7 @@ LED_BRIGHTNESS = 255 # 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
|
||||
|
||||
global led_power
|
||||
led_power = True
|
||||
|
||||
try:
|
||||
|
@ -66,15 +67,6 @@ def blink(strip, color1, color2, iterations=10, wait_ms=10):
|
|||
strip.show()
|
||||
time.sleep(1)
|
||||
|
||||
def led_power_toggle(channel):
|
||||
global led_power
|
||||
if led_power == True:
|
||||
led_power = False
|
||||
return False
|
||||
else:
|
||||
led_power = True
|
||||
return True
|
||||
|
||||
def read_idle():
|
||||
with open('./idle.txt', 'r') as f:
|
||||
idle_mode = f.readline()
|
||||
|
@ -91,8 +83,11 @@ def change_idle_mode(channel):
|
|||
idle_mode = f.readline()
|
||||
print('Change Idle-Mode: '+idle_mode)
|
||||
|
||||
def test():
|
||||
print('test')
|
||||
def power_toggle():
|
||||
if led_power == True:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
if __name__ == '__main__':
|
||||
strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL)
|
||||
|
@ -100,7 +95,7 @@ if __name__ == '__main__':
|
|||
GPIO.setmode(GPIO.BOARD)
|
||||
GPIO.setup(13, GPIO.IN, pull_up_down=GPIO.PUD_UP)
|
||||
GPIO.setup(19, GPIO.IN, pull_up_down=GPIO.PUD_UP)
|
||||
GPIO.add_event_detect(13, GPIO.RISING, callback=led_power_toggle, bouncetime=300)
|
||||
GPIO.add_event_detect(13, GPIO.RISING, callback=power_toggle, bouncetime=300)
|
||||
GPIO.add_event_detect(19, GPIO.RISING, callback=change_idle_mode, bouncetime=300)
|
||||
|
||||
try:
|
||||
|
@ -114,11 +109,12 @@ if __name__ == '__main__':
|
|||
with open('./idle.txt', 'r') as f:
|
||||
idle_mode = f.readline()
|
||||
|
||||
print(led_power_toggle)
|
||||
|
||||
if led_power_toggle == False:
|
||||
if power_toggle == False:
|
||||
setColor(strip, Color(0,0,0))
|
||||
led_power == False
|
||||
|
||||
else:
|
||||
led_power == True
|
||||
if check_internet() == False:
|
||||
blink(strip, Color(255,0,0), Color(255,255,255))
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue