tmytのらくがき

個人の日記レベルです

Netduino3 のオンボードボタンを使ってみる

HelloWorldの次の次ぐらいにやるよくあるあれです。

var button = new InputPort(Pins.ONBOARD_SW1, false, Port.ResistorMode.PullUp);
var down = false;
while (true)
{
    var state = button.Read();
    if (!down && state)
    {
        down = true;
        button_OnInterrupt(0, 0, DateTime.Now);
    }
    if (down && !state)
    {
        down = false;
    }
    Thread.Sleep(16);
}

このコード、Netduino 3 Wifi (ver.4.3.2.1)で動きません。どうなるかというと、ボタンを押すとリセットされます。意味わからんです。フレームワークでリセットボタンの挙動上書きできてないバグです。

まぁそのうちなおるでしょ。って放置してたら、フォーラムに新しいファームがリリースされていました。

Updates in this release

  1. Fix: Pins.ONBOARD_BTN now disables reset feature properly

ばっちりなおっているようです。最初のコードも正しく動くようになりました。

さてこのバグ、こんなんすぐなおるやろー。とほってたらこんなスレッドが2日前に立ってました。

My understanding is that the onboard button is dual purpose - it will (a) reset the board, or ( B) if in a program with an InputPort bound to the ONBOARD_BTN, it should read button presses instead. When running the program below, when I press the onboard button, the board resets.

(私が間違ってなければボタンってリセットとプログラマブルな入力に使えるはずなのに、このプログラムを実行するとボードがリセットされてしまうんだけど…?)

 

Ack, that's a bug.

(バグだね)

バグだったようです。2週間もそのままだった割に、報告されたらすぐ直ったことから、がんがんフォーラムに投げたほうがよさそうな感じ…