Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
[fw/altos] / altoslib / AltosTelemetryCompanion.java
index a97fda2d0cbb5135601cafddba6aafe431cb21c7..c6dfe3eb90a54d2a1579bc7610a12d75260d1439 100644 (file)
  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  */
 
-package org.altusmetrum.altoslib_11;
+package org.altusmetrum.altoslib_12;
 
 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;
        }
 
-       public void update_state(AltosState state) {
-               super.update_state(state);
+       static final public int max_channels = 12;
+
+       public AltosTelemetryCompanion(int[] bytes) throws AltosCRCException {
+               super(bytes);
+       }
 
-               state.set_companion(companion);
+       public void provide_data(AltosDataListener listener) {
+               super.provide_data(listener);
+               listener.set_companion(companion());
        }
 }