vts

Chrono

Chrono

32-bit counter object that increments every microseconds. Instantiated with no parameters. All returned values are in microseconds(us)

ChrTimer = vts.Chrono()

Warning

Will overflow after 32-bits are filled (this is after approximately 1hr and 12minutes of running).

read

Gets the time that the timer has been running since the last start/restart.

ChrTimer.read()

Returns:

  • An integer of the time since the last start/restart in us.

restart

Starts this timer from 0. Use after initialised as sometimes the timer starts from the incorrect place.

ChrTimer.restart()

Returns:

  • An integer of the current value of the read in us before the restart.

start

Starts this timer from 0. Use after initialised as sometimes the timer starts from the incorrect place.

ChrTimer.start()

time

Gets how long the VBOX Touch has been running:

ChrTimer.time()

Returns:

  • An integer of how long the VBOX Touch has been running in us.

MChrono

32-bit counter object that increments every millisecond. Instantiated with no parameters. All returned values are in milliseconds(ms).

MChrTimer = vts.MChrono()

Warning

Will overflow after 32-bits are filled (this is after approximately 50 days of running)

read

Gets the time that the timer has been running since the last start/restart.

MChrTimer.read()

Returns:

  • An integer of the time since the last start/restart in ms.

restart

Starts this timer from 0. Use after initialised as sometimes the timer starts from the incorrect place.

MChrTimer.restart()

Returns:

  • An integer of the current value of the timer in ms before the restart.

start

Starts this timer from 0. Use after initialised as sometimes the timer starts from the incorrect place.

MChrTimer.start()

time

Gets how long the VBOX Touch has been running:

MChrTimer.time()

Returns:

  • An integer of how long the VBOX Touch has been running in ms.

time_since_ms

This returns how long it has been since a value.

MChrTimer.time_since_ms(num)

Input Parameters:

  • num[int] = The time you want to compare to.

This value is not affected by restart/start and instead uses (time() - (start_time+num)).

Clock

get

Gets the current time from the Real-Time Clock.

vts.clock_get()

Returns a dictionary of the following data:

  • day of year = Amount of days passed this year + a day (for today)

  • minutes = Current minute

  • day of month = Current day

  • year = Current year

  • day of week = Current day of the week (Monday=1, …, Sunday=7). However, this is often not set.

  • month = Current month

  • seconds = Current second

  • hours = Current hour

set

Sets the current time for the Real-Time Clock.

vts.clock_set(clock_time)

Input Parameters:

  • clock_time[dict] = A dictionary with the same keys as the one returned with clock_get():

    • “day of year” = range from 1-366

    • “minutes” = range from 0-59

    • “day of month” = range from 1-31

    • “year” = the full calendar year (for example 2024)

    • “day of week” = range from 1-7

    • “month” = range from 1-12

    • “seconds” = range from 0-59

    • “hours” = range from 0-23

Config

Configure the serial ports.

vts.config(config)

Input Parameters:

  • config[dict] = A dictionary containing a key of the port you want to change and an item of what to change it to.

    • Possible keys: ‘serialREPL’, ‘serialUSER’, ‘serialConn’

    • Possible items: 0, 1, 2

Returns when the input is empty:

  • The current status of the things you can configure.

Additional:

You can also set the key to be ‘uPyIntChar’. In this case the item passed is the keyboard interrupt key in ASCII. We typically use 3 (0x03) as this is the EXT key which you can trigger with CTRL + C.

Datetime

Datetime adjust

Adjusts the datetime by the specified milliseconds.

vts.datetime_adjust(datetime, milliseconds)

Input Parameters:

  • datetime[list] = current datetime. The datetime is the items from the rtc clock:

    clock = vts.clock_get()
    datetime = [clock["year"], clock["month"], clock["day of month"], clock["hours"], clock["minutes"], clock["seconds"]]
    
  • milliseconds[int] = the amount of time in milliseconds to adjust by.

Note:

If you put in a value equal to a second it will only adjust it by -1 of that. For example: 2000 will adjust by 1 second but 2001 will adjust by 2 seconds

Datetime difference

Returns the difference between 2 datetimes.

vts.datetime_diff(datetime1, datetime2)

Input Parameters:

  • datetime1[list] = a datetime

  • datetime2[list] = the datetime to be compared with

Returns:

  • The difference between the 2 times in seconds. You need to round this value up otherwise it will be 1s out.

