バイブレーション機能
久しぶりの更新になりました。
今回はバイブレーション機能を触ってみました。
バイブレーション関数
第一引数はAXPのLDO番号、第二引数は有効/無効(true/false)
を設定します。
M5.Axp.SetLDOEnable( uint8_t number, bool state );
サンプルコード
#include <M5Core2.h> void setup() { // 初期化 M5.begin(); // 文字サイズを変更 M5.Lcd.setTextSize(2); // Aボタン M5.Lcd.setCursor(20,75); M5.Lcd.printf("Button A : Vivrator ON"); // Bボタン M5.Lcd.setCursor(20,125); M5.Lcd.printf("Button C : Vivrator OFF"); return; } void loop() { TouchPoint_t atTouchPoint; // タッチ中 if( M5.Touch.ispressed() ) { // タッチしたX座標、Y座標を取得する atTouchPoint = M5.Touch.getPressPoint(); } // Aボタン if( ((0 <= atTouchPoint.x) && ((129) >= atTouchPoint.x)) && ((240 <= atTouchPoint.y) && ((280) >= atTouchPoint.y)) ) { M5.Axp.SetLDOEnable(3, true); } // Bボタン if( ((130 <= atTouchPoint.x) && ((200) >= atTouchPoint.x)) && ((240 <= atTouchPoint.y) && ((280) >= atTouchPoint.y)) ) { ; } // Cボタン if( ((201 <= atTouchPoint.x) && ((320) >= atTouchPoint.x)) && ((240 <= atTouchPoint.y) && ((280) >= atTouchPoint.y)) ) { M5.Axp.SetLDOEnable(3, false); } return; }
動画見て頂くとバイブレーションの振動で動いているのがわかりますか?
音も小さいですがバイブ音がなっています。