Skip to content

Instantly share code, notes, and snippets.

@kimmoli
Last active October 4, 2018 16:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kimmoli/d2910acd355cf9214ea6aa8435a1e616 to your computer and use it in GitHub Desktop.
Save kimmoli/d2910acd355cf9214ea6aa8435a1e616 to your computer and use it in GitHub Desktop.
import QtQuick 2.0
import Sailfish.Silica 1.0
import org.nemomobile.dbus 2.0
Page
{
property var stepsNow: 0
Component.onCompleted:
{
stpcntrd.getSteps()
stpcntrd.setAutoUpdate(true)
}
Component.onDestruction:
{
stpcntrd.setAutoUpdate(false)
}
Label
{
anchors.centerIn: parent
text: "Step count: " + stepsNow
font.pixelSize: Theme.fontSizeLarge
}
DBusInterface
{
id: stpcntrd
service: 'com.kimmoli.stpcntrd'
path: '/'
iface: 'com.kimmoli.stpcntrd'
signalsEnabled: true
function steps(val)
{
console.log("steps: ", val)
stepsNow = val
}
function setAutoUpdate(val)
{
typedCall('setAutoUpdate',
[ { 'type': 'b', 'value' : val } ],
function(result) { console.log('stepcounter auto update ', val) },
function() { console.log('stepcounter call failed') }
)
}
function getSteps()
{
typedCall('getSteps',
[],
function(result) { stepsNow = result },
function() { console.log('stepcounter call failed') }
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment