The sound emitter is connected to the PWM output in the Wiren Board Smart Home controller and is controlled via the sysfs kernel interface. The PWM port number is 2.
PWM is a rectangular pulse, the core interface allows you to adjust the pulse rate and fill factor. Coeffecient filling effect on the sound volume.
Exporting port to sysfs:
echo 2 > /sys/class/pwm/pwmchip0/export
After that, the /sys/class/pwm/pwmchip0/pwm2 folder appears
Sets the period in nanoseconds. The conversion from frequency(from kilohertz per period in nanoseconds is produced by the formula: T(ns) = 1 000 000 / f(kHz)
echo 250000 > /sys/class/pwm/pwmchip0/pwm2/period # set the period to 250 000 NS, ie 250mks, which corresponds to a frequency of 4kHz
Setting the duty_cycle (the duration of the high state) in nanoseconds. Maximum volume is reached at duty_cycle = period / 2
echo 125000 > /sys/class/pwm/pwmchip0/pwm2/duty_cycle #set duty_cycle to 125 000 NS, i.e. in half of the period
Enable PWM output:
echo 1 > /sys/class/pwm/pwmchip0/pwm2/enable
echo 0 > /sys/class/pwm/pwmchip0/pwm2/enable