Skip to main content

Script

The RTU-X can run a program that adds local intelligence to the device. This script, written in the user interface in an intuitive language with many similarities to the C programming language, can perform all kinds of operations with inputs and outputs, slaves, the log, etc.

User interface script editor

The language's characteristics and its use in the user interface are described below.

Want an AI assistant to help you?

There's a Claude skill that knows this language in depth and can write, review, or debug scripts in a conversation — see AI Assistant (Claude).

The script editor​

Besides the editor, the Script section of the user interface has several tools for compiling and debugging the program in real time:

  • Compile / Compile and apply / Recover / Stop — control compiling and running the script on the connected device.
  • Script status — shows whether the script is Running or Stopped.
  • Memory — percentage of program, data, and code memory in use, to keep track of the available margin before hitting the device's limits.
  • Slave map — a grid with the status of each configured Modbus/BLE slave.
  • Variable viewer — shows the real-time value of the variables chosen with the selection button.
Variable selection to display

The variable selection modal organizes the available variables into tabs — Telemetry·Attribute·Shared, Slave queries, Calendar, Other + alias, and System — with a search box and Select all / Deselect all buttons to quickly build the set of variables to monitor while the script runs.

Language structure​

The script must start with the declaration of all the variables to be used. Declaring variables partway through the program isn't allowed.

After the variable declarations, the program code must be written. This code runs only once, so if you want it to run continuously it must be placed inside an infinite loop.

Control Flow​

If statement​

The syntax is as follows:

if (Condition1)
{
Instructions1
}
else if (Condition2)
{
Instructions2
}
else
{
Instructions3
}

If Condition1 is true, the Instructions1 block is executed; otherwise, if Condition2 is true, the Instructions2 block is executed; otherwise, the Instructions3 block is executed.

The else if and else blocks are optional.

While statement​

The syntax is as follows:

while (Condition)
{
Instructions
}

The instructions inside the while block run continuously as long as Condition is true. The instruction block can be empty.

For statement​

The syntax is as follows:

for (Exp1; Exp2; Exp3)
{
Instructions
}

Exp1 is an expression that runs only once, at the start of the loop. Exp1 usually contains an expression that initializes a counter used in the for loop.

Exp2 is the expression that indicates when the loop should end, and is therefore a conditional expression. This expression is evaluated at the start of each cycle of the loop, and the loop stops running when this expression is no longer true. As a result, the loop might not run at all.

Exp3 is an expression that runs at the end of each iteration, and is generally used to update the counter used in the loop.

On each iteration, all the statements inside the for block are executed.

Variables​

There are two types of variables: general purpose variables and system variables.

General purpose variables​

General purpose variables are those defined by the user in the script, and can be one of the following types:

TypeDescription
int16-bit signed integer. Ranges from -32,768 to 32,767
uint16-bit unsigned integer. Ranges from 0 to 65,535
long32-bit signed integer. Ranges from -2,147,483,647 to 2,147,483,647
ulong32-bit unsigned integer. Ranges from 0 to 4,294,967,295
float32-bit floating point number. Single-precision IEEE 754 representation

General purpose variables can be defined as arrays.

Some examples of variable definitions:

int i; // Variable of type int called i
float f; // Variable of type float called f

Telemetry, attribute, and shared variables​

Any general purpose variable can be defined with the telemetry, attribute, or shared prefix.

Variables must be defined as telemetry or attribute to be used with the log and report functions.

The shared prefix is used exclusively when the RTU-X is integrated via MQTT with Nettra's Telemetry+ system, for variables that hold configuration parameters that are adjusted from the system.

Some examples of variable definitions:

attribute float f; // Variable of type attribute float called f
telemetry int t; // Variable of type telemetry int called t

Arrays​

You can declare one- or two-dimensional arrays of any available data type. For example:

int a[10]; // Array of length 10
float b[12,3]; // Array of size 12 x 3

