Logic Machine Forum
lm ambient buzzer - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: lm ambient buzzer (/showthread.php?tid=3376)



lm ambient buzzer - gjniewenhuijse - 20.05.2021

I like to use the buzzer as posted in: Some LM Ambient questions (logicmachine.net)

But it doesn't work for me. Is there something changed?
And i also like to set the volume in a script.


RE: lm ambient buzzer - Daniel - 20.05.2021

Which LM Ambient do you have and which fw? I just tried RC1 and it works.


RE: lm ambient buzzer - gjniewenhuijse - 20.05.2021

(20.05.2021, 08:14)Daniel. Wrote: Which LM Ambient do you have and which fw? I just tried RC1 and it works.

LMWECO2-ZR
With latest rc1 firmware: LM Ambient V2: https://dl.openrb.com/lm-21-imx6/lmwallv2-20210510.img

And is it correct that this device doesn't display a pm25 value?


RE: lm ambient buzzer - admin - 20.05.2021

Buzzer control for new HW (with volume control):
Code:
function beep(note, time, volume)
  volume = volume or 10
  volume = 1 + (11 - volume) ^ 2

  local period = math.floor(10 ^ 9 / note)
  local cycle = math.floor(period / volume)
  local path = '/sys/class/pwm/pwmchip3/pwm0/'

  io.writefile(path .. 'period', period)
  io.writefile(path .. 'duty_cycle', cycle)

  io.writefile(path .. 'enable', 1)
  os.sleep(time or 0.1)
  io.writefile(path .. 'enable', 0)
end



RE: lm ambient buzzer - gjniewenhuijse - 20.05.2021

(20.05.2021, 08:51)admin Wrote: Buzzer control for new HW (with volume control):
Code:
function beep(note, time, volume)
  volume = volume or 10
  volume = 1 + (11 - volume) ^ 2

  local period = math.floor(10 ^ 9 / note)
  local cycle = math.floor(period / volume)
  local path = '/sys/class/pwm/pwmchip3/pwm0/'

  io.writefile(path .. 'period', period)
  io.writefile(path .. 'duty_cycle', cycle)

  io.writefile(path .. 'enable', 1)
  os.sleep(time or 0.1)
  io.writefile(path .. 'enable', 0)
end

Thanks it works, and how lower the volume value, how harder the buzzer?

And is it correct that this device doesn't display a pm25 value?


RE: lm ambient buzzer - admin - 20.05.2021

I suspect that the original firmware on your device was wrong and that your device does not have a PM2.5 sensor.