Metadata-Version: 2.1
Name: k8090
Version: 1.0.0
Summary: A class for interacting with K8090 or VM8090 relay boards
Author-email: Morten Hauan <morten@hauan.me>
License: MIT License
        
        Copyright (c) 2022 Morten Hauan
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/mortenhauan/k8090
Project-URL: Bug Tracker, https://github.com/mortenhauan/k8090/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE

# K8090

A module for interacting with the K8090 and VM8090 relay boards.

## Installation

To install the module, run the following command:

```bash
pip install k8090
```

## Example

```python
# Import relay_card from k8090
import time
from k8090 import relay_card

# Connecting to card
card = relay_card.connect('/dev/tty.usbmodem11301')

# Doing factory reset
card.factory_reset()

# Reading information about card
print(f'Firmware version: {card.firmware_version}')
print(f'Jumper status: {card.jumper_status}\n')

# Copying relay 4 into a variable
relay_4 = card.relays[3]

# Toggle relay 4
relay_4.on()
card.relays[3].off()
relay_4.toggle()
card.relays[3].toggle()

# Turn on relay 4 and then turn off after 10 seconds
relay_4.delay = 10
relay_4.timer()

# Getting status of all relays
for relay in card.relays:
    print(f'Relay number: {relay.id+1}')
    print(f'Relay status: {relay.status}')
    print(f'Relay delay: {relay.delay}')
    print(f'Timer is active: {relay.timer_is_active}\n')

print(f'Relay 4 delay: {relay_4.delay}')

# Copying button 4 into a variable
button_4 = card.buttons[3]

# Changing mode of button 4 to momentary
button_4.mode = card.Button.MOMENTARY

# Getting status of button 1 every second for 10 seconds
button_1 = card.buttons[0]
for _ in range(10):
    print(f'Button 1 pressed: {button_1.pressed}')
    print(f'Button 1 mode: {button_1.mode}')
    print(f'Button 1 last action: {button_1.action}\n')
    time.sleep(1)

# Getting status of all buttons
for button in card.buttons:
    print(f'Button number: {button.id+1}')
    print(f'Button 1 pressed: {button.pressed}')
    print(f'Button 1 mode: {button.mode}')
    print(f'Button 1 last action: {button.action}\n')

```
