Skip to content

Commit

Permalink
Merge branch 'feat/add_keyboard_v1.1' into 'master'
Browse files Browse the repository at this point in the history
feat(keyboard): add keyboard v1.1 support

See merge request ae_group/esp-iot-solution!1035
  • Loading branch information
lijunru-hub committed Jul 12, 2024
2 parents e7061be + 3f7d9ee commit d4f0c73
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 90 deletions.
4 changes: 4 additions & 0 deletions examples/keyboard/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ cmake_minimum_required(VERSION 3.16)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(keyboard)

# Make MAX brightness configurable
idf_component_get_property(keyboard_rgb_matrix lijunru-hub__keyboard_rgb_matrix COMPONENT_LIB)
target_compile_definitions(${keyboard_rgb_matrix} PUBLIC "-DRGB_MATRIX_MAXIMUM_BRIGHTNESS=100")
4 changes: 3 additions & 1 deletion examples/keyboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ The ESP-KeyBoard project is a keyboard project using the ESP32-S3, supporting N-

* Demo video [video](https://www.bilibili.com/video/BV1yi421C7qV/?share_source=copy_web&vd_source=7e24f4cefdafbd8477369f33616312a9)

* Board support package introduction documentation [BSP](./components/esp32_s3_kbd_kit/README.md)

![keyboard_hardware](https://dl.espressif.com/esp-iot-solution/static/keyboard_1.gif)

### Software Design
Expand All @@ -30,7 +32,7 @@ The ESP-KeyBoard project is a keyboard project using the ESP32-S3, supporting N-
| Connection Mode | Local Lighting | WIN11 Lighting | N-key Rollover | Report Rate |
| :------------------: | :-----------------: | :------------: | :------------: | :---------: |
| USB |||| 1k |
| BLE | √(Default disabled) | × || 125k |
| BLE | √(Default disabled) | × || 125Hz |
| 2.4G (Not Supported) || × || 1k |

本地灯效
Expand Down
4 changes: 3 additions & 1 deletion examples/keyboard/README_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ ESP-KeyBoard 项目是使用 ESP32-S3 的键盘项目,支持全键无冲,USB

* Demo 视频 [video](https://www.bilibili.com/video/BV1yi421C7qV/?share_source=copy_web&vd_source=7e24f4cefdafbd8477369f33616312a9)

* BSP 介绍文档 [BSP](./components/esp32_s3_kbd_kit/README.md)

![keyboard_hardware](https://dl.espressif.com/esp-iot-solution/static/keyboard_1.gif)

### 软件设计
Expand All @@ -30,7 +32,7 @@ ESP-KeyBoard 项目是使用 ESP32-S3 的键盘项目,支持全键无冲,USB
| 连接模式 | 本地灯效 | WIN11 灯效 | 全键无冲 | 回报率 |
| :--------------: | :-------------: | :--------: | :------: | :----: |
| USB |||| 1k |
| BLE | √(默认不开启) | × || 125k |
| BLE | √(默认不开启) | × || 125Hz |
| 2.4G(暂不支持) || × || 1k |

本地灯效
Expand Down
70 changes: 0 additions & 70 deletions examples/keyboard/components/esp32_s3_kbd_kit/Kconfig

This file was deleted.

87 changes: 75 additions & 12 deletions examples/keyboard/components/esp32_s3_kbd_kit/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,82 @@
# BSP: ESP-WROVER-KIT
# BSP: ESP32-S3-KBD-KIT

[![Component Registry](https://components.espressif.com/components/espressif/esp_wrover_kit/badge.svg)](https://components.espressif.com/components/espressif/esp_wrover_kit)
ESP32-S3-KBD-KIT is an ESP32S3-based development board produced by Espressif.
* [Hardware Reference](https://oshwhub.com/esp-college/esp-keyboard)

ESP-WROVER-KIT is an ESP32-based development board produced by Espressif.
* [Hardware Reference](https://www.espressif.com/en/products/hardware/esp-wrover-kit/overview)
![ESP-KeyBoard](https://dl.espressif.com/esp-iot-solution/static/keyboard.jpg)

![](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/_images/esp-wrover-kit-v4.1-layout-front.png)
ESP32-S3-KBD-KIT features the following integrated components:

ESP-WROVER-KIT features the following integrated components:
* ESP32-S3-WROOM-1-N4 module
* WS2812 RGB LED
* 6x15 Key Scan Circuit
* Battery Charge and Discharge Management

* ESP32-WROVER-E module
* LCD screen
* microSD card slot
* RGB LED
ESP32-S3-KBD-KIT only supports hardware version V1.1. If you need to use the V1.0 hardware version, please modify it according to the hardware GPIO.

Its another distinguishing feature is the embedded FTDI FT2232HL chip - an advanced multi-interface USB bridge. This chip enables to use JTAG for direct debugging of ESP32 through the USB interface without a separate JTAG debugger. ESP-WROVER-KIT makes development convenient, easy, and cost-effective.
## Hardware Version

Most of the ESP32 I/O pins are broken out to the board’s pin headers for easy access.
### v1.1

Make the following hardware modifications:
1. Added a 32.768K crystal oscillator to reduce power consumption when the BLE connection enters light sleep mode (reduces standby current by about 2mA).
2. Added total power control for the WS2812 LED group, allowing complete disconnection of WS2812 power supply when using battery power (reduces standby current by about 40mA).
3. Added battery voltage detection.

| Name | Status | GPIO | Descriptor |
| :-------------: | :------: | :----: | :-----------------: |
| ROW_IO_0 | Maintain | GPIO40 | Row Scan GPIO |
| ROW_IO_1 | Maintain | GPIO39 | Row Scan GPIO |
| ROW_IO_2 | Maintain | GPIO38 | Row Scan GPIO |
| ROW_IO_3 | Maintain | GPIO45 | Row Scan GPIO |
| ROW_IO_4 | Maintain | GPIO48 | Row Scan GPIO |
| ROW_IO_5 | Maintain | GPIO47 | Row Scan GPIO |
| COL_IO_0 | Maintain | GPIO21 | COL Scan GPIO |
| COL_IO_1 | Maintain | GPIO14 | COL Scan GPIO |
| COL_IO_2 | Maintain | GPIO13 | COL Scan GPIO |
| COL_IO_3 | Maintain | GPIO12 | COL Scan GPIO |
| COL_IO_4 | Maintain | GPIO11 | COL Scan GPIO |
| COL_IO_5 | Maintain | GPIO10 | COL Scan GPIO |
| COL_IO_6 | Maintain | GPIO9 | COL Scan GPIO |
| COL_IO_7 | Maintain | GPIO4 | COL Scan GPIO |
| COL_IO_8 | Maintain | GPIO5 | COL Scan GPIO |
| COL_IO_9 | Maintain | GPIO6 | COL Scan GPIO |
| COL_IO_10 | Maintain | GPIO7 | COL Scan GPIO |
| COL_IO_11 | Modify | GPIO17 | COL Scan GPIO |
| COL_IO_12 | Modify | GPIO3 | COL Scan GPIO |
| COL_IO_13 | Modify | GPIO18 | COL Scan GPIO |
| COL_IO_14 | Modify | GPIO8 | COL Scan GPIO |
| WS2812_EN | Add | GPIO1 | WS2812 Control GPIO |
| WS2812_GPIO | Modify | GPIO0 | WS2812 GPIO |
| Battery_Monitor | Add | GPIO2 | Battery ADC Monitor |

### v1.0

Features include:
1. 6*15 row-column scanning method
2. WS2812 LED strip

| Name | Status | GPIO | Descriptor |
| :---------: | :------: | :----: | :-----------: |
| ROW_IO_0 | Maintain | GPIO40 | Row Scan GPIO |
| ROW_IO_1 | Maintain | GPIO39 | Row Scan GPIO |
| ROW_IO_2 | Maintain | GPIO38 | Row Scan GPIO |
| ROW_IO_3 | Maintain | GPIO45 | Row Scan GPIO |
| ROW_IO_4 | Maintain | GPIO48 | Row Scan GPIO |
| ROW_IO_5 | Maintain | GPIO47 | Row Scan GPIO |
| COL_IO_0 | Maintain | GPIO21 | COL Scan GPIO |
| COL_IO_1 | Maintain | GPIO14 | COL Scan GPIO |
| COL_IO_2 | Maintain | GPIO13 | COL Scan GPIO |
| COL_IO_3 | Maintain | GPIO12 | COL Scan GPIO |
| COL_IO_4 | Maintain | GPIO11 | COL Scan GPIO |
| COL_IO_5 | Maintain | GPIO10 | COL Scan GPIO |
| COL_IO_6 | Maintain | GPIO9 | COL Scan GPIO |
| COL_IO_7 | Maintain | GPIO4 | COL Scan GPIO |
| COL_IO_8 | Maintain | GPIO5 | COL Scan GPIO |
| COL_IO_9 | Maintain | GPIO6 | COL Scan GPIO |
| COL_IO_10 | Maintain | GPIO7 | COL Scan GPIO |
| COL_IO_11 | Maintain | GPIO15 | COL Scan GPIO |
| COL_IO_12 | Maintain | GPIO16 | COL Scan GPIO |
| COL_IO_13 | Maintain | GPIO17 | COL Scan GPIO |
| COL_IO_14 | Maintain | GPIO18 | COL Scan GPIO |
| WS2812_GPIO | Maintain | GPIO8 | WS2812 GPIO |
17 changes: 16 additions & 1 deletion examples/keyboard/components/esp32_s3_kbd_kit/esp32_s3_kbd_kit.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ esp_err_t bsp_keyboard_init(keyboard_btn_handle_t *kbd_handle, keyboard_btn_conf
.input_gpios = (int[])KBD_INPUT_IOS,
.input_gpio_num = KBD_COL_NUM,
.active_level = KBD_ATTIVE_LEVEL,
.debounce_ticks = 2,
.debounce_ticks = 3,
.ticks_interval = KBD_TICKS_INTERVAL_US,
.enable_power_save = true,
};
Expand All @@ -49,6 +49,15 @@ esp_err_t bsp_ws2812_init(led_strip_handle_t *led_strip)
}
return ESP_OK;
}

gpio_config_t io_conf = {
.pin_bit_mask = 1ULL << KBD_WS2812_POWER_IO,
.mode = GPIO_MODE_OUTPUT_OD,
.pull_down_en = 0,
.pull_up_en = 0,
};
gpio_config(&io_conf);

/* LED strip initialization with the GPIO and pixels number*/
led_strip_config_t strip_config = {
.strip_gpio_num = LIGHTMAP_GPIO, // The GPIO that connected to the LED strip's data line
Expand All @@ -70,6 +79,12 @@ esp_err_t bsp_ws2812_init(led_strip_handle_t *led_strip)
return ESP_OK;
}

esp_err_t bsp_ws2812_enable(bool enable)
{
gpio_set_level(KBD_WS2812_POWER_IO, !enable);
return ESP_OK;
}

esp_err_t bsp_lamp_array_init(uint32_t bind)
{
if (!s_led_strip) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ esp_err_t bsp_keyboard_init(keyboard_btn_handle_t *kbd_handle, keyboard_btn_conf

esp_err_t bsp_ws2812_init(led_strip_handle_t *led_strip);

esp_err_t bsp_ws2812_enable(bool enable);

esp_err_t bsp_lamp_array_init(uint32_t bind);

esp_err_t bsp_rgb_matrix_init(void);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
extern "C" {
#endif

/*!< Keyboard active level */
#define KBD_ATTIVE_LEVEL 1
#define KBD_TICKS_INTERVAL_US 500

/*!< Keyboard matrix GPIO */
#define KBD_ROW_NUM 6
#define KBD_COL_NUM 15

Expand All @@ -33,16 +35,22 @@ extern "C" {
#define KBD_COL_IO_8 5
#define KBD_COL_IO_9 6
#define KBD_COL_IO_10 7
#define KBD_COL_IO_11 15
#define KBD_COL_IO_12 16
#define KBD_COL_IO_13 17
#define KBD_COL_IO_14 18
#define KBD_COL_IO_11 17
#define KBD_COL_IO_12 3
#define KBD_COL_IO_13 18
#define KBD_COL_IO_14 8

#define KBD_OUTPUT_IOS {KBD_ROW_IO_0, KBD_ROW_IO_1, KBD_ROW_IO_2, KBD_ROW_IO_3, KBD_ROW_IO_4, KBD_ROW_IO_5}
#define KBD_INPUT_IOS {KBD_COL_IO_0, KBD_COL_IO_1, KBD_COL_IO_2, KBD_COL_IO_3, KBD_COL_IO_4, KBD_COL_IO_5, \
KBD_COL_IO_6, KBD_COL_IO_7, KBD_COL_IO_8, KBD_COL_IO_9, KBD_COL_IO_10, KBD_COL_IO_11,\
KBD_COL_IO_12, KBD_COL_IO_13, KBD_COL_IO_14}

/*!< WS2812 power control GPIO */
#define KBD_WS2812_POWER_IO 1

/*!< Battery monitor GPIO */
#define KBD_BATTERY_MONITOR_IO 2

#ifdef __cplusplus
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
extern "C" {
#endif

#define LIGHTMAP_GPIO 8
#define LIGHTMAP_GPIO 0
#define LIGHTMAP_NUM 82
#define LIGHTMAP_WIDTH 310000 /*!< 31 cm */
#define LIGHTMAP_HEIGHT 120000 /*!< 12 cm */
Expand Down
2 changes: 2 additions & 0 deletions examples/keyboard/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ void app_main(void)
btn_progress_set_light_type(sys_param->light_type);
if (sys_param->report_type == TINYUSB_HID_REPORT) {
tinyusb_hid_init();
bsp_ws2812_enable(1);
} else if (sys_param->report_type == BLE_HID_REPORT) {
ble_hid_init();
bsp_ws2812_enable(0);
esp_pm_config_t pm_config = {
.max_freq_mhz = CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ,
.min_freq_mhz = 160,
Expand Down

0 comments on commit d4f0c73

Please sign in to comment.