Skip to content

Instantly share code, notes, and snippets.

@hgroll
Last active Sep 28, 2021
Embed
What would you like to do?
device tree overlay to use pidi with fbtft driver for rpi 2 B
/*
* Device Tree overlay to use pidi by Pimoroni as framebuffer device
*
* Known Issues:
* - flickery
*/
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2835";
fragment@0 {
target = <&spi0>;
__overlay__ {
status = "okay";
spidev@0{
status = "disabled";
};
spidev@1{
status = "disabled";
};
};
};
fragment@1 {
target = <&gpio>;
__overlay__ {
pidi_pins: pidi_pins {
brcm,pins = <9 13>; /* dc brightness */
brcm,function = <1 1>; /* out out*/
};
};
};
fragment@2 {
target = <&spi0>;
__overlay__ {
/* needed to avoid dtc warning */
#address-cells = <1>;
#size-cells = <0>;
pidi: pidi@0{
compatible = "sitronix,st7789v"; /* uses fbtft in rpi-4.19.y */
reg = <0>;
pinctrl-names = "default";
pinctrl-0 = <&pidi_pins>;
spi-max-frequency = <40000000>;
rotate = <0>;
fps = <25>;
buswidth = <8>;
regwidth = <8>;
dc-gpios = <&gpio 9 0>;
led-gpios = <&gpio 13 1>;
debug = <0>;
height = <240>;
txbuflen = <32768>;
/* gamma and init values from https://github.com/pimoroni/st7789-python/blob/master/library/ST7789/__init__.py */
gamma = "D0 04 0D 11 13 2B 3F 54 4C 18 0D 0B 1F 23\nD0 04 0C 11 13 2C 3F 44 51 2F 1F 1F 20 23";
/* ST7789_SWRESET = 0x01 */
/* ST7789_MADCTL = 0x36, 0x70 */
/* ST7789_FRMCTR2 = 0xB2, idle mode*/
/* ST7789_COLMOD = 0x3A, 0x05 16 bit */
/* ST7789_GCTRL = 0xB7, 0x14 */
/* ST7789_VCOMS = 0xBB, 0x37 */
/* ST7789_LCMCTRL = 0xC0, 0x2C */
/* ST7789_VDVVRHEN = 0xC2, 0x01 */
/* ST7789_VRHS = 0xC3, 0x12 */
/* ST7789_VDVS = 0xC4, 0x20 */
/* PWCTRL1 = 0xD0, 0xA4, 0xA1 */
/* ST7789_FRCTRL2 = 0xC6, 0x0F */
/* ST7789_INVOFF = 0x20 */
/* ST7789_INVON = 0x21 */
/* ST7789_SLPOUT = 0x11 */
/* ST7789_DISPON = 0x29 */
init = <0x2000001
0x1000036 0x70
0x10000B2 0x0C 0x0C 0x00 0x33 0x33
0x100003A 0x05
0x10000B7 0x14
0x10000BB 0x37
0x10000C0 0x2C
0x10000C2 0x01
0x10000C3 0x12
0x10000C4 0x20
0x10000D0 0xA4 0xA1
0x10000C6 0x0F
0x1000021
0x1000011
0x1000029>;
};
};
};
fragment@3 {
target = <&spi0_pins>;
__overlay__ {
brcm,pins = <10 11>; /* exclude BCM 9 from SPI to use it as DC in fbtft driver */
brcm,function = <4>; /* alt 0 */
};
};
__overrides__ {
speed = <&pidi>,"spi-max-frequency:0";
rotate = <&pidi>,"rotate:0";
fps = <&pidi>,"fps:0";
debug = <&pidi>,"debug:0";
};
};
@johnsboyd
Copy link

johnsboyd commented Sep 28, 2021

At first I made modifications to the "pidi-overlay.dts" then realized I could do the same thing in config.txt

So, I've been modifying these lines in config.txt and the 1st leaves it alone but the second fails with the artifact:

dtoverlay=pidi:rotate=0 # same as no param
or
dtoverlay=pidi:rotate=180 # upside down but with artifact

I see some mention of row_offset elsewhere but that doesn't seem to work here.
So there is no solution?

@johnsboyd
Copy link

johnsboyd commented Sep 28, 2021

Nevermind, this worked in cmdline.txt because I'm using fbconsole:

fbcon=rotate:2

@hgroll
Copy link
Author

hgroll commented Sep 28, 2021

I did not follow the problem anymore. My workaround was rotating the output at one level of abstraction above. I see some interesting comment here notro/fbtft#523 (comment). Maybe this helps.

@hgroll
Copy link
Author

hgroll commented Sep 28, 2021

Nevermind, this worked in cmdline.txt because I'm using fbconsole:

fbcon=rotate:2

exactly, something like that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment