Update GPS Adv Sports II.js

pull/1394/head
nujw 2022-02-05 16:24:25 +13:00 committed by GitHub
parent ce039a95a8
commit a80d287c29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 39 additions and 4 deletions

View File

@ -1,4 +1,4 @@
// Add this script to DroidScript on an android device. / Add this script to DroidScript on an android device.
// Uses the PuckJS plugin to provide mirroring of the GPS Adv Sports II Bangle app face onto an android device. // Uses the PuckJS plugin to provide mirroring of the GPS Adv Sports II Bangle app face onto an android device.
app.LoadPlugin( "PuckJS" ); app.LoadPlugin( "PuckJS" );
@ -57,9 +57,9 @@ function OnStart()
layHor.AddChild(mode) layHor.AddChild(mode)
// sats = app.CreateText( '' ,.3,-1,"Right") // sats = app.CreateText( '' ,.3,-1,"Right")
sats = app.CreateText( '' ,-1,-1) sats = app.CreateText( '' ,-1,-1,"FillXY,Bottom")
sats.SetSize(200,-1,"px") sats.SetSize(200,-1,"px")
sats.SetTextSize( 32 ) sats.SetTextSize( 20 )
sats.SetTextColor('#00E4FF') // cyan sats.SetTextColor('#00E4FF') // cyan
layHor.AddChild(sats) layHor.AddChild(sats)
@ -80,6 +80,11 @@ function OnStart()
btnStop.SetBackColor(btnOff) btnStop.SetBackColor(btnOff)
layBtn.AddChild( btnStop ); layBtn.AddChild( btnStop );
btnScan = app.CreateButton( "Scan" );
btnScan.SetOnTouch( btn_OnScan );
btnScan.SetBackColor(btnOff)
layBtn.AddChild( btnScan );
/* /*
btn1 = app.CreateButton( " SPD " ); btn1 = app.CreateButton( " SPD " );
btn1.SetOnTouch( btn_OnBTN1 ); btn1.SetOnTouch( btn_OnBTN1 );
@ -102,6 +107,15 @@ function OnStart()
layBtn.AddChild( btn4 ); layBtn.AddChild( btn4 );
*/ */
// Status 'LED'
led = app.AddCanvas( layBtn, 0.1, 0.1,"FillXY,Bottom" )
// bt = app.CreateText( '' ,-1,-1)
// bt.SetSize(20,-1,"px")
// layBtn.AddChild(bt)
layVert.AddChild( layBtn ) layVert.AddChild( layBtn )
//Add layout to app. //Add layout to app.
@ -122,9 +136,15 @@ function readResponse(data) {
return return
} }
// Flash blue 'led' indicator when data packet received.
led.SetPaintColor("#0051FF")
led.DrawCircle( 0.5, 0.5, 0.1 )
led.Update()
setTimeout(clearLED, 500 )
if ( d.m == 0 ) { // Speed ( dont need pos or time here ) if ( d.m == 0 ) { // Speed ( dont need pos or time here )
val.SetTextSize( 120 ) val.SetTextSize( 120 )
val2.SetTextSize( 50 ) val2.SetTextSize( 500 )
val.SetText(d.sp) val.SetText(d.sp)
val2.SetText('') val2.SetText('')
@ -192,6 +212,13 @@ function readResponse(data) {
} }
function clearLED() {
led.Clear()
// led.SetPaintColor("#D31A99")
// led.DrawCircle( 0.5, 0.5, 0.1 )
led.Update()
}
function onConnect() { function onConnect() {
btn_OnStart() // Once connect tell app to start sending updates btn_OnStart() // Once connect tell app to start sending updates
} }
@ -215,6 +242,14 @@ function btn_OnStop()
sats.SetText('') sats.SetText('')
} }
function btn_OnScan()
{
btnStart.SetBackColor(btnOff)
btnStop.SetBackColor(btnOff)
puck.Scan("Bangle");
}
/* /*
function btn_OnBTN1() {puck.SendCode('btSetMode(0)\n')} // SPD function btn_OnBTN1() {puck.SendCode('btSetMode(0)\n')} // SPD