Functions¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Details¶
- Colorhug.color_select_to_string(color_select)¶
- Parameters:
color_select (
Colorhug.ColorSelect
) –- Return type:
New in version 0.1.29.
- Colorhug.device_check_firmware(device, data)¶
- Parameters:
device (
GUsb.Device
) –data (
bytes
) – firmware binary data
- Raises:
- Returns:
True
if the command was executed successfully.- Return type:
Checks the firmware is suitable for the ColorHug device that is attached.
New in version 1.2.3.
- Colorhug.device_close(device)¶
- Parameters:
device (
GUsb.Device
) –- Raises:
- Return type:
New in version 1.2.11.
- Colorhug.device_error_quark()¶
- Returns:
ChDevice error quark.
- Return type:
New in version 0.1.1.
- Colorhug.device_get_adc_calibration_neg(device, cancellable)¶
- Parameters:
device (
GUsb.Device
) – AGUsb.Device
cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
True
for success- value:
offset value
- Return type:
Gets the ADC positive calibration value.
New in version 1.3.4.
- Colorhug.device_get_adc_calibration_pos(device, cancellable)¶
- Parameters:
device (
GUsb.Device
) – AGUsb.Device
cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
True
for success- value:
offset value
- Return type:
Gets the ADC positive calibration value.
New in version 1.3.4.
- Colorhug.device_get_ccd_calibration(device, nm_start, c0, c1, c2, cancellable)¶
- Parameters:
device (
GUsb.Device
) – AGUsb.Device
nm_start (
float
) –c0 (
float
) –c1 (
float
) –c2 (
float
) –cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
True
for success- Return type:
Gets any PCB wavelength_cal from the device.
New in version 1.3.1.
- Colorhug.device_get_error(device, cancellable)¶
- Parameters:
device (
GUsb.Device
) – AGUsb.Device
cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
True
for success- status:
- cmd:
a #ChCmd, e.g.
Colorhug.CMD_TAKE_READING_SPECTRAL
- Return type:
(
bool
, status:Colorhug.Error
, cmd:int
)
Gets the status for the last operation.
New in version 1.3.1.
- Colorhug.device_get_guid(device)¶
- Parameters:
device (
GUsb.Device
) – AGUsb.Device
- Returns:
the GUID address, or
None
for error- Return type:
Returns the GUID for the connected ColorHug device.
New in version 1.2.9.
- Colorhug.device_get_illuminants(device, cancellable)¶
- Parameters:
device (
GUsb.Device
) – AGUsb.Device
cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
True
for success- value:
serial number
- Return type:
(
bool
, value:Colorhug.Illuminant
)
Gets the illuminants from the device.
New in version 1.3.4.
- Colorhug.device_get_integral_time(device, cancellable)¶
- Parameters:
device (
GUsb.Device
) – AGUsb.Device
cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
True
for success- value:
integration time in ms
- Return type:
Gets the integration time used for taking the next samples.
New in version 1.3.1.
- Colorhug.device_get_leds(device, cancellable)¶
- Parameters:
device (
GUsb.Device
) – AGUsb.Device
cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
True
for success- value:
serial number
- Return type:
(
bool
, value:Colorhug.StatusLed
)
Gets the LEDs from the device.
New in version 1.3.1.
- Colorhug.device_get_mode(device)¶
- Parameters:
device (
GUsb.Device
) –- Return type:
New in version 0.1.29.
- Colorhug.device_get_pcb_errata(device, cancellable)¶
- Parameters:
device (
GUsb.Device
) – AGUsb.Device
cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
True
for success- value:
- Return type:
(
bool
, value:Colorhug.PcbErrata
)
Gets any PCB errata from the device.
New in version 1.3.1.
- Colorhug.device_get_runcode_address(device)¶
- Parameters:
device (
GUsb.Device
) – AGUsb.Device
- Returns:
the runcode address, or 0 for error
- Return type:
Returns the runcode address for the ColorHug device.
New in version 1.2.9.
- Colorhug.device_get_serial_number(device, cancellable)¶
- Parameters:
device (
GUsb.Device
) – AGUsb.Device
cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
True
for success- value:
serial number
- Return type:
Gets the serial number from the device.
New in version 1.3.1.
- Colorhug.device_get_spectrum(device, cancellable)¶
- Parameters:
device (
GUsb.Device
) – AGUsb.Device
cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
a
Colord.Spectrum
, orNone
for error- Return type:
Gets the spectrum from the device. This queries the device multiple times until the spectrum has been populated.
New in version 1.3.1.
- Colorhug.device_get_spectrum_full(device, kind, cancellable)¶
- Parameters:
device (
GUsb.Device
) – AGUsb.Device
kind (
Colorhug.SpectrumKind
) – AColorhug.SpectrumKind
cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
a
Colord.Spectrum
, orNone
for error- Return type:
Gets the spectrum from the device. This queries the device multiple times until the spectrum has been populated.
New in version 1.3.4.
- Colorhug.device_get_temperature(device, cancellable)¶
- Parameters:
device (
GUsb.Device
) – AGUsb.Device
cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
True
for success- value:
temperature in Celsius
- Return type:
Gets the PCB board temperature from the device.
New in version 1.3.1.
- Colorhug.device_is_colorhug(device)¶
- Parameters:
device (
GUsb.Device
) –- Return type:
New in version 0.1.29.
- Colorhug.device_load_sram(device, cancellable)¶
- Parameters:
device (
GUsb.Device
) – AGUsb.Device
cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
True
for success- Return type:
Loads the entire SRAM from the device EEPROM.
New in version 1.3.4.
- Colorhug.device_mode_from_firmware(data)¶
- Parameters:
data (
bytes
) – firmware binary data- Returns:
- Return type:
Gets the device mode from the unique code stored in the firmware data. The firmware identifier has been present since colorhug-1.2.2.bin for ColorHug and all firmware versions for ColorHug2 and ColorHug+.
New in version 1.2.3.
- Colorhug.device_mode_to_string(device_mode)¶
- Parameters:
device_mode (
Colorhug.DeviceMode
) –- Return type:
New in version 0.1.29.
- Colorhug.device_open(device)¶
- Parameters:
device (
GUsb.Device
) –- Raises:
- Return type:
New in version 0.1.29.
- Colorhug.device_open_full(device, cancellable)¶
- Parameters:
device (
GUsb.Device
) – AGUsb.Device
cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
True
for success- Return type:
Opens the device ready for use.
New in version 1.3.1.
- Colorhug.device_read_sram(device, addr, len, cancellable)¶
- Parameters:
device (
GUsb.Device
) – AGUsb.Device
addr (
int
) –len (
int
) –cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
True
for success- Return type:
Reads a value from the SRAM.
New in version 1.3.4.
- Colorhug.device_save_sram(device, cancellable)¶
- Parameters:
device (
GUsb.Device
) – AGUsb.Device
cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
True
for success- Return type:
Saves the entire SRAM space into the device EEPROM.
New in version 1.3.4.
- Colorhug.device_self_test(device, cancellable)¶
- Parameters:
device (
GUsb.Device
) – AGUsb.Device
cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
True
for success- Return type:
Performs a self test on the device
New in version 1.3.1.
- Colorhug.device_set_ccd_calibration(device, nm_start, c0, c1, c2, cancellable)¶
- Parameters:
device (
GUsb.Device
) – AGUsb.Device
nm_start (
float
) –c0 (
float
) –c1 (
float
) –c2 (
float
) –cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
True
for success- Return type:
Sets any PCB wavelength_cal on the device
New in version 1.3.1.
- Colorhug.device_set_crypto_key(device, keys, cancellable)¶
- Parameters:
device (
GUsb.Device
) – AGUsb.Device
keys (
int
) – a set of XTEA keyscancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
True
for success- Return type:
Sets the firmware signing keys on the device.
IMPORTANT: This can only be called once until the device is unlocked.
New in version 1.3.1.
- Colorhug.device_set_illuminants(device, value, cancellable)¶
- Parameters:
device (
GUsb.Device
) – AGUsb.Device
value (
Colorhug.Illuminant
) – serial numbercancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
True
for success- Return type:
Sets the illuminants on the device
New in version 1.3.4.
- Colorhug.device_set_integral_time(device, value, cancellable)¶
- Parameters:
device (
GUsb.Device
) – AGUsb.Device
value (
int
) – integration time in mscancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
True
for success- Return type:
Sets the integration value for the next sample.
New in version 1.3.1.
- Colorhug.device_set_leds(device, value, cancellable)¶
- Parameters:
device (
GUsb.Device
) – AGUsb.Device
value (
Colorhug.StatusLed
) – serial numbercancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
True
for success- Return type:
Sets the LEDs on the device
New in version 1.3.1.
- Colorhug.device_set_pcb_errata(device, value, cancellable)¶
- Parameters:
device (
GUsb.Device
) – AGUsb.Device
value (
Colorhug.PcbErrata
) –Colorhug.PcbErrata
, e.g.Colorhug.PcbErrata.SWAPPED_LEDS
cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
True
for success- Return type:
Sets any PCB errata on the device
New in version 1.3.1.
- Colorhug.device_set_serial_number(device, value, cancellable)¶
- Parameters:
device (
GUsb.Device
) – AGUsb.Device
value (
int
) – serial numbercancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
True
for success- Return type:
Sets the serial number on the device
New in version 1.3.1.
- Colorhug.device_set_spectrum_full(device, kind, sp, cancellable)¶
- Parameters:
device (
GUsb.Device
) – AGUsb.Device
kind (
Colorhug.SpectrumKind
) – AColorhug.SpectrumKind
sp (
Colord.Spectrum
) – AColord.Spectrum
cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
True
for success- Return type:
Sets the spectrum from the device. This sends data multiple multiple times until the spectrum has been populated.
New in version 1.3.4.
- Colorhug.device_take_reading_spectral(device, value, cancellable)¶
- Parameters:
device (
GUsb.Device
) – AGUsb.Device
value (
Colorhug.SpectrumKind
) – aColorhug.SpectrumKind
, e.g.Colorhug.SpectrumKind.RAW
cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
True
for success- Return type:
Takes a reading from the device.
New in version 1.3.1.
- Colorhug.device_take_reading_xyz(device, calibration_idx, cancellable)¶
- Parameters:
device (
GUsb.Device
) – AGUsb.Device
calibration_idx (
int
) – A calibration index or 0 for nonecancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
a
Colord.ColorXYZ
, orNone
for error- Return type:
Takes a reading from the device and returns the XYZ value.
New in version 1.3.1.
- Colorhug.device_write_command(device, cmd, buffer_in, buffer_in_len, buffer_out, buffer_out_len, cancellable)¶
- Parameters:
device (
GUsb.Device
) – AGUsb.Device
cmd (
int
) – The command to use, e.g.Colorhug.CMD_GET_COLOR_SELECT
buffer_in_len (
int
) – The input buffer lengthbuffer_out_len (
int
) – The output buffer lengthcancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
orNone
- Raises:
- Returns:
True
if the command was executed successfully.- Return type:
Sends a message to the device and waits for a reply.
New in version 0.1.29.
- Colorhug.device_write_command_async(device, cmd, buffer_in, buffer_in_len, buffer_out, buffer_out_len, cancellable, callback, *user_data)¶
- Parameters:
device (
GUsb.Device
) – AGUsb.Device
cmd (
int
) – The command to use, e.g.Colorhug.CMD_GET_COLOR_SELECT
buffer_in_len (
int
) – The input buffer lengthbuffer_out_len (
int
) – The output buffer lengthcancellable (
Gio.Cancellable
orNone
) – AGio.Cancellable
, orNone
callback (
Gio.AsyncReadyCallback
orNone
) – AGio.AsyncReadyCallback
that will be called when finished.
Sends a message to the device and waits for a reply.
New in version 0.1.29.
- Colorhug.device_write_command_finish(device, res)¶
- Parameters:
device (
GUsb.Device
) – aGUsb.Device
instance.res (
Gio.AsyncResult
) – theGio.AsyncResult
- Raises:
- Returns:
True
if the request was fulfilled.- Return type:
Gets the result from the asynchronous function.
New in version 0.1.29.
- Colorhug.device_write_sram(device, addr, data, cancellable)¶
- Parameters:
device (
GUsb.Device
) – AGUsb.Device
addr (
int
) –data (
GLib.Bytes
) – AGLib.Bytes
cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
, orNone
- Raises:
- Returns:
True
for success- Return type:
Loads the entire SRAM from the device EEPROM.
New in version 1.3.4.
- Colorhug.measure_mode_to_string(measure_mode)¶
- Parameters:
measure_mode (
Colorhug.MeasureMode
) –- Return type:
New in version 0.1.29.
- Colorhug.multiplier_to_string(multiplier)¶
- Parameters:
multiplier (
Colorhug.FreqScale
) –- Return type:
New in version 0.1.29.
- Colorhug.sha1_parse(value, sha1)¶
- Parameters:
value (
str
) – A string representation of the SHA1 hashsha1 (
Colorhug.Sha1
) – AColorhug.Sha1
- Raises:
- Returns:
True
for success- Return type:
Parses a SHA1 hash from a string value.
New in version 0.1.29.
- Colorhug.strerror(error_enum)¶
- Parameters:
error_enum (
Colorhug.Error
) –- Return type:
New in version 0.1.29.