Skip to content

Commit

Permalink
add driver code
Browse files Browse the repository at this point in the history
  • Loading branch information
martha-johnston committed Nov 6, 2024
1 parent 0af6608 commit 1d8417f
Show file tree
Hide file tree
Showing 15 changed files with 968 additions and 57 deletions.
4 changes: 2 additions & 2 deletions .canon.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file provides project-level configuration for the canon dev environment utility. https://github.com/viamrobotics/canon
MODULE:
uln2003:
default: true
image_amd64: ghcr.io/viamrobotics/rdk-devenv:amd64-cache
image_arm64: ghcr.io/viamrobotics/rdk-devenv:arm64-cache
Expand All @@ -9,7 +9,7 @@ MODULE:
group: testbot
persistent: true

MODULE-antique:
uln2003-antique:
image_amd64: ghcr.io/viamrobotics/antique2:amd64-cache
image_arm64: ghcr.io/viamrobotics/antique2:arm64-cache
minimum_date: 2023-10-26T20:00:00.0Z
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ jobs:
script: |
let prNumber = context.payload.pull_request && context.payload.pull_request.number;
try {
await github.rest.issues.removeLabel({owner: "viam-modules", repo: "MODULE", issue_number: prNumber, name: "safe to test"});
await github.rest.issues.removeLabel({owner: "viam-modules", repo: "uln2003", issue_number: prNumber, name: "safe to test"});
} catch (err) {
core.info(`Non-fatal error ${err}, while trying to remove 'safe to test' label.`);
}
let orgResp = await github.rest.orgs.checkMembershipForUser({org: "viam-modules", username: context.payload.sender.login});
if (orgResp.status === 204) {
// order of labeling events must be preserved, so two seperate calls
await github.rest.issues.addLabels({owner: "viam-modules", repo: "MODULE", issue_number: prNumber, labels: ["safe to test"]});
await github.rest.issues.addLabels({owner: "viam-modules", repo: "uln2003", issue_number: prNumber, labels: ["safe to test"]});
return true;
}
return false;
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pullrequest-trusted.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ on:
jobs:
test:
if: (github.event.label.name == 'safe to test' || github.event.label.name == 'appimage')
uses: viam-modules/MODULE/.github/workflows/test.yml@main
uses: viam-modules/uln2003/.github/workflows/test.yml@main
secrets:
MONGODB_TEST_OUTPUT_URI: ${{ secrets.MONGODB_TEST_OUTPUT_URI }}
DOCKER_PUBLIC_READONLY_PAT: ${{ secrets.DOCKER_PUBLIC_READONLY_PAT }}

license_finder:
uses: viam-modules/MODULE/.github/workflows/license_finder.yml@main
uses: viam-modules/uln2003/.github/workflows/license_finder.yml@main
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ jobs:
- name: Build and package
run: |
canon --profile MODULE
canon --profile uln2003
TARGET_OS=${{ matrix.platform }} TARGET_ARCH=${{ matrix.arch }} make module
- name: Upload MODULE module to registry
- name: Upload uln2003 module to registry
uses: viamrobotics/upload-module@main
with:
meta-path: meta.json
Expand Down
Empty file removed MODEL/MODEL.go
Empty file.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ endif

module: build
rm -f $(BIN_OUTPUT_PATH)/module.tar.gz
tar czf $(BIN_OUTPUT_PATH)/module.tar.gz $(BIN_OUTPUT_PATH)/MODULE meta.json
tar czf $(BIN_OUTPUT_PATH)/module.tar.gz $(BIN_OUTPUT_PATH)/uln2003 meta.json

build: build-go

build-go:
rm -f $(BIN_OUTPUT_PATH)/MODULE
go build -tags no_cgo,osusergo,netgo -ldflags="-extldflags=-static $(COMMON_LDFLAGS)" -o $(BIN_OUTPUT_PATH)/MODULE main.go
rm -f $(BIN_OUTPUT_PATH)/uln2003
go build -tags no_cgo,osusergo,netgo -ldflags="-extldflags=-static $(COMMON_LDFLAGS)" -o $(BIN_OUTPUT_PATH)/uln2003 main.go

