blink1.clib

blink(1) C library -- aka "blink1-lib"

Part of the blink(1) open source hardware project See https://github.com/todbot/blink1 for details

2012-2014, Tod E. Kurt, http://todbot.com/blog/ , http://thingm.com/

Members

Aliases

blink1_device
alias blink1_device = hid_device_
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
blink1_device
alias blink1_device = usbDevice
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
blink1_device
alias blink1_device = hid_device_
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
hid_device
alias hid_device = hid_device_
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.

Enums

blink1Type_t
enum blink1Type_t
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.

Functions

blink1_adjustBrightness
void blink1_adjustBrightness(ubyte brightness, ubyte* r, ubyte* g, ubyte* b)

Using a brightness value, update an r,g,b triplet Modifies r,g,b in place

blink1_bootloaderGo
int blink1_bootloaderGo(blink1_device* dev)

Tell blink(1) to reset into bootloader. mk3 devices only

blink1_bootloaderLock
int blink1_bootloaderLock(blink1_device* dev)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
blink1_clearCacheDev
int blink1_clearCacheDev(blink1_device* dev)

Clear the blink1 device cache for a given device. @param dev blink1 device @return cache index that was cleared, or -1 if not found

blink1_close_internal
void blink1_close_internal(blink1_device* dev)

Close opened blink1 device. Safe to call blink1_close on already closed device. @param dev blink1_device

blink1_degamma
int blink1_degamma(int n)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
blink1_deviceType
blink1Type_t blink1_deviceType(blink1_device* dev)

@return blink1Type_t (BLINK1_MK2, BLINK1_MK2, BLINK1_MK1)

blink1_deviceTypeById
blink1Type_t blink1_deviceTypeById(int i)

Returns device "mk" type at cache index i @return blink1Type_t (BLINK1_MK2, BLINK1_MK2, BLINK1_MK1)

blink1_deviceTypeToStr
char* blink1_deviceTypeToStr(blink1Type_t t)

Return a string representation of the blink(1) device type (e.g. "mk2" or "mk3") @return const string

blink1_disableDegamma
void blink1_disableDegamma()

Disable blink1-lib gamma curve. @note should probably always have it disabled

blink1_eeread
int blink1_eeread(blink1_device* dev, ushort addr, ubyte* val)

Read eeprom on mk1 devices @note For mk1 devices only

blink1_eewrite
int blink1_eewrite(blink1_device* dev, ushort addr, ubyte val)

Write eeprom on mk1 devices @note For mk1 devices only

blink1_enableDegamma
void blink1_enableDegamma()

Enable blink1-lib gamma curve.

blink1_enumerate
int blink1_enumerate()

Scan USB for blink(1) devices. @return number of devices found

blink1_enumerateByVidPid
int blink1_enumerateByVidPid(int vid, int pid)

Scan USB for devices by given VID,PID. @param vid vendor ID @param pid product ID @return number of devices found

blink1_error_msg
char* blink1_error_msg(int errCode)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
blink1_fadeToRGB
int blink1_fadeToRGB(blink1_device* dev, ushort fadeMillis, ubyte r, ubyte g, ubyte b)

Fade blink1 to given RGB color over specified time. @param dev blink1 device to command @param fadeMillis time to fade in milliseconds @param r red part of RGB color @param g green part of RGB color @param b blue part of RGB color @return -1 on error, 0 on success

blink1_fadeToRGBN
int blink1_fadeToRGBN(blink1_device* dev, ushort fadeMillis, ubyte r, ubyte g, ubyte b, ubyte n)

Fade specific LED on blink1mk2 to given RGB color over specified time. @note For mk2 devices. @param dev blink1 device to command @param fadeMillis time to fade in milliseconds @param r red part of RGB color @param g green part of RGB color @param b blue part of RGB color @param n which LED to address (0=all, 1=1st LED, 2=2nd LED) @return -1 on error, 0 on success

blink1_getCacheIndexByDev
int blink1_getCacheIndexByDev(blink1_device* dev)

Return cache index for a given blink1_device object. @param dev blink1 device to lookup @return cache index or -1 if not found

blink1_getCacheIndexById
int blink1_getCacheIndexById(ushort i)

Return cache index for a given blink1 id (0-max or serial number as uint32) @param i blink1 id (0-blink1_max_devices or serial as uint32) @return cache index or -1 if not found

blink1_getCacheIndexByPath
int blink1_getCacheIndexByPath(char* path)

Return cache index for a given platform-specific USB path. @param path platform-specific path string @return cache index or -1 if not found

blink1_getCacheIndexBySerial
int blink1_getCacheIndexBySerial(char* serial)

Return cache index for a given blink1 serial number. @param path platform-specific path string @return cache index or -1 if not found

blink1_getCachedCount
int blink1_getCachedCount()

Return number of entries in blink1 device cache. @note This is the number of devices found with blink1_enumerate() @return number of cache entries

blink1_getCachedPath
char* blink1_getCachedPath(int i)

Return platform-specific USB path for given cache index. @param i cache index @return path string

blink1_getCachedSerial
char* blink1_getCachedSerial(int i)

