Skip to content

Commit 6fbc8a8

Browse files
committed
doc updates
1 parent 7ef97eb commit 6fbc8a8

File tree

3 files changed

+161
-1
lines changed

3 files changed

+161
-1
lines changed

README.md

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ https://blink1.thingm.com/
1919
* [Servertickle watchdog](#servertickle-watchdog)
2020
* [Gamma correction](#gamma-correction)
2121
* [White point correction](#white-point-correction)
22+
* [API reference](#api-reference)
2223
* [Developer installation](#developer-installation)
2324

2425
## About this library
@@ -226,6 +227,157 @@ The library supports the following temperature names:
226227
* shade
227228
* blue-sky
228229

230+
## API reference
231+
```
232+
Help on class Blink1 in blink1.blink1:
233+
234+
blink1.blink1.Blink1 = class Blink1
235+
| Light controller class, sends messages to the blink(1) via USB HID.
236+
|
237+
| Methods defined here:
238+
|
239+
| __init__(self, serial_number=None, gamma=None, white_point=None)
240+
| :param serial_number: serial number of blink(1) to open, otherwise first found
241+
| :param gamma: Triple of gammas for each channel e.g. (2, 2, 2)
242+
|
243+
| clear_pattern(self)
244+
| Clear entire color pattern in blink(1)
245+
| :raises: Blink1ConnectionFailed: if blink(1) is disconnected
246+
|
247+
| close(self)
248+
|
249+
| fade_to_color(self, fade_milliseconds, color, ledn=0)
250+
| Fade the light to a known colour
251+
| :param fade_milliseconds: Duration of the fade in milliseconds
252+
| :param color: Named color to fade to (e.g. "#FF00FF", "red")
253+
| :param ledn: which led to control
254+
| :raises: Blink1ConnectionFailed: if blink(1) is disconnected
255+
|
256+
| fade_to_rgb(self, fade_milliseconds, red, green, blue, ledn=0)
257+
| Command blink(1) to fade to RGB color
258+
| :param fade_milliseconds: millisecs duration of fade
259+
| :param red: 0-255
260+
| :param green: 0-255
261+
| :param blue: 0-255
262+
| :param ledn: which LED to control (0=all, 1=LED A, 2=LED B)
263+
| :raises: Blink1ConnectionFailed: if blink(1) is disconnected
264+
|
265+
| fade_to_rgb_uncorrected(self, fade_milliseconds, red, green, blue, ledn=0)
266+
| Command blink(1) to fade to RGB color, no color correction applied.
267+
| :throws: Blink1ConnectionFailed if blink(1) is disconnected
268+
|
269+
| get_serial_number(self)
270+
| Get blink(1) serial number
271+
| :return blink(1) serial number as string
272+
| :raises: Blink1ConnectionFailed: if blink(1) is disconnected
273+
|
274+
| get_version(self)
275+
| Get blink(1) firmware version
276+
| :raises: Blink1ConnectionFailed: if blink(1) is disconnected
277+
|
278+
| notfound(self)
279+
|
280+
| off(self)
281+
| Switch the blink(1) off instantly
282+
| :raises: Blink1ConnectionFailed: if blink(1) is disconnected
283+
|
284+
| play(self, start_pos=0, end_pos=0, count=0)
285+
| Play internal color pattern
286+
| :param start_pos: pattern line to start from
287+
| :param end_pos: pattern line to end at
288+
| :param count: number of times to play, 0=play forever
289+
| :raises: Blink1ConnectionFailed: if blink(1) is disconnected
290+
|
291+
| play_pattern(self, pattern_str, onDevice=True)
292+
| Play a Blink1Control-style pattern string
293+
| :param pattern_str: The Blink1Control-style pattern string to play
294+
| :param onDevice: True (default) to run pattern on blink(1),
295+
| otherwise plays in Python process
296+
| :raises: Blink1ConnectionFailed: if blink(1) is disconnected
297+
|
298+
| play_pattern_local(self, pattern_str)
299+
| Play a Blink1Control pattern string in Python process
300+
| (plays in blink1-python, so blocks)
301+
| :param pattern_str: The Blink1Control-style pattern string to play
302+
| :raises: Blink1ConnectionFailed: if blink(1) is disconnected
303+
|
304+
| read(self)
305+
| Read command result from blink(1), low-level internal use
306+
| Receive USB Feature Report 0x01 from blink(1) with 8-byte payload
307+
| Note: buf must be 8 bytes or bad things happen
308+
|
309+
| read_pattern(self)
310+
| Read the entire color pattern
311+
| :return List of pattern line tuples
312+
| :raises: Blink1ConnectionFailed: if blink(1) is disconnected
313+
|
314+
| read_pattern_line(self, pos)
315+
| Read a color pattern line at position
316+
| :param pos: pattern line to read
317+
| :return pattern line data as tuple (r,g,b, step_millis) or False on err
318+
| :raises: Blink1ConnectionFailed: if blink(1) is disconnected
319+
|
320+
| save_pattern(self)
321+
| Save internal RAM pattern to flash
322+
| :raises: Blink1ConnectionFailed: if blink(1) is disconnected
323+
|
324+
| server_tickle(self, enable, timeout_millis=0, stay_lit=False, start_pos=0, end_pos=16)
325+
| Enable/disable servertickle / serverdown watchdog
326+
| :param: enable: Set True to enable serverTickle
327+
| :param: timeout_millis: millisecs until servertickle is triggered
328+
| :param: stay_lit: Set True to keep current color of blink(1), False to turn off
329+
| :param: start_pos: Sub-pattern start position in whole color pattern
330+
| :param: end_pos: Sub-pattern end position in whole color pattern
331+
| :raises: Blink1ConnectionFailed: if blink(1) is disconnected
332+
|
333+
| set_ledn(self, ledn=0)
334+
| Set the 'current LED' value for writePatternLine
335+
| :param ledn: LED to adjust, 0=all, 1=LEDA, 2=LEDB
336+
| :raises: Blink1ConnectionFailed: if blink(1) is disconnected
337+
|
338+
| stop(self)
339+
| Stop internal color pattern playing
340+
| :raises: Blink1ConnectionFailed: if blink(1) is disconnected
341+
|
342+
| write(self, buf)
343+
| Write command to blink(1), low-level internal use
344+
| Send USB Feature Report 0x01 to blink(1) with 8-byte payload
345+
| Note: arg 'buf' must be 8 bytes or bad things happen
346+
| :return: number of bytes written or -1 if failure
347+
|
348+
| write_pattern_line(self, step_milliseconds, color, pos, ledn=0)
349+
| Write a color & step time color pattern line to RAM
350+
| :param step_milliseconds: how long for this pattern line to take
351+
| :param color: LED color
352+
| :param pos: color pattern line number (0-15)
353+
| :param ledn: LED number to adjust, 0=all, 1=LEDA, 2=LEDB
354+
| :raises: Blink1ConnectionFailed: if blink(1) is disconnected
355+
|
356+
| ----------------------------------------------------------------------
357+
| Static methods defined here:
358+
|
359+
| color_to_rgb(color)
360+
| Convert color name or hexcode to (r,g,b) tuple
361+
| :param color: a color string, e.g. "#FF00FF" or "red"
362+
| :raises: InvalidColor: if color string is bad
363+
|
364+
| find(serial_number=None)
365+
| Find a praticular blink(1) device, or the first one
366+
| :param serial_number: serial number of blink(1) device (from Blink1.list())
367+
| :raises: Blink1ConnectionFailed: if blink(1) is not present
368+
|
369+
| list()
370+
| List blink(1) devices connected, by serial number
371+
| :return: List of blink(1) device serial numbers
372+
|
373+
| parse_pattern(pattern_str)
374+
| Parse a Blink1Control pattern string to a list of pattern lines
375+
| e.g. of the form '10,#ff00ff,0.1,0,#00ff00,0.1,0'
376+
| :param pattern_str: The Blink1Control-style pattern string to parse
377+
| :returns: an list of dicts of the parsed out pieces
378+
```
379+
380+
229381
## Developer installation
230382

231383
Having checked out the `blink1-python` library, cd to its directory and run the setup script:

blink1/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
""" blink1 library for python
2+
"""
3+
4+
#__all__ = [
5+
# 'Blink1',
6+
# 'Blink1ConnectionFailed',
7+
#]
8+
#from .blink1 import Blink1,Blink1ConnectionFailed

blink1/blink1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def __call__(self, r, g, b):
7171

7272

7373
class Blink1:
74-
"""Light controller class, sends messages to the blink(1) and blink(1) mk2 via USB HID.
74+
"""Light controller class, sends messages to the blink(1) via USB HID.
7575
"""
7676
def __init__(self, serial_number=None, gamma=None, white_point=None):
7777
"""

0 commit comments

Comments
 (0)