added on_nummernschalter_active event, stop playing the dailtone once it occurs
This commit is contained in:
parent
3ceb7fade3
commit
e8ab032e89
2 changed files with 28 additions and 6 deletions
|
@ -38,6 +38,9 @@ class AbstractState(object):
|
|||
def on_invalid_number(self):
|
||||
raise IllegalEventError()
|
||||
|
||||
def on_nummernschalter_active(self):
|
||||
raise IllegalEventError()
|
||||
|
||||
def on_nummernschalter_input(self, num):
|
||||
raise IllegalEventError()
|
||||
|
||||
|
@ -74,6 +77,9 @@ class IdleState(AbstractState):
|
|||
def on_gabelschalter_down(self):
|
||||
pass
|
||||
|
||||
def on_nummernschalter_active(self, x):
|
||||
pass
|
||||
|
||||
def on_nummernschalter_input(self, x):
|
||||
pass
|
||||
|
||||
|
@ -178,6 +184,10 @@ class DialingState(AbstractState):
|
|||
self.__on_leave()
|
||||
return IdleState
|
||||
|
||||
def on_nummernschalter_active(self):
|
||||
if self.__dial_tone:
|
||||
self._controller.get_phone().stop_playing()
|
||||
|
||||
def on_nummernschalter_input(self, num):
|
||||
print('nummernschalter: %d' % (num))
|
||||
if self.__dial_tone:
|
||||
|
@ -257,7 +267,11 @@ def gabelschalter_cb(state):
|
|||
else:
|
||||
c.queue_event('gabelschalter_down')
|
||||
|
||||
def nummernschalter_cb(digit):
|
||||
def nummernschalter_active_cb():
|
||||
global c
|
||||
c.queue_event('nummernschalter_active')
|
||||
|
||||
def nummernschalter_done_cb(digit):
|
||||
global c
|
||||
c.queue_event('nummernschalter_input', digit)
|
||||
|
||||
|
@ -284,7 +298,8 @@ if __name__ == '__main__':
|
|||
c = StateMachineController(phone, feap)
|
||||
|
||||
feap.add_gabelschalter_callback(gabelschalter_cb)
|
||||
feap.add_nummernschalter_callback(nummernschalter_cb)
|
||||
feap.add_nummernschalter_active_callback(nummernschalter_active_cb)
|
||||
feap.add_nummernschalter_done_callback(nummernschalter_done_cb)
|
||||
phone.add_event_cb(phone_cb)
|
||||
|
||||
phone.start()
|
||||
|
|
15
tuitest.py
15
tuitest.py
|
@ -38,7 +38,8 @@ class FeApUserInterface(object):
|
|||
self.__nsi_cnt = 0
|
||||
self.__weckt = False
|
||||
|
||||
self.__nummernschalter_callbacks = []
|
||||
self.__nummernschalter_active_callbacks = []
|
||||
self.__nummernschalter_done_callbacks = []
|
||||
self.__gabelschalter_callbacks = []
|
||||
|
||||
def __on_nsa_change(self, pin):
|
||||
|
@ -46,8 +47,11 @@ class FeApUserInterface(object):
|
|||
if nsastate == 0:
|
||||
#self.__nsa_up_time = time.time()
|
||||
self.__nsi_cnt = 0
|
||||
|
||||
for cb in self.__nummernschalter_active_callbacks:
|
||||
cb()
|
||||
else:
|
||||
for cb in self.__nummernschalter_callbacks:
|
||||
for cb in self.__nummernschalter_done_callbacks:
|
||||
cb(self.__nsi_cnt % 10)
|
||||
|
||||
def __on_nsi_falling(self, pin):
|
||||
|
@ -82,8 +86,11 @@ class FeApUserInterface(object):
|
|||
def add_gabelschalter_callback(self, cb):
|
||||
self.__gabelschalter_callbacks.append(cb)
|
||||
|
||||
def add_nummernschalter_callback(self, cb):
|
||||
self.__nummernschalter_callbacks.append(cb)
|
||||
def add_nummernschalter_active_callback(self, cb):
|
||||
self.__nummernschalter_active_callbacks.append(cb)
|
||||
|
||||
def add_nummernschalter_done_callback(self, cb):
|
||||
self.__nummernschalter_done_callbacks.append(cb)
|
||||
|
||||
def set_wecker(self, enabled):
|
||||
if enabled and not self.__weckt:
|
||||
|
|
Loading…
Reference in a new issue