RaceCapturePro Lua Scripting: Difference between revisions

(→‎Scripting functions for RaceCapture/Pro: more formatting and additional functions)
(added more documentation)
Line 4: Line 4:
==Scripting functions for RaceCapture/Pro==
==Scripting functions for RaceCapture/Pro==


===getGpio( port )===
===getGpio( channel )===
Retrieves the state of the GPIO ports
Retrieves the state of the specified GPIO channel


*params
*params
** port: integer 0 - 2
** channel: integer 0 - 2
*returns:
*returns:
** state: 1 = port is high, 0 = port is low
** state: 1 = channel is high, 0 = channel is low


When the port is configured for input mode, a voltage high input (> 2 volts) will read as 1; a voltage low will read as 0. A disconnected port will read as high due to the internal pullup resistor.
When the channel is configured for input mode, a voltage high input (> 2 volts) will read as 1; a voltage low will read as 0. A disconnected channel will read as high due to the internal pullup resistor.


When the port is configured as output, the port reads 1 when the port is activated (output transistor is connected to ground) and 0 when the port is deactivated (pullup resistor is active)
When the channel is configured as output, the channel reads 1 when the channel is activated (output transistor is connected to ground) and 0 when the channel is deactivated (pullup resistor is active)


===setGpio ( port, state )===
===setGpio ( channel, state )===
Sets the state of the GPIO port when the port is configured for output mode.  
Sets the state of the GPIO channel when the channel is configured for output mode.  


*params
*params
** port: integer 0 - 2, state - 1 = output active; 0 = output inactive
** channel: integer 0 - 2, state - 1 = output active; 0 = output inactive
*returns:
*returns:
** none
** none
Line 54: Line 54:
** writable: 1 = SD card is writable; 0 = SD card is not writable
** writable: 1 = SD card is writable; 0 = SD card is not writable


===setPwmDutyCycle( port, dutyCyclePct )===
===setPwmDutyCycle( channel, dutyCyclePct )===
Sets the duty cycle of the specified PWM / Analog output channel to the specified duty cycle percentage


*params
*params
** port: PWM / Analog output port 0 - 3
** channel: PWM / Analog output channel 0 - 3
*returns
*returns
** none
** none


Sets the duty cycle of the specified PWM / Analog output port to the specified duty cycle percentage


===setPwmPeriod( port, period )===
===setPwmPeriod( channel, period )===
Sets the period of the specified PWM / Analog output channel to the specified period


*params
*params
** port: PWM / Analog output port 0 - 3
** channel: PWM / Analog output channel 0 - 3
** period: The period value
** period: The period value
** returns
** returns
* none
* none


Sets the period of the specified PWM / Analog output port to the specified period


===setAnalogOut( port, voltage )===
===setAnalogOut( channel, voltage )===
Sets the output voltage of the specified PWM / Analog output channel to the specified period. A convenience function equivalent to setPwmDutyCycle that translates voltage to PWM percentage.


*params
*params
** port: PWM / Analog output port 0 - 3
** channel: PWM / Analog output channel 0 - 3
** voltage: the specified output voltage ( 0 - 5v)
** voltage: the specified output voltage ( 0 - 5v)
** returns
** returns
* none
* none


Sets the output voltage of the specified PWM / Analog output port to the specified period. A convenience function equivalent to setPwmDutyCycle that translates voltage to PWM percentage.


===getTimerRpm===
===getTimerRpm(channel)===
Returns the current RPM of the specified timer input channel. Note, the timer channel configuration must be set to RPM mode.
 
*params
** channel: Timer channel 0 - 3
** returns: RPM value
 
 
===getTimerPeriodMs(channel)===
Returns the current duration of the full cycle pulse of the specified timer input channel, in milliseconds. Note the timer channel configuration must be set to Duration mode.
 
*params
** channel: Timer channel 0 - 3
** returns:  millisecond value
 
 
===getTimerFrequency(channel)===
Returns the current frequency present on the specified timer input channel, in Hz. Note the timer channel configuration must be set to Frequency Mode.
 
*params
** channel: Timer channel 0 - 3
** returns:  Frequency in Hz


===getTimerPeriodMs===
===getTimerPeriodUsec===
===getTimerFrequency===
===getTimerRaw===


===getTimerRaw(channel)===
Returns the current raw timer value as measured on the specified timer input channel.
*params
** channel: Timer channel 0 - 3
** returns: Raw timer value between 0 - 65535
<!--
===resetTimerCount===
===resetTimerCount===
===getTimerCount===
===getTimerCount===
-->
===getAnalog===
   
