Add new board pewpew_lcd

This commit is contained in:
Radomir Dopieralski 2022-04-28 13:41:34 +02:00
parent 816a26e8b7
commit e7735a3631
6 changed files with 209 additions and 0 deletions

3
.gitmodules vendored
View File

@ -286,3 +286,6 @@
[submodule "frozen/Adafruit_CircuitPython_FakeRequests"]
path = frozen/Adafruit_CircuitPython_FakeRequests
url = https://github.com/adafruit/Adafruit_CircuitPython_FakeRequests.git
[submodule "frozen/pew-pewpew-lcd"]
path = frozen/pew-pewpew-lcd
url = https://github.com/pypewpew/pew-pewpew-lcd.git

1
frozen/pew-pewpew-lcd Submodule

@ -0,0 +1 @@
Subproject commit 837f3e5f16accae5b3677954921b5ddd517f0799

View File

@ -0,0 +1,104 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "supervisor/board.h"
#include "shared-bindings/board/__init__.h"
#include "shared-bindings/displayio/FourWire.h"
#include "shared-module/displayio/__init__.h"
#include "shared-module/displayio/mipi_constants.h"
#include "shared-bindings/busio/SPI.h"
displayio_fourwire_obj_t board_display_obj;
#define DELAY 0x80
uint8_t display_init_sequence[] = {
0xe2, 0, // reset
0x2f, 0, // power on
0x80, 0, // contrast 0
0xa4, 0, // display normal
0xaf, 0, // display on
0x40, 0, // start line 0
};
void board_init(void) {
busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus;
common_hal_busio_spi_construct(spi, &pin_PA23, &pin_PA22, NULL, false);
common_hal_busio_spi_never_reset(spi);
displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus;
bus->base.type = &displayio_fourwire_type;
common_hal_displayio_fourwire_construct(bus,
spi,
NULL, // Command or data
&pin_PA19, // Chip select
&pin_PA18, // Reset
40000000LL, // Baudrate
0, // Polarity
0); // Phase
displayio_display_obj_t *display = &displays[0].display;
display->base.type = &displayio_display_type;
common_hal_displayio_display_construct(display,
bus,
96, // Width
68, // Height
0, // column start
0, // row start
180, // rotation
1, // Color depth
true, // grayscale
false, // pixels in byte share row. Only used with depth < 8
1, // bytes per cell. Only valid for depths < 8
false, // reverse_pixels_in_byte. Only valid for depths < 8
false, // reverse_pixels_in_word
0, // Set column command
0, // Set row command
0, // Write memory command
display_init_sequence,
sizeof(display_init_sequence),
NULL, // &pin_PA17, // brightness pin
NO_BRIGHTNESS_COMMAND,
0.0f, // brightness
false, // auto_brightness
false, // single_byte_bounds
true, // data as commands
true, // auto_refresh
2, // native_frames_per_second
true, // backlight_on_high
true); // SH1107_addressing
}
bool board_requests_safe_mode(void) {
return false;
}
void reset_board(void) {
}
void board_deinit(void) {
}

View File

@ -0,0 +1,16 @@
#define MICROPY_HW_BOARD_NAME "PewPew LCD"
#define MICROPY_HW_MCU_NAME "samd21e18"
#define MICROPY_PORT_A (0)
#define MICROPY_PORT_B (0)
#define MICROPY_PORT_C (0)
#define CIRCUITPY_INTERNAL_NVM_SIZE 0
#define CIRCUITPY_INTERNAL_FLASH_FILESYSTEM_SIZE (48 * 1024)
// USB is always used internally so skip the pin objects for it.
#define IGNORE_PIN_PA24 1
#define IGNORE_PIN_PA25 1
#define SAMD21_BOD33_LEVEL (6)
#define CIRCUITPY_REPL_LOGO (0)

View File