tool-install:
GOBIN=`pwd`/$(TOOL_BIN) go install \
Expand Down
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# [`MODULE` module](https://github.com/viam-modules/MODULE)
# [`uln2003` module](https://github.com/viam-modules/uln2003)

This [MODULE module](https://app.viam.com/module/viam/MODULE) implements a MODULE [MODEL COMPONENT](<LINK TO HARDWARE>), used for <DESCRIPTION> using the [`rdk:component:COMPONENT` API](https://docs.viam.com/appendix/apis/components/COMPONENT/).
This [uln2003 module](https://app.viam.com/module/viam/uln2003) implements a uln2003 [28byj-48 motor](<LINK TO HARDWARE>), used for <DESCRIPTION> using the [`rdk:component:motor` API](https://docs.viam.com/appendix/apis/components/motor/).

> [!NOTE]
> Before configuring your COMPONENT, you must [create a machine](https://docs.viam.com/cloud/machines/#add-a-new-machine).
> Before configuring your motor, you must [create a machine](https://docs.viam.com/cloud/machines/#add-a-new-machine).
## Configure your MODEL COMPONENT
## Configure your 28byj-48 motor

Navigate to the [**CONFIGURE** tab](https://docs.viam.com/configure/) of your [machine](https://docs.viam.com/fleet/machines/) in the [Viam app](https://app.viam.com/).
[Add COMPONENT / MODULE:MODEL to your machine](https://docs.viam.com/configure/#components).
[Add motor / uln2003:28byj-48 to your machine](https://docs.viam.com/configure/#components).

On the new component panel, copy and paste the following attribute template into your COMPONENT's attributes field:
On the new component panel, copy and paste the following attribute template into your motor's attributes field:

```json
{
Expand All @@ -20,22 +20,22 @@ On the new component panel, copy and paste the following attribute template into

### Attributes

The following attributes are available for `viam:MODULE:MODEL` COMPONENTs:
The following attributes are available for `viam:uln2003:28byj-48` motors:

<EXAMPLE !!>
| Attribute | Type | Required? | Description |
| --------- | ---- | --------- | ---------- |
| `i2c_bus` | string | **Required** | The index of the I<sup>2</sup>C bus on the board that the COMPONENT is wired to. |
| `i2c_address` | string | Optional | Default: `0x77`. The [I<sup>2</sup>C device address](https://learn.adafruit.com/i2c-addresses/overview) of the COMPONENT. |
| `i2c_bus` | string | **Required** | The index of the I<sup>2</sup>C bus on the board that the motor is wired to. |
| `i2c_address` | string | Optional | Default: `0x77`. The [I<sup>2</sup>C device address](https://learn.adafruit.com/i2c-addresses/overview) of the motor. |

## Example configuration

### `viam:MODULE:MODEL`
### `viam:uln2003:28byj-48`
```json
{
"name": "<your-MODULE-MODEL-COMPONENT-name>",
"model": "viam:MODULE:MODEL",
"type": "COMPONENT",
"name": "<your-uln2003-28byj-48-motor-name>",
"model": "viam:uln2003:28byj-48",
"type": "motor",
"namespace": "rdk",
"attributes": {
},
Expand All @@ -44,6 +44,6 @@ The following attributes are available for `viam:MODULE:MODEL` COMPONENTs:
```

### Next Steps
- To test your COMPONENT, expand the **TEST** section of its configuration pane or go to the [**CONTROL** tab](https://docs.viam.com/fleet/control/).
- To write code against your COMPONENT, use one of the [available SDKs](https://docs.viam.com/sdks/).
- To view examples using a COMPONENT component, explore [these tutorials](https://docs.viam.com/tutorials/).
- To test your motor, expand the **TEST** section of its configuration pane or go to the [**CONTROL** tab](https://docs.viam.com/fleet/control/).
- To write code against your motor, use one of the [available SDKs](https://docs.viam.com/sdks/).
- To view examples using a motor component, explore [these tutorials](https://docs.viam.com/tutorials/).
1 change: 1 addition & 0 deletions etc/golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ linters:
- importas
- interfacebloat
- interfacer
- intrange
- ireturn
- maintidx
- maligned
Expand Down
39 changes: 35 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module MODULE
module uln2003

go 1.23.0

Expand All @@ -8,8 +8,11 @@ require (
github.com/edaniels/golinters v0.0.5-0.20220906153528-641155550742
github.com/fullstorydev/grpcurl v1.8.6
github.com/golangci/golangci-lint v1.61.0
github.com/pkg/errors v0.9.1
github.com/rhysd/actionlint v1.6.24
go.uber.org/multierr v1.11.0
go.viam.com/rdk v0.48.2
go.viam.com/test v1.1.1-0.20220913152726-5da9916c08a2
go.viam.com/utils v0.1.110
gotest.tools/gotestsum v1.10.0
)
Expand Down Expand Up @@ -42,11 +45,15 @@ require (
github.com/alexkohler/nakedret/v2 v2.0.4 // indirect
github.com/alexkohler/prealloc v1.0.0 // indirect
github.com/alingse/asasalint v0.0.11 // indirect
github.com/apache/arrow/go/arrow v0.0.0-20201229220542-30ce2eb5d4dc // indirect
github.com/ashanbrown/forbidigo v1.6.0 // indirect
github.com/ashanbrown/makezero v1.1.1 // indirect
github.com/aybabtme/uniplot v0.0.0-20151203143629-039c559e5e7e // indirect
github.com/benbjohnson/clock v1.3.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bep/debounce v1.2.1 // indirect
github.com/bkielbasa/cyclop v1.2.1 // indirect
github.com/blackjack/webcam v0.6.1 // indirect
github.com/blizzy78/varnamelen v0.8.0 // indirect
github.com/bluenviron/gortsplib/v4 v4.8.0 // indirect
github.com/bombsimon/wsl/v4 v4.4.1 // indirect
Expand All @@ -65,6 +72,8 @@ require (
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/charithe/durationcheck v0.0.10 // indirect
github.com/chavacava/garif v0.1.0 // indirect
github.com/chewxy/hm v1.0.0 // indirect
github.com/chewxy/math32 v1.0.8 // indirect
github.com/ckaznocha/intrange v0.2.0 // indirect
github.com/cncf/xds/go v0.0.0-20240423153145-555b57ec207b // indirect
github.com/curioswitch/go-reassign v0.2.0 // indirect
Expand All @@ -73,6 +82,7 @@ require (
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/denis-tingaikin/go-header v0.5.0 // indirect
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
github.com/disintegration/imaging v1.6.2 // indirect
github.com/dnephin/pflag v1.0.7 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/edaniels/golog v0.0.0-20230215213219-28954395e8d0 // indirect
Expand All @@ -87,15 +97,22 @@ require (
github.com/fatih/structtag v1.2.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/firefart/nonamedreturns v1.0.5 // indirect
github.com/fogleman/gg v1.3.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/fzipp/gocyclo v0.6.0 // indirect
github.com/gen2brain/malgo v0.11.21 // indirect
github.com/ghostiam/protogetter v0.3.6 // indirect
github.com/go-audio/audio v1.0.0 // indirect
github.com/go-audio/riff v1.0.0 // indirect
github.com/go-audio/transforms v0.0.0-20180121090939-51830ccc35a5 // indirect
github.com/go-audio/wav v1.1.0 // indirect
github.com/go-critic/go-critic v0.11.4 // indirect
github.com/go-fonts/liberation v0.3.0 // indirect
github.com/go-gl/mathgl v1.0.0 // indirect
github.com/go-latex/latex v0.0.0-20230307184459-12ec69307ad9 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-nlopt/nlopt v0.0.0-20230219125344-443d3362dcb5 // indirect
github.com/go-pdf/fpdf v0.6.0 // indirect
github.com/go-toolsmith/astcast v1.1.0 // indirect
github.com/go-toolsmith/astcopy v1.1.0 // indirect
Expand All @@ -109,6 +126,7 @@ require (
github.com/gobwas/glob v0.2.3 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/gofrs/flock v0.12.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 // indirect
Expand All @@ -123,6 +141,7 @@ require (
github.com/golangci/revgrep v0.5.3 // indirect
github.com/golangci/unconvert v0.0.0-20240309020433-c5143eacb3ed // indirect
github.com/gonuts/binary v0.2.0 // indirect
github.com/google/flatbuffers v2.0.6+incompatible // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/s2a-go v0.1.8 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
Expand Down Expand Up @@ -169,6 +188,7 @@ require (
github.com/lestrrat-go/jwx v1.2.29 // indirect
github.com/lestrrat-go/option v1.0.1 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/lmittmann/ppm v1.0.2 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/lufeee/execinquery v1.2.1 // indirect
github.com/macabu/inamedparam v0.1.3 // indirect
Expand All @@ -186,6 +206,8 @@ require (
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/montanaflynn/stats v0.7.0 // indirect
github.com/moricho/tparallel v0.3.2 // indirect
github.com/muesli/clusters v0.0.0-20200529215643-2700303c1762 // indirect
github.com/muesli/kmeans v0.3.1 // indirect
github.com/nakabonne/nestif v0.3.1 // indirect
github.com/nishanths/exhaustive v0.12.0 // indirect
github.com/nishanths/predeclared v0.2.2 // indirect
Expand All @@ -199,6 +221,7 @@ require (
github.com/pion/interceptor v0.1.29 // indirect
github.com/pion/logging v0.2.2 // indirect
github.com/pion/mdns v0.0.12 // indirect
github.com/pion/mediadevices v0.6.4 // indirect
github.com/pion/randutil v0.1.0 // indirect
github.com/pion/rtcp v1.2.14 // indirect
github.com/pion/rtp v1.8.7 // indirect
Expand All @@ -208,7 +231,7 @@ require (
github.com/pion/stun v0.6.1 // indirect
github.com/pion/transport/v2 v2.2.10 // indirect
github.com/pion/turn/v2 v2.1.6 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pion/webrtc/v3 v3.2.36 // indirect
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/polyfloyd/go-errorlint v1.6.0 // indirect
Expand Down Expand Up @@ -266,6 +289,8 @@ require (
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/xen0n/gosmopolitan v1.2.2 // indirect
github.com/xfmoulet/qoi v0.2.0 // indirect
github.com/xtgo/set v1.0.0 // indirect
github.com/yagipy/maintidx v1.0.0 // indirect
github.com/yeya24/promlinter v0.3.0 // indirect
github.com/ykadowak/zerologlint v0.1.5 // indirect
Expand All @@ -285,10 +310,9 @@ require (
go.opentelemetry.io/otel/trace v1.29.0 // indirect
go.uber.org/automaxprocs v1.5.3 // indirect
go.uber.org/goleak v1.3.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
go.viam.com/api v0.1.350 // indirect
go.viam.com/test v1.1.1-0.20220913152726-5da9916c08a2 // indirect
go4.org/unsafe/assume-no-moving-gc v0.0.0-20230525183740-e7c30c78aeb2 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e // indirect
golang.org/x/exp/typeparams v0.0.0-20240314144324-c7f7c6466f7f // indirect
Expand All @@ -302,6 +326,7 @@ require (
golang.org/x/text v0.19.0 // indirect
golang.org/x/time v0.6.0 // indirect
golang.org/x/tools v0.24.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
gonum.org/v1/gonum v0.12.0 // indirect
gonum.org/v1/plot v0.12.0 // indirect
google.golang.org/api v0.196.0 // indirect
Expand All @@ -312,10 +337,16 @@ require (
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
gopkg.in/src-d/go-billy.v4 v4.3.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gorgonia.org/tensor v0.9.24 // indirect
gorgonia.org/vecf32 v0.9.0 // indirect
gorgonia.org/vecf64 v0.9.0 // indirect
honnef.co/go/tools v0.5.1 // indirect
mvdan.cc/gofumpt v0.7.0 // indirect
mvdan.cc/unparam v0.0.0-20240528143540-8a5130ca722f // indirect
nhooyr.io/websocket v1.8.7 // indirect
periph.io/x/conn/v3 v3.7.0 // indirect
periph.io/x/host/v3 v3.8.1-0.20230331112814-9f0d9f7d76db // indirect
)
Loading

0 comments on commit 1d8417f

Please sign in to comment.