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:
		@@ -241,6 +241,12 @@ def change_led_colour(red_amount,green_amount,blue_amount):
 | 
				
			|||||||
        change_red(red_amount)
 | 
					        change_red(red_amount)
 | 
				
			||||||
        change_blue(blue_amount)
 | 
					        change_blue(blue_amount)
 | 
				
			||||||
        change_green(green_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):
 | 
					def change_led_speed(colour, speed):
 | 
				
			||||||
        # changes the speed of the LED pwm
 | 
					        # 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.
 | 
					        # led blinking effect. can be toggled on or off by setting led_blink to true or false.
 | 
				
			||||||
        # blinks every second-
 | 
					        # blinks every second-
 | 
				
			||||||
 | 
					        if leds_constant_update == True:
 | 
				
			||||||
        if led_blink == True: 
 | 
					            if led_blink == True: 
 | 
				
			||||||
            # this equals to 0 every tick for one second, and 1 every tick for another second
 | 
					                # 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
 | 
					                # 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
 | 
					                # 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.
 | 
					                # aswell. the real value of get_ticks()/1000 cannot be predetermined.
 | 
				
			||||||
            if int((pygame.time.get_ticks()/1000))%2 == 0:
 | 
					                if int((pygame.time.get_ticks()/1000))%2 == 0:
 | 
				
			||||||
                if timer_led_switched == 0:
 | 
					                    if timer_led_switched == 0:
 | 
				
			||||||
                    timer_led_switched = 1        
 | 
					                        timer_led_switched = 1        
 | 
				
			||||||
                    if timer_led_blink_toggle == 1:
 | 
					                        if timer_led_blink_toggle == 1:
 | 
				
			||||||
                        print('BLINK: switching leds off')
 | 
					                            print('BLINK: switching leds off')
 | 
				
			||||||
                        leds_toggle()
 | 
					                            leds_toggle()
 | 
				
			||||||
                        timer_led_blink_toggle = 0
 | 
					                            timer_led_blink_toggle = 0
 | 
				
			||||||
                    else:
 | 
					                        else:
 | 
				
			||||||
                        print('BLINK: reverting colours')
 | 
					                            print('BLINK: reverting colours')
 | 
				
			||||||
                        leds_toggle()
 | 
					                            leds_toggle()
 | 
				
			||||||
                        timer_led_blink_toggle = 1
 | 
					                            timer_led_blink_toggle = 1
 | 
				
			||||||
            else:
 | 
					                else:
 | 
				
			||||||
                timer_led_switched = 0
 | 
					                    timer_led_switched = 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # update the led duty cycle
 | 
					        # update the led duty cycle
 | 
				
			||||||
@@ -294,15 +300,16 @@ def led_handler():
 | 
				
			|||||||
        # instead, just copy the needed values to the 3 brightness variables! 
 | 
					        # instead, just copy the needed values to the 3 brightness variables! 
 | 
				
			||||||
        # the values will be correctly put in once the toggle is back
 | 
					        # the values will be correctly put in once the toggle is back
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if leds_off_toggle == False:
 | 
					        if leds_constant_update == True:
 | 
				
			||||||
            if int((pygame.time.get_ticks()/100))%2 == 0:
 | 
					            if leds_off_toggle == False:
 | 
				
			||||||
                if timer_led_updated == 0:
 | 
					                if int((pygame.time.get_ticks()/100))%20 == 0:
 | 
				
			||||||
                    timer_led_updated = 1        
 | 
					                    if timer_led_updated == 0:
 | 
				
			||||||
                    led_red.ChangeDutyCycle(led_red_brightness)
 | 
					                        timer_led_updated = 1        
 | 
				
			||||||
                    led_green.ChangeDutyCycle(led_green_brightness)
 | 
					                        led_red.ChangeDutyCycle(led_red_brightness)
 | 
				
			||||||
                    led_blue.ChangeDutyCycle(led_blue_brightness)
 | 
					                        led_green.ChangeDutyCycle(led_green_brightness)
 | 
				
			||||||
            else:
 | 
					                        led_blue.ChangeDutyCycle(led_blue_brightness)
 | 
				
			||||||
                timer_led_updated = 0
 | 
					                else:
 | 
				
			||||||
 | 
					                    timer_led_updated = 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def leds_toggle():
 | 
					def leds_toggle():
 | 
				
			||||||
@@ -316,6 +323,10 @@ def leds_toggle():
 | 
				
			|||||||
            leds_off_toggle = True
 | 
					            leds_off_toggle = True
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            leds_off_toggle = False
 | 
					            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():
 | 
					def toggle_fullscreen():
 | 
				
			||||||
        screen = pygame.display.get_surface()
 | 
					        screen = pygame.display.get_surface()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user