Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: michaellee1019/mcp23017
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.0.0
Choose a base ref
...
head repository: michaellee1019/mcp23017
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on Jan 22, 2025

  1. Copy the full SHA
    acc8f9c View commit details
Showing with 35 additions and 28 deletions.
  1. +26 −25 README.md
  2. +9 −3 meta.json
51 changes: 26 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -5,13 +5,14 @@ The MCP23017 is a GPIO expansion chip that uses i2c to add an additional 16 GPIO
## Model: michaellee1019:mcp23017:board
This model makes a Viam Board to control the mcp23017. Pins are numbered "0" to "15" for the pins. "0" maps to "A0" and range up to "15" for "B7"

No configuration needed. By default the i2c_address is `0x27` and can be configured with a different `i2c_address` as shown below. Additionally, all pins are configured with no input pull resistors. To enable the internal pullup resistor on a pin, add the pin number to the `pullups` list in configuration.
No configuration needed. By default the component will communicate with i2c_address `0x27` on i2c_bus `1`. You can change the i2c_address and i2c_bus in the configuration as shown below. Additionally, all pins are configured with no input pull resistors. To enable the internal pullup resistor on a pin, add the pin number to the `pullups` list in configuration.

This model is implemented using the [Adafruit mcp230xx library](https://docs.circuitpython.org/projects/mcp230xx/en/latest/index.html).

### Configuration
```
```json
{
"i2c_bus": 1,
"i2c_address": "0x27",
"pullups": [
"14",
@@ -24,9 +25,26 @@ This model is implemented using the [Adafruit mcp230xx library](https://docs.cir
- Supporting digital interrupts

## Model: michaellee1019:mcp23017:sevensegment
This model supports diplaying characters on two independent seven segment LED display. One character is connected to the "A" pins 0-7 and the other to the B pins. Its not the most efficient use of GPIO pins compared to other devices out there (for example take a look at the modules for [TM1637]() and [ht16k33](https://github.com/michaellee1019/ht16k33) modules). But it is useful if you want to control just 1-2 digits and especially useful in testing your datasheet knowledge for how to wire an LED segment display. Each LED is controllable on a `channel` with this model, which is either the A pins or B pins.
This model supports diplaying characters on two independent seven segment LED display. One character is connected to the "A" pins 0-7 and the other to the B pins. Its not the most efficient use of GPIO pins compared to other devices out there (for example take a look at the modules for [TM1637](https://github.com/michaellee1019/tm1637) and [HT16K33](https://github.com/michaellee1019/ht16k33) modules). But it is useful if you want to control just 1-2 digits and especially useful in testing your datasheet knowledge for how to wire an LED segment display. Each LED is controllable on a `channel` with this model, which is either the A pins or B pins.

### Configuration
```json
{
"i2c_bus": 1,
"i2c_address": "0x27",
"a_direction": "abcdefg",
"b_direction": "gfedcba"
}
```

| Attribute | Required? | Default | Description |
| -------- | ------- | ------ | ------ |
| `i2c_bus` | No | `1` | The i2c bus number to communicate with the `mcp20317`. For example the Raspberry Pi uses bus 1 in most circumstances. |
| `ic2_address` | No | `"0x27"` | The i2c address of the `mcp20317` peripheral. The default address of the `mcp20317` is usually `0x27` and can be changed using the `A0-A2` pins. |
| `a_direction` | No | `gfedcba` | Wiring order of the LED segments on the A channel |
| `b_direction` | No | `gfedcba` | Wiring order of the LED segments on the B channel |

### Wiring Order
#### Wiring Order
There are two standards for wiring LED segments: `gfedcba` and `abcdefg`: The most common is `gfedcba`. If you can choose your wiring, this is recommended. This standard seems like a clever ploy for those that can actually say the alphabet backwards, disadvantaging the rest of us. Depending on your wiring between the segment and the mcp23017, choose the corresponding mode based on the mapping below:

gfedcba:
@@ -53,44 +71,27 @@ A/B6 -> f
A/B7 -> g
```

### Configuration
```
{
"i2c_bus": 1,
"i2c_address": "0x27",
"a_direction": "abcdefg",
"b_direction": "gfedcba"
}
```

| Attribute | Required? | Default | Description |
| -------- | ------- | ------ | ------ |
| `i2c_bus` | No | `1` | The i2c bus number to communicate with the `mcp20317`. For example the Raspberry Pi uses bus 1 in most circumstances. |
| `ic2_address` | No | `"0x27"` | The i2c address of the `mcp20317` peripheral. The default address of the `mcp20317` is usually `0x27` and can be changed using the `A0-A2` pins. |
| `a_direction` | No | `gfedcba` | Wiring order of the LED segments on the A channel |
| `b_direction` | No | `gfedcba` | Wiring order of the LED segments on the B channel |

### Example DoCommands

#### Display Character
Show a single character on the specified channel (A or B).
```
```json
{
"display_char": {"char": "8","channel":"A"}
}
```

#### Clear Display
Clear text on the diplay. Equal to having the display render a `" "` space character
```
```json
{
"clear": {"channel":"A"}
}
```

#### Flash Word
Cycle through a sequence of characters to display a readable word. Each character will be displayed in order on the channel specified. There will be a delay of the specified seconds between each character.
```
```json
{
"flash_word": {"word": "ASDF","channel":"A", "delay_seconds": 0.25}
}
@@ -101,7 +102,7 @@ This model is a sensor that reads the state of the 16 pins on the mcp23017. It w

### Configuration
Similar to the `board` model, the `sensor` model requires the `i2c_bus` and `i2c_address` to be specified. Additionally, the `pullups` attribute is used to specify which pins should have internal pullups enabled.
```
```json
{
"i2c_bus": 1,
"i2c_address": "0x27",
12 changes: 9 additions & 3 deletions meta.json
Original file line number Diff line number Diff line change
@@ -7,15 +7,21 @@
"models": [
{
"api": "rdk:component:board",
"model": "michaellee1019:mcp23017:board"
"model": "michaellee1019:mcp23017:board",
"markdown_link": "README.md#model-michaellee1019mcp23017board",
"short_description": "A board component for the mcp23017 GPIO expansion chip. Pins are numbered 0-15."
},
{
"api": "rdk:component:generic",
"model": "michaellee1019:mcp23017:seven_segment_led"
"model": "michaellee1019:mcp23017:seven_segment_led",
"markdown_link": "README.md#model-michaellee1019mcp23017sevensegment",
"short_description": "A component to control up to two seven segment led displays using one mcp23017 chip."
},
{
"api": "rdk:component:sensor",
"model": "michaellee1019:mcp23017:sensor"
"model": "michaellee1019:mcp23017:sensor",
"markdown_link": "README.md#model-michaellee1019mcp23017sensor",
"short_description": "Provides a list of pin output states as a sensor component. Pins are numbered 0-15."
}
],
"entrypoint": "dist/main",