Skip to content

Commit 8c714ec

Browse files
authored
Merge pull request #7497 from tannewt/banglejs2
Add Bangle.js 2, JDI memory displays and ACeP epd
2 parents adf5b7a + 144aed4 commit 8c714ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+835
-183
lines changed

.github/actions/deps/ports/action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ runs:
2222
- name: Set up espressif port
2323
if: steps.board-to-port.outputs.port == 'espressif'
2424
uses: ./.github/actions/deps/ports/espressif
25+
26+
- name: Set up nrf port
27+
if: steps.board-to-port.outputs.port == 'nrf'
28+
uses: ./.github/actions/deps/ports/nrf
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Fetch nrf port deps
2+
3+
runs:
4+
using: composite
5+
steps:
6+
- name: Get nrfutil 7+
7+
run: |
8+
wget https://developer.nordicsemi.com/.pc-tools/nrfutil/x64-linux/nrfutil
9+
chmod +x nrfutil
10+
./nrfutil install nrf5sdk-tools
11+
mkdir -p $HOME/.local/bin
12+
mv nrfutil $HOME/.local/bin
13+
echo "$HOME/.local/bin" >> $GITHUB_PATH
14+
shell: bash
15+
- name: Print nrfutil version
16+
run: nrfutil -V
17+
shell: bash

