mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-13 10:08:08 +00:00
feat(core): add LHS200KB display panel
[no changelog]
This commit is contained in:
parent
5575fce461
commit
138fadbf7b
@ -17,6 +17,7 @@
|
|||||||
#define DISPLAY_RESY 240
|
#define DISPLAY_RESY 240
|
||||||
#define DISPLAY_LEGACY_HEADER "displays/st7789v.h"
|
#define DISPLAY_LEGACY_HEADER "displays/st7789v.h"
|
||||||
#define DISPLAY_COLOR_MODE DMA2D_OUTPUT_RGB565
|
#define DISPLAY_COLOR_MODE DMA2D_OUTPUT_RGB565
|
||||||
|
#define DISPLAY_PANEL_LX154A2482 1
|
||||||
|
|
||||||
#define DISPLAY_IDENTIFY 1
|
#define DISPLAY_IDENTIFY 1
|
||||||
#define DISPLAY_TE_PORT GPIOD
|
#define DISPLAY_TE_PORT GPIOD
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#define DISPLAY_RESY 240
|
#define DISPLAY_RESY 240
|
||||||
#define DISPLAY_LEGACY_HEADER "displays/st7789v.h"
|
#define DISPLAY_LEGACY_HEADER "displays/st7789v.h"
|
||||||
#define DISPLAY_COLOR_MODE DMA2D_OUTPUT_RGB565
|
#define DISPLAY_COLOR_MODE DMA2D_OUTPUT_RGB565
|
||||||
|
#define DISPLAY_PANEL_LX154A2482 1
|
||||||
|
|
||||||
#define DISPLAY_IDENTIFY 1
|
#define DISPLAY_IDENTIFY 1
|
||||||
#define DISPLAY_TE_PORT GPIOD
|
#define DISPLAY_TE_PORT GPIOD
|
||||||
|
@ -34,6 +34,8 @@
|
|||||||
|
|
||||||
#ifdef TOUCH_PANEL_LX154A2422CPT23
|
#ifdef TOUCH_PANEL_LX154A2422CPT23
|
||||||
#include "panels/lx154a2422cpt23.h"
|
#include "panels/lx154a2422cpt23.h"
|
||||||
|
#elif defined TOUCH_PANEL_LHS200KB_IF21
|
||||||
|
#include "panels/lhs200kb-if21.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// #define TOUCH_TRACE_REGS
|
// #define TOUCH_TRACE_REGS
|
||||||
@ -54,7 +56,7 @@ typedef struct {
|
|||||||
// Time (in ticks) when the touch registers were read last time
|
// Time (in ticks) when the touch registers were read last time
|
||||||
uint32_t read_ticks;
|
uint32_t read_ticks;
|
||||||
// Set if the touch controller is currently touched
|
// Set if the touch controller is currently touched
|
||||||
// (respectively, the we detected a touch event)
|
// (respectively, that we detected a touch event)
|
||||||
bool pressed;
|
bool pressed;
|
||||||
// Previously reported x-coordinate
|
// Previously reported x-coordinate
|
||||||
uint16_t last_x;
|
uint16_t last_x;
|
||||||
@ -213,7 +215,7 @@ static bool ft6x36_test_and_clear_interrupt(void) {
|
|||||||
return event != 0;
|
return event != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configures the touch controller to the funtional state.
|
// Configures the touch controller to the functional state.
|
||||||
static secbool ft6x36_configure(i2c_bus_t* i2c_bus) {
|
static secbool ft6x36_configure(i2c_bus_t* i2c_bus) {
|
||||||
const static uint8_t config[] = {
|
const static uint8_t config[] = {
|
||||||
// Set touch controller to the interrupt trigger mode.
|
// Set touch controller to the interrupt trigger mode.
|
||||||
@ -242,6 +244,8 @@ static void ft6x36_panel_correction(uint16_t x, uint16_t y, uint16_t* x_new,
|
|||||||
uint16_t* y_new) {
|
uint16_t* y_new) {
|
||||||
#ifdef TOUCH_PANEL_LX154A2422CPT23
|
#ifdef TOUCH_PANEL_LX154A2422CPT23
|
||||||
lx154a2422cpt23_touch_correction(x, y, x_new, y_new);
|
lx154a2422cpt23_touch_correction(x, y, x_new, y_new);
|
||||||
|
#elif defined TOUCH_PANEL_LHS200KB_IF21
|
||||||
|
lhs200kb_if21_touch_correction(x, y, x_new, y_new);
|
||||||
#else
|
#else
|
||||||
*x_new = x;
|
*x_new = x;
|
||||||
*y_new = y;
|
*y_new = y;
|
||||||
@ -527,7 +531,7 @@ uint32_t touch_get_event(void) {
|
|||||||
// We have missed the PRESS_DOWN event.
|
// We have missed the PRESS_DOWN event.
|
||||||
// Report the start event only if the coordinates
|
// Report the start event only if the coordinates
|
||||||
// have changed and driver is not starving.
|
// have changed and driver is not starving.
|
||||||
// This suggest that the previous touch was very short,
|
// This suggests that the previous touch was very short,
|
||||||
// or/and the driver is not called very frequently.
|
// or/and the driver is not called very frequently.
|
||||||
event = TOUCH_START | xy;
|
event = TOUCH_START | xy;
|
||||||
} else {
|
} else {
|
||||||
|
31
core/embed/trezorhal/stm32f4/touch/panels/lhs200kb-if21.c
Normal file
31
core/embed/trezorhal/stm32f4/touch/panels/lhs200kb-if21.c
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Trezor project, https://trezor.io/
|
||||||
|
*
|
||||||
|
* Copyright (c) SatoshiLabs
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include TREZOR_BOARD
|
||||||
|
|
||||||
|
#include "lx154a2422cpt23.h"
|
||||||
|
|
||||||
|
#include "touch.h"
|
||||||
|
|
||||||
|
void lhs200kb_if21_touch_correction(uint16_t x, uint16_t y, uint16_t *x_new,
|
||||||
|
uint16_t *y_new) {
|
||||||
|
*x_new = y;
|
||||||
|
*y_new = DISPLAY_RESY - x;
|
||||||
|
}
|
32
core/embed/trezorhal/stm32f4/touch/panels/lhs200kb-if21.h
Normal file
32
core/embed/trezorhal/stm32f4/touch/panels/lhs200kb-if21.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the Trezor project, https://trezor.io/
|
||||||
|
*
|
||||||
|
* Copyright (c) SatoshiLabs
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TREZORHAL_TOUCH_LX154A2422CPT23_H
|
||||||
|
#define TREZORHAL_TOUCH_LX154A2422CPT23_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
// Performs touch coordinates correction needed for a specific panel
|
||||||
|
// Input parameteres x, y represent original touch coordinates.
|
||||||
|
// Output parameters x_new, y_new represent corrected touch coordinates.
|
||||||
|
//
|
||||||
|
void lhs200kb_if21_touch_correction(uint16_t x, uint16_t y, uint16_t *x_new,
|
||||||
|
uint16_t *y_new);
|
||||||
|
|
||||||
|
#endif
|
@ -31,7 +31,18 @@
|
|||||||
#include "panels/lx154a2422.h"
|
#include "panels/lx154a2422.h"
|
||||||
#include "panels/tf15411a.h"
|
#include "panels/tf15411a.h"
|
||||||
#else
|
#else
|
||||||
|
#ifdef DISPLAY_PANEL_LX154A2482
|
||||||
#include "panels/lx154a2482.h"
|
#include "panels/lx154a2482.h"
|
||||||
|
#define PANEL_INIT_SEQ lx154a2482_init_seq
|
||||||
|
#define PANEL_ROTATE lx154a2482_rotate
|
||||||
|
#elif defined(DISPLAY_PANEL_LHS200KB_IF21)
|
||||||
|
#include "panels/lhs200kb-if21.h"
|
||||||
|
#define PANEL_INIT_SEQ lhs200kb_if21_init_seq
|
||||||
|
#define PANEL_ROTATE lhs200kb_if21_rotate
|
||||||
|
#else
|
||||||
|
#error "No display panel defined"
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef KERNEL_MODE
|
#ifdef KERNEL_MODE
|
||||||
@ -214,7 +225,7 @@ void display_panel_init(void) {
|
|||||||
_154a_init_seq();
|
_154a_init_seq();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
lx154a2482_init_seq();
|
PANEL_INIT_SEQ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
display_panel_unsleep();
|
display_panel_unsleep();
|
||||||
@ -232,7 +243,7 @@ void display_panel_reinit(void) {
|
|||||||
} else if (id == DISPLAY_ID_ST7789V) {
|
} else if (id == DISPLAY_ID_ST7789V) {
|
||||||
lx154a2411_gamma();
|
lx154a2411_gamma();
|
||||||
}
|
}
|
||||||
#else
|
#elif defined TREZOR_MODEL_T3T1
|
||||||
// reduced touch-display interference in T3T1
|
// reduced touch-display interference in T3T1
|
||||||
lx154a2482_init_seq();
|
lx154a2482_init_seq();
|
||||||
#endif
|
#endif
|
||||||
@ -247,7 +258,7 @@ void display_panel_rotate(int angle) {
|
|||||||
lx154a2422_rotate(angle, &g_window_padding);
|
lx154a2422_rotate(angle, &g_window_padding);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
lx154a2482_rotate(angle, &g_window_padding);
|
PANEL_ROTATE(angle, &g_window_padding);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,149 @@
|
|||||||
|
|
||||||
|
#include "lhs200kb-if21.h"
|
||||||
|
#include "../display_io.h"
|
||||||
|
|
||||||
|
void lhs200kb_if21_gamma(void) {
|
||||||
|
ISSUE_CMD_BYTE(0xE0);
|
||||||
|
ISSUE_DATA_BYTE(0xF0);
|
||||||
|
ISSUE_DATA_BYTE(0x08);
|
||||||
|
ISSUE_DATA_BYTE(0x0F);
|
||||||
|
ISSUE_DATA_BYTE(0x0B);
|
||||||
|
ISSUE_DATA_BYTE(0x0B);
|
||||||
|
ISSUE_DATA_BYTE(0x07);
|
||||||
|
ISSUE_DATA_BYTE(0x34);
|
||||||
|
ISSUE_DATA_BYTE(0x43);
|
||||||
|
ISSUE_DATA_BYTE(0x4B);
|
||||||
|
ISSUE_DATA_BYTE(0x38);
|
||||||
|
ISSUE_DATA_BYTE(0x14);
|
||||||
|
ISSUE_DATA_BYTE(0x13);
|
||||||
|
ISSUE_DATA_BYTE(0x2C);
|
||||||
|
ISSUE_DATA_BYTE(0x31);
|
||||||
|
|
||||||
|
ISSUE_CMD_BYTE(0xE1);
|
||||||
|
ISSUE_DATA_BYTE(0xF0);
|
||||||
|
ISSUE_DATA_BYTE(0x0C);
|
||||||
|
ISSUE_DATA_BYTE(0x11);
|
||||||
|
ISSUE_DATA_BYTE(0x09);
|
||||||
|
ISSUE_DATA_BYTE(0x08);
|
||||||
|
ISSUE_DATA_BYTE(0x24);
|
||||||
|
ISSUE_DATA_BYTE(0x34);
|
||||||
|
ISSUE_DATA_BYTE(0x33);
|
||||||
|
ISSUE_DATA_BYTE(0x4A);
|
||||||
|
ISSUE_DATA_BYTE(0x3A);
|
||||||
|
ISSUE_DATA_BYTE(0x16);
|
||||||
|
ISSUE_DATA_BYTE(0x16);
|
||||||
|
ISSUE_DATA_BYTE(0x2E);
|
||||||
|
ISSUE_DATA_BYTE(0x32);
|
||||||
|
}
|
||||||
|
void lhs200kb_if21_init_seq() {
|
||||||
|
ISSUE_CMD_BYTE(0x36);
|
||||||
|
ISSUE_DATA_BYTE(0x00);
|
||||||
|
|
||||||
|
ISSUE_CMD_BYTE(0x35);
|
||||||
|
ISSUE_DATA_BYTE(0x00);
|
||||||
|
|
||||||
|
ISSUE_CMD_BYTE(0x3A);
|
||||||
|
ISSUE_DATA_BYTE(0x05);
|
||||||
|
|
||||||
|
ISSUE_CMD_BYTE(0xB2);
|
||||||
|
ISSUE_DATA_BYTE(0x0C);
|
||||||
|
ISSUE_DATA_BYTE(0x0C);
|
||||||
|
ISSUE_DATA_BYTE(0x00);
|
||||||
|
ISSUE_DATA_BYTE(0x33);
|
||||||
|
ISSUE_DATA_BYTE(0x33);
|
||||||
|
|
||||||
|
ISSUE_CMD_BYTE(0xB7);
|
||||||
|
ISSUE_DATA_BYTE(0x78);
|
||||||
|
|
||||||
|
ISSUE_CMD_BYTE(0xBB);
|
||||||
|
ISSUE_DATA_BYTE(0x2F);
|
||||||
|
|
||||||
|
ISSUE_CMD_BYTE(0xC0);
|
||||||
|
ISSUE_DATA_BYTE(0x2C);
|
||||||
|
|
||||||
|
ISSUE_CMD_BYTE(0xC2);
|
||||||
|
ISSUE_DATA_BYTE(0x01);
|
||||||
|
|
||||||
|
ISSUE_CMD_BYTE(0xC3);
|
||||||
|
ISSUE_DATA_BYTE(0x19);
|
||||||
|
|
||||||
|
ISSUE_CMD_BYTE(0xC4);
|
||||||
|
ISSUE_DATA_BYTE(0x20);
|
||||||
|
|
||||||
|
ISSUE_CMD_BYTE(0xC6);
|
||||||
|
ISSUE_DATA_BYTE(0x0F);
|
||||||
|
|
||||||
|
ISSUE_CMD_BYTE(0xD0);
|
||||||
|
ISSUE_DATA_BYTE(0xA4);
|
||||||
|
ISSUE_DATA_BYTE(0xA1);
|
||||||
|
|
||||||
|
ISSUE_CMD_BYTE(0xD6);
|
||||||
|
ISSUE_DATA_BYTE(0xA1);
|
||||||
|
|
||||||
|
lhs200kb_if21_gamma();
|
||||||
|
|
||||||
|
ISSUE_CMD_BYTE(0x21);
|
||||||
|
|
||||||
|
ISSUE_CMD_BYTE(0x29);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lhs200kb_if21_rotate(int degrees, display_padding_t* padding) {
|
||||||
|
uint16_t shift = 0;
|
||||||
|
char BX = 0, BY = 0;
|
||||||
|
|
||||||
|
#define RGB (1 << 3)
|
||||||
|
#define ML (1 << 4) // vertical refresh order
|
||||||
|
#define MH (1 << 2) // horizontal refresh order
|
||||||
|
#define MV (1 << 5)
|
||||||
|
#define MX (1 << 6)
|
||||||
|
#define MY (1 << 7)
|
||||||
|
// MADCTL: Memory Data Access Control - reference:
|
||||||
|
// section 8.12 in the ST7789V manual
|
||||||
|
uint8_t display_command_parameter = 0;
|
||||||
|
switch (degrees) {
|
||||||
|
case 0:
|
||||||
|
display_command_parameter = 0;
|
||||||
|
BY = 0;
|
||||||
|
break;
|
||||||
|
case 90:
|
||||||
|
display_command_parameter = MV | MX | MH | ML;
|
||||||
|
BX = 1;
|
||||||
|
shift = 1;
|
||||||
|
break;
|
||||||
|
case 180:
|
||||||
|
display_command_parameter = MX | MY | MH | ML;
|
||||||
|
BY = 0;
|
||||||
|
shift = 1;
|
||||||
|
break;
|
||||||
|
case 270:
|
||||||
|
display_command_parameter = MV | MY;
|
||||||
|
BX = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ISSUE_CMD_BYTE(0x36);
|
||||||
|
ISSUE_DATA_BYTE(display_command_parameter);
|
||||||
|
|
||||||
|
if (shift) {
|
||||||
|
// GATECTRL: Gate Control; NL = 320 gate lines, first scan line is
|
||||||
|
// gate 0.; gate scan direction 319 -> 0
|
||||||
|
ISSUE_CMD_BYTE(0xE4);
|
||||||
|
ISSUE_DATA_BYTE(0x27);
|
||||||
|
ISSUE_DATA_BYTE(0x00);
|
||||||
|
ISSUE_DATA_BYTE(0x10);
|
||||||
|
} else {
|
||||||
|
// GATECTRL: Gate Control; NL = 320 gate lines, first scan line is
|
||||||
|
// gate 0.; gate scan direction 319 -> 0
|
||||||
|
ISSUE_CMD_BYTE(0xE4);
|
||||||
|
ISSUE_DATA_BYTE(0x27);
|
||||||
|
ISSUE_DATA_BYTE(0x00);
|
||||||
|
ISSUE_DATA_BYTE(0x10);
|
||||||
|
}
|
||||||
|
|
||||||
|
padding->x = BX ? (320 - DISPLAY_RESY) : 0;
|
||||||
|
padding->y = BY ? (320 - DISPLAY_RESY) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// uint32_t lhs200kb_if21_transform_touch_coords(uint16_t x, uint16_t y) {
|
||||||
|
// return touch_pack_xy(y, MAX_DISPLAY_RESY - x);
|
||||||
|
// }
|
@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
#ifndef LHS200KB_IF21_H
|
||||||
|
#define LHS200KB_IF21_H
|
||||||
|
#include "../display_panel.h"
|
||||||
|
|
||||||
|
void lhs200kb_if21_init_seq(void);
|
||||||
|
void lhs200kb_if21_gamma(void);
|
||||||
|
void lhs200kb_if21_rotate(int degrees, display_padding_t* padding);
|
||||||
|
|
||||||
|
#endif // HS200KB_IF21_H
|
Loading…
Reference in New Issue
Block a user