「App:Library:LVGL:docs:Porting:Input device interface」の版間の差分
390行目: | 390行目: | ||
== Other features == | == Other features == | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
:[[App:Library:LVGL:docs:Porting#Input device interface|戻る : Previous]] | :[[App:Library:LVGL:docs:Porting#Input device interface|戻る : Previous]] | ||
== Further reading == | == Further reading == | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
:[[App:Library:LVGL:docs:Porting#Input device interface|戻る : Previous]] | :[[App:Library:LVGL:docs:Porting#Input device interface|戻る : Previous]] | ||
2022年8月30日 (火) 23:55時点における版
https://docs.lvgl.io/8.2/porting/indev.html
Input device interface
Types of input devices
英文 | 自動翻訳 |
---|---|
To set up an input device an lv_indev_drv_t indev_drv;
lv_indev_drv_init(&indev_drv); /*Basic initialization*/
indev_drv.type =... /*See below.*/
indev_drv.read_cb =... /*See below.*/
/*Register the driver in LVGL and save the created input device object*/
lv_indev_t * my_indev = lv_indev_drv_register(&indev_drv);
Visit Input devices to learn more about input devices in general. |
入力デバイスを設定するには、変数lv_indev_drv_t を初期化する必要があります。
lv_indev_drv_t indev_drv ;
lv_indev_drv_init (&indev_drv ); /*基本的な初期化*/
indev_drv 。type = ... /*以下を参照してください。*/
indev_drv 。read_cb = ... /*以下を参照してください。* // * LVGL
にドライバーを登録し、作成した入力デバイスオブジェクトを保存します* /
lv_indev_t * my_indev = lv_indev_drv_register (&indev_drv );
|
Touchpad, mouse or any pointer
英文 | 自動翻訳 |
---|---|
Input devices that can click points on the screen belong to this category. indev_drv.type = LV_INDEV_TYPE_POINTER;
indev_drv.read_cb = my_input_read;
...
void my_input_read(lv_indev_drv_t * drv, lv_indev_data_t*data)
{
if(touchpad_pressed) {
data->point.x = touchpad_x;
data->point.y = touchpad_y;
data->state = LV_INDEV_STATE_PRESSED;
} else {
data->state = LV_INDEV_STATE_RELEASED;
}
}
Important : |
画面上のポイントをクリックできる入力デバイスは、このカテゴリに属します。
indev_drv 。タイプ = LV_INDEV_TYPE_POINTER ;
indev_drv 。read_cb = my_input_read ;
...
void my_input_read (lv_indev_drv_t * drv 、 lv_indev_data_t * data )
{
if (touchpad_pressed ) {
data- > point 。x = touchpad_x ;
データ->ポイント。y = touchpad_y ;
データ->状態 = LV_INDEV_STATE_PRESSED ;
} else {
データ->状態 = LV_INDEV_STATE_RELEASED ;
}
}
Important : |
Keypad or keyboard
英文 | 自動翻訳 |
---|---|
Full keyboards with all the letters or simple keypads with a few navigation buttons belong here. To use a keyboard/keypad:
indev_drv.type = LV_INDEV_TYPE_KEYPAD;
indev_drv.read_cb = keyboard_read;
...
bool keyboard_read(lv_indev_drv_t * drv, lv_indev_data_t*data){
data->key = last_key(); /*Get the last pressed or released key*/
if(key_pressed()) data->state = LV_INDEV_STATE_PRESSED;
else data->state = LV_INDEV_STATE_RELEASED;
return false; /*No buffering now so no more data read*/
}
|
キーボード/キーパッドを使用するには:
indev_drv 。タイプ = LV_INDEV_TYPE_KEYPAD ;
indev_drv 。read_cb = Keyboard_read ;
...
bool Keyboard_read (lv_indev_drv_t * drv 、 lv_indev_data_t * data ){
data- > key = last_key (); /*最後に押されたキーまたはリリースされたキーを取得します*/
if (key_pressed ()) data- > state = LV_INDEV_STATE_PRESSED ;
else データ->状態 = LV_INDEV_STATE_RELEASED ;
return false; /*現在はバッファリングがないため、データの読み取りはありません*/
}
|
Encoder
英文 | 自動翻訳 |
---|---|
With an encoder you can do the following:
indev_drv.type = LV_INDEV_TYPE_ENCODER;
indev_drv.read_cb = encoder_read;
...
bool encoder_read(lv_indev_drv_t * drv, lv_indev_data_t*data){
data->enc_diff = enc_get_new_moves();
if(enc_pressed()) data->state = LV_INDEV_STATE_PRESSED;
else data->state = LV_INDEV_STATE_RELEASED;
return false; /*No buffering now so no more data read*/
}
|
つまり、エンコーダ入力デバイスは次のように機能します。
エンコーダー(キーパッドと同様) を使用するには、オブジェクトをグループに追加する必要があります。 indev_drv.type = LV_INDEV_TYPE_ENCODER;
indev_drv.read_cb = encoder_read;
...
bool encoder_read(lv_indev_drv_t * drv, lv_indev_data_t*data){
data->enc_diff = enc_get_new_moves();
if(enc_pressed()) data->state = LV_INDEV_STATE_PRESSED;
else data->state = LV_INDEV_STATE_RELEASED;
return false; /*現在はバッファリングがないため、データの読み取りはありません*/
}
|
Using buttons with Encoder logic
英文 | 自動翻訳 |
---|---|
In addition to standard encoder behavior, you can also utilize its logic to navigate(focus) and edit widgets using buttons. This is especially handy if you have only few buttons available, or you want to use other buttons in addition to encoder wheel.
indev_drv.type = LV_INDEV_TYPE_ENCODER;
indev_drv.read_cb = encoder_with_keys_read;
...
bool encoder_with_keys_read(lv_indev_drv_t * drv, lv_indev_data_t*data){
data->key = last_key(); /*Get the last pressed or released key*/
/* use LV_KEY_ENTER for encoder press */
if(key_pressed()) data->state = LV_INDEV_STATE_PRESSED;
else {
data->state = LV_INDEV_STATE_RELEASED;
/* Optionally you can also use enc_diff, if you have encoder*/
data->enc_diff = enc_get_new_moves();
}
return false; /*No buffering now so no more data read*/
}
|
3つのボタンを使用できるようにする必要があります。
キーを押したままにすると、で指定された期間でエンコーダの前進をシミュレートします indev_drv.type = LV_INDEV_TYPE_ENCODER;
indev_drv.read_cb = encoder_with_keys_read;
...
bool encoder_with_keys_read(lv_indev_drv_t * drv, lv_indev_data_t*data){
data->key = last_key(); /*最後に押されたキーまたは離されたキーを取得します*/
/*エンコーダーを押すためにLV_KEY_ENTERを使用します*/
if(key_pressed()) data->state = LV_INDEV_STATE_PRESSED;
else {
data->state = LV_INDEV_STATE_RELEASED;
/* Optionally you can also use enc_diff, if you have encoder*/
data->enc_diff = enc_get_new_moves();
}
return false; /*エンコーダーがある場合は、オプションでenc_diffを使用することもできます*/
}
|
Button
英文 | 自動翻訳 |
---|---|
Buttons mean external "hardware" buttons next to the screen which are assigned to specific coordinates of the screen. If a button is pressed it will simulate the pressing on the assigned coordinate. (Similarly to a touchpad)
Important: The points_array can't go out of scope. Either declare it as a global variable or as a static variable inside a function. indev_drv.type = LV_INDEV_TYPE_BUTTON;
indev_drv.read_cb = button_read;
...
bool button_read(lv_indev_drv_t * drv, lv_indev_data_t*data){
static uint32_t last_btn = 0; /*Store the last pressed button*/
int btn_pr = my_btn_read(); /*Get the ID (0,1,2...) of the pressed button*/
if(btn_pr >= 0) { /*Is there a button press? (E.g. -1 indicated no button was pressed)*/
last_btn = btn_pr; /*Save the ID of the pressed button*/
data->state = LV_INDEV_STATE_PRESSED; /*Set the pressed state*/
} else {
data->state = LV_INDEV_STATE_RELEASED; /*Set the released state*/
}
data->btn = last_btn; /*Save the last button*/
return false; /*No buffering now so no more data read*/
}
|
ボタンを座標に割り当てるには、を使用します
重要:points_arrayはスコープ外に出ることはできません。グローバル変数または関数内の静的変数として宣言します。 indev_drv.type = LV_INDEV_TYPE_BUTTON;
indev_drv.read_cb = button_read;
...
bool button_read(lv_indev_drv_t * drv, lv_indev_data_t*data){
static uint32_t last_btn = 0; /*最後に押されたボタンを保存します*/
int btn_pr = my_btn_read(); /*押されたボタンのID(0,1,2 ...)を取得します*/
if(btn_pr >= 0) { /*ボタンが押されたか?(例-1はボタンが押されていないことを示します)*/
last_btn = btn_pr; /*押されたボタンのIDを保存します*/
data->state = LV_INDEV_STATE_PRESSED; /*押された状態を設定します*/
} else {
data->state = LV_INDEV_STATE_RELEASED; /*リリース状態を設定します*/
}
data->btn = last_btn; /*最後のボタンを保存します*/
return false; /*バッファリングがなくなったので、これ以上データを読み込まない*/
}
|
Other features
Further reading
API
英文 | 自動翻訳 |
---|---|
@description Input Device HAL interface layer header file Typedefs typedef struct _lv_indev_drv_t lv_indev_drv_t
typedef struct _lv_indev_proc_t _lv_indev_proc_t
typedef struct _lv_indev_t lv_indev_t
|
Typedef typedef struct _ lv_indev_drv_t lv_indev_drv_t
typedef struct _ lv_indev_proc_t _lv_indev_proc_t
typedef struct _ lv_indev_t lv_indev_t
|
Enums
英文 | 自動翻訳 |
---|---|
enum lv_indev_type_t
enum lv_indev_state_t
|
列挙型lv_indev_state_t
|
Functions
英文 | 自動翻訳 |
---|---|
void lv_indev_drv_init(struct _lv_indev_drv_t *driver)
lv_indev_t *lv_indev_drv_register(struct _lv_indev_drv_t *driver)
void lv_indev_drv_update(lv_indev_t *indev, struct _lv_indev_drv_t *new_drv)
void lv_indev_delete(lv_indev_t *indev)
lv_indev_t *lv_indev_get_next(lv_indev_t *indev)
void _lv_indev_read(lv_indev_t *indev, lv_indev_data_t *data)
struct lv_indev_data_t
struct _lv_indev_drv_t
struct _lv_indev_proc_t
struct _lv_indev_t
|
lv_indev_t * lv_indev_drv_register(struct _ lv_indev_drv_t * driver)
void lv_indev_drv_update(lv_indev_t * indev、struct _lv_indev_drv_t * new_drv)
void lv_indev_delete(lv_indev_t * indev)
lv_indev_t * lv_indev_get_next( lv_indev_t * indev)
void _lv_indev_read(lv_indev_t * indev、lv_indev_data_t * data)
struct lv_indev_data_t
struct _lv_indev_drv_t
struct _lv_indev_proc_t
struct _lv_indev_t
|