To avoid out-of-range evaluations, when a non-numeric expression is used as an index, it is evaluated modulo the corresponding maximum range. For example, for the arrays above:

c = a[3+i]; // the array is evaluated at position (3+i)%10

The maximum number of elements in a 1D array is 100. The maximum number of rows or columns in a two-dimensional array is 10.

An array can be declared as telemetry or attribute so its elements can be used as arguments to the log, report, logonchange, or report_on_change functions.

For one-dimensional arrays, the name stored in the event log will be the array name concatenated with the argument's offset expressed in decimal. For two-dimensional arrays, the array name is concatenated with the row number and column number expressed in hexadecimal.

Examples:

telemetry int a[10];
telemetry float b[12,3];

log(a[4]); // stored in the event log with the name a4
log(b[10,2]); // stored in the event log with the name bA2

Calendar variables​

Variables defined with the calendar prefix are associated with calendar events, defined either locally from the Events section of the user interface, or remotely via RPC commands when the RTU-X is integrated with Nettra's Telemetry+ system. Suppose we define the integer variables a and b as

calendar int a = 0;
calendar int b = 0;

When the system variable unix_ts_utc falls within the interval defined for an event, the event is said to be active, and the variables take the values defined in the event. Otherwise, the variables take the default value set at initialization. If two events overlap, the one that starts first takes effect.

Static variables​

Any general purpose variable can be defined with the static prefix.

When defined this way, the variable is stored in the RTU-X's non-volatile memory, so its value persists even if power and battery are lost.

To give a static variable an initial value, it must be initialized when declared. That way, the initial value is only loaded on the first run of the script, but not on subsequent runs.

For example:

static int a = 10;
static int b[3] = {1,2,3};

System reserved variables​

There's a set of predefined variables related to the operation of the RTU-X and its peripherals that can be used from the script.

The following variables are available:

VariableDescriptionType
INPUTS
ainAnalog inputs. Represents the voltage in mV (0 – 10,000) for voltage inputs, or the current in uA (0 – 20,000) for current inputs.int[8]
pulsesPulse count of the digital inputsulong[2]
MODBUS
slave_errorReflects the connection status between the RTU-X and the slaves. One bit is used per slave, where 1 indicates an error. For example, bit 2 of the variable represents the connection status with slave 2.int
TIME
hoursCurrent hour (0 – 24)uint
minutesCurrent minutes (0 – 59)uint
secondsCurrent seconds (0 – 59)uint
dayDay of the month (0 - 31)uint
monthCurrent month (1 – 12)uint
yearCurrent yearuint
week_dayDay of the week (0 = Sunday)uint
time_syncedIndicates whether the time is synchronized. The variable can be 0 or 1.int
unix_ts_utcNumber of seconds in Unix format of the device's UTC timeulong
unix_ts_localNumber of seconds in Unix format of the device's local timeulong
calendar_events_countNumber of events defined in the system. The maximum is 50uint
timer_etElapsed time (in milliseconds) of each timer() instance, useful for telemetry or debugging. The array index corresponds to the order in which each timer() call appears in the script.ulong[16]
SMS
sms_message

Index of the received message.

If there are no received messages, the variable is -1. After receiving and processing a message, the user must set this variable back to -1.

int
sms_parameterParameter of the received messagefloat
sms_phoneIndex of the phone that sent the received messageint
MODEM
modem_onIf the WAN module isn't configured to turn on automatically when the RTU-X powers on, setting this variable to 1 or 0 lets you turn the modem on or off from the script.int
modem_status

