Skip to content

Commit 9028bf2

Browse files
authored
Merge pull request #6331 from pypewpew/pewpew_lcd
Add new board pewpew_lcd
2 parents 0b58f17 + e7735a3 commit 9028bf2

File tree

6 files changed

+209
-0
lines changed

6 files changed

+209
-0
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,3 +286,6 @@
286286
[submodule "frozen/Adafruit_CircuitPython_FakeRequests"]
287287
path = frozen/Adafruit_CircuitPython_FakeRequests
288288
url = https://github.com/adafruit/Adafruit_CircuitPython_FakeRequests.git
289+
[submodule "frozen/pew-pewpew-lcd"]
290+
path = frozen/pew-pewpew-lcd
291+
url = https://github.com/pypewpew/pew-pewpew-lcd.git

frozen/pew-pewpew-lcd

Submodule pew-pewpew-lcd added at 837f3e5
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include "supervisor/board.h"
28+
29+
#include "shared-bindings/board/__init__.h"
30+
#include "shared-bindings/displayio/FourWire.h"
31+
#include "shared-module/displayio/__init__.h"
32+
#include "shared-module/displayio/mipi_constants.h"
33+
#include "shared-bindings/busio/SPI.h"
34+
35+
displayio_fourwire_obj_t board_display_obj;
36+
37+
#define DELAY 0x80
38+
39+
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
46+
};
47+
48+
void board_init(void) {
49+
busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus;
50+
common_hal_busio_spi_construct(spi, &pin_PA23, &pin_PA22, NULL, false);
51+
common_hal_busio_spi_never_reset(spi);
52+
53+
displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus;
54+
bus->base.type = &displayio_fourwire_type;
55+
common_hal_displayio_fourwire_construct(bus,
56+
spi,
57+
NULL, // Command or data
58+
&pin_PA19, // Chip select
59+
&pin_PA18, // Reset
60+
40000000LL, // Baudrate
61+
0, // Polarity
62+
0); // Phase
63+
64+
displayio_display_obj_t *display = &displays[0].display;
65+
display->base.type = &displayio_display_type;
66+
common_hal_displayio_display_construct(display,
67+
bus,
68+
96, // Width
69+
68, // Height
70+
0, // column start
71+
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
76+
1, // bytes per cell. Only valid for depths < 8
77+
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
82+
display_init_sequence,
83+
sizeof(display_init_sequence),
84+
NULL, // &pin_PA17, // brightness pin
85+
NO_BRIGHTNESS_COMMAND,
86+
0.0f, // brightness
87+
false, // auto_brightness
88+
false, // single_byte_bounds
89+
true, // data as commands
90+
true, // auto_refresh
91+
2, // native_frames_per_second
92+
true, // backlight_on_high
93+
true); // SH1107_addressing
94+
}
95+
96+
bool board_requests_safe_mode(void) {
97+
return false;
98+
}
99+
100+
void reset_board(void) {
101+
}
102+
103+
void board_deinit(void) {
104+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#define MICROPY_HW_BOARD_NAME "PewPew LCD"
2+
#define MICROPY_HW_MCU_NAME "samd21e18"
3+
4+
#define MICROPY_PORT_A (0)
5+
#define MICROPY_PORT_B (0)
6+
#define MICROPY_PORT_C (0)
7+
8+
#define CIRCUITPY_INTERNAL_NVM_SIZE 0
9+
#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (48 * 1024)
10+
11+
// USB is always used internally so skip the pin objects for it.
12+
#define IGNORE_PIN_PA24 1
13+
#define IGNORE_PIN_PA25 1
14+
15+
#define SAMD21_BOD33_LEVEL (6)
16+
#define CIRCUITPY_REPL_LOGO (0)
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
USB_VID = 0x1209
2+
USB_PID = 0xD1B5
3+
USB_PRODUCT = "PewPew LCD"
4+
USB_MANUFACTURER = "Radomir Dopieralski"
5+
6+
CHIP_VARIANT = SAMD21E18A
7+
CHIP_FAMILY = samd21
8+
9+
INTERNAL_FLASH_FILESYSTEM = 1
10+
LONGINT_IMPL = NONE
11+
12+
CIRCUITPY_FULL_BUILD = 0
13+
14+
CIRCUITPY_DISPLAYIO = 1
15+
CIRCUITPY_TOUCHIO = 1
16+
CIRCUITPY_PWMIO = 1
17+
CIRCUITPY_MATH = 0
18+
19+
CIRCUITPY_ANALOGIO = 0
20+
CIRCUITPY_AUDIOBUSIO = 0
21+
CIRCUITPY_AUDIOBUSIO_I2SOUT = 0
22+
CIRCUITPY_AUDIOCORE = 0
23+
CIRCUITPY_AUDIOIO = 0
24+
CIRCUITPY_AUDIOMIXER = 0
25+
CIRCUITPY_AUDIOMP3 = 0
26+
CIRCUITPY_AUDIOPWMIO = 0
27+
CIRCUITPY_BITBANG_APA102 = 0
28+
CIRCUITPY_BITBANGIO = 0
29+
CIRCUITPY_BITBANGIO = 0
30+
CIRCUITPY_BITMAPTOOLS = 0
31+
CIRCUITPY_BITMAPTOOLS = 0
32+
CIRCUITPY_BLEIO = 0
33+
CIRCUITPY_BUSDEVICE = 0
34+
CIRCUITPY_FRAMEBUFFERIO = 0
35+
CIRCUITPY_FREQUENCYIO = 0
36+
CIRCUITPY_I2CPERIPHERAL = 0
37+
CIRCUITPY_MSGPACK = 0
38+
CIRCUITPY_NEOPIXEL_WRITE = 0
39+
CIRCUITPY_NVM = 0
40+
CIRCUITPY_PIXELBUF = 0
41+
CIRCUITPY_PS2IO = 0
42+
CIRCUITPY_PULSEIO = 0
43+
CIRCUITPY_RGBMATRIX = 0
44+
CIRCUITPY_ROTARYIO = 0
45+
CIRCUITPY_ROTARYIO = 0
46+
CIRCUITPY_RTC = 0
47+
CIRCUITPY_SAMD = 0
48+
CIRCUITPY_ULAB = 0
49+
CIRCUITPY_USB_HID = 0
50+
CIRCUITPY_USB_MIDI = 0
51+
CIRCUITPY_USB_VENDOR = 0
52+
CIRCUITPY_VECTORIO = 0
53+
CIRCUITPY_RAINBOWIO = 0
54+
55+
CIRCUITPY_DISPLAY_FONT = $(TOP)/ports/atmel-samd/boards/ugame10/brutalist-6.bdf
56+
OPTIMIZATION_FLAGS = -Os
57+
FROZEN_MPY_DIRS += $(TOP)/frozen/pew-pewpew-lcd
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include "shared-bindings/board/__init__.h"
2+
#include "shared-module/displayio/__init__.h"
3+
4+
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) },
10+
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) },
17+
18+
{ MP_ROM_QSTR(MP_QSTR_P1), MP_ROM_PTR(&pin_PA30) },
19+
{ 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) },
25+
26+
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}
27+
};
28+
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);

0 commit comments

Comments
 (0)