KT6368A-Based Smart TikTok Page Turner Development Summary
1. Functional Overview
The KT6368A Bluetooth chip is also developed based on HID, mainly used for operations like flipping up/down on popular short videos like Douyin, switching left/right menus, pausing, etc. Turn on the phone's Bluetooth to connect, then enter the video browsing interface to operate the corresponding buttons. Includes a Bluetooth indicator light showing connection status. Also supports adkey buttons, which can be customized as needed. The product ultimately uses a CR3032 battery, so power consumption is a major concern.
2. Program Understanding Notes
(1) During system initialization, APP registration is performed based on the following information. The general execution flow is:
REGISTER_APPLICATION--->state_machine--->app_start()--->sys_key_event_enable(); This flow mainly handles device initialization settings and enabling certain functions.
REGISTER_APPLICATION--->event_handler--->app_key_event_handler()--->app_key_deal_test(); Under event_handler, there are multiple cases. The above selects the button event handling flow to illustrate the code flow, mainly showing the program's handling process when button events occur.
(2) APP State Machine
The state machine has create, start, pause, resume, stop, and destroy states, executing corresponding branches based on different states.
After APP registration, initial operation begins, entering the APP_STA_START branch to start APP operation.
static int state_machine(struct application *app, enum app_state state, struct intent *it)
{ switch (state) {
case APP_STA_CREATE:
break;
case APP_STA_START:
if (!it) {
break; }
switch (it->action) {
case ACTION_TOUCHSCREEN:
app_start();
After entering the app_start() function, corresponding initializations are performed: clock initialization, mode selection, low-power initialization, and enabling external events.
static void app_start()
{
log_info("=======================================");
log_info("-----------------------------KEYPAGE------------------------");
log_info("=======================================");
The main operation is event-driven. It sleeps when idle, and wakes up to perform corresponding actions when there are button or Bluetooth protocol stack events. Below is the button action handling:
After APP registration and operation, when a button event occurs, corresponding data is sent. As an HID device, the data is generated from the corresponding HID device descriptor. Users can customize the device's functionality by modifying the descriptor according to the official HID documentation.
The pause button's corresponding HID device sends data packets through hid_data_send_pt() for data transmission.
log_info("point: %d,%d", point_cnt, point_len);
if (point_cnt) {
for (int cnt = 0; cnt < point_cnt; cnt++) {
hid_data_send_pt(1, key_data, point_len);
key_data += point_len;
KEY_DELAY_TIME();
}
}
The descriptor shows the device has 5 input entities (Input), forming 7-byte data. Thus, the pause button's data packet consists of 7 bytes: the first 2 bytes indicate touch input detection, the next 2 bytes each represent y and x coordinates, and the last byte represents contact count. Different button events correspond to different data packets, sent via the hid_data_send_dt function. Button event functionality is achieved through event handling and data transmission.
3. Actual Development Notes - Parameter Details
The Bluetooth chip handles everything itself. There are two buttons: one for short-press power on/off, and the other IO port is for an external adkey.
(1) Chip pin 2: LED, pin 7 [USB-DM] power on/off button, pin 8 [USB-DP] external adkey. Auto power-off after 5 minutes of inactivity.
(2) Bluetooth name: KT6368A-keypage

3.1 Test Environment - KT6368A Test Demo Board

(2) Remove the ME6208A LDO from the original test board as it also consumes power.
3.2 Power Consumption Record - Relatively precise current testing equipment

3.3 Achieved Results:

评论
发表评论