フォーラム


ゲスト  

ようこそ ゲスト さん。このフォーラムに投稿するには 登録が必要です。

ページ: [1]
トピック: Wio Terminal のキーボードテストプログラム
DEKO
管理者
投稿数: 2690
Wio Terminal のキーボードテストプログラム
on: 2020/12/24 21:14 Thu

こんなんでどうでしょう?

[kbtest.ino]

#include <TFT_eSPI.h>
#include <SPI.h>
#include <KeyboardController.h>

// TFT 制御用
TFT_eSPI tft;

// USB 制御用
USBHost usb;

// キーボード制御用
KeyboardController keyboard(usb);

uint32_t lastUSBstate = 0;

void setup() {
// TFT の初期化
tft.init();
tft.begin();
tft.setRotation(3);

// キーボードの初期化
if (usb.Init())
tft.println(F("USB host did not start."));
delay( 20 );
digitalWrite(PIN_USB_HOST_ENABLE, LOW);
digitalWrite(OUTPUT_CTR_5V, HIGH);
}

void keyReleased() {
char c = keyboard.getKey();
tft.println(c);
}

void loop() {
usb.Task();
uint32_t currentUSBstate = usb.getUsbTaskState();
if (lastUSBstate != currentUSBstate) {
tft.print("USB state changed: 0x");
tft.print(lastUSBstate, HEX);
tft.print(" -> 0x");
tft.println(currentUSBstate, HEX);
switch (currentUSBstate) {
case USB_ATTACHED_SUBSTATE_SETTLE: tft.println("Device Attached"); break;
case USB_DETACHED_SUBSTATE_WAIT_FOR_DEVICE: tft.println("Detached, waiting for Device"); break;
case USB_ATTACHED_SUBSTATE_RESET_DEVICE: tft.println("Resetting Device"); break;
case USB_ATTACHED_SUBSTATE_WAIT_RESET_COMPLETE: tft.println("Reset complete"); break;
case USB_STATE_CONFIGURING: tft.println("USB Configuring"); break;
case USB_STATE_RUNNING: tft.println("USB Running"); break;
}
lastUSBstate = currentUSBstate;
}
}
ページ: [1]
WP Forum Server by ForumPress | LucidCrew
バージョン: 1.7.5 ; ページロード: 0.02 sec.