Skip to content

Commit 7ffa2a1

Browse files
authored
Merge pull request #3269 from jepler/sharpdisplay-v2
Sharp Memory Display displayio support (v2)
2 parents 3197c57 + 195c0ea commit 7ffa2a1

File tree

24 files changed

+737
-68
lines changed

24 files changed

+737
-68
lines changed

locale/circuitpython.pot

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2020-08-10 12:54-0500\n"
11+
"POT-Creation-Date: 2020-08-11 15:37-0500\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -823,6 +823,11 @@ msgstr ""
823823
msgid "File exists"
824824
msgstr ""
825825

826+
#: shared-module/framebufferio/FramebufferDisplay.c
827+
#, c-format
828+
msgid "Framebuffer requires %d bytes"
829+
msgstr ""
830+
826831
#: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
827832
msgid "Frequency captured is above capability. Capture Paused."
828833
msgstr ""

ports/atmel-samd/mpconfigport.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ endif
3939

4040
CIRCUITPY_SDCARDIO ?= 0
4141

42+
# Not enough RAM for framebuffers
43+
CIRCUITPY_FRAMEBUFFERIO ?= 0
44+
4245
# SAMD21 needs separate endpoint pairs for MSC BULK IN and BULK OUT, otherwise it's erratic.
4346
USB_MSC_EP_NUM_OUT = 1
4447

ports/nrf/Makefile

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ INC += -I$(BUILD)
7373
INC += -I$(BUILD)/genhdr
7474
INC += -I./../../lib/cmsis/inc
7575
INC += -I./boards/$(BOARD)
76-
INC += -I./nrfx
77-
INC += -I./nrfx/hal
78-
INC += -I./nrfx/mdk
79-
INC += -I./nrfx/drivers/include
80-
INC += -I./nrfx/drivers/src
76+
INC += -isystem ./nrfx
77+
INC += -isystem ./nrfx/hal
78+
INC += -isystem ./nrfx/mdk
79+
INC += -isystem ./nrfx/drivers/include
80+
INC += -isystem ./nrfx/drivers/src
8181
INC += -I./bluetooth
8282
INC += -I./peripherals
8383
INC += -I../../lib/mp-readline
@@ -100,8 +100,6 @@ CFLAGS += $(OPTIMIZATION_FLAGS)
100100
CFLAGS += $(INC) -Wall -Werror -std=gnu11 -nostdlib -fshort-enums $(BASE_CFLAGS) $(CFLAGS_MOD) $(COPT)
101101

102102
# Undo some warnings.
103-
# nrfx uses undefined preprocessor variables quite casually, so we can't do warning checks for these.
104-
CFLAGS += -Wno-undef
105103
# nrfx does casts that increase alignment requirements.
106104
CFLAGS += -Wno-cast-align
107105

@@ -240,6 +238,11 @@ endif
240238
OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
241239
OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o))
242240

241+
# nrfx uses undefined preprocessor variables quite casually, so we can't do
242+
# warning checks for these. Happily, we've confined the offenders to the NRFX
243+
# source files themselves.
244+
$(addprefix $(BUILD)/, $(SRC_NRFX:.c=.o)): CFLAGS += -Wno-undef
245+
243246
$(BUILD)/$(FATFS_DIR)/ff.o: COPT += -Os
244247
$(filter $(PY_BUILD)/../extmod/vfs_fat_%.o, $(PY_O)): COPT += -Os
245248

ports/nrf/common-hal/busio/SPI.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,22 @@
3434
#include "nrfx_spim.h"
3535
#include "nrf_gpio.h"
3636

