Open-Smartwatch / open-smartwatch-os

The Open-Smartwatch Operating System.
https://open-smartwatch.github.io
GNU General Public License v3.0
967 stars 155 forks source link

Updating LUA #385

Closed zwim closed 1 month ago

zwim commented 1 month ago

What is not working?

LUA is very outdated.

Crashes with BIG LUA files

Interpreting big LUA files takes too much memory.

Proposal

Update LUA-support to 5.4, include compiled (and not the original) LUA-files in firmware and automate this LUA-compilation.

Solution

You find my solution in -> https://github.com/zwim/open-smartwatch-os/tree/ZwilightWatchface

Showcase

The outer ring goes from 0 -> 24h; 0 o'clock is in the bottom.

The outer blue ring shows if the sun is over the horizon; the yellow markers show the different twilights (civil, nautical, astronomical). All this is calculated with a LUA script.

(Sidemark: Note how good the anti-aliased hands, indices and arcs look like!)

grafik

And now

If anyone has interest in using some educated LUA-scripts (or about twilight) please make a comment.

simonmicro commented 1 month ago

I think this is a really cool idea! I'm interested in merging this. Although, pre-compiled LUA - why not using C++ directly then? LUA has the advantage of being source-available and can be easily loaded from e.g. an SD-card, but by compiling you are removing that advantage.

zwim commented 1 month ago

You are right, a big advantage of LUA is its readability.

Although my suntime.lua is much takes to much memory to be compiled on the watch, the luac compiled version works well.

I am not using a C++ method, because this suntime.lua is tested well and works (despite it is much more precise as anything else, which is tiny enough to fit on the watch).

zwim commented 1 month ago

Works now in the emulator, too

zwim commented 1 month ago

Closing this in favor of #396.