From 704ec5fea10edb56e680e064181109a440e87dcb Mon Sep 17 00:00:00 2001 From: echarlie Date: Tue, 2 Jan 2024 21:02:21 -0500 Subject: [PATCH 1/4] implement naive timer --- firmware/measure.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/firmware/measure.py b/firmware/measure.py index 051aeb9..8c32f89 100644 --- a/firmware/measure.py +++ b/firmware/measure.py @@ -51,6 +51,12 @@ async def measure(devices: hardware.Hardware, cfg: config.Config, disp: display. if btn == "a": if click == Button.SINGLE: await asyncio.sleep(0.3) + # long click should start timer. + # consider making this more sophisticated + if click == Button.LONG: + for i in range(10): + devices.beep_bip() + await asyncio.sleep(1) success = await take_reading(devices, cfg, disp) elif btn == "b": logger.debug("B pressed") From 9e8e6d1000f7d24f8f3a97a2cc46ad8a29d29c1b Mon Sep 17 00:00:00 2001 From: echarlie Date: Sun, 7 Jan 2024 17:58:30 -0500 Subject: [PATCH 2/4] implement basic timer config --- firmware/config.py | 6 ++++-- firmware/measure.py | 3 +-- firmware/menu.py | 9 +++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/firmware/config.py b/firmware/config.py index acb26a1..60c9d95 100644 --- a/firmware/config.py +++ b/firmware/config.py @@ -33,7 +33,8 @@ def __init__(self, laser_cal: int = 0.157, save_readings: bool = False, low_precision: bool = False, - calib: dict = None): + calib: dict = None, + timer: int = 5): self.timeout = timeout self.angles = angles self.units = units @@ -51,6 +52,7 @@ def __init__(self, self.calib: Optional[Calibration] = Calibration.from_dict(calib) else: self.calib: Optional[Calibration] = None + self.timer = timer def as_dict(self): dct = {} @@ -166,4 +168,4 @@ def convert_distance(self, distance): if self.units == self.IMPERIAL: return distance * _FEET_PER_METRE else: - return distance \ No newline at end of file + return distance diff --git a/firmware/measure.py b/firmware/measure.py index 8c32f89..8e2eb09 100644 --- a/firmware/measure.py +++ b/firmware/measure.py @@ -52,9 +52,8 @@ async def measure(devices: hardware.Hardware, cfg: config.Config, disp: display. if click == Button.SINGLE: await asyncio.sleep(0.3) # long click should start timer. - # consider making this more sophisticated if click == Button.LONG: - for i in range(10): + for i in range(cfg.timer): devices.beep_bip() await asyncio.sleep(1) success = await take_reading(devices, cfg, disp) diff --git a/firmware/menu.py b/firmware/menu.py index 42f52d0..310feb7 100644 --- a/firmware/menu.py +++ b/firmware/menu.py @@ -73,6 +73,15 @@ async def menu(devices: hardware.Hardware, cfg: config.Config, disp: display.Dis ("5 minutes", 300), ] )), + ("Timer", ConfigOptions( + name="timer", obj=cfg, + options=[ + ("0 seconds", 0), + ("3 seconds", 3), + ("5 seconds", 5), + ("10 seconds", 10), + ] + )), ("Distance Units", ConfigOptions( name="units", obj=cfg, options=[ From eaa5e4457f9ee91b8dbde28e49409b7085bb5403 Mon Sep 17 00:00:00 2001 From: echarlie Date: Sun, 7 Jan 2024 18:05:51 -0500 Subject: [PATCH 3/4] update docs to include mention of timer --- firmware/docs/source/index.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/firmware/docs/source/index.rst b/firmware/docs/source/index.rst index b137c28..8fe9ab2 100644 --- a/firmware/docs/source/index.rst +++ b/firmware/docs/source/index.rst @@ -37,8 +37,8 @@ Measure Mode (to take readings) Press **A** to take a reading. You will get an error if the device is not already :ref:`calibrated `. You can choose either a short press of **A** (the reading is taken just after the button is released) or a long press -of **A** (the reading is taken once the button has been pressed for a second or so). Play with each mode and see what -suits you. +of **A** (the reading is taken after a countdown timer, which defaults to 5 seconds and can be configured). +Play with each mode and see what suits you. If the reading is successful you will see three numbers on the screen: .. compass at the top (degrees or grad) @@ -362,4 +362,4 @@ Gaskets ******* You can use 1mm silicone sheet or EVA foam for these pieces. Note that EVA foam works well but permanently deforms when -used so will need replacing if you ever disassemble the device. \ No newline at end of file +used so will need replacing if you ever disassemble the device. From 4ae638827d2d7eb89adbde443e3644da5a81af13 Mon Sep 17 00:00:00 2001 From: echarlie Date: Mon, 8 Jan 2024 15:38:19 -0500 Subject: [PATCH 4/4] make 0s the default and update documentation to suit --- firmware/config.py | 2 +- firmware/docs/source/index.rst | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/firmware/config.py b/firmware/config.py index 60c9d95..c394e28 100644 --- a/firmware/config.py +++ b/firmware/config.py @@ -34,7 +34,7 @@ def __init__(self, save_readings: bool = False, low_precision: bool = False, calib: dict = None, - timer: int = 5): + timer: int = 0): self.timeout = timeout self.angles = angles self.units = units diff --git a/firmware/docs/source/index.rst b/firmware/docs/source/index.rst index 3f04346..97aa7c6 100644 --- a/firmware/docs/source/index.rst +++ b/firmware/docs/source/index.rst @@ -37,7 +37,7 @@ Measure Mode (to take readings) Press **A** to take a reading. You will get an error if the device is not already :ref:`calibrated `. You can choose either a short press of **A** (the reading is taken just after the button is released) or a long press -of **A** (the reading is taken after a countdown timer, which defaults to 5 seconds and can be configured). +of **A** (the reading is taken after about a second, or can trigger a countdown timer which can be configured). Play with each mode and see what suits you. If the reading is successful you will see three numbers on the screen: @@ -73,6 +73,11 @@ be stored in a separate trip file. There is a battery level indicator on the bottom right of the screen. If you want to save power, turn off the device between stations. +When you hold **A** to take a reading, the SAP6 will trigger a timer. The timer mode can be configured to a 0, 3, 5, +or 10 second countdown. For settings greater than 0, the unit will beep every second until it takes the reading. +If set to 0, it will take the reading after about a second while the button is still held (this is the normal +behavior in firmware versions 1.0.2 and prior). + Battery Life ------------