Skip to content

Commit 264856a

Browse files
committed
fix: pwm channel range to 0-3
1 parent 086c750 commit 264856a

File tree

3 files changed

+52
-49
lines changed

3 files changed

+52
-49
lines changed

.github/workflows/docker-publish.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

.github/workflows/pipeline.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Build and Push Docker
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
build-and-push:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
14+
- name: Set up QEMU
15+
uses: docker/setup-qemu-action@v3
16+
17+
- name: Set up Docker Buildx
18+
uses: docker/setup-buildx-action@v3
19+
20+
- name: Login to Docker Hub
21+
uses: docker/login-action@v3
22+
with:
23+
username: ${{ secrets.DOCKERHUB_USERNAME }}
24+
password: ${{ secrets.DOCKERHUB_TOKEN }}
25+
# - name: Login to GitHub Container Registry
26+
# uses: docker/login-action@v3
27+
# with:
28+
# registry: ghcr.io
29+
# username: ${{ github.actor }}
30+
# password: ${{ secrets.GITHUB_TOKEN }}
31+
- name: Write release version
32+
run: |
33+
VERSION=${{ github.event.release.tag_name }}
34+
echo "VERSION=${VERSION:1}" >> $GITHUB_ENV
35+
- name: Build and push
36+
uses: docker/build-push-action@v5
37+
with:
38+
context: .
39+
file: ./Dockerfile
40+
push: true
41+
tags: |
42+
${{ secrets.DOCKERHUB_USERNAME }}/wirehub:${{ env.VERSION }}
43+
${{ secrets.DOCKERHUB_USERNAME }}/wirehub:latest
44+
# ghcr.io/${{ github.repository }}:${{ env.VERSION }}
45+
# ghcr.io/${{ github.repository }}:latest
46+
platforms: linux/arm64

app/gpio/dfrobot_pwm.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ def set_pwm_duty_cycle(channel, duty_cycle):
1010
voltage of PWM ⊕ is 3.3V.
1111
1212
Args:
13-
channel (int): The PWM channel to set (1-4).
13+
channel (int): The PWM channel to set (0-3).
1414
duty_cycle (float): The duty cycle to set for the channel (0.0 - 100.0).
1515
1616
Raises:
1717
ValueError: If the specified channel or duty cycle is out of range.
1818
"""
19-
if not 1 <= channel <= 4:
20-
raise ValueError("Channel must be an integer between 1 and 4")
19+
if not 0 <= channel <= 3:
20+
raise ValueError("Channel must be an integer between 0 and 3")
2121
if not 0.0 <= duty_cycle <= 100.0:
2222
raise ValueError("Duty cycle must be a float between 0.0 and 100.0")
2323

@@ -28,15 +28,15 @@ def get_pwm_duty_cycle(channel):
2828
Get the current PWM duty cycle for a specified channel on the DFRobot Expansion Board.
2929
3030
Args:
31-
channel (int): The PWM channel to get (1-4).
31+
channel (int): The PWM channel to get (0-3).
3232
3333
Returns:
3434
float: The current duty cycle for the specified channel.
3535
3636
Raises:
3737
ValueError: If the specified channel is out of range.
3838
"""
39-
if not 1 <= channel <= 4:
40-
raise ValueError("Channel must be an integer between 1 and 4")
39+
if not 0 <= channel <= 3:
40+
raise ValueError("Channel must be an integer between 0 and 3")
4141

4242
return board.get_pwm_duty(channel)

0 commit comments

Comments
 (0)