Core2: Vibration motor intensity setting support..
-
@m5stack
With "Set vibration intensity" alone the vibration motor does not work at all, no matter if 1-100%.
If I switch it on with "Set vibration enable (true)" the motor will vibrate but with the same intensity, I try to change the intensity with "Set vibration intensity" but nothing happens.
I can only switch it off with "Set vibration enable (false)"! -
Hello @Skink
that is not very surprising. To set the
vibration intensity
an underlying functionSetLDOVoltage()
is used which currently is broken in M5Core2 library as pointed out by @veryalien :
https://github.com/m5stack/M5Core2/issues/4.I've proposed a fix in a pull-request which got closed as it should be fixed in the near future anyways as @Hades2001 pointed out:
https://github.com/m5stack/M5Core2/pull/5Cheers
Felix -
Hi @Skink
here is a Python solution. Button A decreases, Btn C increases intensity. Btn B turns vibration motor on and off:
from m5stack import * from m5stack_ui import * from uiflow import * import i2c_bus screen = M5Screen() screen.clean_screen() screen.set_screen_bg_color(0xFFFFFF) label0 = M5Label('Text', x=52, y=67, color=0x000, font=FONT_MONT_24, parent=None) from numbers import Number motorOnOff = None motorValue = None temp = None def setMotorValue(): global motorOnOff, motorValue, temp label0.set_text(str(motorValue)) temp = (i2c0.read_u8(0x28)) & 0xF0 temp = temp | motorValue i2c0.write_mem_data(0x28, temp, i2c_bus.UINT8LE) def buttonA_wasPressed(): global motorOnOff, motorValue, temp if motorValue > 0: motorValue -= 1 setMotorValue() pass btnA.wasPressed(buttonA_wasPressed) def buttonC_wasPressed(): global motorOnOff, motorValue, temp if motorValue < 15: motorValue += 1 setMotorValue() pass btnC.wasPressed(buttonC_wasPressed) def buttonB_wasPressed(): global motorOnOff, motorValue, temp motorOnOff = not motorOnOff power.setVibrationEnable(motorOnOff) pass btnB.wasPressed(buttonB_wasPressed) i2c0 = i2c_bus.easyI2C(i2c_bus.PORTA, 0x34, freq=400000) motorOnOff = False motorValue = 7 setMotorValue()
Cheers
Felix -
Hello Felix,
Thank you, I have tested your program and it works perfectly. Thank you very much for that !
THX skink
-
Hi skink
you're very welcome.
The required fix mentioned before has now been included to the M5Core2 library so hopefully in one of the next UIFlow updates it will be picked up.
Happy Stacking!
Felix