===getAnalogRaw===
===getAnalog(channel)===
Reads the scaled analog value for the specified analog input channel.
*params
** channel: Analog input channel 0 - 7
** returns: Scaled / calculated value for the specified analog channel as defined in the channel scaling configuration
 
===getAnalogRaw(channel)===
Reads the raw analog value for the specified analog input channel.
*params
** channel: Analog input channel 0 - 7
** returns: The raw value measured by the 10 bit Analog to Digital Converted on the specified analog channel, between 0 - 1023
 
===readSerial(port)===
Read a line of data from the specified serial port. This command blocks until a newline ('\n') character is received on the port.
* params
** port: Serial port 0 - 1
** returns: a line of serial data


===readSerial===
===writeSerial(port, data)===
===writeSerial===
Writes data to the specified serial port.
* params
** port: Serial port 0 - 1
** data: the data in string format
 
===getGpsPosition()===
Reads the current position as measured by the attached GPS module ''coming in firmware 1.2''
* params
** none
* returns
** Latitude: latitude in decimal degrees
** Longitude: longitude in decimal degress
 
===getGpsLatitude()===
Provides the current latitude as measured by the attached GPS module ''will be removed in firmware 1.2, replaced with getGpsPosition''
* params
** (none)
* returns
** The current latitude in decimal degrees


===getGpsLatitude===
===getGpsLongitude===
===getGpsLongitude===
Provides the current longitude as measured by the attached GPS module ''will be removed in firmware 1.2, replaced with getGpsPosition''
* params
** (none)
* returns
** The current longitude in decimal degrees
===getGpsSpeed===
===getGpsSpeed===
Provides the current speed as measured by the attached GPS module
* params
** (none)
* returns
** The current speed in MPH
===getGpsQuality===
===getGpsQuality===
Provides the current GPS quality indicator as indicated by the attached GPS module
* params
** (none)
* returns
** The current GPS quality indicator
===getGpsTime===
===getGpsTime===
Provides the current GPS time as indicated by the attached GPS module (in NMEA format) ''todo: document this''
* params
** (none)
* returns
** The current GPS time value
===getLapCount===
===getLapCount===
Provides the current Lap Count as determined by the start/finish line configuration and measured by the attached GPS module.
* params
** (none)
* returns
** The number of laps detected since the logging session started
===getLapTime===
===getLapTime===
Provides the last lap time as determined by the start/finish line configuration and measured by the attached GPS module.
* params
* (none)
* returns
** The last measured lap time in decimal minutes / seconds
===getGpsSec===
===getGpsSec===
===getAtStartFinish===
===getAtStartFinish===


===getTimeDiff===
===getTimeDiff===
===getTimeSince===
===getTimeSince===
                   
===getAccel===
===getAccel===
===getAccelRaw===
===getAccelRaw===
   
===startLogging===
===startLogging===
===stopLogging===
===stopLogging===
Line 122: Line 218:
===flashLoggerConfig===
===flashLoggerConfig===


   
===setAnalogSampleRate===
===setAnalogSampleRate===
===getAnalogSampleRate===
===getAnalogSampleRate===
   
===setAnalogScaling===
===setAnalogScaling===
===getAnalogScaling===
===getAnalogScaling===
   
===setPwmClockFrequency===
===setPwmClockFrequency===
===getPwmClockFrequency===
===getPwmClockFrequency===
   
   
===setPwmSampleRate===
===setPwmSampleRate===
===getPwmSampleRate===
===getPwmSampleRate===
   
===setPwmOutputConfig===
===setPwmOutputConfig===
===getPwmOutputConfig===
===getPwmOutputConfig===
   
===setPwmLoggingConfig===
===setPwmLoggingConfig===
===getPwmLoggingConfig===
===getPwmLoggingConfig===
   
===setPwmStartupDutyCycle===
===setPwmStartupDutyCycle===
===getPwmStartupDutyCycle===
===getPwmStartupDutyCycle===
       
===setPwmStartupPeriod===
===setPwmStartupPeriod===
===getPwmStartupPeriod===
===getPwmStartupPeriod===
   
===setPwmVoltageScaling===
===setPwmVoltageScaling===
===getPwmVoltageScaling===
===getPwmVoltageScaling===
   
===setGpsInstalled===
===setGpsInstalled===
===getGpsInstalled===
===getGpsInstalled===
   
===setGpsStartFinish===
===setGpsStartFinish===
===getGpsStartFinish===
===getGpsStartFinish===
   
===setGpsPositionSampleRate===
===setGpsPositionSampleRate===
===getGpsPositionSampleRate===
===getGpsPositionSampleRate===
   
