Перейти к содержанию

Навигация

Buzzer/en: различия между версиями

Новая страница: «beeper.beep(0.5, 2) </syntaxhighlight> All sysfs interface settings are supported (recalculation must be done manually; see section on recalculation).»
(Новая страница: «Working example from python: <syntaxhighlight lang="python"> from wb_common import beeper»)
(Новая страница: «beeper.beep(0.5, 2) </syntaxhighlight> All sysfs interface settings are supported (recalculation must be done manually; see section on recalculation).»)
Строка 68: Строка 68:
===Pwm port number for sysfs===
===Pwm port number for sysfs===


<div class="mw-translate-fuzzy">
The gpio pin is configurable like the PWM output in the dts of the linux kernel. For more details, see [[https://github.com/wirenboard/linux/blob/ef2d87e222b365848fe7262c022ca887b6449432/arch/arm/boot/dts/imx6ul-wirenboard61.dts#L495 on our github]].
<pre>
echo 250000 > /sys/class/pwm/pwmchip0/pwm2/period # set the period to 250 000 NS, ie 250mks, which corresponds to a frequency of 4kHz
</pre>
</div>


<div class="mw-translate-fuzzy">
*For WB6.X.X controllers, port number = 0, (for all controllers up to WB6.X.X, port number = 2)
Setting the duty_cycle (the duration of the high state) in nanoseconds. Maximum volume is reached at duty_cycle = period / 2
*The port number can be found by running <syntaxhighlight lang="bash">echo $WB_PWM_BUZZER</syntaxhighlight>
</div>
In all examples below, we will assume that the pwm port number = 0.


<div class="mw-translate-fuzzy">
===Working from sysfs===
<pre>
echo 125000 > /sys/class/pwm/pwmchip0/pwm2/duty_cycle #set duty_cycle to 125 000 NS, i.e. in half of the period
</pre>
</div>


<div class="mw-translate-fuzzy">
<div class="mw-translate-fuzzy">
translator, wb_editors
4218

правок