Skip to content

Commit

Permalink
Dual Output module readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ZodiusInfuser committed Oct 20, 2023
1 parent e44771d commit 897fe73
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 52 deletions.
50 changes: 0 additions & 50 deletions docs/dual_output.md

This file was deleted.

135 changes: 135 additions & 0 deletions docs/modules/dual_output.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# Dual Switched Output Module - Library Reference <!-- omit in toc -->

This is the library reference for the [Dual Switched Output Module for Yukon](https://pimoroni.com/yukon).

- [Getting Started](#getting-started)
- [Initialising the Module](#initialising-the-module)
- [Using the Module](#using-the-module)
- [Controlling its Outputs](#controlling-its-outputs)
- [Onboard Sensors](#onboard-sensors)
- [References](#references)
- [Constants](#constants)
- [Variables](#variables)
- [Functions](#functions)



## Getting Started

To start using a Dual Switched Output Module, you first need to import the class from `pimoroni_yukon.modules`.

```python
from pimoroni_yukon.modules import DualOutputModule
```

Then create an instance of `DualOutputModule`.

```python
module = DualOutputModule()
```


## Initialising the Module

As with all Yukon modules, `DualOutputModule` must be initialised before it can be used. This is achieved by first registering the module with the `Yukon` class, with the slot it is attached to.

```python
from pimoroni_yukon import SLOT1 as SLOT

# Import and set up Yukon and DualOutputModule instances

yukon.register_with_slot(module, SLOT)
```

Then `Yukon` can verify and initialise its modules.

```python
yukon.verify_and_initialise()
```

This checks each slot on the board to see if the modules expected by your program are physically attached to the board. Only if they match will the `DualOutputModule` be initialised, giving it access to the GPIO of the slot it is attached to.

Power can now be provided to all modules, by calling.

```python
yukon.enable_main_output()
```


## Using the Module

### Controlling its Outputs

With the `DualOutputModule` powered, its outputs can be enabled or disabled by calling `.enable(output)` or `.disable(output)`. The state can also be queried by calling `.is_enabled(output)`. `output` is either `1` or `2`.

Enabling an output does not cause it to produce a voltage, but rather "unlocks" the output to be controllable.

Control an output by calling `.output(output, value)` where `output` is either `1` or `2` and `value` is either `True` or `False`. The control state of an output can also be read, by calling `read_output(output)`.

Here is an example that toggles one of the outputs.

```python
OUTPUT = 1

module.enable(OUTPUT)

while True:
next_out_state = not module.read_output(OUTPUT)
module.output(OUTPUT, next_out_state)
yukon.monitored_sleep(1.0)
```


### Onboard Sensors

The Dual Switched Output module features an onboard thermistor, letting its temperature be monitored. This can be read by calling `.read_temperature()`.

Additionally, the power good status of the two output switches can be read by calling `.read_power_good(output)`, where `output` is either `1` or `2`. This will be `True` during normal operation, but will switch to `False` under various conditions. For details of these conditions, check the [SLG55021 datasheet](https://www.renesas.com/eu/en/document/dst/slg55021-200010v-datasheet).


## References

#### Constants

```python
NAME = "Dual Switched Output"
NUM_OUTPUTS = 2
TEMPERATURE_THRESHOLD = 50.0
```

#### Variables
```python
halt_on_not_pgood: bool
```

### Functions

```python
# Address Checking
@staticmethod
is_module(adc1_level: int, adc2_level: int, slow1: bool, slow2: bool, slow3: bool) -> bool

# Initialisation
DualOutputModule(halt_on_not_pgood=False: bool)
initialise(slot: SLOT, adc1_func: Callable, adc2_func: Callable) -> None
reset() -> None

# Power Control
enable(output: int) -> None
disable(output: int) -> None
is_enabled(output: int) -> bool

# Output Control
output(output: int, value: bool) -> None
read_output(output: int) -> bool

# Sensing
read_power_good(output: int) -> bool
read_temperature() -> float

# Monitoring
monitor() -> None
get_readings() -> OrderedDict
process_readings() -> None
clear_readings() -> None
```
2 changes: 1 addition & 1 deletion docs/modules/led_strip.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ yukon.enable_main_output()

### Controlling its Output

With the `LEDStripModule` powered, its output to the strip(s) can be enabled or disabled by calling `.enable()` or `.disable()`. The output state can also be queried by calling `.is_enabled()`.
With the `LEDStripModule` powered, its output to the strip(s) can be enabled or disabled by calling `.enable()` or `.disable()`. The state can also be queried by calling `.is_enabled()`.

### Accessing the LED Strip

Expand Down
2 changes: 1 addition & 1 deletion docs/modules/quad_servo_reg.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ yukon.enable_main_output()

### Controlling its Output

With the `QuadServoRegModule` powered, its output to the servos can be enabled or disabled by calling `.enable()` or `.disable()`. The output state can also be queried by calling `.is_enabled()`.
With the `QuadServoRegModule` powered, its output to the servos can be enabled or disabled by calling `.enable()` or `.disable()`. The state can also be queried by calling `.is_enabled()`.

### Accessing the Servos

Expand Down

0 comments on commit 897fe73

Please sign in to comment.