Reflects the modem's operating status. The possible values are:

  • MODEM_STATUS_NO_SIM (-3) – if the modem detects it has no SIM.
  • MODEM_STATUS_WAITING_PIN (-2) – if the installed SIM requires a PIN but none is configured.
  • MODEM_STATUS_WRONG_PIN (-1) – if the configured PIN is incorrect.
  • MODEM_STATUS_OFF (0) – if the modem is off.
  • MODEM_STATUS_TURNING_ON (1) – if the modem is turning on.
  • MODEM_STATUS_ON (2) – if the modem is on. It normally moves automatically from this state to registering and connecting, but if the modem is used only as GPS, this state indicates it's on.
  • MODEM_STATUS_REGISTERING (3) – if the modem is registering on the cellular network.
  • MODEM_STATUS_REGISTERED (4) – if the modem is registered on the cellular network. It only stays in this state when a data connection isn't used, since otherwise it moves on to connect.
  • MODEM_STATUS_CONNECTING (5) – if the modem is establishing the data connection with the cellular network.
  • MODEM_STATUS_CONNECTED (6) – if the modem successfully established the data connection with the cellular network.
int
modem_signalModem signal level in dBmint
LORA
lora_onIf the WAN module isn't configured to turn on automatically when the RTU-X powers on, setting this variable to 1 or 0 lets you turn the LoraWan module on or off from the script.int
lora_status

Reflects the LoraWan module's operating status. The possible values are:

  • LORA_STATUS_OFF (0) – The module is off.
  • LORA_STATUS_TURNING_ON (1) – The module is powering on.
  • LORA_STATUS_ON (2) – The module is on.
  • LORA_STATUS_JOINING (3) – The module is joining the LoraWan network.
  • LORA_STATUS_JOINED (4) - The module joined the configured LoraWan network
  • LORA_STATUS_JOIN_TIMEOUT (5) – The module attempted to connect and timed out.
int
lora_snrSignal-to-noise ratio in dB measured by the LoraWan module on the last transmissionint
lora_rssiSignal strength in dBm measured by the LoraWan module on the last transmissionint
WIFI
wifi_status

Reflects the WiFi's operating status. The possible values are:

  • WIFI_STATUS_OFF (0) – when the WiFi module is disabled.
  • WIFI_STATUS_DISCONNECTED (1) – when WiFi is disconnected.
  • WIFI_STATUS_CONNECTING (2) – when the WiFi connection is being established.
  • WIFI_STATUS_CONNECTED (3) – when the WiFi connection is established.
  • WIFI_STATUS_LISTENING (4) – when WiFi is working in AP (access point) mode.
int
wifi_signalWiFi signal level in dBmint
MQTT
mqtt_status

Reflects the MQTT connection status. The possible values are:

  • MQTT_STATUS_DISCONNECTED (0) – when the MQTT connection is disconnected.
  • MQTT_STATUS_CONNECTING (1) – when the MQTT connection is being established.
  • MQTT_STATUS_CONNECTED (2) – when the MQTT connection is established.
int
mqtt_pending_logNumber of records pending to be sent over MQTT.ulong
GPS
latitudeGPS latitudefloat
longitudeGPS longitudefloat
altitudeGPS altitudefloat
speedGPS speedfloat
BATTERY
battery_percentageBattery percentageuint
battery_protectionThe RTU-X's internal battery has overheat protection that cuts off the charging process when the temperature exceeds approximately 40°C. While this protection is necessary, when ambient temperature is high it causes the undesired effect of cutting off charging. With value 1 (default) the protection is enabled, while with value 0 the protection is disabled.int
battery_status

Reflects the battery's operating status. The possible values are:

  • BATTERY_STATUS_CHARGING (0) – if external power is connected and the battery is charging.
  • BATTERY_STATUS_CHARGED (1) – if external power is connected and the battery is fully charged.
  • BATTERY_STATUS_NO_POWER (2) – if the device is running on battery with no external power.
  • BATTERY_STATUS_NO_BATTERY (3) – if external power is connected and no battery is connected.
  • BATTERY_STATUS_OTHER (4) – error status
int

Bit access​

You can access any individual bit of any variable by placing a dot and the bit number after the variable's name.

Example that saves bit 2 of variable x into bit 3 of variable y:

y.3 = x.2;