===setGpsSpeedSampleRate===
===setGpsSpeedSampleRate===
===getGpsSpeedSampleRate===
===getGpsSpeedSampleRate===
   
===setGpsTimeSampleRate===
===setGpsTimeSampleRate===
===getGpsTimeSampleRate===
===getGpsTimeSampleRate===
Line 171: Line 267:
===setLapTimeSampleRate===
===setLapTimeSampleRate===
===getLapTimeSampleRate===
===getLapTimeSampleRate===
   
===setGpioSampleRate===
===setGpioSampleRate===
===getGpioSampleRate===
===getGpioSampleRate===
   
===setGpioConfig===
===setGpioConfig===
===getGpioConfig===
===getGpioConfig===
   
===setTimerSampleRate===
===setTimerSampleRate===
===getTimerSampleRate===
===getTimerSampleRate===
   
===setTimerConfig===
===setTimerConfig===
===getTimerConfig===
===getTimerConfig===
   
===setTimerPulsePerRevolution===
===setTimerPulsePerRevolution===
===getTimerPulsePerRevolution===
===getTimerPulsePerRevolution===
   
===setTimerDivider===
===setTimerDivider===
===getTimerDivider===
===getTimerDivider===
   
===calculateTimerScaling===
===calculateTimerScaling===
===getTimerScaling===
===getTimerScaling===
   
===setAccelInstalled===
===setAccelInstalled===
===getAccelInstalled===
===getAccelInstalled===
   
===setAccelSampleRate===
===setAccelSampleRate===
===getAccelSampleRate===
===getAccelSampleRate===
   
===setAccelConfig===
===setAccelConfig===
===getAccelConfig===
===getAccelConfig===
   
===setAccelChannel===
===setAccelChannel===
===getAccelChannel===
===getAccelChannel===
   
===setAccelZeroValue===
===setAccelZeroValue===
===getAccelZeroValue===
===getAccelZeroValue===


===calibrateAccelZero===
===calibrateAccelZero===

Revision as of 17:47, 5 May 2013

This page is under construction. Check back soon!


Scripting functions for RaceCapture/Pro

getGpio( channel )

Retrieves the state of the specified GPIO channel

  • params
    • channel: integer 0 - 2
  • returns:
    • state: 1 = channel is high, 0 = channel is low

When the channel is configured for input mode, a voltage high input (> 2 volts) will read as 1; a voltage low will read as 0. A disconnected channel will read as high due to the internal pullup resistor.

When the channel is configured as output, the channel reads 1 when the channel is activated (output transistor is connected to ground) and 0 when the channel is deactivated (pullup resistor is active)

setGpio ( channel, state )

Sets the state of the GPIO channel when the channel is configured for output mode.

  • params
    • channel: integer 0 - 2, state - 1 = output active; 0 = output inactive
  • returns:
    • none

When the state specified is 1, the output is active (transistor is connected to ground). When state is 0, transistor is disconnected, and pullup resistor is active.

When configured for input mode this function has no effect.

getButton()

Gets the state of the front panel pushbutton.

  • params
    • none
  • returns
    • state: 1 = pushbutton is depressed; 0 = pushbutton is not depressed

isSDCardPresent

Indicates if an SD card is present in the socket

present isSDCardPresent()

  • params
    • none
  • returns
    • present: 1 = SD card is present in socket; 0 = SD card not present

isSDCardWritable()

Indicates if the SD card is writable (lock switch on SD card is active)

  • params
    • none
  • returns
    • writable: 1 = SD card is writable; 0 = SD card is not writable

setPwmDutyCycle( channel, dutyCyclePct )

Sets the duty cycle of the specified PWM / Analog output channel to the specified duty cycle percentage

  • params
    • channel: PWM / Analog output channel 0 - 3
  • returns
    • none


setPwmPeriod( channel, period )

Sets the period of the specified PWM / Analog output channel to the specified period

  • params
    • channel: PWM / Analog output channel 0 - 3
    • period: The period value
    • returns
  • none


setAnalogOut( channel, voltage )

Sets the output voltage of the specified PWM / Analog output channel to the specified period. A convenience function equivalent to setPwmDutyCycle that translates voltage to PWM percentage.

  • params
    • channel: PWM / Analog output channel 0 - 3
    • voltage: the specified output voltage ( 0 - 5v)
    • returns
  • none


getTimerRpm(channel)

Returns the current RPM of the specified timer input channel. Note, the timer channel configuration must be set to RPM mode.

  • params
    • channel: Timer channel 0 - 3
    • returns: RPM value


getTimerPeriodMs(channel)

