An open API service indexing awesome lists of open source software.

https://github.com/stonatm/sparkfun_com-21209

SparkFun COM-21209 OWire LED python library
https://github.com/stonatm/sparkfun_com-21209

com-21209 led micropython onewire programmable python

Last synced: 4 months ago
JSON representation

SparkFun COM-21209 OWire LED python library

Awesome Lists containing this project

README

          

# SparkFun OWire LED python library
Micropython driver for owire led SparkFun COM-21209

## owire_led library

source file: [owire_led.py](./owire_led.py)

![./led.gif](./led.gif)

---
Initialize led.
```
import owire_led
disp = OWIRE(led_pin)
```
parameters:

**led_pin** - pin number where led is connected.

---
Set color.
```
function set_color(color)
```
parameters:

**color** - chose color from avialable colors:

```
OWIRE.RED
OWIRE.GREEN
OWIRE.BLUE
OWIRE.YELLOW
OWIRE.PURPLE
OWIRE.CYAN_BLUE
OWIRE.WHITE
OWIRE.FULL_COLOR
OWIRE.R_G_W
OWIRE.R_B_W
OWIRE.SIX_COLOR
```

---
Set flashing mode.
```
function set_mode(mode)
```

parameters:

**mode** - mode number, range **0..7**

mode list:

**0** - static, always on

**1** - 8s getting lighter and darker

**2** - slow X background color flashes white (4s flashes 0.5s)

**3** - 2s wave

**4** - slow speed without background color flash X color (idle 4s, flash 0.5s)

**5** - fast X background color flashes white (1s flash 0.125s)

**6** - slow X background color flashes for 0.5s)

**7** - fast flash x color without background color (1s flash 0.125s)

---
Set previously chosen color and mode, send data to led.

```
function send_data()
```

---
### Example:

```
import owire_led
import time

led = OWIRE(LED_PIN)

for led_mode in range(8):
# set led mode
led.set_mode(led_mode)
# set led color and send data to led
led.set_color(led.GREEN)
led.send_data()
time.sleep(8)
led.set_color(led.RED)
led.send_data()
time.sleep(8)
led.set_color(led.YELLOW)
led.send_data()
time.sleep(8)

```