File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed
Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @treehouses/cli" ,
3- "version" : " 1.2.3 " ,
3+ "version" : " 1.2.4 " ,
44 "description" : " Thin command-line interface for Raspberry Pi low level configuration." ,
55 "main" : " cli.sh" ,
66 "bin" : {
Original file line number Diff line number Diff line change 55import time
66import subprocess
77
8+ ESTIMATED_STATE_DIFF_DURATION = 1
9+ ESTIMATED_PIN_CALLBACK_DURATION = 15
10+
811GPIO .cleanup ()
912GPIO .setmode (GPIO .BOARD )
1013GPIO .setup (18 , GPIO .IN , pull_up_down = GPIO .PUD_DOWN )
1114
1215prevState = None
1316while True :
1417 state = GPIO .input (18 )
18+ # sleep in the loop is related to how fast the command in the block run
1519 if prevState == state :
20+ time .sleep (ESTIMATED_STATE_DIFF_DURATION )
1621 continue
1722 elif state == 1 :
1823 print "Pin is on"
1924 try :
2025 subprocess .check_output (['bash' , '/etc/gpio-button-action-on.sh' ])
2126 except :
2227 pass
23- time .sleep (15 )
28+ time .sleep (ESTIMATED_PIN_CALLBACK_DURATION )
2429 else :
2530 print "Pin is off"
2631 try :
2732 subprocess .check_output (['bash' , '/etc/gpio-button-action-off.sh' ])
2833 except :
2934 pass
30- time .sleep (15 )
35+ time .sleep (ESTIMATED_PIN_CALLBACK_DURATION )
3136
3237 prevState = state
You can’t perform that action at this time.
0 commit comments