Skip to content

Commit 491e314

Browse files
authored
Merge pull request #3718 from jepler/epd-rotation
EPaperDisplay: add rotation property
2 parents c67f589 + 982bce7 commit 491e314

File tree

28 files changed

+271
-208
lines changed

28 files changed

+271
-208
lines changed

extmod/machine_mem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
STATIC uintptr_t machine_mem_get_addr(mp_obj_t addr_o, uint align) {
2222
uintptr_t addr = mp_obj_int_get_truncated(addr_o);
2323
if ((addr & (align - 1)) != 0) {
24-
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, translate("address %08x is not aligned to %d bytes"), addr, align));
24+
mp_raise_ValueError_varg(translate("address %08x is not aligned to %d bytes"), addr, align);
2525
}
2626
return addr;
2727
}

extmod/moduheapq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_uheapq_heappush_obj, mod_uheapq_heappush);
6262
STATIC mp_obj_t mod_uheapq_heappop(mp_obj_t heap_in) {
6363
mp_obj_list_t *heap = get_heap(heap_in);
6464
if (heap->len == 0) {
65-
nlr_raise(mp_obj_new_exception_msg(&mp_type_IndexError, translate("empty heap")));
65+
mp_raise_IndexError(translate("empty heap"));
6666
}
6767
mp_obj_t item = heap->items[0];
6868
heap->len -= 1;

extmod/modure.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ STATIC mp_obj_t match_group(mp_obj_t self_in, mp_obj_t no_in) {
4343
mp_obj_match_t *self = MP_OBJ_TO_PTR(self_in);
4444
mp_int_t no = mp_obj_get_int(no_in);
4545
if (no < 0 || no >= self->num_matches) {
46-
nlr_raise(mp_obj_new_exception_arg1(&mp_type_IndexError, no_in));
46+
mp_raise_arg1(&mp_type_IndexError, no_in);
4747
}
4848

4949
const char *start = self->caps[no * 2];
@@ -82,7 +82,7 @@ STATIC void match_span_helper(size_t n_args, const mp_obj_t *args, mp_obj_t span
8282
if (n_args == 2) {
8383
no = mp_obj_get_int(args[1]);
8484
if (no < 0 || no >= self->num_matches) {
85-
nlr_raise(mp_obj_new_exception_arg1(&mp_type_IndexError, args[1]));
85+
mp_raise_arg1(&mp_type_IndexError, args[1]);
8686
}
8787
}
8888

@@ -326,7 +326,7 @@ STATIC mp_obj_t re_sub_helper(mp_obj_t self_in, size_t n_args, const mp_obj_t *a
326326
}
327327

328328
if (match_no >= (unsigned int)match->num_matches) {
329-
nlr_raise(mp_obj_new_exception_arg1(&mp_type_IndexError, MP_OBJ_NEW_SMALL_INT(match_no)));
329+
mp_raise_arg1(&mp_type_IndexError, MP_OBJ_NEW_SMALL_INT(match_no));
330330
}
331331

332332
const char *start_match = match->caps[match_no * 2];

extmod/moduzlib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ STATIC mp_obj_t mod_uzlib_decompress(size_t n_args, const mp_obj_t *args) {
179179
return res;
180180

181181
error:
182-
nlr_raise(mp_obj_new_exception_arg1(&mp_type_ValueError, MP_OBJ_NEW_SMALL_INT(st)));
182+
mp_raise_arg1(&mp_type_ValueError, MP_OBJ_NEW_SMALL_INT(st));
183183
}
184184
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_uzlib_decompress_obj, 1, 3, mod_uzlib_decompress);
185185

extmod/vfs_posix_file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ typedef struct _mp_obj_vfs_posix_file_t {
2424
#ifdef MICROPY_CPYTHON_COMPAT
2525
STATIC void check_fd_is_open(const mp_obj_vfs_posix_file_t *o) {
2626
if (o->fd < 0) {
27-
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, translate("I/O operation on closed file")));
27+
mp_raise_ValueError(translate("I/O operation on closed file"));
2828
}
2929
}
3030
#else

ports/atmel-samd/common-hal/audiobusio/PDMIn.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,11 @@ const uint16_t sinc_filter [OVERSAMPLING] = {
337337
94, 63, 39, 21, 9, 2, 0, 0
338338
};
339339

340-
#define REPEAT_16_TIMES(X) X X X X X X X X X X X X X X X X
340+
#ifdef SAMD21
341+
#define REPEAT_16_TIMES(X) do { for(uint8_t j=0; j<4; j++) { X X X X } } while (0)
342+
#else
343+
#define REPEAT_16_TIMES(X) do { X X X X X X X X X X X X X X X X } while(0)
344+
#endif
341345

342346
static uint16_t filter_sample(uint32_t pdm_samples[4]) {
343347
uint16_t running_sum = 0;
@@ -354,7 +358,7 @@ static uint16_t filter_sample(uint32_t pdm_samples[4]) {
354358
filter_ptr++;
355359
pdm_sample <<= 1;
356360
}
357-
)
361+
);
358362
}
359363
return running_sum;
360364
}

ports/unix/modjni.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ STATIC void check_exception(void) {
102102
mp_obj_t py_e = new_jobject(exc);
103103
JJ1(ExceptionClear);
104104
if (JJ(IsInstanceOf, exc, IndexException_class)) {
105-
nlr_raise(mp_obj_new_exception_arg1(&mp_type_IndexError, py_e));
105+
mp_raise_arg1(&mp_type_IndexError, py_e);
106106
}
107-
nlr_raise(mp_obj_new_exception_arg1(&mp_type_Exception, py_e));
107+
mp_raise_arg1(&mp_type_Exception, py_e);
108108
}
109109
}
110110

