@@ -427,26 +427,7 @@ class PWMLED(PWMOutputDevice):
427427 If :data:`False` (the default), the LED will be off initially. If
428428 :data:`True`, the LED will be switched on initially.
429429 """
430- def __init__ (self , pin , active_high = True , initial_value = False ):
431- self ._brightness = 1
432- super ().__init__ (pin = pin ,
433- active_high = active_high ,
434- initial_value = initial_value )
435-
436- @property
437- def brightness (self ):
438- return self ._brightness
439-
440- @brightness .setter
441- def brightness (self , value ):
442- self ._brightness = value
443- self .value = 1 if self ._brightness > 0 else 0
444-
445- def _write (self , value ):
446- super ()._write (self ._brightness * value )
447-
448- def _read (self ):
449- return 1 if super ()._read () > 0 else 0
430+ PWMLED .brightness = PWMLED .value
450431
451432def LED (pin , use_pwm = True , active_high = True , initial_value = False ):
452433 """
@@ -508,29 +489,8 @@ class PWMBuzzer(PWMOutputDevice):
508489 If :data:`False` (the default), the buzzer will be off initially. If
509490 :data:`True`, the buzzer will be switched on initially.
510491 """
511- def __init__ (self , pin , freq = 100 , duty_factor = 1023 , active_high = True , initial_value = False ):
512- self ._volume = 1
513- super ().__init__ (pin = pin ,
514- duty_factor = duty_factor ,
515- active_high = active_high ,
516- initial_value = initial_value )
517-
518- @property
519- def volume (self ):
520- return self ._volume
521-
522- @volume .setter
523- def volume (self , value ):
524- self ._volume = value
525- self .value = 1 if self ._volume > 0 else 0
526-
527- def _write (self , value ):
528- super ()._write (self ._volume * value )
529-
530- def _read (self ):
531- return 1 if super ()._read () > 0 else 0
532-
533- PWMBuzzer .beep = Buzzer .blink
492+ PWMBuzzer .volume = PWMBuzzer .value
493+ PWMBuzzer .beep = PWMBuzzer .blink
534494
535495class Speaker (OutputDevice ):
536496 NOTES = {
0 commit comments