Skip to content

Instantly share code, notes, and snippets.

@F1zye
Last active January 17, 2022 23:10
Show Gist options
  • Save F1zye/81afbc541d6481b1bf988a2dc592a5bd to your computer and use it in GitHub Desktop.
Save F1zye/81afbc541d6481b1bf988a2dc592a5bd to your computer and use it in GitHub Desktop.
/*
* Device Tree overlay for st7735r
*
*/
/dts-v1/;
/plugin/;
/ {
compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";
fragment@0 {
target = <&spi0>;
__overlay__ {
status = "okay";
};
};
fragment@1 {
target = <&spidev0>;
__overlay__ {
status = "disabled";
};
};
/*
fragment@2 {
target = <&spidev1>;
__overlay__ {
status = "disabled";
};
};
*/
fragment@3 {
target = <&gpio>;
__overlay__ {
st7735r_display_pins: st7735r_display_pins {
brcm,pins = <24 25>;
brcm,function = <1 1>;
brcm,pull = <0 0>;
};
};
};
/* fragment@4 {
target-path = "/";
__overlay__ {
backlight_gpio: backlight_gpio {
compatible = "gpio-backlight";
gpios = <&gpio 18 1>;
};
backlight_pwm: backlight_pwm {
pinctrl-names = "default";
pinctrl-0 = <&backlight_pwm_pins>;
status = "okay";
compatible = "pwm-backlight";
pwms = <&ehrpwm1 1 500000 0>;
brightness-levels = <
0 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19
20 21 22 23 24 25 26 27 28 29
30 31 32 33 34 35 36 37 38 39
40 41 42 43 44 45 46 47 48 49
50 51 52 53 54 55 56 57 58 59
60 61 62 63 64 65 66 67 68 69
70 71 72 73 74 75 76 77 78 79
80 81 82 83 84 85 86 87 88 89
90 91 92 93 94 95 96 97 98 99
100
>;
default-brightness-level = <90>;
};
};
};*/
fragment@5 {
target = <&spi0>;
__overlay__ {
/* needed to avoid dtc warning */
#address-cells = <1>;
#size-cells = <0>;
st7735rdisplay: st7735r-display@0{
compatible = "jianda,jd-t18003-t01", "sitronix,st7735r";
reg = <0>;
pinctrl-names = "default";
pinctrl-0 = <&st7735r_display_pins>;
spi-max-frequency = <32000000>;
rotation = <90>;
//bgr = <0>;
fps = <20>;
height = <160>;
width = <128>;
buswidth = <8>;
reset-gpios = <&gpio 25 0>;
dc-gpios = <&gpio 24 0>;
//led-gpios = <&gpio 18 0>;
//backlight = &backlight_gpio;
//debug = <0>;
};
};
};
__overrides__ {
speed = <&st7735rdisplay>,"spi-max-frequency:0";
rotate = <&st7735rdisplay>,"rotation:0";
fps = <&st7735rdisplay>,"fps:0";
debug = <&st7735rdisplay>,"debug:0";
};
};
@F1zye
Copy link
Author

F1zye commented Aug 12, 2020

In combination with gpio -g mode 18 pwm && gpio -g pwm 18 100 (assuming gpio 18 controls the displays led)

@Aleksey-Kudryavtsev
Copy link

Aleksey-Kudryavtsev commented May 23, 2021

Thanks for the overlay!
Could you post the wiring you used with this overlay?

Trying to get this working with Rpi Zero W and an ST7735S breakout board. My understanding is that ST7735R and S are the same in terms of the interface.
Measuring with a scope and the signals on the SCK, MOSI, CS0 and D/C pins are there (and changing when I write to /dev/fb0).
Confused about the RST pin (GPIO 25, pin 22 on Pi Zero) - it's always 0 while it's supposed to be active low, so it's holding it in reset all the time.
Also confused about the frequency on the SCK pin, supposed to be 32MHz but is actually around 18MHz.

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