Documentation

*now with internet permission

A Lua interpreter with Lua 5.3.5 (most recent as of march 9 2019)
load, save, edit, and run lua code, searchable Lua 5 manual

*Save your code to custom filename.lua in your documents/lua/ folder.
*Save output which defaults to /lua/output.txt
*Share: launches your file share app (e.g. filesmaster app works) to send lua file to your phone.
*Change font size of both input and output

*search code, search and replace all amongst code,
*Lua code access to watch sensors (light,pressure,heartrate, etc see below)
*a userlib.lua for storing your reusable functions and using them across many projects

Errata:

*consider using a qwerty keyboard (e.g. agile keyboard app) if the Samsung handwriting keyboard gives you trouble.

Please note:

*Make sure to use [[ ]] and ' ' instead of " " in your lua code.  Tizen OS captures quotes.
for instance print('some text') works while print("some text") doesn't.  Somehow, a quote " in your code will actually give a compiler error. *FIXED in upcoming version (not the one pushed to store on march 8, but ive fixed it since)

*print output is routed to the variable printArgs.  This means you can get the input of all print() calls on newlines by returning the variable printArgs fwhich causes it to output.  The default program gives an example of this.  To get the value in reverse, return variable reversePrint

*userlib must not return a value from the script (e.g. dont end your script with "return var" (result is that you dont get the proper output from your code in the output area) (you can define main() here and return a result from it though).

Lua Interpretor behavior:

If /lua/userlib.lua has error, give that error as output
~or~
if userlib is ok, check the user's code for errors, on error give that error as output
~or~
if userlib and the user's lua file both compile, the output result will be the returned value of the user's script. (e.g. (your code)... return var)
~or~
if both files compile and the function 'main' exists, run main in protected mode and output the returned value. (e.g. (your code)..function main return 'test' end) output is: test
~and~
after Execution, reload the lua environment (you may have to wait for some sensors input)

NOTE: if main() does not exist when you press the purple X to execute your lua code, it will give back the error "attempt to call a nil value"

*lua Code loaded into the editor that is longer than 200,000 characters will probably crash the app.
theoretically your userlib.lua should also be less than 200,000 characters.
This is a hardcoded limit that i can update as necessary.

under development:
Button screen with ten buttons linked to lua in upcoming version. (not pushed to store yet but complete)

future:
more sensors
more lua code buttons (check!)

Complete Sensor List available to Lua: (variables contain sensor data) - (GW) means supported on galaxy watch. (contains data like...)

All sensor values default to -1. use the menu to turn on sensors and set interval.

(GW) Barometric pressure Sensor
var_pressure (float)

(GW) Light Sensor
var_light (integer)

(GW) Heart Rate
var_heart (integer)

(GW) Gravity sensor three axis. All integers
var_gravX
var_gravY
var_gravZ


(GW) Accelerometer (all integers)
var_accelX
var_accelY
var_accelZ

(GW) Gyroscope
var_gyroX
 var_gyroY
 var_gyroZ

(GW) Gyroscope Vector Sensor three axis
var_gyrovectX
 var_gyrovectY
var_gyrovectZ

(GW) GPS location lat and long (with decimals, in c they were doubles. In Lua they are just "numbers") known glitch: no decimal places
var_lat
var_long

(GW) Pedometer (7 different readings) (integers, frequency is float)
(note that step count is incremented from 0, apparently from when you start wristLua and is not equal to the step count in your Samsung health.

var_steps
var_walking
var_running
var_distance
var_calories
var_speed
var_frequency
var_pedestrian (not sure what this one is but ive defaulted it to a 0 value)


Magnetic Sensor var_magnetic  (not supported on galaxy watch, but if it does become supported, this will grab the value)

Most of the sensors get fresh values every second or half second. (except barometer)



Reserved by wristLua: variables starting with var_ and functions starting with wl_ are built into the system so avoid overwriting them in Lua.

No comments:

Post a Comment