Initial commit for nanopsx
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
#include "esp_lcd_panel_io.h"
|
||||
#include "esp_lcd_panel_vendor.h"
|
||||
#include "esp_lcd_panel_ops.h"
|
||||
|
||||
#include "esp_lcd_touch_axs5106.h"
|
||||
|
||||
#include "esp_log.h"
|
||||
#include "bsp_touch.h"
|
||||
|
||||
void bsp_touch_init(esp_lcd_touch_handle_t *touch_handle, i2c_master_bus_handle_t bus_handle, uint16_t xmax, uint16_t ymax, uint16_t rotation)
|
||||
{
|
||||
static i2c_master_dev_handle_t dev_handle;
|
||||
i2c_device_config_t dev_cfg = {
|
||||
.dev_addr_length = I2C_ADDR_BIT_LEN_7,
|
||||
.device_address = ESP_LCD_TOUCH_IO_I2C_AXS5106_ADDRESS,
|
||||
.scl_speed_hz = 400000,
|
||||
};
|
||||
ESP_ERROR_CHECK(i2c_master_bus_add_device(bus_handle, &dev_cfg, &dev_handle));
|
||||
|
||||
esp_lcd_touch_config_t tp_cfg = {};
|
||||
tp_cfg.x_max = xmax < ymax ? xmax : ymax;
|
||||
tp_cfg.y_max = xmax < ymax ? ymax : xmax;;
|
||||
tp_cfg.rst_gpio_num = EXAMPLE_PIN_TP_RST;
|
||||
tp_cfg.int_gpio_num = EXAMPLE_PIN_TP_INT;
|
||||
|
||||
if (90 == rotation)
|
||||
{
|
||||
tp_cfg.flags.swap_xy = 1;
|
||||
tp_cfg.flags.mirror_x = 0;
|
||||
tp_cfg.flags.mirror_y = 0;
|
||||
}
|
||||
else if (180 == rotation)
|
||||
{
|
||||
tp_cfg.flags.swap_xy = 0;
|
||||
tp_cfg.flags.mirror_x = 0;
|
||||
tp_cfg.flags.mirror_y = 1;
|
||||
}
|
||||
else if (270 == rotation)
|
||||
{
|
||||
tp_cfg.flags.swap_xy = 1;
|
||||
tp_cfg.flags.mirror_x = 1;
|
||||
tp_cfg.flags.mirror_y = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
tp_cfg.flags.swap_xy = 0;
|
||||
tp_cfg.flags.mirror_x = 1;
|
||||
tp_cfg.flags.mirror_y = 0;
|
||||
}
|
||||
|
||||
ESP_ERROR_CHECK(esp_lcd_touch_new_i2c_axs5106(dev_handle, &tp_cfg, touch_handle));
|
||||
}
|
||||
Reference in New Issue
Block a user