Im new to connect iq development and rather confused about the whole thing so forgive me if my code is entirely wrong. I am trying to create a very simple test app that connects to my Varia radar and displays radar info. I presumed for the onUpdate() function to consistently update it would have to get data fed to it by a compute method but when I set this up the onUpdate function didn't display any information at all whereas before it displayed a set of 0's (suggesting that it connected to the radar but wasn't receiving any info). Is there another function such as OnSensor that I have to use instead?
import Toybox.Graphics;
import Toybox.WatchUi;
import Toybox.AntPlus;
class RadarTestView extends WatchUi.View {
function initialize() {
View.initialize();
}
var bikeRadar = new AntPlus.BikeRadar(null);
var data = false;
var radarArray = new [8];
// Load your resources here
function onLayout(dc as Dc) as Void {
dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_TRANSPARENT);
dc.fillRectangle(0, 0, dc.getWidth(), dc.getHeight());
}
// Called when this View is brought to the foreground. Restore
// the state of this View and prepare it to be shown. This includes
// loading resources into memory.
function onShow() as Void {
}
// Update the view
function onUpdate(dc as Dc) as Void {
var drawValues = [1,2,3,4,5,6,7,8];
for(var i = 0; i<8; i++){
dc.setColor(Graphics.COLOR_BLACK, Graphics.COLOR_TRANSPARENT);
dc.drawText(
dc.getWidth() / drawValues[i], // gets the width of the device and divides by 2
dc.getHeight() / drawValues[i], // gets the height of the device and divides by 2
Graphics.FONT_SMALL, // sets the font size
radarArray[i], // the String to display
Graphics.TEXT_JUSTIFY_LEFT // sets the justification for the text
);
}
}
function compute(info){
var radarInfo = bikeRadar.getRadarInfo();
if(radarInfo){
for(var i = 0; i < 8; i++){
radarArray[i] = radarInfo[i].range;
}
}
}
// Called when this View is removed from the screen. Save the
// state of this View here. This includes freeing resources from
// memory.
function onHide() as Void {
}
}