Return bilnk1 serial number for given cache index. @param i cache index @return 8-hexdigit serial number as string

blink1_getId
int blink1_getId(blink1_device* dev, ubyte** idbuf)

Internal testing

blink1_getSerialForDev
char* blink1_getSerialForDev(blink1_device* dev)

Return serial number string for give blink1 device. @param dev blink device to lookup @return 8-hexdigit serial number string

blink1_getStartupParams
int blink1_getStartupParams(blink1_device* dev, ubyte* bootmode, ubyte* playstart, ubyte* playend, ubyte* playcount)

@note only for devices with fw val 206+ or mk3

blink1_getVersion
int blink1_getVersion(blink1_device* dev)

Get blink1 firmware version. @param dev opened blink1 device @return version as scaled int number (e.g. "v1.1" = 101)

blink1_isMk2
int blink1_isMk2(blink1_device* dev)

Returns if given blink1_device is a mk2 or not @param dev blink1 device to check @return mk2=1, mk1=0

blink1_isMk2ById
int blink1_isMk2ById(int i)

Returns version of device at cache index i is a mk2

blink1_open
blink1_device* blink1_open()

Open first found blink(1) device. @return pointer to opened blink1_device or NULL if no blink1 found

blink1_openById
blink1_device* blink1_openById(uint id)

Open by "id", which if from 0-blink1_max_devices is index or if >blink1_max_devices, is numerical representation of serial number @param id ordinal 0-15 id of blink1 or numerical rep of 8-hex digit serial @return blink1_device or NULL if no blink1 found

blink1_openByPath
blink1_device* blink1_openByPath(char* path)

Open blink(1) by USB path. note: this is platform-specific, and port-specific. @param path string of platform-specific path to blink1 @return blink1_device or NULL if no blink1 found

blink1_openBySerial
blink1_device* blink1_openBySerial(char* serial)

Open blink(1) by 8-digit serial number. @param serial 8-hex digit serial number @return blink1_device or NULL if no blink1 found

blink1_pid
int blink1_pid()

Product ID for blink1 devices. @return blink1 PID

blink1_play
int blink1_play(blink1_device* dev, ubyte play, ubyte pos)

Play color pattern stored in blink1. @param dev blink1 device to command @param play boolean: 1=play, 0=stop @param pos position to start playing from @return -1 on error, 0 on success

blink1_playloop
int blink1_playloop(blink1_device* dev, ubyte play, ubyte startpos, ubyte endpos, ubyte count)

Play color pattern stored in blink1mk2. @note For mk2 devices only. @param dev blink1 device to command @param play boolean: 1=play, 0=stop @param startpos position to start playing from @param endpos position to end playing @param count number of times to play (0=forever) @return -1 on error, 0 on success

blink1_read
int blink1_read(blink1_device* dev, void* buf, int len)

Low-level read from blink1 device. Used internally by blink1-lib

blink1_readNote
int blink1_readNote(blink1_device* dev, ubyte noteid, ubyte** notebuf)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
blink1_readPatternLine
int blink1_readPatternLine(blink1_device* dev, ushort* fadeMillis, ubyte* r, ubyte* g, ubyte* b, ubyte pos)

Read a color pattern line to blink1. @param dev blink1 device to command @param fadeMillis pointer to milliseconds to fade to RGB color @param r pointer to store red color component @param g pointer to store green color component @param b pointer to store blue color component @return -1 on error, 0 on success

blink1_readPatternLineN
int blink1_readPatternLineN(blink1_device* dev, ushort* fadeMillis, ubyte* r, ubyte* g, ubyte* b, ubyte* ledn, ubyte pos)

Read a color pattern line to blink1. @note ledn param only works on fw204+ devices @param dev blink1 device to command @param fadeMillis pointer to milliseconds to fade to RGB color @return -1 on error, 0 on success

blink1_readPlayState
int blink1_readPlayState(blink1_device* dev, ubyte* playing, ubyte* playstart, ubyte* playend, ubyte* playcount, ubyte* playpos)

Read the current state of a playing pattern. @note For mk2 devices only. @param dev blink1 device to command @param playing pointer to play/stop boolean @param playstart pointer to start position @param playend pointer to end position @param playcount pointer to count left @param playpos pointer to play position @return -1 on error, 0 on success

blink1_readRGB
int blink1_readRGB(blink1_device* dev, ushort* fadeMillis, ubyte* r, ubyte* g, ubyte* b, ubyte ledn)

Read current RGB value on specified LED. @note For mk2 devices only. @param dev blink1 device to command @param r pointer to red part of RGB color @param g pointer to green part of RGB color @param b pointer to blue part of RGB color @param n which LED to get (0=1st, 1=1st LED, 2=2nd LED) @return -1 on error, 0 on success

blink1_readRGB_mk1
int blink1_readRGB_mk1(blink1_device* dev, ushort* fadeMillis, ubyte* r, ubyte* g, ubyte* b)