Datetime to Julian days

Converts a datetime to the equivalent in Julian days.

vts.datetime_to_jdn(datetime)

Input Parameters:

  • datetime[list] = the datetime to convert to Julian days

Returns:

  • The value in Julian days

Julian days to Datetime

Converts Julian days to the equivalent in a datetime.

vts.jdn_to_datetime(julian)

Input Parameters:

  • julian[float] = the date in julian days

Returns:

  • A tuple of the datetime

Delay

ms

Delays the current operation by a time in milliseconds(ms).

vts.delay_ms(time)

Input Parameters:

  • time[int] = the time to delay in ms

us

Delays the current operation by a time in microseconds(us).

vts.delay_us(time)

Input Parameters:

  • time[int] = the time to delay in us

gc

age

Gets how long it has been since the last garbage collection in milliseconds (ms).

vts.gc_age()

Returns:

  • An integer of the amount of time it has been since the last garbage collection in ms.

timing

Stores the information about garbage collection in the buffer.

vts.gc_timing(buf)

Input Parameters:

  • buf[buffer] = The buffer where the information about the garbage collection is stored.

verbose

When enabled it will print out data to do with what was collected whenever a collection happens.

vts.gc_verbose(state)

Input Parameters:

  • state[bool] = The state to set the verbose to.

Returns when the input is empty:

  • The current state of the gc_verbose()

Note:

The internal timer of this is assigned to a 32-bit int so will stop running after approximately 1hr and 12minutes of running.

Input voltage

Gets the current input voltage to the vbox touch.

vts.input_v():

Returns:

  • A float of the current input voltage to the vbox touch

LEDs

Change the colour of the LEDs.

vts.leds(r1,g1,b1, r2,g2,b2, r3,g3,b3, r4,g4,b4)

Input Parameters:

  • r1[int] = The redness of the 1st LED. Range from 0-255 inclusive.

  • g1[int] = The greenness of the 1st LED. Range from 0-255 inclusive.

  • b1[int] = The blueness of the 1st LED. Range from 0-255 inclusive.

  • r2[int] = The redness of the 2nd LED. Range from 0-255 inclusive.

  • g2[int] = The greenness of the 2nd LED. Range from 0-255 inclusive.

  • b2[int] = The blueness of the 2nd LED. Range from 0-255 inclusive.

  • r3[int] = The redness of the 3rd LED. Range from 0-255 inclusive.

  • g3[int] = The greenness of the 3rd LED. Range from 0-255 inclusive.

  • b3[int] = The blueness of the 3rd LED. Range from 0-255 inclusive.

  • r4[int] = The redness of the 4th LED. Range from 0-255 inclusive.

  • g4[int] = The greenness of the 4th LED. Range from 0-255 inclusive.

  • b4[int] = The blueness of the 4th LED. Range from 0-255 inclusive.

rand32

Generates a random 32 bit number.

vts.rand32()

Returns:

  • an integer within the 32 bit range (0 to 4294967295 inclusive).

record

record

Records sound from the mic to a buffer.

vts.record(buf, gain)

Input Parameters:

  • buf[bytearray] = Where to store the data. The data stream is 16000 bytes per second.

  • gain[int] = The gain of the signal.

callback

Sets the callback to be triggered when a recording is done.

vts.record_callback(cb_func)

Input Parameters:

  • cb_func[func] = The callback function to be called when the recording is done.

start

Starts the recording

vts.record_start(buf, gain)

Input Parameters:

  • buf[bytearray] = Where to store the data. The data stream is 16000 bytes per second.

  • gain[int] = The gain of the signal.

Requires the callback to have been set to a function before it can be used otherwise it will throw an error.

recording

Checks if recording is currently taking place.

vts.recording()

Returns:

  • The current status of the recording. True if recording, False means it isn’t recording.

SD Card

get sd card state

Gets the current sd card state.

vts.get_sdcard_state()

Returns one integer which could be any of the following values:

  • -2 = Error

  • -1 = Removing

  • 0 = No Card

  • 1 = Detected

  • 2 = Initialised

sd present

Checks if the sd card is present.

vts.sd_present()

Returns:

  • A bool of if the sd card is present or not.

set sd card callback

Sets the callback for when the SD Card changes state.

vts.set_sd_callback(cb_func)

