Skip to content

Commit b6dff8d

Browse files
izzehoStarGate01
authored andcommitted
Add P8B mirrored version definition.
1 parent e77d47e commit b6dff8d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,7 @@ elseif(TARGET_DEVICE STREQUAL "MOY-UNK") # P8b mirrored
804804
add_definitions(-DCLOCK_CONFIG_LF_SRC=0) # RC
805805
add_definitions(-DMYNEWT_VAL_BLE_LL_SCA=500)
806806
add_definitions(-DCLOCK_CONFIG_LF_CAL_ENABLED=1)
807+
add_definitions(-DDRIVER_DISPLAY_MIRROR)
807808
else()
808809
message(FATAL_ERROR "Invalid TARGET_DEVICE")
809810
endif()

src/drivers/St7789.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ void St7789::Init() {
2121
MemoryDataAccessControl();
2222
ColumnAddressSet();
2323
RowAddressSet();
24+
// P8B Mirrored version does not need display inversion.
25+
#ifndef DRIVER_DISPLAY_MIRROR
2426
DisplayInversionOn();
27+
#endif
2528
NormalModeOn();
2629
SetVdv();
2730
DisplayOn();
@@ -62,7 +65,19 @@ void St7789::ColMod() {
6265

6366
void St7789::MemoryDataAccessControl() {
6467
WriteCommand(static_cast<uint8_t>(Commands::MemoryDataAccessControl));
68+
// P8B Mirrored version sets MX bit high in MADCTL register to flip about vertical axis.
69+
#ifdef DRIVER_DISPLAY_MIRROR
70+
// [0 .. 1] = Unused
71+
// [2] = MH = Display Data Latch Order, 0 = LCD refresh from left to right, 1 = Right to left
72+
// [3] = RGB = RGB/BGR Order, 0 = RGB, 1 = BGR
73+
// [4] = ML = Line Address Order, 0 = LCD refresh from top to bottom, 1 = Bottom to top
74+
// [5] = MV = Page/Column Order, 0 = Normal mode, 1 = Reverse mode
75+
// [6] = MX = Column Address Order, 0 = Left to right, 1 = Right to left
76+
// [7] = MY = Page Address Order, 0 = Top to bottom, 1 = Bottom to top
77+
WriteData(0b01000000);
78+
#else
6579
WriteData(0x00);
80+
#endif
6681
}
6782

6883
void St7789::ColumnAddressSet() {

0 commit comments

Comments
 (0)