Update gpio.md

pull/432/head^2
Maxim Devaev 3 years ago committed by GitHub
parent e0367871e7
commit 1b15f3f1a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -335,57 +335,57 @@ Here the small example with servo control:
<details>
<summary>:exclamation:Click to view:exclamation:</summary>
Servo module is built on top of PWM module and allows user to define angles instead of duty_cyles to control a PWM enabled servo motor like SG90. When the button is pressed the servo motor moves to an angle defined by `angle_push` and when button is released it moves back to `angle_release`. In the example configuration for a [cheap 5V SG90 Servo](https://www.ebay.co.uk/itm/184555802744), the motor moves to an angle of 45 degrees when button is pressed and moves back to 20 degress when released.
The `servo` module is built on top of the `pwm` module and allows user to define angles instead of `duty_cyles` to control a PWM enabled servo motor like SG90. When the button is pressed the servo motor moves to an angle defined by `angle_push` and when button is released it moves back to `angle_release`. In the example configuration for a [cheap 5V SG90 Servo](https://www.ebay.co.uk/itm/184555802744), the motor moves to an angle of 45 degrees when button is pressed and moves back to 20 degress when released.
To use Servo motors in PiKVM you need to follow steps 1-3 for [PWM Module](#pwm) and then use the following configuration.
Add to /etc/kvmd/override.yaml
```yaml
kvmd:
gpio:
drivers:
servo1:
type: servo
chip: 0 # PWM Chip Number
period: 20000000 # Servo Motor SG90 Period in nano-seconds
duty_cycle_min: 350000 # Servo Motor SG90 duty_cycle for -90 degrees
duty_cycle_max: 2350000 # Servo Motor SG90 duty_cycle for +90 degrees
angle_max: 90 # Servo Motor SG90 angle at duty_cycle_max
angle_min: -90 # Servo Motor SG90 angle at duty_cycle_min
angle_push: 45 # Servo Motor SG90 angle to push button
angle_release: 20 # Servo Motor SG90 angle to release button
scheme:
short_press:
driver: servo1
pin: 0 # Pin number is the PWM channel number on the PWM Chip
mode: output
switch: false
pulse:
delay: 0.5
max_delay: 2
long_press:
driver: servo1
pin: 0 # Pin number is the PWM channel number on the PWM Chip
mode: output
switch: false
pulse:
delay: 2
max_delay: 2
extra_long_press:
driver: servo1
pin: 0 # Pin number is the PWM channel number on the PWM Chip
mode: output
switch: false
pulse:
delay: 10
max_delay: 20
view:
header:
title: Controls
table:
- ["#Servo - Short Press", "short_press|Press"]
- ["#Servo - Long Press", "long_press|Press"]
- ["#Servo - Extra Long Press", "extra_long_press|Press"]
kvmd:
gpio:
drivers:
servo1:
type: servo
chip: 0 # PWM Chip Number
period: 20000000 # Servo Motor SG90 Period in nano-seconds
duty_cycle_min: 350000 # Servo Motor SG90 duty_cycle for -90 degrees
duty_cycle_max: 2350000 # Servo Motor SG90 duty_cycle for +90 degrees
angle_max: 90 # Servo Motor SG90 angle at duty_cycle_max
angle_min: -90 # Servo Motor SG90 angle at duty_cycle_min
angle_push: 45 # Servo Motor SG90 angle to push button
angle_release: 20 # Servo Motor SG90 angle to release button
scheme:
short_press:
driver: servo1
pin: 0 # Pin number is the PWM channel number on the PWM Chip
mode: output
switch: false
pulse:
delay: 0.5
max_delay: 2
long_press:
driver: servo1
pin: 0 # Pin number is the PWM channel number on the PWM Chip
mode: output
switch: false
pulse:
delay: 2
max_delay: 2
extra_long_press:
driver: servo1
pin: 0 # Pin number is the PWM channel number on the PWM Chip
mode: output
switch: false
pulse:
delay: 10
max_delay: 20
view:
header:
title: Controls
table:
- ["#Servo - Short Press", "short_press|Press"]
- ["#Servo - Long Press", "long_press|Press"]
- ["#Servo - Extra Long Press", "extra_long_press|Press"]
```
</details>

Loading…
Cancel
Save