Trndi supports ES2023, and provides these functions in addition to it:
These functions are available via Trndi.*
, such as Trndi.alert(...)
:
Trndi.alert("hello")
Result: none
Trndi.confirm("Yes or no?")
Result: true
or false
Trndi.prompt("Enter a value", "We're asking for a value", "default value")
Result: string
Trndi.select("Select your choice", "Choose one of these", ...listOfStringOptions);
Result: integer (zero-based index)
See console.log
Prints out data to the user
Trndi.setBadgeSize(0.9, 9);
Sets size of the reading overlay for Windows Above: Set size to 90% of the Windows app icon with font 9.
Trndi.setDotSize(2);
Sets scale of the trend dots. 2 = 2x etc.
Trndi.setDotAdjust(0.1);
Multiplier on where the dots are drawn on screen up/down. Minus = up, plus = down
Trndi.getUnit()
Returns the current unit: "mg/dL"
or "mmol/L"
.
Trndi.getLocale()
Returns a language code (such as sv
or en
).
Trndi.setLevelColor('#7cd55d','#d55d5d', '#5dc6d5',// Readings (ok, hi, lo))
'#7cd55d','#612828', '#5d75d5', // Colors for the dots (ok, hi, lo)
'#ffbfbf', '#bffff9'); // Color for the custom levels set in NightScout (or via JS) (hi, lo)
Trndi.setTimeAndRange(20, 4); // Sets the max time to fetch to 20 minutes and the range to 4 readings
Trndi.playSound('C:\\file.wav')
Trndi.sayText('High sugar!')
These are global promises, not prefixed with Trndi.
:
asyncGet("https://sample-files.com/downloads/documents/txt/simple.txt")
.then(result => console.log(result))
.catch(error => console.log(`Error: ${error}`));
runCMD('appname.exe')
runCMD('appname.exe', 'parameter', 'sign for parameter separation')
ex:
runCMD("explorer.exe")
.then(result => result ? 'Success' : 'Process returned false')
.catch(error => console.log(`Error!`));
setLimits(low, high, lowRange, highRange)
Note: parameters 3 and 4 are optional! Use floats for mmol/L and integers for mg/dL!
setLimits(3.2, 16.4, 4.1, 12.7).then(() =>Trndi.alert("Custom limits set"));
NOTE: Simply add a function, named the same as a callback below, to have it triggered
updateCallback
This function is called when the main loop updates the reading
updateCallback(reading_system, reading_mgdl, reading_mmol, time)
fetchCallback(reading_mgdl, reading_mmol, delta_mgdl, delta_mmol, has_data)
dotClicked(open, mgdl, mmol, time)
function dotClicked(open, mgdl, mmol, time){console.log("Is the dot now showing the value? " + open, "Reading " + mmol, "Time: " + time )} // if the dot is "open" its showing the reading, not the dot icon
uxClick(element, value)
function uxClick(element, value, ...values){
console.log('clicked', element, 'value of dialog box', value)
return true; // false suppresses Trndi's own dialog
// element =
// "tir" - Time in range was clicked, value = time span, value2 = percent
// "no-reading" - The "No reading" popup is clicked, no args
// "range" - Over/Under range bar is clicked, value = true if the reading is high
}
clockView(glucose_mgdl, glucose_mmol, time)
function clockView(glucose, time){
const user = Trndi.getCurrentUser(); // Returns the username, if running multiple accounts
if (user) return user;
return "Hello"; // Shows Hello instead of the clock every 20 seconds
}
false
when not in multi-user mode)const user = Trndi.getCurrentUser();
if (user === false)
console.log("Not multi user!");
else if (user === '')
console.log("Default user");
else
console.log(`Logged in as ${user}`);
false
if not in multi-user mode)const nick = Trndi.getCurrentNickname();
// See getCurrentUser for usage pattern
// Localized greeting example using getLocale
const lang = Trndi.getLocale();
const strs = {
sv: { Hey: "Hej och välkommen" },
en: { Hey: "Hello and welcome" },
};
Trndi.alert(strs[lang]?.Hey || "Hello and welcome!");