-
-
Notifications
You must be signed in to change notification settings - Fork 655
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
5,994 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/154a.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
|
||
|
||
#include "displays/st7789v.h" | ||
|
||
void _154a_init_seq(void) { | ||
// most recent manual: https://www.newhavendisplay.com/app_notes/ILI9341.pdf | ||
// TEON: Tearing Effect Line On; V-blanking only | ||
CMD(0x35); | ||
DATA(0x00); | ||
|
||
// COLMOD: Interface Pixel format; 65K color: 16-bit/pixel (RGB 5-6-5 bits | ||
// input) | ||
CMD(0x3A); | ||
DATA(0x55); | ||
|
||
// Display Function Control: gate scan direction 319 -> 0 | ||
CMD(0xB6); | ||
DATA(0x0A); | ||
DATA(0xC2); | ||
DATA(0x27); | ||
DATA(0x00); | ||
|
||
// Interface Control: XOR BGR as ST7789V does | ||
CMD(0xF6); | ||
DATA(0x09); | ||
DATA(0x30); | ||
DATA(0x00); | ||
|
||
// the above config is the most important and definitely necessary | ||
|
||
CMD(0xCF); | ||
DATA(0x00); | ||
DATA(0xC1); | ||
DATA(0x30); | ||
|
||
CMD(0xED); | ||
DATA(0x64); | ||
DATA(0x03); | ||
DATA(0x12); | ||
DATA(0x81); | ||
|
||
CMD(0xE8); | ||
DATA(0x85); | ||
DATA(0x10); | ||
DATA(0x7A); | ||
|
||
CMD(0xF7); | ||
DATA(0x20); | ||
|
||
CMD(0xEA); | ||
DATA(0x00); | ||
DATA(0x00); | ||
|
||
// power control VRH[5:0] | ||
CMD(0xC0); | ||
DATA(0x23); | ||
|
||
// power control SAP[2:0] BT[3:0] | ||
CMD(0xC1); | ||
DATA(0x12); | ||
|
||
// vcm control 1 | ||
CMD(0xC5); | ||
DATA(0x60); | ||
DATA(0x44); | ||
|
||
// vcm control 2 | ||
CMD(0xC7); | ||
DATA(0x8A); | ||
|
||
// framerate | ||
CMD(0xB1); | ||
DATA(0x00); | ||
DATA(0x18); | ||
|
||
// 3 gamma func disable | ||
CMD(0xF2); | ||
DATA(0x00); | ||
|
||
// gamma curve 1 | ||
CMD(0xE0); | ||
DATA(0x0F); | ||
DATA(0x2F); | ||
DATA(0x2C); | ||
DATA(0x0B); | ||
DATA(0x0F); | ||
DATA(0x09); | ||
DATA(0x56); | ||
DATA(0xD9); | ||
DATA(0x4A); | ||
DATA(0x0B); | ||
DATA(0x14); | ||
DATA(0x05); | ||
DATA(0x0C); | ||
DATA(0x06); | ||
DATA(0x00); | ||
|
||
// gamma curve 2 | ||
CMD(0xE1); | ||
DATA(0x00); | ||
DATA(0x10); | ||
DATA(0x13); | ||
DATA(0x04); | ||
DATA(0x10); | ||
DATA(0x06); | ||
DATA(0x25); | ||
DATA(0x26); | ||
DATA(0x3B); | ||
DATA(0x04); | ||
DATA(0x0B); | ||
DATA(0x0A); | ||
DATA(0x33); | ||
DATA(0x39); | ||
DATA(0x0F); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef _154A_H_ | ||
#define _154A_H_ | ||
|
||
// ILI9341 IC controller | ||
|
||
void _154a_init_seq(void); | ||
|
||
#endif |
82 changes: 82 additions & 0 deletions
82
core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lx154a2411.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
|
||
#include "displays/st7789v.h" | ||
|
||
void lx154a2411_gamma(void) { | ||
// positive voltage correction | ||
CMD(0xE0); | ||
DATA(0xD0); | ||
DATA(0x03); | ||
DATA(0x08); | ||
DATA(0x0E); | ||
DATA(0x11); | ||
DATA(0x2B); | ||
DATA(0x3B); | ||
DATA(0x44); | ||
DATA(0x4C); | ||
DATA(0x2B); | ||
DATA(0x16); | ||
DATA(0x15); | ||
DATA(0x1E); | ||
DATA(0x21); | ||
|
||
// negative voltage correction | ||
CMD(0xE1); | ||
DATA(0xD0); | ||
DATA(0x03); | ||
DATA(0x08); | ||
DATA(0x0E); | ||
DATA(0x11); | ||
DATA(0x2B); | ||
DATA(0x3B); | ||
DATA(0x54); | ||
DATA(0x4C); | ||
DATA(0x2B); | ||
DATA(0x16); | ||
DATA(0x15); | ||
DATA(0x1E); | ||
DATA(0x21); | ||
} | ||
|
||
void lx154a2411_init_seq(void) { | ||
// most recent manual: | ||
// https://www.newhavendisplay.com/appnotes/datasheets/LCDs/ST7789V.pdf | ||
// TEON: Tearing Effect Line On; V-blanking only | ||
CMD(0x35); | ||
DATA(0x00); | ||
|
||
// COLMOD: Interface Pixel format; 65K color: 16-bit/pixel (RGB 5-6-5 bits | ||
// input) | ||
CMD(0x3A); | ||
DATA(0x55); | ||
|
||
// CMD2EN: Commands in command table 2 can be executed when EXTC level is Low | ||
CMD(0xDF); | ||
DATA(0x5A); | ||
DATA(0x69); | ||
DATA(0x02); | ||
DATA(0x01); | ||
|
||
// LCMCTRL: LCM Control: XOR RGB setting | ||
CMD(0xC0); | ||
DATA(0x20); | ||
|
||
// GATECTRL: Gate Control; NL = 240 gate lines, first scan line is gate 80.; | ||
// gate scan direction 319 -> 0 | ||
CMD(0xE4); | ||
DATA(0x1D); | ||
DATA(0x0A); | ||
DATA(0x11); | ||
|
||
// INVOFF (20h): Display Inversion Off | ||
// INVON (21h): Display Inversion On | ||
CMD(0x20); | ||
|
||
// the above config is the most important and definitely necessary | ||
|
||
// PWCTRL1: Power Control 1 | ||
CMD(0xD0); | ||
DATA(0xA4); | ||
DATA(0xA1); | ||
|
||
lx154a2411_gamma(); | ||
} |
8 changes: 8 additions & 0 deletions
8
core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lx154a2411.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef LX154A2411_H_ | ||
#define LX154A2411_H_ | ||
|
||
// ST7789_V IC controller | ||
void lx154a2411_gamma(void); | ||
void lx154a2411_init_seq(void); | ||
|
||
#endif |
148 changes: 148 additions & 0 deletions
148
core/embed/trezorhal/stm32f4/xdisplay/st-7789/panels/lx154a2422.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
|
||
#include "display.h" | ||
#include "displays/st7789v.h" | ||
#include "touch.h" | ||
|
||
void lx154a2422_gamma(void) { | ||
// positive voltage correction | ||
CMD(0xE0); | ||
DATA(0xD0); | ||
DATA(0x0A); | ||
DATA(0x10); | ||
DATA(0x0A); | ||
DATA(0x0A); | ||
DATA(0x26); | ||
DATA(0x36); | ||
DATA(0x34); | ||
DATA(0x4D); | ||
DATA(0x18); | ||
DATA(0x13); | ||
DATA(0x14); | ||
DATA(0x2F); | ||
DATA(0x34); | ||
|
||
// negative voltage correction | ||
CMD(0xE1); | ||
DATA(0xD0); | ||
DATA(0x0A); | ||
DATA(0x10); | ||
DATA(0x0A); | ||
DATA(0x09); | ||
DATA(0x26); | ||
DATA(0x36); | ||
DATA(0x53); | ||
DATA(0x4C); | ||
DATA(0x18); | ||
DATA(0x14); | ||
DATA(0x14); | ||
DATA(0x2F); | ||
DATA(0x34); | ||
} | ||
|
||
void lx154a2422_init_seq(void) { | ||
// most recent manual: | ||
// https://www.newhavendisplay.com/appnotes/datasheets/LCDs/ST7789V.pdf | ||
// TEON: Tearing Effect Line On; V-blanking only | ||
CMD(0x35); | ||
DATA(0x00); | ||
|
||
// COLMOD: Interface Pixel format; 65K color: 16-bit/pixel (RGB 5-6-5 bits | ||
// input) | ||
CMD(0x3A); | ||
DATA(0x55); | ||
|
||
// CMD2EN: Commands in command table 2 can be executed when EXTC level is Low | ||
CMD(0xDF); | ||
DATA(0x5A); | ||
DATA(0x69); | ||
DATA(0x02); | ||
DATA(0x01); | ||
|
||
// LCMCTRL: LCM Control: XOR RGB setting | ||
CMD(0xC0); | ||
DATA(0x20); | ||
|
||
// GATECTRL: Gate Control; NL = 240 gate lines, first scan line is gate 80.; | ||
// gate scan direction 319 -> 0 | ||
CMD(0xE4); | ||
DATA(0x1D); | ||
DATA(0x0A); | ||
DATA(0x11); | ||
|
||
// INVOFF (20h): Display Inversion Off | ||
// INVON (21h): Display Inversion On | ||
CMD(0x21); | ||
|
||
// the above config is the most important and definitely necessary | ||
|
||
// PWCTRL1: Power Control 1 | ||
CMD(0xD0); | ||
DATA(0xA4); | ||
DATA(0xA1); | ||
|
||
lx154a2422_gamma(); | ||
} | ||
|
||
void lx154a2422_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; | ||
} | ||
|
||
CMD(0x36); | ||
DATA(display_command_parameter); | ||
|
||
if (shift) { | ||
// GATECTRL: Gate Control; NL = 240 gate lines, first scan line is | ||
// gate 80.; gate scan direction 319 -> 0 | ||
CMD(0xE4); | ||
DATA(0x1D); | ||
DATA(0x00); | ||
DATA(0x11); | ||
} else { | ||
// GATECTRL: Gate Control; NL = 240 gate lines, first scan line is | ||
// gate 80.; gate scan direction 319 -> 0 | ||
CMD(0xE4); | ||
DATA(0x1D); | ||
DATA(0x0A); | ||
DATA(0x11); | ||
} | ||
|
||
// reset the column and page extents | ||
display_set_window(0, 0, DISPLAY_RESX - 1, DISPLAY_RESY - 1); | ||
|
||
padding->x = BX ? (MAX_DISPLAY_RESY - DISPLAY_RESY) : 0; | ||
padding->y = BY ? (MAX_DISPLAY_RESY - DISPLAY_RESY) : 0; | ||
} | ||
|
||
uint32_t lx154a2422_transform_touch_coords(uint16_t x, uint16_t y) { | ||
return touch_pack_xy(x, y); | ||
} |
Oops, something went wrong.