让LVGL中文输入法(Let lvgl support Chinese input method)

中文
English

LVGL中文输入法插件

我将它称为插件,因为它是在 lv_keyboard 的基础上编写的一个自定义部件(我定义创建接口为: lv_100ask_keyboard_create(lv_obj_t *parent) ); ),它和 lv_keyboard 没有什么区别,只是新增了支持中文输入法(或者其他输入法)的功能。

这个插件框架在后续非常容易维护和拓展,现在只是最简单的版本,我正在编写更多的功能以及在不同平台上进行测试。相信在一个月之内能和大家分享源码,希望大家能喜欢我的项目!

演示视频:

仓库地址

  • Gitee: TODO
  • Github: TODO

LVGL Chinese input method plug-in

I call it a plug-in because it’s in Lv_ A custom part written on the basis of keyboard (I define the creation interface as lv_100ask_keyboard_create (lv_obj_t * parent)), It and LV_ Keyboard is no different, but it has added the function of supporting Chinese input method (or other input methods).
This plug-in framework is very easy to maintain and expand in the future. Now it is only the simplest version. I am writing more functions and testing on different platforms. I believe I can share the source code with you within one month. I hope you can like my project!

Demo video

Source code

  • Gitee: TODO
  • Github: TODO

why you don’t use Phonetic layout?

That’s a good idea. I’ll try it.

Make you new keyboard layouts like LV_KEYBOARD_MODE_TEXT_LOWER but some like LV_KEYBOARD_MODE_CH_LOWER

#define LV_KB_BTN(width) LV_BTNMATRIX_CTRL_POPOVER | width

static const char* default_kb_map_lc[] = { "1#", "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", LV_SYMBOL_BACKSPACE, "\n",
                                                    "ABC", "a", "s", "d", "f", "g", "h", "j", "k", "l", LV_SYMBOL_NEW_LINE, "\n",
                                                    "_", "-", "z", "x", "c", "v", "b", "n", "m", ".", ",", ":", "\n",
                                                    LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, LV_SYMBOL_OK, ""
};

static const lv_btnmatrix_ctrl_t default_kb_ctrl_lc_map[] = {
    LV_KEYBOARD_CTRL_BTN_FLAGS | 5, LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_BTNMATRIX_CTRL_CHECKED | 7,
    LV_KEYBOARD_CTRL_BTN_FLAGS | 6, LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_BTNMATRIX_CTRL_CHECKED | 7,
    LV_BTNMATRIX_CTRL_CHECKED | LV_KB_BTN(1), LV_BTNMATRIX_CTRL_CHECKED | LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_BTNMATRIX_CTRL_CHECKED | LV_KB_BTN(1), LV_BTNMATRIX_CTRL_CHECKED | LV_KB_BTN(1), LV_BTNMATRIX_CTRL_CHECKED | LV_KB_BTN(1),
    LV_BTNMATRIX_CTRL_CHECKED | 2, 6, LV_BTNMATRIX_CTRL_CHECKED | 2, LV_KEYBOARD_CTRL_BTN_FLAGS | 2
};
lv_keyboard_set_map(keyboard, LV_KEYBOARD_MODE_TEXT_LOWER, default_kb_map_lc, default_kb_ctrl_lc_map);

aaaaa
这个现在能在ESP32上使用吗?中文字体可以更换吗?

FYI, Chinese input is now also supported in NXP GUI Guider from version 1.3.0.

Thank you for your message. What you said should support Chinese display? I didn’t find a function to support Chinese input

主要是看字库和词库的大小,只要开发板资源足够都能显示,字体可以任意切换,我这几天正在将他上传到github仓库

代码已经上传到git仓库,欢迎一起学习交流!
github: https://github.com/100askTeam/lv_chinese_ime
gitee: https://gitee.com/weidongshan/lv_chinese_ime

The code has been uploaded to github. Welcome to discuss it together :grinning:

github: https://github.com/100askTeam/lv_chinese_ime

github: https://github.com/100askTeam/lv_chinese_ime

gitee: lv_chinese_ime: lv_chinese_ime:支持中文输入法的LVGL键盘部件增强插件。lv_chinese_ime: LVGL keyboard widget enhancement plugin that supports Chinese input method.

可以,但是我发现这个输入法现在切换还有点问题,只能中文切换到大写字母,切回小写字母直接就是拼音模式了。

默认的字体 lv_font_source_han_sans_normal_16.c 不能显示空格, 需要把

static const lv_font_fmt_txt_cmap_t cmaps[] =

.range_start = 33, .range_length = 94, .glyph_id_start = 2,

改为:

.range_start = 32, .range_length = 95, .glyph_id_start = 1,