Im not sure if this is just me not being smart enough or if kwgt is the wrong app for me but let me expand:
Im trying to have a button, that if i press starts a stopwatch, this should be represented in a bar that will fill up to a preset amount. if it goes over the preset another bar should fill. Quite simple in theory.
Ive only done a simple music Widget and some Battery related stuff so im not very competent yet.
I reseached a bit and everything i found was working with Tasker for that, but i bit my teeth out trying to learn Tasker.
Now for my way of trying with KWGT:
I tried switching a Global bool that starts counting in another global, i failed misserably. I have no clue how to have Globals Interact with another or even how to count with them.
I tried having the button start the activity of my stopwatch and have KWGT read that. That also didnt work at all. I got the button to start the app but thats about it.
I have a fundamental understanding of code as in JavaScript and a bit of Python but it appears nothing translates well into kustom, exept for simple calculations.
I would appriciate a tip before i go and spend hours on coding my own widget for android, which i want to avoid very much.
I don’t recommend you to use KWGT for your stopwatch widget since it only updates per second basis (maximum, fast mode).
If you really want to do it, use tasker for your stopwatch. Pass the time value to a global variable via intent (org.kustom.action.SEND_VAR) or it’s tasker plugin per second. Access the passed value via br(tasker/#your identifier, #variable name)
For your bars, use formula with offset (I’m assuming that your stopwatch’s unit is in seconds)
Level formula for your progress bars: lv(sec, #seconds per bar)+mu(max, 0, ((gv(time)-(#sec*si(mindex)))/#sec)*100)
To start/stop your stopwatch but don’t want too much scenes. You can create a flow and pass all your data (actions like start or stop) to tasker (I’m using macrodroid)
ok i just played around with macrodroid and holy, it is so much easier than tasker, thx for making me aware of it. I will answer you if i get it working, so you dont need to spend the time
I have done two versions of the stopwatch, one with macrodroid, one without macrodroid (pure flow)
Tested with OPPO, with macrodroid is more stable (actually updating per second), while pure KWGT aren’t stable (like 4-5 sec update interval, maybe a quirk from using flows as tick)
Here’s the fixed macro, just import it and delete the old version Stopwatch_v2.macro.komp (32.8 KB)
. I’m currently working on macrodroid-less version (it’s a torture)
Edit: adding version without macrodroid (pure flow)
Note that it is janky in start/stop, since it need to do a ton of calculations, especially in editor (not in widget actually?). This is just a tech demo to show even kwgt can do such a complex task. Probably the second most complex thing I’ve ever done in kustom. stopwatch_without_macrodroid_v2.kwgt (303.7 KB)