API Reference

adafruit_tcs3430

CircuitPython driver library for AMS TCS3430 / TCS34303 XYZ tri-stimulus color sensor.

  • Author(s): Tim Cocks

Implementation Notes

Hardware:

Software and Dependencies:

# * Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice # * Adafruit’s Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register

class adafruit_tcs3430.ALSGain

ALS gain settings for CFG1 register bits 1:0.

Setting

Gain

ALSGain.GAIN_1X

1x gain

ALSGain.GAIN_4X

4x gain

ALSGain.GAIN_16X

16x gain

ALSGain.GAIN_64X

64x gain

ALSGain.GAIN_128X

128x gain

class adafruit_tcs3430.CV

Constant-value helper for enum-like classes.

classmethod get_name(value: int) str

Return the attribute name for value.

classmethod is_valid(value: int) bool

Validate that value is a member of this CV class.

class adafruit_tcs3430.InterruptPersistence

ALS interrupt persistence filter values for PERS register bits 3:0.

Setting

Description

InterruptPersistence.EVERY

Every ALS cycle

InterruptPersistence.CYCLES_1

1 consecutive value out of range

InterruptPersistence.CYCLES_2

2 consecutive values out of range

InterruptPersistence.CYCLES_3

3 consecutive values out of range

InterruptPersistence.CYCLES_5

5 consecutive values out of range

InterruptPersistence.CYCLES_10

10 consecutive values out of range

InterruptPersistence.CYCLES_15

15 consecutive values out of range

InterruptPersistence.CYCLES_20

20 consecutive values out of range

InterruptPersistence.CYCLES_25

25 consecutive values out of range

InterruptPersistence.CYCLES_30

30 consecutive values out of range

InterruptPersistence.CYCLES_35

35 consecutive values out of range

InterruptPersistence.CYCLES_40

40 consecutive values out of range

InterruptPersistence.CYCLES_45

45 consecutive values out of range

InterruptPersistence.CYCLES_50

50 consecutive values out of range

InterruptPersistence.CYCLES_55

55 consecutive values out of range

InterruptPersistence.CYCLES_60

60 consecutive values out of range

class adafruit_tcs3430.TCS3430(i2c_bus: I2C, address: int = _TCS3430_DEFAULT_ADDR)

CircuitPython driver for the AMS TCS3430 XYZ Color and ALS Sensor.

Parameters:
  • i2c_bus (I2C) – The I2C bus the device is connected to.

  • address (int) – The I2C device address. Defaults to 0x39.

als_enabled

Enable/disable ALS functionality

property als_gain: int

ALS analogue gain.

Must be an ALSGain value. ALSGain.GAIN_128X is achieved by setting the hardware gain to 64x and asserting the HGAIN bit in CFG2.

  • ALSGain.GAIN_1X

  • ALSGain.GAIN_4X

  • ALSGain.GAIN_16X

  • ALSGain.GAIN_64X

  • ALSGain.GAIN_128X

property als_interrupt: bool

True if the ALS interrupt flag is set (read-only).

Use clear_als_interrupt() to clear the flag.

als_interrupt_enabled

Enable/disable als interrupt

als_mux_ir2

ALS MUX setting for IR2 or X channel. True for IR2, False for X.

property als_saturated: bool

True if the ALS data is saturated (read-only).

Use clear_als_saturated() to clear the flag.

als_threshold_high

The high threshold value for ALS

als_threshold_low

The low threshold value for ALS

auto_zero_mode

Enable/disable auto-zero mode

auto_zero_nth

Auto-zero interval. Run auto-zero every N measurements

property channels: Tuple[int, int, int, int]

Read the X, Y, Z, and IR1 channels in a single burst.

If the ALS MUX is currently set to IR2 mode, it is temporarily switched back to X mode for the read and then restored.

Returns a tuple (x, y, z, ir1) of 16-bit unsigned values.

chip_id

Chip ID

clear_als_interrupt() None

Clear the ALS interrupt (and all other status flags) by writing 0xFF to the STATUS register.

Note

If the threshold condition still exists and ALS is running, the interrupt will re-fire on the next integration cycle.

clear_als_saturated() None

Clear the ALS saturation flag by writing 0x80 to the STATUS register.

integration_cycles

The number of integration cycles (1-256)

property integration_time: float

Integration time in milliseconds.

Computed from integration_cycles as (cycles + 1) * 2.78. Setting this property writes the closest cycle count back to the ATIME register.

interrupt_clear_on_read

Enable/disable interrupt clear on reading

interrupt_persistence

Enable/disable The interrupt persistence functionality

property ir2: int

Read the IR2 channel value.

This temporarily switches the ALS MUX to IR2, waits one integration period for fresh data, reads CH3, and restores the previous MUX setting.

power_on

Power on/off the sensor. True for on, False for off.

rev_id

Revision ID

saturation_interrupt_enabled

Enable/disable saturation interrupt

sleep_after_interrupt

Enable/disable sleep after interrupt

wait_cycles

The number of wait cycles (1-256)

wait_enabled

Enable/disable wait functionality

wait_long

Enable/disable longer wait functionality. True to enable 12x time multiplier

property wait_time: float

Wait time in milliseconds.

Computed from wait_cycles as (cycles + 1) * 2.78. When wait_long is enabled the actual wait is multiplied by 12. Setting this property writes the closest cycle count back to the WTIME register (it does not account for wait_long).