changed led blinking to default off, removed the handler to update the pwm per default, and made a toggle to switch it back on
This commit is contained in:
parent
35416a2c28
commit
c0d75a69f8
@ -241,6 +241,12 @@ def change_led_colour(red_amount,green_amount,blue_amount):
|
||||
change_red(red_amount)
|
||||
change_blue(blue_amount)
|
||||
change_green(green_amount)
|
||||
if leds_constant_update = False:
|
||||
led_red.ChangeDutyCycle(led_red_brightness)
|
||||
led_green.ChangeDutyCycle(led_green_brightness)
|
||||
led_blue.ChangeDutyCycle(led_blue_brightness)
|
||||
|
||||
|
||||
|
||||
def change_led_speed(colour, speed):
|
||||
# changes the speed of the LED pwm
|
||||
@ -263,25 +269,25 @@ def led_handler():
|
||||
|
||||
# led blinking effect. can be toggled on or off by setting led_blink to true or false.
|
||||
# blinks every second-
|
||||
|
||||
if led_blink == True:
|
||||
# this equals to 0 every tick for one second, and 1 every tick for another second
|
||||
# it requires being handled in a one-shot situation since this is called
|
||||
# multiple times per second, and will equal to 0 or 1 multiple times per second
|
||||
# aswell. the real value of get_ticks()/1000 cannot be predetermined.
|
||||
if int((pygame.time.get_ticks()/1000))%2 == 0:
|
||||
if timer_led_switched == 0:
|
||||
timer_led_switched = 1
|
||||
if timer_led_blink_toggle == 1:
|
||||
print('BLINK: switching leds off')
|
||||
leds_toggle()
|
||||
timer_led_blink_toggle = 0
|
||||
else:
|
||||
print('BLINK: reverting colours')
|
||||
leds_toggle()
|
||||
timer_led_blink_toggle = 1
|
||||
else:
|
||||
timer_led_switched = 0
|
||||
if leds_constant_update == True:
|
||||
if led_blink == True:
|
||||
# this equals to 0 every tick for one second, and 1 every tick for another second
|
||||
# it requires being handled in a one-shot situation since this is called
|
||||
# multiple times per second, and will equal to 0 or 1 multiple times per second
|
||||
# aswell. the real value of get_ticks()/1000 cannot be predetermined.
|
||||
if int((pygame.time.get_ticks()/1000))%2 == 0:
|
||||
if timer_led_switched == 0:
|
||||
timer_led_switched = 1
|
||||
if timer_led_blink_toggle == 1:
|
||||
print('BLINK: switching leds off')
|
||||
leds_toggle()
|
||||
timer_led_blink_toggle = 0
|
||||
else:
|
||||
print('BLINK: reverting colours')
|
||||
leds_toggle()
|
||||
timer_led_blink_toggle = 1
|
||||
else:
|
||||
timer_led_switched = 0
|
||||
|
||||
|
||||
# update the led duty cycle
|
||||
@ -294,15 +300,16 @@ def led_handler():
|
||||
# instead, just copy the needed values to the 3 brightness variables!
|
||||
# the values will be correctly put in once the toggle is back
|
||||
|
||||
if leds_off_toggle == False:
|
||||
if int((pygame.time.get_ticks()/100))%2 == 0:
|
||||
if timer_led_updated == 0:
|
||||
timer_led_updated = 1
|
||||
led_red.ChangeDutyCycle(led_red_brightness)
|
||||
led_green.ChangeDutyCycle(led_green_brightness)
|
||||
led_blue.ChangeDutyCycle(led_blue_brightness)
|
||||
else:
|
||||
timer_led_updated = 0
|
||||
if leds_constant_update == True:
|
||||
if leds_off_toggle == False:
|
||||
if int((pygame.time.get_ticks()/100))%20 == 0:
|
||||
if timer_led_updated == 0:
|
||||
timer_led_updated = 1
|
||||
led_red.ChangeDutyCycle(led_red_brightness)
|
||||
led_green.ChangeDutyCycle(led_green_brightness)
|
||||
led_blue.ChangeDutyCycle(led_blue_brightness)
|
||||
else:
|
||||
timer_led_updated = 0
|
||||
|
||||
|
||||
def leds_toggle():
|
||||
@ -316,6 +323,10 @@ def leds_toggle():
|
||||
leds_off_toggle = True
|
||||
else:
|
||||
leds_off_toggle = False
|
||||
led_red.ChangeDutyCycle(led_red_brightness)
|
||||
led_green.ChangeDutyCycle(led_green_brightness)
|
||||
led_blue.ChangeDutyCycle(led_blue_brightness)
|
||||
|
||||
|
||||
def toggle_fullscreen():
|
||||
screen = pygame.display.get_surface()
|
||||
|
Loading…
Reference in New Issue
Block a user