The madctl_helper.py program can help determine the colormode
, invert
, and
rot
parameters for a display. Set the mosi
, clk
, dc
, cs
, backlight
, width
, and
height
parameters for your display. Start with rot=0
, colormode=COLOR_MODE_RGB
, and rot=0
.
Run the program with the display in the orientation you would like to configure.
The program will draw a large red full-screen button with an 'F' character centered in the button.
You can determine the colormode
and invert
parameters by observing the button's color.
- If the button is RED, the
colormode
andinvert
parameters are correct. - If the button is BLUE,
colormode
should beCOLOR_MODE_BGR
. - If the button is YELLOW,
invert
should beTrue
. - If the button is CYAN,
colormode
should beCOLOR_MODE_BGR
andinvert
should beTrue
.
The rot
parameter is used to set the MADCTL register of the display. The MADCTL register controls
the order that pixels are written to the framebuffer. This sets the Orientation or Rotation of the
display. Match the orientation and direction of the 'F' character as drawn on the display by the
madctl_helper.py program with the examples in the table below to determine the
rot
parameter value.
Image | rot parameter |
---|---|
rot=0 | |
rot=MADCTL_MY | |
rot=MADCTL_MX | |
rot=MADCTL_MX | MADCTL_MY | |
rot=MADCTL_MV | |
rot=MADCTL_MV | MADCTL_MY | |
rot=MADCTL_MV | MADCTL_MX | |
rot=MADCTL_MV | MADCTL_MX | MADCTL_MX |
The following table shows the MADCTL bit flags and their effects.
Constant | Value | Description |
---|---|---|
MADCTL_MY | 0x80 | Page Address Order |
MADCTL_MX | 0x40 | Column Address Order |
MADCTL_MV | 0x20 | Page/Column Order |
MADCTL_ML | 0x10 | Line Address Order |
MADCTL_MH | 0x04 | Display Data Latch Order |
COLOR_MODE_RGB | 0x00 | RGB color order |
COLOR_MODE_BGR | 0x08 | BGR color order |