File tree Expand file tree Collapse file tree 4 files changed +15
-11
lines changed
Expand file tree Collapse file tree 4 files changed +15
-11
lines changed Original file line number Diff line number Diff line change 1- import RPi . GPIO as GPIO
1+ from gpiozero import LED
22
33class Led ():
4- _pin = 0
4+ led = None
5+ pin = 0
56 def __init__ (self , pin ):
6- GPIO .setwarnings (False )
7- GPIO .setmode (GPIO .BCM )
8- if (pin is not None ):
9- self ._pin = pin
10- GPIO .setup (self ._pin , GPIO .OUT )
7+ self .pin = pin
8+ self .led = LED (pin )
119
1210 def status (self ):
13- return GPIO .input (self ._pin )
11+ if self .leds_on ():
12+ return 1
13+ else :
14+ return 0
1415 def leds_on (self ):
15- return self .status () == 1
16+ return self .led . is_active
1617 def switch_leds (self , on ):
1718 if (on ):
18- GPIO . output ( self ._pin , GPIO . HIGH )
19+ self .led . on ( )
1920 else :
20- GPIO . output ( self ._pin , GPIO . LOW )
21+ self .led . off ( )
Original file line number Diff line number Diff line change 11click==6.7
22Flask==1.1.2
3+ gpiozero
34itsdangerous==0.24
45Jinja2==2.11.2
56MarkupSafe==1.1.1
Original file line number Diff line number Diff line change 11click==6.7
22Flask==1.1.2
3+ gpiozero
34itsdangerous==0.24
45Jinja2==2.11.2
56MarkupSafe==1.1.1
Original file line number Diff line number Diff line change 11click == 6.7
22Flask == 1.1.2
3+ gpiozero
34itsdangerous == 0.24
45Jinja2 == 2.11.2
56MarkupSafe == 1.1.1
You can’t perform that action at this time.
0 commit comments