33 *
44 * The MIT License (MIT)
55 *
6- * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
6+ * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries, 2020 Radomir
7+ * Dopieralski
78 *
89 * Permission is hereby granted, free of charge, to any person obtaining a copy
910 * of this software and associated documentation files (the "Software"), to deal
2526 */
2627
2728#include "supervisor/board.h"
28-
2929#include "shared-bindings/board/__init__.h"
3030#include "shared-bindings/fourwire/FourWire.h"
31+ #include "hal/include/hal_gpio.h"
32+ #include "shared-bindings/busio/SPI.h"
3133#include "shared-module/displayio/__init__.h"
3234#include "shared-module/displayio/mipi_constants.h"
33- #include "shared-bindings/busio/SPI.h"
3435
3536fourwire_fourwire_obj_t board_display_obj ;
3637
3738#define DELAY 0x80
3839
3940uint8_t display_init_sequence [] = {
40- 0xe2 , 0 , // reset
41- 0x2f , 0 , // power on
42- 0x80 , 0 , // contrast 0
43- 0xa4 , 0 , // display normal
44- 0xaf , 0 , // display on
45- 0x40 , 0 , // start line 0
41+ 0x01 , 0 | DELAY , 150 , // SWRESET
42+ 0x11 , 0 | DELAY , 255 , // SLPOUT
43+ 0xb1 , 3 , 0x01 , 0x2C , 0x2D , // _FRMCTR1
44+ 0xb2 , 3 , 0x01 , 0x2C , 0x2D , //
45+ 0xb3 , 6 , 0x01 , 0x2C , 0x2D , 0x01 , 0x2C , 0x2D ,
46+ 0xb4 , 1 , 0x07 , // _INVCTR line inversion
47+ 0xc0 , 3 , 0xa2 , 0x02 , 0x84 , // _PWCTR1 GVDD = 4.7V, 1.0uA
48+ 0xc1 , 1 , 0xc5 , // _PWCTR2 VGH=14.7V, VGL=-7.35V
49+ 0xc2 , 2 , 0x0a , 0x00 , // _PWCTR3 Opamp current small, Boost frequency
50+ 0xc3 , 2 , 0x8a , 0x2a ,
51+ 0xc4 , 2 , 0x8a , 0xee ,
52+ 0xc5 , 1 , 0x0e , // _VMCTR1 VCOMH = 4V, VOML = -1.1V
53+ 0x2a , 0 , // _INVOFF
54+ 0x36 , 1 , 0xa0 , // _MADCTL
55+ // 1 clk cycle nonoverlap, 2 cycle gate rise, 3 cycle osc equalie,
56+ // fix on VTL
57+ 0x3a , 1 , 0x05 , // COLMOD - 16bit color
58+ 0xe0 , 16 , 0x02 , 0x1c , 0x07 , 0x12 , // _GMCTRP1 Gamma
59+ 0x37 , 0x32 , 0x29 , 0x2d ,
60+ 0x29 , 0x25 , 0x2B , 0x39 ,
61+ 0x00 , 0x01 , 0x03 , 0x10 ,
62+ 0xe1 , 16 , 0x03 , 0x1d , 0x07 , 0x06 , // _GMCTRN1
63+ 0x2E , 0x2C , 0x29 , 0x2D ,
64+ 0x2E , 0x2E , 0x37 , 0x3F ,
65+ 0x00 , 0x00 , 0x02 , 0x10 ,
66+ 0x13 , 0 | DELAY , 10 , // _NORON
67+ 0x29 , 0 | DELAY , 100 , // _DISPON
4668};
4769
4870void board_init (void ) {
@@ -54,42 +76,42 @@ void board_init(void) {
5476 bus -> base .type = & fourwire_fourwire_type ;
5577 common_hal_fourwire_fourwire_construct (bus ,
5678 spi ,
57- NULL , // Command or data
58- & pin_PA19 , // Chip select
59- & pin_PA18 , // Reset
60- 40000000LL , // Baudrate
79+ & pin_PA19 , // TFT_DC Command or data
80+ & pin_PA17 , // TFT_CS Chip select
81+ & pin_PA18 , // TFT_RST Reset
82+ 60000000 , // Baudrate
6183 0 , // Polarity
6284 0 ); // Phase
6385
6486 busdisplay_busdisplay_obj_t * display = & allocate_display ()-> display ;
6587 display -> base .type = & busdisplay_busdisplay_type ;
6688 common_hal_busdisplay_busdisplay_construct (display ,
6789 bus ,
68- 96 , // Width
69- 68 , // Height
90+ 160 , // Width (after rotation)
91+ 128 , // Height (after rotation)
7092 0 , // column start
7193 0 , // row start
72- 180 , // rotation
73- 1 , // Color depth
74- true , // grayscale
75- false, // pixels in byte share row. Only used with depth < 8
94+ 0 , // rotation
95+ 16 , // Color depth
96+ false , // grayscale
97+ false, // pixels in byte share row. only used for depth < 8
7698 1 , // bytes per cell. Only valid for depths < 8
7799 false, // reverse_pixels_in_byte. Only valid for depths < 8
78- false , // reverse_pixels_in_word
79- 0 , // Set column command
80- 0 , // Set row command
81- 0 , // Write memory command
100+ true , // reverse_pixels_in_word
101+ MIPI_COMMAND_SET_COLUMN_ADDRESS , // Set column command
102+ MIPI_COMMAND_SET_PAGE_ADDRESS , // Set row command
103+ MIPI_COMMAND_WRITE_MEMORY_START , // Write memory command
82104 display_init_sequence ,
83105 sizeof (display_init_sequence ),
84- NULL , // &pin_PA17, // brightness pin
106+ NULL , // backlight pin
85107 NO_BRIGHTNESS_COMMAND ,
86- 0 .0f , // brightness
108+ 1 .0f , // brightness
87109 false, // single_byte_bounds
88- true , // data as commands
89- true , // auto_refresh
90- 2 , // native_frames_per_second
110+ false , // data_as_commands
111+ false , // auto_refresh
112+ 20 , // native_frames_per_second
91113 true, // backlight_on_high
92- true , // SH1107_addressing
114+ false , // SH1107_addressing
93115 50000 ); // backlight pwm frequency
94116}
95117
0 commit comments