lib/oofatfs/ff.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,12 @@ typedef struct {
278278

279279

280280
/* SBCS up-case tables (\x80-\xFF) */
281+
// Optimize the 437-only case with a truncated lookup table.
282+
#if FF_CODE_PAGE == 437
283+
#define TBL_CT437 {0x80,0x9A,0x45,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \
284+
0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
285+
0x41,0x49,0x4F,0x55,0xA5}
286+
#else
281287
#define TBL_CT437 {0x80,0x9A,0x45,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \
282288
0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
283289
0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \
@@ -286,6 +292,7 @@ typedef struct {
286292
0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \
287293
0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \
288294
0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
295+
#endif
289296
#define TBL_CT720 {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \
290297
0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \
291298
0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \
@@ -2887,7 +2894,12 @@ static FRESULT create_name ( /* FR_OK: successful, FR_INVALID_NAME: could not
28872894
}
28882895
#elif FF_CODE_PAGE < 900 /* SBCS cfg */
28892896
wc = ff_uni2oem(wc, CODEPAGE); /* Unicode ==> ANSI/OEM code */
2897+
// Optimize the 437-only case with a truncated lookup table.
2898+
#if FF_CODE_PAGE == 437
2899+
if (wc & 0x80 && wc < (0xA5 - 0x80)) wc = ExCvt[wc & 0x7F]; /* Convert extended character to upper (SBCS) */
2900+
#else
28902901
if (wc & 0x80) wc = ExCvt[wc & 0x7F]; /* Convert extended character to upper (SBCS) */
2902+
#endif
28912903
#else /* DBCS cfg */
28922904
wc = ff_uni2oem(ff_wtoupper(wc), CODEPAGE); /* Unicode ==> Upper convert ==> ANSI/OEM code */
28932905
#endif

lib/oofatfs/ffunicode.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,13 @@ DWORD ff_wtoupper ( /* Returns up-converted code point */
499499
DWORD uni /* Unicode code point to be up-converted */
500500
)
501501
{
502+
#if FF_FS_CASE_INSENSITIVE_COMPARISON_ASCII_ONLY
503+
// Only uppercase ASCII characters. Everything else will require the user to
504+
// pass in an uppercase version.
505+
if ('a' <= uni && uni <= 'z') {
506+
uni -= 32;
507+
}
508+
#else
502509
const WORD *p;
503510
WORD uc, bc, nc, cmd;
504511
static const WORD cvt1[] = { /* Compressed up conversion table for U+0000 - U+0FFF */
@@ -619,6 +626,7 @@ DWORD ff_wtoupper ( /* Returns up-converted code point */
619626
}
620627
uni = uc;
621628
}
629+
#endif
622630

623631
return uni;
624632
}

locale/circuitpython.pot

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,6 @@ msgstr ""
226226
msgid "%q out of range"
227227
msgstr ""
228228

229-
#: ports/atmel-samd/common-hal/microcontroller/Pin.c
230-
msgid "%q pin invalid"
231-
msgstr ""
232-
233229
#: py/objrange.c py/objslice.c shared-bindings/random/__init__.c
234230
msgid "%q step cannot be zero"
235231
msgstr ""
@@ -1225,9 +1221,11 @@ msgid "Interrupt error."
12251221
msgstr ""
12261222

12271223
#: py/argcheck.c shared-bindings/digitalio/DigitalInOut.c
1224+
#: shared-bindings/displayio/EPaperDisplay.c
12281225
msgid "Invalid %q"
12291226
msgstr ""
12301227

1228+
#: ports/atmel-samd/common-hal/microcontroller/Pin.c
12311229
#: shared-bindings/microcontroller/Pin.c
12321230
msgid "Invalid %q pin"
12331231
msgstr ""

ports/atmel-samd/background.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,8 @@ void port_finish_background_task(void) {
5757
}
5858
#endif
5959

60+
void port_background_tick(void) {
61+
}
62+
6063
void port_background_task(void) {
6164
}

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ uint8_t stop_sequence[] = {
5252
0x02, 0x80, 0xf0 // Power off
5353
};
5454

55+
uint8_t refresh_sequence[] = {
56+
0x12, 0x00
57+
};
58+
5559
void board_init(void) {
5660
busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus;
5761
common_hal_busio_spi_construct(spi, &pin_PB13, &pin_PB15, NULL, false);
@@ -74,6 +78,7 @@ void board_init(void) {
7478
bus,
7579
start_sequence,
7680
sizeof(start_sequence),
81+
0, // start up time
7782
stop_sequence,
7883
sizeof(stop_sequence),
7984
300, // width
@@ -92,13 +97,15 @@ void board_init(void) {
9297
NO_COMMAND, // write_color_ram_command (can add this for grayscale eventually)
9398
false, // color_bits_inverted
9499
0x000000, // highlight_color
95-
0x12, // refresh_display_command
100+
refresh_sequence, // refresh_display_sequence
101+
sizeof(refresh_sequence),
96102
40, // refresh_time
97103
&pin_PA01, // busy_pin
98104
false, // busy_state
99105
5, // seconds_per_frame
100106
false, // chip_select (don't always toggle chip select)
101107
false, // grayscale
108+
false, // acep
102109
false); // two_byte_sequence_length
103110
}
104111

ports/atmel-samd/common-hal/microcontroller/Pin.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,5 +211,5 @@ mcu_pin_function_t *mcu_find_pin_function(mcu_pin_function_t *table, const mcu_p
211211
return table;
212212
}
213213
}
214-
mp_raise_ValueError_varg(translate("%q pin invalid"), name);
214+
mp_raise_ValueError_varg(translate("Invalid %q pin"), name);
215215
}

ports/broadcom/background.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,8 @@ void port_start_background_task(void) {
3333
void port_finish_background_task(void) {
3434
}
3535

36+
void port_background_tick(void) {
37+
}
38+
3639
void port_background_task(void) {
3740
}

ports/cxd56/background.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#include "supervisor/filesystem.h"
3131
#include "supervisor/shared/stack.h"
3232

33+
void port_background_tick(void) {
34+
}
3335
void port_background_task(void) {
3436
}
3537
void port_start_background_task(void) {

ports/espressif/background.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,17 @@
4040
#include "common-hal/pulseio/PulseIn.h"
4141
#endif
4242

43-
void port_background_task(void) {
43+
void port_background_tick(void) {
4444
// Zero delay in case FreeRTOS wants to switch to something else.
4545
vTaskDelay(0);
4646
#if CIRCUITPY_PULSEIO
4747
pulsein_background();
4848
#endif
4949
}
5050

51+
void port_background_task(void) {
52+
}
53+
5154
void port_start_background_task(void) {
5255
}
5356

ports/espressif/boards/adafruit_magtag_2.9_grayscale/board.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ const uint8_t display_stop_sequence[] = {
109109
0x02, 0x00 // Power off
110110
};
111111

112+
const uint8_t refresh_sequence[] = {
113+
0x12, 0x00
114+
};
115+
112116
void board_init(void) {
113117
// Debug UART
114118
#ifdef DEBUG
@@ -137,6 +141,7 @@ void board_init(void) {
137141
display,
138142
bus,
139143
display_start_sequence, sizeof(display_start_sequence),
144+
0, // start up time
140145
display_stop_sequence, sizeof(display_stop_sequence),
141146
296, // width
142147
128, // height
@@ -154,13 +159,14 @@ void board_init(void) {
154159
0x13, // write_color_ram_command
155160
false, // color_bits_inverted
156161
0x000000, // highlight_color
157-
0x12, // refresh_display_command
162+
refresh_sequence, sizeof(refresh_sequence),
158163
1.0, // refresh_time
159164
&pin_GPIO5, // busy_pin
160165
false, // busy_state
161166
5.0, // seconds_per_frame
162167
false, // always_toggle_chip_select
163168
true, // grayscale
169+
false, // acep
164170
false); // two_byte_sequence_length
165171
}
166172

ports/litex/background.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
void port_background_task(void) {
3434
}
35+
void port_background_tick(void) {
36+
}
3537
void port_start_background_task(void) {
3638
}
3739
void port_finish_background_task(void) {

ports/mimxrt10xx/background.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,14 @@
2828
#include "supervisor/port.h"
2929

3030
void port_background_task(void) {
31+
}
32+
33+
void port_background_tick(void) {
3134
#if CIRCUITPY_AUDIOIO || CIRCUITPY_AUDIOBUSIO
3235
audio_dma_background();
3336
#endif
3437
}
38+
3539
void port_start_background_task(void) {
3640
}
3741
void port_finish_background_task(void) {

ports/nrf/Makefile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,8 @@ endif
275275
#####################
276276
.phony: dfu-gen dfu-flash
277277

278-
NRFUTIL = adafruit-nrfutil
278+
NRFUTIL = nrfutil
279+
ADAFRUIT_NRFUTIL = adafruit-nrfutil
279280

280281
ifeq ($(MCU_SUB_VARIANT),nrf52840)
281282
DFU_TOUCH = --touch 1200
@@ -293,14 +294,19 @@ __check_defined = \
293294
## Flash with DFU serial
294295
dfu-flash: $(BUILD)/dfu-package.zip
295296
@:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyUSB0)
296-
$(NRFUTIL) --verbose dfu serial --package $^ -p $(SERIAL) -b 115200 --singlebank $(DFU_TOUCH)
297+
$(ADAFRUIT_NRFUTIL) --verbose dfu serial --package $^ -p $(SERIAL) -b 115200 --singlebank $(DFU_TOUCH)
297298

298299
## Create DFU package file
299300
dfu-gen: $(BUILD)/dfu-package.zip
300301

301302
$(BUILD)/dfu-package.zip: $(BUILD)/firmware.hex
302-
$(NRFUTIL) dfu genpkg --sd-req 0xFFFE --dev-type 0x0052 --application $^ $(BUILD)/dfu-package.zip
303+
$(ADAFRUIT_NRFUTIL) dfu genpkg --sd-req 0xFFFE --dev-type 0x0052 --application $^ $(BUILD)/dfu-package.zip
303304

305+
# Espruino DFU
306+
$(BUILD)/firmware.espruino.zip: $(BUILD)/firmware.hex
307+
$(Q)$(NRFUTIL) pkg generate $(BUILD)/firmware.espruino.zip --application $^ --application-version 0xff --hw-version 52 --sd-req 0xa9,0xae,0xb6 --key-file espruino_dfu_private_key.pem
308+
309+
espruino-dfu-gen: $(BUILD)/firmware.espruino.zip
304310

305311
include $(TOP)/py/mkrules.mk
306312

ports/nrf/background.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
* THE SOFTWARE.
2525
*/
2626

27+
#include "background.h"
28+
2729
#include "py/runtime.h"
2830
#include "supervisor/filesystem.h"
2931
#include "supervisor/port.h"
@@ -44,14 +46,23 @@
4446

4547
void port_start_background_task(void) {
4648
}
49+
4750
void port_finish_background_task(void) {
4851
}
4952

50-
void port_background_task(void) {
53+
void port_background_tick(void) {
5154
#if CIRCUITPY_AUDIOPWMIO
5255
audiopwmout_background();
5356
#endif
5457
#if CIRCUITPY_AUDIOBUSIO
5558
i2s_background();
5659
#endif
5760
}
61+
62+
// Allow boards to override this.
63+
MP_WEAK void board_background_task(void) {
64+
}
65+
66+
void port_background_task(void) {
67+
board_background_task();
68+
}

ports/nrf/background.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,6 @@
2727
#ifndef MICROPY_INCLUDED_NRF_BACKGROUND_H
2828
#define MICROPY_INCLUDED_NRF_BACKGROUND_H
2929

30+
void board_background_task(void);
31+
3032
#endif // MICROPY_INCLUDED_NRF_BACKGROUND_H

0 commit comments

Comments
 (0)