Help us understand the problem. What is going on with this article?

M5StickCを毎回電源ボタン長押しせずにリセットできるようにする

はじめに

M5StickCでM5StackのM5.Power.reset()と同等の機能が欲しかったけど公式のAPIになかったので調査
(リセットの度に電源ボタン長押しするのは時間がかかるし指が疲れますよね)

開発環境
- IDE: VSCode
- OS: macOS Catalina

調査

M5.Power.reset()が何をやっているのかという話
以下公式ソース
https://github.com/m5stack/M5Stack/blob/master/src/utility/Power.cpp

reset()を調べてみると内容は非常にシンプルでesp32のメソッドを呼び出しているだけだった

void POWER::reset() {
  esp_restart();
}

実行

そうとわかればあとはM5StickCでも同じことができるはず

void loop() {
  if(M5.BtnB.wasPressed()){
    esp_restart();
  }
  M5.update();
}

横の小さいボタンでリセット可能になりました

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした