Metadata-Version: 2.1
Name: sm16relind
Version: 1.0.4
Summary: Library to control Multi-IO Automation Card
Home-page: https://sequentmicrosystems.com
Author: Sequent Microsystems
Author-email: olcitu@gmail.com
License: MIT
Keywords: industrial,raspberry,power,4-20mA,0-10V,optoisolated
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Build Tools
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Description-Content-Type: text/markdown
License-File: LICENSE

# SM16relind

This is the python library to control the [Sixteen Relays 8-Layer Stackable HAT for Raspberry Pi](https://sequentmicrosystems.com/collections/all-io-cards/products/sixteen-relays-8-layer-stackable-hat-for-raspberry-pi).

## Install

```bash
sudo pip install SM16relind
```

or (if using python3.x):

```bash
sudo pip3 install SM16relind
```

## Update

```bash
sudo pip install SM16relind -U
```

or (if using python3.x):

```bash
sudo pip3 install SM16relind -U
```

### Manual installation (without pip)

```bash
~$ sudo apt-get update
~$ sudo apt-get install build-essential python-pip python-dev python-smbus git
~$ git clone https://github.com/SequentMicrosystems/16relind-rpi.git
~$ cd 16relind-rpi/python/
~/16relind-rpi/python$ sudo python setup.py install
```
If you use python3.x repace the last line with:
```
~/16relind-rpi/python$ sudo python3 setup.py install
```

### Manual update (only if installed without pip)

```bash
~$ cd 16relind-rpi/
~/16relind-rpi$ git pull
~$ cd 16relind-rpi/python
~/16relind-rpi/python$ sudo python setup.py install
```
If you use python3.x repace the last line with:
```
~/16relind-rpi/python$ sudo python3 setup.py install
```

## Usage example

```bash
~$ python
Python 3.10.7 (main, Nov  7 2022, 22:59:03) [GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import SM16relind
>>> rel = SM16relind.SM16relind(0)
>>> rel.set(1, 1)
>>> rel.get_all()
1
>>>
```

More usage example in the [examples](examples/) folder

## Functions prototype

### *class SM16relind.SM16relind(stack = 0, i2c = 1)*
* Description
  * Init the SM16relind object and check the card presence 
* Parameters
  * stack : Card stack level [0..7] set by the jumpers
  * i2c : I2C port number, 1 - Raspberry default , 7 - rock pi 4, etc.
* Returns 
  * card object

#### *set(relay, val)*
* Description
  * Set one relay state
* Parameters
  * *relay*: The relay number 1 to 16
  * *val*: The new state of the relay 0 = turn off else turn on
* Returns
  * none
  
#### *set_all(val)*
* Description
  * Set the state of all relays as a 16 bits bit-map
* Parameters
  * *val*: The new state of all 16 relays, 0 => all off, 15 => all on
* Returns
  * none
  
#### *get(relay)*
* Description
  * Read one relay state
* Parameters
  * *relay* relay number [1..16]
* Returns
  * the state of the relay 0 or 1

#### *get_all()*
* Description
  * Read the state of all 16 relays 
* Parameters
  * none
* Returns
  * relays state as bitmap [0..65535]