py/argcheck.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,12 @@ void mp_arg_parse_all(size_t n_pos, const mp_obj_t *pos, mp_map_t *kws, size_t n
9999
mp_map_elem_t *kw = mp_map_lookup(kws, MP_OBJ_NEW_QSTR(allowed[i].qst), MP_MAP_LOOKUP);
100100
if (kw == NULL) {
101101
if (allowed[i].flags & MP_ARG_REQUIRED) {
102-
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
102+
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
103103
mp_arg_error_terse_mismatch();
104-
} else {
104+
#else
105105
mp_raise_TypeError_varg(
106106
translate("'%q' argument required"), allowed[i].qst);
107-
}
107+
#endif
108108
}
109109
out_vals[i] = allowed[i].defval;
110110
continue;
@@ -124,20 +124,20 @@ void mp_arg_parse_all(size_t n_pos, const mp_obj_t *pos, mp_map_t *kws, size_t n
124124
}
125125
if (pos_found < n_pos) {
126126
extra_positional:
127-
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
127+
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
128128
mp_arg_error_terse_mismatch();
129-
} else {
129+
#else
130130
// TODO better error message
131131
mp_raise_TypeError(translate("extra positional arguments given"));
132-
}
132+
#endif
133133
}
134134
if (kws_found < kws->used) {
135-
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
135+
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
136136
mp_arg_error_terse_mismatch();
137-
} else {
137+
#else
138138
// TODO better error message
139139
mp_raise_TypeError(translate("extra keyword arguments given"));
140-
}
140+
#endif
141141
}
142142
}
143143

py/bc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,8 @@ void mp_setup_code_state(mp_code_state_t *code_state, size_t n_args, size_t n_kw
214214
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
215215
mp_raise_TypeError(translate("unexpected keyword argument"));
216216
#else
217-
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError,
218-
translate("unexpected keyword argument '%q'"), MP_OBJ_QSTR_VALUE(wanted_arg_name)));
217+
mp_raise_TypeError_varg(
218+
translate("unexpected keyword argument '%q'"), MP_OBJ_QSTR_VALUE(wanted_arg_name));
219219
#endif
220220
}
221221
mp_obj_dict_store(dict, kwargs[2 * i], kwargs[2 * i + 1]);

py/builtinimport.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -426,12 +426,12 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) {
426426
mp_module_call_init(mod_name, module_obj);
427427
} else {
428428
// couldn't find the file, so fail
429-
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
429+
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
430430
mp_raise_ImportError(translate("module not found"));
431-
} else {
431+
#else
432432
mp_raise_msg_varg(&mp_type_ImportError,
433433
translate("no module named '%q'"), mod_name);
434-
}
434+
#endif
435435
}
436436
} else {
437437
// found the file, so get the module
@@ -538,12 +538,12 @@ mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) {
538538
#endif
539539

540540
// Couldn't find the module, so fail
541-
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
541+
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
542542
mp_raise_msg(&mp_type_ImportError, translate("module not found"));
543-
} else {
543+
#else
544544
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ImportError,
545545
translate("no module named '%q'"), module_name_qstr));
546-
}
546+
#endif
547547
}
548548

549549
#endif // MICROPY_ENABLE_EXTERNAL_IMPORT

py/compile.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2486,21 +2486,21 @@ STATIC void compile_atom_brace(compiler_t *comp, mp_parse_node_struct_t *pns) {
24862486
compile_node(comp, pn_i);
24872487
if (is_dict) {
24882488
if (!is_key_value) {
2489-
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
2489+
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
24902490
compile_syntax_error(comp, (mp_parse_node_t)pns, translate("invalid syntax"));
2491-
} else {
2491+
#else
24922492
compile_syntax_error(comp, (mp_parse_node_t)pns, translate("expecting key:value for dict"));
2493-
}
2493+
#endif
24942494
return;
24952495
}
24962496
EMIT(store_map);
24972497
} else {
24982498
if (is_key_value) {
2499-
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
2499+
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
25002500
compile_syntax_error(comp, (mp_parse_node_t)pns, translate("invalid syntax"));
2501-
} else {
2501+
#else
25022502
compile_syntax_error(comp, (mp_parse_node_t)pns, translate("expecting just a value for set"));
2503-
}
2503+
#endif
25042504
return;
25052505
}
25062506
}

py/modbuiltins.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,12 +346,12 @@ STATIC mp_obj_t mp_builtin_ord(mp_obj_t o_in) {
346346
}
347347
}
348348

349-
if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
349+
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
350350
mp_raise_TypeError(translate("ord expects a character"));
351-
} else {
351+
#else
352352
mp_raise_TypeError_varg(
353353
translate("ord() expected a character, but string of length %d found"), (int)len);
354-
}
354+
#endif
355355
}
356356
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_ord_obj, mp_builtin_ord);
357357

py/modsys.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,11 @@ STATIC const MP_DEFINE_STR_OBJ(platform_obj, MICROPY_PY_SYS_PLATFORM);
9292

9393
// exit([retval]): raise SystemExit, with optional argument given to the exception
9494
STATIC mp_obj_t mp_sys_exit(size_t n_args, const mp_obj_t *args) {
95-
mp_obj_t exc;
9695
if (n_args == 0) {
97-
exc = mp_obj_new_exception(&mp_type_SystemExit);
96+
nlr_raise(mp_obj_new_exception(&mp_type_SystemExit));
9897
} else {
99-
exc = mp_obj_new_exception_arg1(&mp_type_SystemExit, args[0]);
98+
mp_raise_arg1(&mp_type_SystemExit, args[0]);
10099
}
101-
nlr_raise(exc);
102100
}
103101
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_sys_exit_obj, 0, 1, mp_sys_exit);
104102

0 commit comments

Comments
 (0)