8000 Merge pull request #8959 from pypewpew/pewpew-lcd · ladyada/circuitpython@eb74d13 · GitHub
[go: up one dir, main page]

Skip to content

Commit eb74d13

Browse files
authored
Merge pull request adafruit#8959 from pypewpew/pewpew-lcd
Update pewpew_lcd to version 4.1
2 parents c219d89 + 5f0ac68 commit eb74d13

File tree

3 files changed

+84
-52
lines changed

3 files changed

+84
-52
lines changed

ports/atmel-samd/boards/pewpew_lcd/board.c

Lines changed: 51 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
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
@@ -25,24 +26,45 @@
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

3536
fourwire_fourwire_obj_t board_display_obj;
3637

3738
#define DELAY 0x80
3839

3940
uint8_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

4870
void 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

ports/atmel-samd/boards/pewpew_lcd/mpconfigboard.mk

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,25 @@ LONGINT_IMPL = NONE
1111

1212
CIRCUITPY_FULL_BUILD = 0
1313

14+
# required
1415
CIRCUITPY_DISPLAYIO = 1
15-
CIRCUITPY_TOUCHIO = 1
16-
CIRCUITPY_PWMIO = 1
17-
CIRCUITPY_MATH = 0
16+
CIRCUITPY_BUSDISPLAY = 1
17+
CIRCUITPY_KEYPAD = 1
18+
CIRCUITPY_KEYPAD_KEYS = 1
19+
CIRCUITPY_KEYPAD_SHIFTREGISTERKEYS = 0
20+
CIRCUITPY_KEYPAD_KEYMATRIX = 0
1821

19-
CIRCUITPY_ANALOGIO = 0
22+
# bonus, can be disabled if needed
23+
CIRCUITPY_MATH = 1
24+
CIRCUITPY_ANALOGIO = 1
25+
CIRCUITPY_NEOPIXEL_WRITE = 1
26+
CIRCUITPY_SAMD = 1
27+
28+
CIRCUITPY_EPAPERDISPLAY = 0
29+
CIRCUITPY_I2CDISPLAYBUS = 0
30+
CIRCUITPY_STAGE = 0
31+
CIRCUITPY_PWMIO = 0
32+
CIRCUITPY_TOUCHIO = 0
2033
CIRCUITPY_AUDIOBUSIO = 0
2134
CIRCUITPY_AUDIOBUSIO_I2SOUT = 0
2235
CIRCUITPY_AUDIOCORE = 0
@@ -35,16 +48,13 @@ CIRCUITPY_FRAMEBUFFERIO = 0
3548
CIRCUITPY_FREQUENCYIO = 0
3649
CIRCUITPY_I2CTARGET = 0
3750
CIRCUITPY_MSGPACK = 0
38-
CIRCUITPY_NEOPIXEL_WRITE = 0
3951
CIRCUITPY_NVM = 0
4052
CIRCUITPY_PIXELBUF = 0
4153
CIRCUITPY_PS2IO = 0
4254
CIRCUITPY_PULSEIO = 0
4355
CIRCUITPY_RGBMATRIX = 0
4456
CIRCUITPY_ROTARYIO = 0
45-
CIRCUITPY_ROTARYIO = 0
4657
CIRCUITPY_RTC = 0
47-
CIRCUITPY_SAMD = 0
4858
CIRCUITPY_ULAB = 0
4959
CIRCUITPY_USB_HID = 0
5060
CIRCUITPY_USB_MIDI = 0

ports/atmel-samd/boards/pewpew_lcd/pins.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@
22
#include "shared-module/displayio/__init__.h"
33

44
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
5-
{ MP_ROM_QSTR(MP_QSTR__SCK), MP_ROM_PTR(&pin_PA23) },
6-
{ MP_ROM_QSTR(MP_QSTR__MOSI), MP_ROM_PTR(&pin_PA22) },
7-
{ MP_ROM_QSTR(MP_QSTR__CS), MP_ROM_PTR(&pin_PA19) },
8-
{ MP_ROM_QSTR(MP_QSTR__RST), MP_ROM_PTR(&pin_PA18) },
9-
{ MP_ROM_QSTR(MP_QSTR__BL), MP_ROM_PTR(&pin_PA17) },
5+
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_PA23) },
6+
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_PA22) },
7+
{ MP_ROM_QSTR(MP_QSTR_CS), MP_ROM_PTR(&pin_PA17) },
8+
{ MP_ROM_QSTR(MP_QSTR_RST), MP_ROM_PTR(&pin_PA18) },
9+
{ MP_ROM_QSTR(MP_QSTR_DC), MP_ROM_PTR(&pin_PA19) },
1010

11-
{ MP_ROM_QSTR(MP_QSTR__UP), MP_ROM_PTR(&pin_PA03) },
12-
{ MP_ROM_QSTR(MP_QSTR__DOWN), MP_ROM_PTR(&pin_PA05) },
13-
{ MP_ROM_QSTR(MP_QSTR__LEFT), MP_ROM_PTR(&pin_PA04) },
14-
{ MP_ROM_QSTR(MP_QSTR__RIGHT), MP_ROM_PTR(&pin_PA02) },
15-
{ MP_ROM_QSTR(MP_QSTR__O), MP_ROM_PTR(&pin_PA06) },
16-
{ MP_ROM_QSTR(MP_QSTR__X), MP_ROM_PTR(&pin_PA07) },
11+
{ MP_ROM_QSTR(MP_QSTR_UP), MP_ROM_PTR(&pin_PA14) },
12+
{ MP_ROM_QSTR(MP_QSTR_DOWN), MP_ROM_PTR(&pin_PA10) },
13+
{ MP_ROM_QSTR(MP_QSTR_LEFT), MP_ROM_PTR(&pin_PA11) },
14+
{ MP_ROM_QSTR(MP_QSTR_RIGHT), MP_ROM_PTR(&pin_PA09) },
15+
{ MP_ROM_QSTR(MP_QSTR_O), MP_ROM_PTR(&pin_PA16) },
16+
{ MP_ROM_QSTR(MP_QSTR_X), MP_ROM_PTR(&pin_PA15) },
1717

1818
{ MP_ROM_QSTR(MP_QSTR_P1), MP_ROM_PTR(&pin_PA30) },
1919
{ MP_ROM_QSTR(MP_QSTR_P2), MP_ROM_PTR(&pin_PA31) },
20-
{ MP_ROM_QSTR(MP_QSTR_P3), MP_ROM_PTR(&pin_PA08) },
21-
{ MP_ROM_QSTR(MP_QSTR_P4), MP_ROM_PTR(&pin_PA09) },
22-
{ MP_ROM_QSTR(MP_QSTR_P5), MP_ROM_PTR(&pin_PA10) },
23-
{ MP_ROM_QSTR(MP_QSTR_P6), MP_ROM_PTR(&pin_PA11) },
24-
{ MP_ROM_QSTR(MP_QSTR_P7), MP_ROM_PTR(&pin_PA14) },
20+
{ MP_ROM_QSTR(MP_QSTR_P3), MP_ROM_PTR(&pin_PA00) },
21+
{ MP_ROM_QSTR(MP_QSTR_P4), MP_ROM_PTR(&pin_PA01) },
22+
{ MP_ROM_QSTR(MP_QSTR_P5), MP_ROM_PTR(&pin_PA02) },
23+
{ MP_ROM_QSTR(MP_QSTR_P6), MP_ROM_PTR(&pin_PA03) },
24+
{ MP_ROM_QSTR(MP_QSTR_P7), MP_ROM_PTR(&pin_PA04) },
2525

2626
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}
2727
};

0 commit comments

Comments
 (0)
0