#include "gpio.h"
#include "ui.h"
#include "keypad.h"

void app_init() {
    // 程序开始时执行一次
    ui_screen_main();
    kp_query();
    printf("\n====start====\n");
}

#include "gpio.h" //test
void app_main_loop() {
    // 反复被调用执行
    // HAL_GPIO_TogglePin(LED_STATUS_GPIO_Port,LED_STATUS_Pin);
    // HAL_Delay(1000);
    uint8_t event = kp_query();
    uint8_t event_type = kp_Type(event);
    uint8_t event_value = kp_Value(event);
    // printf("Raw Event Value: %d\n", event);
    if (event_type != kp_NOP) {
        printf("event: %d, key: %d\n", event_type, event_value);
    }

    GPIO_PinState state = HAL_GPIO_ReadPin(ENCODER_KEY_GPIO_Port, ENCODER_KEY_Pin);
    HAL_GPIO_WritePin(LED_STATUS_GPIO_Port, LED_STATUS_Pin, state);
}