Alias​

You can use an alias to refer to both general purpose variables and system variables. You can define an alias for any variable, an array element, or even a bit of a variable.

The following examples show the definition of different aliases:

alias error as slave_error.2; // Alias for slave 3's error
alias analogica2 as ain[1]; // Alias for analog input 2

Constants​

If constants are going to be used in the script, they can also be defined at the beginning of it. For example, to define a constant called THRESHOLD with a value of 30, you would do the following:

const THRESHOLD = 30;

The compiler will replace the word THRESHOLD with the value 30 wherever it appears in the script.

As with variables, there's a set of predefined constants related to the operation of the RTU-X and its peripherals that can be used from the script when relevant.

Operations​

OperationDescription
+Addition
-Subtraction
*Multiplication
/Division
%Integer division remainder
&AND (bitwise)
|OR (bitwise)
^XOR (bitwise)
~NOT (bitwise)
&&Logical AND
||Logical OR
!Logical NOT
==Equal
! =Not equal
>Greater than
> =Greater than or equal
<Less than
< =Less than or equal

++

pre or post increment

--

pre or post decrement

Slave devices and queries​

The RTU-X can act as master to up to 32 devices (starting with firmware version 3.3.02). Currently, these slaves can be Modbus over RS-485 or BLE (Bluetooth).

Queries can be defined for each slave. The types of query depend on the slave type.

Slave and query configuration must be done at the beginning of the script, before the variable declarations and code.

To define a slave, use the slave reserved word, indicating the configuration parameters, and then within that slave's block define queries using the query reserved word.

The general form for defining a slave and its queries is shown below:

slave(interface, …)
{
var_type var1 = query(query_type, …);
var_type var2 = query(query_type, …);
}

The parameters of the slave and query functions depend on the interface and query_type, detailed below for each case.

Modbus slaves​

The slave is defined as follows:

slave(modbus_rs485_ext1, slave_id, polling_period, format)
slave(modbus_rs485_ext2, slave_id, polling_period, format)

where:

  • slave_id: the slave's Modbus slave id number
  • polling_period: the time interval between two consecutive queries, in seconds
  • format: can be little_endian or big_endian. Defines how bytes are ordered for variables longer than one byte. little_endian is the most common.

Queries are defined as follows:

var_type var1 = query(coils, address, r/w);
var_type var2 = query(inputs, address);
var_type var3 = query(input_registers, address);
var_type var4 = query(holding_registers, address, r/w);

where:

  • address: the address within the Modbus block (starting at zero).
  • r/w: indicates whether the variable being defined is read-only (r) or write-only (w)

BLE slaves​

slave(ble, “mac”, timeout)

where:

  • mac: the Bluetooth device's MAC address.
  • timeout: the time, in seconds, that must pass without receiving any message before a communication error with the slave is assumed.

So far, support has been added for defining slaves for Efento brand BLE sensors.

Queries are defined as follows:

float var1 = query(efento, temperature); // Temperature query
uint var2 = query(efento, humidity); // Relative humidity query
float var3 = query(efento, pressure); // Atmospheric pressure query
uint var4 = query(efento, onoff); // On/off sensor query
uint var5 = query(efento, iaq); // Air quality query

SDI-12 slaves​

slave(sdi12_ext1,“address”, polling_period)
slave(sdi12_ext2,“address”, polling_period)

where:

  • address: the address of the SDI-12 device on the bus.
  • polling_period: the time between queries to the sensor.

Queries are defined as follows:

float var = query(sdi12, index);

Sensor queries are implemented via C commands according to version 1.4 of the SDI-12 standard, published in January 2019, which establishes that the measurement-start command has the form <address>C<index>!

All variables resulting from an sdi12 query must be declared as float.

Multitasking​

The language supports defining multiple tasks that run using cooperative multitasking.

In a cooperative multitasking scheme, tasks voluntarily give up control periodically, or when idle or logically blocked.

