diff options
Diffstat (limited to 'shared-bindings')
254 files changed, 1462 insertions, 1426 deletions
diff --git a/shared-bindings/_bleio/Adapter.c b/shared-bindings/_bleio/Adapter.c index 81277fd70..5cacfa069 100644 --- a/shared-bindings/_bleio/Adapter.c +++ b/shared-bindings/_bleio/Adapter.c @@ -82,7 +82,7 @@ //| ... //| STATIC mp_obj_t bleio_adapter_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { -#if CIRCUITPY_BLEIO_HCI + #if CIRCUITPY_BLEIO_HCI bleio_adapter_obj_t *self = common_hal_bleio_allocate_adapter_or_raise(); enum { ARG_uart, ARG_rts, ARG_cts }; @@ -111,10 +111,10 @@ STATIC mp_obj_t bleio_adapter_make_new(const mp_obj_type_t *type, size_t n_args, common_hal_bleio_adapter_construct_hci_uart(self, uart, rts, cts); return MP_OBJ_FROM_PTR(self); -#else + #else mp_raise_NotImplementedError(translate("Cannot create a new Adapter; use _bleio.adapter;")); return mp_const_none; -#endif // CIRCUITPY_BLEIO_HCI + #endif // CIRCUITPY_BLEIO_HCI } //| @@ -240,7 +240,7 @@ STATIC mp_obj_t bleio_adapter_start_advertising(mp_uint_t n_args, const mp_obj_t const mp_float_t interval = mp_obj_get_float(args[ARG_interval].u_obj); if (interval < ADV_INTERVAL_MIN || interval > ADV_INTERVAL_MAX) { mp_raise_ValueError_varg(translate("interval must be in range %s-%s"), - ADV_INTERVAL_MIN_STRING, ADV_INTERVAL_MAX_STRING); + ADV_INTERVAL_MIN_STRING, ADV_INTERVAL_MAX_STRING); } bool connectable = args[ARG_connectable].u_bool; @@ -251,7 +251,7 @@ STATIC mp_obj_t bleio_adapter_start_advertising(mp_uint_t n_args, const mp_obj_t } common_hal_bleio_adapter_start_advertising(self, connectable, anonymous, timeout, interval, - &data_bufinfo, &scan_response_bufinfo); + &data_bufinfo, &scan_response_bufinfo); return mp_const_none; } @@ -325,12 +325,12 @@ STATIC mp_obj_t bleio_adapter_start_scan(size_t n_args, const mp_obj_t *pos_args mp_raise_ValueError_varg(translate("interval must be in range %s-%s"), INTERVAL_MIN_STRING, INTERVAL_MAX_STRING); } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wfloat-equal" + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wfloat-equal" if (timeout != 0.0f && timeout < interval) { mp_raise_ValueError(translate("non-zero timeout must be >= interval")); } -#pragma GCC diagnostic pop + #pragma GCC diagnostic pop const mp_float_t window = mp_obj_get_float(args[ARG_window].u_obj); if (window > interval) { diff --git a/shared-bindings/_bleio/Adapter.h b/shared-bindings/_bleio/Adapter.h index ac7e216d8..81b9ec313 100644 --- a/shared-bindings/_bleio/Adapter.h +++ b/shared-bindings/_bleio/Adapter.h @@ -48,15 +48,15 @@ extern bool common_hal_bleio_adapter_get_connected(bleio_adapter_obj_t *self); extern bleio_address_obj_t *common_hal_bleio_adapter_get_address(bleio_adapter_obj_t *self); extern bool common_hal_bleio_adapter_set_address(bleio_adapter_obj_t *self, bleio_address_obj_t *address); -extern mp_obj_str_t* common_hal_bleio_adapter_get_name(bleio_adapter_obj_t *self); -extern void common_hal_bleio_adapter_set_name(bleio_adapter_obj_t *self, const char* name); +extern mp_obj_str_t *common_hal_bleio_adapter_get_name(bleio_adapter_obj_t *self); +extern void common_hal_bleio_adapter_set_name(bleio_adapter_obj_t *self, const char *name); extern uint32_t _common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, bool connectable, bool anonymous, uint32_t timeout, float interval, uint8_t *advertising_data, uint16_t advertising_data_len, uint8_t *scan_response_data, uint16_t scan_response_data_len); extern void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, bool connectable, bool anonymous, uint32_t timeout, mp_float_t interval, mp_buffer_info_t *advertising_data_bufinfo, mp_buffer_info_t *scan_response_data_bufinfo); extern void common_hal_bleio_adapter_stop_advertising(bleio_adapter_obj_t *self); -extern mp_obj_t common_hal_bleio_adapter_start_scan(bleio_adapter_obj_t *self, uint8_t* prefixes, size_t prefix_length, bool extended, mp_int_t buffer_size, mp_float_t timeout, mp_float_t interval, mp_float_t window, mp_int_t minimum_rssi, bool active); +extern mp_obj_t common_hal_bleio_adapter_start_scan(bleio_adapter_obj_t *self, uint8_t *prefixes, size_t prefix_length, bool extended, mp_int_t buffer_size, mp_float_t timeout, mp_float_t interval, mp_float_t window, mp_int_t minimum_rssi, bool active); extern void common_hal_bleio_adapter_stop_scan(bleio_adapter_obj_t *self); extern bool common_hal_bleio_adapter_get_connected(bleio_adapter_obj_t *self); diff --git a/shared-bindings/_bleio/Address.c b/shared-bindings/_bleio/Address.c index 04c667db4..56e8a013f 100644 --- a/shared-bindings/_bleio/Address.c +++ b/shared-bindings/_bleio/Address.c @@ -141,7 +141,7 @@ STATIC mp_obj_t bleio_address_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_o bleio_address_obj_t *rhs = MP_OBJ_TO_PTR(rhs_in); return mp_obj_new_bool( mp_obj_equal(common_hal_bleio_address_get_address_bytes(lhs), - common_hal_bleio_address_get_address_bytes(rhs)) && + common_hal_bleio_address_get_address_bytes(rhs)) && common_hal_bleio_address_get_type(lhs) == common_hal_bleio_address_get_type(rhs)); @@ -182,9 +182,9 @@ STATIC void bleio_address_print(const mp_print_t *print, mp_obj_t self_in, mp_pr mp_obj_t address_bytes = common_hal_bleio_address_get_address_bytes(self); mp_get_buffer_raise(address_bytes, &buf_info, MP_BUFFER_READ); - const uint8_t *buf = (uint8_t *) buf_info.buf; + const uint8_t *buf = (uint8_t *)buf_info.buf; mp_printf(print, "<Address %02x:%02x:%02x:%02x:%02x:%02x>", - buf[5], buf[4], buf[3], buf[2], buf[1], buf[0]); + buf[5], buf[4], buf[3], buf[2], buf[1], buf[0]); } //| PUBLIC: int @@ -220,5 +220,5 @@ const mp_obj_type_t bleio_address_type = { .print = bleio_address_print, .unary_op = bleio_address_unary_op, .binary_op = bleio_address_binary_op, - .locals_dict = (mp_obj_dict_t*)&bleio_address_locals_dict + .locals_dict = (mp_obj_dict_t *)&bleio_address_locals_dict }; diff --git a/shared-bindings/_bleio/Attribute.c b/shared-bindings/_bleio/Attribute.c index 2c144c71b..d639f2a42 100644 --- a/shared-bindings/_bleio/Attribute.c +++ b/shared-bindings/_bleio/Attribute.c @@ -78,5 +78,5 @@ STATIC MP_DEFINE_CONST_DICT(bleio_attribute_locals_dict, bleio_attribute_locals_ const mp_obj_type_t bleio_attribute_type = { { &mp_type_type }, .name = MP_QSTR_Attribute, - .locals_dict = (mp_obj_dict_t*)&bleio_attribute_locals_dict, + .locals_dict = (mp_obj_dict_t *)&bleio_attribute_locals_dict, }; diff --git a/shared-bindings/_bleio/Characteristic.c b/shared-bindings/_bleio/Characteristic.c index a0751b7e3..0aa832cf2 100644 --- a/shared-bindings/_bleio/Characteristic.c +++ b/shared-bindings/_bleio/Characteristic.c @@ -77,12 +77,12 @@ STATIC mp_obj_t bleio_characteristic_add_to_service(size_t n_args, const mp_obj_ static const mp_arg_t allowed_args[] = { { MP_QSTR_service, MP_ARG_REQUIRED | MP_ARG_OBJ }, { MP_QSTR_uuid, MP_ARG_REQUIRED | MP_ARG_OBJ }, - { MP_QSTR_properties, MP_ARG_KW_ONLY| MP_ARG_INT, {.u_int = 0} }, - { MP_QSTR_read_perm, MP_ARG_KW_ONLY| MP_ARG_INT, {.u_int = SECURITY_MODE_OPEN} }, - { MP_QSTR_write_perm, MP_ARG_KW_ONLY| MP_ARG_INT, {.u_int = SECURITY_MODE_OPEN} }, - { MP_QSTR_max_length, MP_ARG_KW_ONLY| MP_ARG_INT, {.u_int = 20} }, - { MP_QSTR_fixed_length, MP_ARG_KW_ONLY| MP_ARG_BOOL, {.u_bool = false} }, - { MP_QSTR_initial_value, MP_ARG_KW_ONLY| MP_ARG_OBJ, {.u_obj = mp_const_none} }, + { MP_QSTR_properties, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, + { MP_QSTR_read_perm, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = SECURITY_MODE_OPEN} }, + { MP_QSTR_write_perm, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = SECURITY_MODE_OPEN} }, + { MP_QSTR_max_length, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 20} }, + { MP_QSTR_fixed_length, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} }, + { MP_QSTR_initial_value, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; @@ -113,8 +113,8 @@ STATIC mp_obj_t bleio_characteristic_add_to_service(size_t n_args, const mp_obj_ if (max_length_int < 0) { mp_raise_ValueError(translate("max_length must be >= 0")); } - const size_t max_length = (size_t) max_length_int; - const bool fixed_length = args[ARG_fixed_length].u_bool; + const size_t max_length = (size_t)max_length_int; + const bool fixed_length = args[ARG_fixed_length].u_bool; mp_obj_t initial_value = args[ARG_initial_value].u_obj; mp_buffer_info_t initial_value_bufinfo; @@ -129,7 +129,7 @@ STATIC mp_obj_t bleio_characteristic_add_to_service(size_t n_args, const mp_obj_ mp_get_buffer_raise(initial_value, &initial_value_bufinfo, MP_BUFFER_READ); if (initial_value_bufinfo.len > max_length || (fixed_length && initial_value_bufinfo.len != max_length)) { - mp_raise_ValueError(translate("initial_value length is wrong")); + mp_raise_ValueError(translate("initial_value length is wrong")); } bleio_characteristic_obj_t *characteristic = m_new_obj(bleio_characteristic_obj_t); @@ -330,5 +330,5 @@ const mp_obj_type_t bleio_characteristic_type = { { &mp_type_type }, .name = MP_QSTR_Characteristic, .print = bleio_characteristic_print, - .locals_dict = (mp_obj_dict_t*)&bleio_characteristic_locals_dict, + .locals_dict = (mp_obj_dict_t *)&bleio_characteristic_locals_dict, }; diff --git a/shared-bindings/_bleio/Characteristic.h b/shared-bindings/_bleio/Characteristic.h index e28d61e1f..a8486866f 100644 --- a/shared-bindings/_bleio/Characteristic.h +++ b/shared-bindings/_bleio/Characteristic.h @@ -40,7 +40,7 @@ extern bleio_characteristic_properties_t common_hal_bleio_characteristic_get_pro extern mp_obj_tuple_t *common_hal_bleio_characteristic_get_descriptors(bleio_characteristic_obj_t *self); extern bleio_service_obj_t *common_hal_bleio_characteristic_get_service(bleio_characteristic_obj_t *self); extern bleio_uuid_obj_t *common_hal_bleio_characteristic_get_uuid(bleio_characteristic_obj_t *self); -extern size_t common_hal_bleio_characteristic_get_value(bleio_characteristic_obj_t *self, uint8_t* buf, size_t len); +extern size_t common_hal_bleio_characteristic_get_value(bleio_characteristic_obj_t *self, uint8_t *buf, size_t len); extern void common_hal_bleio_characteristic_add_descriptor(bleio_characteristic_obj_t *self, bleio_descriptor_obj_t *descriptor); extern void common_hal_bleio_characteristic_construct(bleio_characteristic_obj_t *self, bleio_service_obj_t *service, uint16_t handle, bleio_uuid_obj_t *uuid, bleio_characteristic_properties_t props, bleio_attribute_security_mode_t read_perm, bleio_attribute_security_mode_t write_perm, mp_int_t max_length, bool fixed_length, mp_buffer_info_t *initial_value_bufinfo); extern void common_hal_bleio_characteristic_set_cccd(bleio_characteristic_obj_t *self, bool notify, bool indicate); diff --git a/shared-bindings/_bleio/CharacteristicBuffer.c b/shared-bindings/_bleio/CharacteristicBuffer.c index 333b275ff..ddc0c4225 100644 --- a/shared-bindings/_bleio/CharacteristicBuffer.c +++ b/shared-bindings/_bleio/CharacteristicBuffer.c @@ -243,5 +243,5 @@ const mp_obj_type_t bleio_characteristic_buffer_type = { .getiter = mp_identity_getiter, .iternext = mp_stream_unbuffered_iter, .protocol = &characteristic_buffer_stream_p, - .locals_dict = (mp_obj_dict_t*)&bleio_characteristic_buffer_locals_dict + .locals_dict = (mp_obj_dict_t *)&bleio_characteristic_buffer_locals_dict }; diff --git a/shared-bindings/_bleio/Connection.c b/shared-bindings/_bleio/Connection.c index fe82af098..b714f42df 100644 --- a/shared-bindings/_bleio/Connection.c +++ b/shared-bindings/_bleio/Connection.c @@ -146,8 +146,8 @@ STATIC mp_obj_t bleio_connection_discover_remote_services(mp_uint_t n_args, cons bleio_connection_ensure_connected(self); return MP_OBJ_FROM_PTR(common_hal_bleio_connection_discover_remote_services( - self, - args[ARG_service_uuids_whitelist].u_obj)); + self, + args[ARG_service_uuids_whitelist].u_obj)); } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_connection_discover_remote_services_obj, 1, bleio_connection_discover_remote_services); @@ -267,6 +267,6 @@ STATIC MP_DEFINE_CONST_DICT(bleio_connection_locals_dict, bleio_connection_local const mp_obj_type_t bleio_connection_type = { { &mp_type_type }, .name = MP_QSTR_Connection, - .locals_dict = (mp_obj_dict_t*)&bleio_connection_locals_dict, + .locals_dict = (mp_obj_dict_t *)&bleio_connection_locals_dict, .unary_op = mp_generic_unary_op, }; diff --git a/shared-bindings/_bleio/Descriptor.c b/shared-bindings/_bleio/Descriptor.c index 60f0acf44..0eee9d704 100644 --- a/shared-bindings/_bleio/Descriptor.c +++ b/shared-bindings/_bleio/Descriptor.c @@ -74,11 +74,11 @@ STATIC mp_obj_t bleio_descriptor_add_to_characteristic(size_t n_args, const mp_o static const mp_arg_t allowed_args[] = { { MP_QSTR_characteristic, MP_ARG_REQUIRED | MP_ARG_OBJ }, { MP_QSTR_uuid, MP_ARG_REQUIRED | MP_ARG_OBJ }, - { MP_QSTR_read_perm, MP_ARG_KW_ONLY| MP_ARG_INT, {.u_int = SECURITY_MODE_OPEN} }, - { MP_QSTR_write_perm, MP_ARG_KW_ONLY| MP_ARG_INT, {.u_int = SECURITY_MODE_OPEN} }, - { MP_QSTR_max_length, MP_ARG_KW_ONLY| MP_ARG_INT, {.u_int = 20} }, - { MP_QSTR_fixed_length, MP_ARG_KW_ONLY| MP_ARG_BOOL, {.u_bool = false} }, - { MP_QSTR_initial_value, MP_ARG_KW_ONLY| MP_ARG_OBJ, {.u_obj = mp_const_empty_bytes} }, + { MP_QSTR_read_perm, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = SECURITY_MODE_OPEN} }, + { MP_QSTR_write_perm, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = SECURITY_MODE_OPEN} }, + { MP_QSTR_max_length, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 20} }, + { MP_QSTR_fixed_length, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} }, + { MP_QSTR_initial_value, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_empty_bytes} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; @@ -104,8 +104,8 @@ STATIC mp_obj_t bleio_descriptor_add_to_characteristic(size_t n_args, const mp_o if (max_length_int < 0) { mp_raise_ValueError(translate("max_length must be >= 0")); } - const size_t max_length = (size_t) max_length_int; - const bool fixed_length = args[ARG_fixed_length].u_bool; + const size_t max_length = (size_t)max_length_int; + const bool fixed_length = args[ARG_fixed_length].u_bool; mp_obj_t initial_value = args[ARG_initial_value].u_obj; mp_buffer_info_t initial_value_bufinfo; @@ -119,7 +119,7 @@ STATIC mp_obj_t bleio_descriptor_add_to_characteristic(size_t n_args, const mp_o mp_get_buffer_raise(initial_value, &initial_value_bufinfo, MP_BUFFER_READ); if (initial_value_bufinfo.len > max_length || (fixed_length && initial_value_bufinfo.len != max_length)) { - mp_raise_ValueError(translate("initial_value length is wrong")); + mp_raise_ValueError(translate("initial_value length is wrong")); } bleio_descriptor_obj_t *descriptor = m_new_obj(bleio_descriptor_obj_t); @@ -229,5 +229,5 @@ const mp_obj_type_t bleio_descriptor_type = { { &mp_type_type }, .name = MP_QSTR_Descriptor, .print = bleio_descriptor_print, - .locals_dict = (mp_obj_dict_t*)&bleio_descriptor_locals_dict + .locals_dict = (mp_obj_dict_t *)&bleio_descriptor_locals_dict }; diff --git a/shared-bindings/_bleio/Descriptor.h b/shared-bindings/_bleio/Descriptor.h index 273cb1c1e..bda381e3d 100644 --- a/shared-bindings/_bleio/Descriptor.h +++ b/shared-bindings/_bleio/Descriptor.h @@ -38,7 +38,7 @@ extern const mp_obj_type_t bleio_descriptor_type; extern void common_hal_bleio_descriptor_construct(bleio_descriptor_obj_t *self, bleio_characteristic_obj_t *characteristic, bleio_uuid_obj_t *uuid, bleio_attribute_security_mode_t read_perm, bleio_attribute_security_mode_t write_perm, mp_int_t max_length, bool fixed_length, mp_buffer_info_t *initial_value_bufinfo); extern bleio_uuid_obj_t *common_hal_bleio_descriptor_get_uuid(bleio_descriptor_obj_t *self); extern bleio_characteristic_obj_t *common_hal_bleio_descriptor_get_characteristic(bleio_descriptor_obj_t *self); -extern size_t common_hal_bleio_descriptor_get_value(bleio_descriptor_obj_t *self, uint8_t* buf, size_t len); +extern size_t common_hal_bleio_descriptor_get_value(bleio_descriptor_obj_t *self, uint8_t *buf, size_t len); extern void common_hal_bleio_descriptor_set_value(bleio_descriptor_obj_t *self, mp_buffer_info_t *bufinfo); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_DESCRIPTOR_H diff --git a/shared-bindings/_bleio/PacketBuffer.c b/shared-bindings/_bleio/PacketBuffer.c index f2a3cbce0..16ad02a46 100644 --- a/shared-bindings/_bleio/PacketBuffer.c +++ b/shared-bindings/_bleio/PacketBuffer.c @@ -247,5 +247,5 @@ const mp_obj_type_t bleio_packet_buffer_type = { { &mp_type_type }, .name = MP_QSTR_PacketBuffer, .make_new = bleio_packet_buffer_make_new, - .locals_dict = (mp_obj_dict_t*)&bleio_packet_buffer_locals_dict + .locals_dict = (mp_obj_dict_t *)&bleio_packet_buffer_locals_dict }; diff --git a/shared-bindings/_bleio/PacketBuffer.h b/shared-bindings/_bleio/PacketBuffer.h index 769e0a0c7..65ce3ded1 100644 --- a/shared-bindings/_bleio/PacketBuffer.h +++ b/shared-bindings/_bleio/PacketBuffer.h @@ -34,7 +34,7 @@ extern const mp_obj_type_t bleio_packet_buffer_type; extern void common_hal_bleio_packet_buffer_construct( bleio_packet_buffer_obj_t *self, bleio_characteristic_obj_t *characteristic, size_t buffer_size); -mp_int_t common_hal_bleio_packet_buffer_write(bleio_packet_buffer_obj_t *self, uint8_t *data, size_t len, uint8_t* header, size_t header_len); +mp_int_t common_hal_bleio_packet_buffer_write(bleio_packet_buffer_obj_t *self, uint8_t *data, size_t len, uint8_t *header, size_t header_len); mp_int_t common_hal_bleio_packet_buffer_readinto(bleio_packet_buffer_obj_t *self, uint8_t *data, size_t len); mp_int_t common_hal_bleio_packet_buffer_get_incoming_packet_length(bleio_packet_buffer_obj_t *self); mp_int_t common_hal_bleio_packet_buffer_get_outgoing_packet_length(bleio_packet_buffer_obj_t *self); diff --git a/shared-bindings/_bleio/ScanEntry.c b/shared-bindings/_bleio/ScanEntry.c index 4f0789019..5692e3db2 100644 --- a/shared-bindings/_bleio/ScanEntry.c +++ b/shared-bindings/_bleio/ScanEntry.c @@ -164,5 +164,5 @@ STATIC MP_DEFINE_CONST_DICT(bleio_scanentry_locals_dict, bleio_scanentry_locals_ const mp_obj_type_t bleio_scanentry_type = { { &mp_type_type }, .name = MP_QSTR_ScanEntry, - .locals_dict = (mp_obj_dict_t*)&bleio_scanentry_locals_dict + .locals_dict = (mp_obj_dict_t *)&bleio_scanentry_locals_dict }; diff --git a/shared-bindings/_bleio/ScanEntry.h b/shared-bindings/_bleio/ScanEntry.h index 9aeaf20d3..b37cb6109 100644 --- a/shared-bindings/_bleio/ScanEntry.h +++ b/shared-bindings/_bleio/ScanEntry.h @@ -39,6 +39,6 @@ mp_obj_t common_hal_bleio_scanentry_get_advertisement_bytes(bleio_scanentry_obj_ mp_int_t common_hal_bleio_scanentry_get_rssi(bleio_scanentry_obj_t *self); bool common_hal_bleio_scanentry_get_connectable(bleio_scanentry_obj_t *self); bool common_hal_bleio_scanentry_get_scan_response(bleio_scanentry_obj_t *self); -bool common_hal_bleio_scanentry_matches(bleio_scanentry_obj_t *self, uint8_t* prefixes, size_t prefixes_len, bool all); +bool common_hal_bleio_scanentry_matches(bleio_scanentry_obj_t *self, uint8_t *prefixes, size_t prefixes_len, bool all); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_SCANENTRY_H diff --git a/shared-bindings/_bleio/Service.c b/shared-bindings/_bleio/Service.c index 2ddf1a712..6657c7e73 100644 --- a/shared-bindings/_bleio/Service.c +++ b/shared-bindings/_bleio/Service.c @@ -169,5 +169,5 @@ const mp_obj_type_t bleio_service_type = { .name = MP_QSTR_Service, .make_new = bleio_service_make_new, .print = bleio_service_print, - .locals_dict = (mp_obj_dict_t*)&bleio_service_locals_dict + .locals_dict = (mp_obj_dict_t *)&bleio_service_locals_dict }; diff --git a/shared-bindings/_bleio/Service.h b/shared-bindings/_bleio/Service.h index 44d11f60d..b2a35793f 100644 --- a/shared-bindings/_bleio/Service.h +++ b/shared-bindings/_bleio/Service.h @@ -37,9 +37,9 @@ extern const mp_obj_type_t bleio_service_type; // Private version that doesn't allocate on the heap -extern uint32_t _common_hal_bleio_service_construct(bleio_service_obj_t *self, bleio_uuid_obj_t *uuid, bool is_secondary, mp_obj_list_t * characteristic_list); +extern uint32_t _common_hal_bleio_service_construct(bleio_service_obj_t *self, bleio_uuid_obj_t *uuid, bool is_secondary, mp_obj_list_t *characteristic_list); extern void common_hal_bleio_service_construct(bleio_service_obj_t *self, bleio_uuid_obj_t *uuid, bool is_secondary); -extern void common_hal_bleio_service_from_remote_service(bleio_service_obj_t *self, bleio_connection_obj_t* connection, bleio_uuid_obj_t *uuid, bool is_secondary); +extern void common_hal_bleio_service_from_remote_service(bleio_service_obj_t *self, bleio_connection_obj_t *connection, bleio_uuid_obj_t *uuid, bool is_secondary); extern bleio_uuid_obj_t *common_hal_bleio_service_get_uuid(bleio_service_obj_t *self); extern mp_obj_tuple_t *common_hal_bleio_service_get_characteristics(bleio_service_obj_t *self); extern bool common_hal_bleio_service_get_is_remote(bleio_service_obj_t *self); diff --git a/shared-bindings/_bleio/UUID.c b/shared-bindings/_bleio/UUID.c index fe045f385..2da54c1d5 100644 --- a/shared-bindings/_bleio/UUID.c +++ b/shared-bindings/_bleio/UUID.c @@ -228,23 +228,23 @@ STATIC MP_DEFINE_CONST_DICT(bleio_uuid_locals_dict, bleio_uuid_locals_dict_table STATIC mp_obj_t bleio_uuid_unary_op(mp_unary_op_t op, mp_obj_t self_in) { bleio_uuid_obj_t *self = MP_OBJ_TO_PTR(self_in); switch (op) { - case MP_UNARY_OP_HASH: - if (common_hal_bleio_uuid_get_size(self) == 16) { - return MP_OBJ_NEW_SMALL_INT(common_hal_bleio_uuid_get_uuid16(self)); - } else { - union { - uint8_t uuid128_bytes[16]; - uint16_t uuid128_uint16[8]; - } uuid128; - common_hal_bleio_uuid_get_uuid128(self, uuid128.uuid128_bytes); - int hash = 0; - for (size_t i = 0; i < MP_ARRAY_SIZE(uuid128.uuid128_uint16); i++) { - hash += uuid128.uuid128_uint16[i]; + case MP_UNARY_OP_HASH: + if (common_hal_bleio_uuid_get_size(self) == 16) { + return MP_OBJ_NEW_SMALL_INT(common_hal_bleio_uuid_get_uuid16(self)); + } else { + union { + uint8_t uuid128_bytes[16]; + uint16_t uuid128_uint16[8]; + } uuid128; + common_hal_bleio_uuid_get_uuid128(self, uuid128.uuid128_bytes); + int hash = 0; + for (size_t i = 0; i < MP_ARRAY_SIZE(uuid128.uuid128_uint16); i++) { + hash += uuid128.uuid128_uint16[i]; + } + return MP_OBJ_NEW_SMALL_INT(hash); } - return MP_OBJ_NEW_SMALL_INT(hash); - } - default: - return MP_OBJ_NULL; // op not supported + default: + return MP_OBJ_NULL; // op not supported } } @@ -260,7 +260,7 @@ STATIC mp_obj_t bleio_uuid_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_ if (common_hal_bleio_uuid_get_size(lhs_in) == 16 && common_hal_bleio_uuid_get_size(rhs_in) == 16) { return mp_obj_new_bool(common_hal_bleio_uuid_get_uuid16(lhs_in) == - common_hal_bleio_uuid_get_uuid16(rhs_in)); + common_hal_bleio_uuid_get_uuid16(rhs_in)); } uint8_t lhs[16]; uint8_t rhs[16]; @@ -285,16 +285,16 @@ void bleio_uuid_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t uint8_t uuid128[16]; common_hal_bleio_uuid_get_uuid128(self, uuid128); mp_printf(print, "UUID('" - "%02x%02x%02x%02x-" - "%02x%02x-" - "%02x%02x-" - "%02x%02x-" - "%02x%02x%02x%02x%02x%02x')", - uuid128[15], uuid128[14], uuid128[13], uuid128[12], - uuid128[11], uuid128[10], - uuid128[9], uuid128[8], - uuid128[7], uuid128[6], - uuid128[5], uuid128[4], uuid128[3], uuid128[2], uuid128[1], uuid128[0]); + "%02x%02x%02x%02x-" + "%02x%02x-" + "%02x%02x-" + "%02x%02x-" + "%02x%02x%02x%02x%02x%02x')", + uuid128[15], uuid128[14], uuid128[13], uuid128[12], + uuid128[11], uuid128[10], + uuid128[9], uuid128[8], + uuid128[7], uuid128[6], + uuid128[5], uuid128[4], uuid128[3], uuid128[2], uuid128[1], uuid128[0]); } } @@ -305,5 +305,5 @@ const mp_obj_type_t bleio_uuid_type = { .make_new = bleio_uuid_make_new, .unary_op = bleio_uuid_unary_op, .binary_op = bleio_uuid_binary_op, - .locals_dict = (mp_obj_dict_t*)&bleio_uuid_locals_dict, + .locals_dict = (mp_obj_dict_t *)&bleio_uuid_locals_dict, }; diff --git a/shared-bindings/_bleio/UUID.h b/shared-bindings/_bleio/UUID.h index b10cce67f..d07e90380 100644 --- a/shared-bindings/_bleio/UUID.h +++ b/shared-bindings/_bleio/UUID.h @@ -39,6 +39,6 @@ extern uint32_t common_hal_bleio_uuid_get_uuid16(bleio_uuid_obj_t *self); extern void common_hal_bleio_uuid_get_uuid128(bleio_uuid_obj_t *self, uint8_t uuid128[16]); extern uint32_t common_hal_bleio_uuid_get_size(bleio_uuid_obj_t *self); -void common_hal_bleio_uuid_pack_into(bleio_uuid_obj_t *self, uint8_t* buf); +void common_hal_bleio_uuid_pack_into(bleio_uuid_obj_t *self, uint8_t *buf); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BLEIO_UUID_H diff --git a/shared-bindings/_bleio/__init__.c b/shared-bindings/_bleio/__init__.c index 2ef70a64f..b9d68abae 100644 --- a/shared-bindings/_bleio/__init__.c +++ b/shared-bindings/_bleio/__init__.c @@ -63,7 +63,7 @@ //| """Catchall exception for Bluetooth related errors.""" //| ... MP_DEFINE_BLEIO_EXCEPTION(BluetoothError, Exception) -NORETURN void mp_raise_bleio_BluetoothError(const compressed_string_t* fmt, ...) { +NORETURN void mp_raise_bleio_BluetoothError(const compressed_string_t *fmt, ...) { va_list argptr; va_start(argptr,fmt); mp_obj_t exception = mp_obj_new_exception_msg_vlist(&mp_type_bleio_BluetoothError, fmt, argptr); @@ -77,7 +77,7 @@ NORETURN void mp_raise_bleio_BluetoothError(const compressed_string_t* fmt, ...) //| ... //| MP_DEFINE_BLEIO_EXCEPTION(RoleError, bleio_BluetoothError) -NORETURN void mp_raise_bleio_RoleError(const compressed_string_t* msg) { +NORETURN void mp_raise_bleio_RoleError(const compressed_string_t *msg) { mp_raise_msg(&mp_type_bleio_RoleError, msg); } @@ -86,7 +86,7 @@ NORETURN void mp_raise_bleio_RoleError(const compressed_string_t* msg) { //| ... //| MP_DEFINE_BLEIO_EXCEPTION(SecurityError, bleio_BluetoothError) -NORETURN void mp_raise_bleio_SecurityError(const compressed_string_t* fmt, ...) { +NORETURN void mp_raise_bleio_SecurityError(const compressed_string_t *fmt, ...) { va_list argptr; va_start(argptr,fmt); mp_obj_t exception = mp_obj_new_exception_msg_vlist(&mp_type_bleio_SecurityError, fmt, argptr); @@ -97,9 +97,9 @@ NORETURN void mp_raise_bleio_SecurityError(const compressed_string_t* fmt, ...) // Called when _bleio is imported. STATIC mp_obj_t bleio___init__(void) { // HCI cannot be enabled on import, because we need to setup the HCI adapter first. -#if !CIRCUITPY_BLEIO_HCI + #if !CIRCUITPY_BLEIO_HCI common_hal_bleio_adapter_set_enabled(&common_hal_bleio_adapter_obj, true); -#endif + #endif return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_0(bleio___init___obj, bleio___init__); @@ -116,7 +116,7 @@ STATIC mp_obj_dict_t bleio_module_globals; //| ... //| mp_obj_t bleio_set_adapter(mp_obj_t adapter_obj) { -#if CIRCUITPY_BLEIO_HCI + #if CIRCUITPY_BLEIO_HCI if (adapter_obj != mp_const_none && !MP_OBJ_IS_TYPE(adapter_obj, &bleio_adapter_type)) { mp_raise_TypeError_varg(translate("Expected a %q"), bleio_adapter_type.name); } @@ -127,9 +127,9 @@ mp_obj_t bleio_set_adapter(mp_obj_t adapter_obj) { if (elem) { elem->value = adapter_obj; } -#else + #else mp_raise_NotImplementedError(translate("Not settable")); -#endif + #endif return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_1(bleio_set_adapter_obj, bleio_set_adapter); @@ -142,7 +142,7 @@ STATIC mp_map_elem_t bleio_module_globals_table[] = { #else #define OBJ_FROM_PTR MP_ROM_PTR STATIC const mp_rom_map_elem_t bleio_module_globals_table[] = { -#endif + #endif // Name must be the first entry so that the exception printing below is correct. { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__bleio) }, { MP_ROM_QSTR(MP_QSTR_Adapter), OBJ_FROM_PTR(&bleio_adapter_type) }, @@ -158,16 +158,16 @@ STATIC const mp_rom_map_elem_t bleio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_Service), OBJ_FROM_PTR(&bleio_service_type) }, { MP_ROM_QSTR(MP_QSTR_UUID), OBJ_FROM_PTR(&bleio_uuid_type) }, -#if CIRCUITPY_BLEIO_HCI + #if CIRCUITPY_BLEIO_HCI // For HCI, _bleio.adapter is settable, and starts as None. { MP_ROM_QSTR(MP_QSTR_adapter), mp_const_none }, - { MP_ROM_QSTR(MP_QSTR_set_adapter), (mp_obj_t) &bleio_set_adapter_obj }, -#else + { MP_ROM_QSTR(MP_QSTR_set_adapter), (mp_obj_t)&bleio_set_adapter_obj }, + #else // For non-HCI _bleio.adapter is a fixed singleton, and is not settable. // _bleio.set_adapter will raise NotImplementedError. { MP_ROM_QSTR(MP_QSTR_adapter), MP_ROM_PTR(&common_hal_bleio_adapter_obj) }, { MP_ROM_QSTR(MP_QSTR_set_adapter), MP_ROM_PTR(&bleio_set_adapter_obj) }, -#endif + #endif // Errors { MP_ROM_QSTR(MP_QSTR_BluetoothError), OBJ_FROM_PTR(&mp_type_bleio_BluetoothError) }, @@ -197,5 +197,5 @@ void bleio_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind const mp_obj_module_t bleio_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&bleio_module_globals, + .globals = (mp_obj_dict_t *)&bleio_module_globals, }; diff --git a/shared-bindings/_bleio/__init__.h b/shared-bindings/_bleio/__init__.h index 65ba9b3a5..7f251ef18 100644 --- a/shared-bindings/_bleio/__init__.h +++ b/shared-bindings/_bleio/__init__.h @@ -41,14 +41,14 @@ extern bleio_adapter_obj_t common_hal_bleio_adapter_obj; void bleio_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind); #define MP_DEFINE_BLEIO_EXCEPTION(exc_name, base_name) \ -const mp_obj_type_t mp_type_bleio_ ## exc_name = { \ - { &mp_type_type }, \ - .name = MP_QSTR_ ## exc_name, \ - .print = bleio_exception_print, \ - .make_new = mp_obj_exception_make_new, \ - .attr = mp_obj_exception_attr, \ - .parent = &mp_type_ ## base_name, \ -}; + const mp_obj_type_t mp_type_bleio_##exc_name = { \ + { &mp_type_type }, \ + .name = MP_QSTR_##exc_name, \ + .print = bleio_exception_print, \ + .make_new = mp_obj_exception_make_new, \ + .attr = mp_obj_exception_attr, \ + .parent = &mp_type_##base_name, \ + }; extern const mp_obj_type_t mp_type_bleio_BluetoothError; extern const mp_obj_type_t mp_type_bleio_RoleError; @@ -56,9 +56,9 @@ extern const mp_obj_type_t mp_type_bleio_SecurityError; extern mp_obj_t bleio_set_adapter(mp_obj_t adapter_obj); -NORETURN void mp_raise_bleio_BluetoothError(const compressed_string_t* msg, ...); -NORETURN void mp_raise_bleio_RoleError(const compressed_string_t* msg); -NORETURN void mp_raise_bleio_SecurityError(const compressed_string_t* msg, ...); +NORETURN void mp_raise_bleio_BluetoothError(const compressed_string_t *msg, ...); +NORETURN void mp_raise_bleio_RoleError(const compressed_string_t *msg); +NORETURN void mp_raise_bleio_SecurityError(const compressed_string_t *msg, ...); bleio_adapter_obj_t *common_hal_bleio_allocate_adapter_or_raise(void); void common_hal_bleio_check_connected(uint16_t conn_handle); @@ -66,9 +66,9 @@ void common_hal_bleio_check_connected(uint16_t conn_handle); uint16_t common_hal_bleio_device_get_conn_handle(mp_obj_t device); void common_hal_bleio_device_discover_remote_services(mp_obj_t device, mp_obj_t service_uuids_whitelist); -size_t common_hal_bleio_gatts_read(uint16_t handle, uint16_t conn_handle, uint8_t* buf, size_t len); +size_t common_hal_bleio_gatts_read(uint16_t handle, uint16_t conn_handle, uint8_t *buf, size_t len); void common_hal_bleio_gatts_write(uint16_t handle, uint16_t conn_handle, mp_buffer_info_t *bufinfo); -size_t common_hal_bleio_gattc_read(uint16_t handle, uint16_t conn_handle, uint8_t* buf, size_t len); +size_t common_hal_bleio_gattc_read(uint16_t handle, uint16_t conn_handle, uint8_t *buf, size_t len); void common_hal_bleio_gattc_write(uint16_t handle, uint16_t conn_handle, mp_buffer_info_t *bufinfo, bool write_no_response); void common_hal_bleio_gc_collect(void); diff --git a/shared-bindings/_eve/__init__.c b/shared-bindings/_eve/__init__.c index c043aa5fa..3e2591621 100644 --- a/shared-bindings/_eve/__init__.c +++ b/shared-bindings/_eve/__init__.c @@ -52,7 +52,7 @@ typedef struct _mp_obj__EVE_t { STATIC const mp_obj_type_t _EVE_type; #define EVEHAL(s) \ - (&((mp_obj__EVE_t*)mp_instance_cast_to_native_base((s), &_EVE_type))->_eve) + (&((mp_obj__EVE_t *)mp_instance_cast_to_native_base((s), &_EVE_type))->_eve) //| def register(self, o: object) -> None: //| ... @@ -90,7 +90,7 @@ STATIC mp_obj_t _cc(mp_obj_t self, mp_obj_t b) { } STATIC MP_DEFINE_CONST_FUN_OBJ_2(cc_obj, _cc); -//{ +// { //| def AlphaFunc(self, func: int, ref: int) -> None: //| """Set the alpha test function @@ -103,8 +103,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(cc_obj, _cc); //| STATIC mp_obj_t _alphafunc(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t func = mp_obj_get_int_truncated(a0); - uint32_t ref = mp_obj_get_int_truncated(a1); + uint32_t func = mp_obj_get_int_truncated(a0); + uint32_t ref = mp_obj_get_int_truncated(a1); common_hal__eve_AlphaFunc(EVEHAL(self), func, ref); return mp_const_none; } @@ -120,7 +120,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(alphafunc_obj, _alphafunc); //| STATIC mp_obj_t _begin(mp_obj_t self, mp_obj_t a0) { - uint32_t prim = mp_obj_get_int_truncated(a0); + uint32_t prim = mp_obj_get_int_truncated(a0); common_hal__eve_Begin(EVEHAL(self), prim); return mp_const_none; } @@ -134,7 +134,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(begin_obj, _begin); //| STATIC mp_obj_t _bitmapextformat(mp_obj_t self, mp_obj_t a0) { - uint32_t fmt = mp_obj_get_int_truncated(a0); + uint32_t fmt = mp_obj_get_int_truncated(a0); common_hal__eve_BitmapExtFormat(EVEHAL(self), fmt); return mp_const_none; } @@ -199,7 +199,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmaplayout_obj, 4, 4, _bitmaplayout //| STATIC mp_obj_t _bitmapsizeh(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t width = mp_obj_get_int_truncated(a0); + uint32_t width = mp_obj_get_int_truncated(a0); uint32_t height = mp_obj_get_int_truncated(a1); common_hal__eve_BitmapSizeH(EVEHAL(self), width, height); return mp_const_none; @@ -219,9 +219,9 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmapsizeh_obj, _bitmapsizeh); STATIC mp_obj_t _bitmapsize(size_t n_args, const mp_obj_t *args) { uint32_t filter = mp_obj_get_int_truncated(args[1]); - uint32_t wrapx = mp_obj_get_int_truncated(args[2]); - uint32_t wrapy = mp_obj_get_int_truncated(args[3]); - uint32_t width = mp_obj_get_int_truncated(args[4]); + uint32_t wrapx = mp_obj_get_int_truncated(args[2]); + uint32_t wrapy = mp_obj_get_int_truncated(args[3]); + uint32_t width = mp_obj_get_int_truncated(args[4]); uint32_t height = mp_obj_get_int_truncated(args[5]); common_hal__eve_BitmapSize(EVEHAL(args[0]), filter, wrapx, wrapy, width, height); return mp_const_none; @@ -236,7 +236,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmapsize_obj, 6, 6, _bitmapsize); //| STATIC mp_obj_t _bitmapsource(mp_obj_t self, mp_obj_t a0) { - uint32_t addr = mp_obj_get_int_truncated(a0); + uint32_t addr = mp_obj_get_int_truncated(a0); common_hal__eve_BitmapSource(EVEHAL(self), addr); return mp_const_none; } @@ -253,10 +253,10 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmapsource_obj, _bitmapsource); //| STATIC mp_obj_t _bitmapswizzle(size_t n_args, const mp_obj_t *args) { - uint32_t r = mp_obj_get_int_truncated(args[1]); - uint32_t g = mp_obj_get_int_truncated(args[2]); - uint32_t b = mp_obj_get_int_truncated(args[3]); - uint32_t a = mp_obj_get_int_truncated(args[4]); + uint32_t r = mp_obj_get_int_truncated(args[1]); + uint32_t g = mp_obj_get_int_truncated(args[2]); + uint32_t b = mp_obj_get_int_truncated(args[3]); + uint32_t a = mp_obj_get_int_truncated(args[4]); common_hal__eve_BitmapSwizzle(EVEHAL(args[0]), r, g, b, a); return mp_const_none; } @@ -275,8 +275,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitmapswizzle_obj, 5, 5, _bitmapswizz //| STATIC mp_obj_t _bitmaptransforma(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t p = mp_obj_get_int_truncated(a0); - uint32_t v = mp_obj_get_int_truncated(a1); + uint32_t p = mp_obj_get_int_truncated(a0); + uint32_t v = mp_obj_get_int_truncated(a1); common_hal__eve_BitmapTransformA(EVEHAL(self), p, v); return mp_const_none; } @@ -295,8 +295,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransforma_obj, _bitmaptransforma); //| STATIC mp_obj_t _bitmaptransformb(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t p = mp_obj_get_int_truncated(a0); - uint32_t v = mp_obj_get_int_truncated(a1); + uint32_t p = mp_obj_get_int_truncated(a0); + uint32_t v = mp_obj_get_int_truncated(a1); common_hal__eve_BitmapTransformB(EVEHAL(self), p, v); return mp_const_none; } @@ -312,7 +312,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformb_obj, _bitmaptransformb); //| STATIC mp_obj_t _bitmaptransformc(mp_obj_t self, mp_obj_t a0) { - uint32_t v = mp_obj_get_int_truncated(a0); + uint32_t v = mp_obj_get_int_truncated(a0); common_hal__eve_BitmapTransformC(EVEHAL(self), v); return mp_const_none; } @@ -331,8 +331,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmaptransformc_obj, _bitmaptransformc); //| STATIC mp_obj_t _bitmaptransformd(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t p = mp_obj_get_int_truncated(a0); - uint32_t v = mp_obj_get_int_truncated(a1); + uint32_t p = mp_obj_get_int_truncated(a0); + uint32_t v = mp_obj_get_int_truncated(a1); common_hal__eve_BitmapTransformD(EVEHAL(self), p, v); return mp_const_none; } @@ -351,8 +351,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransformd_obj, _bitmaptransformd); //| STATIC mp_obj_t _bitmaptransforme(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t p = mp_obj_get_int_truncated(a0); - uint32_t v = mp_obj_get_int_truncated(a1); + uint32_t p = mp_obj_get_int_truncated(a0); + uint32_t v = mp_obj_get_int_truncated(a1); common_hal__eve_BitmapTransformE(EVEHAL(self), p, v); return mp_const_none; } @@ -368,7 +368,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(bitmaptransforme_obj, _bitmaptransforme); //| STATIC mp_obj_t _bitmaptransformf(mp_obj_t self, mp_obj_t a0) { - uint32_t v = mp_obj_get_int_truncated(a0); + uint32_t v = mp_obj_get_int_truncated(a0); common_hal__eve_BitmapTransformF(EVEHAL(self), v); return mp_const_none; } @@ -385,8 +385,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(bitmaptransformf_obj, _bitmaptransformf); //| STATIC mp_obj_t _blendfunc(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t src = mp_obj_get_int_truncated(a0); - uint32_t dst = mp_obj_get_int_truncated(a1); + uint32_t src = mp_obj_get_int_truncated(a0); + uint32_t dst = mp_obj_get_int_truncated(a1); common_hal__eve_BlendFunc(EVEHAL(self), src, dst); return mp_const_none; } @@ -400,7 +400,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(blendfunc_obj, _blendfunc); //| STATIC mp_obj_t _call(mp_obj_t self, mp_obj_t a0) { - uint32_t dest = mp_obj_get_int_truncated(a0); + uint32_t dest = mp_obj_get_int_truncated(a0); common_hal__eve_Call(EVEHAL(self), dest); return mp_const_none; } @@ -416,7 +416,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(call_obj, _call); //| STATIC mp_obj_t _cell(mp_obj_t self, mp_obj_t a0) { - uint32_t cell = mp_obj_get_int_truncated(a0); + uint32_t cell = mp_obj_get_int_truncated(a0); common_hal__eve_Cell(EVEHAL(self), cell); return mp_const_none; } @@ -432,7 +432,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(cell_obj, _cell); //| STATIC mp_obj_t _clearcolora(mp_obj_t self, mp_obj_t a0) { - uint32_t alpha = mp_obj_get_int_truncated(a0); + uint32_t alpha = mp_obj_get_int_truncated(a0); common_hal__eve_ClearColorA(EVEHAL(self), alpha); return mp_const_none; } @@ -450,9 +450,9 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(clearcolora_obj, _clearcolora); //| STATIC mp_obj_t _clearcolorrgb(size_t n_args, const mp_obj_t *args) { - uint32_t red = mp_obj_get_int_truncated(args[1]); - uint32_t green = mp_obj_get_int_truncated(args[2]); - uint32_t blue = mp_obj_get_int_truncated(args[3]); + uint32_t red = mp_obj_get_int_truncated(args[1]); + uint32_t green = mp_obj_get_int_truncated(args[2]); + uint32_t blue = mp_obj_get_int_truncated(args[3]); common_hal__eve_ClearColorRGB(EVEHAL(args[0]), red, green, blue); return mp_const_none; } @@ -468,9 +468,9 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(clearcolorrgb_obj, 4, 4, _clearcolorr //| STATIC mp_obj_t _clear(size_t n_args, const mp_obj_t *args) { - uint32_t c = (n_args > 1) ? mp_obj_get_int_truncated(args[1]) : 1; - uint32_t s = (n_args > 2) ? mp_obj_get_int_truncated(args[2]) : 1; - uint32_t t = (n_args > 3) ? mp_obj_get_int_truncated(args[3]) : 1; + uint32_t c = (n_args > 1) ? mp_obj_get_int_truncated(args[1]) : 1; + uint32_t s = (n_args > 2) ? mp_obj_get_int_truncated(args[2]) : 1; + uint32_t t = (n_args > 3) ? mp_obj_get_int_truncated(args[3]) : 1; common_hal__eve_Clear(EVEHAL(args[0]), c, s, t); return mp_const_none; } @@ -486,7 +486,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(clear_obj, 1, 4, _clear); //| STATIC mp_obj_t _clearstencil(mp_obj_t self, mp_obj_t a0) { - uint32_t s = mp_obj_get_int_truncated(a0); + uint32_t s = mp_obj_get_int_truncated(a0); common_hal__eve_ClearStencil(EVEHAL(self), s); return mp_const_none; } @@ -501,7 +501,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(clearstencil_obj, _clearstencil); //| STATIC mp_obj_t _cleartag(mp_obj_t self, mp_obj_t a0) { - uint32_t s = mp_obj_get_int_truncated(a0); + uint32_t s = mp_obj_get_int_truncated(a0); common_hal__eve_ClearTag(EVEHAL(self), s); return mp_const_none; } @@ -517,7 +517,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(cleartag_obj, _cleartag); //| STATIC mp_obj_t _colora(mp_obj_t self, mp_obj_t a0) { - uint32_t alpha = mp_obj_get_int_truncated(a0); + uint32_t alpha = mp_obj_get_int_truncated(a0); common_hal__eve_ColorA(EVEHAL(self), alpha); return mp_const_none; } @@ -536,10 +536,10 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(colora_obj, _colora); //| STATIC mp_obj_t _colormask(size_t n_args, const mp_obj_t *args) { - uint32_t r = mp_obj_get_int_truncated(args[1]); - uint32_t g = mp_obj_get_int_truncated(args[2]); - uint32_t b = mp_obj_get_int_truncated(args[3]); - uint32_t a = mp_obj_get_int_truncated(args[4]); + uint32_t r = mp_obj_get_int_truncated(args[1]); + uint32_t g = mp_obj_get_int_truncated(args[2]); + uint32_t b = mp_obj_get_int_truncated(args[3]); + uint32_t a = mp_obj_get_int_truncated(args[4]); common_hal__eve_ColorMask(EVEHAL(args[0]), r, g, b, a); return mp_const_none; } @@ -557,9 +557,9 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(colormask_obj, 5, 5, _colormask); //| STATIC mp_obj_t _colorrgb(size_t n_args, const mp_obj_t *args) { - uint32_t red = mp_obj_get_int_truncated(args[1]); - uint32_t green = mp_obj_get_int_truncated(args[2]); - uint32_t blue = mp_obj_get_int_truncated(args[3]); + uint32_t red = mp_obj_get_int_truncated(args[1]); + uint32_t green = mp_obj_get_int_truncated(args[2]); + uint32_t blue = mp_obj_get_int_truncated(args[3]); common_hal__eve_ColorRGB(EVEHAL(args[0]), red, green, blue); return mp_const_none; } @@ -598,7 +598,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(end_obj, _end); //| STATIC mp_obj_t _jump(mp_obj_t self, mp_obj_t a0) { - uint32_t dest = mp_obj_get_int_truncated(a0); + uint32_t dest = mp_obj_get_int_truncated(a0); common_hal__eve_Jump(EVEHAL(self), dest); return mp_const_none; } @@ -612,7 +612,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(jump_obj, _jump); //| STATIC mp_obj_t _macro(mp_obj_t self, mp_obj_t a0) { - uint32_t m = mp_obj_get_int_truncated(a0); + uint32_t m = mp_obj_get_int_truncated(a0); common_hal__eve_Macro(EVEHAL(self), m); return mp_const_none; } @@ -640,7 +640,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(nop_obj, _nop); //| STATIC mp_obj_t _palettesource(mp_obj_t self, mp_obj_t a0) { - uint32_t addr = mp_obj_get_int_truncated(a0); + uint32_t addr = mp_obj_get_int_truncated(a0); common_hal__eve_PaletteSource(EVEHAL(self), addr); return mp_const_none; } @@ -693,7 +693,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(savecontext_obj, _savecontext); //| STATIC mp_obj_t _scissorsize(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t width = mp_obj_get_int_truncated(a0); + uint32_t width = mp_obj_get_int_truncated(a0); uint32_t height = mp_obj_get_int_truncated(a1); common_hal__eve_ScissorSize(EVEHAL(self), width, height); return mp_const_none; @@ -711,8 +711,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(scissorsize_obj, _scissorsize); //| STATIC mp_obj_t _scissorxy(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t x = mp_obj_get_int_truncated(a0); - uint32_t y = mp_obj_get_int_truncated(a1); + uint32_t x = mp_obj_get_int_truncated(a0); + uint32_t y = mp_obj_get_int_truncated(a1); common_hal__eve_ScissorXY(EVEHAL(self), x, y); return mp_const_none; } @@ -730,9 +730,9 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(scissorxy_obj, _scissorxy); //| STATIC mp_obj_t _stencilfunc(size_t n_args, const mp_obj_t *args) { - uint32_t func = mp_obj_get_int_truncated(args[1]); - uint32_t ref = mp_obj_get_int_truncated(args[2]); - uint32_t mask = mp_obj_get_int_truncated(args[3]); + uint32_t func = mp_obj_get_int_truncated(args[1]); + uint32_t ref = mp_obj_get_int_truncated(args[2]); + uint32_t mask = mp_obj_get_int_truncated(args[3]); common_hal__eve_StencilFunc(EVEHAL(args[0]), func, ref, mask); return mp_const_none; } @@ -748,7 +748,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stencilfunc_obj, 4, 4, _stencilfunc); //| STATIC mp_obj_t _stencilmask(mp_obj_t self, mp_obj_t a0) { - uint32_t mask = mp_obj_get_int_truncated(a0); + uint32_t mask = mp_obj_get_int_truncated(a0); common_hal__eve_StencilMask(EVEHAL(self), mask); return mp_const_none; } @@ -765,8 +765,8 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(stencilmask_obj, _stencilmask); //| STATIC mp_obj_t _stencilop(mp_obj_t self, mp_obj_t a0, mp_obj_t a1) { - uint32_t sfail = mp_obj_get_int_truncated(a0); - uint32_t spass = mp_obj_get_int_truncated(a1); + uint32_t sfail = mp_obj_get_int_truncated(a0); + uint32_t spass = mp_obj_get_int_truncated(a1); common_hal__eve_StencilOp(EVEHAL(self), sfail, spass); return mp_const_none; } @@ -782,7 +782,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(stencilop_obj, _stencilop); //| STATIC mp_obj_t _tagmask(mp_obj_t self, mp_obj_t a0) { - uint32_t mask = mp_obj_get_int_truncated(a0); + uint32_t mask = mp_obj_get_int_truncated(a0); common_hal__eve_TagMask(EVEHAL(self), mask); return mp_const_none; } @@ -798,14 +798,14 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(tagmask_obj, _tagmask); //| STATIC mp_obj_t _tag(mp_obj_t self, mp_obj_t a0) { - uint32_t s = mp_obj_get_int_truncated(a0); + uint32_t s = mp_obj_get_int_truncated(a0); common_hal__eve_Tag(EVEHAL(self), s); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(tag_obj, _tag); STATIC mp_obj_t _vertexformat(mp_obj_t self, mp_obj_t a0) { - uint32_t frac = mp_obj_get_int_truncated(a0); + uint32_t frac = mp_obj_get_int_truncated(a0); common_hal__eve_VertexFormat(EVEHAL(self), frac); return mp_const_none; } @@ -822,10 +822,10 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertexformat_obj, _vertexformat); //| STATIC mp_obj_t _vertex2ii(size_t n_args, const mp_obj_t *args) { - uint32_t x = mp_obj_get_int_truncated(args[1]); - uint32_t y = mp_obj_get_int_truncated(args[2]); + uint32_t x = mp_obj_get_int_truncated(args[1]); + uint32_t y = mp_obj_get_int_truncated(args[2]); uint32_t handle = (n_args > 3) ? mp_obj_get_int_truncated(args[3]) : 0; - uint32_t cell = (n_args > 4) ? mp_obj_get_int_truncated(args[4]) : 0; + uint32_t cell = (n_args > 4) ? mp_obj_get_int_truncated(args[4]) : 0; common_hal__eve_Vertex2ii(EVEHAL(args[0]), x, y, handle, cell); return mp_const_none; } @@ -882,7 +882,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(vertex2ii_obj, 3, 5, _vertex2ii); { MP_ROM_QSTR(MP_QSTR_VertexFormat), MP_ROM_PTR(&vertexformat_obj) }, \ { MP_ROM_QSTR(MP_QSTR_Vertex2ii), MP_ROM_PTR(&vertex2ii_obj) } -//} +// } // Hand-written functions { @@ -911,7 +911,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(vertex2f_obj, _vertex2f); //| STATIC mp_obj_t _linewidth(mp_obj_t self, mp_obj_t a0) { - mp_float_t width = mp_obj_get_float(a0); + mp_float_t width = mp_obj_get_float(a0); common_hal__eve_LineWidth(EVEHAL(self), width); return mp_const_none; } @@ -927,7 +927,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(linewidth_obj, _linewidth); //| STATIC mp_obj_t _pointsize(mp_obj_t self, mp_obj_t a0) { - mp_float_t size = mp_obj_get_float(a0); + mp_float_t size = mp_obj_get_float(a0); common_hal__eve_PointSize(EVEHAL(self), size); return mp_const_none; } @@ -943,7 +943,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(pointsize_obj, _pointsize); //| STATIC mp_obj_t _vertextranslatex(mp_obj_t self, mp_obj_t a0) { - mp_float_t x = mp_obj_get_float(a0); + mp_float_t x = mp_obj_get_float(a0); common_hal__eve_VertexTranslateX(EVEHAL(self), x); return mp_const_none; } @@ -960,7 +960,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertextranslatex_obj, _vertextranslatex); STATIC mp_obj_t _vertextranslatey(mp_obj_t self, mp_obj_t a0) { - mp_float_t y = mp_obj_get_float(a0); + mp_float_t y = mp_obj_get_float(a0); common_hal__eve_VertexTranslateY(EVEHAL(self), y); return mp_const_none; } @@ -975,7 +975,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(vertextranslatey_obj, _vertextranslatey); //| ... //| -//} +// } // Append an object x to the FIFO #define ADD_X(self, x) \ @@ -1024,7 +1024,7 @@ STATIC mp_obj_t _cmd(size_t n_args, const mp_obj_t *args) { // Count how many 32-bit words required size_t n = 0; for (size_t i = 0; i < fmt.len; n++) { - switch (((char*)fmt.buf)[i]) { + switch (((char *)fmt.buf)[i]) { case 'I': case 'i': i += 1; @@ -1044,8 +1044,8 @@ STATIC mp_obj_t _cmd(size_t n_args, const mp_obj_t *args) { mp_obj_t *a = items; uint32_t lo; - for (size_t i = 0; i < fmt.len; ) { - switch (((char*)fmt.buf)[i]) { + for (size_t i = 0; i < fmt.len;) { + switch (((char *)fmt.buf)[i]) { case 'I': case 'i': *p++ = mp_obj_get_int_truncated(*a++); @@ -1091,7 +1091,7 @@ STATIC const mp_obj_type_t _EVE_type = { { &mp_type_type }, .name = MP_QSTR__EVE, .make_new = _EVE_make_new, - .locals_dict = (void*)&_EVE_locals_dict, + .locals_dict = (void *)&_EVE_locals_dict, }; STATIC const mp_rom_map_elem_t mp_module__eve_globals_table[] = { @@ -1103,5 +1103,5 @@ STATIC MP_DEFINE_CONST_DICT(mp_module__eve_globals, mp_module__eve_globals_table const mp_obj_module_t _eve_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module__eve_globals, + .globals = (mp_obj_dict_t *)&mp_module__eve_globals, }; diff --git a/shared-bindings/_pew/PewPew.c b/shared-bindings/_pew/PewPew.c index a8a43e157..b98a12460 100644 --- a/shared-bindings/_pew/PewPew.c +++ b/shared-bindings/_pew/PewPew.c @@ -63,7 +63,7 @@ //| ... //| STATIC mp_obj_t pewpew_make_new(const mp_obj_type_t *type, size_t n_args, - const mp_obj_t *pos_args, mp_map_t *kw_args) { + const mp_obj_t *pos_args, mp_map_t *kw_args) { mp_arg_check_num(n_args, kw_args, 4, 4, true); enum { ARG_buffer, ARG_rows, ARG_cols, ARG_buttons }; static const mp_arg_t allowed_args[] = { @@ -74,7 +74,7 @@ STATIC mp_obj_t pewpew_make_new(const mp_obj_type_t *type, size_t n_args, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), - allowed_args, args); + allowed_args, args); mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[ARG_buffer].u_obj, &bufinfo, MP_BUFFER_READ); @@ -112,11 +112,11 @@ STATIC mp_obj_t pewpew_make_new(const mp_obj_type_t *type, size_t n_args, } if (!MP_OBJ_IS_TYPE(args[ARG_buttons].u_obj, - &digitalio_digitalinout_type)) { + &digitalio_digitalinout_type)) { mp_raise_TypeError(translate("buttons must be digitalio.DigitalInOut")); } digitalio_digitalinout_obj_t *buttons = MP_OBJ_TO_PTR( - args[ARG_buttons].u_obj); + args[ARG_buttons].u_obj); if (common_hal_digitalio_digitalinout_deinited(buttons)) { raise_deinited_error(); } @@ -149,5 +149,5 @@ const mp_obj_type_t pewpew_type = { { &mp_type_type }, .name = MP_QSTR_PewPew, .make_new = pewpew_make_new, - .locals_dict = (mp_obj_dict_t*)&pewpew_locals_dict, + .locals_dict = (mp_obj_dict_t *)&pewpew_locals_dict, }; diff --git a/shared-bindings/_pew/__init__.c b/shared-bindings/_pew/__init__.c index 912d267c4..2ecf34190 100644 --- a/shared-bindings/_pew/__init__.c +++ b/shared-bindings/_pew/__init__.c @@ -57,9 +57,9 @@ STATIC const mp_rom_map_elem_t pew_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_get_ticks), MP_ROM_PTR(&get_ticks_obj)}, }; STATIC MP_DEFINE_CONST_DICT(pew_module_globals, - pew_module_globals_table); + pew_module_globals_table); const mp_obj_module_t pew_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&pew_module_globals, + .globals = (mp_obj_dict_t *)&pew_module_globals, }; diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c index a4b5b5b1b..22923e97d 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.c +++ b/shared-bindings/_pixelbuf/PixelBuf.c @@ -46,7 +46,7 @@ extern const int32_t colorwheel(float pos); -static void parse_byteorder(mp_obj_t byteorder_obj, pixelbuf_byteorder_details_t* parsed); +static void parse_byteorder(mp_obj_t byteorder_obj, pixelbuf_byteorder_details_t *parsed); //| class PixelBuf: //| """A fast RGB[W] pixel buffer for LED and similar devices.""" @@ -113,13 +113,13 @@ STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_a pixelbuf_pixelbuf_obj_t *self = m_new_obj(pixelbuf_pixelbuf_obj_t); self->base.type = &pixelbuf_pixelbuf_type; common_hal__pixelbuf_pixelbuf_construct(self, args[ARG_size].u_int, - &byteorder_details, brightness, args[ARG_auto_write].u_bool, header_bufinfo.buf, - header_bufinfo.len, trailer_bufinfo.buf, trailer_bufinfo.len); + &byteorder_details, brightness, args[ARG_auto_write].u_bool, header_bufinfo.buf, + header_bufinfo.len, trailer_bufinfo.buf, trailer_bufinfo.len); return MP_OBJ_FROM_PTR(self); } -static void parse_byteorder(mp_obj_t byteorder_obj, pixelbuf_byteorder_details_t* parsed) { +static void parse_byteorder(mp_obj_t byteorder_obj, pixelbuf_byteorder_details_t *parsed) { if (!MP_OBJ_IS_STR(byteorder_obj)) { mp_raise_TypeError(translate("byteorder is not a string")); } @@ -242,10 +242,12 @@ const mp_obj_property_t pixelbuf_pixelbuf_byteorder_str = { STATIC mp_obj_t pixelbuf_pixelbuf_unary_op(mp_unary_op_t op, mp_obj_t self_in) { switch (op) { - case MP_UNARY_OP_BOOL: return mp_const_true; + case MP_UNARY_OP_BOOL: + return mp_const_true; case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(common_hal__pixelbuf_pixelbuf_get_len(self_in)); - default: return MP_OBJ_NULL; // op not supported + default: + return MP_OBJ_NULL; // op not supported } } @@ -303,7 +305,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp } if (0) { -#if MICROPY_PY_BUILTINS_SLICE + #if MICROPY_PY_BUILTINS_SLICE } else if (MP_OBJ_IS_TYPE(index_in, &mp_type_slice)) { mp_bound_slice_t slice; @@ -332,7 +334,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp } if (value == MP_OBJ_SENTINEL) { // Get - mp_obj_tuple_t* t = MP_OBJ_TO_PTR(mp_obj_new_tuple(slice_len, NULL)); + mp_obj_tuple_t *t = MP_OBJ_TO_PTR(mp_obj_new_tuple(slice_len, NULL)); for (uint i = 0; i < slice_len; i++) { t->items[i] = common_hal__pixelbuf_pixelbuf_get_pixel(self_in, i * slice.step + slice.start); } @@ -352,7 +354,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp return MP_OBJ_NULL; // op not supported #endif } -#endif + #endif } else { // Single index rather than slice. size_t length = common_hal__pixelbuf_pixelbuf_get_len(self_in); size_t index = mp_get_index(mp_obj_get_type(self_in), length, index_in, false); @@ -379,12 +381,12 @@ STATIC MP_DEFINE_CONST_DICT(pixelbuf_pixelbuf_locals_dict, pixelbuf_pixelbuf_loc const mp_obj_type_t pixelbuf_pixelbuf_type = { - { &mp_type_type }, - .name = MP_QSTR_PixelBuf, - .subscr = pixelbuf_pixelbuf_subscr, - .make_new = pixelbuf_pixelbuf_make_new, - .unary_op = pixelbuf_pixelbuf_unary_op, - .getiter = mp_obj_new_generic_iterator, - .print = NULL, - .locals_dict = (mp_obj_t)&pixelbuf_pixelbuf_locals_dict, + { &mp_type_type }, + .name = MP_QSTR_PixelBuf, + .subscr = pixelbuf_pixelbuf_subscr, + .make_new = pixelbuf_pixelbuf_make_new, + .unary_op = pixelbuf_pixelbuf_unary_op, + .getiter = mp_obj_new_generic_iterator, + .print = NULL, + .locals_dict = (mp_obj_t)&pixelbuf_pixelbuf_locals_dict, }; diff --git a/shared-bindings/_pixelbuf/PixelBuf.h b/shared-bindings/_pixelbuf/PixelBuf.h index d41082059..5e83b9b2d 100644 --- a/shared-bindings/_pixelbuf/PixelBuf.h +++ b/shared-bindings/_pixelbuf/PixelBuf.h @@ -32,8 +32,8 @@ extern const mp_obj_type_t pixelbuf_pixelbuf_type; void common_hal__pixelbuf_pixelbuf_construct(pixelbuf_pixelbuf_obj_t *self, size_t n, - pixelbuf_byteorder_details_t* byteorder, mp_float_t brightness, bool auto_write, uint8_t* header, - size_t header_len, uint8_t* trailer, size_t trailer_len); + pixelbuf_byteorder_details_t *byteorder, mp_float_t brightness, bool auto_write, uint8_t *header, + size_t header_len, uint8_t *trailer, size_t trailer_len); // These take mp_obj_t because they are called on subclasses of PixelBuf. uint8_t common_hal__pixelbuf_pixelbuf_get_bpp(mp_obj_t self); @@ -47,6 +47,6 @@ void common_hal__pixelbuf_pixelbuf_fill(mp_obj_t self, mp_obj_t item); void common_hal__pixelbuf_pixelbuf_show(mp_obj_t self); mp_obj_t common_hal__pixelbuf_pixelbuf_get_pixel(mp_obj_t self, size_t index); void common_hal__pixelbuf_pixelbuf_set_pixel(mp_obj_t self, size_t index, mp_obj_t item); -void common_hal__pixelbuf_pixelbuf_set_pixels(mp_obj_t self_in, size_t start, mp_int_t step, size_t slice_len, mp_obj_t* values, mp_obj_tuple_t *flatten_to); +void common_hal__pixelbuf_pixelbuf_set_pixels(mp_obj_t self_in, size_t start, mp_int_t step, size_t slice_len, mp_obj_t *values, mp_obj_tuple_t *flatten_to); #endif // CP_SHARED_BINDINGS_PIXELBUF_PIXELBUF_H diff --git a/shared-bindings/_pixelbuf/__init__.c b/shared-bindings/_pixelbuf/__init__.c index fdd02509c..5e87bacab 100644 --- a/shared-bindings/_pixelbuf/__init__.c +++ b/shared-bindings/_pixelbuf/__init__.c @@ -59,9 +59,9 @@ const int32_t colorwheel(float pos) { if (pos > 255) { pos = pos - ((uint32_t)(pos / 256) * 256); } - if (pos < 85) + if (pos < 85) { return (uint8_t)(255 - (pos * 3)) << 16 | (uint8_t)(pos * 3) << 8; - else if (pos < 170) { + } else if (pos < 170) { pos -= 85; return (uint8_t)(255 - (pos * 3)) << 8 | (uint8_t)(pos * 3); } else { @@ -81,5 +81,5 @@ STATIC MP_DEFINE_CONST_DICT(pixelbuf_module_globals, pixelbuf_module_globals_tab const mp_obj_module_t pixelbuf_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&pixelbuf_module_globals, + .globals = (mp_obj_dict_t *)&pixelbuf_module_globals, }; diff --git a/shared-bindings/_pixelbuf/__init__.h b/shared-bindings/_pixelbuf/__init__.h index 0e8c4a37f..890543d3e 100644 --- a/shared-bindings/_pixelbuf/__init__.h +++ b/shared-bindings/_pixelbuf/__init__.h @@ -31,4 +31,4 @@ const int32_t colorwheel(float pos); -#endif //CP_SHARED_BINDINGS_PIXELBUF_INIT_H +#endif // CP_SHARED_BINDINGS_PIXELBUF_INIT_H diff --git a/shared-bindings/_stage/Layer.c b/shared-bindings/_stage/Layer.c index 612323a4e..51ed5c3bf 100644 --- a/shared-bindings/_stage/Layer.c +++ b/shared-bindings/_stage/Layer.c @@ -49,7 +49,7 @@ //| ... //| STATIC mp_obj_t layer_make_new(const mp_obj_type_t *type, size_t n_args, - const mp_obj_t *args, mp_map_t *kw_args) { + const mp_obj_t *args, mp_map_t *kw_args) { mp_arg_check_num(n_args, kw_args, 4, 5, false); layer_obj_t *self = m_new_obj(layer_obj_t); @@ -82,7 +82,7 @@ STATIC mp_obj_t layer_make_new(const mp_obj_type_t *type, size_t n_args, mp_raise_ValueError(translate("map buffer too small")); } } else { - self-> map = NULL; + self->map = NULL; } return MP_OBJ_FROM_PTR(self); @@ -106,7 +106,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(layer_move_obj, layer_move); //| ... //| STATIC mp_obj_t layer_frame(mp_obj_t self_in, mp_obj_t frame_in, - mp_obj_t rotation_in) { + mp_obj_t rotation_in) { layer_obj_t *self = MP_OBJ_TO_PTR(self_in); self->frame = mp_obj_get_int(frame_in); self->rotation = mp_obj_get_int(rotation_in); @@ -125,5 +125,5 @@ const mp_obj_type_t mp_type_layer = { { &mp_type_type }, .name = MP_QSTR_Layer, .make_new = layer_make_new, - .locals_dict = (mp_obj_dict_t*)&layer_locals_dict, + .locals_dict = (mp_obj_dict_t *)&layer_locals_dict, }; diff --git a/shared-bindings/_stage/Text.c b/shared-bindings/_stage/Text.c index d1e50fa23..55b60953b 100644 --- a/shared-bindings/_stage/Text.c +++ b/shared-bindings/_stage/Text.c @@ -49,7 +49,7 @@ //| ... //| STATIC mp_obj_t text_make_new(const mp_obj_type_t *type, size_t n_args, - const mp_obj_t *args, mp_map_t *kw_args) { + const mp_obj_t *args, mp_map_t *kw_args) { mp_arg_check_num(n_args, kw_args, 5, 5, false); text_obj_t *self = m_new_obj(text_obj_t); @@ -104,5 +104,5 @@ const mp_obj_type_t mp_type_text = { { &mp_type_type }, .name = MP_QSTR_Text, .make_new = text_make_new, - .locals_dict = (mp_obj_dict_t*)&text_locals_dict, + .locals_dict = (mp_obj_dict_t *)&text_locals_dict, }; diff --git a/shared-bindings/_stage/__init__.c b/shared-bindings/_stage/__init__.c index f173147e3..0e3f08da5 100644 --- a/shared-bindings/_stage/__init__.c +++ b/shared-bindings/_stage/__init__.c @@ -91,7 +91,7 @@ STATIC mp_obj_t stage_render(size_t n_args, const mp_obj_t *args) { } render_stage(x0, y0, x1, y1, layers, layers_size, buffer, buffer_size, - display, scale, background); + display, scale, background); return mp_const_none; } @@ -109,5 +109,5 @@ STATIC MP_DEFINE_CONST_DICT(stage_module_globals, stage_module_globals_table); const mp_obj_module_t stage_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&stage_module_globals, + .globals = (mp_obj_dict_t *)&stage_module_globals, }; diff --git a/shared-bindings/adafruit_bus_device/I2CDevice.c b/shared-bindings/adafruit_bus_device/I2CDevice.c index e6ec8c147..ac760a490 100644 --- a/shared-bindings/adafruit_bus_device/I2CDevice.c +++ b/shared-bindings/adafruit_bus_device/I2CDevice.c @@ -77,7 +77,7 @@ STATIC mp_obj_t adafruit_bus_device_i2cdevice_make_new(const mp_obj_type_t *type mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - mp_obj_t* i2c = args[ARG_i2c].u_obj; + mp_obj_t *i2c = args[ARG_i2c].u_obj; common_hal_adafruit_bus_device_i2cdevice_construct(MP_OBJ_TO_PTR(self), i2c, args[ARG_device_address].u_int); if (args[ARG_probe].u_bool == true) { @@ -138,7 +138,7 @@ STATIC mp_obj_t adafruit_bus_device_i2cdevice_readinto(size_t n_args, const mp_o mp_load_method(self->i2c, MP_QSTR_readfrom_into, dest); dest[2] = MP_OBJ_NEW_SMALL_INT(self->device_address); dest[3] = args[ARG_buffer].u_obj; - //dest[4] = mp_obj_new_str("start", 5); + // dest[4] = mp_obj_new_str("start", 5); dest[4] = MP_OBJ_NEW_QSTR(MP_QSTR_start); dest[5] = MP_OBJ_NEW_SMALL_INT(args[ARG_start].u_int); if (args[ARG_end].u_int != INT_MAX) { @@ -272,8 +272,8 @@ STATIC const mp_rom_map_elem_t adafruit_bus_device_i2cdevice_locals_dict_table[] STATIC MP_DEFINE_CONST_DICT(adafruit_bus_device_i2cdevice_locals_dict, adafruit_bus_device_i2cdevice_locals_dict_table); const mp_obj_type_t adafruit_bus_device_i2cdevice_type = { - { &mp_type_type }, - .name = MP_QSTR_I2CDevice, - .make_new = adafruit_bus_device_i2cdevice_make_new, - .locals_dict = (mp_obj_dict_t*)&adafruit_bus_device_i2cdevice_locals_dict, + { &mp_type_type }, + .name = MP_QSTR_I2CDevice, + .make_new = adafruit_bus_device_i2cdevice_make_new, + .locals_dict = (mp_obj_dict_t *)&adafruit_bus_device_i2cdevice_locals_dict, }; diff --git a/shared-bindings/adafruit_bus_device/I2CDevice.h b/shared-bindings/adafruit_bus_device/I2CDevice.h index 82ef1feb8..36a95b6a2 100644 --- a/shared-bindings/adafruit_bus_device/I2CDevice.h +++ b/shared-bindings/adafruit_bus_device/I2CDevice.h @@ -37,7 +37,7 @@ #include "py/obj.h" #include "shared-module/adafruit_bus_device/I2CDevice.h" -//#include "shared-bindings/busio/I2C.h" +// #include "shared-bindings/busio/I2C.h" // Type object used in Python. Should be shared between ports. extern const mp_obj_type_t adafruit_bus_device_i2cdevice_type; diff --git a/shared-bindings/adafruit_bus_device/SPIDevice.c b/shared-bindings/adafruit_bus_device/SPIDevice.c index 74fa28e4d..94901e4a1 100644 --- a/shared-bindings/adafruit_bus_device/SPIDevice.c +++ b/shared-bindings/adafruit_bus_device/SPIDevice.c @@ -84,7 +84,7 @@ STATIC mp_obj_t adafruit_bus_device_spidevice_make_new(const mp_obj_type_t *type mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - busio_spi_obj_t* spi = args[ARG_spi].u_obj; + busio_spi_obj_t *spi = args[ARG_spi].u_obj; common_hal_adafruit_bus_device_spidevice_construct(MP_OBJ_TO_PTR(self), spi, args[ARG_chip_select].u_obj, args[ARG_baudrate].u_int, args[ARG_polarity].u_int, args[ARG_phase].u_int, args[ARG_extra_clocks].u_int); @@ -130,8 +130,8 @@ STATIC const mp_rom_map_elem_t adafruit_bus_device_spidevice_locals_dict_table[] STATIC MP_DEFINE_CONST_DICT(adafruit_bus_device_spidevice_locals_dict, adafruit_bus_device_spidevice_locals_dict_table); const mp_obj_type_t adafruit_bus_device_spidevice_type = { - { &mp_type_type }, - .name = MP_QSTR_SPIDevice, - .make_new = adafruit_bus_device_spidevice_make_new, - .locals_dict = (mp_obj_dict_t*)&adafruit_bus_device_spidevice_locals_dict, + { &mp_type_type }, + .name = MP_QSTR_SPIDevice, + .make_new = adafruit_bus_device_spidevice_make_new, + .locals_dict = (mp_obj_dict_t *)&adafruit_bus_device_spidevice_locals_dict, }; diff --git a/shared-bindings/adafruit_bus_device/__init__.c b/shared-bindings/adafruit_bus_device/__init__.c index e01abcab3..84abbd0c2 100644 --- a/shared-bindings/adafruit_bus_device/__init__.c +++ b/shared-bindings/adafruit_bus_device/__init__.c @@ -43,7 +43,7 @@ STATIC MP_DEFINE_CONST_DICT(adafruit_bus_device_i2c_device_globals, adafruit_bus const mp_obj_module_t adafruit_bus_device_i2c_device_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&adafruit_bus_device_i2c_device_globals, + .globals = (mp_obj_dict_t *)&adafruit_bus_device_i2c_device_globals, }; STATIC const mp_rom_map_elem_t adafruit_bus_device_spi_device_globals_table[] = { @@ -54,7 +54,7 @@ STATIC MP_DEFINE_CONST_DICT(adafruit_bus_device_spi_device_globals, adafruit_bus const mp_obj_module_t adafruit_bus_device_spi_device_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&adafruit_bus_device_spi_device_globals, + .globals = (mp_obj_dict_t *)&adafruit_bus_device_spi_device_globals, }; //| """Hardware accelerated external bus access @@ -74,5 +74,5 @@ STATIC MP_DEFINE_CONST_DICT(adafruit_bus_device_module_globals, adafruit_bus_dev const mp_obj_module_t adafruit_bus_device_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&adafruit_bus_device_module_globals, + .globals = (mp_obj_dict_t *)&adafruit_bus_device_module_globals, }; diff --git a/shared-bindings/aesio/__init__.h b/shared-bindings/aesio/__init__.h index 634fed2e5..60f6b8361 100644 --- a/shared-bindings/aesio/__init__.h +++ b/shared-bindings/aesio/__init__.h @@ -31,23 +31,23 @@ extern const mp_obj_type_t aesio_aes_type; -void common_hal_aesio_aes_construct(aesio_aes_obj_t* self, - const uint8_t* key, - uint32_t key_length, - const uint8_t* iv, - int mode, - int counter); -void common_hal_aesio_aes_rekey(aesio_aes_obj_t* self, - const uint8_t* key, - uint32_t key_length, - const uint8_t* iv); -void common_hal_aesio_aes_set_mode(aesio_aes_obj_t* self, - int mode); -void common_hal_aesio_aes_encrypt(aesio_aes_obj_t* self, - uint8_t* buffer, - size_t len); -void common_hal_aesio_aes_decrypt(aesio_aes_obj_t* self, - uint8_t* buffer, - size_t len); +void common_hal_aesio_aes_construct(aesio_aes_obj_t *self, + const uint8_t *key, + uint32_t key_length, + const uint8_t *iv, + int mode, + int counter); +void common_hal_aesio_aes_rekey(aesio_aes_obj_t *self, + const uint8_t *key, + uint32_t key_length, + const uint8_t *iv); +void common_hal_aesio_aes_set_mode(aesio_aes_obj_t *self, + int mode); +void common_hal_aesio_aes_encrypt(aesio_aes_obj_t *self, + uint8_t *buffer, + size_t len); +void common_hal_aesio_aes_decrypt(aesio_aes_obj_t *self, + uint8_t *buffer, + size_t len); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_AESIO_H diff --git a/shared-bindings/aesio/aes.c b/shared-bindings/aesio/aes.c index a121845e3..f021e9abc 100644 --- a/shared-bindings/aesio/aes.c +++ b/shared-bindings/aesio/aes.c @@ -37,119 +37,119 @@ //| STATIC mp_obj_t aesio_aes_make_new(const mp_obj_type_t *type, size_t n_args, - const mp_obj_t *pos_args, - mp_map_t *kw_args) { - (void)type; - enum { ARG_key, ARG_mode, ARG_IV, ARG_counter, ARG_segment_size }; - static const mp_arg_t allowed_args[] = { - {MP_QSTR_key, MP_ARG_OBJ | MP_ARG_REQUIRED}, - {MP_QSTR_mode, MP_ARG_INT, {.u_int = AES_MODE_ECB}}, - {MP_QSTR_IV, MP_ARG_OBJ}, - {MP_QSTR_counter, MP_ARG_OBJ}, - {MP_QSTR_segment_size, MP_ARG_INT, {.u_int = 8}}, - }; - mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - - mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), - allowed_args, args); - - aesio_aes_obj_t *self = m_new_obj(aesio_aes_obj_t); - self->base.type = &aesio_aes_type; - - mp_buffer_info_t bufinfo; - - const uint8_t *key = NULL; - uint32_t key_length = 0; - if (mp_get_buffer(args[ARG_key].u_obj, &bufinfo, MP_BUFFER_READ)) { - if ((bufinfo.len != 16) && (bufinfo.len != 24) && (bufinfo.len != 32)) { - mp_raise_TypeError(translate("Key must be 16, 24, or 32 bytes long")); + const mp_obj_t *pos_args, + mp_map_t *kw_args) { + (void)type; + enum { ARG_key, ARG_mode, ARG_IV, ARG_counter, ARG_segment_size }; + static const mp_arg_t allowed_args[] = { + {MP_QSTR_key, MP_ARG_OBJ | MP_ARG_REQUIRED}, + {MP_QSTR_mode, MP_ARG_INT, {.u_int = AES_MODE_ECB}}, + {MP_QSTR_IV, MP_ARG_OBJ}, + {MP_QSTR_counter, MP_ARG_OBJ}, + {MP_QSTR_segment_size, MP_ARG_INT, {.u_int = 8}}, + }; + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + + mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), + allowed_args, args); + + aesio_aes_obj_t *self = m_new_obj(aesio_aes_obj_t); + self->base.type = &aesio_aes_type; + + mp_buffer_info_t bufinfo; + + const uint8_t *key = NULL; + uint32_t key_length = 0; + if (mp_get_buffer(args[ARG_key].u_obj, &bufinfo, MP_BUFFER_READ)) { + if ((bufinfo.len != 16) && (bufinfo.len != 24) && (bufinfo.len != 32)) { + mp_raise_TypeError(translate("Key must be 16, 24, or 32 bytes long")); + } + key = bufinfo.buf; + key_length = bufinfo.len; + } else { + mp_raise_TypeError(translate("No key was specified")); } - key = bufinfo.buf; - key_length = bufinfo.len; - } else { - mp_raise_TypeError(translate("No key was specified")); - } - - int mode = args[ARG_mode].u_int; - switch (args[ARG_mode].u_int) { - case AES_MODE_CBC: - case AES_MODE_ECB: - case AES_MODE_CTR: - break; - default: - mp_raise_TypeError(translate("Requested AES mode is unsupported")); - } - - // IV is required for CBC mode and is ignored for other modes. - const uint8_t *iv = NULL; - if (args[ARG_IV].u_obj != NULL && - mp_get_buffer(args[ARG_IV].u_obj, &bufinfo, MP_BUFFER_READ)) { - if (bufinfo.len != AES_BLOCKLEN) { - mp_raise_TypeError_varg(translate("IV must be %d bytes long"), - AES_BLOCKLEN); + + int mode = args[ARG_mode].u_int; + switch (args[ARG_mode].u_int) { + case AES_MODE_CBC: + case AES_MODE_ECB: + case AES_MODE_CTR: + break; + default: + mp_raise_TypeError(translate("Requested AES mode is unsupported")); + } + + // IV is required for CBC mode and is ignored for other modes. + const uint8_t *iv = NULL; + if (args[ARG_IV].u_obj != NULL && + mp_get_buffer(args[ARG_IV].u_obj, &bufinfo, MP_BUFFER_READ)) { + if (bufinfo.len != AES_BLOCKLEN) { + mp_raise_TypeError_varg(translate("IV must be %d bytes long"), + AES_BLOCKLEN); + } + iv = bufinfo.buf; } - iv = bufinfo.buf; - } - common_hal_aesio_aes_construct(self, key, key_length, iv, mode, - args[ARG_counter].u_int); - return MP_OBJ_FROM_PTR(self); + common_hal_aesio_aes_construct(self, key, key_length, iv, mode, + args[ARG_counter].u_int); + return MP_OBJ_FROM_PTR(self); } STATIC mp_obj_t aesio_aes_rekey(size_t n_args, const mp_obj_t *pos_args) { - aesio_aes_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); - - mp_buffer_info_t bufinfo; - mp_get_buffer_raise(pos_args[1], &bufinfo, MP_BUFFER_READ); - const uint8_t *key = bufinfo.buf; - size_t key_length = bufinfo.len; - if (key == NULL) { - mp_raise_ValueError(translate("No key was specified")); - } - if ((key_length != 16) && (key_length != 24) && (key_length != 32)) { - mp_raise_TypeError(translate("Key must be 16, 24, or 32 bytes long")); - } - - const uint8_t *iv = NULL; - if (n_args > 2) { - mp_get_buffer_raise(pos_args[2], &bufinfo, MP_BUFFER_READ); - size_t iv_length = bufinfo.len; - iv = (const uint8_t *)bufinfo.buf; - if (iv_length != AES_BLOCKLEN) { - mp_raise_TypeError_varg(translate("IV must be %d bytes long"), - AES_BLOCKLEN); + aesio_aes_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); + + mp_buffer_info_t bufinfo; + mp_get_buffer_raise(pos_args[1], &bufinfo, MP_BUFFER_READ); + const uint8_t *key = bufinfo.buf; + size_t key_length = bufinfo.len; + if (key == NULL) { + mp_raise_ValueError(translate("No key was specified")); + } + if ((key_length != 16) && (key_length != 24) && (key_length != 32)) { + mp_raise_TypeError(translate("Key must be 16, 24, or 32 bytes long")); + } + + const uint8_t *iv = NULL; + if (n_args > 2) { + mp_get_buffer_raise(pos_args[2], &bufinfo, MP_BUFFER_READ); + size_t iv_length = bufinfo.len; + iv = (const uint8_t *)bufinfo.buf; + if (iv_length != AES_BLOCKLEN) { + mp_raise_TypeError_varg(translate("IV must be %d bytes long"), + AES_BLOCKLEN); + } } - } - common_hal_aesio_aes_rekey(self, key, key_length, iv); - return mp_const_none; + common_hal_aesio_aes_rekey(self, key, key_length, iv); + return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_VAR(aesio_aes_rekey_obj, 2, aesio_aes_rekey); STATIC void validate_length(aesio_aes_obj_t *self, size_t src_length, - size_t dest_length) { - if (src_length != dest_length) { - mp_raise_ValueError( - translate("Source and destination buffers must be the same length")); - } - - switch (self->mode) { - case AES_MODE_ECB: - if (src_length != 16) { - mp_raise_msg(&mp_type_ValueError, - translate("ECB only operates on 16 bytes at a time")); + size_t dest_length) { + if (src_length != dest_length) { + mp_raise_ValueError( + translate("Source and destination buffers must be the same length")); } - break; - case AES_MODE_CBC: - if ((src_length & 15) != 0) { - mp_raise_msg(&mp_type_ValueError, - translate("CBC blocks must be multiples of 16 bytes")); + + switch (self->mode) { + case AES_MODE_ECB: + if (src_length != 16) { + mp_raise_msg(&mp_type_ValueError, + translate("ECB only operates on 16 bytes at a time")); + } + break; + case AES_MODE_CBC: + if ((src_length & 15) != 0) { + mp_raise_msg(&mp_type_ValueError, + translate("CBC blocks must be multiples of 16 bytes")); + } + break; + case AES_MODE_CTR: + break; } - break; - case AES_MODE_CTR: - break; - } } //| def encrypt_into(self, src: ReadableBuffer, dest: WriteableBuffer) -> None: @@ -161,27 +161,27 @@ STATIC void validate_length(aesio_aes_obj_t *self, size_t src_length, //| ... //| STATIC mp_obj_t aesio_aes_encrypt_into(mp_obj_t aesio_obj, mp_obj_t src, - mp_obj_t dest) { - if (!MP_OBJ_IS_TYPE(aesio_obj, &aesio_aes_type)) { - mp_raise_TypeError_varg(translate("Expected a %q"), aesio_aes_type.name); - } - // Convert parameters into expected types. - aesio_aes_obj_t *aes = MP_OBJ_TO_PTR(aesio_obj); - - mp_buffer_info_t srcbufinfo, destbufinfo; - mp_get_buffer_raise(src, &srcbufinfo, MP_BUFFER_READ); - mp_get_buffer_raise(dest, &destbufinfo, MP_BUFFER_WRITE); - validate_length(aes, srcbufinfo.len, destbufinfo.len); - - memcpy(destbufinfo.buf, srcbufinfo.buf, srcbufinfo.len); - - common_hal_aesio_aes_encrypt(aes, (uint8_t *)destbufinfo.buf, - destbufinfo.len); - return mp_const_none; + mp_obj_t dest) { + if (!MP_OBJ_IS_TYPE(aesio_obj, &aesio_aes_type)) { + mp_raise_TypeError_varg(translate("Expected a %q"), aesio_aes_type.name); + } + // Convert parameters into expected types. + aesio_aes_obj_t *aes = MP_OBJ_TO_PTR(aesio_obj); + + mp_buffer_info_t srcbufinfo, destbufinfo; + mp_get_buffer_raise(src, &srcbufinfo, MP_BUFFER_READ); + mp_get_buffer_raise(dest, &destbufinfo, MP_BUFFER_WRITE); + validate_length(aes, srcbufinfo.len, destbufinfo.len); + + memcpy(destbufinfo.buf, srcbufinfo.buf, srcbufinfo.len); + + common_hal_aesio_aes_encrypt(aes, (uint8_t *)destbufinfo.buf, + destbufinfo.len); + return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(aesio_aes_encrypt_into_obj, - aesio_aes_encrypt_into); + aesio_aes_encrypt_into); //| def decrypt_into(self, src: ReadableBuffer, dest: WriteableBuffer) -> None: //| """Decrypt the buffer from ``src`` into ``dest``. @@ -191,55 +191,55 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(aesio_aes_encrypt_into_obj, //| ... //| STATIC mp_obj_t aesio_aes_decrypt_into(mp_obj_t aesio_obj, mp_obj_t src, - mp_obj_t dest) { - if (!MP_OBJ_IS_TYPE(aesio_obj, &aesio_aes_type)) { - mp_raise_TypeError_varg(translate("Expected a %q"), aesio_aes_type.name); - } - // Convert parameters into expected types. - aesio_aes_obj_t *aes = MP_OBJ_TO_PTR(aesio_obj); - - mp_buffer_info_t srcbufinfo, destbufinfo; - mp_get_buffer_raise(src, &srcbufinfo, MP_BUFFER_READ); - mp_get_buffer_raise(dest, &destbufinfo, MP_BUFFER_WRITE); - validate_length(aes, srcbufinfo.len, destbufinfo.len); - - memcpy(destbufinfo.buf, srcbufinfo.buf, srcbufinfo.len); - - common_hal_aesio_aes_decrypt(aes, (uint8_t *)destbufinfo.buf, - destbufinfo.len); - return mp_const_none; + mp_obj_t dest) { + if (!MP_OBJ_IS_TYPE(aesio_obj, &aesio_aes_type)) { + mp_raise_TypeError_varg(translate("Expected a %q"), aesio_aes_type.name); + } + // Convert parameters into expected types. + aesio_aes_obj_t *aes = MP_OBJ_TO_PTR(aesio_obj); + + mp_buffer_info_t srcbufinfo, destbufinfo; + mp_get_buffer_raise(src, &srcbufinfo, MP_BUFFER_READ); + mp_get_buffer_raise(dest, &destbufinfo, MP_BUFFER_WRITE); + validate_length(aes, srcbufinfo.len, destbufinfo.len); + + memcpy(destbufinfo.buf, srcbufinfo.buf, srcbufinfo.len); + + common_hal_aesio_aes_decrypt(aes, (uint8_t *)destbufinfo.buf, + destbufinfo.len); + return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_3(aesio_aes_decrypt_into_obj, - aesio_aes_decrypt_into); + aesio_aes_decrypt_into); STATIC mp_obj_t aesio_aes_get_mode(mp_obj_t aesio_obj) { - if (!MP_OBJ_IS_TYPE(aesio_obj, &aesio_aes_type)) { - mp_raise_TypeError_varg(translate("Expected a %q"), aesio_aes_type.name); - } - aesio_aes_obj_t *self = MP_OBJ_TO_PTR(aesio_obj); - return MP_OBJ_NEW_SMALL_INT(self->mode); + if (!MP_OBJ_IS_TYPE(aesio_obj, &aesio_aes_type)) { + mp_raise_TypeError_varg(translate("Expected a %q"), aesio_aes_type.name); + } + aesio_aes_obj_t *self = MP_OBJ_TO_PTR(aesio_obj); + return MP_OBJ_NEW_SMALL_INT(self->mode); } MP_DEFINE_CONST_FUN_OBJ_1(aesio_aes_get_mode_obj, aesio_aes_get_mode); STATIC mp_obj_t aesio_aes_set_mode(mp_obj_t aesio_obj, mp_obj_t mode_obj) { - if (!MP_OBJ_IS_TYPE(aesio_obj, &aesio_aes_type)) { - mp_raise_TypeError_varg(translate("Expected a %q"), aesio_aes_type.name); - } - aesio_aes_obj_t *self = MP_OBJ_TO_PTR(aesio_obj); - - int mode = mp_obj_get_int(mode_obj); - switch (mode) { - case AES_MODE_CBC: - case AES_MODE_ECB: - case AES_MODE_CTR: - break; - default: - mp_raise_TypeError(translate("Requested AES mode is unsupported")); - } - - common_hal_aesio_aes_set_mode(self, mode); - return mp_const_none; + if (!MP_OBJ_IS_TYPE(aesio_obj, &aesio_aes_type)) { + mp_raise_TypeError_varg(translate("Expected a %q"), aesio_aes_type.name); + } + aesio_aes_obj_t *self = MP_OBJ_TO_PTR(aesio_obj); + + int mode = mp_obj_get_int(mode_obj); + switch (mode) { + case AES_MODE_CBC: + case AES_MODE_ECB: + case AES_MODE_CTR: + break; + default: + mp_raise_TypeError(translate("Requested AES mode is unsupported")); + } + + common_hal_aesio_aes_set_mode(self, mode); + return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_2(aesio_aes_set_mode_obj, aesio_aes_set_mode); diff --git a/shared-bindings/alarm/SleepMemory.c b/shared-bindings/alarm/SleepMemory.c index aed24827a..9ca0ec047 100644 --- a/shared-bindings/alarm/SleepMemory.c +++ b/shared-bindings/alarm/SleepMemory.c @@ -67,9 +67,12 @@ STATIC mp_obj_t alarm_sleep_memory_unary_op(mp_unary_op_t op, mp_obj_t self_in) alarm_sleep_memory_obj_t *self = MP_OBJ_TO_PTR(self_in); uint16_t len = common_hal_alarm_sleep_memory_get_length(self); switch (op) { - case MP_UNARY_OP_BOOL: return mp_obj_new_bool(len != 0); - case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(len); - default: return MP_OBJ_NULL; // op not supported + case MP_UNARY_OP_BOOL: + return mp_obj_new_bool(len != 0); + case MP_UNARY_OP_LEN: + return MP_OBJ_NEW_SMALL_INT(len); + default: + return MP_OBJ_NULL; // op not supported } } @@ -100,7 +103,7 @@ STATIC mp_obj_t alarm_sleep_memory_subscr(mp_obj_t self_in, mp_obj_t index_in, m } else { alarm_sleep_memory_obj_t *self = MP_OBJ_TO_PTR(self_in); if (0) { -#if MICROPY_PY_BUILTINS_SLICE + #if MICROPY_PY_BUILTINS_SLICE } else if (MP_OBJ_IS_TYPE(index_in, &mp_type_slice)) { mp_bound_slice_t slice; if (!mp_seq_get_fast_slice_indexes(common_hal_alarm_sleep_memory_get_length(self), index_in, &slice)) { @@ -110,11 +113,11 @@ STATIC mp_obj_t alarm_sleep_memory_subscr(mp_obj_t self_in, mp_obj_t index_in, m #if MICROPY_PY_ARRAY_SLICE_ASSIGN // Assign size_t src_len = slice.stop - slice.start; - uint8_t* src_items; + uint8_t *src_items; if (MP_OBJ_IS_TYPE(value, &mp_type_array) || - MP_OBJ_IS_TYPE(value, &mp_type_bytearray) || - MP_OBJ_IS_TYPE(value, &mp_type_memoryview) || - MP_OBJ_IS_TYPE(value, &mp_type_bytes)) { + MP_OBJ_IS_TYPE(value, &mp_type_bytearray) || + MP_OBJ_IS_TYPE(value, &mp_type_memoryview) || + MP_OBJ_IS_TYPE(value, &mp_type_bytes)) { mp_buffer_info_t bufinfo; mp_get_buffer_raise(value, &bufinfo, MP_BUFFER_READ); if (bufinfo.len != src_len) { @@ -143,11 +146,11 @@ STATIC mp_obj_t alarm_sleep_memory_subscr(mp_obj_t self_in, mp_obj_t index_in, m common_hal_alarm_sleep_memory_get_bytes(self, slice.start, items, len); return mp_obj_new_bytearray_by_ref(len, items); } -#endif + #endif } else { // Single index rather than slice. size_t index = mp_get_index(self->base.type, common_hal_alarm_sleep_memory_get_length(self), - index_in, false); + index_in, false); if (value == MP_OBJ_SENTINEL) { // load uint8_t value_out; diff --git a/shared-bindings/alarm/SleepMemory.h b/shared-bindings/alarm/SleepMemory.h index e7a56521b..c1667ec88 100644 --- a/shared-bindings/alarm/SleepMemory.h +++ b/shared-bindings/alarm/SleepMemory.h @@ -34,7 +34,7 @@ extern const mp_obj_type_t alarm_sleep_memory_type; uint32_t common_hal_alarm_sleep_memory_get_length(alarm_sleep_memory_obj_t *self); -bool common_hal_alarm_sleep_memory_set_bytes(alarm_sleep_memory_obj_t *self, uint32_t start_index, const uint8_t* values, uint32_t len); -void common_hal_alarm_sleep_memory_get_bytes(alarm_sleep_memory_obj_t *self, uint32_t start_index, uint8_t* values, uint32_t len); +bool common_hal_alarm_sleep_memory_set_bytes(alarm_sleep_memory_obj_t *self, uint32_t start_index, const uint8_t *values, uint32_t len); +void common_hal_alarm_sleep_memory_get_bytes(alarm_sleep_memory_obj_t *self, uint32_t start_index, uint8_t *values, uint32_t len); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_ALARM_SLEEPMEMORY_H diff --git a/shared-bindings/alarm/__init__.c b/shared-bindings/alarm/__init__.c index 7023c70e5..a7af63f02 100644 --- a/shared-bindings/alarm/__init__.c +++ b/shared-bindings/alarm/__init__.c @@ -168,7 +168,7 @@ STATIC MP_DEFINE_CONST_DICT(alarm_pin_globals, alarm_pin_globals_table); STATIC const mp_obj_module_t alarm_pin_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&alarm_pin_globals, + .globals = (mp_obj_dict_t *)&alarm_pin_globals, }; STATIC const mp_map_elem_t alarm_time_globals_table[] = { @@ -181,7 +181,7 @@ STATIC MP_DEFINE_CONST_DICT(alarm_time_globals, alarm_time_globals_table); STATIC const mp_obj_module_t alarm_time_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&alarm_time_globals, + .globals = (mp_obj_dict_t *)&alarm_time_globals, }; STATIC const mp_map_elem_t alarm_touch_globals_table[] = { @@ -193,7 +193,7 @@ STATIC MP_DEFINE_CONST_DICT(alarm_touch_globals, alarm_touch_globals_table); STATIC const mp_obj_module_t alarm_touch_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&alarm_touch_globals, + .globals = (mp_obj_dict_t *)&alarm_touch_globals, }; // The module table is mutable because .wake_alarm is a mutable attribute. @@ -205,7 +205,7 @@ STATIC mp_map_elem_t alarm_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_light_sleep_until_alarms), MP_OBJ_FROM_PTR(&alarm_light_sleep_until_alarms_obj) }, { MP_ROM_QSTR(MP_QSTR_exit_and_deep_sleep_until_alarms), - MP_OBJ_FROM_PTR(&alarm_exit_and_deep_sleep_until_alarms_obj) }, + MP_OBJ_FROM_PTR(&alarm_exit_and_deep_sleep_until_alarms_obj) }, { MP_ROM_QSTR(MP_QSTR_pin), MP_OBJ_FROM_PTR(&alarm_pin_module) }, { MP_ROM_QSTR(MP_QSTR_time), MP_OBJ_FROM_PTR(&alarm_time_module) }, @@ -240,5 +240,5 @@ void alarm_save_wake_alarm(void) { const mp_obj_module_t alarm_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&alarm_module_globals, + .globals = (mp_obj_dict_t *)&alarm_module_globals, }; diff --git a/shared-bindings/alarm/pin/PinAlarm.c b/shared-bindings/alarm/pin/PinAlarm.c index 89de016bc..04063e89c 100644 --- a/shared-bindings/alarm/pin/PinAlarm.c +++ b/shared-bindings/alarm/pin/PinAlarm.c @@ -89,7 +89,7 @@ STATIC mp_obj_t alarm_pin_pinalarm_make_new(const mp_obj_type_t *type, mp_uint_t //| STATIC mp_obj_t alarm_pin_pinalarm_obj_get_pin(mp_obj_t self_in) { alarm_pin_pinalarm_obj_t *self = MP_OBJ_TO_PTR(self_in); - mcu_pin_obj_t* pin = common_hal_alarm_pin_pinalarm_get_pin(self); + mcu_pin_obj_t *pin = common_hal_alarm_pin_pinalarm_get_pin(self); if (pin == NULL) { return mp_const_none; } diff --git a/shared-bindings/alarm/time/TimeAlarm.c b/shared-bindings/alarm/time/TimeAlarm.c index 1c9b8d37c..46d623489 100644 --- a/shared-bindings/alarm/time/TimeAlarm.c +++ b/shared-bindings/alarm/time/TimeAlarm.c @@ -57,7 +57,7 @@ mp_obj_t MP_WEAK rtc_get_time_source_time(void) { //| ... //| STATIC mp_obj_t alarm_time_timealarm_make_new(const mp_obj_type_t *type, - mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { alarm_time_timealarm_obj_t *self = m_new_obj(alarm_time_timealarm_obj_t); self->base.type = &alarm_time_timealarm_type; @@ -85,20 +85,20 @@ STATIC mp_obj_t alarm_time_timealarm_make_new(const mp_obj_type_t *type, mp_float_t monotonic_time_now = common_hal_time_monotonic_ms() / 1000.0; if (have_epoch) { -#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_NONE + #if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_NONE mp_raise_ValueError(translate("epoch_time not supported on this board")); -#else + #else mp_uint_t epoch_time_secs = mp_obj_int_get_checked(args[ARG_epoch_time].u_obj); timeutils_struct_time_t tm; struct_time_to_tm(rtc_get_time_source_time(), &tm); mp_uint_t epoch_secs_now = timeutils_seconds_since_epoch(tm.tm_year, tm.tm_mon, tm.tm_mday, - tm.tm_hour, tm.tm_min, tm.tm_sec); + tm.tm_hour, tm.tm_min, tm.tm_sec); // How far in the future (in secs) is the requested time? mp_int_t epoch_diff = epoch_time_secs - epoch_secs_now; // Convert it to a future monotonic time. monotonic_time = monotonic_time_now + epoch_diff; -#endif + #endif } if (monotonic_time < monotonic_time_now) { diff --git a/shared-bindings/alarm/touch/TouchAlarm.c b/shared-bindings/alarm/touch/TouchAlarm.c index 4259b71bd..589229de8 100644 --- a/shared-bindings/alarm/touch/TouchAlarm.c +++ b/shared-bindings/alarm/touch/TouchAlarm.c @@ -43,7 +43,7 @@ //| ... //| STATIC mp_obj_t alarm_touch_touchalarm_make_new(const mp_obj_type_t *type, - mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { alarm_touch_touchalarm_obj_t *self = m_new_obj(alarm_touch_touchalarm_obj_t); self->base.type = &alarm_touch_touchalarm_type; diff --git a/shared-bindings/analogio/AnalogIn.c b/shared-bindings/analogio/AnalogIn.c index 328466b0d..a7756b617 100644 --- a/shared-bindings/analogio/AnalogIn.c +++ b/shared-bindings/analogio/AnalogIn.c @@ -56,7 +56,7 @@ //| ... //| STATIC mp_obj_t analogio_analogin_make_new(const mp_obj_type_t *type, - mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { + mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { // check number of arguments mp_arg_check_num(n_args, kw_args, 1, 1, false); @@ -75,9 +75,9 @@ STATIC mp_obj_t analogio_analogin_make_new(const mp_obj_type_t *type, //| ... //| STATIC mp_obj_t analogio_analogin_deinit(mp_obj_t self_in) { - analogio_analogin_obj_t *self = MP_OBJ_TO_PTR(self_in); - common_hal_analogio_analogin_deinit(self); - return mp_const_none; + analogio_analogin_obj_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_analogio_analogin_deinit(self); + return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_1(analogio_analogin_deinit_obj, analogio_analogin_deinit); @@ -140,7 +140,7 @@ STATIC mp_obj_t analogio_analogin_obj_get_reference_voltage(mp_obj_t self_in) { } } MP_DEFINE_CONST_FUN_OBJ_1(analogio_analogin_get_reference_voltage_obj, - analogio_analogin_obj_get_reference_voltage); + analogio_analogin_obj_get_reference_voltage); const mp_obj_property_t analogio_analogin_reference_voltage_obj = { .base.type = &mp_type_property, diff --git a/shared-bindings/analogio/AnalogIn.h b/shared-bindings/analogio/AnalogIn.h index 32f11e08f..9f8041626 100644 --- a/shared-bindings/analogio/AnalogIn.h +++ b/shared-bindings/analogio/AnalogIn.h @@ -32,10 +32,10 @@ extern const mp_obj_type_t analogio_analogin_type; -void common_hal_analogio_analogin_construct(analogio_analogin_obj_t* self, const mcu_pin_obj_t *pin); -void common_hal_analogio_analogin_deinit(analogio_analogin_obj_t* self); -bool common_hal_analogio_analogin_deinited(analogio_analogin_obj_t* self); -uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t* self); -float common_hal_analogio_analogin_get_reference_voltage(analogio_analogin_obj_t* self); +void common_hal_analogio_analogin_construct(analogio_analogin_obj_t *self, const mcu_pin_obj_t *pin); +void common_hal_analogio_analogin_deinit(analogio_analogin_obj_t *self); +bool common_hal_analogio_analogin_deinited(analogio_analogin_obj_t *self); +uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self); +float common_hal_analogio_analogin_get_reference_voltage(analogio_analogin_obj_t *self); #endif // __MICROPY_INCLUDED_SHARED_BINDINGS_ANALOGIO_ANALOGIN_H__ diff --git a/shared-bindings/analogio/AnalogOut.c b/shared-bindings/analogio/AnalogOut.c index f3321a725..f65522828 100644 --- a/shared-bindings/analogio/AnalogOut.c +++ b/shared-bindings/analogio/AnalogOut.c @@ -104,16 +104,16 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(analogio_analogout___exit___obj, 4, 4 //| resolution, the value is 16-bit.""" //| STATIC mp_obj_t analogio_analogout_obj_set_value(mp_obj_t self_in, mp_obj_t value) { - analogio_analogout_obj_t *self = MP_OBJ_TO_PTR(self_in); - if (common_hal_analogio_analogout_deinited(self)) { - raise_deinited_error(); - } - uint32_t v = mp_obj_get_int(value); - if (v >= (1 << 16)) { - mp_raise_ValueError(translate("AnalogOut is only 16 bits. Value must be less than 65536.")); - } - common_hal_analogio_analogout_set_value(self, v); - return mp_const_none; + analogio_analogout_obj_t *self = MP_OBJ_TO_PTR(self_in); + if (common_hal_analogio_analogout_deinited(self)) { + raise_deinited_error(); + } + uint32_t v = mp_obj_get_int(value); + if (v >= (1 << 16)) { + mp_raise_ValueError(translate("AnalogOut is only 16 bits. Value must be less than 65536.")); + } + common_hal_analogio_analogout_set_value(self, v); + return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_2(analogio_analogout_set_value_obj, analogio_analogout_obj_set_value); diff --git a/shared-bindings/analogio/AnalogOut.h b/shared-bindings/analogio/AnalogOut.h index e4e94548b..736afd001 100644 --- a/shared-bindings/analogio/AnalogOut.h +++ b/shared-bindings/analogio/AnalogOut.h @@ -32,7 +32,7 @@ extern const mp_obj_type_t analogio_analogout_type; -void common_hal_analogio_analogout_construct(analogio_analogout_obj_t* self, const mcu_pin_obj_t *pin); +void common_hal_analogio_analogout_construct(analogio_analogout_obj_t *self, const mcu_pin_obj_t *pin); void common_hal_analogio_analogout_deinit(analogio_analogout_obj_t *self); bool common_hal_analogio_analogout_deinited(analogio_analogout_obj_t *self); void common_hal_analogio_analogout_set_value(analogio_analogout_obj_t *self, uint16_t value); diff --git a/shared-bindings/analogio/__init__.c b/shared-bindings/analogio/__init__.c index 1f059f340..4e5aebf01 100644 --- a/shared-bindings/analogio/__init__.c +++ b/shared-bindings/analogio/__init__.c @@ -70,5 +70,5 @@ STATIC MP_DEFINE_CONST_DICT(analogio_module_globals, analogio_module_globals_tab const mp_obj_module_t analogio_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&analogio_module_globals, + .globals = (mp_obj_dict_t *)&analogio_module_globals, }; diff --git a/shared-bindings/audiobusio/I2SOut.c b/shared-bindings/audiobusio/I2SOut.c index 25b536c34..b174cf3a5 100644 --- a/shared-bindings/audiobusio/I2SOut.c +++ b/shared-bindings/audiobusio/I2SOut.c @@ -91,10 +91,10 @@ //| ... //| STATIC mp_obj_t audiobusio_i2sout_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { -#if !CIRCUITPY_AUDIOBUSIO_I2SOUT + #if !CIRCUITPY_AUDIOBUSIO_I2SOUT mp_raise_NotImplementedError(translate("I2SOut not available")); return NULL; // Not reachable. -#else + #else enum { ARG_bit_clock, ARG_word_select, ARG_data, ARG_left_justified }; static const mp_arg_t allowed_args[] = { { MP_QSTR_bit_clock, MP_ARG_OBJ | MP_ARG_REQUIRED }, @@ -114,7 +114,7 @@ STATIC mp_obj_t audiobusio_i2sout_make_new(const mp_obj_type_t *type, size_t n_a common_hal_audiobusio_i2sout_construct(self, bit_clock, word_select, data, args[ARG_left_justified].u_bool); return MP_OBJ_FROM_PTR(self); -#endif + #endif } #if CIRCUITPY_AUDIOBUSIO_I2SOUT @@ -263,7 +263,7 @@ const mp_obj_property_t audiobusio_i2sout_paused_obj = { STATIC const mp_rom_map_elem_t audiobusio_i2sout_locals_dict_table[] = { // Methods -#if CIRCUITPY_AUDIOBUSIO_I2SOUT + #if CIRCUITPY_AUDIOBUSIO_I2SOUT { MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&audiobusio_i2sout_deinit_obj) }, { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&audiobusio_i2sout_deinit_obj) }, { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) }, @@ -276,7 +276,7 @@ STATIC const mp_rom_map_elem_t audiobusio_i2sout_locals_dict_table[] = { // Properties { MP_ROM_QSTR(MP_QSTR_playing), MP_ROM_PTR(&audiobusio_i2sout_playing_obj) }, { MP_ROM_QSTR(MP_QSTR_paused), MP_ROM_PTR(&audiobusio_i2sout_paused_obj) }, -#endif // CIRCUITPY_AUDIOBUSIO_I2SOUT + #endif // CIRCUITPY_AUDIOBUSIO_I2SOUT }; STATIC MP_DEFINE_CONST_DICT(audiobusio_i2sout_locals_dict, audiobusio_i2sout_locals_dict_table); @@ -284,5 +284,5 @@ const mp_obj_type_t audiobusio_i2sout_type = { { &mp_type_type }, .name = MP_QSTR_I2SOut, .make_new = audiobusio_i2sout_make_new, - .locals_dict = (mp_obj_dict_t*)&audiobusio_i2sout_locals_dict, + .locals_dict = (mp_obj_dict_t *)&audiobusio_i2sout_locals_dict, }; diff --git a/shared-bindings/audiobusio/I2SOut.h b/shared-bindings/audiobusio/I2SOut.h index 55527dc73..64dcc3bf6 100644 --- a/shared-bindings/audiobusio/I2SOut.h +++ b/shared-bindings/audiobusio/I2SOut.h @@ -35,18 +35,18 @@ extern const mp_obj_type_t audiobusio_i2sout_type; // Some boards don't have the I2SOut pins available. #if CIRCUITPY_AUDIOBUSIO_I2SOUT -void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t* self, - const mcu_pin_obj_t* bit_clock, const mcu_pin_obj_t* word_select, const mcu_pin_obj_t* data, +void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t *self, + const mcu_pin_obj_t *bit_clock, const mcu_pin_obj_t *word_select, const mcu_pin_obj_t *data, bool left_justified); -void common_hal_audiobusio_i2sout_deinit(audiobusio_i2sout_obj_t* self); -bool common_hal_audiobusio_i2sout_deinited(audiobusio_i2sout_obj_t* self); -void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t* self, mp_obj_t sample, bool loop); -void common_hal_audiobusio_i2sout_stop(audiobusio_i2sout_obj_t* self); -bool common_hal_audiobusio_i2sout_get_playing(audiobusio_i2sout_obj_t* self); -void common_hal_audiobusio_i2sout_pause(audiobusio_i2sout_obj_t* self); -void common_hal_audiobusio_i2sout_resume(audiobusio_i2sout_obj_t* self); -bool common_hal_audiobusio_i2sout_get_paused(audiobusio_i2sout_obj_t* self); +void common_hal_audiobusio_i2sout_deinit(audiobusio_i2sout_obj_t *self); +bool common_hal_audiobusio_i2sout_deinited(audiobusio_i2sout_obj_t *self); +void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t *self, mp_obj_t sample, bool loop); +void common_hal_audiobusio_i2sout_stop(audiobusio_i2sout_obj_t *self); +bool common_hal_audiobusio_i2sout_get_playing(audiobusio_i2sout_obj_t *self); +void common_hal_audiobusio_i2sout_pause(audiobusio_i2sout_obj_t *self); +void common_hal_audiobusio_i2sout_resume(audiobusio_i2sout_obj_t *self); +bool common_hal_audiobusio_i2sout_get_paused(audiobusio_i2sout_obj_t *self); #endif // CIRCUITPY_AUDIOBUSIO_I2SOUT diff --git a/shared-bindings/audiobusio/PDMIn.c b/shared-bindings/audiobusio/PDMIn.c index a3cc8b07e..5a648e165 100644 --- a/shared-bindings/audiobusio/PDMIn.c +++ b/shared-bindings/audiobusio/PDMIn.c @@ -84,9 +84,9 @@ //| ... //| STATIC mp_obj_t audiobusio_pdmin_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { -#if !CIRCUITPY_AUDIOBUSIO_PDMIN + #if !CIRCUITPY_AUDIOBUSIO_PDMIN mp_raise_NotImplementedError(translate("PDMIn not available")); -#else + #else enum { ARG_clock_pin, ARG_data_pin, ARG_sample_rate, ARG_bit_depth, ARG_mono, ARG_oversample, ARG_startup_delay }; static const mp_arg_t allowed_args[] = { { MP_QSTR_clock_pin, MP_ARG_REQUIRED | MP_ARG_OBJ }, @@ -129,13 +129,13 @@ STATIC mp_obj_t audiobusio_pdmin_make_new(const mp_obj_type_t *type, size_t n_ar } common_hal_audiobusio_pdmin_construct(self, clock_pin, data_pin, sample_rate, - bit_depth, mono, oversample); + bit_depth, mono, oversample); // Wait for the microphone to start up. Some start in 10 msecs; some take as much as 100 msecs. mp_hal_delay_ms(startup_delay * 1000); return MP_OBJ_FROM_PTR(self); -#endif + #endif } #if CIRCUITPY_AUDIOBUSIO_PDMIN @@ -248,7 +248,7 @@ const mp_obj_type_t audiobusio_pdmin_type = { { &mp_type_type }, .name = MP_QSTR_PDMIn, .make_new = audiobusio_pdmin_make_new, -#if CIRCUITPY_AUDIOBUSIO_PDMIN - .locals_dict = (mp_obj_dict_t*)&audiobusio_pdmin_locals_dict, -#endif + #if CIRCUITPY_AUDIOBUSIO_PDMIN + .locals_dict = (mp_obj_dict_t *)&audiobusio_pdmin_locals_dict, + #endif }; diff --git a/shared-bindings/audiobusio/PDMIn.h b/shared-bindings/audiobusio/PDMIn.h index e89fc7e23..0516bce61 100644 --- a/shared-bindings/audiobusio/PDMIn.h +++ b/shared-bindings/audiobusio/PDMIn.h @@ -34,15 +34,15 @@ extern const mp_obj_type_t audiobusio_pdmin_type; #if CIRCUITPY_AUDIOBUSIO_PDMIN -void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t* self, - const mcu_pin_obj_t* clock_pin, const mcu_pin_obj_t* data_pin, +void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t *self, + const mcu_pin_obj_t *clock_pin, const mcu_pin_obj_t *data_pin, uint32_t sample_rate, uint8_t bit_depth, bool mono, uint8_t oversample); -void common_hal_audiobusio_pdmin_deinit(audiobusio_pdmin_obj_t* self); -bool common_hal_audiobusio_pdmin_deinited(audiobusio_pdmin_obj_t* self); -uint32_t common_hal_audiobusio_pdmin_record_to_buffer(audiobusio_pdmin_obj_t* self, - uint16_t* buffer, uint32_t length); -uint8_t common_hal_audiobusio_pdmin_get_bit_depth(audiobusio_pdmin_obj_t* self); -uint32_t common_hal_audiobusio_pdmin_get_sample_rate(audiobusio_pdmin_obj_t* self); +void common_hal_audiobusio_pdmin_deinit(audiobusio_pdmin_obj_t *self); +bool common_hal_audiobusio_pdmin_deinited(audiobusio_pdmin_obj_t *self); +uint32_t common_hal_audiobusio_pdmin_record_to_buffer(audiobusio_pdmin_obj_t *self, + uint16_t *buffer, uint32_t length); +uint8_t common_hal_audiobusio_pdmin_get_bit_depth(audiobusio_pdmin_obj_t *self); +uint32_t common_hal_audiobusio_pdmin_get_sample_rate(audiobusio_pdmin_obj_t *self); // TODO(tannewt): Add record to file #endif diff --git a/shared-bindings/audiobusio/__init__.c b/shared-bindings/audiobusio/__init__.c index 89ccbb88b..23e246ec2 100644 --- a/shared-bindings/audiobusio/__init__.c +++ b/shared-bindings/audiobusio/__init__.c @@ -56,5 +56,5 @@ STATIC MP_DEFINE_CONST_DICT(audiobusio_module_globals, audiobusio_module_globals const mp_obj_module_t audiobusio_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&audiobusio_module_globals, + .globals = (mp_obj_dict_t *)&audiobusio_module_globals, }; diff --git a/shared-bindings/audiocore/RawSample.c b/shared-bindings/audiocore/RawSample.c index df31ee2e0..23a2d3f0b 100644 --- a/shared-bindings/audiocore/RawSample.c +++ b/shared-bindings/audiocore/RawSample.c @@ -91,9 +91,9 @@ STATIC mp_obj_t audioio_rawsample_make_new(const mp_obj_type_t *type, size_t n_a } else if (bufinfo.typecode != 'b' && bufinfo.typecode != 'B' && bufinfo.typecode != BYTEARRAY_TYPECODE) { mp_raise_ValueError(translate("sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' or 'B'")); } - common_hal_audioio_rawsample_construct(self, ((uint8_t*)bufinfo.buf), bufinfo.len, - bytes_per_sample, signed_samples, args[ARG_channel_count].u_int, - args[ARG_sample_rate].u_int); + common_hal_audioio_rawsample_construct(self, ((uint8_t *)bufinfo.buf), bufinfo.len, + bytes_per_sample, signed_samples, args[ARG_channel_count].u_int, + args[ARG_sample_rate].u_int); } else { mp_raise_TypeError(translate("buffer must be a bytes-like object")); } @@ -189,6 +189,6 @@ const mp_obj_type_t audioio_rawsample_type = { { &mp_type_type }, .name = MP_QSTR_RawSample, .make_new = audioio_rawsample_make_new, - .locals_dict = (mp_obj_dict_t*)&audioio_rawsample_locals_dict, + .locals_dict = (mp_obj_dict_t *)&audioio_rawsample_locals_dict, .protocol = &audioio_rawsample_proto, }; diff --git a/shared-bindings/audiocore/RawSample.h b/shared-bindings/audiocore/RawSample.h index 61f61a066..b07add2dd 100644 --- a/shared-bindings/audiocore/RawSample.h +++ b/shared-bindings/audiocore/RawSample.h @@ -32,15 +32,15 @@ extern const mp_obj_type_t audioio_rawsample_type; -void common_hal_audioio_rawsample_construct(audioio_rawsample_obj_t* self, - uint8_t* buffer, uint32_t len, uint8_t bytes_per_sample, bool samples_signed, +void common_hal_audioio_rawsample_construct(audioio_rawsample_obj_t *self, + uint8_t *buffer, uint32_t len, uint8_t bytes_per_sample, bool samples_signed, uint8_t channel_count, uint32_t sample_rate); -void common_hal_audioio_rawsample_deinit(audioio_rawsample_obj_t* self); -bool common_hal_audioio_rawsample_deinited(audioio_rawsample_obj_t* self); -uint32_t common_hal_audioio_rawsample_get_sample_rate(audioio_rawsample_obj_t* self); -uint8_t common_hal_audioio_rawsample_get_bits_per_sample(audioio_rawsample_obj_t* self); -uint8_t common_hal_audioio_rawsample_get_channel_count(audioio_rawsample_obj_t* self); -void common_hal_audioio_rawsample_set_sample_rate(audioio_rawsample_obj_t* self, uint32_t sample_rate); +void common_hal_audioio_rawsample_deinit(audioio_rawsample_obj_t *self); +bool common_hal_audioio_rawsample_deinited(audioio_rawsample_obj_t *self); +uint32_t common_hal_audioio_rawsample_get_sample_rate(audioio_rawsample_obj_t *self); +uint8_t common_hal_audioio_rawsample_get_bits_per_sample(audioio_rawsample_obj_t *self); +uint8_t common_hal_audioio_rawsample_get_channel_count(audioio_rawsample_obj_t *self); +void common_hal_audioio_rawsample_set_sample_rate(audioio_rawsample_obj_t *self, uint32_t sample_rate); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOIO_RAWSAMPLE_H diff --git a/shared-bindings/audiocore/WaveFile.c b/shared-bindings/audiocore/WaveFile.c index 3b4c9fd97..73943f980 100644 --- a/shared-bindings/audiocore/WaveFile.c +++ b/shared-bindings/audiocore/WaveFile.c @@ -86,7 +86,7 @@ STATIC mp_obj_t audioio_wavefile_make_new(const mp_obj_type_t *type, size_t n_ar buffer_size = bufinfo.len; } common_hal_audioio_wavefile_construct(self, MP_OBJ_TO_PTR(args[0]), - buffer, buffer_size); + buffer, buffer_size); return MP_OBJ_FROM_PTR(self); } @@ -214,6 +214,6 @@ const mp_obj_type_t audioio_wavefile_type = { { &mp_type_type }, .name = MP_QSTR_WaveFile, .make_new = audioio_wavefile_make_new, - .locals_dict = (mp_obj_dict_t*)&audioio_wavefile_locals_dict, + .locals_dict = (mp_obj_dict_t *)&audioio_wavefile_locals_dict, .protocol = &audioio_wavefile_proto, }; diff --git a/shared-bindings/audiocore/WaveFile.h b/shared-bindings/audiocore/WaveFile.h index f4a172319..29140b4a2 100644 --- a/shared-bindings/audiocore/WaveFile.h +++ b/shared-bindings/audiocore/WaveFile.h @@ -34,14 +34,14 @@ extern const mp_obj_type_t audioio_wavefile_type; -void common_hal_audioio_wavefile_construct(audioio_wavefile_obj_t* self, - pyb_file_obj_t* file, uint8_t *buffer, size_t buffer_size); +void common_hal_audioio_wavefile_construct(audioio_wavefile_obj_t *self, + pyb_file_obj_t *file, uint8_t *buffer, size_t buffer_size); -void common_hal_audioio_wavefile_deinit(audioio_wavefile_obj_t* self); -bool common_hal_audioio_wavefile_deinited(audioio_wavefile_obj_t* self); -uint32_t common_hal_audioio_wavefile_get_sample_rate(audioio_wavefile_obj_t* self); -void common_hal_audioio_wavefile_set_sample_rate(audioio_wavefile_obj_t* self, uint32_t sample_rate); -uint8_t common_hal_audioio_wavefile_get_bits_per_sample(audioio_wavefile_obj_t* self); -uint8_t common_hal_audioio_wavefile_get_channel_count(audioio_wavefile_obj_t* self); +void common_hal_audioio_wavefile_deinit(audioio_wavefile_obj_t *self); +bool common_hal_audioio_wavefile_deinited(audioio_wavefile_obj_t *self); +uint32_t common_hal_audioio_wavefile_get_sample_rate(audioio_wavefile_obj_t *self); +void common_hal_audioio_wavefile_set_sample_rate(audioio_wavefile_obj_t *self, uint32_t sample_rate); +uint8_t common_hal_audioio_wavefile_get_bits_per_sample(audioio_wavefile_obj_t *self); +uint8_t common_hal_audioio_wavefile_get_channel_count(audioio_wavefile_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOIO_WAVEFILE_H diff --git a/shared-bindings/audiocore/__init__.c b/shared-bindings/audiocore/__init__.c index b400b9454..9fe4a81c4 100644 --- a/shared-bindings/audiocore/__init__.c +++ b/shared-bindings/audiocore/__init__.c @@ -33,7 +33,7 @@ #include "shared-bindings/audiocore/__init__.h" #include "shared-bindings/audiocore/RawSample.h" #include "shared-bindings/audiocore/WaveFile.h" -//#include "shared-bindings/audiomixer/Mixer.h" +// #include "shared-bindings/audiomixer/Mixer.h" //| """Support for audio samples""" //| @@ -48,5 +48,5 @@ STATIC MP_DEFINE_CONST_DICT(audiocore_module_globals, audiocore_module_globals_t const mp_obj_module_t audiocore_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&audiocore_module_globals, + .globals = (mp_obj_dict_t *)&audiocore_module_globals, }; diff --git a/shared-bindings/audioio/AudioOut.c b/shared-bindings/audioio/AudioOut.c index 0d479be09..6a6aeea59 100644 --- a/shared-bindings/audioio/AudioOut.c +++ b/shared-bindings/audioio/AudioOut.c @@ -273,5 +273,5 @@ const mp_obj_type_t audioio_audioout_type = { { &mp_type_type }, .name = MP_QSTR_AudioOut, .make_new = audioio_audioout_make_new, - .locals_dict = (mp_obj_dict_t*)&audioio_audioout_locals_dict, + .locals_dict = (mp_obj_dict_t *)&audioio_audioout_locals_dict, }; diff --git a/shared-bindings/audioio/AudioOut.h b/shared-bindings/audioio/AudioOut.h index 1076ac5cc..163d7848b 100644 --- a/shared-bindings/audioio/AudioOut.h +++ b/shared-bindings/audioio/AudioOut.h @@ -34,16 +34,16 @@ extern const mp_obj_type_t audioio_audioout_type; // left_channel will always be non-NULL but right_channel may be for mono output. -void common_hal_audioio_audioout_construct(audioio_audioout_obj_t* self, - const mcu_pin_obj_t* left_channel, const mcu_pin_obj_t* right_channel, uint16_t default_value); +void common_hal_audioio_audioout_construct(audioio_audioout_obj_t *self, + const mcu_pin_obj_t *left_channel, const mcu_pin_obj_t *right_channel, uint16_t default_value); -void common_hal_audioio_audioout_deinit(audioio_audioout_obj_t* self); -bool common_hal_audioio_audioout_deinited(audioio_audioout_obj_t* self); -void common_hal_audioio_audioout_play(audioio_audioout_obj_t* self, mp_obj_t sample, bool loop); -void common_hal_audioio_audioout_stop(audioio_audioout_obj_t* self); -bool common_hal_audioio_audioout_get_playing(audioio_audioout_obj_t* self); -void common_hal_audioio_audioout_pause(audioio_audioout_obj_t* self); -void common_hal_audioio_audioout_resume(audioio_audioout_obj_t* self); -bool common_hal_audioio_audioout_get_paused(audioio_audioout_obj_t* self); +void common_hal_audioio_audioout_deinit(audioio_audioout_obj_t *self); +bool common_hal_audioio_audioout_deinited(audioio_audioout_obj_t *self); +void common_hal_audioio_audioout_play(audioio_audioout_obj_t *self, mp_obj_t sample, bool loop); +void common_hal_audioio_audioout_stop(audioio_audioout_obj_t *self); +bool common_hal_audioio_audioout_get_playing(audioio_audioout_obj_t *self); +void common_hal_audioio_audioout_pause(audioio_audioout_obj_t *self); +void common_hal_audioio_audioout_resume(audioio_audioout_obj_t *self); +bool common_hal_audioio_audioout_get_paused(audioio_audioout_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOIO_AUDIOOUT_H diff --git a/shared-bindings/audioio/__init__.c b/shared-bindings/audioio/__init__.c index a9c58e864..426f756d4 100644 --- a/shared-bindings/audioio/__init__.c +++ b/shared-bindings/audioio/__init__.c @@ -59,5 +59,5 @@ STATIC MP_DEFINE_CONST_DICT(audioio_module_globals, audioio_module_globals_table const mp_obj_module_t audioio_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&audioio_module_globals, + .globals = (mp_obj_dict_t *)&audioio_module_globals, }; diff --git a/shared-bindings/audiomixer/Mixer.c b/shared-bindings/audiomixer/Mixer.c index 293b19b05..95619ca95 100644 --- a/shared-bindings/audiomixer/Mixer.c +++ b/shared-bindings/audiomixer/Mixer.c @@ -112,9 +112,9 @@ STATIC mp_obj_t audiomixer_mixer_make_new(const mp_obj_type_t *type, size_t n_ar self->base.type = &audiomixer_mixer_type; common_hal_audiomixer_mixer_construct(self, voice_count, args[ARG_buffer_size].u_int, bits_per_sample, args[ARG_samples_signed].u_bool, channel_count, sample_rate); - for(int v=0; v<voice_count; v++){ - self->voice[v] = audiomixer_mixervoice_type.make_new(&audiomixer_mixervoice_type, 0, 0, NULL); - common_hal_audiomixer_mixervoice_set_parent(self->voice[v], self); + for (int v = 0; v < voice_count; v++) { + self->voice[v] = audiomixer_mixervoice_type.make_new(&audiomixer_mixervoice_type, 0, 0, NULL); + common_hal_audiomixer_mixervoice_set_parent(self->voice[v], self); } self->voice_tuple = mp_obj_new_tuple(self->voice_count, self->voice); @@ -280,7 +280,7 @@ STATIC const mp_rom_map_elem_t audiomixer_mixer_locals_dict_table[] = { // Properties { MP_ROM_QSTR(MP_QSTR_playing), MP_ROM_PTR(&audiomixer_mixer_playing_obj) }, { MP_ROM_QSTR(MP_QSTR_sample_rate), MP_ROM_PTR(&audiomixer_mixer_sample_rate_obj) }, - { MP_ROM_QSTR(MP_QSTR_voice), MP_ROM_PTR(&audiomixer_mixer_voice_obj) } + { MP_ROM_QSTR(MP_QSTR_voice), MP_ROM_PTR(&audiomixer_mixer_voice_obj) } }; STATIC MP_DEFINE_CONST_DICT(audiomixer_mixer_locals_dict, audiomixer_mixer_locals_dict_table); @@ -298,6 +298,6 @@ const mp_obj_type_t audiomixer_mixer_type = { { &mp_type_type }, .name = MP_QSTR_Mixer, .make_new = audiomixer_mixer_make_new, - .locals_dict = (mp_obj_dict_t*)&audiomixer_mixer_locals_dict, + .locals_dict = (mp_obj_dict_t *)&audiomixer_mixer_locals_dict, .protocol = &audiomixer_mixer_proto, }; diff --git a/shared-bindings/audiomixer/Mixer.h b/shared-bindings/audiomixer/Mixer.h index a99e1bf62..88592a1cb 100644 --- a/shared-bindings/audiomixer/Mixer.h +++ b/shared-bindings/audiomixer/Mixer.h @@ -34,20 +34,20 @@ extern const mp_obj_type_t audiomixer_mixer_type; extern const mp_obj_type_t audiomixer_mixervoice_type; -void common_hal_audiomixer_mixer_construct(audiomixer_mixer_obj_t* self, - uint8_t voice_count, - uint32_t buffer_size, - uint8_t bits_per_sample, - bool samples_signed, - uint8_t channel_count, - uint32_t sample_rate); +void common_hal_audiomixer_mixer_construct(audiomixer_mixer_obj_t *self, + uint8_t voice_count, + uint32_t buffer_size, + uint8_t bits_per_sample, + bool samples_signed, + uint8_t channel_count, + uint32_t sample_rate); -void common_hal_audiomixer_mixer_deinit(audiomixer_mixer_obj_t* self); -bool common_hal_audiomixer_mixer_deinited(audiomixer_mixer_obj_t* self); +void common_hal_audiomixer_mixer_deinit(audiomixer_mixer_obj_t *self); +bool common_hal_audiomixer_mixer_deinited(audiomixer_mixer_obj_t *self); -bool common_hal_audiomixer_mixer_get_playing(audiomixer_mixer_obj_t* self); -uint32_t common_hal_audiomixer_mixer_get_sample_rate(audiomixer_mixer_obj_t* self); -uint8_t common_hal_audiomixer_mixer_get_channel_count(audiomixer_mixer_obj_t* self); -uint8_t common_hal_audiomixer_mixer_get_bits_per_sample(audiomixer_mixer_obj_t* self); +bool common_hal_audiomixer_mixer_get_playing(audiomixer_mixer_obj_t *self); +uint32_t common_hal_audiomixer_mixer_get_sample_rate(audiomixer_mixer_obj_t *self); +uint8_t common_hal_audiomixer_mixer_get_channel_count(audiomixer_mixer_obj_t *self); +uint8_t common_hal_audiomixer_mixer_get_bits_per_sample(audiomixer_mixer_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOMIXER_MIXER_H diff --git a/shared-bindings/audiomixer/MixerVoice.c b/shared-bindings/audiomixer/MixerVoice.c index af00e1055..c519f7ac4 100644 --- a/shared-bindings/audiomixer/MixerVoice.c +++ b/shared-bindings/audiomixer/MixerVoice.c @@ -117,7 +117,7 @@ STATIC mp_obj_t audiomixer_mixervoice_obj_set_level(size_t n_args, const mp_obj_ mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - float level = mp_obj_get_float(args[ARG_level].u_obj); + float level = mp_obj_get_float(args[ARG_level].u_obj); if (level > 1 || level < 0) { mp_raise_ValueError(translate("level must be between 0 and 1")); @@ -170,5 +170,5 @@ const mp_obj_type_t audiomixer_mixervoice_type = { { &mp_type_type }, .name = MP_QSTR_MixerVoice, .make_new = audiomixer_mixervoice_make_new, - .locals_dict = (mp_obj_dict_t*)&audiomixer_mixervoice_locals_dict, + .locals_dict = (mp_obj_dict_t *)&audiomixer_mixervoice_locals_dict, }; diff --git a/shared-bindings/audiomixer/MixerVoice.h b/shared-bindings/audiomixer/MixerVoice.h index 83098bc9d..bce463276 100644 --- a/shared-bindings/audiomixer/MixerVoice.h +++ b/shared-bindings/audiomixer/MixerVoice.h @@ -36,12 +36,12 @@ extern const mp_obj_type_t audiomixer_mixer_type; extern const mp_obj_type_t audiomixer_mixervoice_type; void common_hal_audiomixer_mixervoice_construct(audiomixer_mixervoice_obj_t *self); -void common_hal_audiomixer_mixervoice_set_parent(audiomixer_mixervoice_obj_t* self, audiomixer_mixer_obj_t *parent); -void common_hal_audiomixer_mixervoice_play(audiomixer_mixervoice_obj_t* self, mp_obj_t sample, bool loop); -void common_hal_audiomixer_mixervoice_stop(audiomixer_mixervoice_obj_t* self); -float common_hal_audiomixer_mixervoice_get_level(audiomixer_mixervoice_obj_t* self); -void common_hal_audiomixer_mixervoice_set_level(audiomixer_mixervoice_obj_t* self, float gain); +void common_hal_audiomixer_mixervoice_set_parent(audiomixer_mixervoice_obj_t *self, audiomixer_mixer_obj_t *parent); +void common_hal_audiomixer_mixervoice_play(audiomixer_mixervoice_obj_t *self, mp_obj_t sample, bool loop); +void common_hal_audiomixer_mixervoice_stop(audiomixer_mixervoice_obj_t *self); +float common_hal_audiomixer_mixervoice_get_level(audiomixer_mixervoice_obj_t *self); +void common_hal_audiomixer_mixervoice_set_level(audiomixer_mixervoice_obj_t *self, float gain); -bool common_hal_audiomixer_mixervoice_get_playing(audiomixer_mixervoice_obj_t* self); +bool common_hal_audiomixer_mixervoice_get_playing(audiomixer_mixervoice_obj_t *self); #endif /* SHARED_BINDINGS_AUDIOMIXER_MIXERVOICE_H_ */ diff --git a/shared-bindings/audiomixer/__init__.c b/shared-bindings/audiomixer/__init__.c index 1146bb798..9d0bf676f 100644 --- a/shared-bindings/audiomixer/__init__.c +++ b/shared-bindings/audiomixer/__init__.c @@ -44,5 +44,5 @@ STATIC MP_DEFINE_CONST_DICT(audiomixer_module_globals, audiomixer_module_globals const mp_obj_module_t audiomixer_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&audiomixer_module_globals, + .globals = (mp_obj_dict_t *)&audiomixer_module_globals, }; diff --git a/shared-bindings/audiomp3/MP3Decoder.c b/shared-bindings/audiomp3/MP3Decoder.c index 85073bf89..bdbd14e9e 100644 --- a/shared-bindings/audiomp3/MP3Decoder.c +++ b/shared-bindings/audiomp3/MP3Decoder.c @@ -84,7 +84,7 @@ STATIC mp_obj_t audiomp3_mp3file_make_new(const mp_obj_type_t *type, size_t n_ar buffer_size = bufinfo.len; } common_hal_audiomp3_mp3file_construct(self, MP_OBJ_TO_PTR(args[0]), - buffer, buffer_size); + buffer, buffer_size); return MP_OBJ_FROM_PTR(self); } @@ -262,6 +262,6 @@ const mp_obj_type_t audiomp3_mp3file_type = { { &mp_type_type }, .name = MP_QSTR_MP3Decoder, .make_new = audiomp3_mp3file_make_new, - .locals_dict = (mp_obj_dict_t*)&audiomp3_mp3file_locals_dict, + .locals_dict = (mp_obj_dict_t *)&audiomp3_mp3file_locals_dict, .protocol = &audiomp3_mp3file_proto, }; diff --git a/shared-bindings/audiomp3/MP3Decoder.h b/shared-bindings/audiomp3/MP3Decoder.h index 36d525e93..2428cedf1 100644 --- a/shared-bindings/audiomp3/MP3Decoder.h +++ b/shared-bindings/audiomp3/MP3Decoder.h @@ -35,16 +35,16 @@ extern const mp_obj_type_t audiomp3_mp3file_type; -void common_hal_audiomp3_mp3file_construct(audiomp3_mp3file_obj_t* self, - pyb_file_obj_t* file, uint8_t *buffer, size_t buffer_size); +void common_hal_audiomp3_mp3file_construct(audiomp3_mp3file_obj_t *self, + pyb_file_obj_t *file, uint8_t *buffer, size_t buffer_size); -void common_hal_audiomp3_mp3file_set_file(audiomp3_mp3file_obj_t* self, pyb_file_obj_t* file); -void common_hal_audiomp3_mp3file_deinit(audiomp3_mp3file_obj_t* self); -bool common_hal_audiomp3_mp3file_deinited(audiomp3_mp3file_obj_t* self); -uint32_t common_hal_audiomp3_mp3file_get_sample_rate(audiomp3_mp3file_obj_t* self); -void common_hal_audiomp3_mp3file_set_sample_rate(audiomp3_mp3file_obj_t* self, uint32_t sample_rate); -uint8_t common_hal_audiomp3_mp3file_get_bits_per_sample(audiomp3_mp3file_obj_t* self); -uint8_t common_hal_audiomp3_mp3file_get_channel_count(audiomp3_mp3file_obj_t* self); -float common_hal_audiomp3_mp3file_get_rms_level(audiomp3_mp3file_obj_t* self); +void common_hal_audiomp3_mp3file_set_file(audiomp3_mp3file_obj_t *self, pyb_file_obj_t *file); +void common_hal_audiomp3_mp3file_deinit(audiomp3_mp3file_obj_t *self); +bool common_hal_audiomp3_mp3file_deinited(audiomp3_mp3file_obj_t *self); +uint32_t common_hal_audiomp3_mp3file_get_sample_rate(audiomp3_mp3file_obj_t *self); +void common_hal_audiomp3_mp3file_set_sample_rate(audiomp3_mp3file_obj_t *self, uint32_t sample_rate); +uint8_t common_hal_audiomp3_mp3file_get_bits_per_sample(audiomp3_mp3file_obj_t *self); +uint8_t common_hal_audiomp3_mp3file_get_channel_count(audiomp3_mp3file_obj_t *self); +float common_hal_audiomp3_mp3file_get_rms_level(audiomp3_mp3file_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOIO_MP3FILE_H diff --git a/shared-bindings/audiomp3/__init__.c b/shared-bindings/audiomp3/__init__.c index 62e5f56cb..29bdd0bb2 100644 --- a/shared-bindings/audiomp3/__init__.c +++ b/shared-bindings/audiomp3/__init__.c @@ -43,5 +43,5 @@ STATIC MP_DEFINE_CONST_DICT(audiomp3_module_globals, audiomp3_module_globals_tab const mp_obj_module_t audiomp3_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&audiomp3_module_globals, + .globals = (mp_obj_dict_t *)&audiomp3_module_globals, }; diff --git a/shared-bindings/audiopwmio/PWMAudioOut.c b/shared-bindings/audiopwmio/PWMAudioOut.c index 06571fae1..fbe64fba7 100644 --- a/shared-bindings/audiopwmio/PWMAudioOut.c +++ b/shared-bindings/audiopwmio/PWMAudioOut.c @@ -275,5 +275,5 @@ const mp_obj_type_t audiopwmio_pwmaudioout_type = { { &mp_type_type }, .name = MP_QSTR_PWMAudioOut, .make_new = audiopwmio_pwmaudioout_make_new, - .locals_dict = (mp_obj_dict_t*)&audiopwmio_pwmaudioout_locals_dict, + .locals_dict = (mp_obj_dict_t *)&audiopwmio_pwmaudioout_locals_dict, }; diff --git a/shared-bindings/audiopwmio/PWMAudioOut.h b/shared-bindings/audiopwmio/PWMAudioOut.h index 22afc70d3..15d1fa940 100644 --- a/shared-bindings/audiopwmio/PWMAudioOut.h +++ b/shared-bindings/audiopwmio/PWMAudioOut.h @@ -34,16 +34,16 @@ extern const mp_obj_type_t audiopwmio_pwmaudioout_type; // left_channel will always be non-NULL but right_channel may be for mono output. -void common_hal_audiopwmio_pwmaudioout_construct(audiopwmio_pwmaudioout_obj_t* self, - const mcu_pin_obj_t* left_channel, const mcu_pin_obj_t* right_channel, uint16_t default_value); +void common_hal_audiopwmio_pwmaudioout_construct(audiopwmio_pwmaudioout_obj_t *self, + const mcu_pin_obj_t *left_channel, const mcu_pin_obj_t *right_channel, uint16_t default_value); -void common_hal_audiopwmio_pwmaudioout_deinit(audiopwmio_pwmaudioout_obj_t* self); -bool common_hal_audiopwmio_pwmaudioout_deinited(audiopwmio_pwmaudioout_obj_t* self); -void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t* self, mp_obj_t sample, bool loop); -void common_hal_audiopwmio_pwmaudioout_stop(audiopwmio_pwmaudioout_obj_t* self); -bool common_hal_audiopwmio_pwmaudioout_get_playing(audiopwmio_pwmaudioout_obj_t* self); -void common_hal_audiopwmio_pwmaudioout_pause(audiopwmio_pwmaudioout_obj_t* self); -void common_hal_audiopwmio_pwmaudioout_resume(audiopwmio_pwmaudioout_obj_t* self); -bool common_hal_audiopwmio_pwmaudioout_get_paused(audiopwmio_pwmaudioout_obj_t* self); +void common_hal_audiopwmio_pwmaudioout_deinit(audiopwmio_pwmaudioout_obj_t *self); +bool common_hal_audiopwmio_pwmaudioout_deinited(audiopwmio_pwmaudioout_obj_t *self); +void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t *self, mp_obj_t sample, bool loop); +void common_hal_audiopwmio_pwmaudioout_stop(audiopwmio_pwmaudioout_obj_t *self); +bool common_hal_audiopwmio_pwmaudioout_get_playing(audiopwmio_pwmaudioout_obj_t *self); +void common_hal_audiopwmio_pwmaudioout_pause(audiopwmio_pwmaudioout_obj_t *self); +void common_hal_audiopwmio_pwmaudioout_resume(audiopwmio_pwmaudioout_obj_t *self); +bool common_hal_audiopwmio_pwmaudioout_get_paused(audiopwmio_pwmaudioout_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOPWMIO_AUDIOOUT_H diff --git a/shared-bindings/audiopwmio/__init__.c b/shared-bindings/audiopwmio/__init__.c index 5caea1420..2bafb608a 100644 --- a/shared-bindings/audiopwmio/__init__.c +++ b/shared-bindings/audiopwmio/__init__.c @@ -55,5 +55,5 @@ STATIC MP_DEFINE_CONST_DICT(audiopwmio_module_globals, audiopwmio_module_globals const mp_obj_module_t audiopwmio_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&audiopwmio_module_globals, + .globals = (mp_obj_dict_t *)&audiopwmio_module_globals, }; diff --git a/shared-bindings/bitbangio/I2C.c b/shared-bindings/bitbangio/I2C.c index 17005f63a..f6be84547 100644 --- a/shared-bindings/bitbangio/I2C.c +++ b/shared-bindings/bitbangio/I2C.c @@ -70,8 +70,8 @@ STATIC mp_obj_t bitbangio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - const mcu_pin_obj_t* scl = validate_obj_is_free_pin(args[ARG_scl].u_obj); - const mcu_pin_obj_t* sda = validate_obj_is_free_pin(args[ARG_sda].u_obj); + const mcu_pin_obj_t *scl = validate_obj_is_free_pin(args[ARG_scl].u_obj); + const mcu_pin_obj_t *sda = validate_obj_is_free_pin(args[ARG_sda].u_obj); bitbangio_i2c_obj_t *self = m_new_obj(bitbangio_i2c_obj_t); self->base.type = &bitbangio_i2c_type; @@ -135,7 +135,7 @@ STATIC mp_obj_t bitbangio_i2c_scan(mp_obj_t self_in) { for (int addr = 0x08; addr < 0x78; ++addr) { bool success = shared_module_bitbangio_i2c_probe(self, addr); if (success) { - mp_obj_list_append(list, MP_OBJ_NEW_SMALL_INT(addr)); + mp_obj_list_append(list, MP_OBJ_NEW_SMALL_INT(addr)); } } return list; @@ -191,7 +191,7 @@ STATIC void readfrom(bitbangio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffe mp_raise_ValueError(translate("Buffer must be at least length 1")); } - uint8_t status = shared_module_bitbangio_i2c_read(self, address, ((uint8_t*)bufinfo.buf) + start, length); + uint8_t status = shared_module_bitbangio_i2c_read(self, address, ((uint8_t *)bufinfo.buf) + start, length); if (status != 0) { mp_raise_OSError(status); } @@ -212,7 +212,7 @@ STATIC mp_obj_t bitbangio_i2c_readfrom_into(size_t n_args, const mp_obj_t *pos_a mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); readfrom(self, args[ARG_address].u_int, args[ARG_buffer].u_obj, args[ARG_start].u_int, - args[ARG_end].u_int); + args[ARG_end].u_int); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_readfrom_into_obj, 3, bitbangio_i2c_readfrom_into); @@ -246,8 +246,8 @@ STATIC void writeto(bitbangio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffer // do the transfer uint8_t status = shared_module_bitbangio_i2c_write(self, address, - ((uint8_t*) bufinfo.buf) + start, length, - stop); + ((uint8_t *)bufinfo.buf) + start, length, + stop); if (status != 0) { mp_raise_OSError(status); } @@ -268,7 +268,7 @@ STATIC mp_obj_t bitbangio_i2c_writeto(size_t n_args, const mp_obj_t *pos_args, m mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); writeto(self, args[ARG_address].u_int, args[ARG_buffer].u_obj, args[ARG_start].u_int, - args[ARG_end].u_int, true); + args[ARG_end].u_int, true); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_writeto_obj, 1, bitbangio_i2c_writeto); @@ -309,9 +309,9 @@ STATIC mp_obj_t bitbangio_i2c_writeto_then_readfrom(size_t n_args, const mp_obj_ mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); writeto(self, args[ARG_address].u_int, args[ARG_out_buffer].u_obj, args[ARG_out_start].u_int, - args[ARG_out_end].u_int, false); + args[ARG_out_end].u_int, false); readfrom(self, args[ARG_address].u_int, args[ARG_in_buffer].u_obj, args[ARG_in_start].u_int, - args[ARG_in_end].u_int); + args[ARG_in_end].u_int); return mp_const_none; } @@ -337,5 +337,5 @@ const mp_obj_type_t bitbangio_i2c_type = { { &mp_type_type }, .name = MP_QSTR_I2C, .make_new = bitbangio_i2c_make_new, - .locals_dict = (mp_obj_dict_t*)&bitbangio_i2c_locals_dict, + .locals_dict = (mp_obj_dict_t *)&bitbangio_i2c_locals_dict, }; diff --git a/shared-bindings/bitbangio/I2C.h b/shared-bindings/bitbangio/I2C.h index 97dd4580d..d950180a2 100644 --- a/shared-bindings/bitbangio/I2C.h +++ b/shared-bindings/bitbangio/I2C.h @@ -37,10 +37,10 @@ extern const mp_obj_type_t bitbangio_i2c_type; // Initializes the hardware peripheral. extern void shared_module_bitbangio_i2c_construct(bitbangio_i2c_obj_t *self, - const mcu_pin_obj_t * scl, - const mcu_pin_obj_t * sda, - uint32_t frequency, - uint32_t us_timeout); + const mcu_pin_obj_t *scl, + const mcu_pin_obj_t *sda, + uint32_t frequency, + uint32_t us_timeout); extern void shared_module_bitbangio_i2c_deinit(bitbangio_i2c_obj_t *self); extern bool shared_module_bitbangio_i2c_deinited(bitbangio_i2c_obj_t *self); @@ -53,13 +53,13 @@ extern void shared_module_bitbangio_i2c_unlock(bitbangio_i2c_obj_t *self); extern bool shared_module_bitbangio_i2c_probe(bitbangio_i2c_obj_t *self, uint8_t addr); extern uint8_t shared_module_bitbangio_i2c_write(bitbangio_i2c_obj_t *self, - uint16_t address, - const uint8_t * data, size_t len, - bool stop); + uint16_t address, + const uint8_t *data, size_t len, + bool stop); // Reads memory of the i2c device picking up where it left off. extern uint8_t shared_module_bitbangio_i2c_read(bitbangio_i2c_obj_t *self, - uint16_t address, - uint8_t * data, size_t len); + uint16_t address, + uint8_t *data, size_t len); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BITBANGIO_I2C_H diff --git a/shared-bindings/bitbangio/OneWire.c b/shared-bindings/bitbangio/OneWire.c index da94a393e..15cf83324 100644 --- a/shared-bindings/bitbangio/OneWire.c +++ b/shared-bindings/bitbangio/OneWire.c @@ -69,7 +69,7 @@ STATIC mp_obj_t bitbangio_onewire_make_new(const mp_obj_type_t *type, size_t n_a mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - const mcu_pin_obj_t* pin = validate_obj_is_free_pin(args[ARG_pin].u_obj); + const mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[ARG_pin].u_obj); bitbangio_onewire_obj_t *self = m_new_obj(bitbangio_onewire_obj_t); self->base.type = &bitbangio_onewire_type; @@ -168,5 +168,5 @@ const mp_obj_type_t bitbangio_onewire_type = { { &mp_type_type }, .name = MP_QSTR_OneWire, .make_new = bitbangio_onewire_make_new, - .locals_dict = (mp_obj_dict_t*)&bitbangio_onewire_locals_dict, + .locals_dict = (mp_obj_dict_t *)&bitbangio_onewire_locals_dict, }; diff --git a/shared-bindings/bitbangio/OneWire.h b/shared-bindings/bitbangio/OneWire.h index da665b50d..0dbc97512 100644 --- a/shared-bindings/bitbangio/OneWire.h +++ b/shared-bindings/bitbangio/OneWire.h @@ -32,12 +32,12 @@ extern const mp_obj_type_t bitbangio_onewire_type; -extern void shared_module_bitbangio_onewire_construct(bitbangio_onewire_obj_t* self, - const mcu_pin_obj_t* pin); -extern void shared_module_bitbangio_onewire_deinit(bitbangio_onewire_obj_t* self); -extern bool shared_module_bitbangio_onewire_deinited(bitbangio_onewire_obj_t* self); -extern bool shared_module_bitbangio_onewire_reset(bitbangio_onewire_obj_t* self); -extern bool shared_module_bitbangio_onewire_read_bit(bitbangio_onewire_obj_t* self); -extern void shared_module_bitbangio_onewire_write_bit(bitbangio_onewire_obj_t* self, bool bit); +extern void shared_module_bitbangio_onewire_construct(bitbangio_onewire_obj_t *self, + const mcu_pin_obj_t *pin); +extern void shared_module_bitbangio_onewire_deinit(bitbangio_onewire_obj_t *self); +extern bool shared_module_bitbangio_onewire_deinited(bitbangio_onewire_obj_t *self); +extern bool shared_module_bitbangio_onewire_reset(bitbangio_onewire_obj_t *self); +extern bool shared_module_bitbangio_onewire_read_bit(bitbangio_onewire_obj_t *self); +extern void shared_module_bitbangio_onewire_write_bit(bitbangio_onewire_obj_t *self, bool bit); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BITBANGIO_ONEWIRE_H diff --git a/shared-bindings/bitbangio/SPI.c b/shared-bindings/bitbangio/SPI.c index fea88bbd4..e0fc6682e 100644 --- a/shared-bindings/bitbangio/SPI.c +++ b/shared-bindings/bitbangio/SPI.c @@ -73,16 +73,16 @@ STATIC mp_obj_t bitbangio_spi_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_clock, ARG_MOSI, ARG_MISO, ARG_baudrate, ARG_polarity, ARG_phase, ARG_bits, ARG_firstbit }; static const mp_arg_t allowed_args[] = { - { MP_QSTR_clock, MP_ARG_REQUIRED | MP_ARG_OBJ }, - { MP_QSTR_MOSI, MP_ARG_OBJ, {.u_obj = mp_const_none} }, - { MP_QSTR_MISO, MP_ARG_OBJ, {.u_obj = mp_const_none} }, + { MP_QSTR_clock, MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_MOSI, MP_ARG_OBJ, {.u_obj = mp_const_none} }, + { MP_QSTR_MISO, MP_ARG_OBJ, {.u_obj = mp_const_none} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - const mcu_pin_obj_t* clock = validate_obj_is_free_pin(args[ARG_clock].u_obj); - const mcu_pin_obj_t* mosi = validate_obj_is_free_pin_or_none(args[ARG_MOSI].u_obj); - const mcu_pin_obj_t* miso = validate_obj_is_free_pin_or_none(args[ARG_MISO].u_obj); + const mcu_pin_obj_t *clock = validate_obj_is_free_pin(args[ARG_clock].u_obj); + const mcu_pin_obj_t *mosi = validate_obj_is_free_pin_or_none(args[ARG_MOSI].u_obj); + const mcu_pin_obj_t *miso = validate_obj_is_free_pin_or_none(args[ARG_MISO].u_obj); bitbangio_spi_obj_t *self = m_new_obj(bitbangio_spi_obj_t); self->base.type = &bitbangio_spi_type; @@ -299,9 +299,9 @@ STATIC mp_obj_t bitbangio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_ } bool ok = shared_module_bitbangio_spi_transfer(self, - ((uint8_t*)buf_out_info.buf) + out_start, - ((uint8_t*)buf_in_info.buf) + in_start, - out_length); + ((uint8_t *)buf_out_info.buf) + out_start, + ((uint8_t *)buf_in_info.buf) + in_start, + out_length); if (!ok) { mp_raise_OSError(MP_EIO); } @@ -328,5 +328,5 @@ const mp_obj_type_t bitbangio_spi_type = { { &mp_type_type }, .name = MP_QSTR_SPI, .make_new = bitbangio_spi_make_new, - .locals_dict = (mp_obj_dict_t*)&bitbangio_spi_locals_dict, + .locals_dict = (mp_obj_dict_t *)&bitbangio_spi_locals_dict, }; diff --git a/shared-bindings/bitbangio/SPI.h b/shared-bindings/bitbangio/SPI.h index 645f1a39c..b2a644575 100644 --- a/shared-bindings/bitbangio/SPI.h +++ b/shared-bindings/bitbangio/SPI.h @@ -37,8 +37,8 @@ extern const mp_obj_type_t bitbangio_spi_type; // Construct an underlying SPI object. extern void shared_module_bitbangio_spi_construct(bitbangio_spi_obj_t *self, - const mcu_pin_obj_t * clock, const mcu_pin_obj_t * mosi, - const mcu_pin_obj_t * miso); + const mcu_pin_obj_t *clock, const mcu_pin_obj_t *mosi, + const mcu_pin_obj_t *miso); extern void shared_module_bitbangio_spi_deinit(bitbangio_spi_obj_t *self); extern bool shared_module_bitbangio_spi_deinited(bitbangio_spi_obj_t *self); diff --git a/shared-bindings/bitbangio/__init__.c b/shared-bindings/bitbangio/__init__.c index 3e4d2c08e..81e9d91a3 100644 --- a/shared-bindings/bitbangio/__init__.c +++ b/shared-bindings/bitbangio/__init__.c @@ -80,5 +80,5 @@ STATIC MP_DEFINE_CONST_DICT(bitbangio_module_globals, bitbangio_module_globals_t const mp_obj_module_t bitbangio_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&bitbangio_module_globals, + .globals = (mp_obj_dict_t *)&bitbangio_module_globals, }; diff --git a/shared-bindings/bitmaptools/__init__.c b/shared-bindings/bitmaptools/__init__.c index 118564ff8..cb30a46f8 100644 --- a/shared-bindings/bitmaptools/__init__.c +++ b/shared-bindings/bitmaptools/__init__.c @@ -37,7 +37,7 @@ STATIC int16_t validate_point(mp_obj_t point, int16_t default_value) { // Checks if point is None and returns default_value, otherwise decodes integer value - if ( point == mp_const_none ) { + if (point == mp_const_none) { return default_value; } return mp_obj_get_int(point); @@ -46,13 +46,13 @@ STATIC int16_t validate_point(mp_obj_t point, int16_t default_value) { STATIC void extract_tuple(mp_obj_t xy_tuple, int16_t *x, int16_t *y, int16_t x_default, int16_t y_default) { // Helper function for rotozoom // Extract x,y values from a tuple or default if None - if ( xy_tuple == mp_const_none ) { + if (xy_tuple == mp_const_none) { *x = x_default; *y = y_default; - } else if ( !MP_OBJ_IS_OBJ(xy_tuple) ) { + } else if (!MP_OBJ_IS_OBJ(xy_tuple)) { mp_raise_ValueError(translate("clip point must be (x,y) tuple")); } else { - mp_obj_t* items; + mp_obj_t *items; mp_obj_get_array_fixed_n(xy_tuple, 2, &items); *x = mp_obj_get_int(items[0]); *y = mp_obj_get_int(items[1]); @@ -60,7 +60,7 @@ STATIC void extract_tuple(mp_obj_t xy_tuple, int16_t *x, int16_t *y, int16_t x_d } STATIC void validate_clip_region(displayio_bitmap_t *bitmap, mp_obj_t clip0_tuple, int16_t *clip0_x, int16_t *clip0_y, - mp_obj_t clip1_tuple, int16_t *clip1_x, int16_t *clip1_y) { + mp_obj_t clip1_tuple, int16_t *clip1_x, int16_t *clip1_y) { // Helper function for rotozoom // 1. Extract the clip x,y points from the two clip tuples // 2. Rearrange values such that clip0_ < clip1_ @@ -70,12 +70,12 @@ STATIC void validate_clip_region(displayio_bitmap_t *bitmap, mp_obj_t clip0_tupl extract_tuple(clip1_tuple, clip1_x, clip1_y, bitmap->width, bitmap->height); // Ensure the value for clip0 is less than clip1 (for both x and y) - if ( *clip0_x > *clip1_x ) { + if (*clip0_x > *clip1_x) { int16_t temp_value = *clip0_x; // swap values *clip0_x = *clip1_x; *clip1_x = temp_value; } - if ( *clip0_y > *clip1_y ) { + if (*clip0_y > *clip1_y) { int16_t temp_value = *clip0_y; // swap values *clip0_y = *clip1_y; *clip1_y = temp_value; @@ -143,11 +143,11 @@ STATIC void validate_clip_region(displayio_bitmap_t *bitmap, mp_obj_t clip0_tupl //| set to None to copy all pixels""" //| ... //| -STATIC mp_obj_t bitmaptools_obj_rotozoom(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args){ +STATIC mp_obj_t bitmaptools_obj_rotozoom(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum {ARG_dest_bitmap, ARG_source_bitmap, - ARG_ox, ARG_oy, ARG_dest_clip0, ARG_dest_clip1, - ARG_px, ARG_py, ARG_source_clip0, ARG_source_clip1, - ARG_angle, ARG_scale, ARG_skip_index}; + ARG_ox, ARG_oy, ARG_dest_clip0, ARG_dest_clip1, + ARG_px, ARG_py, ARG_source_clip0, ARG_source_clip1, + ARG_angle, ARG_scale, ARG_skip_index}; static const mp_arg_t allowed_args[] = { {MP_QSTR_dest_bitmap, MP_ARG_REQUIRED | MP_ARG_OBJ}, @@ -165,7 +165,7 @@ STATIC mp_obj_t bitmaptools_obj_rotozoom(size_t n_args, const mp_obj_t *pos_args {MP_QSTR_angle, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, // None convert to 0.0 {MP_QSTR_scale, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, // None convert to 1.0 - {MP_QSTR_skip_index, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj=mp_const_none} }, + {MP_QSTR_skip_index, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; @@ -182,35 +182,35 @@ STATIC mp_obj_t bitmaptools_obj_rotozoom(size_t n_args, const mp_obj_t *pos_args // Confirm the destination location target (ox,oy); if None, default to bitmap midpoint int16_t ox, oy; - ox = validate_point(args[ARG_ox].u_obj, destination->width / 2); + ox = validate_point(args[ARG_ox].u_obj, destination->width / 2); oy = validate_point(args[ARG_oy].u_obj, destination->height / 2); // Confirm the source location target (px,py); if None, default to bitmap midpoint int16_t px, py; - px = validate_point(args[ARG_px].u_obj, source->width / 2); + px = validate_point(args[ARG_px].u_obj, source->width / 2); py = validate_point(args[ARG_py].u_obj, source->height / 2); // Validate the clipping regions for the destination bitmap int16_t dest_clip0_x, dest_clip0_y, dest_clip1_x, dest_clip1_y; validate_clip_region(destination, args[ARG_dest_clip0].u_obj, &dest_clip0_x, &dest_clip0_y, - args[ARG_dest_clip1].u_obj, &dest_clip1_x, &dest_clip1_y); + args[ARG_dest_clip1].u_obj, &dest_clip1_x, &dest_clip1_y); // Validate the clipping regions for the source bitmap int16_t source_clip0_x, source_clip0_y, source_clip1_x, source_clip1_y; validate_clip_region(source, args[ARG_source_clip0].u_obj, &source_clip0_x, &source_clip0_y, - args[ARG_source_clip1].u_obj, &source_clip1_x, &source_clip1_y); + args[ARG_source_clip1].u_obj, &source_clip1_x, &source_clip1_y); // Confirm the angle value - float angle=0.0; - if ( args[ARG_angle].u_obj != mp_const_none ) { + float angle = 0.0; + if (args[ARG_angle].u_obj != mp_const_none) { angle = mp_obj_get_float(args[ARG_angle].u_obj); } // Confirm the scale value - float scale=1.0; - if ( args[ARG_scale].u_obj != mp_const_none ) { + float scale = 1.0; + if (args[ARG_scale].u_obj != mp_const_none) { scale = mp_obj_get_float(args[ARG_scale].u_obj); } if (scale < 0) { // ensure scale >= 0 @@ -219,7 +219,7 @@ STATIC mp_obj_t bitmaptools_obj_rotozoom(size_t n_args, const mp_obj_t *pos_args uint32_t skip_index; bool skip_index_none; // Flag whether input skip_value was None - if (args[ARG_skip_index].u_obj == mp_const_none ) { + if (args[ARG_skip_index].u_obj == mp_const_none) { skip_index = 0; skip_index_none = true; } else { @@ -228,14 +228,14 @@ STATIC mp_obj_t bitmaptools_obj_rotozoom(size_t n_args, const mp_obj_t *pos_args } common_hal_bitmaptools_rotozoom(destination, ox, oy, - dest_clip0_x, dest_clip0_y, - dest_clip1_x, dest_clip1_y, - source, px, py, - source_clip0_x, source_clip0_y, - source_clip1_x, source_clip1_y, - angle, - scale, - skip_index, skip_index_none); + dest_clip0_x, dest_clip0_y, + dest_clip1_x, dest_clip1_y, + source, px, py, + source_clip0_x, source_clip0_y, + source_clip1_x, source_clip1_y, + angle, + scale, + skip_index, skip_index_none); return mp_const_none; } @@ -261,7 +261,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_rotozoom_obj, 0, bitmaptools_obj_rotozoom //| fill region in the destination bitmap""" //| ... //| -STATIC mp_obj_t bitmaptools_obj_fill_region(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args){ +STATIC mp_obj_t bitmaptools_obj_fill_region(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum {ARG_dest_bitmap, ARG_x1, ARG_y1, ARG_x2, ARG_y2, ARG_value}; static const mp_arg_t allowed_args[] = { @@ -281,8 +281,8 @@ STATIC mp_obj_t bitmaptools_obj_fill_region(size_t n_args, const mp_obj_t *pos_a value = args[ARG_value].u_int; color_depth = (1 << destination->bits_per_value); if (color_depth <= value) { - mp_raise_ValueError(translate("out of range of target")); - } + mp_raise_ValueError(translate("out of range of target")); + } int16_t x1 = args[ARG_x1].u_int; int16_t y1 = args[ARG_y1].u_int; @@ -314,7 +314,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitmaptools_fill_region_obj, 0, bitmaptools_obj_fill_ //| line in the destination bitmap""" //| ... //| -STATIC mp_obj_t bitmaptools_obj_draw_line(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args){ +STATIC mp_obj_t bitmaptools_obj_draw_line(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum {ARG_dest_bitmap, ARG_x1, ARG_y1, ARG_x2, ARG_y2, ARG_value}; static const mp_arg_t allowed_args[] = { @@ -334,8 +334,8 @@ STATIC mp_obj_t bitmaptools_obj_draw_line(size_t n_args, const mp_obj_t *pos_arg value = args[ARG_value].u_int; color_depth = (1 << destination->bits_per_value); if (color_depth <= value) { - mp_raise_ValueError(translate("out of range of target")); - } + mp_raise_ValueError(translate("out of range of target")); + } int16_t x1 = args[ARG_x1].u_int; int16_t y1 = args[ARG_y1].u_int; @@ -343,9 +343,9 @@ STATIC mp_obj_t bitmaptools_obj_draw_line(size_t n_args, const mp_obj_t *pos_arg int16_t y2 = args[ARG_y2].u_int; // verify points are within the bitmap boundary (inclusive) - if ( (x1 < 0) || (x2 < 0) || (y1 < 0) || (y2 < 0) || - (x1 >= destination->width) || (x2 >= destination->width) || - (y1 >= destination->height) || (y2 >= destination->height) ) { + if ((x1 < 0) || (x2 < 0) || (y1 < 0) || (y2 < 0) || + (x1 >= destination->width) || (x2 >= destination->width) || + (y1 >= destination->height) || (y2 >= destination->height)) { mp_raise_ValueError(translate("out of range of target")); } @@ -366,5 +366,5 @@ STATIC MP_DEFINE_CONST_DICT(bitmaptools_module_globals, bitmaptools_module_globa const mp_obj_module_t bitmaptools_module = { .base = {&mp_type_module }, - .globals = (mp_obj_dict_t*)&bitmaptools_module_globals, + .globals = (mp_obj_dict_t *)&bitmaptools_module_globals, }; diff --git a/shared-bindings/bitmaptools/__init__.h b/shared-bindings/bitmaptools/__init__.h index 1ab6e4129..42f111b02 100644 --- a/shared-bindings/bitmaptools/__init__.h +++ b/shared-bindings/bitmaptools/__init__.h @@ -30,23 +30,23 @@ #include "py/obj.h" void common_hal_bitmaptools_rotozoom(displayio_bitmap_t *self, int16_t ox, int16_t oy, - int16_t dest_clip0_x, int16_t dest_clip0_y, - int16_t dest_clip1_x, int16_t dest_clip1_y, - displayio_bitmap_t *source, int16_t px, int16_t py, - int16_t source_clip0_x, int16_t source_clip0_y, - int16_t source_clip1_x, int16_t source_clip1_y, - float angle, - float scale, - uint32_t skip_index, bool skip_index_none); + int16_t dest_clip0_x, int16_t dest_clip0_y, + int16_t dest_clip1_x, int16_t dest_clip1_y, + displayio_bitmap_t *source, int16_t px, int16_t py, + int16_t source_clip0_x, int16_t source_clip0_y, + int16_t source_clip1_x, int16_t source_clip1_y, + float angle, + float scale, + uint32_t skip_index, bool skip_index_none); void common_hal_bitmaptools_fill_region(displayio_bitmap_t *destination, - int16_t x1, int16_t y1, - int16_t x2, int16_t y2, - uint32_t value); + int16_t x1, int16_t y1, + int16_t x2, int16_t y2, + uint32_t value); void common_hal_bitmaptools_draw_line(displayio_bitmap_t *destination, - int16_t x0, int16_t y0, - int16_t x1, int16_t y1, - uint32_t value); + int16_t x0, int16_t y0, + int16_t x1, int16_t y1, + uint32_t value); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BITMAPTOOLS__INIT__H diff --git a/shared-bindings/bitops/__init__.c b/shared-bindings/bitops/__init__.c index 3c567b8ed..913c8bc83 100644 --- a/shared-bindings/bitops/__init__.c +++ b/shared-bindings/bitops/__init__.c @@ -97,5 +97,5 @@ STATIC MP_DEFINE_CONST_DICT(bitops_module_globals, bitops_module_globals_table); const mp_obj_module_t bitops_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&bitops_module_globals, + .globals = (mp_obj_dict_t *)&bitops_module_globals, }; diff --git a/shared-bindings/board/__init__.c b/shared-bindings/board/__init__.c index 717698408..06b3a899d 100644 --- a/shared-bindings/board/__init__.c +++ b/shared-bindings/board/__init__.c @@ -122,5 +122,5 @@ MP_DEFINE_CONST_FUN_OBJ_0(board_uart_obj, board_uart); const mp_obj_module_t board_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&board_module_globals, + .globals = (mp_obj_dict_t *)&board_module_globals, }; diff --git a/shared-bindings/busio/I2C.c b/shared-bindings/busio/I2C.c index 8b456dbd3..56a6e1b8a 100644 --- a/shared-bindings/busio/I2C.c +++ b/shared-bindings/busio/I2C.c @@ -76,8 +76,8 @@ STATIC mp_obj_t busio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, con mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - const mcu_pin_obj_t* scl = validate_obj_is_free_pin(args[ARG_scl].u_obj); - const mcu_pin_obj_t* sda = validate_obj_is_free_pin(args[ARG_sda].u_obj); + const mcu_pin_obj_t *scl = validate_obj_is_free_pin(args[ARG_scl].u_obj); + const mcu_pin_obj_t *sda = validate_obj_is_free_pin(args[ARG_sda].u_obj); common_hal_busio_i2c_construct(self, scl, sda, args[ARG_frequency].u_int, args[ARG_timeout].u_int); return (mp_obj_t)self; @@ -119,7 +119,7 @@ STATIC mp_obj_t busio_i2c_obj___exit__(size_t n_args, const mp_obj_t *args) { STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_i2c___exit___obj, 4, 4, busio_i2c_obj___exit__); static void check_lock(busio_i2c_obj_t *self) { - asm(""); + asm (""); if (!common_hal_busio_i2c_has_lock(self)) { mp_raise_RuntimeError(translate("Function requires lock")); } @@ -201,7 +201,7 @@ STATIC void readfrom(busio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffer, i mp_raise_ValueError(translate("Buffer must be at least length 1")); } - uint8_t status = common_hal_busio_i2c_read(self, address, ((uint8_t*)bufinfo.buf) + start, length); + uint8_t status = common_hal_busio_i2c_read(self, address, ((uint8_t *)bufinfo.buf) + start, length); if (status != 0) { mp_raise_OSError(status); } @@ -222,7 +222,7 @@ STATIC mp_obj_t busio_i2c_readfrom_into(size_t n_args, const mp_obj_t *pos_args, mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); readfrom(self, args[ARG_address].u_int, args[ARG_buffer].u_obj, args[ARG_start].u_int, - args[ARG_end].u_int); + args[ARG_end].u_int); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_readfrom_into_obj, 3, busio_i2c_readfrom_into); @@ -254,8 +254,8 @@ STATIC void writeto(busio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffer, in normalize_buffer_bounds(&start, end, &length); // do the transfer - uint8_t status = common_hal_busio_i2c_write(self, address, ((uint8_t*) bufinfo.buf) + start, - length, stop); + uint8_t status = common_hal_busio_i2c_write(self, address, ((uint8_t *)bufinfo.buf) + start, + length, stop); if (status != 0) { mp_raise_OSError(status); } @@ -276,7 +276,7 @@ STATIC mp_obj_t busio_i2c_writeto(size_t n_args, const mp_obj_t *pos_args, mp_ma mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); writeto(self, args[ARG_address].u_int, args[ARG_buffer].u_obj, args[ARG_start].u_int, - args[ARG_end].u_int, true); + args[ARG_end].u_int, true); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_writeto_obj, 1, busio_i2c_writeto); @@ -317,9 +317,9 @@ STATIC mp_obj_t busio_i2c_writeto_then_readfrom(size_t n_args, const mp_obj_t *p mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); writeto(self, args[ARG_address].u_int, args[ARG_out_buffer].u_obj, args[ARG_out_start].u_int, - args[ARG_out_end].u_int, false); + args[ARG_out_end].u_int, false); readfrom(self, args[ARG_address].u_int, args[ARG_in_buffer].u_obj, args[ARG_in_start].u_int, - args[ARG_in_end].u_int); + args[ARG_in_end].u_int); return mp_const_none; } @@ -342,8 +342,8 @@ STATIC const mp_rom_map_elem_t busio_i2c_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(busio_i2c_locals_dict, busio_i2c_locals_dict_table); const mp_obj_type_t busio_i2c_type = { - { &mp_type_type }, - .name = MP_QSTR_I2C, - .make_new = busio_i2c_make_new, - .locals_dict = (mp_obj_dict_t*)&busio_i2c_locals_dict, + { &mp_type_type }, + .name = MP_QSTR_I2C, + .make_new = busio_i2c_make_new, + .locals_dict = (mp_obj_dict_t *)&busio_i2c_locals_dict, }; diff --git a/shared-bindings/busio/I2C.h b/shared-bindings/busio/I2C.h index a2d5dbf50..08701938c 100644 --- a/shared-bindings/busio/I2C.h +++ b/shared-bindings/busio/I2C.h @@ -44,10 +44,10 @@ extern const mp_obj_type_t busio_i2c_type; // Initializes the hardware peripheral. extern void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, - const mcu_pin_obj_t * scl, - const mcu_pin_obj_t * sda, - uint32_t frequency, - uint32_t timeout); + const mcu_pin_obj_t *scl, + const mcu_pin_obj_t *sda, + uint32_t frequency, + uint32_t timeout); extern void common_hal_busio_i2c_deinit(busio_i2c_obj_t *self); extern bool common_hal_busio_i2c_deinited(busio_i2c_obj_t *self); @@ -61,13 +61,13 @@ extern bool common_hal_busio_i2c_probe(busio_i2c_obj_t *self, uint8_t addr); // Write to the device and return 0 on success or an appropriate error code from mperrno.h extern uint8_t common_hal_busio_i2c_write(busio_i2c_obj_t *self, uint16_t address, - const uint8_t * data, size_t len, - bool stop); + const uint8_t *data, size_t len, + bool stop); // Reads memory of the i2c device picking up where it left off and return 0 on // success or an appropriate error code from mperrno.h extern uint8_t common_hal_busio_i2c_read(busio_i2c_obj_t *self, uint16_t address, - uint8_t * data, size_t len); + uint8_t *data, size_t len); // This is used by the supervisor to claim I2C devices indefinitely. extern void common_hal_busio_i2c_never_reset(busio_i2c_obj_t *self); diff --git a/shared-bindings/busio/OneWire.c b/shared-bindings/busio/OneWire.c index 1fae39181..026e1ee96 100644 --- a/shared-bindings/busio/OneWire.c +++ b/shared-bindings/busio/OneWire.c @@ -68,7 +68,7 @@ STATIC mp_obj_t busio_onewire_make_new(const mp_obj_type_t *type, size_t n_args, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - const mcu_pin_obj_t* pin = validate_obj_is_free_pin(args[ARG_pin].u_obj); + const mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[ARG_pin].u_obj); busio_onewire_obj_t *self = m_new_obj(busio_onewire_obj_t); self->base.type = &busio_onewire_type; @@ -170,5 +170,5 @@ const mp_obj_type_t busio_onewire_type = { { &mp_type_type }, .name = MP_QSTR_OneWire, .make_new = busio_onewire_make_new, - .locals_dict = (mp_obj_dict_t*)&busio_onewire_locals_dict, + .locals_dict = (mp_obj_dict_t *)&busio_onewire_locals_dict, }; diff --git a/shared-bindings/busio/OneWire.h b/shared-bindings/busio/OneWire.h index 9ee5f639b..a270bab5c 100644 --- a/shared-bindings/busio/OneWire.h +++ b/shared-bindings/busio/OneWire.h @@ -32,12 +32,12 @@ extern const mp_obj_type_t busio_onewire_type; -extern void common_hal_busio_onewire_construct(busio_onewire_obj_t* self, - const mcu_pin_obj_t* pin); -extern void common_hal_busio_onewire_deinit(busio_onewire_obj_t* self); -extern bool common_hal_busio_onewire_deinited(busio_onewire_obj_t* self); -extern bool common_hal_busio_onewire_reset(busio_onewire_obj_t* self); -extern bool common_hal_busio_onewire_read_bit(busio_onewire_obj_t* self); -extern void common_hal_busio_onewire_write_bit(busio_onewire_obj_t* self, bool bit); +extern void common_hal_busio_onewire_construct(busio_onewire_obj_t *self, + const mcu_pin_obj_t *pin); +extern void common_hal_busio_onewire_deinit(busio_onewire_obj_t *self); +extern bool common_hal_busio_onewire_deinited(busio_onewire_obj_t *self); +extern bool common_hal_busio_onewire_reset(busio_onewire_obj_t *self); +extern bool common_hal_busio_onewire_read_bit(busio_onewire_obj_t *self); +extern void common_hal_busio_onewire_write_bit(busio_onewire_obj_t *self, bool bit); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_BUSIO_ONEWIRE_H diff --git a/shared-bindings/busio/SPI.c b/shared-bindings/busio/SPI.c index cbc6b5c08..e64f17b14 100644 --- a/shared-bindings/busio/SPI.c +++ b/shared-bindings/busio/SPI.c @@ -92,9 +92,9 @@ STATIC mp_obj_t busio_spi_make_new(const mp_obj_type_t *type, size_t n_args, con mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - const mcu_pin_obj_t* clock = validate_obj_is_free_pin(args[ARG_clock].u_obj); - const mcu_pin_obj_t* mosi = validate_obj_is_free_pin_or_none(args[ARG_MOSI].u_obj); - const mcu_pin_obj_t* miso = validate_obj_is_free_pin_or_none(args[ARG_MISO].u_obj); + const mcu_pin_obj_t *clock = validate_obj_is_free_pin(args[ARG_clock].u_obj); + const mcu_pin_obj_t *mosi = validate_obj_is_free_pin_or_none(args[ARG_MOSI].u_obj); + const mcu_pin_obj_t *miso = validate_obj_is_free_pin_or_none(args[ARG_MISO].u_obj); if (!miso && !mosi) { mp_raise_ValueError(translate("Must provide MISO or MOSI pin")); @@ -134,7 +134,7 @@ STATIC mp_obj_t busio_spi_obj___exit__(size_t n_args, const mp_obj_t *args) { STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_spi_obj___exit___obj, 4, 4, busio_spi_obj___exit__); STATIC void check_lock(busio_spi_obj_t *self) { - asm(""); + asm (""); if (!common_hal_busio_spi_has_lock(self)) { mp_raise_RuntimeError(translate("Function requires lock")); } @@ -198,7 +198,7 @@ STATIC mp_obj_t busio_spi_configure(size_t n_args, const mp_obj_t *pos_args, mp_ } if (!common_hal_busio_spi_configure(self, args[ARG_baudrate].u_int, - polarity, phase, bits)) { + polarity, phase, bits)) { mp_raise_OSError(MP_EIO); } return mp_const_none; @@ -265,7 +265,7 @@ STATIC mp_obj_t busio_spi_write(size_t n_args, const mp_obj_t *pos_args, mp_map_ return mp_const_none; } - bool ok = common_hal_busio_spi_write(self, ((uint8_t*)bufinfo.buf) + start, length); + bool ok = common_hal_busio_spi_write(self, ((uint8_t *)bufinfo.buf) + start, length); if (!ok) { mp_raise_OSError(MP_EIO); } @@ -310,7 +310,7 @@ STATIC mp_obj_t busio_spi_readinto(size_t n_args, const mp_obj_t *pos_args, mp_m return mp_const_none; } - bool ok = common_hal_busio_spi_read(self, ((uint8_t*)bufinfo.buf) + start, length, args[ARG_write_value].u_int); + bool ok = common_hal_busio_spi_read(self, ((uint8_t *)bufinfo.buf) + start, length, args[ARG_write_value].u_int); if (!ok) { mp_raise_OSError(MP_EIO); } @@ -371,9 +371,9 @@ STATIC mp_obj_t busio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args } bool ok = common_hal_busio_spi_transfer(self, - ((uint8_t*)buf_out_info.buf) + out_start, - ((uint8_t*)buf_in_info.buf) + in_start, - out_length); + ((uint8_t *)buf_out_info.buf) + out_start, + ((uint8_t *)buf_in_info.buf) + in_start, + out_length); if (!ok) { mp_raise_OSError(MP_EIO); } @@ -417,10 +417,10 @@ STATIC const mp_rom_map_elem_t busio_spi_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(busio_spi_locals_dict, busio_spi_locals_dict_table); const mp_obj_type_t busio_spi_type = { - { &mp_type_type }, - .name = MP_QSTR_SPI, - .make_new = busio_spi_make_new, - .locals_dict = (mp_obj_dict_t*)&busio_spi_locals_dict, + { &mp_type_type }, + .name = MP_QSTR_SPI, + .make_new = busio_spi_make_new, + .locals_dict = (mp_obj_dict_t *)&busio_spi_locals_dict, }; busio_spi_obj_t *validate_obj_is_spi_bus(mp_obj_t obj) { diff --git a/shared-bindings/busio/SPI.h b/shared-bindings/busio/SPI.h index 3a8b6dbc1..67ca752ba 100644 --- a/shared-bindings/busio/SPI.h +++ b/shared-bindings/busio/SPI.h @@ -37,8 +37,8 @@ extern const mp_obj_type_t busio_spi_type; // Construct an underlying SPI object. extern void common_hal_busio_spi_construct(busio_spi_obj_t *self, - const mcu_pin_obj_t * clock, const mcu_pin_obj_t * mosi, - const mcu_pin_obj_t * miso); + const mcu_pin_obj_t *clock, const mcu_pin_obj_t *mosi, + const mcu_pin_obj_t *miso); extern void common_hal_busio_spi_deinit(busio_spi_obj_t *self); extern bool common_hal_busio_spi_deinited(busio_spi_obj_t *self); @@ -59,13 +59,13 @@ extern bool common_hal_busio_spi_read(busio_spi_obj_t *self, uint8_t *data, size extern bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, const uint8_t *data_out, uint8_t *data_in, size_t len); // Return actual SPI bus frequency. -uint32_t common_hal_busio_spi_get_frequency(busio_spi_obj_t* self); +uint32_t common_hal_busio_spi_get_frequency(busio_spi_obj_t *self); // Return SPI bus phase. -uint8_t common_hal_busio_spi_get_phase(busio_spi_obj_t* self); +uint8_t common_hal_busio_spi_get_phase(busio_spi_obj_t *self); // Return SPI bus polarity. -uint8_t common_hal_busio_spi_get_polarity(busio_spi_obj_t* self); +uint8_t common_hal_busio_spi_get_polarity(busio_spi_obj_t *self); // This is used by the supervisor to claim SPI devices indefinitely. extern void common_hal_busio_spi_never_reset(busio_spi_obj_t *self); diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c index 06647e779..05c3addd3 100644 --- a/shared-bindings/busio/UART.c +++ b/shared-bindings/busio/UART.c @@ -72,7 +72,7 @@ extern const busio_uart_parity_obj_t busio_uart_parity_even_obj; extern const busio_uart_parity_obj_t busio_uart_parity_odd_obj; STATIC void validate_timeout(mp_float_t timeout) { - if (timeout < (mp_float_t) 0.0f || timeout > (mp_float_t) 100.0f) { + if (timeout < (mp_float_t)0.0f || timeout > (mp_float_t)100.0f) { mp_raise_ValueError(translate("timeout must be 0.0-100.0 seconds")); } } @@ -103,10 +103,10 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, co mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - const mcu_pin_obj_t* rx = validate_obj_is_free_pin_or_none(args[ARG_rx].u_obj); - const mcu_pin_obj_t* tx = validate_obj_is_free_pin_or_none(args[ARG_tx].u_obj); + const mcu_pin_obj_t *rx = validate_obj_is_free_pin_or_none(args[ARG_rx].u_obj); + const mcu_pin_obj_t *tx = validate_obj_is_free_pin_or_none(args[ARG_tx].u_obj); - if ( (tx == NULL) && (rx == NULL) ) { + if ((tx == NULL) && (rx == NULL)) { mp_raise_ValueError(translate("tx and rx cannot both be None")); } @@ -130,15 +130,15 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, co mp_float_t timeout = mp_obj_get_float(args[ARG_timeout].u_obj); validate_timeout(timeout); - const mcu_pin_obj_t* rts = validate_obj_is_free_pin_or_none(args[ARG_rts].u_obj); - const mcu_pin_obj_t* cts = validate_obj_is_free_pin_or_none(args[ARG_cts].u_obj); - const mcu_pin_obj_t* rs485_dir = validate_obj_is_free_pin_or_none(args[ARG_rs485_dir].u_obj); + const mcu_pin_obj_t *rts = validate_obj_is_free_pin_or_none(args[ARG_rts].u_obj); + const mcu_pin_obj_t *cts = validate_obj_is_free_pin_or_none(args[ARG_cts].u_obj); + const mcu_pin_obj_t *rs485_dir = validate_obj_is_free_pin_or_none(args[ARG_rs485_dir].u_obj); const bool rs485_invert = args[ARG_rs485_invert].u_bool; common_hal_busio_uart_construct(self, tx, rx, rts, cts, rs485_dir, rs485_invert, - args[ARG_baudrate].u_int, bits, parity, stop, timeout, - args[ARG_receiver_buffer_size].u_int, NULL, false); + args[ARG_baudrate].u_int, bits, parity, stop, timeout, + args[ARG_receiver_buffer_size].u_int, NULL, false); return (mp_obj_t)self; } @@ -427,5 +427,5 @@ const mp_obj_type_t busio_uart_type = { .getiter = mp_identity_getiter, .iternext = mp_stream_unbuffered_iter, .protocol = &uart_stream_p, - .locals_dict = (mp_obj_dict_t*)&busio_uart_locals_dict, + .locals_dict = (mp_obj_dict_t *)&busio_uart_locals_dict, }; diff --git a/shared-bindings/busio/UART.h b/shared-bindings/busio/UART.h index ce8da1445..31b062aee 100644 --- a/shared-bindings/busio/UART.h +++ b/shared-bindings/busio/UART.h @@ -41,11 +41,11 @@ typedef enum { // Construct an underlying UART object. extern void common_hal_busio_uart_construct(busio_uart_obj_t *self, - const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, - const mcu_pin_obj_t * rts, const mcu_pin_obj_t * cts, - const mcu_pin_obj_t * rs485_dir, bool rs485_invert, + const mcu_pin_obj_t *tx, const mcu_pin_obj_t *rx, + const mcu_pin_obj_t *rts, const mcu_pin_obj_t *cts, + const mcu_pin_obj_t *rs485_dir, bool rs485_invert, uint32_t baudrate, uint8_t bits, busio_uart_parity_t parity, uint8_t stop, - mp_float_t timeout, uint16_t receiver_buffer_size, byte* receiver_buffer, + mp_float_t timeout, uint16_t receiver_buffer_size, byte *receiver_buffer, bool sigint_enabled); extern void common_hal_busio_uart_deinit(busio_uart_obj_t *self); @@ -57,7 +57,7 @@ extern size_t common_hal_busio_uart_read(busio_uart_obj_t *self, // Write characters. len is in characters NOT bytes! extern size_t common_hal_busio_uart_write(busio_uart_obj_t *self, - const uint8_t *data, size_t len, int *errcode); + const uint8_t *data, size_t len, int *errcode); extern uint32_t common_hal_busio_uart_get_baudrate(busio_uart_obj_t *self); extern void common_hal_busio_uart_set_baudrate(busio_uart_obj_t *self, uint32_t baudrate); diff --git a/shared-bindings/busio/__init__.c b/shared-bindings/busio/__init__.c index 04632c2f4..e7df331c1 100644 --- a/shared-bindings/busio/__init__.c +++ b/shared-bindings/busio/__init__.c @@ -81,5 +81,5 @@ STATIC MP_DEFINE_CONST_DICT(busio_module_globals, busio_module_globals_table); const mp_obj_module_t busio_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&busio_module_globals, + .globals = (mp_obj_dict_t *)&busio_module_globals, }; diff --git a/shared-bindings/camera/Camera.c b/shared-bindings/camera/Camera.c index fd88ccab0..a58896500 100644 --- a/shared-bindings/camera/Camera.c +++ b/shared-bindings/camera/Camera.c @@ -125,8 +125,8 @@ STATIC const mp_rom_map_elem_t camera_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(camera_locals_dict, camera_locals_dict_table); const mp_obj_type_t camera_type = { - { &mp_type_type }, - .name = MP_QSTR_Camera, - .make_new = camera_make_new, - .locals_dict = (mp_obj_dict_t*)&camera_locals_dict, + { &mp_type_type }, + .name = MP_QSTR_Camera, + .make_new = camera_make_new, + .locals_dict = (mp_obj_dict_t *)&camera_locals_dict, }; diff --git a/shared-bindings/camera/__init__.c b/shared-bindings/camera/__init__.c index 080516d51..dfe1093a4 100644 --- a/shared-bindings/camera/__init__.c +++ b/shared-bindings/camera/__init__.c @@ -46,5 +46,5 @@ STATIC MP_DEFINE_CONST_DICT(camera_module_globals, camera_module_globals_table); const mp_obj_module_t camera_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&camera_module_globals, + .globals = (mp_obj_dict_t *)&camera_module_globals, }; diff --git a/shared-bindings/canio/CAN.c b/shared-bindings/canio/CAN.c index 13066764e..e2d21c1df 100644 --- a/shared-bindings/canio/CAN.c +++ b/shared-bindings/canio/CAN.c @@ -74,7 +74,7 @@ STATIC mp_obj_t canio_can_make_new(const mp_obj_type_t *type, size_t n_args, con { MP_QSTR_auto_restart, MP_ARG_BOOL, {.u_bool = false} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - MP_STATIC_ASSERT( MP_ARRAY_SIZE(allowed_args) == NUM_ARGS ); + MP_STATIC_ASSERT(MP_ARRAY_SIZE(allowed_args) == NUM_ARGS); mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); @@ -244,7 +244,7 @@ STATIC mp_obj_t canio_can_listen(size_t n_args, const mp_obj_t *pos_args, mp_map { MP_QSTR_timeout, MP_ARG_OBJ, {.u_obj = 0} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - MP_STATIC_ASSERT( MP_ARRAY_SIZE(allowed_args) == NUM_ARGS ); + MP_STATIC_ASSERT(MP_ARRAY_SIZE(allowed_args) == NUM_ARGS); mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); @@ -256,7 +256,7 @@ STATIC mp_obj_t canio_can_listen(size_t n_args, const mp_obj_t *pos_args, mp_map } canio_match_obj_t *matches[nmatch]; - for (size_t i=0; i<nmatch; i++) { + for (size_t i = 0; i < nmatch; i++) { mp_obj_type_t *type = mp_obj_get_type(match_objects[i]); if (type != &canio_match_type) { mp_raise_TypeError_varg(translate("expected '%q' but got '%q'"), MP_QSTR_Match, type->name); diff --git a/shared-bindings/canio/Listener.c b/shared-bindings/canio/Listener.c index 8a39f0f2a..370c61ad8 100644 --- a/shared-bindings/canio/Listener.c +++ b/shared-bindings/canio/Listener.c @@ -174,5 +174,5 @@ const mp_obj_type_t canio_listener_type = { .name = MP_QSTR_Listener, .getiter = mp_identity_getiter, .iternext = canio_iternext, - .locals_dict = (mp_obj_dict_t*)&canio_listener_locals_dict, + .locals_dict = (mp_obj_dict_t *)&canio_listener_locals_dict, }; diff --git a/shared-bindings/canio/Match.c b/shared-bindings/canio/Match.c index 6039631fa..cddb85c26 100644 --- a/shared-bindings/canio/Match.c +++ b/shared-bindings/canio/Match.c @@ -50,7 +50,7 @@ STATIC mp_obj_t canio_match_make_new(const mp_obj_type_t *type, size_t n_args, c { MP_QSTR_extended, MP_ARG_BOOL, {.u_bool = false} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - MP_STATIC_ASSERT( MP_ARRAY_SIZE(allowed_args) == NUM_ARGS ); + MP_STATIC_ASSERT(MP_ARRAY_SIZE(allowed_args) == NUM_ARGS); mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); @@ -135,5 +135,5 @@ const mp_obj_type_t canio_match_type = { { &mp_type_type }, .name = MP_QSTR_Match, .make_new = canio_match_make_new, - .locals_dict = (mp_obj_dict_t*)&canio_match_locals_dict, + .locals_dict = (mp_obj_dict_t *)&canio_match_locals_dict, }; diff --git a/shared-bindings/canio/Message.c b/shared-bindings/canio/Message.c index 04fa8fc6c..7b85f1722 100644 --- a/shared-bindings/canio/Message.c +++ b/shared-bindings/canio/Message.c @@ -50,7 +50,7 @@ STATIC mp_obj_t canio_message_make_new(const mp_obj_type_t *type, size_t n_args, { MP_QSTR_extended, MP_ARG_BOOL, {.u_bool = false} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - MP_STATIC_ASSERT( MP_ARRAY_SIZE(allowed_args) == NUM_ARGS ); + MP_STATIC_ASSERT(MP_ARRAY_SIZE(allowed_args) == NUM_ARGS); mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); @@ -95,7 +95,7 @@ STATIC const mp_obj_property_t canio_message_id_obj = { //| STATIC mp_obj_t canio_message_data_get(const mp_obj_t self_in) { canio_message_obj_t *self = self_in; - return mp_obj_new_bytes((const byte*)common_hal_canio_message_get_data(self), common_hal_canio_message_get_length(self)); + return mp_obj_new_bytes((const byte *)common_hal_canio_message_get_data(self), common_hal_canio_message_get_length(self)); } MP_DEFINE_CONST_FUN_OBJ_1(canio_message_data_get_obj, canio_message_data_get); diff --git a/shared-bindings/canio/RemoteTransmissionRequest.c b/shared-bindings/canio/RemoteTransmissionRequest.c index fcd259034..7f8a8fb96 100644 --- a/shared-bindings/canio/RemoteTransmissionRequest.c +++ b/shared-bindings/canio/RemoteTransmissionRequest.c @@ -50,7 +50,7 @@ STATIC mp_obj_t canio_remote_transmission_request_make_new(const mp_obj_type_t * { MP_QSTR_extended, MP_ARG_BOOL, {.u_bool = false} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - MP_STATIC_ASSERT( MP_ARRAY_SIZE(allowed_args) == NUM_ARGS ); + MP_STATIC_ASSERT(MP_ARRAY_SIZE(allowed_args) == NUM_ARGS); mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); diff --git a/shared-bindings/canio/__init__.c b/shared-bindings/canio/__init__.c index f29d3ab8a..d9863e8a2 100644 --- a/shared-bindings/canio/__init__.c +++ b/shared-bindings/canio/__init__.c @@ -121,5 +121,5 @@ STATIC MP_DEFINE_CONST_DICT(canio_module_globals, canio_module_globals_table); const mp_obj_module_t canio_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&canio_module_globals, + .globals = (mp_obj_dict_t *)&canio_module_globals, }; diff --git a/shared-bindings/countio/Counter.c b/shared-bindings/countio/Counter.c index 820db5ea9..e03665d63 100644 --- a/shared-bindings/countio/Counter.c +++ b/shared-bindings/countio/Counter.c @@ -41,7 +41,7 @@ STATIC mp_obj_t countio_counter_make_new(const mp_obj_type_t *type, size_t n_arg mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - const mcu_pin_obj_t* pin_a = validate_obj_is_free_pin(args[ARG_pin_a].u_obj); + const mcu_pin_obj_t *pin_a = validate_obj_is_free_pin(args[ARG_pin_a].u_obj); countio_counter_obj_t *self = m_new_obj(countio_counter_obj_t); @@ -115,12 +115,12 @@ const mp_obj_property_t countio_counter_count_obj = { //| def reset(self) -> None: //| """Resets the count back to 0.""" //| -STATIC mp_obj_t countio_counter_reset(mp_obj_t self_in){ - countio_counter_obj_t *self = MP_OBJ_TO_PTR(self_in); - check_for_deinit(self); - //set the position to zero for reset - common_hal_countio_counter_reset(self); - return mp_const_none; +STATIC mp_obj_t countio_counter_reset(mp_obj_t self_in) { + countio_counter_obj_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); + // set the position to zero for reset + common_hal_countio_counter_reset(self); + return mp_const_none; } @@ -140,5 +140,5 @@ const mp_obj_type_t countio_counter_type = { { &mp_type_type }, .name = MP_QSTR_Counter, .make_new = countio_counter_make_new, - .locals_dict = (mp_obj_dict_t*)&countio_counter_locals_dict, + .locals_dict = (mp_obj_dict_t *)&countio_counter_locals_dict, }; diff --git a/shared-bindings/countio/Counter.h b/shared-bindings/countio/Counter.h index 15adbbe2a..a9eced41a 100644 --- a/shared-bindings/countio/Counter.h +++ b/shared-bindings/countio/Counter.h @@ -6,13 +6,13 @@ extern const mp_obj_type_t countio_counter_type; -extern void common_hal_countio_counter_construct(countio_counter_obj_t* self, - const mcu_pin_obj_t* pin_a); -extern void common_hal_countio_counter_deinit(countio_counter_obj_t* self); -extern bool common_hal_countio_counter_deinited(countio_counter_obj_t* self); -extern mp_int_t common_hal_countio_counter_get_count(countio_counter_obj_t* self); -extern void common_hal_countio_counter_set_count(countio_counter_obj_t* self, +extern void common_hal_countio_counter_construct(countio_counter_obj_t *self, + const mcu_pin_obj_t *pin_a); +extern void common_hal_countio_counter_deinit(countio_counter_obj_t *self); +extern bool common_hal_countio_counter_deinited(countio_counter_obj_t *self); +extern mp_int_t common_hal_countio_counter_get_count(countio_counter_obj_t *self); +extern void common_hal_countio_counter_set_count(countio_counter_obj_t *self, mp_int_t new_count); -extern void common_hal_countio_counter_reset(countio_counter_obj_t* self); +extern void common_hal_countio_counter_reset(countio_counter_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_COUNTIO_COUNTER_H diff --git a/shared-bindings/countio/__init__.c b/shared-bindings/countio/__init__.c index 7046a5e72..f6c0a4221 100644 --- a/shared-bindings/countio/__init__.c +++ b/shared-bindings/countio/__init__.c @@ -32,5 +32,5 @@ STATIC MP_DEFINE_CONST_DICT(countio_module_globals, countio_module_globals_table const mp_obj_module_t countio_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&countio_module_globals, + .globals = (mp_obj_dict_t *)&countio_module_globals, }; diff --git a/shared-bindings/digitalio/DigitalInOut.c b/shared-bindings/digitalio/DigitalInOut.c index 351e122e0..0874bed55 100644 --- a/shared-bindings/digitalio/DigitalInOut.c +++ b/shared-bindings/digitalio/DigitalInOut.c @@ -59,7 +59,7 @@ //| ... //| STATIC mp_obj_t digitalio_digitalinout_make_new(const mp_obj_type_t *type, - mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { + mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { mp_arg_check_num(n_args, kw_args, 1, 1, false); digitalio_digitalinout_obj_t *self = m_new_obj(digitalio_digitalinout_obj_t); @@ -170,7 +170,7 @@ STATIC mp_obj_t digitalio_digitalinout_switch_to_input(size_t n_args, const mp_o digitalio_pull_t pull = PULL_NONE; if (args[ARG_pull].u_rom_obj == &digitalio_pull_up_obj) { pull = PULL_UP; - }else if (args[ARG_pull].u_rom_obj == &digitalio_pull_down_obj) { + } else if (args[ARG_pull].u_rom_obj == &digitalio_pull_down_obj) { pull = PULL_DOWN; } // do the transfer diff --git a/shared-bindings/digitalio/DigitalInOut.h b/shared-bindings/digitalio/DigitalInOut.h index 3d1f9c7cb..ebc94fa1a 100644 --- a/shared-bindings/digitalio/DigitalInOut.h +++ b/shared-bindings/digitalio/DigitalInOut.h @@ -41,18 +41,18 @@ typedef enum { DIGITALINOUT_INPUT_ONLY } digitalinout_result_t; -digitalinout_result_t common_hal_digitalio_digitalinout_construct(digitalio_digitalinout_obj_t* self, const mcu_pin_obj_t* pin); -void common_hal_digitalio_digitalinout_deinit(digitalio_digitalinout_obj_t* self); -bool common_hal_digitalio_digitalinout_deinited(digitalio_digitalinout_obj_t* self); -void common_hal_digitalio_digitalinout_switch_to_input(digitalio_digitalinout_obj_t* self, digitalio_pull_t pull); -digitalinout_result_t common_hal_digitalio_digitalinout_switch_to_output(digitalio_digitalinout_obj_t* self, bool value, digitalio_drive_mode_t drive_mode); -digitalio_direction_t common_hal_digitalio_digitalinout_get_direction(digitalio_digitalinout_obj_t* self); -void common_hal_digitalio_digitalinout_set_value(digitalio_digitalinout_obj_t* self, bool value); -bool common_hal_digitalio_digitalinout_get_value(digitalio_digitalinout_obj_t* self); -digitalinout_result_t common_hal_digitalio_digitalinout_set_drive_mode(digitalio_digitalinout_obj_t* self, digitalio_drive_mode_t drive_mode); -digitalio_drive_mode_t common_hal_digitalio_digitalinout_get_drive_mode(digitalio_digitalinout_obj_t* self); -void common_hal_digitalio_digitalinout_set_pull(digitalio_digitalinout_obj_t* self, digitalio_pull_t pull); -digitalio_pull_t common_hal_digitalio_digitalinout_get_pull(digitalio_digitalinout_obj_t* self); +digitalinout_result_t common_hal_digitalio_digitalinout_construct(digitalio_digitalinout_obj_t *self, const mcu_pin_obj_t *pin); +void common_hal_digitalio_digitalinout_deinit(digitalio_digitalinout_obj_t *self); +bool common_hal_digitalio_digitalinout_deinited(digitalio_digitalinout_obj_t *self); +void common_hal_digitalio_digitalinout_switch_to_input(digitalio_digitalinout_obj_t *self, digitalio_pull_t pull); +digitalinout_result_t common_hal_digitalio_digitalinout_switch_to_output(digitalio_digitalinout_obj_t *self, bool value, digitalio_drive_mode_t drive_mode); +digitalio_direction_t common_hal_digitalio_digitalinout_get_direction(digitalio_digitalinout_obj_t *self); +void common_hal_digitalio_digitalinout_set_value(digitalio_digitalinout_obj_t *self, bool value); +bool common_hal_digitalio_digitalinout_get_value(digitalio_digitalinout_obj_t *self); +digitalinout_result_t common_hal_digitalio_digitalinout_set_drive_mode(digitalio_digitalinout_obj_t *self, digitalio_drive_mode_t drive_mode); +digitalio_drive_mode_t common_hal_digitalio_digitalinout_get_drive_mode(digitalio_digitalinout_obj_t *self); +void common_hal_digitalio_digitalinout_set_pull(digitalio_digitalinout_obj_t *self, digitalio_pull_t pull); +digitalio_pull_t common_hal_digitalio_digitalinout_get_pull(digitalio_digitalinout_obj_t *self); void common_hal_digitalio_digitalinout_never_reset(digitalio_digitalinout_obj_t *self); digitalio_digitalinout_obj_t *assert_digitalinout(mp_obj_t obj); diff --git a/shared-bindings/digitalio/__init__.c b/shared-bindings/digitalio/__init__.c index f8f45b158..52ce377e3 100644 --- a/shared-bindings/digitalio/__init__.c +++ b/shared-bindings/digitalio/__init__.c @@ -88,5 +88,5 @@ STATIC MP_DEFINE_CONST_DICT(digitalio_module_globals, digitalio_module_globals_t const mp_obj_module_t digitalio_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&digitalio_module_globals, + .globals = (mp_obj_dict_t *)&digitalio_module_globals, }; diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index b9f06fe14..f906be2f9 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -150,7 +150,7 @@ STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t val x = i % width; y = i / width; } else { - mp_obj_t* items; + mp_obj_t *items; mp_obj_get_array_fixed_n(index_obj, 2, &items); x = mp_obj_get_int(items[0]); y = mp_obj_get_int(items[1]); @@ -189,7 +189,7 @@ STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t val //| set to None to copy all pixels""" //| ... //| -STATIC mp_obj_t displayio_bitmap_obj_blit(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args){ +STATIC mp_obj_t displayio_bitmap_obj_blit(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum {ARG_x, ARG_y, ARG_source, ARG_x1, ARG_y1, ARG_x2, ARG_y2, ARG_skip_index}; static const mp_arg_t allowed_args[] = { {MP_QSTR_x, MP_ARG_REQUIRED | MP_ARG_INT}, @@ -199,7 +199,7 @@ STATIC mp_obj_t displayio_bitmap_obj_blit(size_t n_args, const mp_obj_t *pos_arg {MP_QSTR_y1, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, {MP_QSTR_x2, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, // None convert to source->width {MP_QSTR_y2, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, // None convert to source->height - {MP_QSTR_skip_index, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj=mp_const_none} }, + {MP_QSTR_skip_index, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_obj = mp_const_none} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); @@ -220,46 +220,46 @@ STATIC mp_obj_t displayio_bitmap_obj_blit(size_t n_args, const mp_obj_t *pos_arg int16_t y1 = args[ARG_y1].u_int; int16_t x2, y2; // if x2 or y2 is None, then set as the maximum size of the source bitmap - if ( args[ARG_x2].u_obj == mp_const_none ) { + if (args[ARG_x2].u_obj == mp_const_none) { x2 = source->width; } else { x2 = mp_obj_get_int(args[ARG_x2].u_obj); } - //int16_t y2; - if ( args[ARG_y2].u_obj == mp_const_none ) { + // int16_t y2; + if (args[ARG_y2].u_obj == mp_const_none) { y2 = source->height; } else { y2 = mp_obj_get_int(args[ARG_y2].u_obj); } // Check x,y are within self (target) bitmap boundary - if ( (x < 0) || (y < 0) || (x > self->width) || (y > self->height) ) { - mp_raise_ValueError(translate("out of range of target")); + if ((x < 0) || (y < 0) || (x > self->width) || (y > self->height)) { + mp_raise_ValueError(translate("out of range of target")); } // Check x1,y1,x2,y2 are within source bitmap boundary - if ( (x1 < 0) || (x1 > source->width) || + if ((x1 < 0) || (x1 > source->width) || (y1 < 0) || (y1 > source->height) || - (x2 < 0) || (x2 > source->width) || - (y2 < 0) || (y2 > source->height) ) { - mp_raise_ValueError(translate("out of range of source")); + (x2 < 0) || (x2 > source->width) || + (y2 < 0) || (y2 > source->height)) { + mp_raise_ValueError(translate("out of range of source")); } // Ensure x1 < x2 and y1 < y2 if (x1 > x2) { - int16_t temp=x2; - x2=x1; - x1=temp; + int16_t temp = x2; + x2 = x1; + x1 = temp; } if (y1 > y2) { - int16_t temp=y2; - y2=y1; - y1=temp; + int16_t temp = y2; + y2 = y1; + y1 = temp; } uint32_t skip_index; bool skip_index_none; // flag whether skip_value was None - if (args[ARG_skip_index].u_obj == mp_const_none ) { + if (args[ARG_skip_index].u_obj == mp_const_none) { skip_index = 0; skip_index_none = true; } else { @@ -283,7 +283,7 @@ STATIC mp_obj_t displayio_bitmap_obj_fill(mp_obj_t self_in, mp_obj_t value_obj) mp_uint_t value = (mp_uint_t)mp_obj_get_int(value_obj); if ((value >> common_hal_displayio_bitmap_get_bits_per_value(self)) != 0) { - mp_raise_ValueError(translate("pixel value requires too many bits")); + mp_raise_ValueError(translate("pixel value requires too many bits")); } common_hal_displayio_bitmap_fill(self, value); @@ -305,5 +305,5 @@ const mp_obj_type_t displayio_bitmap_type = { .name = MP_QSTR_Bitmap, .make_new = displayio_bitmap_make_new, .subscr = bitmap_subscr, - .locals_dict = (mp_obj_dict_t*)&displayio_bitmap_locals_dict, + .locals_dict = (mp_obj_dict_t *)&displayio_bitmap_locals_dict, }; diff --git a/shared-bindings/displayio/Bitmap.h b/shared-bindings/displayio/Bitmap.h index 00cd98b0a..1f74c31fc 100644 --- a/shared-bindings/displayio/Bitmap.h +++ b/shared-bindings/displayio/Bitmap.h @@ -34,15 +34,15 @@ extern const mp_obj_type_t displayio_bitmap_type; void common_hal_displayio_bitmap_construct(displayio_bitmap_t *self, uint32_t width, uint32_t height, uint32_t bits_per_value); -void common_hal_displayio_bitmap_load_row(displayio_bitmap_t *self, uint16_t y, uint8_t* data, - uint16_t len); +void common_hal_displayio_bitmap_load_row(displayio_bitmap_t *self, uint16_t y, uint8_t *data, + uint16_t len); uint16_t common_hal_displayio_bitmap_get_height(displayio_bitmap_t *self); uint16_t common_hal_displayio_bitmap_get_width(displayio_bitmap_t *self); uint32_t common_hal_displayio_bitmap_get_bits_per_value(displayio_bitmap_t *self); void common_hal_displayio_bitmap_set_pixel(displayio_bitmap_t *bitmap, int16_t x, int16_t y, uint32_t value); void common_hal_displayio_bitmap_blit(displayio_bitmap_t *self, int16_t x, int16_t y, displayio_bitmap_t *source, - int16_t x1, int16_t y1, int16_t x2, int16_t y2, - uint32_t skip_index, bool skip_index_none); + int16_t x1, int16_t y1, int16_t x2, int16_t y2, + uint32_t skip_index, bool skip_index_none); uint32_t common_hal_displayio_bitmap_get_pixel(displayio_bitmap_t *bitmap, int16_t x, int16_t y); void common_hal_displayio_bitmap_fill(displayio_bitmap_t *bitmap, uint32_t value); diff --git a/shared-bindings/displayio/ColorConverter.c b/shared-bindings/displayio/ColorConverter.c index 88d3a1ba8..d102d7f9d 100644 --- a/shared-bindings/displayio/ColorConverter.c +++ b/shared-bindings/displayio/ColorConverter.c @@ -146,5 +146,5 @@ const mp_obj_type_t displayio_colorconverter_type = { { &mp_type_type }, .name = MP_QSTR_ColorConverter, .make_new = displayio_colorconverter_make_new, - .locals_dict = (mp_obj_dict_t*)&displayio_colorconverter_locals_dict, + .locals_dict = (mp_obj_dict_t *)&displayio_colorconverter_locals_dict, }; diff --git a/shared-bindings/displayio/ColorConverter.h b/shared-bindings/displayio/ColorConverter.h index 441f7c7ae..d5a5d0524 100644 --- a/shared-bindings/displayio/ColorConverter.h +++ b/shared-bindings/displayio/ColorConverter.h @@ -33,13 +33,13 @@ extern const mp_obj_type_t displayio_colorconverter_type; -void common_hal_displayio_colorconverter_construct(displayio_colorconverter_t* self, bool dither); -void common_hal_displayio_colorconverter_convert(displayio_colorconverter_t *colorconverter, const _displayio_colorspace_t* colorspace, uint32_t input_color, uint32_t* output_color); +void common_hal_displayio_colorconverter_construct(displayio_colorconverter_t *self, bool dither); +void common_hal_displayio_colorconverter_convert(displayio_colorconverter_t *colorconverter, const _displayio_colorspace_t *colorspace, uint32_t input_color, uint32_t *output_color); -void common_hal_displayio_colorconverter_set_dither(displayio_colorconverter_t* self, bool dither); -bool common_hal_displayio_colorconverter_get_dither(displayio_colorconverter_t* self); +void common_hal_displayio_colorconverter_set_dither(displayio_colorconverter_t *self, bool dither); +bool common_hal_displayio_colorconverter_get_dither(displayio_colorconverter_t *self); -void common_hal_displayio_colorconverter_make_transparent(displayio_colorconverter_t* self, uint32_t transparent_color); -void common_hal_displayio_colorconverter_make_opaque(displayio_colorconverter_t* self, uint32_t transparent_color); +void common_hal_displayio_colorconverter_make_transparent(displayio_colorconverter_t *self, uint32_t transparent_color); +void common_hal_displayio_colorconverter_make_opaque(displayio_colorconverter_t *self, uint32_t transparent_color); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_COLORCONVERTER_H diff --git a/shared-bindings/displayio/Display.c b/shared-bindings/displayio/Display.c index 8d1a888fe..9d8f8298f 100644 --- a/shared-bindings/displayio/Display.c +++ b/shared-bindings/displayio/Display.c @@ -114,15 +114,15 @@ //| ... //| STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_args, - const mp_obj_t *pos_args, mp_map_t *kw_args) { + const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_display_bus, ARG_init_sequence, ARG_width, ARG_height, ARG_colstart, ARG_rowstart, - ARG_rotation, ARG_color_depth, ARG_grayscale, ARG_pixels_in_byte_share_row, - ARG_bytes_per_cell, ARG_reverse_pixels_in_byte, ARG_reverse_bytes_in_word, - ARG_set_column_command, ARG_set_row_command, ARG_write_ram_command, - ARG_set_vertical_scroll, ARG_backlight_pin, ARG_brightness_command, - ARG_brightness, ARG_auto_brightness, ARG_single_byte_bounds, ARG_data_as_commands, - ARG_auto_refresh, ARG_native_frames_per_second, ARG_backlight_on_high, - ARG_SH1107_addressing }; + ARG_rotation, ARG_color_depth, ARG_grayscale, ARG_pixels_in_byte_share_row, + ARG_bytes_per_cell, ARG_reverse_pixels_in_byte, ARG_reverse_bytes_in_word, + ARG_set_column_command, ARG_set_row_command, ARG_write_ram_command, + ARG_set_vertical_scroll, ARG_backlight_pin, ARG_brightness_command, + ARG_brightness, ARG_auto_brightness, ARG_single_byte_bounds, ARG_data_as_commands, + ARG_auto_refresh, ARG_native_frames_per_second, ARG_backlight_on_high, + ARG_SH1107_addressing }; static const mp_arg_t allowed_args[] = { { MP_QSTR_display_bus, MP_ARG_REQUIRED | MP_ARG_OBJ }, { MP_QSTR_init_sequence, MP_ARG_REQUIRED | MP_ARG_OBJ }, @@ -160,7 +160,7 @@ STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_a mp_buffer_info_t bufinfo; mp_get_buffer_raise(args[ARG_init_sequence].u_obj, &bufinfo, MP_BUFFER_READ); - const mcu_pin_obj_t* backlight_pin = validate_obj_is_free_pin_or_none(args[ARG_backlight_pin].u_obj); + const mcu_pin_obj_t *backlight_pin = validate_obj_is_free_pin_or_none(args[ARG_backlight_pin].u_obj); mp_float_t brightness = mp_obj_get_float(args[ARG_brightness].u_obj); @@ -170,7 +170,8 @@ STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_a } primary_display_t *disp = allocate_display_or_raise(); - displayio_display_obj_t *self = &disp->display;; + displayio_display_obj_t *self = &disp->display; + ; self->base.type = &displayio_display_type; common_hal_displayio_display_construct( self, @@ -200,7 +201,7 @@ STATIC mp_obj_t displayio_display_make_new(const mp_obj_type_t *type, size_t n_a } // Helper to ensure we have the native super class instead of a subclass. -static displayio_display_obj_t* native_display(mp_obj_t display_obj) { +static displayio_display_obj_t *native_display(mp_obj_t display_obj) { mp_obj_t native_display = mp_instance_cast_to_native_base(display_obj, &displayio_display_type); mp_obj_assert_native_inited(native_display); return MP_OBJ_TO_PTR(native_display); @@ -215,7 +216,7 @@ static displayio_display_obj_t* native_display(mp_obj_t display_obj) { //| STATIC mp_obj_t displayio_display_obj_show(mp_obj_t self_in, mp_obj_t group_in) { displayio_display_obj_t *self = native_display(self_in); - displayio_group_t* group = NULL; + displayio_group_t *group = NULL; if (group_in != mp_const_none) { group = MP_OBJ_TO_PTR(native_group(group_in)); } @@ -268,8 +269,7 @@ STATIC mp_obj_t displayio_display_obj_refresh(size_t n_args, const mp_obj_t *pos uint32_t target_ms_per_frame; if (args[ARG_target_frames_per_second].u_obj == mp_const_none) { target_ms_per_frame = 0xffffffff; - } - else { + } else { target_ms_per_frame = 1000 / mp_obj_get_int(args[ARG_target_frames_per_second].u_obj); } @@ -467,40 +467,40 @@ STATIC mp_obj_t displayio_display_obj_fill_row(size_t n_args, const mp_obj_t *po mp_get_buffer_raise(result, &bufinfo, MP_BUFFER_WRITE); if (bufinfo.typecode != BYTEARRAY_TYPECODE) { - mp_raise_ValueError(translate("Buffer is not a bytearray.")); + mp_raise_ValueError(translate("Buffer is not a bytearray.")); } if (self->core.colorspace.depth != 16) { - mp_raise_ValueError(translate("Display must have a 16 bit colorspace.")); + mp_raise_ValueError(translate("Display must have a 16 bit colorspace.")); } displayio_area_t area = { - .x1 = 0, - .y1 = y, - .x2 = self->core.width, - .y2 = y + 1 + .x1 = 0, + .y1 = y, + .x2 = self->core.width, + .y2 = y + 1 }; uint8_t pixels_per_word = (sizeof(uint32_t) * 8) / self->core.colorspace.depth; uint16_t buffer_size = self->core.width / pixels_per_word; uint16_t pixels_per_buffer = displayio_area_size(&area); if (pixels_per_buffer % pixels_per_word) { - buffer_size += 1; + buffer_size += 1; } uint32_t *result_buffer = bufinfo.buf; size_t result_buffer_size = bufinfo.len; if (result_buffer_size >= (buffer_size * 4)) { - volatile uint32_t mask_length = (pixels_per_buffer / 32) + 1; - uint32_t mask[mask_length]; + volatile uint32_t mask_length = (pixels_per_buffer / 32) + 1; + uint32_t mask[mask_length]; - for (uint16_t k = 0; k < mask_length; k++) { - mask[k] = 0x00000000; - } + for (uint16_t k = 0; k < mask_length; k++) { + mask[k] = 0x00000000; + } - displayio_display_core_fill_area(&self->core, &area, mask, result_buffer); - return result; + displayio_display_core_fill_area(&self->core, &area, mask, result_buffer); + return result; } else { - mp_raise_ValueError(translate("Buffer is too small")); + mp_raise_ValueError(translate("Buffer is too small")); } } MP_DEFINE_CONST_FUN_OBJ_KW(displayio_display_fill_row_obj, 1, displayio_display_obj_fill_row); @@ -526,5 +526,5 @@ const mp_obj_type_t displayio_display_type = { { &mp_type_type }, .name = MP_QSTR_Display, .make_new = displayio_display_make_new, - .locals_dict = (mp_obj_dict_t*)&displayio_display_locals_dict, + .locals_dict = (mp_obj_dict_t *)&displayio_display_locals_dict, }; diff --git a/shared-bindings/displayio/Display.h b/shared-bindings/displayio/Display.h index f9fbc157c..36015cd56 100644 --- a/shared-bindings/displayio/Display.h +++ b/shared-bindings/displayio/Display.h @@ -38,39 +38,39 @@ extern const mp_obj_type_t displayio_display_type; #define NO_BRIGHTNESS_COMMAND 0x100 -void common_hal_displayio_display_construct(displayio_display_obj_t* self, +void common_hal_displayio_display_construct(displayio_display_obj_t *self, mp_obj_t bus, uint16_t width, uint16_t height, int16_t colstart, int16_t rowstart, uint16_t rotation, uint16_t color_depth, bool grayscale, bool pixels_in_byte_share_row, uint8_t bytes_per_cell, bool reverse_pixels_in_byte, bool reverse_bytes_in_word, uint8_t set_column_command, uint8_t set_row_command, uint8_t write_ram_command, uint8_t set_vertical_scroll, - uint8_t* init_sequence, uint16_t init_sequence_len, const mcu_pin_obj_t* backlight_pin, uint16_t brightness_command, + uint8_t *init_sequence, uint16_t init_sequence_len, const mcu_pin_obj_t *backlight_pin, uint16_t brightness_command, mp_float_t brightness, bool auto_brightness, bool single_byte_bounds, bool data_as_commands, bool auto_refresh, uint16_t native_frames_per_second, bool backlight_on_high, bool SH1107_addressing); -bool common_hal_displayio_display_show(displayio_display_obj_t* self, - displayio_group_t* root_group); +bool common_hal_displayio_display_show(displayio_display_obj_t *self, + displayio_group_t *root_group); -bool common_hal_displayio_display_refresh(displayio_display_obj_t* self, uint32_t target_ms_per_frame, uint32_t maximum_ms_per_real_frame); +bool common_hal_displayio_display_refresh(displayio_display_obj_t *self, uint32_t target_ms_per_frame, uint32_t maximum_ms_per_real_frame); -bool common_hal_displayio_display_get_auto_refresh(displayio_display_obj_t* self); -void common_hal_displayio_display_set_auto_refresh(displayio_display_obj_t* self, bool auto_refresh); +bool common_hal_displayio_display_get_auto_refresh(displayio_display_obj_t *self); +void common_hal_displayio_display_set_auto_refresh(displayio_display_obj_t *self, bool auto_refresh); -uint16_t common_hal_displayio_display_get_width(displayio_display_obj_t* self); -uint16_t common_hal_displayio_display_get_height(displayio_display_obj_t* self); -uint16_t common_hal_displayio_display_get_rotation(displayio_display_obj_t* self); -void common_hal_displayio_display_set_rotation(displayio_display_obj_t* self, int rotation); +uint16_t common_hal_displayio_display_get_width(displayio_display_obj_t *self); +uint16_t common_hal_displayio_display_get_height(displayio_display_obj_t *self); +uint16_t common_hal_displayio_display_get_rotation(displayio_display_obj_t *self); +void common_hal_displayio_display_set_rotation(displayio_display_obj_t *self, int rotation); -bool common_hal_displayio_display_get_auto_brightness(displayio_display_obj_t* self); -void common_hal_displayio_display_set_auto_brightness(displayio_display_obj_t* self, bool auto_brightness); +bool common_hal_displayio_display_get_auto_brightness(displayio_display_obj_t *self); +void common_hal_displayio_display_set_auto_brightness(displayio_display_obj_t *self, bool auto_brightness); -bool common_hal_displayio_display_get_dither(displayio_display_obj_t* self); -void common_hal_displayio_display_set_dither(displayio_display_obj_t* self, bool dither); +bool common_hal_displayio_display_get_dither(displayio_display_obj_t *self); +void common_hal_displayio_display_set_dither(displayio_display_obj_t *self, bool dither); -mp_float_t common_hal_displayio_display_get_brightness(displayio_display_obj_t* self); -bool common_hal_displayio_display_set_brightness(displayio_display_obj_t* self, mp_float_t brightness); +mp_float_t common_hal_displayio_display_get_brightness(displayio_display_obj_t *self); +bool common_hal_displayio_display_set_brightness(displayio_display_obj_t *self, mp_float_t brightness); -mp_obj_t common_hal_displayio_display_get_bus(displayio_display_obj_t* self); +mp_obj_t common_hal_displayio_display_get_bus(displayio_display_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_DISPLAY_H diff --git a/shared-bindings/displayio/EPaperDisplay.c b/shared-bindings/displayio/EPaperDisplay.c index 4f5c47aca..6a7c089c9 100644 --- a/shared-bindings/displayio/EPaperDisplay.c +++ b/shared-bindings/displayio/EPaperDisplay.c @@ -148,7 +148,7 @@ STATIC mp_obj_t displayio_epaperdisplay_make_new(const mp_obj_type_t *type, size mp_get_buffer_raise(args[ARG_stop_sequence].u_obj, &stop_bufinfo, MP_BUFFER_READ); - const mcu_pin_obj_t* busy_pin = validate_obj_is_free_pin_or_none(args[ARG_busy_pin].u_obj); + const mcu_pin_obj_t *busy_pin = validate_obj_is_free_pin_or_none(args[ARG_busy_pin].u_obj); mp_int_t rotation = args[ARG_rotation].u_int; if (rotation % 90 != 0) { @@ -156,7 +156,8 @@ STATIC mp_obj_t displayio_epaperdisplay_make_new(const mp_obj_type_t *type, size } primary_display_t *disp = allocate_display_or_raise(); - displayio_epaperdisplay_obj_t *self = &disp->epaper_display;; + displayio_epaperdisplay_obj_t *self = &disp->epaper_display; + ; mp_float_t refresh_time = mp_obj_get_float(args[ARG_refresh_time].u_obj); mp_float_t seconds_per_frame = mp_obj_get_float(args[ARG_seconds_per_frame].u_obj); @@ -186,7 +187,7 @@ STATIC mp_obj_t displayio_epaperdisplay_make_new(const mp_obj_type_t *type, size } // Helper to ensure we have the native super class instead of a subclass. -static displayio_epaperdisplay_obj_t* native_display(mp_obj_t display_obj) { +static displayio_epaperdisplay_obj_t *native_display(mp_obj_t display_obj) { mp_obj_t native_display = mp_instance_cast_to_native_base(display_obj, &displayio_epaperdisplay_type); mp_obj_assert_native_inited(native_display); return MP_OBJ_TO_PTR(native_display); @@ -201,7 +202,7 @@ static displayio_epaperdisplay_obj_t* native_display(mp_obj_t display_obj) { //| STATIC mp_obj_t displayio_epaperdisplay_obj_show(mp_obj_t self_in, mp_obj_t group_in) { displayio_epaperdisplay_obj_t *self = native_display(self_in); - displayio_group_t* group = NULL; + displayio_group_t *group = NULL; if (group_in != mp_const_none) { group = MP_OBJ_TO_PTR(native_group(group_in)); } @@ -351,5 +352,5 @@ const mp_obj_type_t displayio_epaperdisplay_type = { { &mp_type_type }, .name = MP_QSTR_EPaperDisplay, .make_new = displayio_epaperdisplay_make_new, - .locals_dict = (mp_obj_dict_t*)&displayio_epaperdisplay_locals_dict, + .locals_dict = (mp_obj_dict_t *)&displayio_epaperdisplay_locals_dict, }; diff --git a/shared-bindings/displayio/EPaperDisplay.h b/shared-bindings/displayio/EPaperDisplay.h index 14d4f6aa9..7c2b302ce 100644 --- a/shared-bindings/displayio/EPaperDisplay.h +++ b/shared-bindings/displayio/EPaperDisplay.h @@ -38,27 +38,27 @@ extern const mp_obj_type_t displayio_epaperdisplay_type; #define NO_COMMAND 0x100 -void common_hal_displayio_epaperdisplay_construct(displayio_epaperdisplay_obj_t* self, - mp_obj_t bus, const uint8_t* start_sequence, uint16_t start_sequence_len, const uint8_t* stop_sequence, uint16_t stop_sequence_len, - uint16_t width, uint16_t height, uint16_t ram_width, uint16_t ram_height, int16_t colstart, int16_t rowstart, uint16_t rotation, - uint16_t set_column_window_command, uint16_t set_row_window_command, - uint16_t set_current_column_command, uint16_t set_current_row_command, - uint16_t write_black_ram_command, bool black_bits_inverted, uint16_t write_color_ram_command, bool color_bits_inverted, uint32_t highlight_color, uint16_t refresh_display_command, mp_float_t refresh_time, - const mcu_pin_obj_t* busy_pin, bool busy_state, mp_float_t seconds_per_frame, bool always_toggle_chip_select, bool grayscale); +void common_hal_displayio_epaperdisplay_construct(displayio_epaperdisplay_obj_t *self, + mp_obj_t bus, const uint8_t *start_sequence, uint16_t start_sequence_len, const uint8_t *stop_sequence, uint16_t stop_sequence_len, + uint16_t width, uint16_t height, uint16_t ram_width, uint16_t ram_height, int16_t colstart, int16_t rowstart, uint16_t rotation, + uint16_t set_column_window_command, uint16_t set_row_window_command, + uint16_t set_current_column_command, uint16_t set_current_row_command, + uint16_t write_black_ram_command, bool black_bits_inverted, uint16_t write_color_ram_command, bool color_bits_inverted, uint32_t highlight_color, uint16_t refresh_display_command, mp_float_t refresh_time, + const mcu_pin_obj_t *busy_pin, bool busy_state, mp_float_t seconds_per_frame, bool always_toggle_chip_select, bool grayscale); -bool common_hal_displayio_epaperdisplay_refresh(displayio_epaperdisplay_obj_t* self); +bool common_hal_displayio_epaperdisplay_refresh(displayio_epaperdisplay_obj_t *self); -bool common_hal_displayio_epaperdisplay_show(displayio_epaperdisplay_obj_t* self, displayio_group_t* root_group); +bool common_hal_displayio_epaperdisplay_show(displayio_epaperdisplay_obj_t *self, displayio_group_t *root_group); // Returns time in milliseconds. -uint32_t common_hal_displayio_epaperdisplay_get_time_to_refresh(displayio_epaperdisplay_obj_t* self); -bool common_hal_displayio_epaperdisplay_get_busy(displayio_epaperdisplay_obj_t* self); +uint32_t common_hal_displayio_epaperdisplay_get_time_to_refresh(displayio_epaperdisplay_obj_t *self); +bool common_hal_displayio_epaperdisplay_get_busy(displayio_epaperdisplay_obj_t *self); -uint16_t common_hal_displayio_epaperdisplay_get_width(displayio_epaperdisplay_obj_t* self); -uint16_t common_hal_displayio_epaperdisplay_get_height(displayio_epaperdisplay_obj_t* self); -uint16_t common_hal_displayio_epaperdisplay_get_rotation(displayio_epaperdisplay_obj_t* self); -void common_hal_displayio_epaperdisplay_set_rotation(displayio_epaperdisplay_obj_t* self, int rotation); +uint16_t common_hal_displayio_epaperdisplay_get_width(displayio_epaperdisplay_obj_t *self); +uint16_t common_hal_displayio_epaperdisplay_get_height(displayio_epaperdisplay_obj_t *self); +uint16_t common_hal_displayio_epaperdisplay_get_rotation(displayio_epaperdisplay_obj_t *self); +void common_hal_displayio_epaperdisplay_set_rotation(displayio_epaperdisplay_obj_t *self, int rotation); -mp_obj_t common_hal_displayio_epaperdisplay_get_bus(displayio_epaperdisplay_obj_t* self); +mp_obj_t common_hal_displayio_epaperdisplay_get_bus(displayio_epaperdisplay_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_EPAPERDISPLAY_H diff --git a/shared-bindings/displayio/FourWire.c b/shared-bindings/displayio/FourWire.c index 455d22e72..d87f2421d 100644 --- a/shared-bindings/displayio/FourWire.c +++ b/shared-bindings/displayio/FourWire.c @@ -79,7 +79,7 @@ STATIC mp_obj_t displayio_fourwire_make_new(const mp_obj_type_t *type, size_t n_ mcu_pin_obj_t *reset = validate_obj_is_free_pin_or_none(args[ARG_reset].u_obj); mp_obj_t spi = args[ARG_spi_bus].u_obj; - displayio_fourwire_obj_t* self = &allocate_display_bus_or_raise()->fourwire_bus; + displayio_fourwire_obj_t *self = &allocate_display_bus_or_raise()->fourwire_bus; self->base.type = &displayio_fourwire_type; uint8_t polarity = args[ARG_polarity].u_int; @@ -144,7 +144,7 @@ STATIC mp_obj_t displayio_fourwire_obj_send(size_t n_args, const mp_obj_t *pos_a chip_select = CHIP_SELECT_TOGGLE_EVERY_BYTE; } common_hal_displayio_fourwire_send(self, DISPLAY_COMMAND, chip_select, &command, 1); - common_hal_displayio_fourwire_send(self, DISPLAY_DATA, chip_select, ((uint8_t*) bufinfo.buf), bufinfo.len); + common_hal_displayio_fourwire_send(self, DISPLAY_DATA, chip_select, ((uint8_t *)bufinfo.buf), bufinfo.len); common_hal_displayio_fourwire_end_transaction(self); return mp_const_none; @@ -161,5 +161,5 @@ const mp_obj_type_t displayio_fourwire_type = { { &mp_type_type }, .name = MP_QSTR_FourWire, .make_new = displayio_fourwire_make_new, - .locals_dict = (mp_obj_dict_t*)&displayio_fourwire_locals_dict, + .locals_dict = (mp_obj_dict_t *)&displayio_fourwire_locals_dict, }; diff --git a/shared-bindings/displayio/FourWire.h b/shared-bindings/displayio/FourWire.h index 6f6b528e7..300327f7a 100644 --- a/shared-bindings/displayio/FourWire.h +++ b/shared-bindings/displayio/FourWire.h @@ -36,12 +36,12 @@ extern const mp_obj_type_t displayio_fourwire_type; -void common_hal_displayio_fourwire_construct(displayio_fourwire_obj_t* self, - busio_spi_obj_t* spi, const mcu_pin_obj_t* command, - const mcu_pin_obj_t* chip_select, const mcu_pin_obj_t* reset, uint32_t baudrate, +void common_hal_displayio_fourwire_construct(displayio_fourwire_obj_t *self, + busio_spi_obj_t *spi, const mcu_pin_obj_t *command, + const mcu_pin_obj_t *chip_select, const mcu_pin_obj_t *reset, uint32_t baudrate, uint8_t polarity, uint8_t phase); -void common_hal_displayio_fourwire_deinit(displayio_fourwire_obj_t* self); +void common_hal_displayio_fourwire_deinit(displayio_fourwire_obj_t *self); bool common_hal_displayio_fourwire_reset(mp_obj_t self); bool common_hal_displayio_fourwire_bus_free(mp_obj_t self); diff --git a/shared-bindings/displayio/Group.c b/shared-bindings/displayio/Group.c index c1c05504d..75e210db8 100644 --- a/shared-bindings/displayio/Group.c +++ b/shared-bindings/displayio/Group.c @@ -72,7 +72,7 @@ STATIC mp_obj_t displayio_group_make_new(const mp_obj_type_t *type, size_t n_arg } // Helper to ensure we have the native super class instead of a subclass. -displayio_group_t* native_group(mp_obj_t group_obj) { +displayio_group_t *native_group(mp_obj_t group_obj) { mp_obj_t native_group = mp_instance_cast_to_native_base(group_obj, &displayio_group_type); if (native_group == MP_OBJ_NULL) { mp_raise_ValueError_varg(translate("Must be a %q subclass."), MP_QSTR_Group); @@ -202,7 +202,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(displayio_group_append_obj, displayio_group_obj_append //| STATIC mp_obj_t displayio_group_obj_insert(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t layer) { displayio_group_t *self = native_group(self_in); - if ((size_t) MP_OBJ_SMALL_INT_VALUE(index_obj) == common_hal_displayio_group_get_len(self)){ + if ((size_t)MP_OBJ_SMALL_INT_VALUE(index_obj) == common_hal_displayio_group_get_len(self)) { return displayio_group_obj_append(self_in, layer); } size_t index = mp_get_index(&displayio_group_type, common_hal_displayio_group_get_len(self), index_obj, false); @@ -241,9 +241,9 @@ STATIC mp_obj_t displayio_group_obj_pop(size_t n_args, const mp_obj_t *pos_args, displayio_group_t *self = native_group(pos_args[0]); size_t index = mp_get_index(&displayio_group_type, - common_hal_displayio_group_get_len(self), - MP_OBJ_NEW_SMALL_INT(args[ARG_i].u_int), - false); + common_hal_displayio_group_get_len(self), + MP_OBJ_NEW_SMALL_INT(args[ARG_i].u_int), + false); return common_hal_displayio_group_pop(self, index); } MP_DEFINE_CONST_FUN_OBJ_KW(displayio_group_pop_obj, 1, displayio_group_obj_pop); @@ -273,9 +273,12 @@ STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) { displayio_group_t *self = native_group(self_in); uint16_t len = common_hal_displayio_group_get_len(self); switch (op) { - case MP_UNARY_OP_BOOL: return mp_obj_new_bool(len != 0); - case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(len); - default: return MP_OBJ_NULL; // op not supported + case MP_UNARY_OP_BOOL: + return mp_obj_new_bool(len != 0); + case MP_UNARY_OP_LEN: + return MP_OBJ_NEW_SMALL_INT(len); + default: + return MP_OBJ_NULL; // op not supported } } @@ -359,5 +362,5 @@ const mp_obj_type_t displayio_group_type = { .subscr = group_subscr, .unary_op = group_unary_op, .getiter = mp_obj_new_generic_iterator, - .locals_dict = (mp_obj_dict_t*)&displayio_group_locals_dict, + .locals_dict = (mp_obj_dict_t *)&displayio_group_locals_dict, }; diff --git a/shared-bindings/displayio/Group.h b/shared-bindings/displayio/Group.h index 69c73bf4d..266fce959 100644 --- a/shared-bindings/displayio/Group.h +++ b/shared-bindings/displayio/Group.h @@ -31,23 +31,23 @@ extern const mp_obj_type_t displayio_group_type; -displayio_group_t* native_group(mp_obj_t group_obj); +displayio_group_t *native_group(mp_obj_t group_obj); -void common_hal_displayio_group_construct(displayio_group_t* self, uint32_t scale, mp_int_t x, mp_int_t y); -uint32_t common_hal_displayio_group_get_scale(displayio_group_t* self); -void common_hal_displayio_group_set_scale(displayio_group_t* self, uint32_t scale); -bool common_hal_displayio_group_get_hidden(displayio_group_t* self); -void common_hal_displayio_group_set_hidden(displayio_group_t* self, bool hidden); -mp_int_t common_hal_displayio_group_get_x(displayio_group_t* self); -void common_hal_displayio_group_set_x(displayio_group_t* self, mp_int_t x); -mp_int_t common_hal_displayio_group_get_y(displayio_group_t* self); -void common_hal_displayio_group_set_y(displayio_group_t* self, mp_int_t y); -void common_hal_displayio_group_append(displayio_group_t* self, mp_obj_t layer); -void common_hal_displayio_group_insert(displayio_group_t* self, size_t index, mp_obj_t layer); -size_t common_hal_displayio_group_get_len(displayio_group_t* self); -mp_obj_t common_hal_displayio_group_pop(displayio_group_t* self, size_t index); -mp_int_t common_hal_displayio_group_index(displayio_group_t* self, mp_obj_t layer); -mp_obj_t common_hal_displayio_group_get(displayio_group_t* self, size_t index); -void common_hal_displayio_group_set(displayio_group_t* self, size_t index, mp_obj_t layer); +void common_hal_displayio_group_construct(displayio_group_t *self, uint32_t scale, mp_int_t x, mp_int_t y); +uint32_t common_hal_displayio_group_get_scale(displayio_group_t *self); +void common_hal_displayio_group_set_scale(displayio_group_t *self, uint32_t scale); +bool common_hal_displayio_group_get_hidden(displayio_group_t *self); +void common_hal_displayio_group_set_hidden(displayio_group_t *self, bool hidden); +mp_int_t common_hal_displayio_group_get_x(displayio_group_t *self); +void common_hal_displayio_group_set_x(displayio_group_t *self, mp_int_t x); +mp_int_t common_hal_displayio_group_get_y(displayio_group_t *self); +void common_hal_displayio_group_set_y(displayio_group_t *self, mp_int_t y); +void common_hal_displayio_group_append(displayio_group_t *self, mp_obj_t layer); +void common_hal_displayio_group_insert(displayio_group_t *self, size_t index, mp_obj_t layer); +size_t common_hal_displayio_group_get_len(displayio_group_t *self); +mp_obj_t common_hal_displayio_group_pop(displayio_group_t *self, size_t index); +mp_int_t common_hal_displayio_group_index(displayio_group_t *self, mp_obj_t layer); +mp_obj_t common_hal_displayio_group_get(displayio_group_t *self, size_t index); +void common_hal_displayio_group_set(displayio_group_t *self, size_t index, mp_obj_t layer); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_GROUP_H diff --git a/shared-bindings/displayio/I2CDisplay.c b/shared-bindings/displayio/I2CDisplay.c index 5dc4711b3..2f27c7b5d 100644 --- a/shared-bindings/displayio/I2CDisplay.c +++ b/shared-bindings/displayio/I2CDisplay.c @@ -68,7 +68,7 @@ STATIC mp_obj_t displayio_i2cdisplay_make_new(const mp_obj_type_t *type, size_t mcu_pin_obj_t *reset = validate_obj_is_free_pin_or_none(args[ARG_reset].u_obj); mp_obj_t i2c = args[ARG_i2c_bus].u_obj; - displayio_i2cdisplay_obj_t* self = &allocate_display_bus_or_raise()->i2cdisplay_bus; + displayio_i2cdisplay_obj_t *self = &allocate_display_bus_or_raise()->i2cdisplay_bus; self->base.type = &displayio_i2cdisplay_type; common_hal_displayio_i2cdisplay_construct(self, @@ -111,7 +111,7 @@ STATIC mp_obj_t displayio_i2cdisplay_obj_send(mp_obj_t self, mp_obj_t command_ob } uint8_t full_command[bufinfo.len + 1]; full_command[0] = command; - memcpy(full_command + 1, ((uint8_t*) bufinfo.buf), bufinfo.len); + memcpy(full_command + 1, ((uint8_t *)bufinfo.buf), bufinfo.len); common_hal_displayio_i2cdisplay_send(self, DISPLAY_COMMAND, CHIP_SELECT_UNTOUCHED, full_command, bufinfo.len + 1); common_hal_displayio_i2cdisplay_end_transaction(self); @@ -129,5 +129,5 @@ const mp_obj_type_t displayio_i2cdisplay_type = { { &mp_type_type }, .name = MP_QSTR_I2CDisplay, .make_new = displayio_i2cdisplay_make_new, - .locals_dict = (mp_obj_dict_t*)&displayio_i2cdisplay_locals_dict, + .locals_dict = (mp_obj_dict_t *)&displayio_i2cdisplay_locals_dict, }; diff --git a/shared-bindings/displayio/I2CDisplay.h b/shared-bindings/displayio/I2CDisplay.h index 37520202e..d40cd19d8 100644 --- a/shared-bindings/displayio/I2CDisplay.h +++ b/shared-bindings/displayio/I2CDisplay.h @@ -34,10 +34,10 @@ extern const mp_obj_type_t displayio_i2cdisplay_type; -void common_hal_displayio_i2cdisplay_construct(displayio_i2cdisplay_obj_t* self, - busio_i2c_obj_t* i2c, uint16_t device_address, const mcu_pin_obj_t* reset); +void common_hal_displayio_i2cdisplay_construct(displayio_i2cdisplay_obj_t *self, + busio_i2c_obj_t *i2c, uint16_t device_address, const mcu_pin_obj_t *reset); -void common_hal_displayio_i2cdisplay_deinit(displayio_i2cdisplay_obj_t* self); +void common_hal_displayio_i2cdisplay_deinit(displayio_i2cdisplay_obj_t *self); bool common_hal_displayio_i2cdisplay_reset(mp_obj_t self); bool common_hal_displayio_i2cdisplay_bus_free(mp_obj_t self); diff --git a/shared-bindings/displayio/OnDiskBitmap.c b/shared-bindings/displayio/OnDiskBitmap.c index 938e408ab..e41f54edf 100644 --- a/shared-bindings/displayio/OnDiskBitmap.c +++ b/shared-bindings/displayio/OnDiskBitmap.c @@ -137,5 +137,5 @@ const mp_obj_type_t displayio_ondiskbitmap_type = { { &mp_type_type }, .name = MP_QSTR_OnDiskBitmap, .make_new = displayio_ondiskbitmap_make_new, - .locals_dict = (mp_obj_dict_t*)&displayio_ondiskbitmap_locals_dict, + .locals_dict = (mp_obj_dict_t *)&displayio_ondiskbitmap_locals_dict, }; diff --git a/shared-bindings/displayio/OnDiskBitmap.h b/shared-bindings/displayio/OnDiskBitmap.h index 9a6c81f8f..aff3a19db 100644 --- a/shared-bindings/displayio/OnDiskBitmap.h +++ b/shared-bindings/displayio/OnDiskBitmap.h @@ -32,7 +32,7 @@ extern const mp_obj_type_t displayio_ondiskbitmap_type; -void common_hal_displayio_ondiskbitmap_construct(displayio_ondiskbitmap_t *self, pyb_file_obj_t* file); +void common_hal_displayio_ondiskbitmap_construct(displayio_ondiskbitmap_t *self, pyb_file_obj_t *file); uint32_t common_hal_displayio_ondiskbitmap_get_pixel(displayio_ondiskbitmap_t *bitmap, int16_t x, int16_t y); diff --git a/shared-bindings/displayio/Palette.c b/shared-bindings/displayio/Palette.c index c868aea9c..d5acf1ed6 100644 --- a/shared-bindings/displayio/Palette.c +++ b/shared-bindings/displayio/Palette.c @@ -74,10 +74,12 @@ STATIC mp_obj_t displayio_palette_make_new(const mp_obj_type_t *type, size_t n_a STATIC mp_obj_t group_unary_op(mp_unary_op_t op, mp_obj_t self_in) { displayio_palette_t *self = MP_OBJ_TO_PTR(self_in); switch (op) { - case MP_UNARY_OP_BOOL: return mp_const_true; + case MP_UNARY_OP_BOOL: + return mp_const_true; case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_palette_get_len(self)); - default: return MP_OBJ_NULL; // op not supported + default: + return MP_OBJ_NULL; // op not supported } } @@ -130,7 +132,7 @@ STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t val if (bufinfo.typecode != 'b' && bufinfo.typecode != 'B' && bufinfo.typecode != BYTEARRAY_TYPECODE) { mp_raise_ValueError(translate("color buffer must be a bytearray or array of type 'b' or 'B'")); } - uint8_t* buf = bufinfo.buf; + uint8_t *buf = bufinfo.buf; if (bufinfo.len == 3 || bufinfo.len == 4) { color = buf[0] << 16 | buf[1] << 8 | buf[2]; } else { @@ -191,5 +193,5 @@ const mp_obj_type_t displayio_palette_type = { .subscr = palette_subscr, .unary_op = group_unary_op, .getiter = mp_obj_new_generic_iterator, - .locals_dict = (mp_obj_dict_t*)&displayio_palette_locals_dict, + .locals_dict = (mp_obj_dict_t *)&displayio_palette_locals_dict, }; diff --git a/shared-bindings/displayio/Palette.h b/shared-bindings/displayio/Palette.h index 8c9fe11e3..62b8f3600 100644 --- a/shared-bindings/displayio/Palette.h +++ b/shared-bindings/displayio/Palette.h @@ -31,12 +31,12 @@ extern const mp_obj_type_t displayio_palette_type; -void common_hal_displayio_palette_construct(displayio_palette_t* self, uint16_t color_count); -void common_hal_displayio_palette_set_color(displayio_palette_t* self, uint32_t palette_index, uint32_t color); -uint32_t common_hal_displayio_palette_get_color(displayio_palette_t* self, uint32_t palette_index); -uint32_t common_hal_displayio_palette_get_len(displayio_palette_t* self); +void common_hal_displayio_palette_construct(displayio_palette_t *self, uint16_t color_count); +void common_hal_displayio_palette_set_color(displayio_palette_t *self, uint32_t palette_index, uint32_t color); +uint32_t common_hal_displayio_palette_get_color(displayio_palette_t *self, uint32_t palette_index); +uint32_t common_hal_displayio_palette_get_len(displayio_palette_t *self); -void common_hal_displayio_palette_make_opaque(displayio_palette_t* self, uint32_t palette_index); -void common_hal_displayio_palette_make_transparent(displayio_palette_t* self, uint32_t palette_index); +void common_hal_displayio_palette_make_opaque(displayio_palette_t *self, uint32_t palette_index); +void common_hal_displayio_palette_make_transparent(displayio_palette_t *self, uint32_t palette_index); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_PALETTE_H diff --git a/shared-bindings/displayio/ParallelBus.c b/shared-bindings/displayio/ParallelBus.c index 30c9d373c..69483d5aa 100644 --- a/shared-bindings/displayio/ParallelBus.c +++ b/shared-bindings/displayio/ParallelBus.c @@ -79,7 +79,7 @@ STATIC mp_obj_t displayio_parallelbus_make_new(const mp_obj_type_t *type, size_t mcu_pin_obj_t *read = validate_obj_is_free_pin(args[ARG_read].u_obj); mcu_pin_obj_t *reset = validate_obj_is_free_pin(args[ARG_reset].u_obj); - displayio_parallelbus_obj_t* self = &allocate_display_bus_or_raise()->parallel_bus; + displayio_parallelbus_obj_t *self = &allocate_display_bus_or_raise()->parallel_bus; self->base.type = &displayio_parallelbus_type; common_hal_displayio_parallelbus_construct(self, data0, command, chip_select, write, read, reset); @@ -121,7 +121,7 @@ STATIC mp_obj_t displayio_parallelbus_obj_send(mp_obj_t self, mp_obj_t command_o RUN_BACKGROUND_TASKS; } common_hal_displayio_parallelbus_send(self, DISPLAY_COMMAND, CHIP_SELECT_UNTOUCHED, &command, 1); - common_hal_displayio_parallelbus_send(self, DISPLAY_DATA, CHIP_SELECT_UNTOUCHED, ((uint8_t*) bufinfo.buf), bufinfo.len); + common_hal_displayio_parallelbus_send(self, DISPLAY_DATA, CHIP_SELECT_UNTOUCHED, ((uint8_t *)bufinfo.buf), bufinfo.len); common_hal_displayio_parallelbus_end_transaction(self); return mp_const_none; @@ -138,5 +138,5 @@ const mp_obj_type_t displayio_parallelbus_type = { { &mp_type_type }, .name = MP_QSTR_ParallelBus, .make_new = displayio_parallelbus_make_new, - .locals_dict = (mp_obj_dict_t*)&displayio_parallelbus_locals_dict, + .locals_dict = (mp_obj_dict_t *)&displayio_parallelbus_locals_dict, }; diff --git a/shared-bindings/displayio/ParallelBus.h b/shared-bindings/displayio/ParallelBus.h index 1e74e3a0a..24c973884 100644 --- a/shared-bindings/displayio/ParallelBus.h +++ b/shared-bindings/displayio/ParallelBus.h @@ -35,11 +35,11 @@ extern const mp_obj_type_t displayio_parallelbus_type; -void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t* self, - const mcu_pin_obj_t* data0, const mcu_pin_obj_t* command, const mcu_pin_obj_t* chip_select, - const mcu_pin_obj_t* write, const mcu_pin_obj_t* read, const mcu_pin_obj_t* reset); +void common_hal_displayio_parallelbus_construct(displayio_parallelbus_obj_t *self, + const mcu_pin_obj_t *data0, const mcu_pin_obj_t *command, const mcu_pin_obj_t *chip_select, + const mcu_pin_obj_t *write, const mcu_pin_obj_t *read, const mcu_pin_obj_t *reset); -void common_hal_displayio_parallelbus_deinit(displayio_parallelbus_obj_t* self); +void common_hal_displayio_parallelbus_deinit(displayio_parallelbus_obj_t *self); bool common_hal_displayio_parallelbus_reset(mp_obj_t self); bool common_hal_displayio_parallelbus_bus_free(mp_obj_t self); diff --git a/shared-bindings/displayio/Shape.c b/shared-bindings/displayio/Shape.c index 4d737ecae..0126df885 100644 --- a/shared-bindings/displayio/Shape.c +++ b/shared-bindings/displayio/Shape.c @@ -84,7 +84,7 @@ STATIC mp_obj_t displayio_shape_make_new(const mp_obj_type_t *type, size_t n_arg //| ... //| STATIC mp_obj_t displayio_shape_obj_set_boundary(size_t n_args, const mp_obj_t *args) { - (void) n_args; + (void)n_args; displayio_shape_t *self = MP_OBJ_TO_PTR(args[0]); mp_int_t y; if (!mp_obj_get_int_maybe(args[1], &y)) { @@ -113,5 +113,5 @@ const mp_obj_type_t displayio_shape_type = { { &mp_type_type }, .name = MP_QSTR_Shape, .make_new = displayio_shape_make_new, - .locals_dict = (mp_obj_dict_t*)&displayio_shape_locals_dict, + .locals_dict = (mp_obj_dict_t *)&displayio_shape_locals_dict, }; diff --git a/shared-bindings/displayio/Shape.h b/shared-bindings/displayio/Shape.h index d08a38782..961b57c67 100644 --- a/shared-bindings/displayio/Shape.h +++ b/shared-bindings/displayio/Shape.h @@ -35,7 +35,7 @@ void common_hal_displayio_shape_construct(displayio_shape_t *self, uint32_t widt uint32_t height, bool mirror_x, bool mirror_y); void common_hal_displayio_shape_set_boundary(displayio_shape_t *self, uint16_t y, uint16_t start_x, - uint16_t end_x); + uint16_t end_x); uint32_t common_hal_displayio_shape_get_pixel(void *shape, int16_t x, int16_t y); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_SHAPE_H diff --git a/shared-bindings/displayio/TileGrid.c b/shared-bindings/displayio/TileGrid.c index 73a08f556..dee0d7a68 100644 --- a/shared-bindings/displayio/TileGrid.c +++ b/shared-bindings/displayio/TileGrid.c @@ -87,16 +87,16 @@ STATIC mp_obj_t displayio_tilegrid_make_new(const mp_obj_type_t *type, size_t n_ uint16_t bitmap_height; mp_obj_t native = mp_instance_cast_to_native_base(bitmap, &displayio_shape_type); if (native != MP_OBJ_NULL) { - displayio_shape_t* bmp = MP_OBJ_TO_PTR(native); + displayio_shape_t *bmp = MP_OBJ_TO_PTR(native); bitmap_width = bmp->width; bitmap_height = bmp->height; } else if (MP_OBJ_IS_TYPE(bitmap, &displayio_bitmap_type)) { - displayio_bitmap_t* bmp = MP_OBJ_TO_PTR(bitmap); + displayio_bitmap_t *bmp = MP_OBJ_TO_PTR(bitmap); native = bitmap; bitmap_width = bmp->width; bitmap_height = bmp->height; } else if (MP_OBJ_IS_TYPE(bitmap, &displayio_ondiskbitmap_type)) { - displayio_ondiskbitmap_t* bmp = MP_OBJ_TO_PTR(bitmap); + displayio_ondiskbitmap_t *bmp = MP_OBJ_TO_PTR(bitmap); native = bitmap; bitmap_width = bmp->width; bitmap_height = bmp->height; @@ -136,7 +136,7 @@ STATIC mp_obj_t displayio_tilegrid_make_new(const mp_obj_type_t *type, size_t n_ } // Helper to ensure we have the native super class instead of a subclass. -static displayio_tilegrid_t* native_tilegrid(mp_obj_t tilegrid_obj) { +static displayio_tilegrid_t *native_tilegrid(mp_obj_t tilegrid_obj) { mp_obj_t native_tilegrid = mp_instance_cast_to_native_base(tilegrid_obj, &displayio_tilegrid_type); mp_obj_assert_native_inited(native_tilegrid); return MP_OBJ_TO_PTR(native_tilegrid); @@ -354,13 +354,13 @@ STATIC mp_obj_t tilegrid_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t v x = i % width; y = i / width; } else { - mp_obj_t* items; + mp_obj_t *items; mp_obj_get_array_fixed_n(index_obj, 2, &items); x = mp_obj_get_int(items[0]); y = mp_obj_get_int(items[1]); } if (x >= common_hal_displayio_tilegrid_get_width(self) || - y >= common_hal_displayio_tilegrid_get_height(self)) { + y >= common_hal_displayio_tilegrid_get_height(self)) { mp_raise_IndexError(translate("Tile index out of bounds")); } @@ -397,5 +397,5 @@ const mp_obj_type_t displayio_tilegrid_type = { .name = MP_QSTR_TileGrid, .make_new = displayio_tilegrid_make_new, .subscr = tilegrid_subscr, - .locals_dict = (mp_obj_dict_t*)&displayio_tilegrid_locals_dict, + .locals_dict = (mp_obj_dict_t *)&displayio_tilegrid_locals_dict, }; diff --git a/shared-bindings/displayio/TileGrid.h b/shared-bindings/displayio/TileGrid.h index 0ee1c7883..7c8d8a605 100644 --- a/shared-bindings/displayio/TileGrid.h +++ b/shared-bindings/displayio/TileGrid.h @@ -32,12 +32,12 @@ extern const mp_obj_type_t displayio_tilegrid_type; void common_hal_displayio_tilegrid_construct(displayio_tilegrid_t *self, mp_obj_t bitmap, - uint16_t bitmap_width_in_tiles, uint16_t bitmap_height_in_tiles, - mp_obj_t pixel_shader, uint16_t width, uint16_t height, - uint16_t tile_width, uint16_t tile_height, uint16_t x, uint16_t y, uint8_t default_tile); + uint16_t bitmap_width_in_tiles, uint16_t bitmap_height_in_tiles, + mp_obj_t pixel_shader, uint16_t width, uint16_t height, + uint16_t tile_width, uint16_t tile_height, uint16_t x, uint16_t y, uint8_t default_tile); -bool common_hal_displayio_tilegrid_get_hidden(displayio_tilegrid_t* self); -void common_hal_displayio_tilegrid_set_hidden(displayio_tilegrid_t* self, bool hidden); +bool common_hal_displayio_tilegrid_get_hidden(displayio_tilegrid_t *self); +void common_hal_displayio_tilegrid_set_hidden(displayio_tilegrid_t *self, bool hidden); mp_int_t common_hal_displayio_tilegrid_get_x(displayio_tilegrid_t *self); void common_hal_displayio_tilegrid_set_x(displayio_tilegrid_t *self, mp_int_t x); mp_int_t common_hal_displayio_tilegrid_get_y(displayio_tilegrid_t *self); diff --git a/shared-bindings/displayio/__init__.c b/shared-bindings/displayio/__init__.c index 16d068e2e..bca4289b0 100644 --- a/shared-bindings/displayio/__init__.c +++ b/shared-bindings/displayio/__init__.c @@ -88,5 +88,5 @@ STATIC MP_DEFINE_CONST_DICT(displayio_module_globals, displayio_module_globals_t const mp_obj_module_t displayio_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&displayio_module_globals, + .globals = (mp_obj_dict_t *)&displayio_module_globals, }; diff --git a/shared-bindings/dualbank/__init__.c b/shared-bindings/dualbank/__init__.c index 8021ab18b..3b267a56f 100644 --- a/shared-bindings/dualbank/__init__.c +++ b/shared-bindings/dualbank/__init__.c @@ -111,5 +111,5 @@ STATIC MP_DEFINE_CONST_DICT(dualbank_module_globals, dualbank_module_globals_tab const mp_obj_module_t dualbank_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&dualbank_module_globals, + .globals = (mp_obj_dict_t *)&dualbank_module_globals, }; diff --git a/shared-bindings/fontio/BuiltinFont.c b/shared-bindings/fontio/BuiltinFont.c index 8ae2356bb..29b124dc5 100644 --- a/shared-bindings/fontio/BuiltinFont.c +++ b/shared-bindings/fontio/BuiltinFont.c @@ -101,5 +101,5 @@ STATIC MP_DEFINE_CONST_DICT(fontio_builtinfont_locals_dict, fontio_builtinfont_l const mp_obj_type_t fontio_builtinfont_type = { { &mp_type_type }, .name = MP_QSTR_BuiltinFont, - .locals_dict = (mp_obj_dict_t*)&fontio_builtinfont_locals_dict, + .locals_dict = (mp_obj_dict_t *)&fontio_builtinfont_locals_dict, }; diff --git a/shared-bindings/fontio/__init__.c b/shared-bindings/fontio/__init__.c index f376f3503..c80d68a87 100644 --- a/shared-bindings/fontio/__init__.c +++ b/shared-bindings/fontio/__init__.c @@ -46,5 +46,5 @@ STATIC MP_DEFINE_CONST_DICT(fontio_module_globals, fontio_module_globals_table); const mp_obj_module_t fontio_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&fontio_module_globals, + .globals = (mp_obj_dict_t *)&fontio_module_globals, }; diff --git a/shared-bindings/framebufferio/FramebufferDisplay.c b/shared-bindings/framebufferio/FramebufferDisplay.c index 8d1e2ac9c..329e2a893 100644 --- a/shared-bindings/framebufferio/FramebufferDisplay.c +++ b/shared-bindings/framebufferio/FramebufferDisplay.c @@ -62,7 +62,7 @@ STATIC mp_obj_t framebufferio_framebufferdisplay_make_new(const mp_obj_type_t *t { MP_QSTR_rotation, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0} }, { MP_QSTR_auto_refresh, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = true} }, }; - MP_STATIC_ASSERT( MP_ARRAY_SIZE(allowed_args) == NUM_ARGS ); + MP_STATIC_ASSERT(MP_ARRAY_SIZE(allowed_args) == NUM_ARGS); mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); @@ -87,7 +87,7 @@ STATIC mp_obj_t framebufferio_framebufferdisplay_make_new(const mp_obj_type_t *t } // Helper to ensure we have the native super class instead of a subclass. -static framebufferio_framebufferdisplay_obj_t* native_display(mp_obj_t display_obj) { +static framebufferio_framebufferdisplay_obj_t *native_display(mp_obj_t display_obj) { mp_obj_t native_display = mp_instance_cast_to_native_base(display_obj, &framebufferio_framebufferdisplay_type); mp_obj_assert_native_inited(native_display); return MP_OBJ_TO_PTR(native_display); @@ -102,7 +102,7 @@ static framebufferio_framebufferdisplay_obj_t* native_display(mp_obj_t display_o //| STATIC mp_obj_t framebufferio_framebufferdisplay_obj_show(mp_obj_t self_in, mp_obj_t group_in) { framebufferio_framebufferdisplay_obj_t *self = native_display(self_in); - displayio_group_t* group = NULL; + displayio_group_t *group = NULL; if (group_in != mp_const_none) { group = MP_OBJ_TO_PTR(native_group(group_in)); } @@ -339,40 +339,40 @@ STATIC mp_obj_t framebufferio_framebufferdisplay_obj_fill_row(size_t n_args, con mp_get_buffer_raise(result, &bufinfo, MP_BUFFER_WRITE); if (bufinfo.typecode != BYTEARRAY_TYPECODE) { - mp_raise_ValueError(translate("Buffer is not a bytearray.")); + mp_raise_ValueError(translate("Buffer is not a bytearray.")); } if (self->core.colorspace.depth != 16) { - mp_raise_ValueError(translate("Display must have a 16 bit colorspace.")); + mp_raise_ValueError(translate("Display must have a 16 bit colorspace.")); } displayio_area_t area = { - .x1 = 0, - .y1 = y, - .x2 = self->core.width, - .y2 = y + 1 + .x1 = 0, + .y1 = y, + .x2 = self->core.width, + .y2 = y + 1 }; uint8_t pixels_per_word = (sizeof(uint32_t) * 8) / self->core.colorspace.depth; uint16_t buffer_size = self->core.width / pixels_per_word; uint16_t pixels_per_buffer = displayio_area_size(&area); if (pixels_per_buffer % pixels_per_word) { - buffer_size += 1; + buffer_size += 1; } uint32_t *result_buffer = bufinfo.buf; size_t result_buffer_size = bufinfo.len; if (result_buffer_size >= (buffer_size * 4)) { - volatile uint32_t mask_length = (pixels_per_buffer / 32) + 1; - uint32_t mask[mask_length]; + volatile uint32_t mask_length = (pixels_per_buffer / 32) + 1; + uint32_t mask[mask_length]; - for (uint16_t k = 0; k < mask_length; k++) { - mask[k] = 0x00000000; - } + for (uint16_t k = 0; k < mask_length; k++) { + mask[k] = 0x00000000; + } - displayio_display_core_fill_area(&self->core, &area, mask, result_buffer); - return result; + displayio_display_core_fill_area(&self->core, &area, mask, result_buffer); + return result; } else { - mp_raise_ValueError(translate("Buffer is too small")); + mp_raise_ValueError(translate("Buffer is too small")); } } MP_DEFINE_CONST_FUN_OBJ_KW(framebufferio_framebufferdisplay_fill_row_obj, 1, framebufferio_framebufferdisplay_obj_fill_row); @@ -398,5 +398,5 @@ const mp_obj_type_t framebufferio_framebufferdisplay_type = { { &mp_type_type }, .name = MP_QSTR_FramebufferDisplay, .make_new = framebufferio_framebufferdisplay_make_new, - .locals_dict = (mp_obj_dict_t*)&framebufferio_framebufferdisplay_locals_dict, + .locals_dict = (mp_obj_dict_t *)&framebufferio_framebufferdisplay_locals_dict, }; diff --git a/shared-bindings/framebufferio/FramebufferDisplay.h b/shared-bindings/framebufferio/FramebufferDisplay.h index c41e041ce..b482666c2 100644 --- a/shared-bindings/framebufferio/FramebufferDisplay.h +++ b/shared-bindings/framebufferio/FramebufferDisplay.h @@ -39,31 +39,31 @@ extern const mp_obj_type_t framebufferio_framebufferdisplay_type; #define NO_BRIGHTNESS_COMMAND 0x100 -void common_hal_framebufferio_framebufferdisplay_construct(framebufferio_framebufferdisplay_obj_t* self, - mp_obj_t framebuffer, - uint16_t rotation, - bool auto_refresh); +void common_hal_framebufferio_framebufferdisplay_construct(framebufferio_framebufferdisplay_obj_t *self, + mp_obj_t framebuffer, + uint16_t rotation, + bool auto_refresh); -bool common_hal_framebufferio_framebufferdisplay_show(framebufferio_framebufferdisplay_obj_t* self, - displayio_group_t* root_group); +bool common_hal_framebufferio_framebufferdisplay_show(framebufferio_framebufferdisplay_obj_t *self, + displayio_group_t *root_group); -bool common_hal_framebufferio_framebufferdisplay_refresh(framebufferio_framebufferdisplay_obj_t* self, uint32_t target_ms_per_frame, uint32_t maximum_ms_per_real_frame); +bool common_hal_framebufferio_framebufferdisplay_refresh(framebufferio_framebufferdisplay_obj_t *self, uint32_t target_ms_per_frame, uint32_t maximum_ms_per_real_frame); -bool common_hal_framebufferio_framebufferdisplay_get_auto_refresh(framebufferio_framebufferdisplay_obj_t* self); -void common_hal_framebufferio_framebufferdisplay_set_auto_refresh(framebufferio_framebufferdisplay_obj_t* self, bool auto_refresh); +bool common_hal_framebufferio_framebufferdisplay_get_auto_refresh(framebufferio_framebufferdisplay_obj_t *self); +void common_hal_framebufferio_framebufferdisplay_set_auto_refresh(framebufferio_framebufferdisplay_obj_t *self, bool auto_refresh); -uint16_t common_hal_framebufferio_framebufferdisplay_get_width(framebufferio_framebufferdisplay_obj_t* self); -uint16_t common_hal_framebufferio_framebufferdisplay_get_height(framebufferio_framebufferdisplay_obj_t* self); -uint16_t common_hal_framebufferio_framebufferdisplay_get_rotation(framebufferio_framebufferdisplay_obj_t* self); -void common_hal_framebufferio_framebufferdisplay_set_rotation(framebufferio_framebufferdisplay_obj_t* self, int rotation); +uint16_t common_hal_framebufferio_framebufferdisplay_get_width(framebufferio_framebufferdisplay_obj_t *self); +uint16_t common_hal_framebufferio_framebufferdisplay_get_height(framebufferio_framebufferdisplay_obj_t *self); +uint16_t common_hal_framebufferio_framebufferdisplay_get_rotation(framebufferio_framebufferdisplay_obj_t *self); +void common_hal_framebufferio_framebufferdisplay_set_rotation(framebufferio_framebufferdisplay_obj_t *self, int rotation); -bool common_hal_framebufferio_framebufferdisplay_get_auto_brightness(framebufferio_framebufferdisplay_obj_t* self); -bool common_hal_framebufferio_framebufferdisplay_set_auto_brightness(framebufferio_framebufferdisplay_obj_t* self, bool auto_brightness); +bool common_hal_framebufferio_framebufferdisplay_get_auto_brightness(framebufferio_framebufferdisplay_obj_t *self); +bool common_hal_framebufferio_framebufferdisplay_set_auto_brightness(framebufferio_framebufferdisplay_obj_t *self, bool auto_brightness); -mp_float_t common_hal_framebufferio_framebufferdisplay_get_brightness(framebufferio_framebufferdisplay_obj_t* self); -bool common_hal_framebufferio_framebufferdisplay_set_brightness(framebufferio_framebufferdisplay_obj_t* self, mp_float_t brightness); +mp_float_t common_hal_framebufferio_framebufferdisplay_get_brightness(framebufferio_framebufferdisplay_obj_t *self); +bool common_hal_framebufferio_framebufferdisplay_set_brightness(framebufferio_framebufferdisplay_obj_t *self, mp_float_t brightness); -mp_obj_t common_hal_framebufferio_framebufferdisplay_framebuffer(framebufferio_framebufferdisplay_obj_t* self); +mp_obj_t common_hal_framebufferio_framebufferdisplay_framebuffer(framebufferio_framebufferdisplay_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_DISPLAYIO_FRAMEBUFFERDISPLAY_H diff --git a/shared-bindings/framebufferio/__init__.c b/shared-bindings/framebufferio/__init__.c index 3e58162bf..ae0f3f906 100644 --- a/shared-bindings/framebufferio/__init__.c +++ b/shared-bindings/framebufferio/__init__.c @@ -45,6 +45,6 @@ static const mp_rom_map_elem_t framebufferio_module_globals_table[] = { STATIC MP_DEFINE_CONST_DICT(framebufferio_module_globals, framebufferio_module_globals_table); const mp_obj_module_t framebufferio_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&framebufferio_module_globals, + .globals = (mp_obj_dict_t *)&framebufferio_module_globals, }; #endif diff --git a/shared-bindings/frequencyio/FrequencyIn.c b/shared-bindings/frequencyio/FrequencyIn.c index 8b0e2b41c..6a2ed0279 100644 --- a/shared-bindings/frequencyio/FrequencyIn.c +++ b/shared-bindings/frequencyio/FrequencyIn.c @@ -72,7 +72,7 @@ //| ... //| STATIC mp_obj_t frequencyio_frequencyin_make_new(const mp_obj_type_t *type, size_t n_args, - const mp_obj_t *pos_args, mp_map_t *kw_args) { + const mp_obj_t *pos_args, mp_map_t *kw_args) { mp_arg_check_num(n_args, kw_args, 1, 1, true); frequencyio_frequencyin_obj_t *self = m_new_obj(frequencyio_frequencyin_obj_t); @@ -85,7 +85,7 @@ STATIC mp_obj_t frequencyio_frequencyin_make_new(const mp_obj_type_t *type, size mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - mcu_pin_obj_t* pin = validate_obj_is_free_pin(args[ARG_pin].u_obj); + mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[ARG_pin].u_obj); const uint16_t capture_period = args[ARG_capture_period].u_int; @@ -209,7 +209,7 @@ STATIC mp_obj_t frequencyio_frequencyin_obj_get_value(mp_obj_t self_in) { frequencyio_frequencyin_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); - //return MP_OBJ_NEW_SMALL_INT(common_hal_frequencyio_frequencyin_get_item(self)); + // return MP_OBJ_NEW_SMALL_INT(common_hal_frequencyio_frequencyin_get_item(self)); return mp_obj_new_int_from_float(common_hal_frequencyio_frequencyin_get_item(self)); } MP_DEFINE_CONST_FUN_OBJ_1(frequencyio_frequencyin_get_value_obj, frequencyio_frequencyin_obj_get_value); @@ -238,5 +238,5 @@ const mp_obj_type_t frequencyio_frequencyin_type = { { &mp_type_type }, .name = MP_QSTR_frequencyin, .make_new = frequencyio_frequencyin_make_new, - .locals_dict = (mp_obj_dict_t*)&frequencyio_frequencyin_locals_dict, + .locals_dict = (mp_obj_dict_t *)&frequencyio_frequencyin_locals_dict, }; diff --git a/shared-bindings/frequencyio/__init__.c b/shared-bindings/frequencyio/__init__.c index 031004d4b..0ad8bbbe9 100644 --- a/shared-bindings/frequencyio/__init__.c +++ b/shared-bindings/frequencyio/__init__.c @@ -70,5 +70,5 @@ STATIC MP_DEFINE_CONST_DICT(frequencyio_module_globals, frequencyio_module_globa const mp_obj_module_t frequencyio_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&frequencyio_module_globals, + .globals = (mp_obj_dict_t *)&frequencyio_module_globals, }; diff --git a/shared-bindings/gamepad/GamePad.c b/shared-bindings/gamepad/GamePad.c index dca1eb1e8..367f1ccce 100644 --- a/shared-bindings/gamepad/GamePad.c +++ b/shared-bindings/gamepad/GamePad.c @@ -102,14 +102,14 @@ //| ... //| STATIC mp_obj_t gamepad_make_new(const mp_obj_type_t *type, size_t n_args, - const mp_obj_t *args, mp_map_t *kw_args) { + const mp_obj_t *args, mp_map_t *kw_args) { if (n_args > 8 || n_args == 0) { mp_raise_TypeError(translate("argument num/types mismatch")); } for (size_t i = 0; i < n_args; ++i) { assert_digitalinout(args[i]); } - gamepad_obj_t* gamepad_singleton = MP_STATE_VM(gamepad_singleton); + gamepad_obj_t *gamepad_singleton = MP_STATE_VM(gamepad_singleton); if (!gamepad_singleton || !MP_OBJ_IS_TYPE(MP_OBJ_FROM_PTR(gamepad_singleton), &gamepad_type)) { gamepad_singleton = m_new_ll_obj(gamepad_obj_t); @@ -134,7 +134,7 @@ STATIC mp_obj_t gamepad_make_new(const mp_obj_type_t *type, size_t n_args, //| ... //| STATIC mp_obj_t gamepad_get_pressed(mp_obj_t self_in) { - gamepad_obj_t* gamepad_singleton = MP_STATE_VM(gamepad_singleton); + gamepad_obj_t *gamepad_singleton = MP_STATE_VM(gamepad_singleton); mp_obj_t pressed = MP_OBJ_NEW_SMALL_INT(gamepad_singleton->pressed); gamepad_singleton->pressed = gamepad_singleton->last; return pressed; @@ -162,5 +162,5 @@ const mp_obj_type_t gamepad_type = { { &mp_type_type }, .name = MP_QSTR_GamePad, .make_new = gamepad_make_new, - .locals_dict = (mp_obj_dict_t*)&gamepad_locals_dict, + .locals_dict = (mp_obj_dict_t *)&gamepad_locals_dict, }; diff --git a/shared-bindings/gamepad/__init__.c b/shared-bindings/gamepad/__init__.c index 557777f50..273f109bf 100644 --- a/shared-bindings/gamepad/__init__.c +++ b/shared-bindings/gamepad/__init__.c @@ -36,9 +36,9 @@ STATIC const mp_rom_map_elem_t gamepad_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_GamePad), MP_ROM_PTR(&gamepad_type)}, }; STATIC MP_DEFINE_CONST_DICT(gamepad_module_globals, - gamepad_module_globals_table); + gamepad_module_globals_table); const mp_obj_module_t gamepad_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&gamepad_module_globals, + .globals = (mp_obj_dict_t *)&gamepad_module_globals, }; diff --git a/shared-bindings/gamepadshift/GamePadShift.c b/shared-bindings/gamepadshift/GamePadShift.c index f6488bbd7..18f9876b7 100644 --- a/shared-bindings/gamepadshift/GamePadShift.c +++ b/shared-bindings/gamepadshift/GamePadShift.c @@ -51,7 +51,7 @@ //| ... //| STATIC mp_obj_t gamepadshift_make_new(const mp_obj_type_t *type, size_t n_args, - const mp_obj_t *pos_args, mp_map_t *kw_args) { + const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_clock, ARG_data, ARG_latch }; static const mp_arg_t allowed_args[] = { @@ -61,16 +61,16 @@ STATIC mp_obj_t gamepadshift_make_new(const mp_obj_type_t *type, size_t n_args, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), - allowed_args, args); + allowed_args, args); digitalio_digitalinout_obj_t *clock_pin = assert_digitalinout(args[ARG_clock].u_obj); digitalio_digitalinout_obj_t *data_pin = assert_digitalinout(args[ARG_data].u_obj); digitalio_digitalinout_obj_t *latch_pin = assert_digitalinout(args[ARG_latch].u_obj); - gamepadshift_obj_t* gamepad_singleton = MP_STATE_VM(gamepad_singleton); + gamepadshift_obj_t *gamepad_singleton = MP_STATE_VM(gamepad_singleton); if (!gamepad_singleton || !MP_OBJ_IS_TYPE(MP_OBJ_FROM_PTR(gamepad_singleton), - &gamepadshift_type)) { + &gamepadshift_type)) { gamepad_singleton = m_new_ll_obj(gamepadshift_obj_t); gamepad_singleton->base.type = &gamepadshift_type; if (!MP_STATE_VM(gamepad_singleton)) { @@ -93,7 +93,7 @@ STATIC mp_obj_t gamepadshift_make_new(const mp_obj_type_t *type, size_t n_args, //| ... //| STATIC mp_obj_t gamepadshift_get_pressed(mp_obj_t self_in) { - gamepadshift_obj_t* gamepad_singleton = MP_STATE_VM(gamepad_singleton); + gamepadshift_obj_t *gamepad_singleton = MP_STATE_VM(gamepad_singleton); mp_obj_t pressed = MP_OBJ_NEW_SMALL_INT(gamepad_singleton->pressed); gamepad_singleton->pressed = gamepad_singleton->last; return pressed; @@ -120,5 +120,5 @@ const mp_obj_type_t gamepadshift_type = { { &mp_type_type }, .name = MP_QSTR_GamePadShift, .make_new = gamepadshift_make_new, - .locals_dict = (mp_obj_dict_t*)&gamepadshift_locals_dict, + .locals_dict = (mp_obj_dict_t *)&gamepadshift_locals_dict, }; diff --git a/shared-bindings/gamepadshift/GamePadShift.h b/shared-bindings/gamepadshift/GamePadShift.h index 3e8ea9693..8856e133a 100644 --- a/shared-bindings/gamepadshift/GamePadShift.h +++ b/shared-bindings/gamepadshift/GamePadShift.h @@ -33,9 +33,9 @@ extern const mp_obj_type_t gamepadshift_type; void common_hal_gamepadshift_gamepadshift_init(gamepadshift_obj_t *gamepadshift, - digitalio_digitalinout_obj_t *clock_pin, - digitalio_digitalinout_obj_t *data_pin, - digitalio_digitalinout_obj_t *latch_pin); + digitalio_digitalinout_obj_t *clock_pin, + digitalio_digitalinout_obj_t *data_pin, + digitalio_digitalinout_obj_t *latch_pin); void common_hal_gamepadshift_gamepadshift_deinit(gamepadshift_obj_t *gamepadshift); diff --git a/shared-bindings/gamepadshift/__init__.c b/shared-bindings/gamepadshift/__init__.c index f17135893..1b25d342a 100644 --- a/shared-bindings/gamepadshift/__init__.c +++ b/shared-bindings/gamepadshift/__init__.c @@ -40,5 +40,5 @@ STATIC MP_DEFINE_CONST_DICT(gamepadshift_module_globals, gamepadshift_module_glo const mp_obj_module_t gamepadshift_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&gamepadshift_module_globals, + .globals = (mp_obj_dict_t *)&gamepadshift_module_globals, }; diff --git a/shared-bindings/gnss/GNSS.c b/shared-bindings/gnss/GNSS.c index 087c35395..a3563b7fd 100644 --- a/shared-bindings/gnss/GNSS.c +++ b/shared-bindings/gnss/GNSS.c @@ -198,8 +198,8 @@ STATIC const mp_rom_map_elem_t gnss_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(gnss_locals_dict, gnss_locals_dict_table); const mp_obj_type_t gnss_type = { - { &mp_type_type }, - .name = MP_QSTR_GNSS, - .make_new = gnss_make_new, - .locals_dict = (mp_obj_dict_t*)&gnss_locals_dict, + { &mp_type_type }, + .name = MP_QSTR_GNSS, + .make_new = gnss_make_new, + .locals_dict = (mp_obj_dict_t *)&gnss_locals_dict, }; diff --git a/shared-bindings/gnss/__init__.c b/shared-bindings/gnss/__init__.c index 4b0d312ae..80901a8c5 100644 --- a/shared-bindings/gnss/__init__.c +++ b/shared-bindings/gnss/__init__.c @@ -27,5 +27,5 @@ STATIC MP_DEFINE_CONST_DICT(gnss_module_globals, gnss_module_globals_table); const mp_obj_module_t gnss_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&gnss_module_globals, + .globals = (mp_obj_dict_t *)&gnss_module_globals, }; diff --git a/shared-bindings/i2cperipheral/I2CPeripheral.c b/shared-bindings/i2cperipheral/I2CPeripheral.c index b5c268eb5..9192d61ec 100644 --- a/shared-bindings/i2cperipheral/I2CPeripheral.c +++ b/shared-bindings/i2cperipheral/I2CPeripheral.c @@ -76,8 +76,8 @@ STATIC mp_obj_t i2cperipheral_i2c_peripheral_make_new(const mp_obj_type_t *type, mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - const mcu_pin_obj_t* scl = validate_obj_is_free_pin(args[ARG_scl].u_obj); - const mcu_pin_obj_t* sda = validate_obj_is_free_pin(args[ARG_sda].u_obj); + const mcu_pin_obj_t *scl = validate_obj_is_free_pin(args[ARG_scl].u_obj); + const mcu_pin_obj_t *sda = validate_obj_is_free_pin(args[ARG_sda].u_obj); mp_obj_iter_buf_t iter_buf; mp_obj_t iterable = mp_getiter(args[ARG_addresses].u_obj, &iter_buf); @@ -144,7 +144,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(i2cperipheral_i2c_peripheral___exit__ STATIC mp_obj_t i2cperipheral_i2c_peripheral_request(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { mp_check_self(MP_OBJ_IS_TYPE(pos_args[0], &i2cperipheral_i2c_peripheral_type)); i2cperipheral_i2c_peripheral_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); - if(common_hal_i2cperipheral_i2c_peripheral_deinited(self)) { + if (common_hal_i2cperipheral_i2c_peripheral_deinited(self)) { raise_deinited_error(); } enum { ARG_timeout }; @@ -220,10 +220,10 @@ STATIC const mp_rom_map_elem_t i2cperipheral_i2c_peripheral_locals_dict_table[] STATIC MP_DEFINE_CONST_DICT(i2cperipheral_i2c_peripheral_locals_dict, i2cperipheral_i2c_peripheral_locals_dict_table); const mp_obj_type_t i2cperipheral_i2c_peripheral_type = { - { &mp_type_type }, - .name = MP_QSTR_I2CPeripheral, - .make_new = i2cperipheral_i2c_peripheral_make_new, - .locals_dict = (mp_obj_dict_t*)&i2cperipheral_i2c_peripheral_locals_dict, + { &mp_type_type }, + .name = MP_QSTR_I2CPeripheral, + .make_new = i2cperipheral_i2c_peripheral_make_new, + .locals_dict = (mp_obj_dict_t *)&i2cperipheral_i2c_peripheral_locals_dict, }; //| class I2CPeripheralRequest: @@ -429,8 +429,8 @@ STATIC const mp_rom_map_elem_t i2cperipheral_i2c_peripheral_request_locals_dict_ STATIC MP_DEFINE_CONST_DICT(i2cperipheral_i2c_peripheral_request_locals_dict, i2cperipheral_i2c_peripheral_request_locals_dict_table); const mp_obj_type_t i2cperipheral_i2c_peripheral_request_type = { - { &mp_type_type }, - .name = MP_QSTR_I2CPeripheralRequest, - .make_new = i2cperipheral_i2c_peripheral_request_make_new, - .locals_dict = (mp_obj_dict_t*)&i2cperipheral_i2c_peripheral_request_locals_dict, + { &mp_type_type }, + .name = MP_QSTR_I2CPeripheralRequest, + .make_new = i2cperipheral_i2c_peripheral_request_make_new, + .locals_dict = (mp_obj_dict_t *)&i2cperipheral_i2c_peripheral_request_locals_dict, }; diff --git a/shared-bindings/i2cperipheral/I2CPeripheral.h b/shared-bindings/i2cperipheral/I2CPeripheral.h index 3035cfbfe..d3db1b96c 100644 --- a/shared-bindings/i2cperipheral/I2CPeripheral.h +++ b/shared-bindings/i2cperipheral/I2CPeripheral.h @@ -45,13 +45,13 @@ extern const mp_obj_type_t i2cperipheral_i2c_peripheral_request_type; extern const mp_obj_type_t i2cperipheral_i2c_peripheral_type; extern void common_hal_i2cperipheral_i2c_peripheral_construct(i2cperipheral_i2c_peripheral_obj_t *self, - const mcu_pin_obj_t* scl, const mcu_pin_obj_t* sda, - uint8_t *addresses, unsigned int num_addresses, bool smbus); + const mcu_pin_obj_t *scl, const mcu_pin_obj_t *sda, + uint8_t *addresses, unsigned int num_addresses, bool smbus); extern void common_hal_i2cperipheral_i2c_peripheral_deinit(i2cperipheral_i2c_peripheral_obj_t *self); extern bool common_hal_i2cperipheral_i2c_peripheral_deinited(i2cperipheral_i2c_peripheral_obj_t *self); extern int common_hal_i2cperipheral_i2c_peripheral_is_addressed(i2cperipheral_i2c_peripheral_obj_t *self, - uint8_t *address, bool *is_read, bool *is_restart); + uint8_t *address, bool *is_read, bool *is_restart); extern int common_hal_i2cperipheral_i2c_peripheral_read_byte(i2cperipheral_i2c_peripheral_obj_t *self, uint8_t *data); extern int common_hal_i2cperipheral_i2c_peripheral_write_byte(i2cperipheral_i2c_peripheral_obj_t *self, uint8_t data); extern void common_hal_i2cperipheral_i2c_peripheral_ack(i2cperipheral_i2c_peripheral_obj_t *self, bool ack); diff --git a/shared-bindings/i2cperipheral/__init__.c b/shared-bindings/i2cperipheral/__init__.c index e2cb8509d..183b8511c 100644 --- a/shared-bindings/i2cperipheral/__init__.c +++ b/shared-bindings/i2cperipheral/__init__.c @@ -30,7 +30,7 @@ #include "py/runtime.h" #include "shared-bindings/microcontroller/Pin.h" -//#include "shared-bindings/i2cperipheral/__init__.h" +// #include "shared-bindings/i2cperipheral/__init__.h" #include "shared-bindings/i2cperipheral/I2CPeripheral.h" #include "py/runtime.h" @@ -102,5 +102,5 @@ STATIC MP_DEFINE_CONST_DICT(i2cperipheral_module_globals, i2cperipheral_module_g const mp_obj_module_t i2cperipheral_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&i2cperipheral_module_globals, + .globals = (mp_obj_dict_t *)&i2cperipheral_module_globals, }; diff --git a/shared-bindings/ipaddress/IPv4Address.c b/shared-bindings/ipaddress/IPv4Address.c index e027f32d6..62a54560e 100644 --- a/shared-bindings/ipaddress/IPv4Address.c +++ b/shared-bindings/ipaddress/IPv4Address.c @@ -57,13 +57,13 @@ STATIC mp_obj_t ipaddress_ipv4address_make_new(const mp_obj_type_t *type, size_t const mp_obj_t address = args[ARG_address].u_obj; uint32_t value; - uint8_t* buf = NULL; - if (mp_obj_get_int_maybe(address, (mp_int_t*) &value)) { + uint8_t *buf = NULL; + if (mp_obj_get_int_maybe(address, (mp_int_t *)&value)) { // We're done. - buf = (uint8_t*) value; + buf = (uint8_t *)value; } else if (MP_OBJ_IS_STR(address)) { GET_STR_DATA_LEN(address, str_data, str_len); - if (!ipaddress_parse_ipv4address((const char*) str_data, str_len, &value)) { + if (!ipaddress_parse_ipv4address((const char *)str_data, str_len, &value)) { mp_raise_ValueError(translate("Not a valid IP string")); } } else { @@ -139,7 +139,7 @@ STATIC mp_obj_t ipaddress_ipv4address_binary_op(mp_binary_op_t op, mp_obj_t lhs_ ipaddress_ipv4address_obj_t *rhs = MP_OBJ_TO_PTR(rhs_in); return mp_obj_new_bool( mp_obj_equal(common_hal_ipaddress_ipv4address_get_packed(lhs), - common_hal_ipaddress_ipv4address_get_packed(rhs))); + common_hal_ipaddress_ipv4address_get_packed(rhs))); } else { return mp_const_false; @@ -177,7 +177,7 @@ STATIC void ipaddress_ipv4address_print(const mp_print_t *print, mp_obj_t self_i mp_obj_t address_bytes = common_hal_ipaddress_ipv4address_get_packed(self); mp_get_buffer_raise(address_bytes, &buf_info, MP_BUFFER_READ); - const uint8_t *buf = (uint8_t *) buf_info.buf; + const uint8_t *buf = (uint8_t *)buf_info.buf; mp_printf(print, "%d.%d.%d.%d", buf[0], buf[1], buf[2], buf[3]); } @@ -194,5 +194,5 @@ const mp_obj_type_t ipaddress_ipv4address_type = { .print = ipaddress_ipv4address_print, .unary_op = ipaddress_ipv4address_unary_op, .binary_op = ipaddress_ipv4address_binary_op, - .locals_dict = (mp_obj_dict_t*)&ipaddress_ipv4address_locals_dict + .locals_dict = (mp_obj_dict_t *)&ipaddress_ipv4address_locals_dict }; diff --git a/shared-bindings/ipaddress/IPv4Address.h b/shared-bindings/ipaddress/IPv4Address.h index b45cf3bac..46a52a0b2 100644 --- a/shared-bindings/ipaddress/IPv4Address.h +++ b/shared-bindings/ipaddress/IPv4Address.h @@ -32,7 +32,7 @@ extern const mp_obj_type_t ipaddress_ipv4address_type; mp_obj_t common_hal_ipaddress_new_ipv4address(uint32_t value); -void common_hal_ipaddress_ipv4address_construct(ipaddress_ipv4address_obj_t* self, uint8_t* buf, size_t len); -mp_obj_t common_hal_ipaddress_ipv4address_get_packed(ipaddress_ipv4address_obj_t* self); +void common_hal_ipaddress_ipv4address_construct(ipaddress_ipv4address_obj_t *self, uint8_t *buf, size_t len); +mp_obj_t common_hal_ipaddress_ipv4address_get_packed(ipaddress_ipv4address_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_IPADDRESS_IPV4ADDRESS_H diff --git a/shared-bindings/ipaddress/__init__.c b/shared-bindings/ipaddress/__init__.c index 7ec2984ef..f768ec0ba 100644 --- a/shared-bindings/ipaddress/__init__.c +++ b/shared-bindings/ipaddress/__init__.c @@ -38,7 +38,7 @@ //| -bool ipaddress_parse_ipv4address(const char* str_data, size_t str_len, uint32_t* ip_out) { +bool ipaddress_parse_ipv4address(const char *str_data, size_t str_len, uint32_t *ip_out) { size_t period_count = 0; size_t period_index[4] = {0, 0, 0, str_len}; for (size_t i = 0; i < str_len; i++) { @@ -62,7 +62,7 @@ bool ipaddress_parse_ipv4address(const char* str_data, size_t str_len, uint32_t* nlr_buf_t nlr; mp_obj_t octet; if (nlr_push(&nlr) == 0) { - octet = mp_parse_num_integer((const char*) str_data + last_period, period_index[i] - last_period, 10, NULL); + octet = mp_parse_num_integer((const char *)str_data + last_period, period_index[i] - last_period, 10, NULL); nlr_pop(); } else { return false; @@ -83,11 +83,11 @@ bool ipaddress_parse_ipv4address(const char* str_data, size_t str_len, uint32_t* STATIC mp_obj_t ipaddress_ip_address(mp_obj_t ip_in) { uint32_t value; - if (mp_obj_get_int_maybe(ip_in, (mp_int_t*) &value)) { + if (mp_obj_get_int_maybe(ip_in, (mp_int_t *)&value)) { // We're done. } else if (MP_OBJ_IS_STR(ip_in)) { GET_STR_DATA_LEN(ip_in, str_data, str_len); - if (!ipaddress_parse_ipv4address((const char*) str_data, str_len, &value)) { + if (!ipaddress_parse_ipv4address((const char *)str_data, str_len, &value)) { mp_raise_ValueError(translate("Not a valid IP string")); } } else { @@ -109,5 +109,5 @@ STATIC MP_DEFINE_CONST_DICT(ipaddress_module_globals, ipaddress_module_globals_t const mp_obj_module_t ipaddress_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&ipaddress_module_globals, + .globals = (mp_obj_dict_t *)&ipaddress_module_globals, }; diff --git a/shared-bindings/ipaddress/__init__.h b/shared-bindings/ipaddress/__init__.h index a1c31775f..7c2e5c181 100644 --- a/shared-bindings/ipaddress/__init__.h +++ b/shared-bindings/ipaddress/__init__.h @@ -29,7 +29,7 @@ #include "shared-module/ipaddress/__init__.h" -bool ipaddress_parse_ipv4address(const char* ip_str, size_t len, uint32_t* ip_out); +bool ipaddress_parse_ipv4address(const char *ip_str, size_t len, uint32_t *ip_out); mp_obj_t common_hal_ipaddress_new_ipv4address(uint32_t value); diff --git a/shared-bindings/math/__init__.c b/shared-bindings/math/__init__.c index 3883c03c1..f5a8ca9cb 100644 --- a/shared-bindings/math/__init__.c +++ b/shared-bindings/math/__init__.c @@ -49,30 +49,30 @@ STATIC NORETURN void math_error(void) { } #define MATH_FUN_1(py_name, c_name) \ - STATIC mp_obj_t mp_math_ ## py_name(mp_obj_t x_obj) { return mp_obj_new_float(MICROPY_FLOAT_C_FUN(c_name)(mp_obj_get_float(x_obj))); } \ - STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_## py_name ## _obj, mp_math_ ## py_name); + STATIC mp_obj_t mp_math_##py_name(mp_obj_t x_obj) { return mp_obj_new_float(MICROPY_FLOAT_C_FUN(c_name)(mp_obj_get_float(x_obj))); } \ + STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_##py_name##_obj, mp_math_##py_name); #define MATH_FUN_2(py_name, c_name) \ - STATIC mp_obj_t mp_math_ ## py_name(mp_obj_t x_obj, mp_obj_t y_obj) { return mp_obj_new_float(MICROPY_FLOAT_C_FUN(c_name)(mp_obj_get_float(x_obj), mp_obj_get_float(y_obj))); } \ - STATIC MP_DEFINE_CONST_FUN_OBJ_2(mp_math_## py_name ## _obj, mp_math_ ## py_name); + STATIC mp_obj_t mp_math_##py_name(mp_obj_t x_obj, mp_obj_t y_obj) { return mp_obj_new_float(MICROPY_FLOAT_C_FUN(c_name)(mp_obj_get_float(x_obj), mp_obj_get_float(y_obj))); } \ + STATIC MP_DEFINE_CONST_FUN_OBJ_2(mp_math_##py_name##_obj, mp_math_##py_name); #define MATH_FUN_1_TO_BOOL(py_name, c_name) \ - STATIC mp_obj_t mp_math_ ## py_name(mp_obj_t x_obj) { return mp_obj_new_bool(c_name(mp_obj_get_float(x_obj))); } \ - STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_## py_name ## _obj, mp_math_ ## py_name); + STATIC mp_obj_t mp_math_##py_name(mp_obj_t x_obj) { return mp_obj_new_bool(c_name(mp_obj_get_float(x_obj))); } \ + STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_##py_name##_obj, mp_math_##py_name); #define MATH_FUN_1_TO_INT(py_name, c_name) \ - STATIC mp_obj_t mp_math_ ## py_name(mp_obj_t x_obj) { return mp_obj_new_int_from_float(MICROPY_FLOAT_C_FUN(c_name)(mp_obj_get_float(x_obj))); } \ - STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_## py_name ## _obj, mp_math_ ## py_name); + STATIC mp_obj_t mp_math_##py_name(mp_obj_t x_obj) { return mp_obj_new_int_from_float(MICROPY_FLOAT_C_FUN(c_name)(mp_obj_get_float(x_obj))); } \ + STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_##py_name##_obj, mp_math_##py_name); #define MATH_FUN_1_ERRCOND(py_name, c_name, error_condition) \ - STATIC mp_obj_t mp_math_ ## py_name(mp_obj_t x_obj) { \ + STATIC mp_obj_t mp_math_##py_name(mp_obj_t x_obj) { \ mp_float_t x = mp_obj_get_float(x_obj); \ if (error_condition) { \ math_error(); \ } \ return mp_obj_new_float(MICROPY_FLOAT_C_FUN(c_name)(x)); \ } \ - STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_## py_name ## _obj, mp_math_ ## py_name); + STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_##py_name##_obj, mp_math_##py_name); #ifdef MP_NEED_LOG2 // 1.442695040888963407354163704 is 1/_M_LN2 @@ -184,7 +184,7 @@ STATIC NORETURN void math_error(void) { //| """Return an integer, being ``x`` rounded towards 0.""" //| ... //| - MATH_FUN_1_ERRCOND(sqrt, sqrt, (x < (mp_float_t)0.0)) +MATH_FUN_1_ERRCOND(sqrt, sqrt, (x < (mp_float_t)0.0)) MATH_FUN_2(pow, pow) @@ -265,7 +265,7 @@ MATH_FUN_2(copysign, copysign) MATH_FUN_1(fabs, fabs) -MATH_FUN_1_TO_INT(floor, floor) //TODO: delegate to x.__floor__() if x is not a float +MATH_FUN_1_TO_INT(floor, floor) // TODO: delegate to x.__floor__() if x is not a float MATH_FUN_2(fmod, fmod) @@ -304,7 +304,7 @@ MATH_FUN_1(gamma, tgamma) //| MATH_FUN_1(lgamma, lgamma) #endif -//TODO: factorial, fsum +// TODO: factorial, fsum // Function that takes a variable number of arguments @@ -322,10 +322,10 @@ STATIC mp_obj_t mp_math_log(size_t n_args, const mp_obj_t *args) { if (base <= (mp_float_t)0.0) { math_error(); // Turn off warning when comparing exactly with integral value 1.0 -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wfloat-equal" + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wfloat-equal" } else if (base == (mp_float_t)1.0) { -#pragma GCC diagnostic pop + #pragma GCC diagnostic pop mp_raise_msg(&mp_type_ZeroDivisionError, translate("division by zero")); } return mp_obj_new_float(l / MICROPY_FLOAT_C_FUN(log)(base)); @@ -424,7 +424,7 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_math_globals, mp_module_math_globals_table const mp_obj_module_t math_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_math_globals, + .globals = (mp_obj_dict_t *)&mp_module_math_globals, }; #endif // MICROPY_PY_BUILTINS_FLOAT && MICROPY_PY_MATH diff --git a/shared-bindings/memorymonitor/AllocationAlarm.c b/shared-bindings/memorymonitor/AllocationAlarm.c index 7de8c1287..f7684b51a 100644 --- a/shared-bindings/memorymonitor/AllocationAlarm.c +++ b/shared-bindings/memorymonitor/AllocationAlarm.c @@ -133,5 +133,5 @@ const mp_obj_type_t memorymonitor_allocationalarm_type = { { &mp_type_type }, .name = MP_QSTR_AllocationAlarm, .make_new = memorymonitor_allocationalarm_make_new, - .locals_dict = (mp_obj_dict_t*)&memorymonitor_allocationalarm_locals_dict, + .locals_dict = (mp_obj_dict_t *)&memorymonitor_allocationalarm_locals_dict, }; diff --git a/shared-bindings/memorymonitor/AllocationAlarm.h b/shared-bindings/memorymonitor/AllocationAlarm.h index 304b9c5a7..0a6297182 100644 --- a/shared-bindings/memorymonitor/AllocationAlarm.h +++ b/shared-bindings/memorymonitor/AllocationAlarm.h @@ -31,9 +31,9 @@ extern const mp_obj_type_t memorymonitor_allocationalarm_type; -void common_hal_memorymonitor_allocationalarm_construct(memorymonitor_allocationalarm_obj_t* self, size_t minimum_block_count); -void common_hal_memorymonitor_allocationalarm_pause(memorymonitor_allocationalarm_obj_t* self); -void common_hal_memorymonitor_allocationalarm_resume(memorymonitor_allocationalarm_obj_t* self); -void common_hal_memorymonitor_allocationalarm_set_ignore(memorymonitor_allocationalarm_obj_t* self, mp_int_t count); +void common_hal_memorymonitor_allocationalarm_construct(memorymonitor_allocationalarm_obj_t *self, size_t minimum_block_count); +void common_hal_memorymonitor_allocationalarm_pause(memorymonitor_allocationalarm_obj_t *self); +void common_hal_memorymonitor_allocationalarm_resume(memorymonitor_allocationalarm_obj_t *self); +void common_hal_memorymonitor_allocationalarm_set_ignore(memorymonitor_allocationalarm_obj_t *self, mp_int_t count); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_MEMORYMONITOR_ALLOCATIONALARM_H diff --git a/shared-bindings/memorymonitor/AllocationSize.c b/shared-bindings/memorymonitor/AllocationSize.c index b35bae360..ea6a1db3c 100644 --- a/shared-bindings/memorymonitor/AllocationSize.c +++ b/shared-bindings/memorymonitor/AllocationSize.c @@ -125,9 +125,12 @@ STATIC mp_obj_t memorymonitor_allocationsize_unary_op(mp_unary_op_t op, mp_obj_t memorymonitor_allocationsize_obj_t *self = MP_OBJ_TO_PTR(self_in); uint16_t len = common_hal_memorymonitor_allocationsize_get_len(self); switch (op) { - case MP_UNARY_OP_BOOL: return mp_obj_new_bool(len != 0); - case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(len); - default: return MP_OBJ_NULL; // op not supported + case MP_UNARY_OP_BOOL: + return mp_obj_new_bool(len != 0); + case MP_UNARY_OP_LEN: + return MP_OBJ_NEW_SMALL_INT(len); + default: + return MP_OBJ_NULL; // op not supported } } @@ -179,5 +182,5 @@ const mp_obj_type_t memorymonitor_allocationsize_type = { .subscr = memorymonitor_allocationsize_subscr, .unary_op = memorymonitor_allocationsize_unary_op, .getiter = mp_obj_new_generic_iterator, - .locals_dict = (mp_obj_dict_t*)&memorymonitor_allocationsize_locals_dict, + .locals_dict = (mp_obj_dict_t *)&memorymonitor_allocationsize_locals_dict, }; diff --git a/shared-bindings/memorymonitor/AllocationSize.h b/shared-bindings/memorymonitor/AllocationSize.h index bcd9514bf..c677c1a5b 100644 --- a/shared-bindings/memorymonitor/AllocationSize.h +++ b/shared-bindings/memorymonitor/AllocationSize.h @@ -31,12 +31,12 @@ extern const mp_obj_type_t memorymonitor_allocationsize_type; -extern void common_hal_memorymonitor_allocationsize_construct(memorymonitor_allocationsize_obj_t* self); -extern void common_hal_memorymonitor_allocationsize_pause(memorymonitor_allocationsize_obj_t* self); -extern void common_hal_memorymonitor_allocationsize_resume(memorymonitor_allocationsize_obj_t* self); -extern void common_hal_memorymonitor_allocationsize_clear(memorymonitor_allocationsize_obj_t* self); -extern size_t common_hal_memorymonitor_allocationsize_get_bytes_per_block(memorymonitor_allocationsize_obj_t* self); -extern uint16_t common_hal_memorymonitor_allocationsize_get_len(memorymonitor_allocationsize_obj_t* self); -extern uint16_t common_hal_memorymonitor_allocationsize_get_item(memorymonitor_allocationsize_obj_t* self, int16_t index); +extern void common_hal_memorymonitor_allocationsize_construct(memorymonitor_allocationsize_obj_t *self); +extern void common_hal_memorymonitor_allocationsize_pause(memorymonitor_allocationsize_obj_t *self); +extern void common_hal_memorymonitor_allocationsize_resume(memorymonitor_allocationsize_obj_t *self); +extern void common_hal_memorymonitor_allocationsize_clear(memorymonitor_allocationsize_obj_t *self); +extern size_t common_hal_memorymonitor_allocationsize_get_bytes_per_block(memorymonitor_allocationsize_obj_t *self); +extern uint16_t common_hal_memorymonitor_allocationsize_get_len(memorymonitor_allocationsize_obj_t *self); +extern uint16_t common_hal_memorymonitor_allocationsize_get_item(memorymonitor_allocationsize_obj_t *self, int16_t index); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_MEMORYMONITOR_ALLOCATIONSIZE_H diff --git a/shared-bindings/memorymonitor/__init__.c b/shared-bindings/memorymonitor/__init__.c index c101ba5e0..f6546c25d 100644 --- a/shared-bindings/memorymonitor/__init__.c +++ b/shared-bindings/memorymonitor/__init__.c @@ -41,7 +41,7 @@ //| ... MP_DEFINE_MEMORYMONITOR_EXCEPTION(AllocationError, Exception) -NORETURN void mp_raise_memorymonitor_AllocationError(const compressed_string_t* fmt, ...) { +NORETURN void mp_raise_memorymonitor_AllocationError(const compressed_string_t *fmt, ...) { va_list argptr; va_start(argptr,fmt); mp_obj_t exception = mp_obj_new_exception_msg_vlist(&mp_type_memorymonitor_AllocationError, fmt, argptr); @@ -72,5 +72,5 @@ void memorymonitor_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_pr const mp_obj_module_t memorymonitor_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&memorymonitor_module_globals, + .globals = (mp_obj_dict_t *)&memorymonitor_module_globals, }; diff --git a/shared-bindings/memorymonitor/__init__.h b/shared-bindings/memorymonitor/__init__.h index 60fcdc3f6..5d9dfddbe 100644 --- a/shared-bindings/memorymonitor/__init__.h +++ b/shared-bindings/memorymonitor/__init__.h @@ -33,17 +33,17 @@ void memorymonitor_exception_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind); #define MP_DEFINE_MEMORYMONITOR_EXCEPTION(exc_name, base_name) \ -const mp_obj_type_t mp_type_memorymonitor_ ## exc_name = { \ - { &mp_type_type }, \ - .name = MP_QSTR_ ## exc_name, \ - .print = memorymonitor_exception_print, \ - .make_new = mp_obj_exception_make_new, \ - .attr = mp_obj_exception_attr, \ - .parent = &mp_type_ ## base_name, \ -}; + const mp_obj_type_t mp_type_memorymonitor_##exc_name = { \ + { &mp_type_type }, \ + .name = MP_QSTR_##exc_name, \ + .print = memorymonitor_exception_print, \ + .make_new = mp_obj_exception_make_new, \ + .attr = mp_obj_exception_attr, \ + .parent = &mp_type_##base_name, \ + }; extern const mp_obj_type_t mp_type_memorymonitor_AllocationError; -NORETURN void mp_raise_memorymonitor_AllocationError(const compressed_string_t* msg, ...); +NORETURN void mp_raise_memorymonitor_AllocationError(const compressed_string_t *msg, ...); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_MEMORYMONITOR___INIT___H diff --git a/shared-bindings/microcontroller/Pin.c b/shared-bindings/microcontroller/Pin.c index 2a97b54b3..289d89017 100644 --- a/shared-bindings/microcontroller/Pin.c +++ b/shared-bindings/microcontroller/Pin.c @@ -43,8 +43,8 @@ //| ... //| -static void get_pin_name(const mcu_pin_obj_t *self, qstr* package, qstr* module, qstr* name) { - const mp_map_t* board_map = &board_module_globals.map; +static void get_pin_name(const mcu_pin_obj_t *self, qstr *package, qstr *module, qstr *name) { + const mp_map_t *board_map = &board_module_globals.map; for (uint8_t i = 0; i < board_map->alloc; i++) { if (board_map->table[i].value == self) { *package = 0; @@ -53,7 +53,7 @@ static void get_pin_name(const mcu_pin_obj_t *self, qstr* package, qstr* module, return; } } - const mp_map_t* mcu_map = &mcu_pin_globals.map; + const mp_map_t *mcu_map = &mcu_pin_globals.map; for (uint8_t i = 0; i < mcu_map->alloc; i++) { if (mcu_map->table[i].value == self) { *package = MP_QSTR_microcontroller; @@ -74,7 +74,7 @@ STATIC void mcu_pin_print(const mp_print_t *print, mp_obj_t self_in, mp_print_ki if (package) { mp_printf(print, "%q.%q.%q", package, module, name); } else { - mp_printf(print, "%q.%q", module , name); + mp_printf(print, "%q.%q", module, name); } } @@ -112,7 +112,7 @@ void validate_list_is_free_pins(qstr what, mcu_pin_obj_t **pins_out, mp_int_t ma mp_raise_ValueError_varg(translate("At most %d %q may be specified (not %d)"), max_pins, what, len); } *count_out = len; - for (mp_int_t i=0; i<len; i++) { + for (mp_int_t i = 0; i < len; i++) { pins_out[i] = validate_obj_is_free_pin(mp_obj_subscr(seq, MP_OBJ_NEW_SMALL_INT(i), MP_OBJ_SENTINEL)); } } @@ -127,7 +127,7 @@ mcu_pin_obj_t *validate_obj_is_free_pin_or_none(mp_obj_t obj) { return pin; } -void assert_pin_free(const mcu_pin_obj_t* pin) { +void assert_pin_free(const mcu_pin_obj_t *pin) { if (pin != NULL && pin != MP_OBJ_TO_PTR(mp_const_none) && !common_hal_mcu_pin_is_free(pin)) { qstr package; qstr module; diff --git a/shared-bindings/microcontroller/Pin.h b/shared-bindings/microcontroller/Pin.h index f6659db7d..60c5400bd 100644 --- a/shared-bindings/microcontroller/Pin.h +++ b/shared-bindings/microcontroller/Pin.h @@ -39,13 +39,13 @@ mcu_pin_obj_t *validate_obj_is_free_pin(mp_obj_t obj); mcu_pin_obj_t *validate_obj_is_free_pin_or_none(mp_obj_t obj); void validate_list_is_free_pins(qstr what, mcu_pin_obj_t **pins_out, mp_int_t max_pins, mp_obj_t seq, uint8_t *count_out); -void assert_pin_free(const mcu_pin_obj_t* pin); +void assert_pin_free(const mcu_pin_obj_t *pin); -bool common_hal_mcu_pin_is_free(const mcu_pin_obj_t* pin); -void common_hal_never_reset_pin(const mcu_pin_obj_t* pin); -void common_hal_reset_pin(const mcu_pin_obj_t* pin); -uint8_t common_hal_mcu_pin_number(const mcu_pin_obj_t* pin); -void common_hal_mcu_pin_claim(const mcu_pin_obj_t* pin); +bool common_hal_mcu_pin_is_free(const mcu_pin_obj_t *pin); +void common_hal_never_reset_pin(const mcu_pin_obj_t *pin); +void common_hal_reset_pin(const mcu_pin_obj_t *pin); +uint8_t common_hal_mcu_pin_number(const mcu_pin_obj_t *pin); +void common_hal_mcu_pin_claim(const mcu_pin_obj_t *pin); void common_hal_mcu_pin_claim_number(uint8_t pin_no); void common_hal_mcu_pin_reset_number(uint8_t pin_no); diff --git a/shared-bindings/microcontroller/Processor.c b/shared-bindings/microcontroller/Processor.c index 67001c831..58e8384ce 100644 --- a/shared-bindings/microcontroller/Processor.c +++ b/shared-bindings/microcontroller/Processor.c @@ -126,8 +126,8 @@ MP_DEFINE_CONST_FUN_OBJ_1(mcu_processor_get_uid_obj, mcu_processor_get_uid); const mp_obj_property_t mcu_processor_uid_obj = { .base.type = &mp_type_property, .proxy = {(mp_obj_t)&mcu_processor_get_uid_obj, // getter - (mp_obj_t)&mp_const_none_obj, // no setter - (mp_obj_t)&mp_const_none_obj, // no deleter + (mp_obj_t)&mp_const_none_obj, // no setter + (mp_obj_t)&mp_const_none_obj, // no deleter }, }; diff --git a/shared-bindings/microcontroller/RunMode.c b/shared-bindings/microcontroller/RunMode.c index a54f40cac..789bb77c3 100644 --- a/shared-bindings/microcontroller/RunMode.c +++ b/shared-bindings/microcontroller/RunMode.c @@ -79,7 +79,7 @@ STATIC void mcu_runmode_print(const mp_print_t *print, mp_obj_t self_in, mp_prin runmode = MP_QSTR_BOOTLOADER; } mp_printf(print, "%q.%q.%q", MP_QSTR_microcontroller, MP_QSTR_RunMode, - runmode); + runmode); } const mp_obj_type_t mcu_runmode_type = { diff --git a/shared-bindings/microcontroller/__init__.c b/shared-bindings/microcontroller/__init__.c index dba66fa4f..fcd19c10b 100644 --- a/shared-bindings/microcontroller/__init__.c +++ b/shared-bindings/microcontroller/__init__.c @@ -155,15 +155,15 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(mcu_reset_obj, mcu_reset); const mp_obj_module_t mcu_pin_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mcu_pin_globals, + .globals = (mp_obj_dict_t *)&mcu_pin_globals, }; STATIC const mp_rom_map_elem_t mcu_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_microcontroller) }, { MP_ROM_QSTR(MP_QSTR_cpu), MP_ROM_PTR(&common_hal_mcu_processor_obj) }, -#if CIRCUITPY_PROCESSOR_COUNT > 1 + #if CIRCUITPY_PROCESSOR_COUNT > 1 { MP_ROM_QSTR(MP_QSTR_cpus), MP_ROM_PTR(&common_hal_multi_processor_obj) }, -#endif + #endif { MP_ROM_QSTR(MP_QSTR_delay_us), MP_ROM_PTR(&mcu_delay_us_obj) }, { MP_ROM_QSTR(MP_QSTR_disable_interrupts), MP_ROM_PTR(&mcu_disable_interrupts_obj) }, { MP_ROM_QSTR(MP_QSTR_enable_interrupts), MP_ROM_PTR(&mcu_enable_interrupts_obj) }, @@ -191,5 +191,5 @@ STATIC MP_DEFINE_CONST_DICT(mcu_module_globals, mcu_module_globals_table); const mp_obj_module_t microcontroller_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mcu_module_globals, + .globals = (mp_obj_dict_t *)&mcu_module_globals, }; diff --git a/shared-bindings/msgpack/ExtType.c b/shared-bindings/msgpack/ExtType.c index e9ddd32bc..44731c016 100644 --- a/shared-bindings/msgpack/ExtType.c +++ b/shared-bindings/msgpack/ExtType.c @@ -122,5 +122,5 @@ const mp_obj_type_t mod_msgpack_exttype_type = { { &mp_type_type }, .name = MP_QSTR_ExtType, .make_new = mod_msgpack_exttype_make_new, - .locals_dict = (mp_obj_dict_t*)&mod_msgpack_exttype_locals_dict, + .locals_dict = (mp_obj_dict_t *)&mod_msgpack_exttype_locals_dict, }; diff --git a/shared-bindings/msgpack/__init__.c b/shared-bindings/msgpack/__init__.c index f5c47bb21..0bd1d86e2 100644 --- a/shared-bindings/msgpack/__init__.c +++ b/shared-bindings/msgpack/__init__.c @@ -31,7 +31,7 @@ #include "shared-module/msgpack/__init__.h" #include "shared-bindings/msgpack/ExtType.h" -#define MP_OBJ_IS_METH(o) (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t*)MP_OBJ_TO_PTR(o))->type->name == MP_QSTR_bound_method)) +#define MP_OBJ_IS_METH(o) (MP_OBJ_IS_OBJ(o) && (((mp_obj_base_t *)MP_OBJ_TO_PTR(o))->type->name == MP_QSTR_bound_method)) //| """Pack object in msgpack format //| @@ -158,5 +158,5 @@ STATIC MP_DEFINE_CONST_DICT(msgpack_module_globals, msgpack_module_globals_table const mp_obj_module_t msgpack_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&msgpack_module_globals, + .globals = (mp_obj_dict_t *)&msgpack_module_globals, }; diff --git a/shared-bindings/multiterminal/__init__.c b/shared-bindings/multiterminal/__init__.c index 689d3d761..f3f8d1ab6 100644 --- a/shared-bindings/multiterminal/__init__.c +++ b/shared-bindings/multiterminal/__init__.c @@ -106,5 +106,5 @@ STATIC MP_DEFINE_CONST_DICT(multiterminal_module_globals, multiterminal_module_g const mp_obj_module_t multiterminal_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&multiterminal_module_globals, + .globals = (mp_obj_dict_t *)&multiterminal_module_globals, }; diff --git a/shared-bindings/neopixel_write/__init__.c b/shared-bindings/neopixel_write/__init__.c index a353e34ae..da4f28a13 100644 --- a/shared-bindings/neopixel_write/__init__.c +++ b/shared-bindings/neopixel_write/__init__.c @@ -65,7 +65,7 @@ STATIC mp_obj_t neopixel_write_neopixel_write_(mp_obj_t digitalinout_obj, mp_obj mp_buffer_info_t bufinfo; mp_get_buffer_raise(buf, &bufinfo, MP_BUFFER_READ); // Call platform's neopixel write function with provided buffer and options. - common_hal_neopixel_write(digitalinout, (uint8_t*)bufinfo.buf, bufinfo.len); + common_hal_neopixel_write(digitalinout, (uint8_t *)bufinfo.buf, bufinfo.len); return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_2(neopixel_write_neopixel_write_obj, neopixel_write_neopixel_write_); @@ -79,5 +79,5 @@ STATIC MP_DEFINE_CONST_DICT(neopixel_write_module_globals, neopixel_write_module const mp_obj_module_t neopixel_write_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&neopixel_write_module_globals, + .globals = (mp_obj_dict_t *)&neopixel_write_module_globals, }; diff --git a/shared-bindings/neopixel_write/__init__.h b/shared-bindings/neopixel_write/__init__.h index 9799e3413..89b087ddf 100644 --- a/shared-bindings/neopixel_write/__init__.h +++ b/shared-bindings/neopixel_write/__init__.h @@ -32,6 +32,6 @@ #include "common-hal/digitalio/DigitalInOut.h" -extern void common_hal_neopixel_write(const digitalio_digitalinout_obj_t* gpio, uint8_t *pixels, uint32_t numBytes); +extern void common_hal_neopixel_write(const digitalio_digitalinout_obj_t *gpio, uint8_t *pixels, uint32_t numBytes); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_NEOPIXEL_WRITE_H diff --git a/shared-bindings/network/__init__.c b/shared-bindings/network/__init__.c index cfcadd98f..2c7faf182 100644 --- a/shared-bindings/network/__init__.c +++ b/shared-bindings/network/__init__.c @@ -66,7 +66,7 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_network_globals, mp_module_network_globals const mp_obj_module_t network_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_network_globals, + .globals = (mp_obj_dict_t *)&mp_module_network_globals, }; #endif // CIRCUITPY_NETWORK diff --git a/shared-bindings/nvm/ByteArray.c b/shared-bindings/nvm/ByteArray.c index 1c8a45b20..0a2ef3389 100644 --- a/shared-bindings/nvm/ByteArray.c +++ b/shared-bindings/nvm/ByteArray.c @@ -61,9 +61,12 @@ STATIC mp_obj_t nvm_bytearray_unary_op(mp_unary_op_t op, mp_obj_t self_in) { nvm_bytearray_obj_t *self = MP_OBJ_TO_PTR(self_in); uint16_t len = common_hal_nvm_bytearray_get_length(self); switch (op) { - case MP_UNARY_OP_BOOL: return mp_obj_new_bool(len != 0); - case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(len); - default: return MP_OBJ_NULL; // op not supported + case MP_UNARY_OP_BOOL: + return mp_obj_new_bool(len != 0); + case MP_UNARY_OP_LEN: + return MP_OBJ_NEW_SMALL_INT(len); + default: + return MP_OBJ_NULL; // op not supported } } @@ -94,7 +97,7 @@ STATIC mp_obj_t nvm_bytearray_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj } else { nvm_bytearray_obj_t *self = MP_OBJ_TO_PTR(self_in); if (0) { -#if MICROPY_PY_BUILTINS_SLICE + #if MICROPY_PY_BUILTINS_SLICE } else if (MP_OBJ_IS_TYPE(index_in, &mp_type_slice)) { mp_bound_slice_t slice; if (!mp_seq_get_fast_slice_indexes(common_hal_nvm_bytearray_get_length(self), index_in, &slice)) { @@ -104,11 +107,11 @@ STATIC mp_obj_t nvm_bytearray_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj #if MICROPY_PY_ARRAY_SLICE_ASSIGN // Assign size_t src_len = slice.stop - slice.start; - uint8_t* src_items; + uint8_t *src_items; if (MP_OBJ_IS_TYPE(value, &mp_type_array) || - MP_OBJ_IS_TYPE(value, &mp_type_bytearray) || - MP_OBJ_IS_TYPE(value, &mp_type_memoryview) || - MP_OBJ_IS_TYPE(value, &mp_type_bytes)) { + MP_OBJ_IS_TYPE(value, &mp_type_bytearray) || + MP_OBJ_IS_TYPE(value, &mp_type_memoryview) || + MP_OBJ_IS_TYPE(value, &mp_type_bytes)) { mp_buffer_info_t bufinfo; mp_get_buffer_raise(value, &bufinfo, MP_BUFFER_READ); if (bufinfo.len != src_len) { @@ -137,11 +140,11 @@ STATIC mp_obj_t nvm_bytearray_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj common_hal_nvm_bytearray_get_bytes(self, slice.start, len, items); return mp_obj_new_bytearray_by_ref(len, items); } -#endif + #endif } else { // Single index rather than slice. size_t index = mp_get_index(self->base.type, common_hal_nvm_bytearray_get_length(self), - index_in, false); + index_in, false); if (value == MP_OBJ_SENTINEL) { // load uint8_t value_out; diff --git a/shared-bindings/nvm/ByteArray.h b/shared-bindings/nvm/ByteArray.h index 9375bcb85..9b74a4a3f 100644 --- a/shared-bindings/nvm/ByteArray.h +++ b/shared-bindings/nvm/ByteArray.h @@ -34,10 +34,10 @@ extern const mp_obj_type_t nvm_bytearray_type; uint32_t common_hal_nvm_bytearray_get_length(nvm_bytearray_obj_t *self); bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self, - uint32_t start_index, uint8_t* values, uint32_t len); + uint32_t start_index, uint8_t *values, uint32_t len); // len and values are intentionally swapped to signify values is an output and // also leverage the compiler to validate uses are expected. void common_hal_nvm_bytearray_get_bytes(nvm_bytearray_obj_t *self, - uint32_t start_index, uint32_t len, uint8_t* values); + uint32_t start_index, uint32_t len, uint8_t *values); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_NVM_BYTEARRAY_H diff --git a/shared-bindings/nvm/__init__.c b/shared-bindings/nvm/__init__.c index e9784bd18..dffc4cda8 100644 --- a/shared-bindings/nvm/__init__.c +++ b/shared-bindings/nvm/__init__.c @@ -49,5 +49,5 @@ STATIC MP_DEFINE_CONST_DICT(nvm_module_globals, nvm_module_globals_table); const mp_obj_module_t nvm_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&nvm_module_globals, + .globals = (mp_obj_dict_t *)&nvm_module_globals, }; diff --git a/shared-bindings/os/__init__.c b/shared-bindings/os/__init__.c index 8b9b38911..798f3c361 100644 --- a/shared-bindings/os/__init__.c +++ b/shared-bindings/os/__init__.c @@ -89,7 +89,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(os_getcwd_obj, os_getcwd); //| ... //| mp_obj_t os_listdir(size_t n_args, const mp_obj_t *args) { - const char* path; + const char *path; if (n_args == 1) { path = mp_obj_str_get_str(args[0]); } else { @@ -207,7 +207,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(os_sync_obj, os_sync); STATIC mp_obj_t os_urandom(mp_obj_t size_in) { mp_int_t size = mp_obj_get_int(size_in); mp_obj_str_t *result = MP_OBJ_TO_PTR(mp_obj_new_bytes_of_zeros(size)); - if (!common_hal_os_urandom((uint8_t*) result->data, size)) { + if (!common_hal_os_urandom((uint8_t *)result->data, size)) { mp_raise_NotImplementedError(translate("No hardware random available")); } return result; @@ -245,5 +245,5 @@ STATIC MP_DEFINE_CONST_DICT(os_module_globals, os_module_globals_table); const mp_obj_module_t os_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&os_module_globals, + .globals = (mp_obj_dict_t *)&os_module_globals, }; diff --git a/shared-bindings/os/__init__.h b/shared-bindings/os/__init__.h index 8394890de..f6f0a25c9 100644 --- a/shared-bindings/os/__init__.h +++ b/shared-bindings/os/__init__.h @@ -35,17 +35,17 @@ extern const mp_rom_obj_tuple_t common_hal_os_uname_info_obj; mp_obj_t common_hal_os_uname(void); -void common_hal_os_chdir(const char* path); +void common_hal_os_chdir(const char *path); mp_obj_t common_hal_os_getcwd(void); -mp_obj_t common_hal_os_listdir(const char* path); -void common_hal_os_mkdir(const char* path); -void common_hal_os_remove(const char* path); -void common_hal_os_rename(const char* old_path, const char* new_path); -void common_hal_os_rmdir(const char* path); -mp_obj_t common_hal_os_stat(const char* path); -mp_obj_t common_hal_os_statvfs(const char* path); +mp_obj_t common_hal_os_listdir(const char *path); +void common_hal_os_mkdir(const char *path); +void common_hal_os_remove(const char *path); +void common_hal_os_rename(const char *old_path, const char *new_path); +void common_hal_os_rmdir(const char *path); +mp_obj_t common_hal_os_stat(const char *path); +mp_obj_t common_hal_os_statvfs(const char *path); // Returns true if data was correctly sourced from a true random number generator. -bool common_hal_os_urandom(uint8_t* buffer, mp_uint_t length); +bool common_hal_os_urandom(uint8_t *buffer, mp_uint_t length); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_OS___INIT___H diff --git a/shared-bindings/ps2io/Ps2.c b/shared-bindings/ps2io/Ps2.c index 07fa5cebb..dd6ca83fb 100644 --- a/shared-bindings/ps2io/Ps2.c +++ b/shared-bindings/ps2io/Ps2.c @@ -76,8 +76,8 @@ STATIC mp_obj_t ps2io_ps2_make_new(const mp_obj_type_t *type, size_t n_args, con mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - const mcu_pin_obj_t* clkpin = validate_obj_is_free_pin(args[ARG_clkpin].u_obj); - const mcu_pin_obj_t* datapin = validate_obj_is_free_pin(args[ARG_datapin].u_obj); + const mcu_pin_obj_t *clkpin = validate_obj_is_free_pin(args[ARG_clkpin].u_obj); + const mcu_pin_obj_t *datapin = validate_obj_is_free_pin(args[ARG_datapin].u_obj); ps2io_ps2_obj_t *self = m_new_obj(ps2io_ps2_obj_t); self->base.type = &ps2io_ps2_type; @@ -215,9 +215,12 @@ STATIC mp_obj_t ps2_unary_op(mp_unary_op_t op, mp_obj_t self_in) { check_for_deinit(self); uint16_t len = common_hal_ps2io_ps2_get_len(self); switch (op) { - case MP_UNARY_OP_BOOL: return mp_obj_new_bool(len != 0); - case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(len); - default: return MP_OBJ_NULL; // op not supported + case MP_UNARY_OP_BOOL: + return mp_obj_new_bool(len != 0); + case MP_UNARY_OP_LEN: + return MP_OBJ_NEW_SMALL_INT(len); + default: + return MP_OBJ_NULL; // op not supported } } @@ -237,5 +240,5 @@ const mp_obj_type_t ps2io_ps2_type = { .name = MP_QSTR_Ps2, .make_new = ps2io_ps2_make_new, .unary_op = ps2_unary_op, - .locals_dict = (mp_obj_dict_t*)&ps2io_ps2_locals_dict, + .locals_dict = (mp_obj_dict_t *)&ps2io_ps2_locals_dict, }; diff --git a/shared-bindings/ps2io/Ps2.h b/shared-bindings/ps2io/Ps2.h index 523869d55..da4c6ba2f 100644 --- a/shared-bindings/ps2io/Ps2.h +++ b/shared-bindings/ps2io/Ps2.h @@ -33,13 +33,13 @@ extern const mp_obj_type_t ps2io_ps2_type; -extern void common_hal_ps2io_ps2_construct(ps2io_ps2_obj_t* self, - const mcu_pin_obj_t* data_pin, const mcu_pin_obj_t* clk_pin); -extern void common_hal_ps2io_ps2_deinit(ps2io_ps2_obj_t* self); -extern bool common_hal_ps2io_ps2_deinited(ps2io_ps2_obj_t* self); -extern uint16_t common_hal_ps2io_ps2_get_len(ps2io_ps2_obj_t* self); -extern int16_t common_hal_ps2io_ps2_popleft(ps2io_ps2_obj_t* self); -extern int16_t common_hal_ps2io_ps2_sendcmd(ps2io_ps2_obj_t* self, uint8_t b); -extern uint16_t common_hal_ps2io_ps2_clear_errors(ps2io_ps2_obj_t* self); +extern void common_hal_ps2io_ps2_construct(ps2io_ps2_obj_t *self, + const mcu_pin_obj_t *data_pin, const mcu_pin_obj_t *clk_pin); +extern void common_hal_ps2io_ps2_deinit(ps2io_ps2_obj_t *self); +extern bool common_hal_ps2io_ps2_deinited(ps2io_ps2_obj_t *self); +extern uint16_t common_hal_ps2io_ps2_get_len(ps2io_ps2_obj_t *self); +extern int16_t common_hal_ps2io_ps2_popleft(ps2io_ps2_obj_t *self); +extern int16_t common_hal_ps2io_ps2_sendcmd(ps2io_ps2_obj_t *self, uint8_t b); +extern uint16_t common_hal_ps2io_ps2_clear_errors(ps2io_ps2_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_PS2IO_PS2_H diff --git a/shared-bindings/ps2io/__init__.c b/shared-bindings/ps2io/__init__.c index 38a70b1a2..a71ffd515 100644 --- a/shared-bindings/ps2io/__init__.c +++ b/shared-bindings/ps2io/__init__.c @@ -57,5 +57,5 @@ STATIC MP_DEFINE_CONST_DICT(ps2io_module_globals, ps2io_module_globals_table); const mp_obj_module_t ps2io_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&ps2io_module_globals, + .globals = (mp_obj_dict_t *)&ps2io_module_globals, }; diff --git a/shared-bindings/pulseio/PulseIn.c b/shared-bindings/pulseio/PulseIn.c index 3e44a1479..18a5d3f3e 100644 --- a/shared-bindings/pulseio/PulseIn.c +++ b/shared-bindings/pulseio/PulseIn.c @@ -85,7 +85,7 @@ STATIC mp_obj_t pulseio_pulsein_make_new(const mp_obj_type_t *type, size_t n_arg }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - const mcu_pin_obj_t* pin = validate_obj_is_free_pin(args[ARG_pin].u_obj); + const mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[ARG_pin].u_obj); pulseio_pulsein_obj_t *self = m_new_obj(pulseio_pulsein_obj_t); self->base.type = &pulseio_pulsein_type; @@ -250,9 +250,12 @@ STATIC mp_obj_t pulsein_unary_op(mp_unary_op_t op, mp_obj_t self_in) { check_for_deinit(self); uint16_t len = common_hal_pulseio_pulsein_get_len(self); switch (op) { - case MP_UNARY_OP_BOOL: return mp_obj_new_bool(len != 0); - case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(len); - default: return MP_OBJ_NULL; // op not supported + case MP_UNARY_OP_BOOL: + return mp_obj_new_bool(len != 0); + case MP_UNARY_OP_LEN: + return MP_OBJ_NEW_SMALL_INT(len); + default: + return MP_OBJ_NULL; // op not supported } } @@ -310,5 +313,5 @@ const mp_obj_type_t pulseio_pulsein_type = { .make_new = pulseio_pulsein_make_new, .subscr = pulsein_subscr, .unary_op = pulsein_unary_op, - .locals_dict = (mp_obj_dict_t*)&pulseio_pulsein_locals_dict, + .locals_dict = (mp_obj_dict_t *)&pulseio_pulsein_locals_dict, }; diff --git a/shared-bindings/pulseio/PulseIn.h b/shared-bindings/pulseio/PulseIn.h index e28a3c2df..09d01fded 100644 --- a/shared-bindings/pulseio/PulseIn.h +++ b/shared-bindings/pulseio/PulseIn.h @@ -32,17 +32,17 @@ extern const mp_obj_type_t pulseio_pulsein_type; -extern void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t* self, - const mcu_pin_obj_t* pin, uint16_t maxlen, bool idle_state); -extern void common_hal_pulseio_pulsein_deinit(pulseio_pulsein_obj_t* self); -extern bool common_hal_pulseio_pulsein_deinited(pulseio_pulsein_obj_t* self); -extern void common_hal_pulseio_pulsein_pause(pulseio_pulsein_obj_t* self); -extern void common_hal_pulseio_pulsein_resume(pulseio_pulsein_obj_t* self, uint16_t trigger_duration); -extern void common_hal_pulseio_pulsein_clear(pulseio_pulsein_obj_t* self); -extern uint16_t common_hal_pulseio_pulsein_popleft(pulseio_pulsein_obj_t* self); -extern uint16_t common_hal_pulseio_pulsein_get_maxlen(pulseio_pulsein_obj_t* self); -extern bool common_hal_pulseio_pulsein_get_paused(pulseio_pulsein_obj_t* self); -extern uint16_t common_hal_pulseio_pulsein_get_len(pulseio_pulsein_obj_t* self); -extern uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t* self, int16_t index); +extern void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t *self, + const mcu_pin_obj_t *pin, uint16_t maxlen, bool idle_state); +extern void common_hal_pulseio_pulsein_deinit(pulseio_pulsein_obj_t *self); +extern bool common_hal_pulseio_pulsein_deinited(pulseio_pulsein_obj_t *self); +extern void common_hal_pulseio_pulsein_pause(pulseio_pulsein_obj_t *self); +extern void common_hal_pulseio_pulsein_resume(pulseio_pulsein_obj_t *self, uint16_t trigger_duration); +extern void common_hal_pulseio_pulsein_clear(pulseio_pulsein_obj_t *self); +extern uint16_t common_hal_pulseio_pulsein_popleft(pulseio_pulsein_obj_t *self); +extern uint16_t common_hal_pulseio_pulsein_get_maxlen(pulseio_pulsein_obj_t *self); +extern bool common_hal_pulseio_pulsein_get_paused(pulseio_pulsein_obj_t *self); +extern uint16_t common_hal_pulseio_pulsein_get_len(pulseio_pulsein_obj_t *self); +extern uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t *self, int16_t index); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_PULSEIO_PULSEIN_H diff --git a/shared-bindings/pulseio/PulseOut.c b/shared-bindings/pulseio/PulseOut.c index 2b787df4f..61614889f 100644 --- a/shared-bindings/pulseio/PulseOut.c +++ b/shared-bindings/pulseio/PulseOut.c @@ -80,11 +80,11 @@ STATIC mp_obj_t pulseio_pulseout_make_new(const mp_obj_type_t *type, size_t n_ar static const mp_arg_t allowed_args[] = { { MP_QSTR_pin, MP_ARG_REQUIRED | MP_ARG_OBJ }, { MP_QSTR_frequency, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 38000} }, - { MP_QSTR_duty_cycle, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 1<<15} }, + { MP_QSTR_duty_cycle, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 1 << 15} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - const mcu_pin_obj_t* pin = validate_obj_is_free_pin(args[ARG_pin].u_obj); + const mcu_pin_obj_t *pin = validate_obj_is_free_pin(args[ARG_pin].u_obj); common_hal_pulseio_pulseout_construct(self, NULL, pin, args[ARG_frequency].u_int, args[ARG_frequency].u_int); } return MP_OBJ_FROM_PTR(self); @@ -159,5 +159,5 @@ const mp_obj_type_t pulseio_pulseout_type = { { &mp_type_type }, .name = MP_QSTR_PulseOut, .make_new = pulseio_pulseout_make_new, - .locals_dict = (mp_obj_dict_t*)&pulseio_pulseout_locals_dict, + .locals_dict = (mp_obj_dict_t *)&pulseio_pulseout_locals_dict, }; diff --git a/shared-bindings/pulseio/PulseOut.h b/shared-bindings/pulseio/PulseOut.h index 49dc555fe..dce58a63e 100644 --- a/shared-bindings/pulseio/PulseOut.h +++ b/shared-bindings/pulseio/PulseOut.h @@ -33,15 +33,15 @@ extern const mp_obj_type_t pulseio_pulseout_type; -extern void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self, - const pwmio_pwmout_obj_t* carrier, - const mcu_pin_obj_t* pin, - uint32_t frequency, - uint16_t duty_cycle); +extern void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t *self, + const pwmio_pwmout_obj_t *carrier, + const mcu_pin_obj_t *pin, + uint32_t frequency, + uint16_t duty_cycle); -extern void common_hal_pulseio_pulseout_deinit(pulseio_pulseout_obj_t* self); -extern bool common_hal_pulseio_pulseout_deinited(pulseio_pulseout_obj_t* self); -extern void common_hal_pulseio_pulseout_send(pulseio_pulseout_obj_t* self, - uint16_t* pulses, uint16_t len); +extern void common_hal_pulseio_pulseout_deinit(pulseio_pulseout_obj_t *self); +extern bool common_hal_pulseio_pulseout_deinited(pulseio_pulseout_obj_t *self); +extern void common_hal_pulseio_pulseout_send(pulseio_pulseout_obj_t *self, + uint16_t *pulses, uint16_t len); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_PULSEIO_PULSEOUT_H diff --git a/shared-bindings/pulseio/__init__.c b/shared-bindings/pulseio/__init__.c index bfe9635f0..44a07fafc 100644 --- a/shared-bindings/pulseio/__init__.c +++ b/shared-bindings/pulseio/__init__.c @@ -62,5 +62,5 @@ STATIC MP_DEFINE_CONST_DICT(pulseio_module_globals, pulseio_module_globals_table const mp_obj_module_t pulseio_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&pulseio_module_globals, + .globals = (mp_obj_dict_t *)&pulseio_module_globals, }; diff --git a/shared-bindings/pwmio/PWMOut.c b/shared-bindings/pwmio/PWMOut.c index da0755592..0f3111485 100644 --- a/shared-bindings/pwmio/PWMOut.c +++ b/shared-bindings/pwmio/PWMOut.c @@ -174,8 +174,8 @@ STATIC mp_obj_t pwmio_pwmout_obj_set_duty_cycle(mp_obj_t self_in, mp_obj_t duty_ if (duty < 0 || duty > 0xffff) { mp_raise_ValueError(translate("PWM duty_cycle must be between 0 and 65535 inclusive (16 bit resolution)")); } - common_hal_pwmio_pwmout_set_duty_cycle(self, duty); - return mp_const_none; + common_hal_pwmio_pwmout_set_duty_cycle(self, duty); + return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_2(pwmio_pwmout_set_duty_cycle_obj, pwmio_pwmout_obj_set_duty_cycle); @@ -211,8 +211,8 @@ STATIC mp_obj_t pwmio_pwmout_obj_set_frequency(mp_obj_t self_in, mp_obj_t freque "PWM frequency not writable when variable_frequency is False on " "construction.")); } - common_hal_pwmio_pwmout_set_frequency(self, mp_obj_get_int(frequency)); - return mp_const_none; + common_hal_pwmio_pwmout_set_frequency(self, mp_obj_get_int(frequency)); + return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_2(pwmio_pwmout_set_frequency_obj, pwmio_pwmout_obj_set_frequency); @@ -241,5 +241,5 @@ const mp_obj_type_t pwmio_pwmout_type = { { &mp_type_type }, .name = MP_QSTR_PWMOut, .make_new = pwmio_pwmout_make_new, - .locals_dict = (mp_obj_dict_t*)&pwmio_pwmout_locals_dict, + .locals_dict = (mp_obj_dict_t *)&pwmio_pwmout_locals_dict, }; diff --git a/shared-bindings/pwmio/PWMOut.h b/shared-bindings/pwmio/PWMOut.h index de2ebd1cf..4155ba12d 100644 --- a/shared-bindings/pwmio/PWMOut.h +++ b/shared-bindings/pwmio/PWMOut.h @@ -40,16 +40,16 @@ typedef enum pwmout_result_t { PWMOUT_ALL_TIMERS_IN_USE } pwmout_result_t; -extern pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t* self, - const mcu_pin_obj_t* pin, uint16_t duty, uint32_t frequency, +extern pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t *self, + const mcu_pin_obj_t *pin, uint16_t duty, uint32_t frequency, bool variable_frequency); -extern void common_hal_pwmio_pwmout_deinit(pwmio_pwmout_obj_t* self); -extern bool common_hal_pwmio_pwmout_deinited(pwmio_pwmout_obj_t* self); -extern void common_hal_pwmio_pwmout_set_duty_cycle(pwmio_pwmout_obj_t* self, uint16_t duty); -extern uint16_t common_hal_pwmio_pwmout_get_duty_cycle(pwmio_pwmout_obj_t* self); -extern void common_hal_pwmio_pwmout_set_frequency(pwmio_pwmout_obj_t* self, uint32_t frequency); -extern uint32_t common_hal_pwmio_pwmout_get_frequency(pwmio_pwmout_obj_t* self); -extern bool common_hal_pwmio_pwmout_get_variable_frequency(pwmio_pwmout_obj_t* self); +extern void common_hal_pwmio_pwmout_deinit(pwmio_pwmout_obj_t *self); +extern bool common_hal_pwmio_pwmout_deinited(pwmio_pwmout_obj_t *self); +extern void common_hal_pwmio_pwmout_set_duty_cycle(pwmio_pwmout_obj_t *self, uint16_t duty); +extern uint16_t common_hal_pwmio_pwmout_get_duty_cycle(pwmio_pwmout_obj_t *self); +extern void common_hal_pwmio_pwmout_set_frequency(pwmio_pwmout_obj_t *self, uint32_t frequency); +extern uint32_t common_hal_pwmio_pwmout_get_frequency(pwmio_pwmout_obj_t *self); +extern bool common_hal_pwmio_pwmout_get_variable_frequency(pwmio_pwmout_obj_t *self); // This is used by the supervisor to claim PWMOut devices indefinitely. extern void common_hal_pwmio_pwmout_never_reset(pwmio_pwmout_obj_t *self); diff --git a/shared-bindings/pwmio/__init__.c b/shared-bindings/pwmio/__init__.c index a51383703..bf4ba31dd 100644 --- a/shared-bindings/pwmio/__init__.c +++ b/shared-bindings/pwmio/__init__.c @@ -69,5 +69,5 @@ STATIC MP_DEFINE_CONST_DICT(pwmio_module_globals, pwmio_module_globals_table); const mp_obj_module_t pwmio_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&pwmio_module_globals, + .globals = (mp_obj_dict_t *)&pwmio_module_globals, }; diff --git a/shared-bindings/random/__init__.c b/shared-bindings/random/__init__.c index 35756eef1..e3ac4cdc6 100644 --- a/shared-bindings/random/__init__.c +++ b/shared-bindings/random/__init__.c @@ -71,7 +71,7 @@ STATIC mp_obj_t random_getrandbits(mp_obj_t num_in) { if (n > 32 || n == 0) { mp_raise_ValueError(NULL); } - return mp_obj_new_int_from_uint(shared_modules_random_getrandbits((uint8_t) n)); + return mp_obj_new_int_from_uint(shared_modules_random_getrandbits((uint8_t)n)); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(random_getrandbits_obj, random_getrandbits); @@ -182,5 +182,5 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_random_globals, mp_module_random_globals_t const mp_obj_module_t random_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_random_globals, + .globals = (mp_obj_dict_t *)&mp_module_random_globals, }; diff --git a/shared-bindings/rgbmatrix/RGBMatrix.c b/shared-bindings/rgbmatrix/RGBMatrix.c index 30b72dffd..045cc82b8 100644 --- a/shared-bindings/rgbmatrix/RGBMatrix.c +++ b/shared-bindings/rgbmatrix/RGBMatrix.c @@ -49,10 +49,10 @@ STATIC uint8_t validate_pin(mp_obj_t obj) { return common_hal_mcu_pin_number(result); } -STATIC void validate_pins(qstr what, uint8_t* pin_nos, mp_int_t max_pins, mp_obj_t seq, uint8_t *count_out) { +STATIC void validate_pins(qstr what, uint8_t *pin_nos, mp_int_t max_pins, mp_obj_t seq, uint8_t *count_out) { mcu_pin_obj_t *pins[max_pins]; validate_list_is_free_pins(what, pins, max_pins, seq, count_out); - for (mp_int_t i=0; i<*count_out; i++) { + for (mp_int_t i = 0; i < *count_out; i++) { pin_nos[i] = common_hal_mcu_pin_number(pins[i]); } } @@ -64,7 +64,7 @@ STATIC void claim_and_never_reset_pin(mp_obj_t pin) { STATIC void claim_and_never_reset_pins(mp_obj_t seq) { mp_int_t len = MP_OBJ_SMALL_INT_VALUE(mp_obj_len(seq)); - for (mp_int_t i=0; i<len; i++) { + for (mp_int_t i = 0; i < len; i++) { claim_and_never_reset_pin(mp_obj_subscr(seq, MP_OBJ_NEW_SMALL_INT(i), MP_OBJ_SENTINEL)); } } @@ -99,15 +99,23 @@ STATIC void preflight_pins_or_throw(uint8_t clock_pin, uint8_t *rgb_pins, uint8_ } uint8_t byte_mask = 0; - if (bit_mask & 0x000000FF) byte_mask |= 0b0001; - if (bit_mask & 0x0000FF00) byte_mask |= 0b0010; - if (bit_mask & 0x00FF0000) byte_mask |= 0b0100; - if (bit_mask & 0xFF000000) byte_mask |= 0b1000; + if (bit_mask & 0x000000FF) { + byte_mask |= 0b0001; + } + if (bit_mask & 0x0000FF00) { + byte_mask |= 0b0010; + } + if (bit_mask & 0x00FF0000) { + byte_mask |= 0b0100; + } + if (bit_mask & 0xFF000000) { + byte_mask |= 0b1000; + } uint8_t bytes_per_element = 0xff; uint8_t ideal_bytes_per_element = (rgb_pin_count + 7) / 8; - switch(byte_mask) { + switch (byte_mask) { case 0b0001: case 0b0010: case 0b0100: @@ -172,7 +180,7 @@ STATIC void preflight_pins_or_throw(uint8_t clock_pin, uint8_t *rgb_pins, uint8_ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_width, ARG_bit_depth, ARG_rgb_list, ARG_addr_list, - ARG_clock_pin, ARG_latch_pin, ARG_output_enable_pin, ARG_doublebuffer, ARG_framebuffer, ARG_height, ARG_tile, ARG_serpentine }; + ARG_clock_pin, ARG_latch_pin, ARG_output_enable_pin, ARG_doublebuffer, ARG_framebuffer, ARG_height, ARG_tile, ARG_serpentine }; static const mp_arg_t allowed_args[] = { { MP_QSTR_width, MP_ARG_INT | MP_ARG_REQUIRED | MP_ARG_KW_ONLY }, { MP_QSTR_bit_depth, MP_ARG_INT | MP_ARG_REQUIRED | MP_ARG_KW_ONLY }, @@ -265,7 +273,7 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n //| ... //| STATIC mp_obj_t rgbmatrix_rgbmatrix_deinit(mp_obj_t self_in) { - rgbmatrix_rgbmatrix_obj_t *self = (rgbmatrix_rgbmatrix_obj_t*)self_in; + rgbmatrix_rgbmatrix_obj_t *self = (rgbmatrix_rgbmatrix_obj_t *)self_in; common_hal_rgbmatrix_rgbmatrix_deinit(self); return mp_const_none; } @@ -283,14 +291,14 @@ static void check_for_deinit(rgbmatrix_rgbmatrix_obj_t *self) { //| and any other value up to 1.0 turns the display on fully.""" //| STATIC mp_obj_t rgbmatrix_rgbmatrix_get_brightness(mp_obj_t self_in) { - rgbmatrix_rgbmatrix_obj_t *self = (rgbmatrix_rgbmatrix_obj_t*)self_in; + rgbmatrix_rgbmatrix_obj_t *self = (rgbmatrix_rgbmatrix_obj_t *)self_in; check_for_deinit(self); return mp_obj_new_float(common_hal_rgbmatrix_rgbmatrix_get_paused(self)? 0.0f : 1.0f); } MP_DEFINE_CONST_FUN_OBJ_1(rgbmatrix_rgbmatrix_get_brightness_obj, rgbmatrix_rgbmatrix_get_brightness); -STATIC mp_obj_t rgbmatrix_rgbmatrix_set_brightness(mp_obj_t self_in, mp_obj_t value_in) { - rgbmatrix_rgbmatrix_obj_t *self = (rgbmatrix_rgbmatrix_obj_t*)self_in; +STATIC mp_obj_t rgbmatrix_rgbmatrix_set_brightness(mp_obj_t self_in, mp_obj_t value_in) { + rgbmatrix_rgbmatrix_obj_t *self = (rgbmatrix_rgbmatrix_obj_t *)self_in; check_for_deinit(self); mp_float_t brightness = mp_obj_get_float(value_in); if (brightness < 0.0f || brightness > 1.0f) { @@ -315,7 +323,7 @@ const mp_obj_property_t rgbmatrix_rgbmatrix_brightness_obj = { //| ... //| STATIC mp_obj_t rgbmatrix_rgbmatrix_refresh(mp_obj_t self_in) { - rgbmatrix_rgbmatrix_obj_t *self = (rgbmatrix_rgbmatrix_obj_t*)self_in; + rgbmatrix_rgbmatrix_obj_t *self = (rgbmatrix_rgbmatrix_obj_t *)self_in; check_for_deinit(self); common_hal_rgbmatrix_rgbmatrix_refresh(self); return mp_const_none; @@ -326,7 +334,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(rgbmatrix_rgbmatrix_refresh_obj, rgbmatrix_rgbmatrix_r //| """The width of the display, in pixels""" //| STATIC mp_obj_t rgbmatrix_rgbmatrix_get_width(mp_obj_t self_in) { - rgbmatrix_rgbmatrix_obj_t *self = (rgbmatrix_rgbmatrix_obj_t*)self_in; + rgbmatrix_rgbmatrix_obj_t *self = (rgbmatrix_rgbmatrix_obj_t *)self_in; check_for_deinit(self); return MP_OBJ_NEW_SMALL_INT(common_hal_rgbmatrix_rgbmatrix_get_width(self)); } @@ -342,7 +350,7 @@ const mp_obj_property_t rgbmatrix_rgbmatrix_width_obj = { //| """The height of the display, in pixels""" //| STATIC mp_obj_t rgbmatrix_rgbmatrix_get_height(mp_obj_t self_in) { - rgbmatrix_rgbmatrix_obj_t *self = (rgbmatrix_rgbmatrix_obj_t*)self_in; + rgbmatrix_rgbmatrix_obj_t *self = (rgbmatrix_rgbmatrix_obj_t *)self_in; check_for_deinit(self); return MP_OBJ_NEW_SMALL_INT(common_hal_rgbmatrix_rgbmatrix_get_height(self)); } @@ -365,7 +373,7 @@ STATIC const mp_rom_map_elem_t rgbmatrix_rgbmatrix_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(rgbmatrix_rgbmatrix_locals_dict, rgbmatrix_rgbmatrix_locals_dict_table); STATIC void rgbmatrix_rgbmatrix_get_bufinfo(mp_obj_t self_in, mp_buffer_info_t *bufinfo) { - rgbmatrix_rgbmatrix_obj_t *self = (rgbmatrix_rgbmatrix_obj_t*)self_in; + rgbmatrix_rgbmatrix_obj_t *self = (rgbmatrix_rgbmatrix_obj_t *)self_in; check_for_deinit(self); *bufinfo = self->bufinfo; @@ -427,7 +435,7 @@ STATIC const framebuffer_p_t rgbmatrix_rgbmatrix_proto = { }; STATIC mp_int_t rgbmatrix_rgbmatrix_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) { - rgbmatrix_rgbmatrix_obj_t *self = (rgbmatrix_rgbmatrix_obj_t*)self_in; + rgbmatrix_rgbmatrix_obj_t *self = (rgbmatrix_rgbmatrix_obj_t *)self_in; // a readonly framebuffer would be unusual but not impossible if ((flags & MP_BUFFER_WRITE) && !(self->bufinfo.typecode & MP_OBJ_ARRAY_TYPECODE_FLAG_RW)) { return 1; @@ -442,5 +450,5 @@ const mp_obj_type_t rgbmatrix_RGBMatrix_type = { .buffer_p = { .get_buffer = rgbmatrix_rgbmatrix_get_buffer, }, .make_new = rgbmatrix_rgbmatrix_make_new, .protocol = &rgbmatrix_rgbmatrix_proto, - .locals_dict = (mp_obj_dict_t*)&rgbmatrix_rgbmatrix_locals_dict, + .locals_dict = (mp_obj_dict_t *)&rgbmatrix_rgbmatrix_locals_dict, }; diff --git a/shared-bindings/rgbmatrix/RGBMatrix.h b/shared-bindings/rgbmatrix/RGBMatrix.h index 4eb3c04b2..127f920da 100644 --- a/shared-bindings/rgbmatrix/RGBMatrix.h +++ b/shared-bindings/rgbmatrix/RGBMatrix.h @@ -31,12 +31,12 @@ extern const mp_obj_type_t rgbmatrix_RGBMatrix_type; -void common_hal_rgbmatrix_rgbmatrix_construct(rgbmatrix_rgbmatrix_obj_t* self, int width, int bit_depth, uint8_t rgb_count, uint8_t* rgb_pins, uint8_t addr_count, uint8_t* addr_pins, uint8_t clock_pin, uint8_t latch_pin, uint8_t oe_pin, bool doublebuffer, mp_obj_t framebuffer, int8_t tile, bool serpentine, void* timer); -void common_hal_rgbmatrix_rgbmatrix_deinit(rgbmatrix_rgbmatrix_obj_t*); -void rgbmatrix_rgbmatrix_collect_ptrs(rgbmatrix_rgbmatrix_obj_t*); -void common_hal_rgbmatrix_rgbmatrix_reconstruct(rgbmatrix_rgbmatrix_obj_t* self, mp_obj_t framebuffer); -void common_hal_rgbmatrix_rgbmatrix_set_paused(rgbmatrix_rgbmatrix_obj_t* self, bool paused); -bool common_hal_rgbmatrix_rgbmatrix_get_paused(rgbmatrix_rgbmatrix_obj_t* self); -void common_hal_rgbmatrix_rgbmatrix_refresh(rgbmatrix_rgbmatrix_obj_t* self); -int common_hal_rgbmatrix_rgbmatrix_get_width(rgbmatrix_rgbmatrix_obj_t* self); -int common_hal_rgbmatrix_rgbmatrix_get_height(rgbmatrix_rgbmatrix_obj_t* self); +void common_hal_rgbmatrix_rgbmatrix_construct(rgbmatrix_rgbmatrix_obj_t *self, int width, int bit_depth, uint8_t rgb_count, uint8_t *rgb_pins, uint8_t addr_count, uint8_t *addr_pins, uint8_t clock_pin, uint8_t latch_pin, uint8_t oe_pin, bool doublebuffer, mp_obj_t framebuffer, int8_t tile, bool serpentine, void *timer); +void common_hal_rgbmatrix_rgbmatrix_deinit(rgbmatrix_rgbmatrix_obj_t *); +void rgbmatrix_rgbmatrix_collect_ptrs(rgbmatrix_rgbmatrix_obj_t *); +void common_hal_rgbmatrix_rgbmatrix_reconstruct(rgbmatrix_rgbmatrix_obj_t *self, mp_obj_t framebuffer); +void common_hal_rgbmatrix_rgbmatrix_set_paused(rgbmatrix_rgbmatrix_obj_t *self, bool paused); +bool common_hal_rgbmatrix_rgbmatrix_get_paused(rgbmatrix_rgbmatrix_obj_t *self); +void common_hal_rgbmatrix_rgbmatrix_refresh(rgbmatrix_rgbmatrix_obj_t *self); +int common_hal_rgbmatrix_rgbmatrix_get_width(rgbmatrix_rgbmatrix_obj_t *self); +int common_hal_rgbmatrix_rgbmatrix_get_height(rgbmatrix_rgbmatrix_obj_t *self); diff --git a/shared-bindings/rgbmatrix/__init__.c b/shared-bindings/rgbmatrix/__init__.c index 7f0576652..451163dbe 100644 --- a/shared-bindings/rgbmatrix/__init__.c +++ b/shared-bindings/rgbmatrix/__init__.c @@ -43,5 +43,5 @@ STATIC MP_DEFINE_CONST_DICT(rgbmatrix_module_globals, rgbmatrix_module_globals_t const mp_obj_module_t rgbmatrix_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&rgbmatrix_module_globals, + .globals = (mp_obj_dict_t *)&rgbmatrix_module_globals, }; diff --git a/shared-bindings/rotaryio/IncrementalEncoder.c b/shared-bindings/rotaryio/IncrementalEncoder.c index 8b0badbe8..b27e601c2 100644 --- a/shared-bindings/rotaryio/IncrementalEncoder.c +++ b/shared-bindings/rotaryio/IncrementalEncoder.c @@ -69,8 +69,8 @@ STATIC mp_obj_t rotaryio_incrementalencoder_make_new(const mp_obj_type_t *type, mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - const mcu_pin_obj_t* pin_a = validate_obj_is_free_pin(args[ARG_pin_a].u_obj); - const mcu_pin_obj_t* pin_b = validate_obj_is_free_pin(args[ARG_pin_b].u_obj); + const mcu_pin_obj_t *pin_a = validate_obj_is_free_pin(args[ARG_pin_a].u_obj); + const mcu_pin_obj_t *pin_b = validate_obj_is_free_pin(args[ARG_pin_b].u_obj); rotaryio_incrementalencoder_obj_t *self = m_new_obj(rotaryio_incrementalencoder_obj_t); self->base.type = &rotaryio_incrementalencoder_type; @@ -157,5 +157,5 @@ const mp_obj_type_t rotaryio_incrementalencoder_type = { { &mp_type_type }, .name = MP_QSTR_IncrementalEncoder, .make_new = rotaryio_incrementalencoder_make_new, - .locals_dict = (mp_obj_dict_t*)&rotaryio_incrementalencoder_locals_dict, + .locals_dict = (mp_obj_dict_t *)&rotaryio_incrementalencoder_locals_dict, }; diff --git a/shared-bindings/rotaryio/IncrementalEncoder.h b/shared-bindings/rotaryio/IncrementalEncoder.h index f70632aef..51bf7bd9f 100644 --- a/shared-bindings/rotaryio/IncrementalEncoder.h +++ b/shared-bindings/rotaryio/IncrementalEncoder.h @@ -32,12 +32,12 @@ extern const mp_obj_type_t rotaryio_incrementalencoder_type; -extern void common_hal_rotaryio_incrementalencoder_construct(rotaryio_incrementalencoder_obj_t* self, - const mcu_pin_obj_t* pin_a, const mcu_pin_obj_t* pin_b); -extern void common_hal_rotaryio_incrementalencoder_deinit(rotaryio_incrementalencoder_obj_t* self); -extern bool common_hal_rotaryio_incrementalencoder_deinited(rotaryio_incrementalencoder_obj_t* self); -extern mp_int_t common_hal_rotaryio_incrementalencoder_get_position(rotaryio_incrementalencoder_obj_t* self); -extern void common_hal_rotaryio_incrementalencoder_set_position(rotaryio_incrementalencoder_obj_t* self, +extern void common_hal_rotaryio_incrementalencoder_construct(rotaryio_incrementalencoder_obj_t *self, + const mcu_pin_obj_t *pin_a, const mcu_pin_obj_t *pin_b); +extern void common_hal_rotaryio_incrementalencoder_deinit(rotaryio_incrementalencoder_obj_t *self); +extern bool common_hal_rotaryio_incrementalencoder_deinited(rotaryio_incrementalencoder_obj_t *self); +extern mp_int_t common_hal_rotaryio_incrementalencoder_get_position(rotaryio_incrementalencoder_obj_t *self); +extern void common_hal_rotaryio_incrementalencoder_set_position(rotaryio_incrementalencoder_obj_t *self, mp_int_t new_position); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_ROTARYIO_INCREMENTALENCODER_H diff --git a/shared-bindings/rotaryio/__init__.c b/shared-bindings/rotaryio/__init__.c index cd967baa4..cdc7742bc 100644 --- a/shared-bindings/rotaryio/__init__.c +++ b/shared-bindings/rotaryio/__init__.c @@ -54,5 +54,5 @@ STATIC MP_DEFINE_CONST_DICT(rotaryio_module_globals, rotaryio_module_globals_tab const mp_obj_module_t rotaryio_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&rotaryio_module_globals, + .globals = (mp_obj_dict_t *)&rotaryio_module_globals, }; diff --git a/shared-bindings/rtc/RTC.c b/shared-bindings/rtc/RTC.c index 5e6b00c6e..3380a2e6a 100644 --- a/shared-bindings/rtc/RTC.c +++ b/shared-bindings/rtc/RTC.c @@ -135,5 +135,5 @@ const mp_obj_type_t rtc_rtc_type = { { &mp_type_type }, .name = MP_QSTR_RTC, .make_new = rtc_rtc_make_new, - .locals_dict = (mp_obj_dict_t*)&rtc_rtc_locals_dict, + .locals_dict = (mp_obj_dict_t *)&rtc_rtc_locals_dict, }; diff --git a/shared-bindings/rtc/__init__.c b/shared-bindings/rtc/__init__.c index baa9c95e1..1071fa0ea 100644 --- a/shared-bindings/rtc/__init__.c +++ b/shared-bindings/rtc/__init__.c @@ -84,5 +84,5 @@ STATIC MP_DEFINE_CONST_DICT(rtc_module_globals, rtc_module_globals_table); const mp_obj_module_t rtc_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&rtc_module_globals, + .globals = (mp_obj_dict_t *)&rtc_module_globals, }; diff --git a/shared-bindings/sdcardio/SDCard.c b/shared-bindings/sdcardio/SDCard.c index 35d6c1497..612203b56 100644 --- a/shared-bindings/sdcardio/SDCard.c +++ b/shared-bindings/sdcardio/SDCard.c @@ -84,7 +84,7 @@ STATIC mp_obj_t sdcardio_sdcard_make_new(const mp_obj_type_t *type, size_t n_arg { MP_QSTR_baudrate, MP_ARG_INT, {.u_int = 8000000} }, { MP_QSTR_sdio, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_int = 8000000} }, }; - MP_STATIC_ASSERT( MP_ARRAY_SIZE(allowed_args) == NUM_ARGS ); + MP_STATIC_ASSERT(MP_ARRAY_SIZE(allowed_args) == NUM_ARGS); mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); @@ -108,7 +108,7 @@ STATIC mp_obj_t sdcardio_sdcard_make_new(const mp_obj_type_t *type, size_t n_arg //| :return: The number of 512-byte blocks, as a number""" //| mp_obj_t sdcardio_sdcard_count(mp_obj_t self_in) { - sdcardio_sdcard_obj_t *self = (sdcardio_sdcard_obj_t*)self_in; + sdcardio_sdcard_obj_t *self = (sdcardio_sdcard_obj_t *)self_in; return mp_obj_new_int_from_ull(common_hal_sdcardio_sdcard_get_blockcount(self)); } MP_DEFINE_CONST_FUN_OBJ_1(sdcardio_sdcard_count_obj, sdcardio_sdcard_count); @@ -119,7 +119,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(sdcardio_sdcard_count_obj, sdcardio_sdcard_count); //| :return: None""" //| mp_obj_t sdcardio_sdcard_deinit(mp_obj_t self_in) { - sdcardio_sdcard_obj_t *self = (sdcardio_sdcard_obj_t*)self_in; + sdcardio_sdcard_obj_t *self = (sdcardio_sdcard_obj_t *)self_in; common_hal_sdcardio_sdcard_deinit(self); return mp_const_none; } @@ -140,7 +140,7 @@ mp_obj_t sdcardio_sdcard_readblocks(mp_obj_t self_in, mp_obj_t start_block_in, m uint32_t start_block = mp_obj_get_int(start_block_in); mp_buffer_info_t bufinfo; mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_WRITE); - sdcardio_sdcard_obj_t *self = (sdcardio_sdcard_obj_t*)self_in; + sdcardio_sdcard_obj_t *self = (sdcardio_sdcard_obj_t *)self_in; int result = common_hal_sdcardio_sdcard_readblocks(self, start_block, &bufinfo); if (result < 0) { mp_raise_OSError(-result); @@ -164,7 +164,7 @@ mp_obj_t sdcardio_sdcard_writeblocks(mp_obj_t self_in, mp_obj_t start_block_in, uint32_t start_block = mp_obj_get_int(start_block_in); mp_buffer_info_t bufinfo; mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_READ); - sdcardio_sdcard_obj_t *self = (sdcardio_sdcard_obj_t*)self_in; + sdcardio_sdcard_obj_t *self = (sdcardio_sdcard_obj_t *)self_in; int result = common_hal_sdcardio_sdcard_writeblocks(self, start_block, &bufinfo); if (result < 0) { mp_raise_OSError(-result); @@ -185,5 +185,5 @@ const mp_obj_type_t sdcardio_SDCard_type = { { &mp_type_type }, .name = MP_QSTR_SDCard, .make_new = sdcardio_sdcard_make_new, - .locals_dict = (mp_obj_dict_t*)&sdcardio_sdcard_locals_dict, + .locals_dict = (mp_obj_dict_t *)&sdcardio_sdcard_locals_dict, }; diff --git a/shared-bindings/sdcardio/__init__.c b/shared-bindings/sdcardio/__init__.c index 746aa5588..e798ad095 100644 --- a/shared-bindings/sdcardio/__init__.c +++ b/shared-bindings/sdcardio/__init__.c @@ -43,5 +43,5 @@ STATIC MP_DEFINE_CONST_DICT(sdcardio_module_globals, sdcardio_module_globals_tab const mp_obj_module_t sdcardio_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&sdcardio_module_globals, + .globals = (mp_obj_dict_t *)&sdcardio_module_globals, }; diff --git a/shared-bindings/sdioio/SDCard.c b/shared-bindings/sdioio/SDCard.c index aba414cd6..468c89821 100644 --- a/shared-bindings/sdioio/SDCard.c +++ b/shared-bindings/sdioio/SDCard.c @@ -88,13 +88,13 @@ STATIC mp_obj_t sdioio_sdcard_make_new(const mp_obj_type_t *type, size_t n_args, { MP_QSTR_data, MP_ARG_REQUIRED | MP_ARG_KW_ONLY | MP_ARG_OBJ }, { MP_QSTR_frequency, MP_ARG_REQUIRED | MP_ARG_KW_ONLY | MP_ARG_INT }, }; - MP_STATIC_ASSERT( MP_ARRAY_SIZE(allowed_args) == NUM_ARGS ); + MP_STATIC_ASSERT(MP_ARRAY_SIZE(allowed_args) == NUM_ARGS); mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); - const mcu_pin_obj_t* clock = validate_obj_is_free_pin(args[ARG_clock].u_obj); - const mcu_pin_obj_t* command = validate_obj_is_free_pin(args[ARG_command].u_obj); + const mcu_pin_obj_t *clock = validate_obj_is_free_pin(args[ARG_clock].u_obj); + const mcu_pin_obj_t *command = validate_obj_is_free_pin(args[ARG_command].u_obj); mcu_pin_obj_t *data_pins[4]; uint8_t num_data; validate_list_is_free_pins(MP_QSTR_data, data_pins, MP_ARRAY_SIZE(data_pins), args[ARG_data].u_obj, &num_data); @@ -126,7 +126,7 @@ STATIC mp_obj_t sdioio_sdcard_configure(size_t n_args, const mp_obj_t *pos_args, sdioio_sdcard_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); check_for_deinit(self); mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - MP_STATIC_ASSERT( MP_ARRAY_SIZE(allowed_args) == NUM_ARGS ); + MP_STATIC_ASSERT(MP_ARRAY_SIZE(allowed_args) == NUM_ARGS); mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_int_t frequency = args[ARG_frequency].u_int; @@ -172,7 +172,7 @@ mp_obj_t sdioio_sdcard_readblocks(mp_obj_t self_in, mp_obj_t start_block_in, mp_ uint32_t start_block = mp_obj_get_int(start_block_in); mp_buffer_info_t bufinfo; mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_WRITE); - sdioio_sdcard_obj_t *self = (sdioio_sdcard_obj_t*)self_in; + sdioio_sdcard_obj_t *self = (sdioio_sdcard_obj_t *)self_in; int result = common_hal_sdioio_sdcard_readblocks(self, start_block, &bufinfo); if (result < 0) { mp_raise_OSError(-result); @@ -195,7 +195,7 @@ mp_obj_t sdioio_sdcard_writeblocks(mp_obj_t self_in, mp_obj_t start_block_in, mp uint32_t start_block = mp_obj_get_int(start_block_in); mp_buffer_info_t bufinfo; mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_READ); - sdioio_sdcard_obj_t *self = (sdioio_sdcard_obj_t*)self_in; + sdioio_sdcard_obj_t *self = (sdioio_sdcard_obj_t *)self_in; int result = common_hal_sdioio_sdcard_writeblocks(self, start_block, &bufinfo); if (result < 0) { mp_raise_OSError(-result); @@ -289,8 +289,8 @@ STATIC const mp_rom_map_elem_t sdioio_sdcard_locals_dict_table[] = { STATIC MP_DEFINE_CONST_DICT(sdioio_sdcard_locals_dict, sdioio_sdcard_locals_dict_table); const mp_obj_type_t sdioio_SDCard_type = { - { &mp_type_type }, - .name = MP_QSTR_SDCard, - .make_new = sdioio_sdcard_make_new, - .locals_dict = (mp_obj_dict_t*)&sdioio_sdcard_locals_dict, + { &mp_type_type }, + .name = MP_QSTR_SDCard, + .make_new = sdioio_sdcard_make_new, + .locals_dict = (mp_obj_dict_t *)&sdioio_sdcard_locals_dict, }; diff --git a/shared-bindings/sdioio/SDCard.h b/shared-bindings/sdioio/SDCard.h index 7f62ee7a6..cd302f4de 100644 --- a/shared-bindings/sdioio/SDCard.h +++ b/shared-bindings/sdioio/SDCard.h @@ -37,8 +37,8 @@ extern const mp_obj_type_t sdioio_SDCard_type; // Construct an underlying SDIO object. extern void common_hal_sdioio_sdcard_construct(sdioio_sdcard_obj_t *self, - const mcu_pin_obj_t * clock, const mcu_pin_obj_t * command, - uint8_t num_data, mcu_pin_obj_t ** data, uint32_t frequency); + const mcu_pin_obj_t *clock, const mcu_pin_obj_t *command, + uint8_t num_data, mcu_pin_obj_t **data, uint32_t frequency); extern void common_hal_sdioio_sdcard_deinit(sdioio_sdcard_obj_t *self); extern bool common_hal_sdioio_sdcard_deinited(sdioio_sdcard_obj_t *self); @@ -48,17 +48,17 @@ extern bool common_hal_sdioio_sdcard_configure(sdioio_sdcard_obj_t *self, uint32 extern void common_hal_sdioio_sdcard_unlock(sdioio_sdcard_obj_t *self); // Return actual SDIO bus frequency. -uint32_t common_hal_sdioio_sdcard_get_frequency(sdioio_sdcard_obj_t* self); +uint32_t common_hal_sdioio_sdcard_get_frequency(sdioio_sdcard_obj_t *self); // Return SDIO bus width. -uint8_t common_hal_sdioio_sdcard_get_width(sdioio_sdcard_obj_t* self); +uint8_t common_hal_sdioio_sdcard_get_width(sdioio_sdcard_obj_t *self); // Return number of device blocks -uint32_t common_hal_sdioio_sdcard_get_count(sdioio_sdcard_obj_t* self); +uint32_t common_hal_sdioio_sdcard_get_count(sdioio_sdcard_obj_t *self); // Read or write blocks -int common_hal_sdioio_sdcard_readblocks(sdioio_sdcard_obj_t* self, uint32_t start_block, mp_buffer_info_t *bufinfo); -int common_hal_sdioio_sdcard_writeblocks(sdioio_sdcard_obj_t* self, uint32_t start_block, mp_buffer_info_t *bufinfo); +int common_hal_sdioio_sdcard_readblocks(sdioio_sdcard_obj_t *self, uint32_t start_block, mp_buffer_info_t *bufinfo); +int common_hal_sdioio_sdcard_writeblocks(sdioio_sdcard_obj_t *self, uint32_t start_block, mp_buffer_info_t *bufinfo); // This is used by the supervisor to claim SDIO devices indefinitely. extern void common_hal_sdioio_sdcard_never_reset(sdioio_sdcard_obj_t *self); diff --git a/shared-bindings/sdioio/__init__.c b/shared-bindings/sdioio/__init__.c index b88e5c3a9..98867fc12 100644 --- a/shared-bindings/sdioio/__init__.c +++ b/shared-bindings/sdioio/__init__.c @@ -43,5 +43,5 @@ STATIC MP_DEFINE_CONST_DICT(sdioio_module_globals, sdioio_module_globals_table); const mp_obj_module_t sdioio_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&sdioio_module_globals, + .globals = (mp_obj_dict_t *)&sdioio_module_globals, }; diff --git a/shared-bindings/sharpdisplay/SharpMemoryFramebuffer.c b/shared-bindings/sharpdisplay/SharpMemoryFramebuffer.c index e8f4e970a..713807745 100644 --- a/shared-bindings/sharpdisplay/SharpMemoryFramebuffer.c +++ b/shared-bindings/sharpdisplay/SharpMemoryFramebuffer.c @@ -43,14 +43,14 @@ STATIC mp_obj_t sharpdisplay_framebuffer_make_new(const mp_obj_type_t *type, siz { MP_QSTR_baudrate, MP_ARG_INT, {.u_int = 2000000} }, }; mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; - MP_STATIC_ASSERT( MP_ARRAY_SIZE(allowed_args) == NUM_ARGS ); + MP_STATIC_ASSERT(MP_ARRAY_SIZE(allowed_args) == NUM_ARGS); mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mcu_pin_obj_t *chip_select = validate_obj_is_free_pin(args[ARG_chip_select].u_obj); busio_spi_obj_t *spi = validate_obj_is_spi_bus(args[ARG_spi_bus].u_obj); - sharpdisplay_framebuffer_obj_t* self = &allocate_display_bus_or_raise()->sharpdisplay; + sharpdisplay_framebuffer_obj_t *self = &allocate_display_bus_or_raise()->sharpdisplay; self->base.type = &sharpdisplay_framebuffer_type; common_hal_sharpdisplay_framebuffer_construct(self, spi, chip_select, args[ARG_baudrate].u_int, args[ARG_width].u_int, args[ARG_height].u_int); @@ -60,7 +60,7 @@ STATIC mp_obj_t sharpdisplay_framebuffer_make_new(const mp_obj_type_t *type, siz STATIC mp_int_t sharpdisplay_framebuffer_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) { - sharpdisplay_framebuffer_obj_t *self = (sharpdisplay_framebuffer_obj_t*)self_in; + sharpdisplay_framebuffer_obj_t *self = (sharpdisplay_framebuffer_obj_t *)self_in; // a readonly framebuffer would be unusual but not impossible if ((flags & MP_BUFFER_WRITE) && !(self->bufinfo.typecode & MP_OBJ_ARRAY_TYPECODE_FLAG_RW)) { return 1; @@ -70,7 +70,7 @@ STATIC mp_int_t sharpdisplay_framebuffer_get_buffer(mp_obj_t self_in, mp_buffer_ } STATIC mp_obj_t sharpdisplay_framebuffer_deinit(mp_obj_t self_in) { - sharpdisplay_framebuffer_obj_t *self = (sharpdisplay_framebuffer_obj_t*)self_in; + sharpdisplay_framebuffer_obj_t *self = (sharpdisplay_framebuffer_obj_t *)self_in; common_hal_sharpdisplay_framebuffer_deinit(self); return mp_const_none; @@ -88,5 +88,5 @@ const mp_obj_type_t sharpdisplay_framebuffer_type = { .buffer_p = { .get_buffer = sharpdisplay_framebuffer_get_buffer, }, .make_new = sharpdisplay_framebuffer_make_new, .protocol = &sharpdisplay_framebuffer_proto, - .locals_dict = (mp_obj_dict_t*)&sharpdisplay_framebuffer_locals_dict, + .locals_dict = (mp_obj_dict_t *)&sharpdisplay_framebuffer_locals_dict, }; diff --git a/shared-bindings/sharpdisplay/__init__.c b/shared-bindings/sharpdisplay/__init__.c index d1f728c61..d3d3e1491 100644 --- a/shared-bindings/sharpdisplay/__init__.c +++ b/shared-bindings/sharpdisplay/__init__.c @@ -43,5 +43,5 @@ STATIC MP_DEFINE_CONST_DICT(sharpdisplay_module_globals, sharpdisplay_module_glo const mp_obj_module_t sharpdisplay_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&sharpdisplay_module_globals, + .globals = (mp_obj_dict_t *)&sharpdisplay_module_globals, }; diff --git a/shared-bindings/socket/__init__.c b/shared-bindings/socket/__init__.c index 799bf28af..336b11225 100644 --- a/shared-bindings/socket/__init__.c +++ b/shared-bindings/socket/__init__.c @@ -93,7 +93,7 @@ STATIC void socket_select_nic(mod_network_socket_obj_t *self, const byte *ip) { if (self->nic == MP_OBJ_NULL) { // select NIC based on IP self->nic = network_module_find_nic(ip); - self->nic_type = (mod_network_nic_type_t*)mp_obj_get_type(self->nic); + self->nic_type = (mod_network_nic_type_t *)mp_obj_get_type(self->nic); // call the NIC to open the socket int _errno; @@ -289,7 +289,7 @@ STATIC mp_obj_t socket_recv_into(size_t n_args, const mp_obj_t *args) { } } - mp_int_t ret = _socket_recv_into(self, (byte*)bufinfo.buf, len); + mp_int_t ret = _socket_recv_into(self, (byte *)bufinfo.buf, len); return mp_obj_new_int_from_uint(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(socket_recv_into_obj, 2, 3, socket_recv_into); @@ -312,7 +312,7 @@ STATIC mp_obj_t socket_recv(mp_obj_t self_in, mp_obj_t len_in) { mp_int_t len = mp_obj_get_int(len_in); vstr_t vstr; vstr_init_len(&vstr, len); - mp_int_t ret = _socket_recv_into(self, (byte*)vstr.buf, len); + mp_int_t ret = _socket_recv_into(self, (byte *)vstr.buf, len); if (ret == 0) { return mp_const_empty_bytes; } @@ -379,7 +379,7 @@ STATIC mp_obj_t socket_recvfrom(mp_obj_t self_in, mp_obj_t len_in) { byte ip[4]; mp_uint_t port; int _errno; - mp_int_t ret = self->nic_type->recvfrom(self, (byte*)vstr.buf, vstr.len, ip, &port, &_errno); + mp_int_t ret = self->nic_type->recvfrom(self, (byte *)vstr.buf, vstr.len, ip, &port, &_errno); if (ret == -1) { mp_raise_OSError(_errno); } @@ -519,7 +519,7 @@ STATIC const mp_obj_type_t socket_type = { .name = MP_QSTR_socket, .make_new = socket_make_new, .protocol = &socket_stream_p, - .locals_dict = (mp_obj_dict_t*)&socket_locals_dict, + .locals_dict = (mp_obj_dict_t *)&socket_locals_dict, }; //| def getaddrinfo(host: str, port: int) -> Tuple[int, int, int, str, str]: @@ -554,7 +554,7 @@ STATIC mp_obj_t socket_getaddrinfo(mp_obj_t host_in, mp_obj_t port_in) { // find a NIC that can do a name lookup for (mp_uint_t i = 0; i < MP_STATE_PORT(mod_network_nic_list).len; i++) { mp_obj_t nic = MP_STATE_PORT(mod_network_nic_list).items[i]; - mod_network_nic_type_t *nic_type = (mod_network_nic_type_t*)mp_obj_get_type(nic); + mod_network_nic_type_t *nic_type = (mod_network_nic_type_t *)mp_obj_get_type(nic); if (nic_type->gethostbyname != NULL) { int ret = nic_type->gethostbyname(nic, host, hlen, out_ip); if (ret != 0) { @@ -576,7 +576,7 @@ STATIC mp_obj_t socket_getaddrinfo(mp_obj_t host_in, mp_obj_t port_in) { tuple->items[2] = MP_OBJ_NEW_SMALL_INT(0); tuple->items[3] = MP_OBJ_NEW_QSTR(MP_QSTR_); tuple->items[4] = netutils_format_inet_addr(out_ip, port, NETUTILS_BIG); - return mp_obj_new_list(1, (mp_obj_t*)&tuple); + return mp_obj_new_list(1, (mp_obj_t *)&tuple); } STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_getaddrinfo_obj, socket_getaddrinfo); @@ -609,5 +609,5 @@ STATIC MP_DEFINE_CONST_DICT(socket_globals, socket_globals_table); const mp_obj_module_t socket_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&socket_globals, + .globals = (mp_obj_dict_t *)&socket_globals, }; diff --git a/shared-bindings/socketpool/Socket.c b/shared-bindings/socketpool/Socket.c index da827798c..642656bbf 100644 --- a/shared-bindings/socketpool/Socket.c +++ b/shared-bindings/socketpool/Socket.c @@ -74,7 +74,7 @@ STATIC mp_obj_t socketpool_socket_accept(mp_obj_t self_in) { uint8_t ip[4]; uint32_t port; - socketpool_socket_obj_t * sock = common_hal_socketpool_socket_accept(self, ip, &port); + socketpool_socket_obj_t *sock = common_hal_socketpool_socket_accept(self, ip, &port); mp_obj_t tuple_contents[2]; tuple_contents[0] = MP_OBJ_FROM_PTR(sock); @@ -96,7 +96,7 @@ STATIC mp_obj_t socketpool_socket_bind(mp_obj_t self_in, mp_obj_t addr_in) { mp_obj_get_array_fixed_n(addr_in, 2, &addr_items); size_t hostlen; - const char* host = mp_obj_str_get_data(addr_items[0], &hostlen); + const char *host = mp_obj_str_get_data(addr_items[0], &hostlen); mp_int_t port = mp_obj_get_int(addr_items[1]); if (port < 0) { mp_raise_ValueError(translate("port must be >= 0")); @@ -134,7 +134,7 @@ STATIC mp_obj_t socketpool_socket_connect(mp_obj_t self_in, mp_obj_t addr_in) { mp_obj_get_array_fixed_n(addr_in, 2, &addr_items); size_t hostlen; - const char* host = mp_obj_str_get_data(addr_items[0], &hostlen); + const char *host = mp_obj_str_get_data(addr_items[0], &hostlen); mp_int_t port = mp_obj_get_int(addr_items[1]); if (port < 0) { mp_raise_ValueError(translate("port must be >= 0")); @@ -183,7 +183,7 @@ STATIC mp_obj_t socketpool_socket_recvfrom_into(mp_obj_t self_in, mp_obj_t data_ byte ip[4]; mp_uint_t port; mp_int_t ret = common_hal_socketpool_socket_recvfrom_into(self, - (byte*)bufinfo.buf, bufinfo.len, ip, &port); + (byte *)bufinfo.buf, bufinfo.len, ip, &port); mp_obj_t tuple_contents[2]; tuple_contents[0] = mp_obj_new_int_from_uint(ret); tuple_contents[1] = netutils_format_inet_addr(ip, port, NETUTILS_BIG); @@ -232,7 +232,7 @@ STATIC mp_obj_t socketpool_socket_recv_into(size_t n_args, const mp_obj_t *args) return MP_OBJ_NEW_SMALL_INT(0); } - mp_int_t ret = common_hal_socketpool_socket_recv_into(self, (byte*)bufinfo.buf, len); + mp_int_t ret = common_hal_socketpool_socket_recv_into(self, (byte *)bufinfo.buf, len); return mp_obj_new_int_from_uint(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(socketpool_socket_recv_into_obj, 2, 3, socketpool_socket_recv_into); @@ -282,7 +282,7 @@ STATIC mp_obj_t socketpool_socket_sendto(mp_obj_t self_in, mp_obj_t data_in, mp_ mp_obj_get_array_fixed_n(addr_in, 2, &addr_items); size_t hostlen; - const char* host = mp_obj_str_get_data(addr_items[0], &hostlen); + const char *host = mp_obj_str_get_data(addr_items[0], &hostlen); mp_int_t port = mp_obj_get_int(addr_items[1]); if (port < 0) { mp_raise_ValueError(translate("port must be >= 0")); @@ -410,6 +410,6 @@ STATIC MP_DEFINE_CONST_DICT(socketpool_socket_locals_dict, socketpool_socket_loc const mp_obj_type_t socketpool_socket_type = { { &mp_type_type }, .name = MP_QSTR_Socket, - .locals_dict = (mp_obj_dict_t*)&socketpool_socket_locals_dict, + .locals_dict = (mp_obj_dict_t *)&socketpool_socket_locals_dict, .unary_op = socketpool_socket_unary_op, }; diff --git a/shared-bindings/socketpool/Socket.h b/shared-bindings/socketpool/Socket.h index 27173c8b3..3e757c73a 100644 --- a/shared-bindings/socketpool/Socket.h +++ b/shared-bindings/socketpool/Socket.h @@ -31,20 +31,20 @@ extern const mp_obj_type_t socketpool_socket_type; -socketpool_socket_obj_t * common_hal_socketpool_socket_accept(socketpool_socket_obj_t* self, uint8_t* ip, uint32_t *port); -bool common_hal_socketpool_socket_bind(socketpool_socket_obj_t* self, const char* host, size_t hostlen, uint32_t port); -void common_hal_socketpool_socket_close(socketpool_socket_obj_t* self); -bool common_hal_socketpool_socket_connect(socketpool_socket_obj_t* self, const char* host, size_t hostlen, uint32_t port); -bool common_hal_socketpool_socket_get_closed(socketpool_socket_obj_t* self); -bool common_hal_socketpool_socket_get_connected(socketpool_socket_obj_t* self); -mp_uint_t common_hal_socketpool_socket_get_timeout(socketpool_socket_obj_t* self); -bool common_hal_socketpool_socket_listen(socketpool_socket_obj_t* self, int backlog); -mp_uint_t common_hal_socketpool_socket_recvfrom_into(socketpool_socket_obj_t* self, - uint8_t* buf, uint32_t len, uint8_t* ip, uint32_t *port); -mp_uint_t common_hal_socketpool_socket_recv_into(socketpool_socket_obj_t* self, const uint8_t* buf, uint32_t len); -mp_uint_t common_hal_socketpool_socket_send(socketpool_socket_obj_t* self, const uint8_t* buf, uint32_t len); -mp_uint_t common_hal_socketpool_socket_sendto(socketpool_socket_obj_t* self, - const char* host, size_t hostlen, uint32_t port, const uint8_t* buf, uint32_t len); -void common_hal_socketpool_socket_settimeout(socketpool_socket_obj_t* self, uint32_t timeout_ms); +socketpool_socket_obj_t *common_hal_socketpool_socket_accept(socketpool_socket_obj_t *self, uint8_t *ip, uint32_t *port); +bool common_hal_socketpool_socket_bind(socketpool_socket_obj_t *self, const char *host, size_t hostlen, uint32_t port); +void common_hal_socketpool_socket_close(socketpool_socket_obj_t *self); +bool common_hal_socketpool_socket_connect(socketpool_socket_obj_t *self, const char *host, size_t hostlen, uint32_t port); +bool common_hal_socketpool_socket_get_closed(socketpool_socket_obj_t *self); +bool common_hal_socketpool_socket_get_connected(socketpool_socket_obj_t *self); +mp_uint_t common_hal_socketpool_socket_get_timeout(socketpool_socket_obj_t *self); +bool common_hal_socketpool_socket_listen(socketpool_socket_obj_t *self, int backlog); +mp_uint_t common_hal_socketpool_socket_recvfrom_into(socketpool_socket_obj_t *self, + uint8_t *buf, uint32_t len, uint8_t *ip, uint32_t *port); +mp_uint_t common_hal_socketpool_socket_recv_into(socketpool_socket_obj_t *self, const uint8_t *buf, uint32_t len); +mp_uint_t common_hal_socketpool_socket_send(socketpool_socket_obj_t *self, const uint8_t *buf, uint32_t len); +mp_uint_t common_hal_socketpool_socket_sendto(socketpool_socket_obj_t *self, + const char *host, size_t hostlen, uint32_t port, const uint8_t *buf, uint32_t len); +void common_hal_socketpool_socket_settimeout(socketpool_socket_obj_t *self, uint32_t timeout_ms); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_SOCKETPOOL_SOCKET_H diff --git a/shared-bindings/socketpool/SocketPool.c b/shared-bindings/socketpool/SocketPool.c index 6ff6d5f98..038a0d533 100644 --- a/shared-bindings/socketpool/SocketPool.c +++ b/shared-bindings/socketpool/SocketPool.c @@ -135,7 +135,7 @@ STATIC mp_obj_t socketpool_socketpool_getaddrinfo(size_t n_args, const mp_obj_t sockaddr->items[0] = ip_str; sockaddr->items[1] = MP_OBJ_NEW_SMALL_INT(port); tuple->items[4] = MP_OBJ_FROM_PTR(sockaddr); - return mp_obj_new_list(1, (mp_obj_t*)&tuple); + return mp_obj_new_list(1, (mp_obj_t *)&tuple); } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(socketpool_socketpool_getaddrinfo_obj, 3, socketpool_socketpool_getaddrinfo); @@ -158,5 +158,5 @@ const mp_obj_type_t socketpool_socketpool_type = { { &mp_type_type }, .name = MP_QSTR_SocketPool, .make_new = socketpool_socketpool_make_new, - .locals_dict = (mp_obj_dict_t*)&socketpool_socketpool_locals_dict, + .locals_dict = (mp_obj_dict_t *)&socketpool_socketpool_locals_dict, }; diff --git a/shared-bindings/socketpool/SocketPool.h b/shared-bindings/socketpool/SocketPool.h index b007aad8f..10a943d38 100644 --- a/shared-bindings/socketpool/SocketPool.h +++ b/shared-bindings/socketpool/SocketPool.h @@ -44,12 +44,12 @@ typedef enum { SOCKETPOOL_AF_INET6 } socketpool_socketpool_addressfamily_t; -void common_hal_socketpool_socketpool_construct(socketpool_socketpool_obj_t* self, mp_obj_t radio); +void common_hal_socketpool_socketpool_construct(socketpool_socketpool_obj_t *self, mp_obj_t radio); -socketpool_socket_obj_t* common_hal_socketpool_socket(socketpool_socketpool_obj_t* self, +socketpool_socket_obj_t *common_hal_socketpool_socket(socketpool_socketpool_obj_t *self, socketpool_socketpool_addressfamily_t family, socketpool_socketpool_sock_t type); -mp_obj_t common_hal_socketpool_socketpool_gethostbyname(socketpool_socketpool_obj_t* self, - const char* host); +mp_obj_t common_hal_socketpool_socketpool_gethostbyname(socketpool_socketpool_obj_t *self, + const char *host); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_SOCKETPOOL_SOCKETPOOL_H diff --git a/shared-bindings/socketpool/__init__.c b/shared-bindings/socketpool/__init__.c index d3f8ba302..e6f36261a 100644 --- a/shared-bindings/socketpool/__init__.c +++ b/shared-bindings/socketpool/__init__.c @@ -49,5 +49,5 @@ STATIC MP_DEFINE_CONST_DICT(socketpool_globals, socketpool_globals_table); const mp_obj_module_t socketpool_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&socketpool_globals, + .globals = (mp_obj_dict_t *)&socketpool_globals, }; diff --git a/shared-bindings/ssl/SSLContext.c b/shared-bindings/ssl/SSLContext.c index 44e9e6bbf..4a3dafb98 100644 --- a/shared-bindings/ssl/SSLContext.c +++ b/shared-bindings/ssl/SSLContext.c @@ -75,7 +75,7 @@ STATIC mp_obj_t ssl_sslcontext_wrap_socket(size_t n_args, const mp_obj_t *pos_ar mp_raise_ValueError(translate("Server side context cannot have hostname")); } - socketpool_socket_obj_t* sock = args[ARG_sock].u_obj; + socketpool_socket_obj_t *sock = args[ARG_sock].u_obj; return common_hal_ssl_sslcontext_wrap_socket(self, sock, server_side, server_hostname); } @@ -91,5 +91,5 @@ const mp_obj_type_t ssl_sslcontext_type = { { &mp_type_type }, .name = MP_QSTR_SSLContext, .make_new = ssl_sslcontext_make_new, - .locals_dict = (mp_obj_dict_t*)&ssl_sslcontext_locals_dict, + .locals_dict = (mp_obj_dict_t *)&ssl_sslcontext_locals_dict, }; diff --git a/shared-bindings/ssl/SSLContext.h b/shared-bindings/ssl/SSLContext.h index ad4d7e6a8..1e1986a48 100644 --- a/shared-bindings/ssl/SSLContext.h +++ b/shared-bindings/ssl/SSLContext.h @@ -34,9 +34,9 @@ extern const mp_obj_type_t ssl_sslcontext_type; -void common_hal_ssl_sslcontext_construct(ssl_sslcontext_obj_t* self); +void common_hal_ssl_sslcontext_construct(ssl_sslcontext_obj_t *self); -ssl_sslsocket_obj_t* common_hal_ssl_sslcontext_wrap_socket(ssl_sslcontext_obj_t* self, - socketpool_socket_obj_t* sock, bool server_side, const char* server_hostname); +ssl_sslsocket_obj_t *common_hal_ssl_sslcontext_wrap_socket(ssl_sslcontext_obj_t *self, + socketpool_socket_obj_t *sock, bool server_side, const char *server_hostname); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_SSL_SSLCONTEXT_H diff --git a/shared-bindings/ssl/SSLSocket.c b/shared-bindings/ssl/SSLSocket.c index 0daa930ef..1c2de28e9 100644 --- a/shared-bindings/ssl/SSLSocket.c +++ b/shared-bindings/ssl/SSLSocket.c @@ -73,7 +73,7 @@ STATIC mp_obj_t ssl_sslsocket_accept(mp_obj_t self_in) { uint8_t ip[4]; uint32_t port; - ssl_sslsocket_obj_t * sslsock = common_hal_ssl_sslsocket_accept(self, ip, &port); + ssl_sslsocket_obj_t *sslsock = common_hal_ssl_sslsocket_accept(self, ip, &port); mp_obj_t tuple_contents[2]; tuple_contents[0] = MP_OBJ_FROM_PTR(sslsock); @@ -95,7 +95,7 @@ STATIC mp_obj_t ssl_sslsocket_bind(mp_obj_t self_in, mp_obj_t addr_in) { mp_obj_get_array_fixed_n(addr_in, 2, &addr_items); size_t hostlen; - const char* host = mp_obj_str_get_data(addr_items[0], &hostlen); + const char *host = mp_obj_str_get_data(addr_items[0], &hostlen); mp_int_t port = mp_obj_get_int(addr_items[1]); if (port < 0) { mp_raise_ValueError(translate("port must be >= 0")); @@ -133,7 +133,7 @@ STATIC mp_obj_t ssl_sslsocket_connect(mp_obj_t self_in, mp_obj_t addr_in) { mp_obj_get_array_fixed_n(addr_in, 2, &addr_items); size_t hostlen; - const char* host = mp_obj_str_get_data(addr_items[0], &hostlen); + const char *host = mp_obj_str_get_data(addr_items[0], &hostlen); mp_int_t port = mp_obj_get_int(addr_items[1]); if (port < 0) { mp_raise_ValueError(translate("port must be >= 0")); @@ -205,7 +205,7 @@ STATIC mp_obj_t ssl_sslsocket_recv_into(size_t n_args, const mp_obj_t *args) { return MP_OBJ_NEW_SMALL_INT(0); } - mp_int_t ret = common_hal_ssl_sslsocket_recv_into(self, (byte*)bufinfo.buf, len); + mp_int_t ret = common_hal_ssl_sslsocket_recv_into(self, (byte *)bufinfo.buf, len); return mp_obj_new_int_from_uint(ret); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(ssl_sslsocket_recv_into_obj, 2, 3, ssl_sslsocket_recv_into); @@ -321,6 +321,6 @@ STATIC MP_DEFINE_CONST_DICT(ssl_sslsocket_locals_dict, ssl_sslsocket_locals_dict const mp_obj_type_t ssl_sslsocket_type = { { &mp_type_type }, .name = MP_QSTR_SSLSocket, - .locals_dict = (mp_obj_dict_t*)&ssl_sslsocket_locals_dict, + .locals_dict = (mp_obj_dict_t *)&ssl_sslsocket_locals_dict, .unary_op = ssl_sslsocket_unary_op, }; diff --git a/shared-bindings/ssl/SSLSocket.h b/shared-bindings/ssl/SSLSocket.h index d117e5dca..fc6cc8ec1 100644 --- a/shared-bindings/ssl/SSLSocket.h +++ b/shared-bindings/ssl/SSLSocket.h @@ -31,15 +31,15 @@ extern const mp_obj_type_t ssl_sslsocket_type; -ssl_sslsocket_obj_t * common_hal_ssl_sslsocket_accept(ssl_sslsocket_obj_t* self, uint8_t* ip, uint32_t *port); -bool common_hal_ssl_sslsocket_bind(ssl_sslsocket_obj_t* self, const char* host, size_t hostlen, uint32_t port); -void common_hal_ssl_sslsocket_close(ssl_sslsocket_obj_t* self); -bool common_hal_ssl_sslsocket_connect(ssl_sslsocket_obj_t* self, const char* host, size_t hostlen, uint32_t port); -bool common_hal_ssl_sslsocket_get_closed(ssl_sslsocket_obj_t* self); -bool common_hal_ssl_sslsocket_get_connected(ssl_sslsocket_obj_t* self); -bool common_hal_ssl_sslsocket_listen(ssl_sslsocket_obj_t* self, int backlog); -mp_uint_t common_hal_ssl_sslsocket_recv_into(ssl_sslsocket_obj_t* self, const uint8_t* buf, uint32_t len); -mp_uint_t common_hal_ssl_sslsocket_send(ssl_sslsocket_obj_t* self, const uint8_t* buf, uint32_t len); -void common_hal_ssl_sslsocket_settimeout(ssl_sslsocket_obj_t* self, uint32_t timeout_ms); +ssl_sslsocket_obj_t *common_hal_ssl_sslsocket_accept(ssl_sslsocket_obj_t *self, uint8_t *ip, uint32_t *port); +bool common_hal_ssl_sslsocket_bind(ssl_sslsocket_obj_t *self, const char *host, size_t hostlen, uint32_t port); +void common_hal_ssl_sslsocket_close(ssl_sslsocket_obj_t *self); +bool common_hal_ssl_sslsocket_connect(ssl_sslsocket_obj_t *self, const char *host, size_t hostlen, uint32_t port); +bool common_hal_ssl_sslsocket_get_closed(ssl_sslsocket_obj_t *self); +bool common_hal_ssl_sslsocket_get_connected(ssl_sslsocket_obj_t *self); +bool common_hal_ssl_sslsocket_listen(ssl_sslsocket_obj_t *self, int backlog); +mp_uint_t common_hal_ssl_sslsocket_recv_into(ssl_sslsocket_obj_t *self, const uint8_t *buf, uint32_t len); +mp_uint_t common_hal_ssl_sslsocket_send(ssl_sslsocket_obj_t *self, const uint8_t *buf, uint32_t len); +void common_hal_ssl_sslsocket_settimeout(ssl_sslsocket_obj_t *self, uint32_t timeout_ms); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_SSL_SSLSOCKET_H diff --git a/shared-bindings/ssl/__init__.c b/shared-bindings/ssl/__init__.c index 57f4e6f4a..151acfe80 100644 --- a/shared-bindings/ssl/__init__.c +++ b/shared-bindings/ssl/__init__.c @@ -62,5 +62,5 @@ STATIC MP_DEFINE_CONST_DICT(ssl_globals, ssl_globals_table); const mp_obj_module_t ssl_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&ssl_globals, + .globals = (mp_obj_dict_t *)&ssl_globals, }; diff --git a/shared-bindings/ssl/__init__.h b/shared-bindings/ssl/__init__.h index 5ddada64e..64f69c3ed 100644 --- a/shared-bindings/ssl/__init__.h +++ b/shared-bindings/ssl/__init__.h @@ -29,6 +29,6 @@ #include "common-hal/ssl/SSLContext.h" -void common_hal_ssl_create_default_context(ssl_sslcontext_obj_t* self); +void common_hal_ssl_create_default_context(ssl_sslcontext_obj_t *self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_SSL___INIT___H diff --git a/shared-bindings/storage/__init__.c b/shared-bindings/storage/__init__.c index cafaf5986..7b436a4df 100644 --- a/shared-bindings/storage/__init__.c +++ b/shared-bindings/storage/__init__.c @@ -223,5 +223,5 @@ STATIC MP_DEFINE_CONST_DICT(storage_module_globals, storage_module_globals_table const mp_obj_module_t storage_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&storage_module_globals, + .globals = (mp_obj_dict_t *)&storage_module_globals, }; diff --git a/shared-bindings/storage/__init__.h b/shared-bindings/storage/__init__.h index 7851b9e29..eeb0d3a73 100644 --- a/shared-bindings/storage/__init__.h +++ b/shared-bindings/storage/__init__.h @@ -30,11 +30,11 @@ #include <stdint.h> #include <stdbool.h> -void common_hal_storage_mount(mp_obj_t vfs_obj, const char* path, bool readonly); -void common_hal_storage_umount_path(const char* path); +void common_hal_storage_mount(mp_obj_t vfs_obj, const char *path, bool readonly); +void common_hal_storage_umount_path(const char *path); void common_hal_storage_umount_object(mp_obj_t vfs_obj); -void common_hal_storage_remount(const char* path, bool readonly, bool disable_concurrent_write_protection); -mp_obj_t common_hal_storage_getmount(const char* path); +void common_hal_storage_remount(const char *path, bool readonly, bool disable_concurrent_write_protection); +mp_obj_t common_hal_storage_getmount(const char *path); void common_hal_storage_erase_filesystem(void); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_STORAGE___INIT___H diff --git a/shared-bindings/struct/__init__.c b/shared-bindings/struct/__init__.c index b886a662e..56371d3b9 100644 --- a/shared-bindings/struct/__init__.c +++ b/shared-bindings/struct/__init__.c @@ -72,7 +72,7 @@ STATIC mp_obj_t struct_pack(size_t n_args, const mp_obj_t *args) { mp_int_t size = MP_OBJ_SMALL_INT_VALUE(struct_calcsize(args[0])); vstr_t vstr; vstr_init_len(&vstr, size); - byte *p = (byte*)vstr.buf; + byte *p = (byte *)vstr.buf; memset(p, 0, size); byte *end_p = &p[size]; shared_modules_struct_pack_into(args[0], p, end_p, n_args - 1, &args[1]); @@ -120,7 +120,7 @@ STATIC mp_obj_t struct_unpack(size_t n_args, const mp_obj_t *args) { byte *end_p = &p[bufinfo.len]; // true means check the size must be exactly right. - return MP_OBJ_FROM_PTR(shared_modules_struct_unpack_from(args[0] , p, end_p, true)); + return MP_OBJ_FROM_PTR(shared_modules_struct_unpack_from(args[0], p, end_p, true)); } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_unpack_obj, 2, 3, struct_unpack); @@ -177,5 +177,5 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_struct_globals, mp_module_struct_globals_t const mp_obj_module_t struct_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_struct_globals, + .globals = (mp_obj_dict_t *)&mp_module_struct_globals, }; diff --git a/shared-bindings/struct/__init__.h b/shared-bindings/struct/__init__.h index a7e72b11c..4c7c65da3 100644 --- a/shared-bindings/struct/__init__.h +++ b/shared-bindings/struct/__init__.h @@ -27,8 +27,8 @@ #ifndef MICROPY_INCLUDED_SHARED_BINDINGS_STRUCT___INIT___H #define MICROPY_INCLUDED_SHARED_BINDINGS_STRUCT___INIT___H -void shared_modules_struct_pack_into(mp_obj_t fmt_in, byte *p, byte* end_p, size_t n_args, const mp_obj_t *args); +void shared_modules_struct_pack_into(mp_obj_t fmt_in, byte *p, byte *end_p, size_t n_args, const mp_obj_t *args); mp_uint_t shared_modules_struct_calcsize(mp_obj_t fmt_in); -mp_obj_tuple_t * shared_modules_struct_unpack_from(mp_obj_t fmt_in, byte *p, byte *end_p, bool exact_size); +mp_obj_tuple_t *shared_modules_struct_unpack_from(mp_obj_t fmt_in, byte *p, byte *end_p, bool exact_size); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_RANDOM___INIT___H diff --git a/shared-bindings/supervisor/Runtime.c b/shared-bindings/supervisor/Runtime.c index 283c8a1d6..4c004e092 100755..100644 --- a/shared-bindings/supervisor/Runtime.c +++ b/shared-bindings/supervisor/Runtime.c @@ -35,7 +35,7 @@ STATIC supervisor_run_reason_t _run_reason; -//TODO: add USB, REPL to description once they're operational +// TODO: add USB, REPL to description once they're operational //| class Runtime: //| """Current status of runtime objects. //| @@ -55,7 +55,7 @@ STATIC supervisor_run_reason_t _run_reason; //| serial_connected: bool //| """Returns the USB serial communication status (read-only).""" //| -STATIC mp_obj_t supervisor_runtime_get_serial_connected(mp_obj_t self){ +STATIC mp_obj_t supervisor_runtime_get_serial_connected(mp_obj_t self) { return mp_obj_new_bool(common_hal_supervisor_runtime_get_serial_connected()); } MP_DEFINE_CONST_FUN_OBJ_1(supervisor_runtime_get_serial_connected_obj, supervisor_runtime_get_serial_connected); @@ -72,7 +72,7 @@ const mp_obj_property_t supervisor_runtime_serial_connected_obj = { //| on the USB serial input. Allows for polling to see whether //| to call the built-in input() or wait. (read-only)""" //| -STATIC mp_obj_t supervisor_runtime_get_serial_bytes_available(mp_obj_t self){ +STATIC mp_obj_t supervisor_runtime_get_serial_bytes_available(mp_obj_t self) { return mp_obj_new_bool(common_hal_supervisor_runtime_get_serial_bytes_available()); } MP_DEFINE_CONST_FUN_OBJ_1(supervisor_runtime_get_serial_bytes_available_obj, supervisor_runtime_get_serial_bytes_available); diff --git a/shared-bindings/supervisor/Runtime.h b/shared-bindings/supervisor/Runtime.h index 6874ac744..3a94a8fd5 100755..100644 --- a/shared-bindings/supervisor/Runtime.h +++ b/shared-bindings/supervisor/Runtime.h @@ -40,8 +40,8 @@ bool common_hal_supervisor_runtime_get_serial_connected(void); bool common_hal_supervisor_runtime_get_serial_bytes_available(void); -//TODO: placeholders for future functions -//bool common_hal_get_supervisor_runtime_repl_active(void); -//bool common_hal_get_supervisor_runtime_usb_enumerated(void); +// TODO: placeholders for future functions +// bool common_hal_get_supervisor_runtime_repl_active(void); +// bool common_hal_get_supervisor_runtime_usb_enumerated(void); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_SUPERVISOR_RUNTIME_H diff --git a/shared-bindings/supervisor/__init__.c b/shared-bindings/supervisor/__init__.c index ad8603047..28ac68d62 100644 --- a/shared-bindings/supervisor/__init__.c +++ b/shared-bindings/supervisor/__init__.c @@ -73,14 +73,14 @@ MP_DEFINE_CONST_FUN_OBJ_0(supervisor_disable_autoreload_obj, supervisor_disable_ //| `set_rgb_status_brightness` is called.""" //| ... //| -STATIC mp_obj_t supervisor_set_rgb_status_brightness(mp_obj_t lvl){ - // This must be int. If cast to uint8_t first, will never raise a ValueError. - int brightness_int = mp_obj_get_int(lvl); - if(brightness_int < 0 || brightness_int > 255){ - mp_raise_ValueError(translate("Brightness must be between 0 and 255")); - } - set_rgb_status_brightness((uint8_t)brightness_int); - return mp_const_none; +STATIC mp_obj_t supervisor_set_rgb_status_brightness(mp_obj_t lvl) { + // This must be int. If cast to uint8_t first, will never raise a ValueError. + int brightness_int = mp_obj_get_int(lvl); + if (brightness_int < 0 || brightness_int > 255) { + mp_raise_ValueError(translate("Brightness must be between 0 and 255")); + } + set_rgb_status_brightness((uint8_t)brightness_int); + return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_1(supervisor_set_rgb_status_brightness_obj, supervisor_set_rgb_status_brightness); @@ -128,5 +128,5 @@ STATIC MP_DEFINE_CONST_DICT(supervisor_module_globals, supervisor_module_globals const mp_obj_module_t supervisor_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&supervisor_module_globals, + .globals = (mp_obj_dict_t *)&supervisor_module_globals, }; diff --git a/shared-bindings/supervisor/__init__.h b/shared-bindings/supervisor/__init__.h index b79bdacca..a2ad3dd6d 100755..100644 --- a/shared-bindings/supervisor/__init__.h +++ b/shared-bindings/supervisor/__init__.h @@ -27,7 +27,7 @@ #ifndef MICROPY_INCLUDED_SHARED_BINDINGS_SUPERVISOR___INIT___H #define MICROPY_INCLUDED_SHARED_BINDINGS_SUPERVISOR___INIT___H -//#include "py/mpconfig.h" +// #include "py/mpconfig.h" #include "py/obj.h" #include "common-hal/supervisor/Runtime.h" diff --git a/shared-bindings/terminalio/Terminal.c b/shared-bindings/terminalio/Terminal.c index 3d53e3cce..b1d3cce65 100644 --- a/shared-bindings/terminalio/Terminal.c +++ b/shared-bindings/terminalio/Terminal.c @@ -123,5 +123,5 @@ const mp_obj_type_t terminalio_terminal_type = { .getiter = mp_identity_getiter, .iternext = mp_stream_unbuffered_iter, .protocol = &terminalio_terminal_stream_p, - .locals_dict = (mp_obj_dict_t*)&terminalio_terminal_locals_dict, + .locals_dict = (mp_obj_dict_t *)&terminalio_terminal_locals_dict, }; diff --git a/shared-bindings/terminalio/Terminal.h b/shared-bindings/terminalio/Terminal.h index 7ae0bf1b0..f884edd6d 100644 --- a/shared-bindings/terminalio/Terminal.h +++ b/shared-bindings/terminalio/Terminal.h @@ -34,11 +34,11 @@ extern const mp_obj_type_t terminalio_terminal_type; extern void common_hal_terminalio_terminal_construct(terminalio_terminal_obj_t *self, - displayio_tilegrid_t* tilegrid, const fontio_builtinfont_t* font); + displayio_tilegrid_t *tilegrid, const fontio_builtinfont_t *font); // Write characters. len is in characters NOT bytes! extern size_t common_hal_terminalio_terminal_write(terminalio_terminal_obj_t *self, - const uint8_t *data, size_t len, int *errcode); + const uint8_t *data, size_t len, int *errcode); extern bool common_hal_terminalio_terminal_ready_to_tx(terminalio_terminal_obj_t *self); diff --git a/shared-bindings/terminalio/__init__.c b/shared-bindings/terminalio/__init__.c index 9cd1da5b6..084b76f21 100644 --- a/shared-bindings/terminalio/__init__.c +++ b/shared-bindings/terminalio/__init__.c @@ -43,7 +43,7 @@ //| FONT: fontio.BuiltinFont //| """The built in font""" //| -STATIC const mp_rom_map_elem_t terminalio_module_globals_table[] = { +STATIC const mp_rom_map_elem_t terminalio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_terminalio) }, { MP_ROM_QSTR(MP_QSTR_Terminal), MP_OBJ_FROM_PTR(&terminalio_terminal_type) }, { MP_ROM_QSTR(MP_QSTR_FONT), MP_ROM_PTR(&supervisor_terminal_font) }, @@ -54,5 +54,5 @@ STATIC MP_DEFINE_CONST_DICT(terminalio_module_globals, terminalio_module_globals const mp_obj_module_t terminalio_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&terminalio_module_globals, + .globals = (mp_obj_dict_t *)&terminalio_module_globals, }; diff --git a/shared-bindings/time/__init__.c b/shared-bindings/time/__init__.c index 2624384af..0fb12c9b8 100644 --- a/shared-bindings/time/__init__.c +++ b/shared-bindings/time/__init__.c @@ -83,11 +83,11 @@ mp_obj_t struct_time_make_new(const mp_obj_type_t *type, size_t n_args, const mp if (n_args != 1 || (kw_args != NULL && kw_args->used > 0)) { return namedtuple_make_new(type, n_args, args, kw_args); } - if (mp_obj_get_type(args[0])->getiter != mp_obj_tuple_getiter || ((mp_obj_tuple_t*) MP_OBJ_TO_PTR(args[0]))->len != 9) { + if (mp_obj_get_type(args[0])->getiter != mp_obj_tuple_getiter || ((mp_obj_tuple_t *)MP_OBJ_TO_PTR(args[0]))->len != 9) { mp_raise_TypeError(translate("time.struct_time() takes a 9-sequence")); } - mp_obj_tuple_t* tuple = MP_OBJ_TO_PTR(args[0]); + mp_obj_tuple_t *tuple = MP_OBJ_TO_PTR(args[0]); return namedtuple_make_new(type, 9, tuple->items, NULL); } @@ -140,7 +140,7 @@ const mp_obj_namedtuple_type_t struct_time_type_obj = { mp_obj_t struct_time_from_tm(timeutils_struct_time_t *tm) { timeutils_struct_time_t tmp; mp_uint_t secs = timeutils_seconds_since_epoch(tm->tm_year, tm->tm_mon, tm->tm_mday, - tm->tm_hour, tm->tm_min, tm->tm_sec); + tm->tm_hour, tm->tm_min, tm->tm_sec); timeutils_seconds_since_epoch_to_struct_time(secs, &tmp); tm->tm_wday = tmp.tm_wday; tm->tm_yday = tmp.tm_yday; @@ -157,7 +157,7 @@ mp_obj_t struct_time_from_tm(timeutils_struct_time_t *tm) { mp_obj_new_int(-1), // tm_isdst is not supported }; - return namedtuple_make_new((const mp_obj_type_t*)&struct_time_type_obj, 9, elems, NULL); + return namedtuple_make_new((const mp_obj_type_t *)&struct_time_type_obj, 9, elems, NULL); }; void struct_time_to_tm(mp_obj_t t, timeutils_struct_time_t *tm) { @@ -208,7 +208,7 @@ STATIC mp_obj_t time_time(void) { timeutils_struct_time_t tm; struct_time_to_tm(rtc_get_time_source_time(), &tm); mp_uint_t secs = timeutils_seconds_since_epoch(tm.tm_year, tm.tm_mon, tm.tm_mday, - tm.tm_hour, tm.tm_min, tm.tm_sec); + tm.tm_hour, tm.tm_min, tm.tm_sec); return mp_obj_new_int_from_uint(secs); } MP_DEFINE_CONST_FUN_OBJ_0(time_time_obj, time_time); @@ -222,7 +222,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(time_time_obj, time_time); //| STATIC mp_obj_t time_monotonic_ns(void) { uint64_t time64 = common_hal_time_monotonic_ns(); - return mp_obj_new_int_from_ll((long long) time64); + return mp_obj_new_int_from_ll((long long)time64); } MP_DEFINE_CONST_FUN_OBJ_0(time_monotonic_ns_obj, time_monotonic_ns); @@ -287,7 +287,7 @@ STATIC mp_obj_t time_mktime(mp_obj_t t) { } mp_uint_t secs = timeutils_mktime(mp_obj_get_int(elem[0]), mp_obj_get_int(elem[1]), mp_obj_get_int(elem[2]), - mp_obj_get_int(elem[3]), mp_obj_get_int(elem[4]), mp_obj_get_int(elem[5])); + mp_obj_get_int(elem[3]), mp_obj_get_int(elem[4]), mp_obj_get_int(elem[5])); return mp_obj_new_int_from_uint(secs); } MP_DEFINE_CONST_FUN_OBJ_1(time_mktime_obj, time_mktime); @@ -322,5 +322,5 @@ STATIC MP_DEFINE_CONST_DICT(time_module_globals, time_module_globals_table); const mp_obj_module_t time_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&time_module_globals, + .globals = (mp_obj_dict_t *)&time_module_globals, }; diff --git a/shared-bindings/touchio/TouchIn.c b/shared-bindings/touchio/TouchIn.c index 904589a48..8fb36eab4 100644 --- a/shared-bindings/touchio/TouchIn.c +++ b/shared-bindings/touchio/TouchIn.c @@ -59,7 +59,7 @@ //| ... //| STATIC mp_obj_t touchio_touchin_make_new(const mp_obj_type_t *type, - mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { + mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { // check number of arguments mp_arg_check_num(n_args, kw_args, 1, 1, false); @@ -70,7 +70,7 @@ STATIC mp_obj_t touchio_touchin_make_new(const mp_obj_type_t *type, self->base.type = &touchio_touchin_type; common_hal_touchio_touchin_construct(self, pin); - return (mp_obj_t) self; + return (mp_obj_t)self; } //| def deinit(self) -> None: @@ -144,7 +144,7 @@ const mp_obj_property_t touchio_touchin_raw_value_obj = { .proxy = {(mp_obj_t)&touchio_touchin_get_raw_value_obj, (mp_obj_t)&mp_const_none_obj, (mp_obj_t)&mp_const_none_obj}, - }; +}; //| threshold: Optional[int] diff --git a/shared-bindings/touchio/TouchIn.h b/shared-bindings/touchio/TouchIn.h index 42f9da46d..1da2cf190 100644 --- a/shared-bindings/touchio/TouchIn.h +++ b/shared-bindings/touchio/TouchIn.h @@ -37,9 +37,9 @@ extern const mp_obj_type_t touchio_touchin_type; -void common_hal_touchio_touchin_construct(touchio_touchin_obj_t* self, const mcu_pin_obj_t *pin); -void common_hal_touchio_touchin_deinit(touchio_touchin_obj_t* self); -bool common_hal_touchio_touchin_deinited(touchio_touchin_obj_t* self); +void common_hal_touchio_touchin_construct(touchio_touchin_obj_t *self, const mcu_pin_obj_t *pin); +void common_hal_touchio_touchin_deinit(touchio_touchin_obj_t *self); +bool common_hal_touchio_touchin_deinited(touchio_touchin_obj_t *self); bool common_hal_touchio_touchin_get_value(touchio_touchin_obj_t *self); uint16_t common_hal_touchio_touchin_get_raw_value(touchio_touchin_obj_t *self); uint16_t common_hal_touchio_touchin_get_threshold(touchio_touchin_obj_t *self); diff --git a/shared-bindings/touchio/__init__.c b/shared-bindings/touchio/__init__.c index 92e067cf6..3c3413438 100644 --- a/shared-bindings/touchio/__init__.c +++ b/shared-bindings/touchio/__init__.c @@ -66,5 +66,5 @@ STATIC MP_DEFINE_CONST_DICT(touchio_module_globals, touchio_module_globals_table const mp_obj_module_t touchio_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&touchio_module_globals, + .globals = (mp_obj_dict_t *)&touchio_module_globals, }; diff --git a/shared-bindings/uheap/__init__.c b/shared-bindings/uheap/__init__.c index daf55a613..8c9e2e81d 100644 --- a/shared-bindings/uheap/__init__.c +++ b/shared-bindings/uheap/__init__.c @@ -55,5 +55,5 @@ STATIC MP_DEFINE_CONST_DICT(uheap_module_globals, uheap_module_globals_table); const mp_obj_module_t uheap_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&uheap_module_globals, + .globals = (mp_obj_dict_t *)&uheap_module_globals, }; diff --git a/shared-bindings/usb_cdc/Serial.c b/shared-bindings/usb_cdc/Serial.c index 82355f897..ab0549451 100644 --- a/shared-bindings/usb_cdc/Serial.c +++ b/shared-bindings/usb_cdc/Serial.c @@ -314,5 +314,5 @@ const mp_obj_type_t usb_cdc_serial_type = { .getiter = mp_identity_getiter, .iternext = mp_stream_unbuffered_iter, .protocol = &usb_cdc_serial_stream_p, - .locals_dict = (mp_obj_dict_t*)&usb_cdc_serial_locals_dict, + .locals_dict = (mp_obj_dict_t *)&usb_cdc_serial_locals_dict, }; diff --git a/shared-bindings/usb_cdc/__init__.c b/shared-bindings/usb_cdc/__init__.c index eb9c25e00..9e9ccb898 100644 --- a/shared-bindings/usb_cdc/__init__.c +++ b/shared-bindings/usb_cdc/__init__.c @@ -55,5 +55,5 @@ static MP_DEFINE_CONST_DICT(usb_cdc_module_globals, usb_cdc_module_globals_table const mp_obj_module_t usb_cdc_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&usb_cdc_module_globals, + .globals = (mp_obj_dict_t *)&usb_cdc_module_globals, }; diff --git a/shared-bindings/usb_hid/Device.c b/shared-bindings/usb_hid/Device.c index c7c05a974..cd4f3dd54 100644 --- a/shared-bindings/usb_hid/Device.c +++ b/shared-bindings/usb_hid/Device.c @@ -53,7 +53,7 @@ STATIC mp_obj_t usb_hid_device_send_report(mp_obj_t self_in, mp_obj_t buffer) { mp_buffer_info_t bufinfo; mp_get_buffer_raise(buffer, &bufinfo, MP_BUFFER_READ); - common_hal_usb_hid_device_send_report(self, ((uint8_t*) bufinfo.buf), bufinfo.len); + common_hal_usb_hid_device_send_report(self, ((uint8_t *)bufinfo.buf), bufinfo.len); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_2(usb_hid_device_send_report_obj, usb_hid_device_send_report); @@ -104,7 +104,7 @@ STATIC mp_obj_t usb_hid_device_obj_get_usage(mp_obj_t self_in) { return MP_OBJ_NEW_SMALL_INT(common_hal_usb_hid_device_get_usage(self)); } MP_DEFINE_CONST_FUN_OBJ_1(usb_hid_device_get_usage_obj, - usb_hid_device_obj_get_usage); + usb_hid_device_obj_get_usage); const mp_obj_property_t usb_hid_device_usage_obj = { .base.type = &mp_type_property, diff --git a/shared-bindings/usb_hid/Device.h b/shared-bindings/usb_hid/Device.h index 017995ccc..d9918d406 100644 --- a/shared-bindings/usb_hid/Device.h +++ b/shared-bindings/usb_hid/Device.h @@ -31,7 +31,7 @@ extern const mp_obj_type_t usb_hid_device_type; -void common_hal_usb_hid_device_send_report(usb_hid_device_obj_t *self, uint8_t* report, uint8_t len); +void common_hal_usb_hid_device_send_report(usb_hid_device_obj_t *self, uint8_t *report, uint8_t len); uint8_t common_hal_usb_hid_device_get_usage_page(usb_hid_device_obj_t *self); uint8_t common_hal_usb_hid_device_get_usage(usb_hid_device_obj_t *self); diff --git a/shared-bindings/usb_hid/__init__.c b/shared-bindings/usb_hid/__init__.c index 36111e919..1a2f28d43 100644 --- a/shared-bindings/usb_hid/__init__.c +++ b/shared-bindings/usb_hid/__init__.c @@ -49,5 +49,5 @@ STATIC MP_DEFINE_CONST_DICT(usb_hid_module_globals, usb_hid_module_globals_table const mp_obj_module_t usb_hid_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&usb_hid_module_globals, + .globals = (mp_obj_dict_t *)&usb_hid_module_globals, }; diff --git a/shared-bindings/usb_midi/PortIn.c b/shared-bindings/usb_midi/PortIn.c index c621c8c50..735d9da18 100644 --- a/shared-bindings/usb_midi/PortIn.c +++ b/shared-bindings/usb_midi/PortIn.c @@ -117,5 +117,5 @@ const mp_obj_type_t usb_midi_portin_type = { .getiter = mp_identity_getiter, .iternext = mp_stream_unbuffered_iter, .protocol = &usb_midi_portin_stream_p, - .locals_dict = (mp_obj_dict_t*)&usb_midi_portin_locals_dict, + .locals_dict = (mp_obj_dict_t *)&usb_midi_portin_locals_dict, }; diff --git a/shared-bindings/usb_midi/PortOut.c b/shared-bindings/usb_midi/PortOut.c index ce7062ed3..42fb61016 100644 --- a/shared-bindings/usb_midi/PortOut.c +++ b/shared-bindings/usb_midi/PortOut.c @@ -98,5 +98,5 @@ const mp_obj_type_t usb_midi_portout_type = { .getiter = mp_identity_getiter, .iternext = mp_stream_unbuffered_iter, .protocol = &usb_midi_portout_stream_p, - .locals_dict = (mp_obj_dict_t*)&usb_midi_portout_locals_dict, + .locals_dict = (mp_obj_dict_t *)&usb_midi_portout_locals_dict, }; diff --git a/shared-bindings/usb_midi/PortOut.h b/shared-bindings/usb_midi/PortOut.h index 1eac2fa98..7d8a014da 100644 --- a/shared-bindings/usb_midi/PortOut.h +++ b/shared-bindings/usb_midi/PortOut.h @@ -33,7 +33,7 @@ extern const mp_obj_type_t usb_midi_portout_type; // Write characters. len is in characters NOT bytes! extern size_t common_hal_usb_midi_portout_write(usb_midi_portout_obj_t *self, - const uint8_t *data, size_t len, int *errcode); + const uint8_t *data, size_t len, int *errcode); extern bool common_hal_usb_midi_portout_ready_to_tx(usb_midi_portout_obj_t *self); diff --git a/shared-bindings/usb_midi/__init__.c b/shared-bindings/usb_midi/__init__.c index d88a0db48..4bbe46fda 100644 --- a/shared-bindings/usb_midi/__init__.c +++ b/shared-bindings/usb_midi/__init__.c @@ -55,5 +55,5 @@ MP_DEFINE_MUTABLE_DICT(usb_midi_module_globals, usb_midi_module_globals_table); const mp_obj_module_t usb_midi_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&usb_midi_module_globals, + .globals = (mp_obj_dict_t *)&usb_midi_module_globals, }; diff --git a/shared-bindings/ustack/__init__.c b/shared-bindings/ustack/__init__.c index de48c838a..e2a31e9c4 100644 --- a/shared-bindings/ustack/__init__.c +++ b/shared-bindings/ustack/__init__.c @@ -83,5 +83,5 @@ STATIC MP_DEFINE_CONST_DICT(ustack_module_globals, ustack_module_globals_table); const mp_obj_module_t ustack_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&ustack_module_globals, + .globals = (mp_obj_dict_t *)&ustack_module_globals, }; diff --git a/shared-bindings/vectorio/Circle.c b/shared-bindings/vectorio/Circle.c index 8f0d58d87..f7cf254fa 100644 --- a/shared-bindings/vectorio/Circle.c +++ b/shared-bindings/vectorio/Circle.c @@ -70,5 +70,5 @@ const mp_obj_type_t vectorio_circle_type = { { &mp_type_type }, .name = MP_QSTR_Circle, .make_new = vectorio_circle_make_new, - .locals_dict = (mp_obj_dict_t*)&vectorio_circle_locals_dict, + .locals_dict = (mp_obj_dict_t *)&vectorio_circle_locals_dict, }; diff --git a/shared-bindings/vectorio/Polygon.c b/shared-bindings/vectorio/Polygon.c index 6a72f9124..737476c5e 100644 --- a/shared-bindings/vectorio/Polygon.c +++ b/shared-bindings/vectorio/Polygon.c @@ -75,5 +75,5 @@ const mp_obj_type_t vectorio_polygon_type = { { &mp_type_type }, .name = MP_QSTR_Polygon, .make_new = vectorio_polygon_make_new, - .locals_dict = (mp_obj_dict_t*)&vectorio_polygon_locals_dict, + .locals_dict = (mp_obj_dict_t *)&vectorio_polygon_locals_dict, }; diff --git a/shared-bindings/vectorio/Rectangle.c b/shared-bindings/vectorio/Rectangle.c index 9a637f317..a50a8a14b 100644 --- a/shared-bindings/vectorio/Rectangle.c +++ b/shared-bindings/vectorio/Rectangle.c @@ -48,5 +48,5 @@ const mp_obj_type_t vectorio_rectangle_type = { { &mp_type_type }, .name = MP_QSTR_Rectangle, .make_new = vectorio_rectangle_make_new, - .locals_dict = (mp_obj_dict_t*)&vectorio_rectangle_locals_dict, + .locals_dict = (mp_obj_dict_t *)&vectorio_rectangle_locals_dict, }; diff --git a/shared-bindings/vectorio/VectorShape.c b/shared-bindings/vectorio/VectorShape.c index bc8c8d29c..7c7f467b0 100644 --- a/shared-bindings/vectorio/VectorShape.c +++ b/shared-bindings/vectorio/VectorShape.c @@ -72,7 +72,7 @@ STATIC mp_obj_t vectorio_vector_shape_make_new(const mp_obj_type_t *type, size_t self->base.type = &vectorio_vector_shape_type; common_hal_vectorio_vector_shape_construct(self, ishape, pixel_shader, x, y - ); + ); // Wire up event callbacks vectorio_event_t on_dirty = { @@ -186,5 +186,5 @@ const mp_obj_type_t vectorio_vector_shape_type = { { &mp_type_type }, .name = MP_QSTR_VectorShape, .make_new = vectorio_vector_shape_make_new, - .locals_dict = (mp_obj_dict_t*)&vectorio_vector_shape_locals_dict, + .locals_dict = (mp_obj_dict_t *)&vectorio_vector_shape_locals_dict, }; diff --git a/shared-bindings/vectorio/VectorShape.h b/shared-bindings/vectorio/VectorShape.h index d098504e9..fa11f73ff 100644 --- a/shared-bindings/vectorio/VectorShape.h +++ b/shared-bindings/vectorio/VectorShape.h @@ -7,8 +7,8 @@ extern const mp_obj_type_t vectorio_vector_shape_type; void common_hal_vectorio_vector_shape_construct(vectorio_vector_shape_t *self, - vectorio_ishape_t ishape, - mp_obj_t pixel_shader, uint16_t x, uint16_t y); + vectorio_ishape_t ishape, + mp_obj_t pixel_shader, uint16_t x, uint16_t y); void common_hal_vectorio_vector_shape_set_dirty(void *self); diff --git a/shared-bindings/vectorio/__init__.c b/shared-bindings/vectorio/__init__.c index c74783426..12fb4d72b 100644 --- a/shared-bindings/vectorio/__init__.c +++ b/shared-bindings/vectorio/__init__.c @@ -23,5 +23,5 @@ STATIC MP_DEFINE_CONST_DICT(vectorio_module_globals, vectorio_module_globals_tab const mp_obj_module_t vectorio_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&vectorio_module_globals, + .globals = (mp_obj_dict_t *)&vectorio_module_globals, }; diff --git a/shared-bindings/watchdog/WatchDogMode.c b/shared-bindings/watchdog/WatchDogMode.c index 71512bdf8..513884cdf 100644 --- a/shared-bindings/watchdog/WatchDogMode.c +++ b/shared-bindings/watchdog/WatchDogMode.c @@ -83,12 +83,11 @@ STATIC void watchdog_watchdogmode_print(const mp_print_t *print, mp_obj_t self_i qstr runmode = MP_QSTR_None; if (MP_OBJ_TO_PTR(self_in) == MP_ROM_PTR(&watchdog_watchdogmode_raise_obj)) { runmode = MP_QSTR_RAISE; - } - else if (MP_OBJ_TO_PTR(self_in) == MP_ROM_PTR(&watchdog_watchdogmode_reset_obj)) { + } else if (MP_OBJ_TO_PTR(self_in) == MP_ROM_PTR(&watchdog_watchdogmode_reset_obj)) { runmode = MP_QSTR_RESET; } mp_printf(print, "%q.%q.%q", MP_QSTR_watchdog, MP_QSTR_WatchDogMode, - runmode); + runmode); } const mp_obj_type_t watchdog_watchdogmode_type = { diff --git a/shared-bindings/watchdog/WatchDogTimer.c b/shared-bindings/watchdog/WatchDogTimer.c index 575021a21..a27d26c20 100644 --- a/shared-bindings/watchdog/WatchDogTimer.c +++ b/shared-bindings/watchdog/WatchDogTimer.c @@ -177,5 +177,5 @@ const mp_obj_type_t watchdog_watchdogtimer_type = { { &mp_type_type }, .name = MP_QSTR_WatchDogTimer, // .make_new = watchdog_watchdogtimer_make_new, - .locals_dict = (mp_obj_dict_t*)&watchdog_watchdogtimer_locals_dict, + .locals_dict = (mp_obj_dict_t *)&watchdog_watchdogtimer_locals_dict, }; diff --git a/shared-bindings/watchdog/__init__.c b/shared-bindings/watchdog/__init__.c index 76e631729..0911aca28 100644 --- a/shared-bindings/watchdog/__init__.c +++ b/shared-bindings/watchdog/__init__.c @@ -64,7 +64,7 @@ mp_obj_exception_t mp_watchdog_timeout_exception = { .traceback_alloc = 0, .traceback_len = 0, .traceback_data = NULL, - .args = (mp_obj_tuple_t*)&mp_const_empty_tuple_obj, + .args = (mp_obj_tuple_t *)&mp_const_empty_tuple_obj, }; STATIC const mp_rom_map_elem_t watchdog_module_globals_table[] = { @@ -77,5 +77,5 @@ STATIC MP_DEFINE_CONST_DICT(watchdog_module_globals, watchdog_module_globals_tab const mp_obj_module_t watchdog_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&watchdog_module_globals, + .globals = (mp_obj_dict_t *)&watchdog_module_globals, }; diff --git a/shared-bindings/wifi/Radio.c b/shared-bindings/wifi/Radio.c index 8181fc4c9..5c7fe1492 100644 --- a/shared-bindings/wifi/Radio.c +++ b/shared-bindings/wifi/Radio.c @@ -132,7 +132,7 @@ STATIC mp_obj_t wifi_radio_set_hostname(mp_obj_t self_in, mp_obj_t hostname_in) mp_raise_ValueError(translate("Hostname must be between 1 and 253 characters")); } - regex_t regex; //validate hostname according to RFC 1123 + regex_t regex; // validate hostname according to RFC 1123 regcomp(®ex,"^(([a-z0-9]|[a-z0-9][a-z0-9\\-]{0,61}[a-z0-9])\\.)*([a-z0-9]|[a-z0-9][a-z0-9\\-]{0,61}[a-z0-9])$", REG_EXTENDED | REG_ICASE | REG_NOSUB); if (regexec(®ex, hostname.buf, 0, NULL, 0)) { mp_raise_ValueError(translate("invalid hostname")); @@ -179,7 +179,7 @@ STATIC mp_obj_t wifi_radio_connect(size_t n_args, const mp_obj_t *pos_args, mp_m static const mp_arg_t allowed_args[] = { { MP_QSTR_ssid, MP_ARG_REQUIRED | MP_ARG_OBJ }, { MP_QSTR_password, MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, - { MP_QSTR_channel, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, + { MP_QSTR_channel, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} }, { MP_QSTR_bssid, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} }, { MP_QSTR_timeout, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, }; diff --git a/shared-bindings/wifi/Radio.h b/shared-bindings/wifi/Radio.h index 64c1052f7..333c82bab 100644 --- a/shared-bindings/wifi/Radio.h +++ b/shared-bindings/wifi/Radio.h @@ -82,7 +82,7 @@ extern mp_obj_t common_hal_wifi_radio_get_mac_address(wifi_radio_obj_t *self); extern mp_obj_t common_hal_wifi_radio_start_scanning_networks(wifi_radio_obj_t *self); extern void common_hal_wifi_radio_stop_scanning_networks(wifi_radio_obj_t *self); -extern wifi_radio_error_t common_hal_wifi_radio_connect(wifi_radio_obj_t *self, uint8_t* ssid, size_t ssid_len, uint8_t* password, size_t password_len, uint8_t channel, mp_float_t timeout, uint8_t* bssid, size_t bssid_len); +extern wifi_radio_error_t common_hal_wifi_radio_connect(wifi_radio_obj_t *self, uint8_t *ssid, size_t ssid_len, uint8_t *password, size_t password_len, uint8_t channel, mp_float_t timeout, uint8_t *bssid, size_t bssid_len); extern mp_obj_t common_hal_wifi_radio_get_ap_info(wifi_radio_obj_t *self); extern mp_obj_t common_hal_wifi_radio_get_ipv4_dns(wifi_radio_obj_t *self); diff --git a/shared-bindings/wifi/__init__.c b/shared-bindings/wifi/__init__.c index 352ceb331..38bd1bf07 100644 --- a/shared-bindings/wifi/__init__.c +++ b/shared-bindings/wifi/__init__.c @@ -66,5 +66,5 @@ STATIC MP_DEFINE_CONST_DICT(wifi_module_globals, wifi_module_globals_table); const mp_obj_module_t wifi_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&wifi_module_globals, + .globals = (mp_obj_dict_t *)&wifi_module_globals, }; diff --git a/shared-bindings/wiznet/__init__.c b/shared-bindings/wiznet/__init__.c index 8df06b546..68402fd10 100644 --- a/shared-bindings/wiznet/__init__.c +++ b/shared-bindings/wiznet/__init__.c @@ -47,13 +47,13 @@ extern const mod_network_nic_type_t mod_network_nic_type_wiznet5k; STATIC const mp_rom_map_elem_t mp_module_wiznet_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_wiznet) }, -#ifdef MICROPY_PY_WIZNET5K + #ifdef MICROPY_PY_WIZNET5K { MP_ROM_QSTR(MP_QSTR_WIZNET5K), MP_ROM_PTR(&mod_network_nic_type_wiznet5k) }, -#endif // MICROPY_PY_WIZNET5K + #endif // MICROPY_PY_WIZNET5K }; STATIC MP_DEFINE_CONST_DICT(mp_module_wiznet_globals, mp_module_wiznet_globals_table); const mp_obj_module_t wiznet_module = { .base = { &mp_type_module }, - .globals = (mp_obj_dict_t*)&mp_module_wiznet_globals, + .globals = (mp_obj_dict_t *)&mp_module_wiznet_globals, }; diff --git a/shared-bindings/wiznet/wiznet5k.c b/shared-bindings/wiznet/wiznet5k.c index 5e9a3a9fb..9ee1c6d58 100644 --- a/shared-bindings/wiznet/wiznet5k.c +++ b/shared-bindings/wiznet/wiznet5k.c @@ -80,7 +80,9 @@ STATIC mp_obj_t wiznet5k_make_new(const mp_obj_type_t *type, size_t n_args, cons const mcu_pin_obj_t *rst = validate_obj_is_free_pin_or_none(args[ARG_rst].u_obj); mp_obj_t ret = wiznet5k_create(args[ARG_spi].u_obj, cs, rst); - if (args[ARG_dhcp].u_bool) wiznet5k_start_dhcp(); + if (args[ARG_dhcp].u_bool) { + wiznet5k_start_dhcp(); + } return ret; } @@ -118,10 +120,14 @@ STATIC mp_obj_t wiznet5k_dhcp_set_value(mp_obj_t self_in, mp_obj_t value) { (void)self_in; if (mp_obj_is_true(value)) { int ret = wiznet5k_start_dhcp(); - if (ret) mp_raise_OSError(ret); + if (ret) { + mp_raise_OSError(ret); + } } else { int ret = wiznet5k_stop_dhcp(); - if (ret) mp_raise_OSError(ret); + if (ret) { + mp_raise_OSError(ret); + } } return mp_const_none; } @@ -183,7 +189,7 @@ const mod_network_nic_type_t mod_network_nic_type_wiznet5k = { { &mp_type_type }, .name = MP_QSTR_WIZNET5K, .make_new = wiznet5k_make_new, - .locals_dict = (mp_obj_dict_t*)&wiznet5k_locals_dict, + .locals_dict = (mp_obj_dict_t *)&wiznet5k_locals_dict, }, .gethostbyname = wiznet5k_gethostbyname, .socket = wiznet5k_socket_socket, |
