左(A)ボタンを押すことでタイマーが1分増加します。上には+1minと表示されています。 右(C)ボタンを押すとタイマーをスタートさせることができます。上にはStartと表示されています。 タイマー起動中とタイムアップになっている状態のときは左側のボタンがリセットボタンに変更されます。 タイムアップとなるとバイブレーションが鳴り、お知らせします。
初期化 (setup() 関数): M5Stackを初期化し、液晶ディスプレイの背景色を設定し、初期画面を表示します。
メインループ (loop() 関数): ユーザーのボタン入力に応じてタイマーの設定や開始を行い、タイマーが動作中の間は時間をカウントダウンします。タイマーがゼロになると、アラームが作動し、表示が更新されます。
表示更新 (updateDisplay() 関数): タイマーの状態に応じて液晶ディスプレイに表示内容を更新します。
タイマーの開始 (startTimer() 関数): タイマーを動作中に設定し、表示を更新します。
タイマーの停止 (stopTimer() 関数): タイマーを停止し、表示をリセットします。
タイムアップ処理 (timeUp() 関数): タイマーがゼロになると呼ばれ、アラームを作動させ、表示を更新します。
アラームの停止 (stopAlarm() 関数): アラームを停止し、表示を元に戻します。
Pressing the left (A) button increases the timer by 1 minute. The display shows "+1min" at the top. Pressing the right (C) button starts the timer. The display shows "Start" at the top. When the timer is running or when the timer reaches zero, the left button changes to a reset button. When time is up, a vibration will sound to notify you. Initialization (setup() function): Initializes the M5Stack, sets the background color of the LCD display, and shows the initial screen.
Main Loop (loop() function): Handles user button inputs to set or start the timer, counts down the time while the timer is running, and updates the display when the timer reaches zero. When time is up, an alarm is activated and the display is updated.
Display Update (updateDisplay() function): Updates the LCD display based on the current timer status.
Start Timer (startTimer() function): Sets the timer to be active, and updates the display.
Stop Timer (stopTimer() function): Stops the timer and resets the display.
Time Up Processing (timeUp() function): Called when the timer reaches zero, activates the alarm, and updates the display.
Stop Alarm (stopAlarm() function): Stops the alarm and restores the display to its previous state.