Returns the current duration of the full cycle pulse of the specified timer input channel, in milliseconds. Note the timer channel configuration must be set to Duration mode.

  • params
    • channel: Timer channel 0 - 3
    • returns: millisecond value


getTimerFrequency(channel)

Returns the current frequency present on the specified timer input channel, in Hz. Note the timer channel configuration must be set to Frequency Mode.

  • params
    • channel: Timer channel 0 - 3
    • returns: Frequency in Hz


getTimerRaw(channel)

Returns the current raw timer value as measured on the specified timer input channel.

  • params
    • channel: Timer channel 0 - 3
    • returns: Raw timer value between 0 - 65535


getAnalog(channel)

Reads the scaled analog value for the specified analog input channel.

  • params
    • channel: Analog input channel 0 - 7
    • returns: Scaled / calculated value for the specified analog channel as defined in the channel scaling configuration

getAnalogRaw(channel)

Reads the raw analog value for the specified analog input channel.

  • params
    • channel: Analog input channel 0 - 7
    • returns: The raw value measured by the 10 bit Analog to Digital Converted on the specified analog channel, between 0 - 1023

readSerial(port)

Read a line of data from the specified serial port. This command blocks until a newline ('\n') character is received on the port.

  • params
    • port: Serial port 0 - 1
    • returns: a line of serial data

writeSerial(port, data)

Writes data to the specified serial port.

  • params
    • port: Serial port 0 - 1
    • data: the data in string format

getGpsPosition()

Reads the current position as measured by the attached GPS module coming in firmware 1.2

  • params
    • none
  • returns
    • Latitude: latitude in decimal degrees
    • Longitude: longitude in decimal degress

getGpsLatitude()

Provides the current latitude as measured by the attached GPS module will be removed in firmware 1.2, replaced with getGpsPosition

  • params
    • (none)
  • returns
    • The current latitude in decimal degrees

getGpsLongitude

Provides the current longitude as measured by the attached GPS module will be removed in firmware 1.2, replaced with getGpsPosition

  • params
    • (none)
  • returns
    • The current longitude in decimal degrees

getGpsSpeed

Provides the current speed as measured by the attached GPS module

  • params
    • (none)
  • returns
    • The current speed in MPH

getGpsQuality

Provides the current GPS quality indicator as indicated by the attached GPS module

  • params
    • (none)
  • returns
    • The current GPS quality indicator

getGpsTime

Provides the current GPS time as indicated by the attached GPS module (in NMEA format) todo: document this

  • params
    • (none)
  • returns
    • The current GPS time value

getLapCount

Provides the current Lap Count as determined by the start/finish line configuration and measured by the attached GPS module.

  • params
    • (none)
  • returns
    • The number of laps detected since the logging session started

getLapTime

Provides the last lap time as determined by the start/finish line configuration and measured by the attached GPS module.

  • params
  • (none)
  • returns
    • The last measured lap time in decimal minutes / seconds

getGpsSec

getAtStartFinish

getTimeDiff

getTimeSince

getAccel

getAccelRaw

startLogging

stopLogging

setLed

flashLoggerConfig

setAnalogSampleRate

getAnalogSampleRate

setAnalogScaling

getAnalogScaling

setPwmClockFrequency

getPwmClockFrequency

setPwmSampleRate

getPwmSampleRate

setPwmOutputConfig

getPwmOutputConfig

setPwmLoggingConfig

getPwmLoggingConfig

setPwmStartupDutyCycle

getPwmStartupDutyCycle

setPwmStartupPeriod

getPwmStartupPeriod

setPwmVoltageScaling

getPwmVoltageScaling

setGpsInstalled

getGpsInstalled

setGpsStartFinish

getGpsStartFinish

setGpsPositionSampleRate

getGpsPositionSampleRate

setGpsSpeedSampleRate

getGpsSpeedSampleRate

setGpsTimeSampleRate

getGpsTimeSampleRate

setLapCountSampleRate

getLapCountSampleRate

setLapTimeSampleRate

getLapTimeSampleRate

setGpioSampleRate

getGpioSampleRate

setGpioConfig

getGpioConfig

setTimerSampleRate

getTimerSampleRate

setTimerConfig

getTimerConfig

setTimerPulsePerRevolution

getTimerPulsePerRevolution

setTimerDivider

getTimerDivider

calculateTimerScaling

getTimerScaling

setAccelInstalled

getAccelInstalled

setAccelSampleRate

getAccelSampleRate

setAccelConfig

getAccelConfig

setAccelChannel

getAccelChannel

setAccelZeroValue

getAccelZeroValue

calibrateAccelZero