Skip to content

Commit

Permalink
sensor_angle: No need to send messages when stopping queries
Browse files Browse the repository at this point in the history
Simplify the mcu code as any messages are ignored by the host anyway.

Signed-off-by: Kevin O'Connor <[email protected]>
  • Loading branch information
KevinOConnor committed Dec 18, 2023
1 parent f200c16 commit 49ea4b5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
7 changes: 2 additions & 5 deletions klippy/extras/angle.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ def __init__(self, config):
self.oid = oid = mcu.create_oid()
self.sensor_helper = sensor_class(config, self.spi, oid)
# Setup mcu sensor_spi_angle bulk query code
self.query_spi_angle_cmd = self.query_spi_angle_end_cmd = None
self.query_spi_angle_cmd = None
mcu.add_config_cmd(
"config_spi_angle oid=%d spi_oid=%d spi_angle_type=%s"
% (oid, self.spi.get_oid(), sensor_type))
Expand All @@ -462,9 +462,6 @@ def _build_config(self):
self.query_spi_angle_cmd = self.mcu.lookup_command(
"query_spi_angle oid=%c clock=%u rest_ticks=%u time_shift=%c",
cq=cmdqueue)
self.query_spi_angle_end_cmd = self.mcu.lookup_query_command(
"query_spi_angle oid=%c clock=%u rest_ticks=%u time_shift=%c",
"spi_angle_end oid=%c sequence=%hu", oid=self.oid, cq=cmdqueue)
def get_status(self, eventtime=None):
return {'temperature': self.sensor_helper.last_temperature}
def add_client(self, client_cb):
Expand Down Expand Up @@ -547,7 +544,7 @@ def _finish_measurements(self):
if not self._is_measuring():
return
# Halt bulk reading
params = self.query_spi_angle_end_cmd.send([self.oid, 0, 0, 0])
self.query_spi_angle_cmd.send_wait_ack([self.oid, 0, 0, 0])
self.start_clock = 0
self.bulk_queue.pull_samples()
self.sensor_helper.last_temperature = None
Expand Down
7 changes: 2 additions & 5 deletions src/sensor_angle.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,10 @@ command_query_spi_angle(uint32_t *args)

sched_del_timer(&sa->timer);
sa->flags = 0;
if (!args[2]) {
if (!args[2])
// End measurements
if (sa->data_count)
angle_report(sa, oid);
sendf("spi_angle_end oid=%c sequence=%hu", oid, sa->sequence);
return;
}

// Start new measurements query
sa->timer.waketime = args[1];
sa->rest_ticks = args[2];
Expand Down

0 comments on commit 49ea4b5

Please sign in to comment.