Fix hallowing and nrf builds
This commit is contained in:
parent
4672866eec
commit
ec03887040
@ -17,6 +17,5 @@ CHIP_FAMILY = samd21
|
||||
|
||||
# Include these Python libraries in firmware.
|
||||
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BusDevice
|
||||
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_HID
|
||||
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_LIS3DH
|
||||
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_NeoPixel
|
||||
|
@ -226,8 +226,10 @@ SRC_SHARED_MODULE = \
|
||||
displayio/OnDiskBitmap.c \
|
||||
displayio/Palette.c \
|
||||
displayio/Shape.c \
|
||||
displayio/Sprite.c \
|
||||
storage/__init__.c
|
||||
displayio/TileGrid.c \
|
||||
storage/__init__.c \
|
||||
terminalio/__init__.c \
|
||||
terminalio/Terminal.c
|
||||
|
||||
|
||||
ifndef EXCLUDE_PIXELBUF
|
||||
|
@ -55,8 +55,33 @@ STATIC NRF_PWM_Type* pwms[] = {
|
||||
|
||||
STATIC uint16_t pwm_seq[MP_ARRAY_SIZE(pwms)][CHANNELS_PER_PWM];
|
||||
|
||||
static uint8_t never_reset_pwm[MP_ARRAY_SIZE(pwms)];
|
||||
|
||||
void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self) {
|
||||
for(int i=0; i < MP_ARRAY_SIZE(pwms); i++) {
|
||||
NRF_PWM_Type* pwm = pwms[i];
|
||||
if (pwm == self->pwm) {
|
||||
never_reset_pwm[i] += 1;
|
||||
}
|
||||
}
|
||||
|
||||
never_reset_pin_number(self->pin_number);
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pwmout_reset_ok(pulseio_pwmout_obj_t *self) {
|
||||
for(int i=0; i < MP_ARRAY_SIZE(pwms); i++) {
|
||||
NRF_PWM_Type* pwm = pwms[i];
|
||||
if (pwm == self->pwm) {
|
||||
never_reset_pwm[i] -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void pwmout_reset(void) {
|
||||
for(int i=0; i < MP_ARRAY_SIZE(pwms); i++) {
|
||||
if (never_reset_pwm[i] > 0) {
|
||||
continue;
|
||||
}
|
||||
NRF_PWM_Type* pwm = pwms[i];
|
||||
|
||||
pwm->ENABLE = 0;
|
||||
@ -104,11 +129,11 @@ bool convert_frequency(uint32_t frequency, uint16_t *countertop, nrf_pwm_clk_t *
|
||||
return false;
|
||||
}
|
||||
|
||||
void common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
|
||||
const mcu_pin_obj_t* pin,
|
||||
uint16_t duty,
|
||||
uint32_t frequency,
|
||||
bool variable_frequency) {
|
||||
pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
|
||||
const mcu_pin_obj_t* pin,
|
||||
uint16_t duty,
|
||||
uint32_t frequency,
|
||||
bool variable_frequency) {
|
||||
|
||||
// We don't use the nrfx driver here because we want to dynamically allocate channels
|
||||
// as needed in an already-enabled PWM.
|
||||
@ -116,7 +141,7 @@ void common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
|
||||
uint16_t countertop;
|
||||
nrf_pwm_clk_t base_clock;
|
||||
if (frequency == 0 || !convert_frequency(frequency, &countertop, &base_clock)) {
|
||||
mp_raise_ValueError(translate("Invalid PWM frequency"));
|
||||
return PWMOUT_INVALID_FREQUENCY;
|
||||
}
|
||||
|
||||
self->pwm = NULL;
|
||||
@ -158,7 +183,7 @@ void common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
|
||||
}
|
||||
|
||||
if (self->pwm == NULL) {
|
||||
mp_raise_ValueError(translate("All PWM peripherals are in use"));
|
||||
return PWMOUT_ALL_TIMERS_IN_USE;
|
||||
}
|
||||
|
||||
self->pin_number = pin->number;
|
||||
@ -183,6 +208,7 @@ void common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
|
||||
nrf_pwm_enable(pwm);
|
||||
|
||||
common_hal_pulseio_pwmout_set_duty_cycle(self, duty);
|
||||
return PWMOUT_OK;
|
||||
}
|
||||
|
||||
bool common_hal_pulseio_pwmout_deinited(pulseio_pwmout_obj_t* self) {
|
||||
|
@ -229,6 +229,7 @@ extern const struct _mp_obj_module_t touchio_module;
|
||||
#define MICROPY_PORT_ROOT_POINTERS \
|
||||
const char *readline_hist[8]; \
|
||||
mp_obj_t gamepad_singleton; \
|
||||
mp_obj_t terminal_tilegrid_tiles; \
|
||||
FLASH_ROOT_POINTERS \
|
||||
|
||||
// We need to provide a declaration/definition of alloca()
|
||||
|
@ -98,19 +98,7 @@ STATIC mp_obj_t displayio_fourwire_make_new(const mp_obj_type_t *type, size_t n_
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
//| .. method:: send(command, data)
|
||||
//|
|
||||
//|
|
||||
STATIC mp_obj_t displayio_fourwire_obj_send(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
mp_raise_NotImplementedError(translate("displayio is a work in progress"));
|
||||
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_KW(displayio_fourwire_send_obj, 1, displayio_fourwire_obj_send);
|
||||
|
||||
STATIC const mp_rom_map_elem_t displayio_fourwire_locals_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_send), MP_ROM_PTR(&displayio_fourwire_send_obj) },
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(displayio_fourwire_locals_dict, displayio_fourwire_locals_dict_table);
|
||||
|
||||
|
@ -102,19 +102,7 @@ STATIC mp_obj_t displayio_parallelbus_make_new(const mp_obj_type_t *type, size_t
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
//| .. method:: send(command, data)
|
||||
//|
|
||||
//|
|
||||
STATIC mp_obj_t displayio_parallelbus_obj_send(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
mp_raise_NotImplementedError(translate("displayio is a work in progress"));
|
||||
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_KW(displayio_parallelbus_send_obj, 1, displayio_parallelbus_obj_send);
|
||||
|
||||
STATIC const mp_rom_map_elem_t displayio_parallelbus_locals_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_send), MP_ROM_PTR(&displayio_parallelbus_send_obj) },
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(displayio_parallelbus_locals_dict, displayio_parallelbus_locals_dict_table);
|
||||
|
||||
|
@ -94,7 +94,7 @@ void supervisor_display_move_memory(void) {
|
||||
}
|
||||
uint16_t total_tiles = grid->width_in_tiles * grid->height_in_tiles;
|
||||
|
||||
tilegrid_tiles = allocate_memory(total_tiles, false);
|
||||
tilegrid_tiles = allocate_memory(align32_size(total_tiles), false);
|
||||
if (tilegrid_tiles != NULL) {
|
||||
memcpy(tilegrid_tiles->ptr, grid->tiles, total_tiles);
|
||||
grid->tiles = (uint8_t*) tilegrid_tiles->ptr;
|
||||
|
@ -92,11 +92,12 @@ autogen_usb_descriptor.intermediate: ../../tools/gen_usb_descriptor.py Makefile
|
||||
--output_c_file $(BUILD)/autogen_usb_descriptor.c\
|
||||
--output_h_file $(BUILD)/genhdr/autogen_usb_descriptor.h
|
||||
|
||||
CIRCUITPY_DISPLAY_FONT = "../../tools/Tecate-bitmap-fonts/bitmap/cherry/cherry-10-r.bdf"
|
||||
CIRCUITPY_DISPLAY_FONT = "../../tools/Tecate-bitmap-fonts/bitmap/terminus-font-4.39/ter-u12n.bdf"
|
||||
|
||||
$(BUILD)/autogen_display_resources.c: ../../tools/gen_display_resources.py $(HEADER_BUILD)/qstrdefs.generated.h Makefile | $(HEADER_BUILD)
|
||||
$(STEPECHO) "GEN $@"
|
||||
$(Q)install -d $(BUILD)/genhdr
|
||||
$(Q)$(PYTHON3) ../../tools/gen_display_resources.py \
|
||||
--font $(CIRCUITPY_DISPLAY_FONT) \
|
||||
--sample_file $(HEADER_BUILD)/qstrdefs.generated.h \
|
||||
--output_c_file $(BUILD)/autogen_display_resources.c
|
||||
|
@ -11,7 +11,11 @@ from adafruit_bitmap_font import bitmap_font
|
||||
|
||||
parser = argparse.ArgumentParser(description='Generate USB descriptors.')
|
||||
parser.add_argument('--font', type=str,
|
||||
help='manufacturer of the device', required=True)
|
||||
help='Font path', required=True)
|
||||
parser.add_argument('--extra_characters', type=str,
|
||||
help='Unicode string of extra characters')
|
||||
parser.add_argument('--sample_file', type=argparse.FileType('r'),
|
||||
help='Text file that includes strings to support.')
|
||||
parser.add_argument('--output_c_file', type=argparse.FileType('w'), required=True)
|
||||
|
||||
args = parser.parse_args()
|
||||
@ -25,32 +29,44 @@ class BitmapStub:
|
||||
self.rows[y] = bytes(row)
|
||||
|
||||
f = bitmap_font.load_font(args.font, BitmapStub)
|
||||
f.load_glyphs(range(0x20, 0x7f))
|
||||
|
||||
print(f.get_bounding_box())
|
||||
real_bb = [0, 0]
|
||||
|
||||
# Load extra characters from the sample file.
|
||||
sample_characters = set()
|
||||
if args.sample_file:
|
||||
for line in args.sample_file:
|
||||
# Skip comments because we add additional characters in our huffman comments.
|
||||
if line.startswith("//"):
|
||||
continue
|
||||
for c in line.strip():
|
||||
sample_characters.add(c)
|
||||
|
||||
# Merge visible ascii, sample characters and extra characters.
|
||||
visible_ascii = bytes(range(0x20, 0x7f)).decode("utf-8")
|
||||
extra_characters = "üàêùéáçãÍóíαψ◌"
|
||||
all_characters = visible_ascii + extra_characters
|
||||
all_characters = visible_ascii
|
||||
for c in sample_characters:
|
||||
if c not in all_characters:
|
||||
all_characters += c
|
||||
if args.extra_characters:
|
||||
all_characters.extend(args.extra_characters)
|
||||
filtered_characters = all_characters
|
||||
|
||||
# Try to pre-load all of the glyphs. Misses will still be slow later.
|
||||
f.load_glyphs(set(all_characters))
|
||||
|
||||
# Get each glyph.
|
||||
for c in all_characters:
|
||||
g = f.get_glyph(ord(c))
|
||||
if not g:
|
||||
print("Font missing character:", c, ord(c))
|
||||
filtered_characters = filtered_characters.replace(c, "")
|
||||
extra_characters = extra_characters.replace(c, "")
|
||||
continue
|
||||
x, y, dx, dy = g["bounds"]
|
||||
#print(c, g["bounds"], g["shift"])
|
||||
if g["shift"][1] != 0:
|
||||
raise RuntimeError("y shift")
|
||||
real_bb[0] = max(real_bb[0], x - dx)
|
||||
real_bb[1] = max(real_bb[1], y - dy)
|
||||
|
||||
#real_bb[1] += 1
|
||||
#print(real_bb)
|
||||
|
||||
tile_x, tile_y = real_bb
|
||||
total_bits = tile_x * len(all_characters)
|
||||
total_bits += 32 - total_bits % 32
|
||||
@ -61,7 +77,6 @@ for x, c in enumerate(filtered_characters):
|
||||
g = f.get_glyph(ord(c))
|
||||
start_bit = x * tile_x + g["bounds"][2]
|
||||
start_y = (tile_y - 2) - (g["bounds"][1] + g["bounds"][3])
|
||||
# print(c, g["bounds"], g["shift"], tile_y, start_y)
|
||||
for y, row in enumerate(g["bitmap"].rows):
|
||||
for i in range(g["bounds"][0]):
|
||||
byte = i // 8
|
||||
@ -69,23 +84,12 @@ for x, c in enumerate(filtered_characters):
|
||||
if row[byte] & (1 << (7-bit)) != 0:
|
||||
overall_bit = start_bit + (start_y + y) * bytes_per_row * 8 + i
|
||||
b[overall_bit // 8] |= 1 << (7 - (overall_bit % 8))
|
||||
# print("*",end="")
|
||||
# else:
|
||||
# print("_",end="")
|
||||
#print()
|
||||
|
||||
# print(b)
|
||||
# print("tile_x = {}".format(tile_x))
|
||||
# print("tile_y = {}".format(tile_y))
|
||||
# print("tiles = {}".format(len(all_characters)))
|
||||
# print("font = displayio.Bitmap(tile_x * tiles, tile_y, 2)")
|
||||
# for row in range(tile_y):
|
||||
# print("font._load_row({}, {})".format(row, bytes(b[row*bytes_per_row:row*bytes_per_row+bytes_per_row])))
|
||||
|
||||
# for row in range(tile_y):
|
||||
# for byte in b[row*bytes_per_row:row*bytes_per_row+bytes_per_row]:
|
||||
# print("{:08b} ".format(byte),end="")
|
||||
# print()
|
||||
extra_characters = ""
|
||||
for c in filtered_characters:
|
||||
if c not in visible_ascii:
|
||||
extra_characters += c
|
||||
|
||||
c_file = args.output_c_file
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user