@ -0,0 +1,57 @@
USB_VID = 0x1209
USB_PID = 0xD1B5
USB_PRODUCT = "PewPew LCD"
USB_MANUFACTURER = "Radomir Dopieralski"
CHIP_VARIANT = SAMD21E18A
CHIP_FAMILY = samd21
INTERNAL_FLASH_FILESYSTEM = 1
LONGINT_IMPL = NONE
CIRCUITPY_FULL_BUILD = 0
CIRCUITPY_DISPLAYIO = 1
CIRCUITPY_TOUCHIO = 1
CIRCUITPY_PWMIO = 1
CIRCUITPY_MATH = 0
CIRCUITPY_ANALOGIO = 0
CIRCUITPY_AUDIOBUSIO = 0
CIRCUITPY_AUDIOBUSIO_I2SOUT = 0
CIRCUITPY_AUDIOCORE = 0
CIRCUITPY_AUDIOIO = 0
CIRCUITPY_AUDIOMIXER = 0
CIRCUITPY_AUDIOMP3 = 0
CIRCUITPY_AUDIOPWMIO = 0
CIRCUITPY_BITBANG_APA102 = 0
CIRCUITPY_BITBANGIO = 0
CIRCUITPY_BITBANGIO = 0
CIRCUITPY_BITMAPTOOLS = 0
CIRCUITPY_BITMAPTOOLS = 0
CIRCUITPY_BLEIO = 0
CIRCUITPY_BUSDEVICE = 0
CIRCUITPY_FRAMEBUFFERIO = 0
CIRCUITPY_FREQUENCYIO = 0
CIRCUITPY_I2CPERIPHERAL = 0
CIRCUITPY_MSGPACK = 0
CIRCUITPY_NEOPIXEL_WRITE = 0
CIRCUITPY_NVM = 0
CIRCUITPY_PIXELBUF = 0
CIRCUITPY_PS2IO = 0
CIRCUITPY_PULSEIO = 0
CIRCUITPY_RGBMATRIX = 0
CIRCUITPY_ROTARYIO = 0
CIRCUITPY_ROTARYIO = 0
CIRCUITPY_RTC = 0
CIRCUITPY_SAMD = 0
CIRCUITPY_ULAB = 0
CIRCUITPY_USB_HID = 0
CIRCUITPY_USB_MIDI = 0
CIRCUITPY_USB_VENDOR = 0
CIRCUITPY_VECTORIO = 0
CIRCUITPY_RAINBOWIO = 0
CIRCUITPY_DISPLAY_FONT = $(TOP)/ports/atmel-samd/boards/ugame10/brutalist-6.bdf
OPTIMIZATION_FLAGS = -Os
FROZEN_MPY_DIRS += $(TOP)/frozen/pew-pewpew-lcd

View File

@ -0,0 +1,28 @@
#include "shared-bindings/board/__init__.h"
#include "shared-module/displayio/__init__.h"
STATIC const mp_rom_map_elem_t board_global_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR__SCK), MP_ROM_PTR(&pin_PA23) },
{ MP_ROM_QSTR(MP_QSTR__MOSI), MP_ROM_PTR(&pin_PA22) },
{ MP_ROM_QSTR(MP_QSTR__CS), MP_ROM_PTR(&pin_PA19) },
{ MP_ROM_QSTR(MP_QSTR__RST), MP_ROM_PTR(&pin_PA18) },
{ MP_ROM_QSTR(MP_QSTR__BL), MP_ROM_PTR(&pin_PA17) },
{ MP_ROM_QSTR(MP_QSTR__UP), MP_ROM_PTR(&pin_PA03) },
{ MP_ROM_QSTR(MP_QSTR__DOWN), MP_ROM_PTR(&pin_PA05) },
{ MP_ROM_QSTR(MP_QSTR__LEFT), MP_ROM_PTR(&pin_PA04) },
{ MP_ROM_QSTR(MP_QSTR__RIGHT), MP_ROM_PTR(&pin_PA02) },
{ MP_ROM_QSTR(MP_QSTR__O), MP_ROM_PTR(&pin_PA06) },
{ MP_ROM_QSTR(MP_QSTR__X), MP_ROM_PTR(&pin_PA07) },
{ MP_ROM_QSTR(MP_QSTR_P1), MP_ROM_PTR(&pin_PA30) },
{ MP_ROM_QSTR(MP_QSTR_P2), MP_ROM_PTR(&pin_PA31) },
{ MP_ROM_QSTR(MP_QSTR_P3), MP_ROM_PTR(&pin_PA08) },
{ MP_ROM_QSTR(MP_QSTR_P4), MP_ROM_PTR(&pin_PA09) },
{ MP_ROM_QSTR(MP_QSTR_P5), MP_ROM_PTR(&pin_PA10) },
{ MP_ROM_QSTR(MP_QSTR_P6), MP_ROM_PTR(&pin_PA11) },
{ MP_ROM_QSTR(MP_QSTR_P7), MP_ROM_PTR(&pin_PA14) },
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}
};
MP_DEFINE_CONST_DICT(board_module_globals, board_global_dict_table);