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 Jan 19, 2024
1 parent 95e1a29 commit dc6182f
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 @@ -543,7 +540,7 @@ def _start_measurements(self):
self.time_shift], reqclock=reqclock)
def _finish_measurements(self):
# 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.bulk_queue.clear_samples()
self.sensor_helper.last_temperature = None
logging.info("Stopped angle '%s' measurements", self.name)
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 dc6182f

Please sign in to comment.