37+
#ifndef NRFX_SPIM3_ENABLED
38+
#define NRFX_SPIM3_ENABLED (0)
39+
#endif
40+
41+
#ifndef NRFX_SPIM2_ENABLED
42+
#define NRFX_SPIM2_ENABLED (0)
43+
#endif
44+
45+
#ifndef NRFX_SPIM1_ENABLED
46+
#define NRFX_SPIM1_ENABLED (0)
47+
#endif
48+
49+
#ifndef NRFX_SPIM0_ENABLED
50+
#define NRFX_SPIM0_ENABLED (0)
51+
#endif
52+
3753
// These are in order from highest available frequency to lowest (32MHz first, then 8MHz).
3854
STATIC spim_peripheral_t spim_peripherals[] = {
3955
#if NRFX_CHECK(NRFX_SPIM3_ENABLED)

ports/nrf/common-hal/microcontroller/Pin.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ void reset_pin_number(uint8_t pin_number) {
9393

9494
// Clear claimed bit.
9595
claimed_pins[nrf_pin_port(pin_number)] &= ~(1 << nrf_relative_pin_number(pin_number));
96+
never_reset_pins[nrf_pin_port(pin_number)] &= ~(1 << nrf_relative_pin_number(pin_number));
9697

9798
#ifdef MICROPY_HW_NEOPIXEL
9899
if (pin_number == MICROPY_HW_NEOPIXEL->number) {

ports/nrf/supervisor/qspi_flash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ void spi_flash_init(void) {
201201
.irq_priority = 7,
202202
};
203203

204-
#if EXTERNAL_FLASH_QSPI_DUAL
204+
#if defined(EXTERNAL_FLASH_QSPI_DUAL)
205205
qspi_cfg.pins.io1_pin = MICROPY_QSPI_DATA1;
206206
qspi_cfg.prot_if.readoc = NRF_QSPI_READOC_READ2O;
207207
qspi_cfg.prot_if.writeoc = NRF_QSPI_WRITEOC_PP2O;

py/circuitpy_defns.mk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,9 @@ endif
222222
ifeq ($(CIRCUITPY_SDIOIO),1)
223223
SRC_PATTERNS += sdioio/%
224224
endif
225+
ifeq ($(CIRCUITPY_SHARPDISPLAY),1)
226+
SRC_PATTERNS += sharpdisplay/%
227+
endif
225228
ifeq ($(CIRCUITPY_STAGE),1)
226229
SRC_PATTERNS += _stage/%
227230
endif
@@ -409,6 +412,8 @@ SRC_SHARED_MODULE_ALL = \
409412
random/__init__.c \
410413
rgbmatrix/RGBMatrix.c \
411414
rgbmatrix/__init__.c \
415+
sharpdisplay/SharpMemoryFramebuffer.c \
416+
sharpdisplay/__init__.c \
412417
socket/__init__.c \
413418
storage/__init__.c \
414419
struct/__init__.c \

py/circuitpy_mpconfig.h

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -499,13 +499,6 @@ extern const struct _mp_obj_module_t pixelbuf_module;
499499
#define PIXELBUF_MODULE
500500
#endif
501501

502-
#if CIRCUITPY_RGBMATRIX
503-
extern const struct _mp_obj_module_t rgbmatrix_module;
504-
#define RGBMATRIX_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_rgbmatrix),(mp_obj_t)&rgbmatrix_module },
505-
#else
506-
#define RGBMATRIX_MODULE
507-
#endif
508-
509502
#if CIRCUITPY_PULSEIO
510503
extern const struct _mp_obj_module_t pulseio_module;
511504
#define PULSEIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_pulseio), (mp_obj_t)&pulseio_module },
@@ -520,6 +513,13 @@ extern const struct _mp_obj_module_t ps2io_module;
520513
#define PS2IO_MODULE
521514
#endif
522515

516+
#if CIRCUITPY_RGBMATRIX
517+
extern const struct _mp_obj_module_t rgbmatrix_module;
518+
#define RGBMATRIX_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_rgbmatrix),(mp_obj_t)&rgbmatrix_module },
519+
#else
520+
#define RGBMATRIX_MODULE
521+
#endif
522+
523523
#if CIRCUITPY_RANDOM
524524
extern const struct _mp_obj_module_t random_module;
525525
#define RANDOM_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_random), (mp_obj_t)&random_module },
@@ -562,6 +562,13 @@ extern const struct _mp_obj_module_t sdioio_module;
562562
#define SDIOIO_MODULE
563563
#endif
564564

565+
#if CIRCUITPY_SHARPDISPLAY
566+
extern const struct _mp_obj_module_t sharpdisplay_module;
567+
#define SHARPDISPLAY_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_sharpdisplay),(mp_obj_t)&sharpdisplay_module },
568+
#else
569+
#define SHARPDISPLAY_MODULE
570+
#endif
571+
565572
#if CIRCUITPY_STAGE
566573
extern const struct _mp_obj_module_t stage_module;
567574
#define STAGE_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR__stage), (mp_obj_t)&stage_module },
@@ -737,6 +744,7 @@ extern const struct _mp_obj_module_t watchdog_module;
737744
SAMD_MODULE \
738745
SDCARDIO_MODULE \
739746
SDIOIO_MODULE \
747+
SHARPDISPLAY_MODULE \
740748
STAGE_MODULE \
741749
STORAGE_MODULE \
742750
STRUCT_MODULE \

py/circuitpy_mpconfig.mk

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ CFLAGS += -DCIRCUITPY_COUNTIO=$(CIRCUITPY_COUNTIO)
9595
CIRCUITPY_DISPLAYIO ?= $(CIRCUITPY_FULL_BUILD)
9696
CFLAGS += -DCIRCUITPY_DISPLAYIO=$(CIRCUITPY_DISPLAYIO)
9797

98+
ifeq ($(CIRCUITPY_DISPLAYIO),1)
99+
CIRCUITPY_FRAMEBUFFERIO ?= $(CIRCUITPY_FULL_BUILD)
100+
else
98101
CIRCUITPY_FRAMEBUFFERIO ?= 0
102+
endif
99103
CFLAGS += -DCIRCUITPY_FRAMEBUFFERIO=$(CIRCUITPY_FRAMEBUFFERIO)
100104

101105
CIRCUITPY_VECTORIO ?= $(CIRCUITPY_DISPLAYIO)
@@ -144,7 +148,6 @@ CFLAGS += -DCIRCUITPY_OS=$(CIRCUITPY_OS)
144148
CIRCUITPY_PIXELBUF ?= $(CIRCUITPY_FULL_BUILD)
145149
CFLAGS += -DCIRCUITPY_PIXELBUF=$(CIRCUITPY_PIXELBUF)
146150

147-
# Only for SAMD boards for the moment
148151
CIRCUITPY_RGBMATRIX ?= 0
149152
CFLAGS += -DCIRCUITPY_RGBMATRIX=$(CIRCUITPY_RGBMATRIX)
150153

@@ -176,6 +179,9 @@ CFLAGS += -DCIRCUITPY_SDCARDIO=$(CIRCUITPY_SDCARDIO)
176179
CIRCUITPY_SDIOIO ?= 0
177180
CFLAGS += -DCIRCUITPY_SDIOIO=$(CIRCUITPY_SDIOIO)
178181

182+
CIRCUITPY_SHARPDISPLAY ?= $(CIRCUITPY_FRAMEBUFFERIO)
183+
CFLAGS += -DCIRCUITPY_SHARPDISPLAY=$(CIRCUITPY_SHARPDISPLAY)
184+
179185
# Currently always off.
180186
CIRCUITPY_STAGE ?= 0
181187
CFLAGS += -DCIRCUITPY_STAGE=$(CIRCUITPY_STAGE)

py/qstr.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ STATIC const byte *find_qstr(qstr q) {
137137
while (q < pool->total_prev_len) {
138138
pool = pool->prev;
139139
}
140+
assert(q - pool->total_prev_len < pool->len);
140141
return pool->qstrs[q - pool->total_prev_len];
141142
}
142143

0 commit comments

Comments
 (0)