TI Hub Menu

Note: When creating a new program that uses this module, it is recommended to use the Hub Project program type. This will ensure that all the relevant modules are imported.

Item

Description

from ti_hub import *

Imports all methods from the ti_hub module.

 

Hub Built-in Devices > Color Output

Item

Description

rgb(red,green,blue)

Sets the color for the RGB LED.

blink(frequency,time)

Sets the blinking frequency and duration for the selected color.

off()

Turns the RGB LED off.

 

Hub Built-in Devices > Light Output

Item

Description

on()

Turns the LED on.

off()

Turns the LED off.

blink(frequency,time)

Sets the blinking frequency and duration for the LED.

 

Hub Built-in Devices > Sound Output

Item

Description

tone(frequency,time)

Plays a tone of the specified frequency for the specified duration.

note("note",time)

Plays the specified note for the specified time.

The note is specified using the note name and an octave. For example: A4, C5.

The note names are C, CS, D, DS, E, F, FS, G, GS, A, AS, and B.

The octave numbers range from 1 to 9 (inclusive).

 

Hub Built-in Devices > Brightness Input

Item

Description

measurement()

Reads the built-in BRIGHTNESS (light level) sensor and returns a reading.

The default range is 0 to 100. This can be changed using the range() function.

range(min,max)

Sets the range for mapping the readings from the light level sensor.

If both are missing, or set to a value of None, then the default brightness range of 0 to 100 is set.

 

Add Input Device

This menu has a list of the sensors (input devices) supported by the ti_hub module. All the menu items will paste the name of the object and expect a variable and a port used with the sensor. Each sensor has a measurement() method that returns the value of the sensor.

Item

Description

DHT (Digital Humidity & Temp)

Returns a list consisting of the current temperature, humidity, type of sensor, and last cached read status.

Ranger

Returns the current distance measurement from the specified ultrasonic ranger.

Light Level

Returns the brightness level from the external light level (brightness) sensor.

Temperature

Returns the temperature reading from the external temperature sensor.

The default configuration is to support the Seeed temperature sensor in IN 1, IN 2 or IN 3 ports.

To use the TI LM19 Temperature sensor from the TI-Innovator™ Hub breadboard pack, edit the port to the BB pin in use and use an optional argument "TIANALOG".

Example: mylm19=temperature("BB 5","TIANALOG")

Moisture

Returns the moisture sensor reading.

Magnetic

Detects the presence of a magnetic field.

The threshold value to determine the presence of the field is set through the trigger() function.

The default value of the threshold is 150.

Vernier

Reads the value from the Vernier analog sensor specified in the command.

The command supports the following Vernier sensors:

temperature - Stainless Steel Temperature sensor.
lightlevel - TI Light level sensor.
pressure - Original gas pressure sensor
pressure - Newer gas pressure sensor.
pH - pH sensor.
force10 - ±10 N setting, Dual Force Sensor.
force50 - ±50 N setting, Dual Force Sensor.
accelerometer - Low-G Accelerometer.
generic - Allows setting of other sensors not supported directly above, and use of the calibrate() API above to set equation coefficients.

Analog In

Supports the use of analog input generic devices.

Digital In

Returns the current state of the digital pin connected to the DIGITAL object, or the cached state of the digital output value last SET to the object.

Potentiometer

Supports a potentiometer sensor.

The range of the sensor can be changed by the range() function.

Thermistor

Reads thermistor sensors.

The default coefficients are designed to match the thermistor included in the Breadboard Pack of the TI-Innovator™ Hub, when used with a 10KΩ fixed resistor.

A new set of calibration coefficients and reference resistance for the thermistor can be configured using the calibrate() function.

Loudness

Supports sound loudness sensors.

Color Input

Provides interfaces to an I2C-connected Color Input sensor.

The bb_port pin is used in addition to the I2C port to control the LED on the color sensor.

color_number(): Returns a value from 1 to 9 that represents the color the sensor is detecting.

The numbers represent the colors per the following mapping:

1: Red

2: Green

3: Blue

4: Cyan

5: Magenta

6: Yellow

7: Black

8: White

9: Gray

red(): Returns a value from 0 to 255 that represents the intensity of the RED color level being detected.
green(): Returns a value from 0 to 255 that represents the intensity of the GREEN color level being detected.
blue(): Returns a value from 0 to 255 that represents the intensity of the BLUE color level being detected.
gray(): Returns a value from 0 to 255 that represents the gray level being detected, where 0 is black and 255 is white.

