Save touch setting for use when logged-out

This commit is contained in:
Peter D. Gray 2018-11-09 12:58:25 -05:00
parent fd9d2f467a
commit 4e8186a1dc
4 changed files with 16 additions and 3 deletions

View File

@ -97,6 +97,16 @@ def sensitivity_chooser():
settings.set('sens', value)
numpad.sensitivity = value
# save also for next login time.
from main import pa
from nvstore import SettingsObject
if not pa.is_secondary:
tmp = SettingsObject()
tmp.set('sens', value)
tmp.save()
del tmp
return which, [n for k,n in ch], set_it
# EOF

View File

@ -57,6 +57,9 @@ sf = SPIFlash()
from nvstore import SettingsObject
settings = SettingsObject(loop)
# important default/restore preference
numpad.sensitivity = settings.get('sens', numpad.sensitivity)
async def done_splash2():
# Boot up code; after splash screen is done.

View File

@ -72,7 +72,7 @@ class Numpad:
CTPH=12, CTPL=12, pulse_prescale=4, max_count=16383)
self.debug = 0 # 0..2
self.sensitivity = 1 # 0..2: 0=sensitive, 2=less-so, 3=new level, etc
self.sensitivity = 1 # 0..4: random order now, see chooser.py
self.baseline = None
self.count = 0
self.levels = array.array('I', (0 for i in range(NUM_PINS)))

View File

@ -48,7 +48,7 @@ _tmp = nvstore_buf
class SettingsObject:
def __init__(self, loop):
def __init__(self, loop=None):
self.loop = loop
self.current = {}
self.is_dirty = 0
@ -202,7 +202,7 @@ class SettingsObject:
def changed(self):
self.is_dirty += 1
if self.is_dirty < 2:
if self.is_dirty < 2 and self.loop:
self.loop.call_later_ms(250, self.write_out())
def put(self, kn, v):