Skip to content

Commit 06368da

Browse files
use new hardware api
1 parent fdbd995 commit 06368da

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

developer-guide/03-Background jobs/02-writing-background-jobs.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ We see that the `__init__` requires the two parameters for PWM: `hz` and an `ini
211211
We next initialize the PWM code (this is still in the `__init__`) that controls the PWM outputs on the HAT, and add more imports:
212212

213213
```python
214-
from pioreactor.hardware import PWM_TO_PIN
214+
from pioreactor.hardware import get_pwm_to_pin_map
215215
from pioreactor.utils.pwm import PWM
216216
from pioreactor.config import config
217217

@@ -220,7 +220,7 @@ from pioreactor.config import config
220220

221221
def __init__(...)
222222
...
223-
223+
PWM_TO_PIN = get_pwm_to_pin_map()
224224
pwm_pin = PWM_TO_PIN[config.get("PWM_reverse", "motor_driver")]
225225
self.pwm = PWM(pwm_pin, self.hz)
226226
self.pwm.lock()
@@ -319,7 +319,7 @@ import json
319319

320320
from pioreactor.config import config
321321
from pioreactor.background_jobs.base import BackgroundJob
322-
from pioreactor.hardware import PWM_TO_PIN
322+
from pioreactor.hardware import get_pwm_to_pin_map
323323
from pioreactor.utils.pwm import PWM
324324
from pioreactor.utils import clamp
325325

@@ -338,6 +338,7 @@ class MotorDriver(BackgroundJob):
338338
self._initial_duty_cycle = initial_duty_cycle
339339
self.duty_cycle = initial_duty_cycle
340340

341+
PWM_TO_PIN = get_pwm_to_pin_map()
341342
self.pwm_pin = PWM_TO_PIN[config.get("PWM_reverse", "motor_driver")]
342343

343344
self.pwm = PWM(self.pwm_pin, self.hz)

0 commit comments

Comments
 (0)