Functions

  color_select_to_string (color_select)
  command_to_string (cmd)
  device_check_firmware (device, data, data_len)
  device_close (device)
  device_error_quark ()
  device_get_adc_calibration_neg (device, cancellable)
  device_get_adc_calibration_pos (device, cancellable)
  device_get_ccd_calibration (device, nm_start, c0, c1, c2, cancellable)
  device_get_error (device, cancellable)
  device_get_guid (device)
  device_get_illuminants (device, cancellable)
  device_get_integral_time (device, cancellable)
  device_get_leds (device, cancellable)
  device_get_mode (device)
  device_get_pcb_errata (device, cancellable)
  device_get_runcode_address (device)
  device_get_serial_number (device, cancellable)
  device_get_spectrum (device, cancellable)
  device_get_spectrum_full (device, kind, cancellable)
  device_get_temperature (device, cancellable)
  device_is_colorhug (device)
  device_load_sram (device, cancellable)
  device_mode_from_firmware (data, data_len)
  device_mode_to_string (device_mode)
  device_open (device)
  device_open_full (device, cancellable)
  device_read_sram (device, addr, len, cancellable)
  device_save_sram (device, cancellable)
  device_self_test (device, cancellable)
  device_set_ccd_calibration (device, nm_start, c0, c1, c2, cancellable)
  device_set_crypto_key (device, keys, cancellable)
  device_set_illuminants (device, value, cancellable)
  device_set_integral_time (device, value, cancellable)
  device_set_leds (device, value, cancellable)
  device_set_pcb_errata (device, value, cancellable)
  device_set_serial_number (device, value, cancellable)
  device_set_spectrum_full (device, kind, sp, cancellable)
  device_take_reading_spectral (device, value, cancellable)
  device_take_reading_xyz (device, calibration_idx, cancellable)
  device_write_command (device, cmd, buffer_in, buffer_in_len, buffer_out, buffer_out_len, cancellable)
  device_write_command_async (device, cmd, buffer_in, buffer_in_len, buffer_out, buffer_out_len, cancellable, callback, *user_data)
  device_write_command_finish (device, res)
  device_write_sram (device, addr, data, cancellable)
  measure_mode_to_string (measure_mode)
  multiplier_to_string (multiplier)
  sha1_parse (value, sha1)
  strerror (error_enum)

Details

Colorhug.color_select_to_string(color_select)
Parameters:color_select (Colorhug.ColorSelect) –
Return type:str

New in version 0.1.29.

Colorhug.command_to_string(cmd)
Parameters:cmd (int) –
Return type:str

New in version 0.1.29.

Colorhug.device_check_firmware(device, data, data_len)
Parameters:
  • device (GUsb.Device) –
  • data (int) – firmware binary data
  • data_len (int) – size of data
Raises:

GLib.Error

Returns:

True if the command was executed successfully.

Return type:

bool

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:GLib.Error
Return type:bool

New in version 1.2.11.

Colorhug.device_error_quark()
Returns:ChDevice error quark.
Return type:int

New in version 0.1.1.