BB Port

Provides support for using all 10 BB port pins as a combined digital input/output port.

The initialization functions have an optional "mask" parameter that allows the use of the subset of the 10 pins.

read_port(): Reads the current values on the input pins of the BB port.
write_port(value): Sets the output pin values to the specified value, where value is between 0 and 1023. Note that the value is also adjusted against the mask value in the var=bbport(mask) operation, if a mask was provided.

Hub Time

Provides access to the internal millisecond timer.

TI-RGB Array

Provides functions for programming the TI-RGB Array.

The initialization function accepts an optional "LAMP" parameter to enable a high-brightness mode for the TI-RGB Array that requires an external power supply.

set(led_position, r,g,b): Sets a specific led_position (0-15) to the specified r,g,b value, where r,g,b are values from 0 to 255.
set_all(r,g,b): Sets all RGB LEDs in the array to the same r,g,b value.
all_off(): Turns off all RGBs in the array.
measurement(): Returns the approximate current draw that the RGB array is using from the TI-Innovator™ in milliAmps.
pattern(pattern): Using the value of the argument as a binary value in the range 0 to 65535, turns on pixels where a 1 value in the representation would be. LEDs are turned on as RED with pwm level value of 255.

 

Add Output Device

This menu has a list of the output devices supported by the ti_hub module. All the menu items will paste the name of the object and expect a variable and a port used with the device.

Item

Description

LED

Functions for controlling externally connected LEDs.

RGB

Support for controlling external RGB LEDs.

TI-RGB Array

Provides functions for programming the TI-RGB Array.

Speaker

Functions for supporting an external speaker with the TI-Innovator™ Hub.

The functions are the same as the ones for "sound" above.

Power

Functions for controlling external power with the TI-Innovator™ Hub.

set(value): Sets the Power level to the specified value, between 0 and 100.
on(): Sets the Power level to 100.
off(): Sets the Power level to 0.

Continuous Servo

Functions for controlling continuous servo motors.

set_cw(speed,time): The servo will spin in the clockwise direction at the specified speed (0-255) and for the specific duration in seconds.
set_ccw(speed,time): The servo will spin in the counter-clockwise direction at the specified speed (0-255) and for the specific duration in seconds.
stop(): Stops the continuous servo.

Analog Out

Functions for the use of analog input generic devices.

Vibration Motor

Functions for controlling vibration motors.

set(val): Sets the vibration motor intensity to "val" (0-255).
off(): Turns the vibration motor off.
on(): Turns the vibration motor on at the highest level.

Relay

Controls interfaces for controlling relays.

on(): Sets the relay to the ON state.
off(): Sets the relay to the OFF state.

Servo

Functions for controlling servo motors.

set_position(pos): Sets the sweep servo position within a range of -90 to +90.
zero(): Sets the sweep servo to the zero position.

Squarewave

Functions for generating a square wave.

set(frequency,duty,time): Sets the output squarewave with a default duty cycle of 50% (if duty is not specified) and an output frequency specified by "frequence". The frequency may be from 1 to 500 Hz. The duty cycle, if specified, may be from 0 to 100%.
off(): Turns the squarewave off.

Digital Out

Interfaces for controlling a digital output.

set(val): Sets the digital output to the value specified by "val" (0 or 1).
on(): Sets the state of the digital output to high (1).
off(): Sets the state of the digital output to low (0).

BB Port

Provides functions for programming the TI-RGB Array.

See the details above.

 

Commands

Item

Description

sleep(seconds)

Pauses the program for the specified number of seconds.

Imported from the 'time' module.

text_at(row,"text","align")

Displays the specified "text" in the plotting area at specified "align".

Part of the ti_plotlib module.

cls()

Clears the Shell screen for plotting.

Part of the ti_plotlib module.

while get_key() != "esc":

Runs the commands in the "while" loop until the "esc" key is pressed.

get_key()

Returns a string representing the key pressed.

The '1' key returns "1", 'esc' returns "esc", and so on.

When called without any parameters - get_key() - it returns immediately.

When called with a parameter - get_key(1) - it waits until a key is pressed.

Part of the ti_system module.

 

Ports

These are the input and output ports available on the TI-Innovator™ Hub.

Item

OUT 1

OUT 2

OUT 3

IN 1

IN 2

IN 3

BB 1

BB 2

BB 3

BB 4

BB 5

BB 6

BB 7

BB 8

BB 9

BB 10

I2C