「App:Library:LVGL:docs:Porting:Input device interface」の版間の差分
43行目: | 43行目: | ||
Visit [https://docs.lvgl.io/8.2/overview/indev.html '''Input devices to'''] learn more about input devices in general. | Visit [https://docs.lvgl.io/8.2/overview/indev.html '''Input devices to'''] learn more about input devices in general. | ||
− | |入力デバイスを登録するには、<code>lv_indev_drv_t</code>変数を初期化する必要があります。 | + | |入力デバイスを登録するには、<code style="color: #bb0000;">lv_indev_drv_t</code>変数を初期化する必要があります。 |
'''入力デバイスを登録する前に、必ず少なくとも1つのディスプレイを登録してください。''' | '''入力デバイスを登録する前に、必ず少なくとも1つのディスプレイを登録してください。''' | ||
56行目: | 56行目: | ||
lv_indev_t * my_indev = lv_indev_drv_register (&indev_drv ); | lv_indev_t * my_indev = lv_indev_drv_register (&indev_drv ); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | <code>type</code>メンバーは次 のようになります。 | + | <code style="color: #bb0000;">type</code>メンバーは次 のようになります。 |
− | * <code>LV_INDEV_TYPE_POINTER</code>タッチパッドまたはマウス | + | * <code style="color: #bb0000;">LV_INDEV_TYPE_POINTER</code>タッチパッドまたはマウス |
− | * <code>LV_INDEV_TYPE_KEYPAD</code>キーボードまたはキーパッド | + | * <code style="color: #bb0000;">LV_INDEV_TYPE_KEYPAD</code>キーボードまたはキーパッド |
− | * <code>LV_INDEV_TYPE_ENCODER</code>左/右回転およびプッシュオプション付きエンコーダ | + | * <code style="color: #bb0000;">LV_INDEV_TYPE_ENCODER</code>左/右回転およびプッシュオプション付きエンコーダ |
− | * <code>LV_INDEV_TYPE_BUTTON</code>画面を仮想的に押す外部ボタン | + | * <code style="color: #bb0000;">LV_INDEV_TYPE_BUTTON</code>画面を仮想的に押す外部ボタン |
− | <code>read_cb</code>入力デバイスの現在の状態を報告するために定期的に呼び出される関数ポインタです。 | + | <code style="color: #bb0000;">read_cb</code>入力デバイスの現在の状態を報告するために定期的に呼び出される関数ポインタです。 |
'''一般的な入力デバイスの詳細については、入力デバイスにアクセスして'''ください。 | '''一般的な入力デバイスの詳細については、入力デバイスにアクセスして'''ください。 | ||
113行目: | 113行目: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | マウスカーソルを設定するには、を使用します<code>lv_indev_set_cursor(my_indev, &img_cursor)</code>。(<code>my_indev</code>はの戻り値です<code>lv_indev_drv_register</code>) | + | マウスカーソルを設定するには、を使用します<code style="color: #bb0000;">lv_indev_set_cursor(my_indev, &img_cursor)</code>。(<code style="color: #bb0000;">my_indev</code>はの戻り値です<code style="color: #bb0000;">lv_indev_drv_register</code>) |
|} | |} | ||
:[[App:Library:LVGL:docs:Porting|戻る : Previous]] | :[[App:Library:LVGL:docs:Porting|戻る : Previous]] | ||
151行目: | 151行目: | ||
キーボード/キーパッドを使用するには: | キーボード/キーパッドを使用するには: | ||
− | * <font class="goog-text-highlight">入力デバイスを登録するには、</font><code>read_cb</code>タイプで関数を登録します<code>LV_INDEV_TYPE_KEYPAD</code>。 | + | * <font class="goog-text-highlight">入力デバイスを登録するには、</font><code style="color: #bb0000;">read_cb</code>タイプで関数を登録します<code style="color: #bb0000;">LV_INDEV_TYPE_KEYPAD</code>。 |
− | * オブジェクトグループを作成する必要があります:<code>lv_group_t * g = lv_group_create()</code>そしてオブジェクトを追加する必要があります<code>lv_group_add_obj(g, obj)</code> | + | * オブジェクトグループを作成する必要があります:<code style="color: #bb0000;">lv_group_t * g = lv_group_create()</code>そしてオブジェクトを追加する必要があります<code style="color: #bb0000;">lv_group_add_obj(g, obj)</code> |
− | * 作成されたグループは、入力デバイスに割り当てる必要があります:(<code>lv_indev_set_group(my_indev, g)</code>はの<code>my_indev</code>戻り値です<code>lv_indev_drv_register</code>) | + | * 作成されたグループは、入力デバイスに割り当てる必要があります:(<code style="color: #bb0000;">lv_indev_set_group(my_indev, g)</code>はの<code style="color: #bb0000;">my_indev</code>戻り値です<code style="color: #bb0000;">lv_indev_drv_register</code>) |
− | * <font class="goog-text-highlight">入力デバイスを登録するには、</font><code>LV_KEY_...</code>グループ内のオブジェクト間を移動するために使用します。<code>lv_core/lv_group.h</code>使用可能なキーについては、を参照してください。 | + | * <font class="goog-text-highlight">入力デバイスを登録するには、</font><code style="color: #bb0000;">LV_KEY_...</code>グループ内のオブジェクト間を移動するために使用します。<code style="color: #bb0000;">lv_core/lv_group.h</code>使用可能なキーについては、を参照してください。 |
<syntaxhighlight lang="C++" style="border: 1px dashed gray;"> | <syntaxhighlight lang="C++" style="border: 1px dashed gray;"> | ||
indev_drv 。タイプ = LV_INDEV_TYPE_KEYPAD ; | indev_drv 。タイプ = LV_INDEV_TYPE_KEYPAD ; | ||
285行目: | 285行目: | ||
3つのボタンを使用できるようにする必要があります。 | 3つのボタンを使用できるようにする必要があります。 | ||
− | * <code>LV_KEY_ENTER</code>エンコーダボタンの押下または押下をシミュレートします | + | * <code style="color: #bb0000;">LV_KEY_ENTER</code>エンコーダボタンの押下または押下をシミュレートします |
− | * <code>LV_KEY_LEFT</code>エンコーダを左に回すシミュレーションを行います | + | * <code style="color: #bb0000;">LV_KEY_LEFT</code>エンコーダを左に回すシミュレーションを行います |
− | * <code>LV_KEY_RIGHT</code>エンコーダを右に回すシミュレーションを行います | + | * <code style="color: #bb0000;">LV_KEY_RIGHT</code>エンコーダを右に回すシミュレーションを行います |
* 他のキーはフォーカスされたウィジェットに渡されます | * 他のキーはフォーカスされたウィジェットに渡されます | ||
− | キーを押したままにすると、で指定された期間でエンコーダの前進をシミュレートします<code>indev_drv.long_press_rep_time</code>。 | + | キーを押したままにすると、で指定された期間でエンコーダの前進をシミュレートします<code style="color: #bb0000;">indev_drv.long_press_rep_time</code>。 |
<syntaxhighlight lang="C++" style="border: 1px dashed gray;"> | <syntaxhighlight lang="C++" style="border: 1px dashed gray;"> | ||
indev_drv 。タイプ = LV_INDEV_TYPE_ENCODER ; | indev_drv 。タイプ = LV_INDEV_TYPE_ENCODER ; | ||
350行目: | 350行目: | ||
''ボタン''とは、画面の特定の座標に割り当てられた、画面の横にある外部の「ハードウェア」ボタンを意味します。ボタンが押されると、割り当てられた座標の押下をシミュレートします。(タッチパッドと同様) | ''ボタン''とは、画面の特定の座標に割り当てられた、画面の横にある外部の「ハードウェア」ボタンを意味します。ボタンが押されると、割り当てられた座標の押下をシミュレートします。(タッチパッドと同様) | ||
− | ボタンを座標に割り当てるには、を使用します<code>lv_indev_set_button_points(my_indev, points_array)</code>。 | + | ボタンを座標に割り当てるには、を使用します<code style="color: #bb0000;">lv_indev_set_button_points(my_indev, points_array)</code>。 |
− | <code>points_array</code>次のようになります<code>const lv_point_t points_array[] = { {12,30},{60,90}, ...}</code> | + | <code style="color: #bb0000;">points_array</code>次のようになります<code style="color: #bb0000;">const lv_point_t points_array[] = { {12,30},{60,90}, ...}</code> |
'''重要''':points_arrayはスコープ外に出ることはできません。グローバル変数または関数内の静的変数として宣言します。 | '''重要''':points_arrayはスコープ外に出ることはできません。グローバル変数または関数内の静的変数として宣言します。 | ||
395行目: | 395行目: | ||
− | 次のパラメータのデフォルト値は、次の場所で変更できます<code>lv_indev_drv_t</code>。 | + | 次のパラメータのデフォルト値は、次の場所で変更できます<code style="color: #bb0000;">lv_indev_drv_t</code>。 |
− | * <code>scroll_limit</code>オブジェクトを実際にスクロールする前にスライドするピクセル数。 | + | * <code style="color: #bb0000;">scroll_limit</code>オブジェクトを実際にスクロールする前にスライドするピクセル数。 |
− | * <code>scroll_throw</code>[%]でスロースロー(勢い)をスクロールします。値が大きいほど、速度が速くなります。 | + | * <code style="color: #bb0000;">scroll_throw</code>[%]でスロースロー(勢い)をスクロールします。値が大きいほど、速度が速くなります。 |
− | * <code>long_press_time</code>送信する時間を押す<code>LV_EVENT_LONG_PRESSED</code>(ミリ秒単位) | + | * <code style="color: #bb0000;">long_press_time</code>送信する時間を押す<code style="color: #bb0000;">LV_EVENT_LONG_PRESSED</code>(ミリ秒単位) |
− | * <code>long_press_rep_time</code>送信間隔<code>LV_EVENT_LONG_PRESSED_REPEAT</code>(ミリ秒単位) | + | * <code style="color: #bb0000;">long_press_rep_time</code>送信間隔<code style="color: #bb0000;">LV_EVENT_LONG_PRESSED_REPEAT</code>(ミリ秒単位) |
− | * <code>read_timer</code><font class="goog-text-highlight">入力デバイスを登録するには、</font><code>lv_timer</code>入力デバイスを読み取るへのポインタ。そのパラメータは<code>lv_timer_...()</code>関数によって変更できます。<code>LV_INDEV_DEF_READ_PERIOD</code>in<code>lv_conf.h</code>は、デフォルトの読み取り期間を設定します。 | + | * <code style="color: #bb0000;">read_timer</code><font class="goog-text-highlight">入力デバイスを登録するには、</font><code style="color: #bb0000;">lv_timer</code>入力デバイスを読み取るへのポインタ。そのパラメータは<code style="color: #bb0000;">lv_timer_...()</code>関数によって変更できます。<code style="color: #bb0000;">LV_INDEV_DEF_READ_PERIOD</code>in<code style="color: #bb0000;">lv_conf.h</code>は、デフォルトの読み取り期間を設定します。 |
|} | |} | ||
:[[App:Library:LVGL:docs:Porting|戻る : Previous]] | :[[App:Library:LVGL:docs:Porting|戻る : Previous]] | ||
413行目: | 413行目: | ||
| | | | ||
Besides <code style="color: #bb0000;">read_cb</code> a <code style="color: #bb0000;">feedback_cb</code> callback can be also specified in <code style="color: #bb0000;">lv_indev_drv_t</code>. <code style="color: #bb0000;">feedback_cb</code> is called when any type of event is sent by the input devices (independently of its type). This allows generating feedback for the user, e.g. to play a sound on <code style="color: #bb0000;">LV_EVENT_CLICKED</code>. | Besides <code style="color: #bb0000;">read_cb</code> a <code style="color: #bb0000;">feedback_cb</code> callback can be also specified in <code style="color: #bb0000;">lv_indev_drv_t</code>. <code style="color: #bb0000;">feedback_cb</code> is called when any type of event is sent by the input devices (independently of its type). This allows generating feedback for the user, e.g. to play a sound on <code style="color: #bb0000;">LV_EVENT_CLICKED</code>. | ||
− | |コールバックに加え<code>read_cb</code>て、で指定することもできます。任意のタイプのイベントが(そのタイプに関係なく)入力デバイスによって送信されたときに呼び出されます。これにより、ユーザーにフィードバックを生成できます。たとえば、でサウンドを再生できます。 <code>feedback_cblv_indev_drv_tfeedback_cbLV_EVENT_CLICKED</code> | + | |コールバックに加え<code style="color: #bb0000;">read_cb</code>て、で指定することもできます。任意のタイプのイベントが(そのタイプに関係なく)入力デバイスによって送信されたときに呼び出されます。これにより、ユーザーにフィードバックを生成できます。たとえば、でサウンドを再生できます。 <code style="color: #bb0000;">feedback_cblv_indev_drv_tfeedback_cbLV_EVENT_CLICKED</code> |
|} | |} | ||
:[[App:Library:LVGL:docs:Porting|戻る : Previous]] | :[[App:Library:LVGL:docs:Porting|戻る : Previous]] | ||
425行目: | 425行目: | ||
| | | | ||
Every input device is associated with a display. By default, a new input device is added to the last display created or explicitly selected (using <code style="color: #bb0000;">lv_disp_set_default()</code>). The associated display is stored and can be changed in <code style="color: #bb0000;">disp</code> field of the driver. | Every input device is associated with a display. By default, a new input device is added to the last display created or explicitly selected (using <code style="color: #bb0000;">lv_disp_set_default()</code>). The associated display is stored and can be changed in <code style="color: #bb0000;">disp</code> field of the driver. | ||
− | |すべての入力デバイスはディスプレイに関連付けられています。デフォルトでは、(を使用して<code>lv_disp_set_default()</code>)作成または明示的に選択された最後のディスプレイに新しい入力デバイスが追加されます。<code>disp</code>関連する表示が保存され、ドライバーのフィールドで 変更できます。 | + | |すべての入力デバイスはディスプレイに関連付けられています。デフォルトでは、(を使用して<code style="color: #bb0000;">lv_disp_set_default()</code>)作成または明示的に選択された最後のディスプレイに新しい入力デバイスが追加されます。<code style="color: #bb0000;">disp</code>関連する表示が保存され、ドライバーのフィールドで 変更できます。 |
|} | |} | ||
:[[App:Library:LVGL:docs:Porting|戻る : Previous]] | :[[App:Library:LVGL:docs:Porting|戻る : Previous]] | ||
440行目: | 440行目: | ||
To solve this you can write an event driven driver for your input device that buffers measured data. In <code style="color: #bb0000;">read_cb</code> you can report the buffered data instead of directly reading the input device. Setting the <code style="color: #bb0000;">data->continue_reading</code> flag will tell LVGL there is more data to read and it should call <code style="color: #bb0000;">read_cb</code> again. | To solve this you can write an event driven driver for your input device that buffers measured data. In <code style="color: #bb0000;">read_cb</code> you can report the buffered data instead of directly reading the input device. Setting the <code style="color: #bb0000;">data->continue_reading</code> flag will tell LVGL there is more data to read and it should call <code style="color: #bb0000;">read_cb</code> again. | ||
− | |デフォルトでは、LVGLは<code>read_cb</code>定期的に呼び出します。この断続的なポーリングのために、一部のユーザージェスチャが見落とされる可能性があります。 | + | |デフォルトでは、LVGLは<code style="color: #bb0000;">read_cb</code>定期的に呼び出します。この断続的なポーリングのために、一部のユーザージェスチャが見落とされる可能性があります。 |
− | これを解決するために、測定データをバッファリングする入力デバイス用のイベント駆動型ドライバーを作成できます。では<code>read_cb</code>、入力デバイスを直接読み取る代わりに、バッファリングされたデータをレポートできます。フラグを設定する<code>data->continue_reading</code>と、LVGLに読み取るデータがさらにあることが通知され、<code>read_cb</code>再度呼び出す必要があります。 | + | これを解決するために、測定データをバッファリングする入力デバイス用のイベント駆動型ドライバーを作成できます。では<code style="color: #bb0000;">read_cb</code>、入力デバイスを直接読み取る代わりに、バッファリングされたデータをレポートできます。フラグを設定する<code style="color: #bb0000;">data->continue_reading</code>と、LVGLに読み取るデータがさらにあることが通知され、<code style="color: #bb0000;">read_cb</code>再度呼び出す必要があります。 |
|} | |} | ||
:[[App:Library:LVGL:docs:Porting|戻る : Previous]] | :[[App:Library:LVGL:docs:Porting|戻る : Previous]] | ||
740行目: | 740行目: | ||
: 実行時にドライバーを更新します。 | : 実行時にドライバーを更新します。 | ||
: '''パラメーター''' | : '''パラメーター''' | ||
− | ::* '''indev--'''入力デバイスへのポインタ。(の戻り値<code>lv_indev_drv_register</code>) | + | ::* '''indev--'''入力デバイスへのポインタ。(の戻り値<code style="color: #bb0000;">lv_indev_drv_register</code>) |
::* '''new_drv--'''新しいドライバへのポインタ | ::* '''new_drv--'''新しいドライバへのポインタ | ||
794行目: | 794行目: | ||
: void(* Feedback_cb)(struct _ '''lv_indev_drv_t''' *、uint8_t) | : void(* Feedback_cb)(struct _ '''lv_indev_drv_t''' *、uint8_t) | ||
:: 入力デバイスでアクションが発生したときに呼び出されます。 | :: 入力デバイスでアクションが発生したときに呼び出されます。 | ||
− | :: 2番目のパラメータはからのイベントです<code>lv_event_t</code> | + | :: 2番目のパラメータはからのイベントです<code style="color: #bb0000;">lv_event_t</code> |
: void * user_data | : void * user_data | ||
:: | :: | ||
837行目: | 837行目: | ||
:: read_cbから読み取られた最後のポイント。 | :: read_cbから読み取られた最後のポイント。 | ||
: lv_point_t vect | : lv_point_t vect | ||
− | :: <font class="goog-text-highlight">入力デバイスを登録するには、</font><code>act_point</code>との違い<code>last_point</code>。 | + | :: <font class="goog-text-highlight">入力デバイスを登録するには、</font><code style="color: #bb0000;">act_point</code>との違い<code style="color: #bb0000;">last_point</code>。 |
: lv_point_t scroll_sum | : lv_point_t scroll_sum | ||
:: | :: |
2022年6月29日 (水) 14:16時点における版
https://docs.lvgl.io/8.2/porting/indev.html
英文 | 自動翻訳 |
---|---|
Input device interface
Types of input devices
英文 | 自動翻訳 |
---|---|
To register an input device an Be sure to register at least one display before you register any input devices. lv_disp_drv_register(&disp_drv);
static 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);
The
Visit Input devices to learn more about input devices in general. |
入力デバイスを登録するには、lv_indev_drv_t 変数を初期化する必要があります。
入力デバイスを登録する前に、必ず少なくとも1つのディスプレイを登録してください。 lv_disp_drv_register (&disp_drv );
static 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;
}
}
To set a mouse cursor use |
画面上のポイントをクリックできる入力デバイスは、このカテゴリに属します。
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 ;
}
}
マウスカーソルを設定するには、を使用します |
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;
...
void 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;
}
|
キーボード/キーパッドを使用するには:
indev_drv 。タイプ = LV_INDEV_TYPE_KEYPAD ;
indev_drv 。read_cb = Keyboard_read ;
...
void 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 ;
}
|
Encoder
英文 | 自動翻訳 |
---|---|
With an encoder you can do the following:
indev_drv.type = LV_INDEV_TYPE_ENCODER;
indev_drv.read_cb = encoder_read;
...
void 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;
}
|
つまり、エンコーダ入力デバイスは次のように機能します。
エンコーダー(キーパッドと同様) を使用するには、オブジェクトをグループに追加する必要があります。 indev_drv 。タイプ = LV_INDEV_TYPE_ENCODER ;
indev_drv 。read_cb = エンコーダー読み取り;
...
void エンコーダー読み取り(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 データ->状態 = LV_INDEV_STATE_RELEASED ;
}
|
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;
...
void 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();
}
}
|
3つのボタンを使用できるようにする必要があります。
キーを押したままにすると、で指定された期間でエンコーダの前進をシミュレートします indev_drv 。タイプ = LV_INDEV_TYPE_ENCODER ;
indev_drv 。read_cb = エンコーダーwith_keys_read ;
...
void エンコーダ_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 {
データ->状態 = LV_INDEV_STATE_RELEASED ;
/ *エンコーダーがある場合は、オプションでenc_diffを使用することもできます* /
data- >enc_diff = enc_get_new_moves ();
}
}
|
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;
...
void 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*/
}
|
ボタンを座標に割り当てるには、を使用します
重要:points_arrayはスコープ外に出ることはできません。グローバル変数または関数内の静的変数として宣言します。 indev_drv 。タイプ = LV_INDEV_TYPE_BUTTON ;
indev_drv 。read_cb = button_read ;
...
void 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を保存します*/
データ->状態 = LV_INDEV_STATE_PRESSED ; /*押された状態を設定します*/
} else {
データ->状態 = LV_INDEV_STATE_RELEASED ; /*リリース状態を設定します*/
}
データ-> btn = last_btn ; /*最後のボタンを保存します*/
}
|
Other features
Parameters
英文 | 自動翻訳 |
---|---|
The default value of the following parameters can be changed in
|
|
Feedback
英文 | 自動翻訳 |
---|---|
Besides |
コールバックに加えread_cb て、で指定することもできます。任意のタイプのイベントが(そのタイプに関係なく)入力デバイスによって送信されたときに呼び出されます。これにより、ユーザーにフィードバックを生成できます。たとえば、でサウンドを再生できます。 feedback_cblv_indev_drv_tfeedback_cbLV_EVENT_CLICKED
|
Associating with a display
英文 | 自動翻訳 |
---|---|
Every input device is associated with a display. By default, a new input device is added to the last display created or explicitly selected (using |
すべての入力デバイスはディスプレイに関連付けられています。デフォルトでは、(を使用してlv_disp_set_default() )作成または明示的に選択された最後のディスプレイに新しい入力デバイスが追加されます。disp 関連する表示が保存され、ドライバーのフィールドで 変更できます。
|
Buffered reading
英文 | 自動翻訳 |
---|---|
By default, LVGL calls
|
デフォルトでは、LVGLはread_cb 定期的に呼び出します。この断続的なポーリングのために、一部のユーザージェスチャが見落とされる可能性があります。
これを解決するために、測定データをバッファリングする入力デバイス用のイベント駆動型ドライバーを作成できます。では |
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
|