Colorhug.device_get_adc_calibration_neg(device, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

True for success

value:offset value

Return type:

(bool, value: float)

Gets the ADC positive calibration value.

New in version 1.3.4.

Colorhug.device_get_adc_calibration_pos(device, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

True for success

value:offset value

Return type:

(bool, value: float)

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:
Raises:

GLib.Error

Returns:

True for success

Return type:

bool

Gets any PCB wavelength_cal from the device.

New in version 1.3.1.

Colorhug.device_get_error(device, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

True for success

status:a Colorhug.Error, e.g. Colorhug.Error.INVALID_ADDRESS
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) – A GUsb.Device
Returns:the GUID address, or None for error
Return type:str

Returns the GUID for the connected ColorHug device.

New in version 1.2.9.

Colorhug.device_get_illuminants(device, cancellable)
Parameters:
Raises:

GLib.Error

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:
Raises:

GLib.Error

Returns:

True for success

value:integration time in ms

Return type:

(bool, value: int)

Gets the integration time used for taking the next samples.

New in version 1.3.1.

Colorhug.device_get_leds(device, cancellable)
Parameters:
Raises:

GLib.Error

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:Colorhug.DeviceMode

New in version 0.1.29.

Colorhug.device_get_pcb_errata(device, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

True for success

value:Colorhug.PcbErrata, e.g. Colorhug.PcbErrata.SWAPPED_LEDS

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) – A GUsb.Device
Returns:the runcode address, or 0 for error
Return type:int

Returns the runcode address for the ColorHug device.

New in version 1.2.9.

Colorhug.device_get_serial_number(device, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

True for success

value:serial number

Return type:

(bool, value: int)

Gets the serial number from the device.

New in version 1.3.1.

Colorhug.device_get_spectrum(device, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

a Colord.Spectrum, or None for error

Return type:

Colord.Spectrum

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:
Raises:

GLib.Error

Returns:

a Colord.Spectrum, or None for error

Return type:

Colord.Spectrum

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:
Raises:

GLib.Error

Returns:

True for success

value:temperature in Celcius

Return type:

(bool, value: float)

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:bool

New in version 0.1.29.

Colorhug.device_load_sram(device, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

True for success

Return type:

bool

Loads the entire SRAM from the device EEPROM.

New in version 1.3.4.

Colorhug.device_mode_from_firmware(data, data_len)
Parameters:
  • data (int) – firmware binary data
  • data_len (int) – size of data
Returns:

A Colorhug.DeviceMode

Return type:

Colorhug.DeviceMode

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:str

New in version 0.1.29.

Colorhug.device_open(device)
Parameters:device (GUsb.Device) –
Raises:GLib.Error
Return type:bool

New in version 0.1.29.

Colorhug.device_open_full(device, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

True for success

Return type:

bool

Opens the device ready for use.

New in version 1.3.1.

Colorhug.device_read_sram(device, addr, len, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

True for success

Return type:

GLib.Bytes

Reads a value from the SRAM.

New in version 1.3.4.

Colorhug.device_save_sram(device, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

True for success

Return type:

bool

Saves the entire SRAM space into the device EEPROM.

New in version 1.3.4.

Colorhug.device_self_test(device, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

True for success

Return type:

bool

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:
Raises:

GLib.Error

Returns:

True for success

Return type:

bool

Sets any PCB wavelength_cal on the device

New in version 1.3.1.

Colorhug.device_set_crypto_key(device, keys, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

True for success

Return type:

bool

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:
Raises:

GLib.Error

Returns:

True for success

Return type:

bool

Sets the illuminants on the device

New in version 1.3.4.

Colorhug.device_set_integral_time(device, value, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

True for success

Return type:

bool

Sets the integration value for the next sample.

New in version 1.3.1.

Colorhug.device_set_leds(device, value, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

True for success

Return type:

bool

Sets the LEDs on the device

New in version 1.3.1.

Colorhug.device_set_pcb_errata(device, value, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

True for success

Return type:

bool

Sets any PCB errata on the device

New in version 1.3.1.

Colorhug.device_set_serial_number(device, value, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

True for success

Return type:

bool

Sets the serial number on the device

New in version 1.3.1.

Colorhug.device_set_spectrum_full(device, kind, sp, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

True for success

Return type:

bool

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:
Raises:

GLib.Error

Returns:

True for success

Return type:

bool

Takes a reading from the device.

New in version 1.3.1.

Colorhug.device_take_reading_xyz(device, calibration_idx, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

a Colord.ColorXYZ, or None for error

Return type:

Colord.ColorXYZ

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:
Raises:

GLib.Error

Returns:

True if the command was executed successfully.

Return type:

bool

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:

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:
Raises:

GLib.Error

Returns:

True if the request was fulfilled.

Return type:

bool

Gets the result from the asynchronous function.

New in version 0.1.29.

Colorhug.device_write_sram(device, addr, data, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

True for success

Return type:

bool

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:str

New in version 0.1.29.

Colorhug.multiplier_to_string(multiplier)
Parameters:multiplier (Colorhug.FreqScale) –
Return type:str

New in version 0.1.29.

Colorhug.sha1_parse(value, sha1)
Parameters:
Raises:

GLib.Error

Returns:

True for success

Return type:

bool

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:str

New in version 0.1.29.