Attempt to read current RGB value for mk1 devices. @note Called by blink1_setRGB() if device is mk1. @note Does not always work. @param dev blink1 device to command @param r pointer to red part of RGB color @param g pointer to green part of RGB color @param b pointer to blue part of RGB color @return -1 on error, 0 on success

blink1_read_nosend
int blink1_read_nosend(blink1_device* dev, void* buf, int len)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
blink1_savePattern
int blink1_savePattern(blink1_device* dev)

Save color pattern in RAM to nonvolatile storage. @note For mk2 devices only. @note this doesn't actually return a proper return value, as the time it takes to write to flash actually exceeds USB timeout @param dev blink1 device to command @return -1 on error, 0 on success

blink1_serialnumread
int blink1_serialnumread(blink1_device* dev, ubyte** serialnumstr)

Read serial number from mk1 device. Does not work. @note Use USB descriptor serial number instead. @note for mk1 devices only. @note does not work.

blink1_serialnumwrite
int blink1_serialnumwrite(blink1_device* dev, ubyte* serialnumstr)

Write serial number to mk1 device. Does not work. @note for mk1 devices only. @note does not work.

blink1_serverdown
int blink1_serverdown(blink1_device* dev, ubyte on, ushort millis, ubyte st, ubyte startpos, ubyte endpos)

Tickle blink1 serverdown functionality. @note 'st' param for mk2 firmware only @param on enable or disable: enable=1, disable=0 @param millis milliseconds to wait until triggering (up to 65,355 millis) @param stay lit (st=1) or set off() (st=0) @param startpos pattern start position (fw 205+) @param endpos pattern end pos (fw 205+)

blink1_setLEDN
int blink1_setLEDN(blink1_device* dev, ubyte ledn)

Sets 'ledn' parameter for blink1_savePatternLine() @note only works on fw 204+ devices

blink1_setRGB
int blink1_setRGB(blink1_device* dev, ubyte r, ubyte g, ubyte b)

Set blink1 immediately to a specific RGB color. @note If mk2, sets all LEDs immediately @param dev blink1 device to command @param r red part of RGB color @param g green part of RGB color @param b blue part of RGB color @return -1 on error, 0 on success

blink1_setStartupParams
int blink1_setStartupParams(blink1_device* dev, ubyte bootmode, ubyte playstart, ubyte playend, ubyte playcount)

@note only for devices with fw val 206+ or mk3 FIXME: make 'params' a struct

blink1_sleep
void blink1_sleep(ushort delayMillis)

Simple wrapper for cross-platform millisecond delay. @param delayMillis number of milliseconds to wait

blink1_testtest
int blink1_testtest(blink1_device* dev, ubyte reportid)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
blink1_vid
int blink1_vid()

Vendor ID for blink1 devices. @return blink1 VID

blink1_write
int blink1_write(blink1_device* dev, void* buf, int len)

Low-level write to blink1 device. Used internally by blink1-lib

blink1_writeNote
int blink1_writeNote(blink1_device* dev, ubyte noteid, ubyte* notebuf)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
blink1_writePatternLine
int blink1_writePatternLine(blink1_device* dev, ushort fadeMillis, ubyte r, ubyte g, ubyte b, ubyte pos)

Write a color pattern line to blink1. @note on mk1 devices, this saves the pattern line to nonvolatile storage. @note on mk2 devices, this only saves to RAM (see savePattern() for nonvol) @param dev blink1 device to command @param r red part of RGB color @param g green part of RGB color @param b blue part of RGB color @param pos pattern line number 0-max_patt (FIXME: put note about this) @return -1 on error, 0 on success

hexdump
void hexdump(FILE* fp, ubyte* buffer, int len)
hexread
int hexread(ubyte* buffer, char* str, int buflen)
hsbtorgb
void hsbtorgb(rgb_t* rgb, ubyte* hsb)
msg
void msg(char* fmt, ...)

printf that can be shut up

msg_setquiet
void msg_setquiet(int q)
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
parsePattern
int parsePattern(char* str, int* repeats, patternline_t* pattern)
parsecolor
void parsecolor(rgb_t* color, char* colorstr)

Structs

hid_device_
struct hid_device_
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
patternline_t
struct patternline_t
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
rgb_t
struct rgb_t
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.

Variables

BLINK1_DEVICE_ID
int BLINK1_DEVICE_ID;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
BLINK1_VENDOR_ID
int BLINK1_VENDOR_ID;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
blink1_buf2_size
int blink1_buf2_size;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
blink1_buf_size
int blink1_buf_size;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
blink1_max_devices
int blink1_max_devices;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
blink1_note_size
int blink1_note_size;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
blink1_report2_id
int blink1_report2_id;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
blink1_report2_size
int blink1_report2_size;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
blink1_report_id
int blink1_report_id;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
blink1_report_size
int blink1_report_size;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
blink1mk2_serialstart
int blink1mk2_serialstart;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
blink1mk3_serialstart
int blink1mk3_serialstart;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
cache_max
int cache_max;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
pathstrmax
int pathstrmax;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.
serialstrmax
int serialstrmax;
Undocumented in source but is binding to C. You might be able to learn more by searching the web for its name.

Meta