Browse Source

Added config option to invert the Gabelschalter input

pull/1/head
klonfish 9 years ago
parent
commit
ace97d5657
  1. 7
      configreader.py
  2. 1
      fetap.ini.example
  3. 5
      tuitest.py

7
configreader.py

@ -15,6 +15,7 @@ class ConfigurationReader(object): @@ -15,6 +15,7 @@ class ConfigurationReader(object):
'pin_wecker_enable': '16',
'pin_wecker_a': '18',
'pin_wecker_b': '19',
'invert_gs' : 'false',
'default_proxy': ''
}
@ -35,6 +36,9 @@ class ConfigurationReader(object): @@ -35,6 +36,9 @@ class ConfigurationReader(object):
def __get_global_val_int(self, option):
return int(self.__cp.get('fetapd', option))
def __get_global_val_bool(self, option):
return self.__cp.get('fetapd', option).lower() in ['true', 'yes', '1']
def __get_proxy_val(self, proxyname, option):
return self.__cp.get('proxy_'+proxyname, option)
@ -66,7 +70,8 @@ class ConfigurationReader(object): @@ -66,7 +70,8 @@ class ConfigurationReader(object):
pin_schauzeichen = self.__get_global_val_int('pin_schauzeichen'),
pin_wecker_enable = self.__get_global_val_int('pin_wecker_enable'),
pin_wecker_a = self.__get_global_val_int('pin_wecker_a'),
pin_wecker_b = self.__get_global_val_int('pin_wecker_b')
pin_wecker_b = self.__get_global_val_int('pin_wecker_b'),
invert_gs = self.__get_global_val_bool('invert_gs'),
)
self.__dialconfig = fetapdtest.DialConfiguration(

1
fetap.ini.example

@ -10,6 +10,7 @@ pin_schauzeichen = 12 @@ -10,6 +10,7 @@ pin_schauzeichen = 12
pin_wecker_enable = 16
pin_wecker_a = 18
pin_wecker_b = 19
invert_gs = false
; Zeit bevor ein eingehender Anruf automatisch abgewiesen wird
incoming_timeout = 60

5
tuitest.py

@ -7,7 +7,7 @@ import threading @@ -7,7 +7,7 @@ import threading
class FeApPinConfiguration(object):
def __init__(self, gpio_numbering, pin_nsa, pin_nsi, pin_gabelschalter,
pin_schauzeichen, pin_wecker_enable, pin_wecker_a,
pin_wecker_b):
pin_wecker_b, invert_gs):
if gpio_numbering == 'BOARD':
gpio_numbering = gpio.BOARD
elif gpio_numbering == 'BCM':
@ -23,6 +23,7 @@ class FeApPinConfiguration(object): @@ -23,6 +23,7 @@ class FeApPinConfiguration(object):
self.pin_wecker_enable = pin_wecker_enable
self.pin_wecker_a = pin_wecker_a
self.pin_wecker_b = pin_wecker_b
self.invert_gs = invert_gs
class FeApUserInterface(object):
def __init__(self, pinconfig):
@ -69,6 +70,8 @@ class FeApUserInterface(object): @@ -69,6 +70,8 @@ class FeApUserInterface(object):
def __on_gabelschalter_change(self, pin):
gbstate = gpio.input(self.__pinconfig.pin_gabelschalter)
if self.__pinconfig.invert_gs:
gbstate = 1 - gbstate
print 'gabelschalter:', gbstate
for cb in self.__gabelschalter_callbacks:
cb(gbstate)

Loading…
Cancel
Save