Multitasking is implemented in the script through the task reserved word.

When a task is reached, it runs until it finishes or gives up control. Control is given up by using one of the following functions: wait, delay, delay_loop. These functions are explained further below.

Below is an example of code where two tasks coexist, running "in parallel":

while (1)
{
task
{
// This section of code runs periodically every 1 second
delay(1000);
}
task
{
// This section of code runs periodically every 3 seconds
delay(3000);
}
}
Task limits
  • Defining a task inside another task isn't allowed.
  • All variables are global: local variables can't be defined inside a task.
  • The maximum number of tasks that can be defined is 16.

Functions​

Two types of functions can be used: those defined by the user, or a predefined set of system functions.

User-defined functions​

You can define functions to help optimize a program's execution.

The return statement isn't required at the end of a function declaration. It's only required when the function returns a numeric value.

Below is an example of how a function is declared and called.

float c;
....

function userFunction(int varA, float varB)
{
float varC;

...

return varC;
}

....

c = userFunction(4,4.5);

....

System functions​

The following table describes the functions built into the system.

FunctionDescription
delay(ulong time)

Waits for time milliseconds.
If the function is called outside a task, it stalls the entire script for the specified time.
If the function is called from a task, it only blocks that task, and the other tasks continue running.

Example:

// Stops the script for 1 second
delay(1000);

delay_loop(ulong time)

Like the delay function, waits for time milliseconds, but unlike it, the wait is measured from the immediately preceding call to the function.
**Only use inside tasks**, and it's recommended for tasks that need to repeat periodically at exact intervals.

Example:

task
{
    delay_loop(1000);
    // This code runs exactly every 1 second regardless
    // of how long it takes to execute.
}

sleep(ulong time)

Puts the RTU-X into low power mode for time milliseconds.
During that time the digital outputs keep their state and the pulse count keeps working,
but the script stops.
When it comes back from low power mode, the script resumes execution from the line where the function was called.

Example:

sleep(10000); // Switch to low power mode for 10 seconds

reset()

Resets the RTU-X.
When it restarts, the script starts over from the beginning.
Variables that aren't initialized at the start of the script keep the value they had before the reset.
Variables that are initialized at the start of the script are initialized again, except in special cases
(see static and shared).

Example:

reset();

set_green_led(uint mode)

