Core2: Vibration motor intensity setting support..
Skink last edited by
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)"!
that is not very surprising. To set the
vibration intensityan underlying function
SetLDOVoltage()is used which currently is broken in M5Core2 library as pointed out by @veryalien :
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:
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()
Skink last edited by
Thank you, I have tested your program and it works perfectly. Thank you very much for that !
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.