Input Parameters:

  • cb_func[func] = The function to be called when there is a state change in the SD card.

Note:

This is still a callback and so if you are already in a callback then this one won’t instantly be triggered.

Timer

Takes 2 parameters when instantiated.

UsrTimer = vts.Timer(time, mode)

Input Parameters:

  • time[int] = time in ms. Every time it is reached it will increment the counter and call the callback.

  • mode[bool] = If True it will reset the time so it can be incremented again. Else it won’t.

Note:

You can have a maximum of 32 Timers, with a maximum of 8 Timers that have a callback

counter

Gets the counter of the number of occasions the time has been reached.

UsrTimer.counter()

Returns:

  • An integer of the number of occasions the time has been reached.

destroy

Destroys the timer object.

UsrTimer.destroy()

destroy_all

Destroys all the timer objects.

vts.Timer.destroy_all()

pending

Checks if the Timer callback flag is active.

UsrTimer.pending()

Returns:

  • A boolean of whether it is True or False.

set_callback

Sets the callback for when the Timer value is reached.

UsrTimer.set_callback(cb_func)

Input Parameters

  • cb_func[func] = The callback function for when the time value is reached.

VBOX Unit info

This is used to get information about the hardware of the VBOX Touch you are using. The function and its output are shown below:

vts.unit_info()

Returns a dictionary of the following data:

  • Info Version[int] = The version of the dictionary.

  • Unit Subtype[int] = Variant of VBOX Touch.

    • Values: 255 = VBOX Touch [Default], 1 = PBOX and MFD Touch, 2 = RTK Touch, 3 = VDMS Touch.

  • Unit Type[int] = PBOX, MFD or VBOX.

    • Values: 0 = NONE, 104 = VBOX and MFD Touch, 25 = PBOX Touch.

  • IMU[string] = IMU version.

    • Values: NONE = 0, MTI_3 = 1, LSM = 2, MTI_1 = 3.

  • ODIN UART[string] = If the NETW Module is ODIN-W2 then it will have a value saying what type of ODIN UART it is.

    • Values: UNKNOWN = 0, STANDARD = 1, INV = 2.

  • Build Branch[string] = What branch of the builds made by Racelogic is this VBOX Touch currently running off.

  • Serial Number[int] = The serial number of your VBOX Touch unit. Matches the one on the back of your VBOX Touch on the silver sticker.

  • GNSS Engine[string] = What GNSS Engine is in use on this VBOX Touch.

    • Values: NONE = 0, TOPCON_B111 = 1, UBLOX_M8L = 2, UBLOX_M8Q = 3, UBLOX_F9P = 4, UBLOX_M9N = 5.

  • Firmware Version[string] = System Firmware version.

  • Firmware Date[string] = System Firmware date of build.

  • Firmware Time[string] = System Firmware time of build.

  • FT8xx Swizzle[int] = The way the touch plate is mounted on the screen.

  • PCB Info[string] = PCB Code, the beginning is the type of unit.

  • Screen[string] = Screen variant due to part changes. The values greater than 1 all have DMT043WVNTCMI as a prefix i.e: DMT043WVNTCMI_1A.

    • Values: UNKNOWN = 0, OBSTPC7054BA = 1, _1A = 2, _1B = 3, _1C = 4, _1B2 = 5, _1D = 6, _1E = 7, _1F = 8, _1G = 9, _1H = 10, _1L = 11, _2M = 12, _2N = 13

  • Build Commit[string] = The commit “number” for the branch of the build currently in use.

  • NETW Module[string] = Network module.

    • Values: NONE = 0, ODIN-W2 = 1, PAN1026 = 2, NINA-B2 = 3.

  • Light Sensor[string] = Light sensor module.

    • Values: NONE = 0, VEML6030 = 1, VCNL4035 = 2.

The most often used data from this is the Serial Number which is displayed on all apps at the beginning in the bottom left corner.

The GNSS Engine is often used as it shows the sample rate of the VBOX Touch that is currently in use.

upy callbacks

Used to enable and disable all callbacks that micropython receives.

vts.upy_callbacks(state)

Input Parameters:

  • state[bool] = The state to change the upy_callbacks() to.

Legacy functions: deprecated

catch_callback_exceptions()

hware_rev() = replaced by unit_info()

record_callback(), record_start(). The basic record functionality is simpler to use than these and provides almost all the same features.