diff options
author | Keith Packard <keithp@keithp.com> | 2017-05-23 14:53:55 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2017-05-23 15:15:21 -0700 |
commit | 7600116a191b3ac252a0f716d200d0e0b3500987 (patch) | |
tree | c9cc6c418244d3e2fb5b5c1b9ab961f8a3f5ab30 /altoslib/AltosTelemetryCompanion.java | |
parent | abcedc4b49ce77607ef95abf69479dc1d2c1b76d (diff) |
altoslib: Don't store computed telemetry fields
These values are only needed once, so there's no reason to save them.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib/AltosTelemetryCompanion.java')
-rw-r--r-- | altoslib/AltosTelemetryCompanion.java | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/altoslib/AltosTelemetryCompanion.java b/altoslib/AltosTelemetryCompanion.java index a97fda2d..2c05e245 100644 --- a/altoslib/AltosTelemetryCompanion.java +++ b/altoslib/AltosTelemetryCompanion.java @@ -19,21 +19,16 @@ package org.altusmetrum.altoslib_11; public class AltosTelemetryCompanion extends AltosTelemetryStandard { - AltosCompanion companion; - - static final public int max_channels = 12; - - public AltosTelemetryCompanion(int[] bytes) { - super(bytes); + AltosCompanion companion() { int channels = uint8(7); if (channels > max_channels) channels = max_channels; - companion = new AltosCompanion(channels); + AltosCompanion companion = new AltosCompanion(channels); - companion.tick = tick; + companion.tick = tick(); companion.board_id = uint8(5); companion.update_period = uint8(6); @@ -45,11 +40,17 @@ public class AltosTelemetryCompanion extends AltosTelemetryStandard { for (int i = 0; i < channels; i++) companion.companion_data[i] = uint16(8 + i * 2); } + return companion; + } + + static final public int max_channels = 12; + + public AltosTelemetryCompanion(int[] bytes) throws AltosCRCException { + super(bytes); } public void update_state(AltosState state) { super.update_state(state); - - state.set_companion(companion); + state.set_companion(companion()); } } |