Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
src1138 committed May 23, 2024
1 parent 9c8bce5 commit 9561523
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions motioneye_scripts/VMFB-MC.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
PBKA_ON_PERIOD=1 # seconds the PBKA will sink current to keep a powerbank on
PBKA_OFF_PERIOD=10 # seconds between PBKA current sinks
DEFAULT_TOGGLE_TIMED_DISPENSE=1 # set to 1 to enable timer on startup
DEFAULT_toggle_pbka=0 # set to 1 to enable PBKA on startup
DEFAULT_TOGGLE_PBKA=0 # set to 1 to enable PBKA on startup

# Initialize RPi GPIO
# GPIO.setmode(GPIO.BOARD) # uses board pin numbers to reference pins
Expand Down Expand Up @@ -212,11 +212,11 @@ def manual_dispense(pin=None):
def timed_dispense(pin="TO"):
'''Dispenses a peanut and restarts the timer'''
#print("Start timed_dispense()")
nowTime=int(datetime.now().strftime("%H%M"))
now_time=int(datetime.now().strftime("%H%M"))
# If you want to define multiple windows of timer operation
# of operation on certain days or dates you can do so in
# the following if statement
if (nowTime >= TIMED_DISPENSE_START_TIME) & (nowTime <= TIMED_DISPENSE_END_TIME):
if (now_time >= TIMED_DISPENSE_START_TIME) & (now_time <= TIMED_DISPENSE_END_TIME):
log_event("TMR","DISPENSE",pin)
sensor_ir_on(pin)
motor_on(pin)
Expand Down Expand Up @@ -284,7 +284,6 @@ def toggle_pbka(pin=None):
pbka_idle_timer = threading.Timer(PBKA_OFF_PERIOD, pbka_sink)
pbka_idle_timer.start()
else:
global pbka_sink_timer
if pbka_sink_timer.is_alive() is True:
pbka_sink_timer.cancel()
if pbka_idle_timer.is_alive() is True:
Expand Down Expand Up @@ -426,9 +425,9 @@ def toggle_calibration_mode(pin=None):
pbka_idle_timer = threading.Timer(PBKA_OFF_PERIOD, pbka_sink)

# Initialize timed dispense and PBKA enable/disable - do this after defining interrupts and timers
if DEFAULT_toggle_timed_dispense == 1:
if DEFAULT_TOGGLE_TIMED_DISPENSE == 1:
os.system('echo "1" >| /sys/class/gpio/gpio'+str(TMR_SIG)+'/value')
if DEFAULT_toggle_pbka == 1:
if DEFAULT_TOGGLE_PBKA == 1:
os.system('echo "1" >| /sys/class/gpio/gpio'+str(PBKA_SIG)+'/value')

# Everything is interrupt- and timer-based, so script
Expand Down

0 comments on commit 9561523

Please sign in to comment.