Skip to content

Commit 97b6664

Browse files
committed
re-format with uncrustify
1 parent 542fb58 commit 97b6664

File tree

3 files changed

+198
-165
lines changed

3 files changed

+198
-165
lines changed

shared-bindings/bitmaptools/__init__.c

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
STATIC int16_t validate_point(mp_obj_t point, int16_t default_value) {
4040
// Checks if point is None and returns default_value, otherwise decodes integer value
41-
if ( point == mp_const_none ) {
41+
if (point == mp_const_none) {
4242
return default_value;
4343
}
4444
return mp_obj_get_int(point);
@@ -47,21 +47,21 @@ STATIC int16_t validate_point(mp_obj_t point, int16_t default_value) {
4747
STATIC void extract_tuple(mp_obj_t xy_tuple, int16_t *x, int16_t *y, int16_t x_default, int16_t y_default) {
4848
// Helper function for rotozoom
4949
// Extract x,y values from a tuple or default if None
50-
if ( xy_tuple == mp_const_none ) {
50+
if (xy_tuple == mp_const_none) {
5151
*x = x_default;
5252
*y = y_default;
53-
} else if ( !MP_OBJ_IS_OBJ(xy_tuple) ) {
53+
} else if (!MP_OBJ_IS_OBJ(xy_tuple)) {
5454
mp_raise_ValueError(translate("clip point must be (x,y) tuple"));
5555
} else {
56-
mp_obj_t* items;
56+
mp_obj_t *items;
5757
mp_obj_get_array_fixed_n(xy_tuple, 2, &items);
5858
*x = mp_obj_get_int(items[0]);
5959
*y = mp_obj_get_int(items[1]);
6060
}
6161
}
6262

6363
STATIC void validate_clip_region(displayio_bitmap_t *bitmap, mp_obj_t clip0_tuple, int16_t *clip0_x, int16_t *clip0_y,
64-
mp_obj_t clip1_tuple, int16_t *clip1_x, int16_t *clip1_y) {
64+
mp_obj_t clip1_tuple, int16_t *clip1_x, int16_t *clip1_y) {
6565
// Helper function for rotozoom
6666
// 1. Extract the clip x,y points from the two clip tuples
6767
// 2. Rearrange values such that clip0_ < clip1_
@@ -71,12 +71,12 @@ STATIC void validate_clip_region(displayio_bitmap_t *bitmap, mp_obj_t clip0_tupl
7171
extract_tuple(clip1_tuple, clip1_x, clip1_y, bitmap->width, bitmap->height);
7272

7373
// Ensure the value for clip0 is less than clip1 (for both x and y)
74-
if ( *clip0_x > *clip1_x ) {
74+
if (*clip0_x > *clip1_x) {
7575
int16_t temp_value = *clip0_x; // swap values
7676
*clip0_x = *clip1_x;
7777
*clip1_x = temp_value;
7878
}
79-
if ( *clip0_y > *clip1_y ) {
79+
if (*clip0_y > *clip1_y) {
8080
int16_t temp_value = *clip0_y; // swap values
8181
*clip0_y = *clip1_y;
8282
*clip1_y = temp_value;
@@ -144,11 +144,11 @@ STATIC void validate_clip_region(displayio_bitmap_t *bitmap, mp_obj_t clip0_tupl
144144
//| set to None to copy all pixels"""
145145
//| ...
146146
//|
147-
STATIC mp_obj_t bitmaptools_obj_rotozoom(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args){
147+
STATIC mp_obj_t bitmaptools_obj_rotozoom(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
148148
enum {ARG_dest_bitmap, ARG_source_bitmap,
149-
ARG_ox, ARG_oy, ARG_dest_clip0, ARG_dest_clip1,
150-
ARG_px, ARG_py, ARG_source_clip0, ARG_source_clip1,
151-
ARG_angle, ARG_scale, ARG_skip_index};
149+
ARG_ox, ARG_oy, ARG_dest_clip0, ARG_dest_clip1,
150+
ARG_px, ARG_py, ARG_source_clip0, ARG_source_clip1,
151+
ARG_angle, ARG_scale, ARG_skip_index};
152152

153153
static const mp_arg_t allowed_args[] = {
154154
{MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ},
@@ -166,7 +166,7 @@ STATIC mp_obj_t bitmaptools_obj_rotozoom(size_t n_args, const mp_obj_t *pos_args
166166

167167
{MP_QSTR_angle, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, // None convert to 0.0
168168
{MP_QSTR_scale, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, // None convert to 1.0
169-
{MP_QSTR_skip_index, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj=mp_const_none} },
169+
{MP_QSTR_skip_index, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none} },
170170
};
171171

172172
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
@@ -183,35 +183,35 @@ STATIC mp_obj_t bitmaptools_obj_rotozoom(size_t n_args, const mp_obj_t *pos_args
183183

184184
// Confirm the destination location target (ox,oy); if None, default to bitmap midpoint
185185
int16_t ox, oy;
186-
ox = validate_point(args[ARG_ox].u_obj, destination->width / 2);
186+
ox = validate_point(args[ARG_ox].u_obj, destination->width / 2);
187187
oy = validate_point(args[ARG_oy].u_obj, destination->height / 2);
188188

189189
// Confirm the source location target (px,py); if None, default to bitmap midpoint
190190
int16_t px, py;
191-
px = validate_point(args[ARG_px].u_obj, source->width / 2);
191+
px = validate_point(args[ARG_px].u_obj, source->width / 2);
192192
py = validate_point(args[ARG_py].u_obj, source->height / 2);
193193

194194
// Validate the clipping regions for the destination bitmap
195195
int16_t dest_clip0_x, dest_clip0_y, dest_clip1_x, dest_clip1_y;
196196

197197
validate_clip_region(destination, args[ARG_dest_clip0].u_obj, &dest_clip0_x, &dest_clip0_y,
198-
args[ARG_dest_clip1].u_obj, &dest_clip1_x, &dest_clip1_y);
198+
args[ARG_dest_clip1].u_obj, &dest_clip1_x, &dest_clip1_y);
199199

200200
// Validate the clipping regions for the source bitmap
201201
int16_t source_clip0_x, source_clip0_y, source_clip1_x, source_clip1_y;
202202

203203
validate_clip_region(source, args[ARG_source_clip0].u_obj, &source_clip0_x, &source_clip0_y,
204-
args[ARG_source_clip1].u_obj, &source_clip1_x, &source_clip1_y);
204+
args[ARG_source_clip1].u_obj, &source_clip1_x, &source_clip1_y);
205205

206206
// Confirm the angle value
207-
float angle=0.0;
208-
if ( args[ARG_angle].u_obj != mp_const_none ) {
207+
float angle = 0.0;
208+
if (args[ARG_angle].u_obj != mp_const_none) {
209209
angle = mp_obj_get_float(args[ARG_angle].u_obj);
210210
}
211211

212212
// Confirm the scale value
213-
float scale=1.0;
214-
if ( args[ARG_scale].u_obj != mp_const_none ) {
213+
float scale = 1.0;
214+
if (args[ARG_scale].u_obj != mp_const_none) {
215215
scale = mp_obj_get_float(args[ARG_scale].u_obj);
216216
}
217217
if (scale < 0) { // ensure scale >= 0
@@ -220,7 +220,7 @@ STATIC mp_obj_t bitmaptools_obj_rotozoom(size_t n_args, const mp_obj_t *pos_args
220220

221221
uint32_t skip_index;
222222
bool skip_index_none; // Flag whether input skip_value was None
223-
if (args[ARG_skip_index].u_obj == mp_const_none ) {
223+
if (args[ARG_skip_index].u_obj == mp_const_none) {
224224
skip_index = 0;
225225
skip_index_none = true;
226226
} else {
@@ -229,14 +229,14 @@ STATIC mp_obj_t bitmaptools_obj_rotozoom(size_t n_args, const mp_obj_t *pos_args
229229
}
230230

231231
common_hal_bitmaptools_rotozoom(destination, ox, oy,
232-
dest_clip0_x, dest_clip0_y,
233-
dest_clip1_x, dest_clip1_y,
234-
source, px, py,
235-
source_clip0_x, source_clip0_y,
236-
source_clip1_x, source_clip1_y,
237-
angle,
238-
scale,
239-
skip_index, skip_index_none);
232+
dest_clip0_x, dest_clip0_y,
233+
dest_clip1_x, dest_clip1_y,
234+
source, px, py,
235+
source_clip0_x, source_clip0_y,
236+
source_clip1_x, source_clip1_y,
237+
angle,
238+
scale,
239+
skip_index, skip_index_none);
240240

241241
return mp_const_none;
242242
}
@@ -262,7 +262,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_rotozoom_obj, 0, bitmaptools_obj_rotozoom
262262
//| fill region in the destination bitmap"""
263263
//| ...
264264
//|
265-
STATIC mp_obj_t bitmaptools_obj_fill_region(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args){
265+
STATIC mp_obj_t bitmaptools_obj_fill_region(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
266266
enum {ARG_dest_bitmap, ARG_x1, ARG_y1, ARG_x2, ARG_y2, ARG_value};
267267

268268
static const mp_arg_t allowed_args[] = {
@@ -282,8 +282,8 @@ STATIC mp_obj_t bitmaptools_obj_fill_region(size_t n_args, const mp_obj_t *pos_a
282282
value = args[ARG_value].u_int;
283283
color_depth = (1 << destination->bits_per_value);
284284
if (color_depth <= value) {
285-
mp_raise_ValueError(translate("out of range of target"));
286-
}
285+
mp_raise_ValueError(translate("out of range of target"));
286+
}
287287

288288
int16_t x1 = args[ARG_x1].u_int;
289289
int16_t y1 = args[ARG_y1].u_int;
@@ -315,7 +315,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_fill_region_obj, 0, bitmaptools_obj_fill_
315315
//| line in the destination bitmap"""
316316
//| ...
317317
//|
318-
STATIC mp_obj_t bitmaptools_obj_draw_line(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args){
318+
STATIC mp_obj_t bitmaptools_obj_draw_line(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
319319
enum {ARG_dest_bitmap, ARG_x1, ARG_y1, ARG_x2, ARG_y2, ARG_value};
320320

321321
static const mp_arg_t allowed_args[] = {
@@ -335,18 +335,18 @@ STATIC mp_obj_t bitmaptools_obj_draw_line(size_t n_args, const mp_obj_t *pos_arg
335335
value = args[ARG_value].u_int;
336336
color_depth = (1 << destination->bits_per_value);
337337
if (color_depth <= value) {
338-
mp_raise_ValueError(translate("out of range of target"));
339-
}
338+
mp_raise_ValueError(translate("out of range of target"));
339+
}
340340

341341
int16_t x1 = args[ARG_x1].u_int;
342342
int16_t y1 = args[ARG_y1].u_int;
343343
int16_t x2 = args[ARG_x2].u_int;
344344
int16_t y2 = args[ARG_y2].u_int;
345345

346346
// verify points are within the bitmap boundary (inclusive)
347-
if ( (x1 < 0) || (x2 < 0) || (y1 < 0) || (y2 < 0) ||
348-
(x1 >= destination->width) || (x2 >= destination->width) ||
349-
(y1 >= destination->height) || (y2 >= destination->height) ) {
347+
if ((x1 < 0) || (x2 < 0) || (y1 < 0) || (y2 < 0) ||
348+
(x1 >= destination->width) || (x2 >= destination->width) ||
349+
(y1 >= destination->height) || (y2 >= destination->height)) {
350350
mp_raise_ValueError(translate("out of range of target"));
351351
}
352352

@@ -399,7 +399,7 @@ STATIC mp_obj_t bitmaptools_arrayblit(size_t n_args, const mp_obj_t *pos_args, m
399399
{ MP_QSTR_y2, MP_ARG_INT, {.u_int = -1} },
400400
{ MP_QSTR_skip_index, MP_ARG_OBJ, {.u_obj = mp_const_none } },
401401
}
402-
;
402+
;
403403
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
404404
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
405405

@@ -420,7 +420,7 @@ STATIC mp_obj_t bitmaptools_arrayblit(size_t n_args, const mp_obj_t *pos_args, m
420420
mp_raise_IndexError(translate("pixel coordinates out of bounds"));
421421
}
422422

423-
size_t output_element_count = (x2-x1) * (y2-y1);
423+
size_t output_element_count = (x2 - x1) * (y2 - y1);
424424
size_t element_size = mp_binary_get_size('@', bufinfo.typecode, NULL);
425425
size_t input_element_count = bufinfo.len / element_size;
426426

@@ -477,11 +477,11 @@ STATIC mp_obj_t bitmaptools_readinto(size_t n_args, const mp_obj_t *pos_args, mp
477477
if (!MP_OBJ_IS_TYPE(args[ARG_file].u_obj, &mp_type_fileio)) {
478478
mp_raise_TypeError(NULL);
479479
}
480-
pyb_file_obj_t* file = MP_OBJ_TO_PTR(args[ARG_file].u_obj);
480+
pyb_file_obj_t *file = MP_OBJ_TO_PTR(args[ARG_file].u_obj);
481481

482482
int element_size = args[ARG_element_size].u_int;
483483
if (element_size != 1 && element_size != 2 && element_size != 4) {
484-
mp_raise_ValueError_varg(translate("invalid element_size %d, must be, 1, 2, or 4"), element_size);
484+
mp_raise_ValueError_varg(translate("invalid element_size %d, must be, 1, 2, or 4"), element_size);
485485
}
486486

487487
int bits_per_pixel = args[ARG_bits_per_pixel].u_int;
@@ -523,5 +523,5 @@ STATIC MP_DEFINE_CONST_DICT(bitmaptools_module_globals, bitmaptools_module_globa
523523

524524
const mp_obj_module_t bitmaptools_module = {
525525
.base = {&mp_type_module },
526-
.globals = (mp_obj_dict_t*)&bitmaptools_module_globals,
526+
.globals = (mp_obj_dict_t *)&bitmaptools_module_globals,
527527
};

shared-bindings/bitmaptools/__init__.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,26 @@
3232
#include "extmod/vfs_fat.h"
3333

3434
void common_hal_bitmaptools_rotozoom(displayio_bitmap_t *self, int16_t ox, int16_t oy,
35-
int16_t dest_clip0_x, int16_t dest_clip0_y,
36-
int16_t dest_clip1_x, int16_t dest_clip1_y,
37-
displayio_bitmap_t *source, int16_t px, int16_t py,
38-
int16_t source_clip0_x, int16_t source_clip0_y,
39-
int16_t source_clip1_x, int16_t source_clip1_y,
40-
float angle,
41-
float scale,
42-
uint32_t skip_index, bool skip_index_none);
35+
int16_t dest_clip0_x, int16_t dest_clip0_y,
36+
int16_t dest_clip1_x, int16_t dest_clip1_y,
37+
displayio_bitmap_t *source, int16_t px, int16_t py,
38+
int16_t source_clip0_x, int16_t source_clip0_y,
39+
int16_t source_clip1_x, int16_t source_clip1_y,
40+
float angle,
41+
float scale,
42+
uint32_t skip_index, bool skip_index_none);
4343

4444
void common_hal_bitmaptools_fill_region(displayio_bitmap_t *destination,
45-
int16_t x1, int16_t y1,
46-
int16_t x2, int16_t y2,
47-
uint32_t value);
45+
int16_t x1, int16_t y1,
46+
int16_t x2, int16_t y2,
47+
uint32_t value);
4848

4949
void common_hal_bitmaptools_draw_line(displayio_bitmap_t *destination,
50-
int16_t x0, int16_t y0,
51-
int16_t x1, int16_t y1,
52-
uint32_t value);
50+
int16_t x0, int16_t y0,
51+
int16_t x1, int16_t y1,
52+
uint32_t value);
5353

54-
void common_hal_bitmaptools_readinto(displayio_bitmap_t *self, pyb_file_obj_t* file, int element_size, int bits_per_pixel, bool reverse_pixels_in_word, bool swap_bytes);
54+
void common_hal_bitmaptools_readinto(displayio_bitmap_t *self, pyb_file_obj_t *file, int element_size, int bits_per_pixel, bool reverse_pixels_in_word, bool swap_bytes);
5555
void common_hal_bitmaptools_arrayblit(displayio_bitmap_t *self, void *data, int element_size, int x1, int y1, int x2, int y2, bool skip_specified, uint32_t skip_index);
5656

5757
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_BITMAPTOOLS__INIT__H

0 commit comments

Comments
 (0)