KWGT Formula to show picture based on moonfase no longer shows the right picture

Hi Dev,

As it says in the title, for example the formula $if(ai(mage)=29, “file:/emulated/0/KWGT/Kustom/bitmaps/Moon/29-waning-crescent.png”)$ from one day to the other stopped showing the correct picture.
I have 29 of these lines and based on the moonfase it shows a certain picture.
The weird thing is, that in the text preview box it does show the correct line out of the 29.
Meaning it accurately shows file:/emulated/0/KWGT/Kustom/bitmaps/Moon/4-waxing-crescent.png")$, but the picture in my widget stays always the same.
I am not sure which KWGT version introduced this bug.

I tested to see if showing one picture without formula shows a picture, and it does.

I hope you can find the problem because my whole moonfase widget has become useless.

Thanks

Use the /sdcard/ path, as it’s the most reliable for Kustom:

“file://sdcard/Kustom/bitmaps/Moon/your_image.png”

Stop using 29 if lines: It’s very inefficient. Instead:

Rename your moon images to simple numbers: 0.png, 1.png, 2.png, etc., to match the values of $ai(mage)$.

Create a Global Bitmap for each number (name them 0, 1, 2…) Use this single line to automatically show the correct moon phase:

$gv(ai(mage))$

This works if your Globals are named after the phase numbers.

And that’s it now your widget will work perfectly.

This method is much faster, uses less battery, and won’t break after updates.

1 Like

Hi Max,

Thanks for the response and tips.
It was a bit confusing because I have globals in Root and in the Moon container. I found out I needed to use the latter. It’s working now. Thanks

Glad to hear it’s all working now!:+1:

1 Like

I’d love to see a screenshot of your widget if you don’t mind posting one.


Here you go. :slightly_smiling_face:

It’s a 24hr clock, midnight on the bottom, noon on top. Grey circle is time the moon is up, orange circle is time the sun is up. On top is total sun hours, bottom is total moon hours.
Left and right top circles used to show available data in my bundle and available calls/sms, but Android broke the USSDNot app, so it’s no longer fetching the data. I need to find another way.

2 Likes

It’s really interesting! Thanks for sharing.

This topic was automatically closed 25 days after the last reply. New replies are no longer allowed.