I am reading the acc of my Fenix 3 HR with a timer where I access Sensor.Info.accel. Sadly the maximum frequency to have a timer executed is 20Hz which is not too much.
Can I somehow up the frequency I am polling the value?
Furthermore I am logging the acc data to a TXT file via the System.println() call which I suppose is very slow and a bad way to do.
Is there a better way to story the acc data? I need to store it so I can analyze it on the PC. Later on I will real time process the data on the watch.
Using .FIT files doesn't work since the format is VERY crpytic (even when converted to CSV and I am unable to optain a format explanation) AND the .FIT files are always corrupted ... (bad checksum ...)
The code I am using is:
using Toybox.Graphics as Gfx;
using Toybox.WatchUi as Ui;
using Toybox.Sensor as Sensor;
using Toybox.FitContributor as Fit;
using Toybox.ActivityRecording as Record;
class CounterView extends Ui.View {
var counter = 0;
var started = false;
var ui_update_timer = null;
var fit_update_timer = null;
var session = null;
var fit_data = null;
var acc = [0, 0, 0];
function initialize() {
View.initialize();
}
function onLayout(dc) {
ui_update_timer = new Timer.Timer();
ui_update_timer.start(method(:ui_update_callback), 100, true);
}
function onUpdate( dc ) {
var flags = Gfx.TEXT_JUSTIFY_CENTER | Gfx.TEXT_JUSTIFY_VCENTER;
var center_x = dc.getWidth() / 2;
var center_y = dc.getHeight() / 2;
dc.setColor( Gfx.COLOR_BLACK, Gfx.COLOR_BLACK );
dc.clear();
dc.setColor( Gfx.COLOR_WHITE, Gfx.COLOR_TRANSPARENT );
dc.drawText(center_x, center_y - 20, Gfx.FONT_SMALL, acc[0], flags );
dc.drawText(center_x, center_y, Gfx.FONT_SMALL, acc[1], flags );
dc.drawText(center_x, center_y + 20, Gfx.FONT_SMALL, acc[2], flags );
}
function start() {
if((session == null) || (session.isRecording() == false)) {
session = Record.createSession({:name=>"Counter", :sport=>Record.SPORT_GENERIC});
// fit_data = session.createField("acc", 0, Fit.DATA_TYPE_SINT16, {:mesgType=>Fit.MESG_TYPE_RECORD, :units=>"bars"});
fit_update_timer = new Timer.Timer();
fit_update_timer.start(method(:fit_update_callback), 50, true);
session.start();
Ui.requestUpdate();
}
}
function stop() {
if((session != null) && session.isRecording()) {
fit_update_timer.stop();
session.stop();
session.save();
session = null;
Ui.requestUpdate();
}
}
function ui_update_callback() {
Ui.requestUpdate();
}
function fit_update_callback() {
var info = Sensor.getInfo();
if(info has :accel and info.accel != null){
acc = info.accel;
// fit_data.setData(acc[0]);
System.println(acc);
}
}
}
Could anybody give me a hint.
Best regards
Noah