Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Conflicts:
	digital-stopwatch/main.py
	digital-stopwatch/sakshat.py
  • Loading branch information
spoonysonny committed Dec 8, 2015
1 parent 870099e commit f661e44
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
11 changes: 3 additions & 8 deletions digital-stopwatch/main.py
Expand Up @@ -31,8 +31,6 @@
__start_time = datetime.utcnow()
__end_time = datetime.utcnow()
__timer_running = False
__seconds = 0
__microseconds = 0

#在检测到轻触开关触发时自动执行此函数
def tact_event_handler(pin, status):
Expand All @@ -45,19 +43,19 @@ def tact_event_handler(pin, status):
global __start_time
global __end_time
global __timer_running
global __seconds
global __microseconds

if pin == PINS.TACT_RIGHT and status == True:
if __timer_running:
__end_time = datetime.utcnow()
else:
__start_time = datetime.utcnow()
SAKS.digital_display.show(("%02d.%02d" % (0, 0)))
__timer_running = not __timer_running

'''
if pin == PINS.TACT_LEFT and status == True:
SAKS.digital_display.show(("%02d.%02d" % (0, 0)))
__timer_running = False
'''

if __name__ == "__main__":
#设定轻触开关回调函数
Expand All @@ -71,9 +69,6 @@ def tact_event_handler(pin, status):
#print c.seconds
#print c.microseconds
SAKS.digital_display.show(("%02d.%02d" % (c.seconds, c.microseconds)))
else:
pass
#SAKS.digital_display.show(("%02d.%02d" % (0, 0)))

time.sleep(0.01)
input("Enter any keys to exit...")
6 changes: 3 additions & 3 deletions digital-stopwatch/sakshat.py
Expand Up @@ -71,10 +71,10 @@ def __init__(self):
self.saks_gpio_init()
self.buzzer = entities.Buzzer(PINS.BUZZER, GPIO.LOW)
self.ledrow = entities.LedRow(PINS.LEDS, GPIO.LOW)
#self.ds18b20 = entities.DS18B20(PINS.DS18B20)
self.ds18b20 = entities.DS18B20(PINS.DS18B20)
self.digital_display = entities.DigitalDisplay({'seg': PINS.DIGITAL_DISPLAY, 'sel': PINS.DIGITAL_DISPLAY_SELECT}, GPIO.LOW)
#self.dip_switch = entities.DipSwitch2Bit([PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2], GPIO.LOW)
#self.dip_switch.register(self)
self.dip_switch = entities.DipSwitch2Bit([PINS.DIP_SWITCH_1, PINS.DIP_SWITCH_2], GPIO.LOW)
self.dip_switch.register(self)
self.tactrow = entities.TactRow([PINS.TACT_LEFT, PINS.TACT_RIGHT], GPIO.LOW)
for t in self.tactrow.items:
t.register(self)
Expand Down

0 comments on commit f661e44

Please sign in to comment.