This function is valid only when the green LED is configured to be controlled from the script.
Sets the operating mode according to the constants defined with the LED_ prefix:
LED_ON | LED_OFF | LED_BLINK_FAST | LED_BLINK_SLOW | LED_BLIP
See the [LEDs configuration](/rtu-x/input-output#leds-configuration) section for more information.

Example:

set_green_led(LED_ON);

set_red_led(uint mode)

This function is valid only when the red LED is configured to be controlled from the script.
Sets the operating mode according to the constants defined with the LED_ prefix:
LED_ON | LED_OFF | LED_BLINK_FAST | LED_BLINK_SLOW | LED_BLIP
See the [LEDs configuration](/rtu-x/input-output#leds-configuration) section for more information.

Example:

set_red_led(LED_OFF);

set_output(uint output, uint value)

Turns digital output output on or off depending on value (value can be 1 or 0).

Example:

set_output(0,1); // Turns on digital output 0
set_output(3,0); // Turns off digital output 3

int = get_output(uint output)

Returns the value (0 or 1) of output output.

Example:

output0 = get_output(0); // Get the value of digital output 0

int = get_input(uint input)

Returns the value (0 or 1) of input input.

Example:

input0 = get_input(0); // Get the value of digital input 0

set_power(uint value)

Turns the power output on or off depending on value.
value can be one of the constants defined with the POWER_ prefix:
POWER_12V | POWER_24V | POWER_OFF
See the [12V/24V Output](/rtu-x/input-output#12v24v-output) section for more information.

Example:

set_power(POWER_12V);

log(telemetry/attribute value, ...)

Saves the specified variables to the log. To do so they must be of type telemetry or attribute
Calling the function with several variables at once guarantees that they're all logged with the same timestamp.
See the [Log](/rtu-x/log) section for more information

Example:

log(temperature, motor);

report(telemetry/attribute value, ...)

Saves the specified variables to a list in RAM to be sent over MQTT.
To do so they must be of type telemetry or attribute
Calling the function with several variables at once guarantees that they're all sent with the same timestamp.
See the [Log](/rtu-x/log) section for more information

Example:

report(temperature, humidity);

log_on_change(telemetry/attribute value)

Saves the specified variable to the log only when the variable changes. The variable must be of type telemetry or attribute

Example:

log_on_change(status);

report_on_change(telemetry/attribute value)

Saves the specified variable to the RAM log to be sent over MQTT only when the variable changes. The variable must be of type telemetry or attribute

Example:

report_on_change(status);

ulong = set_timeout(ulong timeout)Sets up a timer to time out in timeout milliseconds.
Returns a ulong value configured to later use in the check_timeout function.
check_timeout(ulong timer)

Returns 1 if the time configured with the set_timeout function has passed, or 0 if it hasn't yet.

Example:

// Set up a timer so the timeout happens at 5 seconds.
timer = set_timeout(5000); 

while(1)
{
    if (check_timeout(timer))
    {
        // Enters this if once the 5 seconds have passed
    }
}

send_sms(
uint phone_index,
uint message_index,
long/float param1,
long/float param2)

Sends an SMS to the number configured at index phone_index with the message configured at index message_index.

Outgoing messages can include up to 2 numeric parameters anywhere in the message.

To insert an integer variable (int or long) you must write %li (to display it in decimal format) or %lX (to display it in hexadecimal format). For a float variable, you must write %f.


Optionally, if you want to control the number of decimal places after the decimal point, you can write %.xf, replacing x with the desired number of decimals. For example, %.2f.

Example:

send_sms(0, 0, 45, 85);

float = flow(
bool value,
float liters_per_pulse,
ulong debounce)
The function calculates water flow from the pulses of a flow meter.
Call it passing in value the value of the pulse input, in liters_per_pulse the number of liters per pulse of the flow meter, and a debounce time in milliseconds to filter bouncing and noise in the flow meter. The result is expressed in liters per second.
float = filter(
float value,
uint size,
uint average,
ulong timeout)

This function implements a median and average filter. The RTU-X has 8 identical filters that can be used simultaneously.

The value parameter is the new value to feed into the filter. The size parameter sets the filter's size, i.e. the number of values stored in the filter, with a maximum of 30. The average parameter sets the number of values within the filter used to calculate the average. The remaining values are discarded.

The timeout parameter is used to automatically clear the filter buffer if timeout milliseconds pass without the function being called. If you don't want to use this functionality, you can pass -1 as the parameter.

The function implements a sliding window with size values, and on each call it sorts them and keeps only the average center values, averaging them and discarding "size - average" values from the extremes.

During the first size calls to the function, while the buffer isn't yet full, the function directly returns the value it was given, with no processing.

Example:

voltage = filter(ain[0], 12, 5, 1000);

int = wait(
bool condition,
ulong timeout)

The function waits for condition to be true, or for timeout milliseconds to pass (whichever happens first).
If the function ends because condition is true, it returns 1.
If the function ends because timeout happens, it returns 0.
If the function is called outside a task, it stalls the entire script until it finishes.
If the function is called from a task, it only blocks that task, and the other tasks continue running.

Example:

// Wait until there's no modbus error or 30 seconds pass.
result = wait(slave_error.0 == 0, 30000)

if (result == 0)
    // If the wait ended due to timeout, run this line.

scale(
float value,
float x0,
float y0,
float x1,
float y1)

Performs a linear interpolation of value onto the line passing through [(x0,y0);(x1,y1)].

Example:

// Scaling a 4-20mA temperature sensor to 0-100ºC
temperature = scale(ain[0], 4000, 0, 20000, 100);

float = pid(
float value,
float set_point,
float kp,
float ki,
float kd)

Implements a PID control, where value is the current output value of the plant or process being controlled. set_point is the reference value, and kp, ki, and kd are the proportional, integral, and derivative constants respectively. The function returns the control signal fed into the controlled plant.


The RTU-X can implement up to 4 simultaneous PID controls.

Example:

// Frequency drive to adjust flow
frequency = pid(flow, flow_set_point, 1.1, 0.5, 0.02);

bool = alarm(
bool condition,
ulong timeout_start,
ulong timeout_end)
Implements an alarm with a start and end delay.
If condition is true for more than timeout_start milliseconds, the alarm state is set.
If condition stops being true for more than timeout_end milliseconds, the alarm state ends.
The function always returns 0 or 1 depending on whether it's in an alarm state or not.
int = timer(
TIMER_TON/TIMER_TOFF/TIMER_TP type,
int in,
ulong pt)

Implements an IEC 61131-3 style timer. The type parameter selects the behavior: TIMER_TON (on-delay), TIMER_TOFF (off-delay) or TIMER_TP (fixed-duration pulse).

TIMER_TON: the output turns on only after in has stayed at 1 for pt uninterrupted milliseconds. If in goes back to 0 before that time elapses, the count resets and the output stays at 0.

TIMER_TOFF: the output follows in immediately when it turns on, but when in turns off the output stays at 1 for pt additional milliseconds before dropping to 0.

TIMER_TP: each rising edge of in triggers a pt millisecond pulse on the output, not re-triggerable while the pulse is in progress.

The RTU-X has 16 simultaneous timers (TIMER_TON, TIMER_TOFF and TIMER_TP share the same pool of 16 instances). Timer state does not survive deep sleep.

The elapsed time of each instance is exposed in the system variable timer_et[16], useful for telemetry or debugging.

Example:

// On-delay: turns the output on 5 seconds after input 1 goes to 1
pump_on = timer(TIMER_TON, get_input(1), 5000);

bool = interval(
ulong value,
ulong start,
ulong end)
Checks whether value is within the interval between start and end.
If start <= end, it simply checks that start <= value < end, and returns 1 if true or 0 if not.
If start > end, it checks whether value >= start or value < end,
and returns 1 if either condition is true, or 0 if not.
ulong = sunrise(
ulong day,
ulong month,
ulong year,
float latitude,
float longitude)
Using an internal astronomical clock, returns the second of the day the sun will rise
based on the date (day, month, year) and position (latitude, longitude).
Returns, as a ulong, the instant in seconds of the day in local time.
The current second can be calculated as: current = hours * 3600 + minutes * 60 + seconds;
Combined with the interval and sunset functions, you can easily determine whether it's day or night.
ulong = sunset(
ulong day,
ulong month,
ulong year,
float latitude,
float longitude)
Using an internal astronomical clock, returns the second of the day the sun will set
based on the date (day, month, year) and position (latitude, longitude).
Returns, as a ulong, the instant in seconds of the day in local time.
The current second can be calculated as: current = hours * 3600 + minutes * 60 + seconds;
Combined with the interval and sunrise functions, you can easily determine whether it's day or night.
pow(float x,float y)Returns the result of raising x to the power of y.
log_e(float x)Returns the base-e logarithm of x.
log_10(float x)Returns the base-10 logarithm of x.
cos(float x)Returns the cosine of x. With x in radians.
acos(float x)Returns the arc-cosine of x in radians.
sin(float x)Returns the sine of x. With x in radians.
asin(float x)Returns the arcsine of x in radians.
tan(float x)Returns the tangent of x. With x in radians.
atan(float x)Returns the arctangent of x in radians.
sqrt(float x)Returns the square root of x.
abs(float x)Returns the absolute value of x.