diff --git a/Makefile b/Makefile index 88f8c54ad2..c834e413b1 100644 --- a/Makefile +++ b/Makefile @@ -227,7 +227,7 @@ pseudoxml: all-source: locale/circuitpython.pot: all-source - find $(TRANSLATE_SOURCES) -type d \( $(TRANSLATE_SOURCES_EXC) \) -prune -o -type f \( -iname "*.c" -o -iname "*.h" \) -print | (LC_ALL=C sort) | xgettext -f- -L C -s --add-location=file --keyword=translate --keyword=MP_ERROR_TEXT -o - | sed -e '/"POT-Creation-Date: /d' > $@ + find $(TRANSLATE_SOURCES) -type d \( $(TRANSLATE_SOURCES_EXC) \) -prune -o -type f \( -iname "*.c" -o -iname "*.h" \) -print | (LC_ALL=C sort) | xgettext -f- -L C -s --add-location=file --keyword=MP_ERROR_TEXT -o - | sed -e '/"POT-Creation-Date: /d' > $@ # Historically, `make translate` updated the .pot file and ran msgmerge. # However, this was a frequent source of merge conflicts. Weblate can perform diff --git a/devices/ble_hci/common-hal/_bleio/Adapter.c b/devices/ble_hci/common-hal/_bleio/Adapter.c index b1f71b8cde..06a42cc6e5 100644 --- a/devices/ble_hci/common-hal/_bleio/Adapter.c +++ b/devices/ble_hci/common-hal/_bleio/Adapter.c @@ -180,7 +180,7 @@ STATIC void add_generic_services(bleio_adapter_obj_t *adapter) { STATIC void check_enabled(bleio_adapter_obj_t *adapter) { if (!common_hal_bleio_adapter_get_enabled(adapter)) { - mp_raise_bleio_BluetoothError(translate("Adapter not enabled")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Adapter not enabled")); } } @@ -297,18 +297,18 @@ STATIC void bleio_adapter_hci_init(bleio_adapter_obj_t *self) { // Get version information. if (hci_read_local_version(&self->hci_version, &self->hci_revision, &self->lmp_version, &self->manufacturer, &self->lmp_subversion) != HCI_OK) { - mp_raise_bleio_BluetoothError(translate("Could not read HCI version")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Could not read HCI version")); } // Get supported features. if (hci_le_read_local_supported_features(self->features) != HCI_OK) { - mp_raise_bleio_BluetoothError(translate("Could not read BLE features")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Could not read BLE features")); } // Enabled desired events. // Most importantly, includes: // BT_EVT_MASK_LE_META_EVENT BT_EVT_BIT(61) if (hci_set_event_mask(0x3FFFFFFFFFFFFFFF) != HCI_OK) { - mp_raise_bleio_BluetoothError(translate("Could not set event mask")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Could not set event mask")); } // The default events for LE are: // BT_EVT_MASK_LE_CONN_COMPLETE, BT_EVT_MASK_LE_ADVERTISING_REPORT, @@ -329,7 +329,7 @@ STATIC void bleio_adapter_hci_init(bleio_adapter_obj_t *self) { uint16_t acl_max_num; uint16_t sco_max_num; if (hci_read_buffer_size(&acl_max_len, &sco_max_len, &acl_max_num, &sco_max_num) != HCI_OK) { - mp_raise_bleio_BluetoothError(translate("Could not read BLE buffer info")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Could not read BLE buffer info")); } self->max_acl_buffer_len = acl_max_len; self->max_acl_num_buffers = acl_max_num; @@ -339,7 +339,7 @@ STATIC void bleio_adapter_hci_init(bleio_adapter_obj_t *self) { if (BT_FEAT_LE_EXT_ADV(self->features)) { uint16_t max_adv_data_len; if (hci_le_read_maximum_advertising_data_length(&max_adv_data_len) != HCI_OK) { - mp_raise_bleio_BluetoothError(translate("Could not get max advertising length")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Could not get max advertising length")); } self->max_adv_data_len = max_adv_data_len; } else { @@ -472,7 +472,7 @@ mp_obj_t common_hal_bleio_adapter_start_scan(bleio_adapter_obj_t *self, uint8_t if (self->scan_results != NULL) { if (!shared_module_bleio_scanresults_get_done(self->scan_results)) { - mp_raise_bleio_BluetoothError(translate("Scan already in progress. Stop with stop_scan.")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Scan already in progress. Stop with stop_scan.")); } self->scan_results = NULL; } @@ -601,7 +601,7 @@ mp_obj_t common_hal_bleio_adapter_connect(bleio_adapter_obj_t *self, bleio_addre // uint16_t conn_handle = event_info.conn_handle; // if (conn_handle == BLE_CONN_HANDLE_INVALID) { - // mp_raise_bleio_BluetoothError(translate("Failed to connect: timeout")); + // mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Failed to connect: timeout")); // } // // Negotiate for better PHY, larger MTU and data lengths since we are the central. These are @@ -622,14 +622,14 @@ mp_obj_t common_hal_bleio_adapter_connect(bleio_adapter_obj_t *self, bleio_addre // } // } - mp_raise_bleio_BluetoothError(translate("Failed to connect: internal error")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Failed to connect: internal error")); return mp_const_none; } STATIC void check_data_fit(size_t data_len, bool connectable) { if (data_len > MAX_ADVERTISEMENT_SIZE) { - mp_raise_ValueError(translate("Data too large for advertisement packet")); + mp_raise_ValueError(MP_ERROR_TEXT("Data too large for advertisement packet")); } } @@ -686,7 +686,7 @@ uint32_t _common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, if (extended) { if (!BT_FEAT_LE_EXT_ADV(self->features)) { - mp_raise_bleio_BluetoothError(translate("Data length needs extended advertising, but this adapter does not support it")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Data length needs extended advertising, but this adapter does not support it")); } uint16_t props = 0; @@ -801,7 +801,7 @@ void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, check_data_fit(scan_response_data_bufinfo->len, connectable); if (advertising_data_bufinfo->len > MAX_ADVERTISEMENT_SIZE && scan_response_data_bufinfo->len > 0) { - mp_raise_bleio_BluetoothError(translate("Extended advertisements with scan response not supported.")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Extended advertisements with scan response not supported.")); } // Anonymous mode requires a timeout so that we don't continue to broadcast @@ -811,13 +811,13 @@ void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, timeout = MAX_ANONYMOUS_ADV_TIMEOUT_SECS; } else { if (timeout > MAX_LIMITED_DISCOVERABLE_ADV_TIMEOUT_SECS) { - mp_raise_bleio_BluetoothError(translate("Timeout is too long: Maximum timeout length is %d seconds"), + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Timeout is too long: Maximum timeout length is %d seconds"), MAX_LIMITED_DISCOVERABLE_ADV_TIMEOUT_SECS); } } if (tx_power != 0) { - mp_raise_NotImplementedError(translate("Only tx_power=0 supported")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("Only tx_power=0 supported")); } const uint32_t result = _common_hal_bleio_adapter_start_advertising( @@ -829,7 +829,7 @@ void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, tx_power, directed_to); if (result) { - mp_raise_bleio_BluetoothError(translate("Already advertising")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Already advertising")); } self->circuitpython_advertising = false; } diff --git a/devices/ble_hci/common-hal/_bleio/Attribute.c b/devices/ble_hci/common-hal/_bleio/Attribute.c index b1b31d604f..77a5a4df9b 100644 --- a/devices/ble_hci/common-hal/_bleio/Attribute.c +++ b/devices/ble_hci/common-hal/_bleio/Attribute.c @@ -45,5 +45,5 @@ bleio_uuid_obj_t *bleio_attribute_get_uuid(mp_obj_t *attribute) { bleio_service_obj_t *service = MP_OBJ_TO_PTR(attribute); return service->uuid; } - mp_raise_RuntimeError(translate("Invalid BLE attribute")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Invalid BLE attribute")); } diff --git a/devices/ble_hci/common-hal/_bleio/Characteristic.c b/devices/ble_hci/common-hal/_bleio/Characteristic.c index b6e144f191..fe501ceb5c 100644 --- a/devices/ble_hci/common-hal/_bleio/Characteristic.c +++ b/devices/ble_hci/common-hal/_bleio/Characteristic.c @@ -108,10 +108,10 @@ size_t common_hal_bleio_characteristic_get_value(bleio_characteristic_obj_t *sel void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self, mp_buffer_info_t *bufinfo) { if (self->fixed_length && bufinfo->len != self->max_length) { - mp_raise_ValueError(translate("Value length != required fixed length")); + mp_raise_ValueError(MP_ERROR_TEXT("Value length != required fixed length")); } if (bufinfo->len > self->max_length) { - mp_raise_ValueError(translate("Value length > max_length")); + mp_raise_ValueError(MP_ERROR_TEXT("Value length > max_length")); } // Do GATT operations only if this characteristic has been added to a registered service. @@ -125,7 +125,7 @@ void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self, } else if (self->props & CHAR_PROP_WRITE_NO_RESPONSE) { // att_write_cmd(conn_handle, self->handle, bufinfo->buff, bufinfo->len); } else { - mp_raise_bleio_BluetoothError(translate("Characteristic not writable")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Characteristic not writable")); } } else { // Always write the value locally even if no connections are active. @@ -168,7 +168,7 @@ bleio_characteristic_properties_t common_hal_bleio_characteristic_get_properties void common_hal_bleio_characteristic_add_descriptor(bleio_characteristic_obj_t *self, bleio_descriptor_obj_t *descriptor) { if (self->handle != common_hal_bleio_adapter_obj.last_added_characteristic_handle) { mp_raise_bleio_BluetoothError( - translate("Descriptor can only be added to most recently added characteristic")); + MP_ERROR_TEXT("Descriptor can only be added to most recently added characteristic")); } descriptor->handle = bleio_adapter_add_attribute(&common_hal_bleio_adapter_obj, MP_OBJ_TO_PTR(descriptor)); @@ -181,11 +181,11 @@ void common_hal_bleio_characteristic_add_descriptor(bleio_characteristic_obj_t * void common_hal_bleio_characteristic_set_cccd(bleio_characteristic_obj_t *self, bool notify, bool indicate) { if (self->cccd == NULL) { - mp_raise_bleio_BluetoothError(translate("No CCCD for this Characteristic")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("No CCCD for this Characteristic")); } if (!common_hal_bleio_service_get_is_remote(self->service)) { - mp_raise_bleio_RoleError(translate("Can't set CCCD on local Characteristic")); + mp_raise_bleio_RoleError(MP_ERROR_TEXT("Can't set CCCD on local Characteristic")); } const uint16_t conn_handle = bleio_connection_get_conn_handle(self->service->connection); @@ -199,7 +199,7 @@ void common_hal_bleio_characteristic_set_cccd(bleio_characteristic_obj_t *self, (void)cccd_value; // uint8_t rsp[sizeof(bt_att_error_rsp)]; // if (att_write_req(conn_handle, self->cccd->handle, &cccd_value, sizeof(cccd_value)) == 0) { - // mp_raise_bleio_BluetoothError(translate("Could not write CCCD")); + // mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Could not write CCCD")); // } } diff --git a/devices/ble_hci/common-hal/_bleio/Connection.c b/devices/ble_hci/common-hal/_bleio/Connection.c index b1e2ac6f39..059124ddad 100644 --- a/devices/ble_hci/common-hal/_bleio/Connection.c +++ b/devices/ble_hci/common-hal/_bleio/Connection.c @@ -640,7 +640,7 @@ void common_hal_bleio_connection_set_connection_interval(bleio_connection_intern // mp_obj_t uuid_obj; // while ((uuid_obj = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { // if (!mp_obj_is_type(uuid_obj, &bleio_uuid_type)) { -// mp_raise_TypeError(translate("non-UUID found in service_uuids_whitelist")); +// mp_raise_TypeError(MP_ERROR_TEXT("non-UUID found in service_uuids_whitelist")); // } // bleio_uuid_obj_t *uuid = MP_OBJ_TO_PTR(uuid_obj); diff --git a/devices/ble_hci/common-hal/_bleio/Descriptor.c b/devices/ble_hci/common-hal/_bleio/Descriptor.c index 444d57fb3d..99d0ab274c 100644 --- a/devices/ble_hci/common-hal/_bleio/Descriptor.c +++ b/devices/ble_hci/common-hal/_bleio/Descriptor.c @@ -43,7 +43,7 @@ void common_hal_bleio_descriptor_construct(bleio_descriptor_obj_t *self, bleio_c const mp_int_t max_length_max = fixed_length ? BLE_GATTS_FIX_ATTR_LEN_MAX : BLE_GATTS_VAR_ATTR_LEN_MAX; if (max_length < 0 || max_length > max_length_max) { - mp_raise_ValueError_varg(translate("max_length must be 0-%d when fixed_length is %s"), + mp_raise_ValueError_varg(MP_ERROR_TEXT("max_length must be 0-%d when fixed_length is %s"), max_length_max, fixed_length ? "True" : "False"); } self->max_length = max_length; @@ -85,10 +85,10 @@ size_t common_hal_bleio_descriptor_get_value(bleio_descriptor_obj_t *self, uint8 void common_hal_bleio_descriptor_set_value(bleio_descriptor_obj_t *self, mp_buffer_info_t *bufinfo) { if (self->fixed_length && bufinfo->len != self->max_length) { - mp_raise_ValueError(translate("Value length != required fixed length")); + mp_raise_ValueError(MP_ERROR_TEXT("Value length != required fixed length")); } if (bufinfo->len > self->max_length) { - mp_raise_ValueError(translate("Value length > max_length")); + mp_raise_ValueError(MP_ERROR_TEXT("Value length > max_length")); } self->value = mp_obj_new_bytes(bufinfo->buf, bufinfo->len); diff --git a/devices/ble_hci/common-hal/_bleio/PacketBuffer.c b/devices/ble_hci/common-hal/_bleio/PacketBuffer.c index 24295b025e..e6cdee9a75 100644 --- a/devices/ble_hci/common-hal/_bleio/PacketBuffer.c +++ b/devices/ble_hci/common-hal/_bleio/PacketBuffer.c @@ -102,7 +102,7 @@ void common_hal_bleio_packet_buffer_construct( if (incoming) { if (!ringbuf_alloc(&self->ringbuf, buffer_size * (sizeof(uint16_t) + max_packet_size))) { - mp_raise_ValueError(translate("Buffer too large and unable to allocate")); + mp_raise_ValueError(MP_ERROR_TEXT("Buffer too large and unable to allocate")); } } @@ -151,7 +151,7 @@ mp_int_t common_hal_bleio_packet_buffer_readinto(bleio_packet_buffer_obj_t *self mp_int_t common_hal_bleio_packet_buffer_write(bleio_packet_buffer_obj_t *self, const uint8_t *data, size_t len, uint8_t *header, size_t header_len) { if (self->outgoing[0] == NULL) { - mp_raise_bleio_BluetoothError(translate("Writes not supported on Characteristic")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Writes not supported on Characteristic")); } if (self->conn_handle == BLE_CONN_HANDLE_INVALID) { return -1; @@ -160,7 +160,7 @@ mp_int_t common_hal_bleio_packet_buffer_write(bleio_packet_buffer_obj_t *self, if (len + header_len > outgoing_packet_length) { // Supplied data will not fit in a single BLE packet. - mp_raise_ValueError(translate("Total data to write is larger than outgoing_packet_length")); + mp_raise_ValueError(MP_ERROR_TEXT("Total data to write is larger than outgoing_packet_length")); } if (len + self->pending_size > outgoing_packet_length) { diff --git a/devices/ble_hci/common-hal/_bleio/Service.c b/devices/ble_hci/common-hal/_bleio/Service.c index 6aff981f8e..a20f6d3a55 100644 --- a/devices/ble_hci/common-hal/_bleio/Service.c +++ b/devices/ble_hci/common-hal/_bleio/Service.c @@ -53,7 +53,7 @@ uint32_t _common_hal_bleio_service_construct(bleio_service_obj_t *self, bleio_uu void common_hal_bleio_service_construct(bleio_service_obj_t *self, bleio_uuid_obj_t *uuid, bool is_secondary) { if (_common_hal_bleio_service_construct(self, uuid, is_secondary, mp_obj_new_list(0, NULL)) != 0) { - mp_raise_RuntimeError(translate("Failed to add service")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Failed to add service")); } } @@ -89,7 +89,7 @@ void common_hal_bleio_service_add_characteristic(bleio_service_obj_t *self, if (self->handle != common_hal_bleio_adapter_obj.last_added_service_handle) { mp_raise_bleio_BluetoothError( - translate("Characteristic can only be added to most recently added service")); + MP_ERROR_TEXT("Characteristic can only be added to most recently added service")); } characteristic->decl_handle = bleio_adapter_add_attribute( &common_hal_bleio_adapter_obj, MP_OBJ_TO_PTR(characteristic)); diff --git a/devices/ble_hci/common-hal/_bleio/__init__.c b/devices/ble_hci/common-hal/_bleio/__init__.c index a22bcfb082..be318a30d6 100644 --- a/devices/ble_hci/common-hal/_bleio/__init__.c +++ b/devices/ble_hci/common-hal/_bleio/__init__.c @@ -50,10 +50,10 @@ bool vm_used_ble; // switch (sec_status) { // case BLE_GAP_SEC_STATUS_UNSPECIFIED: -// mp_raise_bleio_SecurityError(translate("Unspecified issue. Can be that the pairing prompt on the other device was declined or ignored.")); +// mp_raise_bleio_SecurityError(MP_ERROR_TEXT("Unspecified issue. Can be that the pairing prompt on the other device was declined or ignored.")); // return; // default: -// mp_raise_bleio_SecurityError(translate("Unknown security error: 0x%04x"), sec_status); +// mp_raise_bleio_SecurityError(MP_ERROR_TEXT("Unknown security error: 0x%04x"), sec_status); // } // } @@ -96,14 +96,14 @@ bleio_adapter_obj_t common_hal_bleio_adapter_obj = { bleio_adapter_obj_t *common_hal_bleio_allocate_adapter_or_raise(void) { if (common_hal_bleio_adapter_obj.allocated) { - mp_raise_RuntimeError(translate("Too many Adapters")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Too many Adapters")); } return &common_hal_bleio_adapter_obj; } void common_hal_bleio_check_connected(uint16_t conn_handle) { if (conn_handle == BLE_CONN_HANDLE_INVALID) { - mp_raise_ConnectionError(translate("Not connected")); + mp_raise_ConnectionError(MP_ERROR_TEXT("Not connected")); } } diff --git a/devices/ble_hci/common-hal/_bleio/att.c b/devices/ble_hci/common-hal/_bleio/att.c index 05099ec718..a15907d81f 100644 --- a/devices/ble_hci/common-hal/_bleio/att.c +++ b/devices/ble_hci/common-hal/_bleio/att.c @@ -1727,52 +1727,52 @@ static void check_att_err(uint8_t err) { case 0: return; case BT_ATT_ERR_INVALID_HANDLE: - msg = translate("Invalid handle"); + msg = MP_ERROR_TEXT("Invalid handle"); break; case BT_ATT_ERR_READ_NOT_PERMITTED: - msg = translate("Read not permitted"); + msg = MP_ERROR_TEXT("Read not permitted"); break; case BT_ATT_ERR_WRITE_NOT_PERMITTED: - msg = translate("Write not permitted"); + msg = MP_ERROR_TEXT("Write not permitted"); break; case BT_ATT_ERR_INVALID_PDU: - msg = translate("Invalid PDU"); + msg = MP_ERROR_TEXT("Invalid PDU"); break; case BT_ATT_ERR_NOT_SUPPORTED: - msg = translate("Not supported"); + msg = MP_ERROR_TEXT("Not supported"); break; case BT_ATT_ERR_INVALID_OFFSET: - msg = translate("Invalid offset"); + msg = MP_ERROR_TEXT("Invalid offset"); break; case BT_ATT_ERR_PREPARE_QUEUE_FULL: - msg = translate("Prepare queue full"); + msg = MP_ERROR_TEXT("Prepare queue full"); break; case BT_ATT_ERR_ATTRIBUTE_NOT_FOUND: - msg = translate("Attribute not found"); + msg = MP_ERROR_TEXT("Attribute not found"); break; case BT_ATT_ERR_ATTRIBUTE_NOT_LONG: - msg = translate("Attribute not long"); + msg = MP_ERROR_TEXT("Attribute not long"); break; case BT_ATT_ERR_ENCRYPTION_KEY_SIZE: - msg = translate("Encryption key size"); + msg = MP_ERROR_TEXT("Encryption key size"); break; case BT_ATT_ERR_INVALID_ATTRIBUTE_LEN: - msg = translate("Invalid attribute length"); + msg = MP_ERROR_TEXT("Invalid attribute length"); break; case BT_ATT_ERR_UNLIKELY: - msg = translate("Unlikely"); + msg = MP_ERROR_TEXT("Unlikely"); break; case BT_ATT_ERR_UNSUPPORTED_GROUP_TYPE: - msg = translate("Unsupported group type"); + msg = MP_ERROR_TEXT("Unsupported group type"); break; case BT_ATT_ERR_INSUFFICIENT_RESOURCES: - msg = translate("Insufficient resources"); + msg = MP_ERROR_TEXT("Insufficient resources"); break; case BT_ATT_ERR_DB_OUT_OF_SYNC: - msg = translate("DB out of sync"); + msg = MP_ERROR_TEXT("DB out of sync"); break; case BT_ATT_ERR_VALUE_NOT_ALLOWED: - msg = translate("Value not allowed"); + msg = MP_ERROR_TEXT("Value not allowed"); break; } if (msg) { @@ -1781,15 +1781,15 @@ static void check_att_err(uint8_t err) { switch (err) { case BT_ATT_ERR_AUTHENTICATION: - msg = translate("Insufficient authentication"); + msg = MP_ERROR_TEXT("Insufficient authentication"); break; case BT_ATT_ERR_INSUFFICIENT_ENCRYPTION: - msg = translate("Insufficient encryption"); + msg = MP_ERROR_TEXT("Insufficient encryption"); break; } if (msg) { mp_raise_bleio_SecurityError(msg); } - mp_raise_bleio_BluetoothError(translate("Unknown ATT error: 0x%02x"), err); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Unknown ATT error: 0x%02x"), err); } diff --git a/devices/ble_hci/common-hal/_bleio/hci.c b/devices/ble_hci/common-hal/_bleio/hci.c index ec1663589d..00a3b114e7 100644 --- a/devices/ble_hci/common-hal/_bleio/hci.c +++ b/devices/ble_hci/common-hal/_bleio/hci.c @@ -770,35 +770,35 @@ void hci_check_error(hci_result_t result) { return; case HCI_RESPONSE_TIMEOUT: - mp_raise_bleio_BluetoothError(translate("Timeout waiting for HCI response")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Timeout waiting for HCI response")); return; case HCI_WRITE_TIMEOUT: - mp_raise_bleio_BluetoothError(translate("Timeout waiting to write HCI request")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Timeout waiting to write HCI request")); return; case HCI_READ_ERROR: - mp_raise_bleio_BluetoothError(translate("Error reading from HCI adapter")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Error reading from HCI adapter")); return; case HCI_WRITE_ERROR: - mp_raise_bleio_BluetoothError(translate("Error writing to HCI adapter")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Error writing to HCI adapter")); return; case HCI_PACKET_SIZE_ERROR: - mp_raise_RuntimeError(translate("HCI packet size mismatch")); + mp_raise_RuntimeError(MP_ERROR_TEXT("HCI packet size mismatch")); return; case HCI_ATT_ERROR: - mp_raise_RuntimeError(translate("Error in ATT protocol code")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Error in ATT protocol code")); return; default: // Should be an HCI status error, > 0. if (result > 0) { - mp_raise_bleio_BluetoothError(translate("HCI status error: %02x"), result); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("HCI status error: %02x"), result); } else { - mp_raise_bleio_BluetoothError(translate("Unknown hci_result_t: %d"), result); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Unknown hci_result_t: %d"), result); } return; } diff --git a/extmod/ulab b/extmod/ulab index 2df210f87a..eacb0c9af4 160000 --- a/extmod/ulab +++ b/extmod/ulab @@ -1 +1 @@ -Subproject commit 2df210f87a79deedc9003b1bbd6015a2fea7c03e +Subproject commit eacb0c9af47f85f5d4864b721c3b28661364e8e3 diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 0aaca6ce69..e8530dab05 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -2958,6 +2958,10 @@ msgstr "" msgid "dtype must be float, or complex" msgstr "" +#: extmod/ulab/code/ndarray_operators.c +msgid "dtype of int32 is not supported" +msgstr "" + #: py/objdeque.c msgid "empty" msgstr "" @@ -3822,6 +3826,10 @@ msgstr "" msgid "operation is not supported for given type" msgstr "" +#: extmod/ulab/code/ndarray_operators.c +msgid "operation not supported for the input types" +msgstr "" + #: py/modbuiltins.c msgid "ord expects a character" msgstr "" diff --git a/main.c b/main.c index b4345b65e0..15a5bfafb4 100644 --- a/main.c +++ b/main.c @@ -147,7 +147,7 @@ STATIC supervisor_allocation *allocate_pystack(safe_mode_t safe_mode) { if (pystack) { return pystack; } - serial_write_compressed(translate("Invalid CIRCUITPY_PYSTACK_SIZE\n")); + serial_write_compressed(MP_ERROR_TEXT("Invalid CIRCUITPY_PYSTACK_SIZE\n")); } #endif return allocate_memory(CIRCUITPY_PYSTACK_SIZE, false, false); @@ -243,7 +243,7 @@ void supervisor_execution_status(void) { exception != NULL) { mp_printf(&mp_plat_print, "%d@%s %q", _exec_result.exception_line, _exec_result.exception_filename, exception->base.type->name); } else { - serial_write_compressed(translate("Done")); + serial_write_compressed(MP_ERROR_TEXT("Done")); } } #endif @@ -275,7 +275,7 @@ STATIC bool maybe_run_list(const char *const *filenames, size_t n_filenames) { return false; } mp_hal_stdout_tx_str(_current_executing_filename); - serial_write_compressed(translate(" output:\n")); + serial_write_compressed(MP_ERROR_TEXT(" output:\n")); #if CIRCUITPY_STATUS_BAR supervisor_status_bar_update(); @@ -393,12 +393,12 @@ STATIC void cleanup_after_vm(supervisor_allocation *heap, supervisor_allocation STATIC void print_code_py_status_message(safe_mode_t safe_mode) { if (autoreload_is_enabled()) { serial_write_compressed( - translate("Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.\n")); + MP_ERROR_TEXT("Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.\n")); } else { - serial_write_compressed(translate("Auto-reload is off.\n")); + serial_write_compressed(MP_ERROR_TEXT("Auto-reload is off.\n")); } if (safe_mode != SAFE_MODE_NONE) { - serial_write_compressed(translate("Running in safe mode! Not running saved code.\n")); + serial_write_compressed(MP_ERROR_TEXT("Running in safe mode! Not running saved code.\n")); } } @@ -463,7 +463,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool *simulate_reset) { found_main = maybe_run_list(filenames, MP_ARRAY_SIZE(filenames)); if (!found_main) { serial_write(info->filename); - serial_write_compressed(translate(" not found.\n")); + serial_write_compressed(MP_ERROR_TEXT(" not found.\n")); } } } @@ -476,7 +476,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool *simulate_reset) { if (!found_main) { found_main = maybe_run_list(double_extension_filenames, MP_ARRAY_SIZE(double_extension_filenames)); if (found_main) { - serial_write_compressed(translate("WARNING: Your code filename has two extensions\n")); + serial_write_compressed(MP_ERROR_TEXT("WARNING: Your code filename has two extensions\n")); } } #else @@ -487,9 +487,9 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool *simulate_reset) { // Print done before resetting everything so that we get the message over // BLE before it is reset and we have a delay before reconnect. if ((_exec_result.return_code & PYEXEC_RELOAD) && supervisor_get_run_reason() == RUN_REASON_AUTO_RELOAD) { - serial_write_compressed(translate("\nCode stopped by auto-reload. Reloading soon.\n")); + serial_write_compressed(MP_ERROR_TEXT("\nCode stopped by auto-reload. Reloading soon.\n")); } else { - serial_write_compressed(translate("\nCode done running.\n")); + serial_write_compressed(MP_ERROR_TEXT("\nCode done running.\n")); } @@ -610,7 +610,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool *simulate_reset) { // sleep. #if CIRCUITPY_ALARM if (fake_sleeping && common_hal_alarm_woken_from_sleep()) { - serial_write_compressed(translate("Woken up by alarm.\n")); + serial_write_compressed(MP_ERROR_TEXT("Woken up by alarm.\n")); supervisor_set_run_reason(RUN_REASON_STARTUP); skip_repl = true; break; @@ -628,7 +628,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool *simulate_reset) { printed_safe_mode_message = true; } serial_write("\r\n"); - serial_write_compressed(translate("Press any key to enter the REPL. Use CTRL-D to reload.\n")); + serial_write_compressed(MP_ERROR_TEXT("Press any key to enter the REPL. Use CTRL-D to reload.\n")); printed_press_any_key = true; } if (!serial_connected()) { @@ -673,7 +673,7 @@ STATIC bool run_code_py(safe_mode_t safe_mode, bool *simulate_reset) { // Does not return. } else { serial_write_compressed( - translate("Pretending to deep sleep until alarm, CTRL-C or file write.\n")); + MP_ERROR_TEXT("Pretending to deep sleep until alarm, CTRL-C or file write.\n")); fake_sleeping = true; } } else { @@ -856,9 +856,9 @@ STATIC void __attribute__ ((noinline)) run_boot_py(safe_mode_t safe_mode) { #if CIRCUITPY_MICROCONTROLLER && COMMON_HAL_MCU_PROCESSOR_UID_LENGTH > 0 uint8_t raw_id[COMMON_HAL_MCU_PROCESSOR_UID_LENGTH]; common_hal_mcu_processor_get_uid(raw_id); - mp_cprintf(&mp_plat_print, translate("UID:")); + mp_cprintf(&mp_plat_print, MP_ERROR_TEXT("UID:")); for (size_t i = 0; i < COMMON_HAL_MCU_PROCESSOR_UID_LENGTH; i++) { - mp_cprintf(&mp_plat_print, translate("%02X"), raw_id[i]); + mp_cprintf(&mp_plat_print, MP_ERROR_TEXT("%02X"), raw_id[i]); } mp_printf(&mp_plat_print, "\n"); port_boot_info(); @@ -1116,7 +1116,7 @@ int __attribute__((used)) main(void) { } if (exit_code == PYEXEC_FORCED_EXIT) { if (!simulate_reset) { - serial_write_compressed(translate("soft reboot\n")); + serial_write_compressed(MP_ERROR_TEXT("soft reboot\n")); } simulate_reset = false; if (pyexec_mode_kind == PYEXEC_MODE_FRIENDLY_REPL) { diff --git a/ports/atmel-samd/audio_dma.c b/ports/atmel-samd/audio_dma.c index 3d5cbf6790..287ef41b35 100644 --- a/ports/atmel-samd/audio_dma.c +++ b/ports/atmel-samd/audio_dma.c @@ -55,7 +55,7 @@ static bool audio_dma_allocated[AUDIO_DMA_CHANNEL_COUNT]; uint8_t find_sync_event_channel_raise() { uint8_t event_channel = find_sync_event_channel(); if (event_channel >= EVSYS_SYNCH_NUM) { - mp_raise_RuntimeError(translate("All sync event channels in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("All sync event channels in use")); } return event_channel; } @@ -109,7 +109,7 @@ static void audio_dma_convert_samples( *output_spacing = 1; if (*output_length > available_output_buffer_length) { - mp_raise_RuntimeError(translate("Internal audio buffer too small")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Internal audio buffer too small")); } uint32_t out_i = 0; diff --git a/ports/atmel-samd/bindings/samd/Clock.c b/ports/atmel-samd/bindings/samd/Clock.c index f483cfe376..c7ca6c59d6 100644 --- a/ports/atmel-samd/bindings/samd/Clock.c +++ b/ports/atmel-samd/bindings/samd/Clock.c @@ -105,10 +105,10 @@ STATIC mp_obj_t samd_clock_set_calibration(mp_obj_t self_in, mp_obj_t calibratio samd_clock_obj_t *self = MP_OBJ_TO_PTR(self_in); int ret = clock_set_calibration(self->type, self->index, mp_obj_get_int(calibration)); if (ret == -2) { - mp_raise_AttributeError(translate("calibration is read only")); + mp_raise_AttributeError(MP_ERROR_TEXT("calibration is read only")); } if (ret == -1) { - mp_raise_ValueError(translate("calibration is out of range")); + mp_raise_ValueError(MP_ERROR_TEXT("calibration is out of range")); } return mp_const_none; } diff --git a/ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.mk b/ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.mk index 7ef2af6ddb..a53261995d 100644 --- a/ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.mk +++ b/ports/atmel-samd/boards/arduino_nano_33_iot/mpconfigboard.mk @@ -13,3 +13,4 @@ LONGINT_IMPL = NONE CIRCUITPY_FULL_BUILD = 0 CIRCUITPY_RAINBOWIO = 0 +CIRCUITPY_NVM = 0 diff --git a/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h b/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h index d7ca2a107c..ee27e99cae 100644 --- a/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h +++ b/ports/atmel-samd/boards/circuitplayground_express/mpconfigboard.h @@ -23,7 +23,7 @@ #define CALIBRATE_CRYSTALLESS 1 // Explanation of how a user got into safe mode. -#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed both buttons at start up.") +#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed both buttons at start up.") // Increase stack size slightly due to CPX library import nesting #define CIRCUITPY_DEFAULT_STACK_SIZE (4248) // divisible by 8 diff --git a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h index 6ee5e0504b..2791d87ce5 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h +++ b/ports/atmel-samd/boards/circuitplayground_express_crickit/mpconfigboard.h @@ -23,7 +23,7 @@ #define CALIBRATE_CRYSTALLESS 1 // Explanation of how a user got into safe mode. -#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed both buttons at start up.") +#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed both buttons at start up.") // Increase stack size slightly due to CPX library import nesting #define CIRCUITPY_DEFAULT_STACK_SIZE (4248) // divisible by 8 diff --git a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h index c0f2d07e9d..55fd91a0fe 100644 --- a/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h +++ b/ports/atmel-samd/boards/circuitplayground_express_displayio/mpconfigboard.h @@ -23,7 +23,7 @@ #define CALIBRATE_CRYSTALLESS 1 // Explanation of how a user got into safe mode. -#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed both buttons at start up.") +#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed both buttons at start up.") // Increase stack size slightly due to CPX library import nesting. #define CIRCUITPY_DEFAULT_STACK_SIZE (4248) // divisible by 8 diff --git a/ports/atmel-samd/boards/meowmeow/mpconfigboard.h b/ports/atmel-samd/boards/meowmeow/mpconfigboard.h index ab5f652d1e..008ab5125d 100644 --- a/ports/atmel-samd/boards/meowmeow/mpconfigboard.h +++ b/ports/atmel-samd/boards/meowmeow/mpconfigboard.h @@ -6,7 +6,7 @@ #define CALIBRATE_CRYSTALLESS 1 // Explanation of how a user got into safe mode. -#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed both buttons at start up.") +#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed both buttons at start up.") #define DEFAULT_I2C_BUS_SCL (&pin_PA01) #define DEFAULT_I2C_BUS_SDA (&pin_PA00) diff --git a/ports/atmel-samd/common-hal/_pew/PewPew.c b/ports/atmel-samd/common-hal/_pew/PewPew.c index 4d8d7ccb83..8a009fdfe4 100644 --- a/ports/atmel-samd/common-hal/_pew/PewPew.c +++ b/ports/atmel-samd/common-hal/_pew/PewPew.c @@ -77,7 +77,7 @@ void pew_init() { // Find a spare timer. uint8_t index = find_free_timer(); if (index == 0xff) { - mp_raise_RuntimeError(translate("All timers in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("All timers in use")); } Tc *tc = tc_insts[index]; diff --git a/ports/atmel-samd/common-hal/alarm/__init__.c b/ports/atmel-samd/common-hal/alarm/__init__.c index f71e3c1806..1d0ebcfa24 100644 --- a/ports/atmel-samd/common-hal/alarm/__init__.c +++ b/ports/atmel-samd/common-hal/alarm/__init__.c @@ -148,7 +148,7 @@ mp_obj_t common_hal_alarm_light_sleep_until_alarms(size_t n_alarms, const mp_obj void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *alarms, size_t n_dios, digitalio_digitalinout_obj_t **preserve_dios) { if (n_dios > 0) { - mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_preserve_dios); + mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_preserve_dios); } _setup_sleep_alarms(true, n_alarms, alarms); } diff --git a/ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c b/ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c index dd2509b8c4..04717c748c 100644 --- a/ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c +++ b/ports/atmel-samd/common-hal/alarm/pin/PinAlarm.c @@ -235,9 +235,9 @@ static void pinalarm_set_alarms_light(size_t n_alarms, const mp_obj_t *alarms) { case PINALARM_ERR_NOEXTINT: raise_ValueError_invalid_pin(); case PINALARM_ERR_NOCHANNEL: - mp_raise_RuntimeError(translate("A hardware interrupt channel is already in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("A hardware interrupt channel is already in use")); default: - mp_raise_RuntimeError(translate("Unknown reason.")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Unknown reason.")); } } diff --git a/ports/atmel-samd/common-hal/alarm/time/TimeAlarm.c b/ports/atmel-samd/common-hal/alarm/time/TimeAlarm.c index 4c1d05feb2..a8f408181f 100644 --- a/ports/atmel-samd/common-hal/alarm/time/TimeAlarm.c +++ b/ports/atmel-samd/common-hal/alarm/time/TimeAlarm.c @@ -101,7 +101,7 @@ void alarm_time_timealarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ continue; } if (timealarm_set) { - mp_raise_ValueError(translate("Only one alarm.time alarm can be set")); + mp_raise_ValueError(MP_ERROR_TEXT("Only one alarm.time alarm can be set")); } timealarm = MP_OBJ_TO_PTR(alarms[i]); timealarm_set = true; diff --git a/ports/atmel-samd/common-hal/alarm/touch/TouchAlarm.c b/ports/atmel-samd/common-hal/alarm/touch/TouchAlarm.c index 88c73726ee..ea3437ec89 100644 --- a/ports/atmel-samd/common-hal/alarm/touch/TouchAlarm.c +++ b/ports/atmel-samd/common-hal/alarm/touch/TouchAlarm.c @@ -28,5 +28,5 @@ #include "shared-bindings/microcontroller/__init__.h" void common_hal_alarm_touch_touchalarm_construct(alarm_touch_touchalarm_obj_t *self, const mcu_pin_obj_t *pin) { - mp_raise_NotImplementedError(translate("Touch alarms not available")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("Touch alarms not available")); } diff --git a/ports/atmel-samd/common-hal/analogio/AnalogOut.c b/ports/atmel-samd/common-hal/analogio/AnalogOut.c index dbf9d5e8dd..38064ec67d 100644 --- a/ports/atmel-samd/common-hal/analogio/AnalogOut.c +++ b/ports/atmel-samd/common-hal/analogio/AnalogOut.c @@ -51,7 +51,7 @@ void common_hal_analogio_analogout_construct(analogio_analogout_obj_t *self, const mcu_pin_obj_t *pin) { #if !HAVE_ANALOGOUT - mp_raise_NotImplementedError(translate("No DAC on chip")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("No DAC on chip")); #else uint8_t channel; diff --git a/ports/atmel-samd/common-hal/audiobusio/I2SOut.c b/ports/atmel-samd/common-hal/audiobusio/I2SOut.c index 8ba18d7701..e1e69f6e52 100644 --- a/ports/atmel-samd/common-hal/audiobusio/I2SOut.c +++ b/ports/atmel-samd/common-hal/audiobusio/I2SOut.c @@ -99,7 +99,7 @@ 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, const mcu_pin_obj_t *main_clock, bool left_justified) { if (main_clock != NULL) { - mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_main_clock); + mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_main_clock); } uint8_t serializer = 0xff; uint8_t bc_clock_unit = 0xff; @@ -159,7 +159,7 @@ void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t *self, raise_ValueError_invalid_pin_name(MP_QSTR_word_select); } if (bc_clock_unit != ws_clock_unit) { - mp_raise_ValueError(translate("Bit clock and word select must share a clock unit")); + mp_raise_ValueError(MP_ERROR_TEXT("Bit clock and word select must share a clock unit")); } if (serializer == 0xff) { raise_ValueError_invalid_pin_name(MP_QSTR_data); @@ -176,12 +176,12 @@ void common_hal_audiobusio_i2sout_construct(audiobusio_i2sout_obj_t *self, } else { #ifdef SAMD21 if ((I2S->CTRLA.vec.SEREN & (1 << serializer)) != 0) { - mp_raise_RuntimeError(translate("Serializer in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Serializer in use")); } #endif #ifdef SAM_D5X_E5X if (I2S->CTRLA.bit.TXEN == 1) { - mp_raise_RuntimeError(translate("Serializer in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Serializer in use")); } #endif } @@ -233,7 +233,7 @@ void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t *self, } #ifdef SAMD21 if ((I2S->CTRLA.vec.CKEN & (1 << self->clock_unit)) == 1) { - mp_raise_RuntimeError(translate("Clock unit in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Clock unit in use")); } #endif uint8_t bits_per_sample = audiosample_bits_per_sample(sample); @@ -243,7 +243,7 @@ void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t *self, // Find a free GCLK to generate the MCLK signal. uint8_t gclk = find_free_gclk(divisor); if (gclk > GCLK_GEN_NUM) { - mp_raise_RuntimeError(translate("Unable to find free GCLK")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Unable to find free GCLK")); } self->gclk = gclk; @@ -257,7 +257,7 @@ void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t *self, } uint8_t channel_count = audiosample_channel_count(sample); if (channel_count > 2) { - mp_raise_ValueError(translate("Too many channels in sample")); + mp_raise_ValueError(MP_ERROR_TEXT("Too many channels in sample")); } #ifdef SAMD21 uint32_t serctrl = (self->clock_unit << I2S_SERCTRL_CLKSEL_Pos) | SERCTRL(SERMODE_TX) | I2S_SERCTRL_TXSAME_SAME | I2S_SERCTRL_EXTEND_MSBIT | I2S_SERCTRL_TXDEFAULT_ONE | I2S_SERCTRL_SLOTADJ_LEFT; @@ -308,10 +308,10 @@ void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t *self, if (result == AUDIO_DMA_DMA_BUSY) { common_hal_audiobusio_i2sout_stop(self); - mp_raise_RuntimeError(translate("No DMA channel found")); + mp_raise_RuntimeError(MP_ERROR_TEXT("No DMA channel found")); } else if (result == AUDIO_DMA_MEMORY_ERROR) { common_hal_audiobusio_i2sout_stop(self); - mp_raise_RuntimeError(translate("Unable to allocate buffers for signed conversion")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Unable to allocate buffers for signed conversion")); } I2S->INTFLAG.reg = I2S_INTFLAG_TXUR0 | I2S_INTFLAG_TXUR1; diff --git a/ports/atmel-samd/common-hal/audiobusio/PDMIn.c b/ports/atmel-samd/common-hal/audiobusio/PDMIn.c index b3c6f9df5e..717c397bbf 100644 --- a/ports/atmel-samd/common-hal/audiobusio/PDMIn.c +++ b/ports/atmel-samd/common-hal/audiobusio/PDMIn.c @@ -157,7 +157,7 @@ void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t *self, } if (!(bit_depth == 16 || bit_depth == 8) || !mono || oversample != OVERSAMPLING) { - mp_raise_NotImplementedError(translate("Only 8 or 16 bit mono with " MP_STRINGIFY(OVERSAMPLING) "x oversampling is supported.")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("Only 8 or 16 bit mono with " MP_STRINGIFY(OVERSAMPLING) "x oversampling is supported.")); } turn_on_i2s(); @@ -169,12 +169,12 @@ void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t *self, } else { #ifdef SAMD21 if ((I2S->CTRLA.vec.SEREN & (1 << self->serializer)) != 0) { - mp_raise_RuntimeError(translate("Serializer in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Serializer in use")); } #endif #ifdef SAM_D5X_E5X if (I2S->CTRLA.bit.RXEN == 1) { - mp_raise_RuntimeError(translate("Serializer in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Serializer in use")); } #endif } @@ -189,12 +189,12 @@ void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t *self, float mic_clock_freq = 48000000.0f / clock_divisor; self->sample_rate = mic_clock_freq / oversample; if (mic_clock_freq < MIN_MIC_CLOCK || clock_divisor == 0) { - mp_raise_ValueError(translate("sampling rate out of range")); + mp_raise_ValueError(MP_ERROR_TEXT("sampling rate out of range")); } // Find a free GCLK to generate the MCLK signal. uint8_t gclk = find_free_gclk(clock_divisor); if (gclk > GCLK_GEN_NUM) { - mp_raise_RuntimeError(translate("Unable to find free GCLK")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Unable to find free GCLK")); } self->gclk = gclk; diff --git a/ports/atmel-samd/common-hal/audioio/AudioOut.c b/ports/atmel-samd/common-hal/audioio/AudioOut.c index 52cf8d422b..c4e26c0f7d 100644 --- a/ports/atmel-samd/common-hal/audioio/AudioOut.c +++ b/ports/atmel-samd/common-hal/audioio/AudioOut.c @@ -128,11 +128,11 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t *self, #endif // Only support exclusive use of the DAC. if (dac_clock_enabled && DAC->CTRLA.bit.ENABLE == 1) { - mp_raise_RuntimeError(translate("DAC already in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("DAC already in use")); } #ifdef SAMD21 if (right_channel != NULL) { - mp_raise_ValueError(translate("Right channel unsupported")); + mp_raise_ValueError(MP_ERROR_TEXT("Right channel unsupported")); } if (left_channel != &pin_PA02) { raise_ValueError_invalid_pin(); @@ -148,7 +148,7 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t *self, raise_ValueError_invalid_pin_name(MP_QSTR_right_channel); } if (right_channel == left_channel) { - mp_raise_ValueError_varg(translate("%q and %q must be different"), + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q and %q must be different"), MP_QSTR_left_channel, MP_QSTR_right_channel); } claim_pin(left_channel); @@ -243,7 +243,7 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t *self, } if (t == NULL) { common_hal_audioio_audioout_deinit(self); - mp_raise_RuntimeError(translate("All timers in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("All timers in use")); return; } self->tc_index = tc_index; @@ -286,7 +286,7 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t *self, // path. uint8_t channel = find_async_event_channel(); if (channel >= EVSYS_CHANNELS) { - mp_raise_RuntimeError(translate("All event channels in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("All event channels in use")); } #ifdef SAM_D5X_E5X @@ -438,9 +438,9 @@ void common_hal_audioio_audioout_play(audioio_audioout_obj_t *self, audio_dma_stop(&self->right_dma); #endif if (result == AUDIO_DMA_DMA_BUSY) { - mp_raise_RuntimeError(translate("No DMA channel found")); + mp_raise_RuntimeError(MP_ERROR_TEXT("No DMA channel found")); } else if (result == AUDIO_DMA_MEMORY_ERROR) { - mp_raise_RuntimeError(translate("Unable to allocate buffers for signed conversion")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Unable to allocate buffers for signed conversion")); } } Tc *timer = tc_insts[self->tc_index]; diff --git a/ports/atmel-samd/common-hal/busio/I2C.c b/ports/atmel-samd/common-hal/busio/I2C.c index b1e981fb31..408251b045 100644 --- a/ports/atmel-samd/common-hal/busio/I2C.c +++ b/ports/atmel-samd/common-hal/busio/I2C.c @@ -100,7 +100,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, if (!gpio_get_pin_level(sda->number) || !gpio_get_pin_level(scl->number)) { reset_pin_number(sda->number); reset_pin_number(scl->number); - mp_raise_RuntimeError(translate("No pull up found on SDA or SCL; check your wiring")); + mp_raise_RuntimeError(MP_ERROR_TEXT("No pull up found on SDA or SCL; check your wiring")); } #endif diff --git a/ports/atmel-samd/common-hal/busio/SPI.c b/ports/atmel-samd/common-hal/busio/SPI.c index 1bc5152b52..5b7a494816 100644 --- a/ports/atmel-samd/common-hal/busio/SPI.c +++ b/ports/atmel-samd/common-hal/busio/SPI.c @@ -58,7 +58,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, uint8_t dopo = 255; if (half_duplex) { - mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("Half duplex SPI is not implemented")); } // Ensure the object starts in its deinit state. diff --git a/ports/atmel-samd/common-hal/busio/UART.c b/ports/atmel-samd/common-hal/busio/UART.c index 424b16b75c..302051f2e9 100644 --- a/ports/atmel-samd/common-hal/busio/UART.c +++ b/ports/atmel-samd/common-hal/busio/UART.c @@ -83,7 +83,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, self->cts_pin = NO_PIN; if ((rs485_dir != NULL) || (rs485_invert)) { - mp_raise_NotImplementedError(translate("RS485")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("RS485")); } mp_arg_validate_int_max(bits, 8, MP_QSTR_bits); @@ -94,7 +94,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, bool have_cts = cts != NULL; if (have_rx && receiver_buffer_size > 0 && (receiver_buffer_size & (receiver_buffer_size - 1)) != 0) { - mp_raise_ValueError_varg(translate("%q must be power of 2"), MP_QSTR_receiver_buffer_size); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q must be power of 2"), MP_QSTR_receiver_buffer_size); } self->baudrate = baudrate; @@ -388,7 +388,7 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { // Read characters. size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) { if (self->rx_pin == NO_PIN) { - mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_rx); + mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_rx); } // This assignment is only here because the usart_async routines take a *const argument. @@ -445,7 +445,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t // Write characters. size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) { if (self->tx_pin == NO_PIN) { - mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_tx); + mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_tx); } // This assignment is only here because the usart_async routines take a *const argument. diff --git a/ports/atmel-samd/common-hal/canio/Listener.c b/ports/atmel-samd/common-hal/canio/Listener.c index 28e82d7818..e4bea9bd84 100644 --- a/ports/atmel-samd/common-hal/canio/Listener.c +++ b/ports/atmel-samd/common-hal/canio/Listener.c @@ -306,24 +306,24 @@ void common_hal_canio_listener_construct(canio_listener_obj_t *self, canio_can_o can->fifo1_in_use = true; can->hw->IR.reg = CAN_IR_RF1N | CAN_IR_RF1W | CAN_IR_RF1F | CAN_IR_RF1L; } else { - mp_raise_ValueError(translate("All RX FIFOs in use")); + mp_raise_ValueError(MP_ERROR_TEXT("All RX FIFOs in use")); } if (!nmatch) { if (can->hw->GFC.bit.ANFS == CAN_GFC_ANFS_RXF1_Val - self->fifo_idx) { - mp_raise_ValueError(translate("Already have all-matches listener")); + mp_raise_ValueError(MP_ERROR_TEXT("Already have all-matches listener")); } if (can->hw->GFC.bit.ANFE == CAN_GFC_ANFE_RXF1_Val - self->fifo_idx) { - mp_raise_ValueError(translate("Already have all-matches listener")); + mp_raise_ValueError(MP_ERROR_TEXT("Already have all-matches listener")); } } if (num_filters_needed(nmatch, matches, false) > num_filters_available(can, false)) { - mp_raise_ValueError(translate("Filters too complex")); + mp_raise_ValueError(MP_ERROR_TEXT("Filters too complex")); } if (num_filters_needed(nmatch, matches, true) > num_filters_available(can, true)) { - mp_raise_ValueError(translate("Filters too complex")); + mp_raise_ValueError(MP_ERROR_TEXT("Filters too complex")); } // Nothing can fail now so it's safe to assign self->can diff --git a/ports/atmel-samd/common-hal/countio/Counter.c b/ports/atmel-samd/common-hal/countio/Counter.c index 6b280c1a60..c484d0094d 100644 --- a/ports/atmel-samd/common-hal/countio/Counter.c +++ b/ports/atmel-samd/common-hal/countio/Counter.c @@ -11,13 +11,13 @@ void common_hal_countio_counter_construct(countio_counter_obj_t *self, const mcu_pin_obj_t *pin, countio_edge_t edge, digitalio_pull_t pull) { if (!pin->has_extint) { - mp_raise_RuntimeError(translate("Pin must support hardware interrupts")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Pin must support hardware interrupts")); } if (eic_get_enable()) { if (!eic_channel_free(pin->extint_channel)) { - mp_raise_RuntimeError(translate("A hardware interrupt channel is already in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("A hardware interrupt channel is already in use")); } } else { turn_on_external_interrupt_controller(); diff --git a/ports/atmel-samd/common-hal/digitalio/DigitalInOut.c b/ports/atmel-samd/common-hal/digitalio/DigitalInOut.c index 3b68748e47..c2d60b3d93 100644 --- a/ports/atmel-samd/common-hal/digitalio/DigitalInOut.c +++ b/ports/atmel-samd/common-hal/digitalio/DigitalInOut.c @@ -175,7 +175,7 @@ digitalio_pull_t common_hal_digitalio_digitalinout_get_pull( digitalio_digitalinout_obj_t *self) { uint32_t pin = self->pin->number; if (self->output) { - mp_raise_AttributeError(translate("Cannot get pull while in output mode")); + mp_raise_AttributeError(MP_ERROR_TEXT("Cannot get pull while in output mode")); return PULL_NONE; } else { if (hri_port_get_PINCFG_PULLEN_bit(PORT, GPIO_PORT(pin), GPIO_PIN(pin)) == 0) { diff --git a/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c b/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c index da0230f60b..14b8f851f7 100644 --- a/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c +++ b/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c @@ -295,12 +295,12 @@ void common_hal_frequencyio_frequencyin_construct(frequencyio_frequencyin_obj_t* #ifdef SAM_D5X_E5X ((EIC->INTENSET.bit.EXTINT & mask) != 0 || (EIC->EVCTRL.bit.EXTINTEO & mask) != 0)) { #endif - mp_raise_RuntimeError(translate("EXTINT channel already in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("EXTINT channel already in use")); } uint8_t timer_index = find_free_timer(); if (timer_index == 0xff) { - mp_raise_RuntimeError(translate("All timers in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("All timers in use")); } Tc *tc = tc_insts[timer_index]; @@ -329,7 +329,7 @@ void common_hal_frequencyio_frequencyin_construct(frequencyio_frequencyin_obj_t* frequencyin_samd51_start_dpll(); if (dpll_gclk == 0xff && !clock_get_enabled(0, GCLK_SOURCE_DPLL1)) { common_hal_frequencyio_frequencyin_deinit(self); - mp_raise_RuntimeError(translate("No available clocks")); + mp_raise_RuntimeError(MP_ERROR_TEXT("No available clocks")); } set_timer_handler(timer_index, dpll_gclk, TC_HANDLER_NO_INTERRUPT); turn_on_clocks(true, timer_index, dpll_gclk); @@ -399,7 +399,7 @@ void common_hal_frequencyio_frequencyin_construct(frequencyio_frequencyin_obj_t* reference_tc = find_free_timer(); if (reference_tc == 0xff) { common_hal_frequencyio_frequencyin_deinit(self); - mp_raise_RuntimeError(translate("All timers in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("All timers in use")); } frequencyin_reference_tc_init(); } diff --git a/ports/atmel-samd/common-hal/imagecapture/ParallelImageCapture.c b/ports/atmel-samd/common-hal/imagecapture/ParallelImageCapture.c index c86ffb8d65..8f789f232b 100644 --- a/ports/atmel-samd/common-hal/imagecapture/ParallelImageCapture.c +++ b/ports/atmel-samd/common-hal/imagecapture/ParallelImageCapture.c @@ -58,7 +58,7 @@ void common_hal_imagecapture_parallelimagecapture_construct(imagecapture_paralle for (int i = 0; i < data_count; i++) { if (data_pins[i] != PIN_PCC_D0 + i) { - mp_raise_ValueError_varg(translate("Invalid data_pins[%d]"), i); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Invalid data_pins[%d]"), i); } } // The peripheral supports 8, 10, 12, or 14 data bits, but the code only supports 8 at present @@ -77,7 +77,7 @@ void common_hal_imagecapture_parallelimagecapture_construct(imagecapture_paralle // technically, 0 was validated as free already but check again for (int i = 0; i < data_count; i++) { if (!pin_number_is_free(data_pins[i])) { - mp_raise_ValueError_varg(translate("data pin #%d in use"), i); + mp_raise_ValueError_varg(MP_ERROR_TEXT("data pin #%d in use"), i); } } diff --git a/ports/atmel-samd/common-hal/microcontroller/Pin.c b/ports/atmel-samd/common-hal/microcontroller/Pin.c index 3db4ec4898..aa56243c37 100644 --- a/ports/atmel-samd/common-hal/microcontroller/Pin.c +++ b/ports/atmel-samd/common-hal/microcontroller/Pin.c @@ -210,5 +210,5 @@ mcu_pin_function_t *mcu_find_pin_function(mcu_pin_function_t *table, const mcu_p return table; } } - mp_raise_ValueError_varg(translate("Invalid %q pin"), name); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Invalid %q pin"), name); } diff --git a/ports/atmel-samd/common-hal/microcontroller/__init__.c b/ports/atmel-samd/common-hal/microcontroller/__init__.c index c4b7c787b4..3e02cba260 100644 --- a/ports/atmel-samd/common-hal/microcontroller/__init__.c +++ b/ports/atmel-samd/common-hal/microcontroller/__init__.c @@ -64,7 +64,7 @@ void common_hal_mcu_enable_interrupts(void) { void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) { if ((runmode == RUNMODE_BOOTLOADER) || (runmode == RUNMODE_UF2)) { if (!bootloader_available()) { - mp_raise_ValueError(translate("Cannot reset into bootloader because no bootloader is present")); + mp_raise_ValueError(MP_ERROR_TEXT("Cannot reset into bootloader because no bootloader is present")); } // Pretend to be the first of the two reset presses needed to enter the // bootloader. That way one reset will end in the bootloader. diff --git a/ports/atmel-samd/common-hal/paralleldisplaybus/ParallelBus.c b/ports/atmel-samd/common-hal/paralleldisplaybus/ParallelBus.c index 5358a2e9a3..fa6e396026 100644 --- a/ports/atmel-samd/common-hal/paralleldisplaybus/ParallelBus.c +++ b/ports/atmel-samd/common-hal/paralleldisplaybus/ParallelBus.c @@ -39,11 +39,11 @@ void common_hal_paralleldisplaybus_parallelbus_construct(paralleldisplaybus_para uint8_t data_pin = data0->number; if (data_pin % 8 != 0) { - mp_raise_ValueError(translate("Data 0 pin must be byte aligned")); + mp_raise_ValueError(MP_ERROR_TEXT("Data 0 pin must be byte aligned")); } for (uint8_t i = 0; i < 8; i++) { if (!pin_number_is_free(data_pin + i)) { - mp_raise_ValueError_varg(translate("Bus pin %d is already in use"), i); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Bus pin %d is already in use"), i); } } PortGroup *const g = &PORT->Group[data0->number / 32]; diff --git a/ports/atmel-samd/common-hal/ps2io/Ps2.c b/ports/atmel-samd/common-hal/ps2io/Ps2.c index bde2ecfac6..33fa1b107f 100644 --- a/ports/atmel-samd/common-hal/ps2io/Ps2.c +++ b/ports/atmel-samd/common-hal/ps2io/Ps2.c @@ -248,7 +248,7 @@ void common_hal_ps2io_ps2_construct(ps2io_ps2_obj_t *self, mp_arg_error_invalid(MP_QSTR_clock_pin); } if (eic_get_enable() && !eic_channel_free(clock_pin->extint_channel)) { - mp_raise_RuntimeError(translate("EXTINT channel already in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("EXTINT channel already in use")); } clk_hi(self); diff --git a/ports/atmel-samd/common-hal/pulseio/PulseIn.c b/ports/atmel-samd/common-hal/pulseio/PulseIn.c index 69c6753c65..097d013c29 100644 --- a/ports/atmel-samd/common-hal/pulseio/PulseIn.c +++ b/ports/atmel-samd/common-hal/pulseio/PulseIn.c @@ -155,7 +155,7 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t *self, raise_ValueError_invalid_pin(); } if (eic_get_enable() && !eic_channel_free(pin->extint_channel)) { - mp_raise_RuntimeError(translate("EXTINT channel already in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("EXTINT channel already in use")); } self->buffer = (uint16_t *)m_malloc(maxlen * sizeof(uint16_t)); @@ -182,7 +182,7 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t *self, } } if (tc == NULL) { - mp_raise_RuntimeError(translate("All timers in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("All timers in use")); } pulsein_tc_index = index; @@ -317,11 +317,11 @@ void common_hal_pulseio_pulsein_clear(pulseio_pulsein_obj_t *self) { uint16_t common_hal_pulseio_pulsein_popleft(pulseio_pulsein_obj_t *self) { if (self->len == 0) { - mp_raise_IndexError_varg(translate("pop from empty %q"), MP_QSTR_PulseIn); + mp_raise_IndexError_varg(MP_ERROR_TEXT("pop from empty %q"), MP_QSTR_PulseIn); } if (self->errored_too_fast) { self->errored_too_fast = 0; - mp_raise_RuntimeError(translate("Input taking too long")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Input taking too long")); } common_hal_mcu_disable_interrupts(); uint16_t value = self->buffer[self->start]; @@ -352,7 +352,7 @@ uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t *self, int16_ if (index < 0 || index >= self->len) { common_hal_mcu_enable_interrupts(); // Can't use mp_arg_validate_index_range() here due to the critical section. - mp_raise_IndexError_varg(translate("%q out of range"), MP_QSTR_index); + mp_raise_IndexError_varg(MP_ERROR_TEXT("%q out of range"), MP_QSTR_index); } uint16_t value = self->buffer[(self->start + index) % self->maxlen]; common_hal_mcu_enable_interrupts(); diff --git a/ports/atmel-samd/common-hal/pulseio/PulseOut.c b/ports/atmel-samd/common-hal/pulseio/PulseOut.c index 282c6035cd..47d3d53d6c 100644 --- a/ports/atmel-samd/common-hal/pulseio/PulseOut.c +++ b/ports/atmel-samd/common-hal/pulseio/PulseOut.c @@ -123,7 +123,7 @@ void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t *self, } } if (tc == NULL) { - mp_raise_RuntimeError(translate("All timers in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("All timers in use")); } pulseout_tc_index = index; @@ -200,7 +200,7 @@ void common_hal_pulseio_pulseout_deinit(pulseio_pulseout_obj_t *self) { void common_hal_pulseio_pulseout_send(pulseio_pulseout_obj_t *self, uint16_t *pulses, uint16_t length) { if (active_pincfg != NULL) { - mp_raise_RuntimeError(translate("Another send is already active")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Another send is already active")); } active_pincfg = self->pincfg; pulse_buffer = pulses; diff --git a/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c b/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c index d8d56e3172..ddc7e91540 100644 --- a/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c +++ b/ports/atmel-samd/common-hal/rotaryio/IncrementalEncoder.c @@ -37,7 +37,7 @@ 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) { if (!pin_a->has_extint || !pin_b->has_extint) { - mp_raise_RuntimeError(translate("Both pins must support hardware interrupts")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Both pins must support hardware interrupts")); } // TODO: The SAMD51 has a peripheral dedicated to quadrature encoder debugging. Use it instead @@ -45,7 +45,7 @@ void common_hal_rotaryio_incrementalencoder_construct(rotaryio_incrementalencode if (eic_get_enable()) { if (!eic_channel_free(pin_a->extint_channel) || !eic_channel_free(pin_b->extint_channel)) { - mp_raise_RuntimeError(translate("A hardware interrupt channel is already in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("A hardware interrupt channel is already in use")); } } else { turn_on_external_interrupt_controller(); diff --git a/ports/atmel-samd/common-hal/sdioio/SDCard.c b/ports/atmel-samd/common-hal/sdioio/SDCard.c index 3490015cbe..c6de588ecc 100644 --- a/ports/atmel-samd/common-hal/sdioio/SDCard.c +++ b/ports/atmel-samd/common-hal/sdioio/SDCard.c @@ -148,7 +148,7 @@ CLK PA21 PCC_D? (D32) BROWN } reset_pin_number(functions[i]->obj->number); } - mp_raise_OSError_msg_varg(translate("%q failure: %d"), MP_QSTR_sd_mmc_check, (int)result); + mp_raise_OSError_msg_varg(MP_ERROR_TEXT("%q failure: %d"), MP_QSTR_sd_mmc_check, (int)result); } // sd_mmc_get_capacity() is in KiB, but our "capacity" is in 512-byte blocks self->capacity = sd_mmc_get_capacity(0) * 2; @@ -173,7 +173,7 @@ STATIC void check_for_deinit(sdioio_sdcard_obj_t *self) { STATIC void check_whole_block(mp_buffer_info_t *bufinfo) { if (bufinfo->len % 512) { - mp_raise_ValueError(translate("Buffer length must be a multiple of 512")); + mp_raise_ValueError(MP_ERROR_TEXT("Buffer length must be a multiple of 512")); } } diff --git a/ports/atmel-samd/common-hal/touchio/TouchIn.c b/ports/atmel-samd/common-hal/touchio/TouchIn.c index 8922dc50fb..9a4315c830 100644 --- a/ports/atmel-samd/common-hal/touchio/TouchIn.c +++ b/ports/atmel-samd/common-hal/touchio/TouchIn.c @@ -69,7 +69,7 @@ void common_hal_touchio_touchin_construct(touchio_touchin_obj_t *self, // We run the PTC at 8mhz so divide the 48mhz clock by 6. uint8_t gclk = find_free_gclk(6); if (gclk > GCLK_GEN_NUM) { - mp_raise_RuntimeError(translate("No free GCLKs")); + mp_raise_RuntimeError(MP_ERROR_TEXT("No free GCLKs")); } enable_clock_generator(gclk, CLOCK_48MHZ, 6); diff --git a/ports/broadcom/common-hal/busio/SPI.c b/ports/broadcom/common-hal/busio/SPI.c index 5780ebe801..5f21f09241 100644 --- a/ports/broadcom/common-hal/busio/SPI.c +++ b/ports/broadcom/common-hal/busio/SPI.c @@ -84,7 +84,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, BP_Function_Enum miso_alt = 0; if (half_duplex) { - mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("Half duplex SPI is not implemented")); } // BCM_VERSION != 2711 have 3 SPI but as listed in peripherals/gen/pins.c two are on diff --git a/ports/broadcom/common-hal/busio/UART.c b/ports/broadcom/common-hal/busio/UART.c index c6888f9330..e6ab9f1fce 100644 --- a/ports/broadcom/common-hal/busio/UART.c +++ b/ports/broadcom/common-hal/busio/UART.c @@ -166,7 +166,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, mp_arg_validate_int_min(receiver_buffer_size, 1, MP_QSTR_receiver_buffer_size); if ((rs485_dir != NULL) || (rs485_invert)) { - mp_raise_NotImplementedError(translate("RS485 Not yet supported on this device")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("RS485 Not yet supported on this device")); } size_t instance_index = NUM_UART; @@ -346,7 +346,7 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { // Write characters. size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) { if (self->tx_pin == NULL) { - mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_tx); + mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_tx); } COMPLETE_MEMORY_READS; @@ -394,7 +394,7 @@ STATIC void enable_interrupt(busio_uart_obj_t *self) { // Read characters. size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) { if (self->rx_pin == NULL) { - mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_rx); + mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_rx); } if (len == 0) { diff --git a/ports/broadcom/common-hal/digitalio/DigitalInOut.c b/ports/broadcom/common-hal/digitalio/DigitalInOut.c index 2173ac5684..ac747235c2 100644 --- a/ports/broadcom/common-hal/digitalio/DigitalInOut.c +++ b/ports/broadcom/common-hal/digitalio/DigitalInOut.c @@ -151,7 +151,7 @@ digitalio_pull_t common_hal_digitalio_digitalinout_get_pull( digitalio_digitalinout_obj_t *self) { uint32_t pin = self->pin->number; if (self->output) { - mp_raise_AttributeError(translate("Cannot get pull while in output mode")); + mp_raise_AttributeError(MP_ERROR_TEXT("Cannot get pull while in output mode")); return PULL_NONE; } else { if (gpio_get_pull(pin) == BP_PULL_UP) { diff --git a/ports/broadcom/common-hal/neopixel_write/__init__.c b/ports/broadcom/common-hal/neopixel_write/__init__.c index 245244614f..93b5641e89 100644 --- a/ports/broadcom/common-hal/neopixel_write/__init__.c +++ b/ports/broadcom/common-hal/neopixel_write/__init__.c @@ -66,7 +66,7 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t *digitalinout, } } if (!found) { - mp_raise_ValueError(translate("NeoPixel not supported on pin")); + mp_raise_ValueError(MP_ERROR_TEXT("NeoPixel not supported on pin")); return; } diff --git a/ports/broadcom/common-hal/rtc/RTC.c b/ports/broadcom/common-hal/rtc/RTC.c index 8f6743cb05..b2aea7b57d 100644 --- a/ports/broadcom/common-hal/rtc/RTC.c +++ b/ports/broadcom/common-hal/rtc/RTC.c @@ -54,5 +54,5 @@ int common_hal_rtc_get_calibration(void) { } void common_hal_rtc_set_calibration(int calibration) { - mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_calibration); + mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_calibration); } diff --git a/ports/broadcom/common-hal/sdioio/SDCard.c b/ports/broadcom/common-hal/sdioio/SDCard.c index 041a06c036..32e6ad95d1 100644 --- a/ports/broadcom/common-hal/sdioio/SDCard.c +++ b/ports/broadcom/common-hal/sdioio/SDCard.c @@ -320,7 +320,7 @@ uint8_t common_hal_sdioio_sdcard_get_width(sdioio_sdcard_obj_t *self) { STATIC void check_whole_block(mp_buffer_info_t *bufinfo) { if (bufinfo->len % 512) { - mp_raise_ValueError(translate("Buffer length must be a multiple of 512")); + mp_raise_ValueError(MP_ERROR_TEXT("Buffer length must be a multiple of 512")); } } diff --git a/ports/broadcom/common-hal/videocore/Framebuffer.c b/ports/broadcom/common-hal/videocore/Framebuffer.c index 63c55324af..8dbc5f9fb9 100644 --- a/ports/broadcom/common-hal/videocore/Framebuffer.c +++ b/ports/broadcom/common-hal/videocore/Framebuffer.c @@ -25,7 +25,7 @@ void common_hal_videocore_framebuffer_construct(videocore_framebuffer_obj_t *sel &bits_per_pixel); if (self->framebuffer == NULL) { if (gc_alloc_possible()) { - mp_raise_ValueError(translate("no fb")); + mp_raise_ValueError(MP_ERROR_TEXT("no fb")); } else { mp_printf(&mp_plat_print, "no fb\n"); } diff --git a/ports/cxd56/common-hal/analogio/AnalogOut.c b/ports/cxd56/common-hal/analogio/AnalogOut.c index b57dc8e323..7252d09c38 100644 --- a/ports/cxd56/common-hal/analogio/AnalogOut.c +++ b/ports/cxd56/common-hal/analogio/AnalogOut.c @@ -29,7 +29,7 @@ #include "shared-bindings/analogio/AnalogOut.h" void common_hal_analogio_analogout_construct(analogio_analogout_obj_t *self, const mcu_pin_obj_t *pin) { - mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_AnalogOut); + mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_AnalogOut); } void common_hal_analogio_analogout_deinit(analogio_analogout_obj_t *self) { diff --git a/ports/cxd56/common-hal/busio/SPI.c b/ports/cxd56/common-hal/busio/SPI.c index 75f530eda1..115cee3a31 100644 --- a/ports/cxd56/common-hal/busio/SPI.c +++ b/ports/cxd56/common-hal/busio/SPI.c @@ -40,7 +40,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t * int port = -1; if (half_duplex) { - mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("Half duplex SPI is not implemented")); } if (clock->number == PIN_SPI4_SCK && diff --git a/ports/cxd56/common-hal/busio/UART.c b/ports/cxd56/common-hal/busio/UART.c index aafc0b790e..8eb24d1e46 100644 --- a/ports/cxd56/common-hal/busio/UART.c +++ b/ports/cxd56/common-hal/busio/UART.c @@ -66,7 +66,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, struct termios tio; if ((rts != NULL) || (cts != NULL) || (rs485_dir != NULL) || (rs485_invert)) { - mp_raise_NotImplementedError(translate("RS485")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("RS485")); } mp_arg_validate_int(bits, 8, MP_QSTR_bits); @@ -90,7 +90,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, if (busio_uart_dev[self->number].fd < 0) { busio_uart_dev[self->number].fd = open(busio_uart_dev[self->number].devpath, O_RDWR); if (busio_uart_dev[self->number].fd < 0) { - mp_raise_RuntimeError(translate("UART init")); + mp_raise_RuntimeError(MP_ERROR_TEXT("UART init")); } // Wait to make sure the UART is ready diff --git a/ports/cxd56/common-hal/camera/Camera.c b/ports/cxd56/common-hal/camera/Camera.c index 37b5f63d17..4f468a537b 100644 --- a/ports/cxd56/common-hal/camera/Camera.c +++ b/ports/cxd56/common-hal/camera/Camera.c @@ -149,11 +149,11 @@ static void camera_start_preview() { void common_hal_camera_construct(camera_obj_t *self) { if (camera_dev.fd < 0) { if (video_initialize(camera_dev.devpath) < 0) { - mp_raise_RuntimeError(translate("Camera init")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Camera init")); } camera_dev.fd = open(camera_dev.devpath, 0); if (camera_dev.fd < 0) { - mp_raise_RuntimeError(translate("Camera init")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Camera init")); } } @@ -181,13 +181,13 @@ bool common_hal_camera_deinited(camera_obj_t *self) { size_t common_hal_camera_take_picture(camera_obj_t *self, uint8_t *buffer, size_t len, uint16_t width, uint16_t height, camera_imageformat_t format) { if (!camera_check_width_and_height(width, height)) { - mp_raise_ValueError(translate("Size not supported")); + mp_raise_ValueError(MP_ERROR_TEXT("Size not supported")); } if (!camera_check_buffer_length(width, height, format, len)) { - mp_raise_ValueError(translate("Buffer too small")); + mp_raise_ValueError(MP_ERROR_TEXT("Buffer too small")); } if (!camera_check_format(format)) { - mp_raise_ValueError(translate("Format not supported")); + mp_raise_ValueError(MP_ERROR_TEXT("Format not supported")); } camera_set_format(V4L2_BUF_TYPE_STILL_CAPTURE, V4L2_PIX_FMT_JPEG, width, height); diff --git a/ports/cxd56/common-hal/gnss/GNSS.c b/ports/cxd56/common-hal/gnss/GNSS.c index 977d2e9b4b..3c63990cf9 100644 --- a/ports/cxd56/common-hal/gnss/GNSS.c +++ b/ports/cxd56/common-hal/gnss/GNSS.c @@ -56,7 +56,7 @@ void common_hal_gnss_construct(gnss_obj_t *self, unsigned long selection) { if (gnss_dev.fd < 0) { gnss_dev.fd = open(gnss_dev.devpath, O_RDONLY); if (gnss_dev.fd < 0) { - mp_raise_RuntimeError(translate("GNSS init")); + mp_raise_RuntimeError(MP_ERROR_TEXT("GNSS init")); } } diff --git a/ports/cxd56/common-hal/microcontroller/__init__.c b/ports/cxd56/common-hal/microcontroller/__init__.c index c77a8829f2..7fbe9351b6 100644 --- a/ports/cxd56/common-hal/microcontroller/__init__.c +++ b/ports/cxd56/common-hal/microcontroller/__init__.c @@ -72,7 +72,7 @@ void common_hal_mcu_enable_interrupts(void) { void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) { if (runmode == RUNMODE_BOOTLOADER) { - mp_raise_ValueError(translate("Cannot reset into bootloader because no bootloader is present")); + mp_raise_ValueError(MP_ERROR_TEXT("Cannot reset into bootloader because no bootloader is present")); } else if (runmode == RUNMODE_SAFE_MODE) { safe_mode_on_next_reset(SAFE_MODE_PROGRAMMATIC); } diff --git a/ports/cxd56/common-hal/pulseio/PulseIn.c b/ports/cxd56/common-hal/pulseio/PulseIn.c index 989acd491c..2abefff04f 100644 --- a/ports/cxd56/common-hal/pulseio/PulseIn.c +++ b/ports/cxd56/common-hal/pulseio/PulseIn.c @@ -100,7 +100,7 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t *self, int irq = pulsein_set_config(self, true); if (irq < 0) { - mp_raise_RuntimeError(translate("EXTINT channel already in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("EXTINT channel already in use")); } else { pulsein_objects[irq - CXD56_IRQ_EXDEVICE_0] = self; } @@ -160,7 +160,7 @@ void common_hal_pulseio_pulsein_clear(pulseio_pulsein_obj_t *self) { uint16_t common_hal_pulseio_pulsein_popleft(pulseio_pulsein_obj_t *self) { if (self->len == 0) { - mp_raise_IndexError_varg(translate("pop from empty %q"), MP_QSTR_PulseIn); + mp_raise_IndexError_varg(MP_ERROR_TEXT("pop from empty %q"), MP_QSTR_PulseIn); } common_hal_mcu_disable_interrupts(); uint16_t value = self->buffer[self->start]; @@ -190,7 +190,7 @@ uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t *self, int16_ } if (index < 0 || index >= self->len) { common_hal_mcu_enable_interrupts(); - mp_raise_IndexError_varg(translate("%q out of range"), MP_QSTR_index); + mp_raise_IndexError_varg(MP_ERROR_TEXT("%q out of range"), MP_QSTR_index); } uint16_t value = self->buffer[(self->start + index) % self->maxlen]; common_hal_mcu_enable_interrupts(); diff --git a/ports/cxd56/common-hal/pulseio/PulseOut.c b/ports/cxd56/common-hal/pulseio/PulseOut.c index 11bd5443bb..3f3e23fbb3 100644 --- a/ports/cxd56/common-hal/pulseio/PulseOut.c +++ b/ports/cxd56/common-hal/pulseio/PulseOut.c @@ -73,7 +73,7 @@ void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t *self, } if (pulse_fd < 0) { - mp_raise_RuntimeError(translate("All timers in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("All timers in use")); } self->pwm_num = self->pwmout.number; @@ -99,7 +99,7 @@ bool common_hal_pulseio_pulseout_deinited(pulseio_pulseout_obj_t *self) { void common_hal_pulseio_pulseout_send(pulseio_pulseout_obj_t *self, uint16_t *pulses, uint16_t len) { if (pulse_buffer != NULL) { - mp_raise_RuntimeError(translate("Another send is already active")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Another send is already active")); } struct timer_sethandler_s sethandler; diff --git a/ports/cxd56/common-hal/rtc/RTC.c b/ports/cxd56/common-hal/rtc/RTC.c index 0024e56cb2..1997955fd9 100644 --- a/ports/cxd56/common-hal/rtc/RTC.c +++ b/ports/cxd56/common-hal/rtc/RTC.c @@ -50,5 +50,5 @@ int common_hal_rtc_get_calibration(void) { } void common_hal_rtc_set_calibration(int calibration) { - mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_calibration); + mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_calibration); } diff --git a/ports/cxd56/common-hal/sdioio/SDCard.c b/ports/cxd56/common-hal/sdioio/SDCard.c index e8e5df4687..9e2e2da4dd 100644 --- a/ports/cxd56/common-hal/sdioio/SDCard.c +++ b/ports/cxd56/common-hal/sdioio/SDCard.c @@ -59,7 +59,7 @@ void common_hal_sdioio_sdcard_construct(sdioio_sdcard_obj_t *self, } if (open_blockdriver("/dev/mmcsd0", 0, &self->inode) < 0) { - mp_raise_RuntimeError(translate("SDCard init")); + mp_raise_RuntimeError(MP_ERROR_TEXT("SDCard init")); } self->inode->u.i_bops->geometry(self->inode, &geo); @@ -111,7 +111,7 @@ uint32_t common_hal_sdioio_sdcard_get_count(sdioio_sdcard_obj_t *self) { STATIC void check_whole_block(mp_buffer_info_t *bufinfo) { if (bufinfo->len % 512) { - mp_raise_ValueError(translate("Buffer length must be a multiple of 512")); + mp_raise_ValueError(MP_ERROR_TEXT("Buffer length must be a multiple of 512")); } } diff --git a/ports/espressif/bindings/espnow/ESPNow.c b/ports/espressif/bindings/espnow/ESPNow.c index 08ed4087ba..d3d10057e3 100644 --- a/ports/espressif/bindings/espnow/ESPNow.c +++ b/ports/espressif/bindings/espnow/ESPNow.c @@ -74,7 +74,7 @@ STATIC mp_obj_t espnow_make_new(const mp_obj_type_t *type, size_t n_args, size_t espnow_obj_t *self = MP_STATE_PORT(espnow_singleton); if (!common_hal_espnow_deinited(self)) { - mp_raise_RuntimeError(translate("Already running")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Already running")); } // Allocate a new object diff --git a/ports/espressif/bindings/espnow/Peer.c b/ports/espressif/bindings/espnow/Peer.c index cfe49954ff..c9f8b75b95 100644 --- a/ports/espressif/bindings/espnow/Peer.c +++ b/ports/espressif/bindings/espnow/Peer.c @@ -86,7 +86,7 @@ STATIC mp_obj_t espnow_peer_make_new(const mp_obj_type_t *type, size_t n_args, s self->lmk_set = true; memcpy(self->peer_info.lmk, common_hal_espnow_get_bytes_len(lmk, ESP_NOW_KEY_LEN), ESP_NOW_KEY_LEN); } else if (self->peer_info.encrypt) { - mp_raise_ValueError_varg(translate("%q is %q"), MP_QSTR_lmk, MP_QSTR_None); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q is %q"), MP_QSTR_lmk, MP_QSTR_None); } return self; @@ -199,7 +199,7 @@ STATIC mp_obj_t espnow_peer_set_encrypted(const mp_obj_t self_in, const mp_obj_t self->peer_info.encrypt = mp_obj_is_true(value); if (!self->lmk_set) { - mp_raise_ValueError_varg(translate("%q is %q"), MP_QSTR_lmk, MP_QSTR_None); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q is %q"), MP_QSTR_lmk, MP_QSTR_None); } esp_now_mod_peer(&self->peer_info); diff --git a/ports/espressif/boards/adafruit_feather_esp32_v2/mpconfigboard.h b/ports/espressif/boards/adafruit_feather_esp32_v2/mpconfigboard.h index 4e9e679e5f..a9bcd85646 100644 --- a/ports/espressif/boards/adafruit_feather_esp32_v2/mpconfigboard.h +++ b/ports/espressif/boards/adafruit_feather_esp32_v2/mpconfigboard.h @@ -47,7 +47,7 @@ #define CIRCUITPY_BOOT_BUTTON (&pin_GPIO38) // Explanation of how a user got into safe mode -#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed the SW38 button at start up.") +#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed the SW38 button at start up.") // UART pins attached to the USB-serial converter chip #define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1) diff --git a/ports/espressif/boards/adafruit_huzzah32_breakout/mpconfigboard.h b/ports/espressif/boards/adafruit_huzzah32_breakout/mpconfigboard.h index 0c6132c7ff..c1d5790acb 100644 --- a/ports/espressif/boards/adafruit_huzzah32_breakout/mpconfigboard.h +++ b/ports/espressif/boards/adafruit_huzzah32_breakout/mpconfigboard.h @@ -35,7 +35,7 @@ #define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) // Explanation of how a user got into safe mode -#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed the GPIO0 button at start up.") +#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed the GPIO0 button at start up.") // UART pins #define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1) diff --git a/ports/espressif/boards/deneyap_kart/mpconfigboard.h b/ports/espressif/boards/deneyap_kart/mpconfigboard.h index c2251c3dcb..959e4e5c02 100644 --- a/ports/espressif/boards/deneyap_kart/mpconfigboard.h +++ b/ports/espressif/boards/deneyap_kart/mpconfigboard.h @@ -43,7 +43,7 @@ #define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) // Explanation of how a user got into safe mode -// #define BOARD_USER_SAFE_MODE_ACTION translate("You pressed the BUT button at start up.") +// #define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed the BUT button at start up.") // UART pins attached to the USB-serial converter chip #define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1) diff --git a/ports/espressif/boards/deneyap_kart_1a/mpconfigboard.h b/ports/espressif/boards/deneyap_kart_1a/mpconfigboard.h index ba7c216c89..403c62e9fd 100644 --- a/ports/espressif/boards/deneyap_kart_1a/mpconfigboard.h +++ b/ports/espressif/boards/deneyap_kart_1a/mpconfigboard.h @@ -43,7 +43,7 @@ #define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) // Explanation of how a user got into safe mode -// #define BOARD_USER_SAFE_MODE_ACTION translate("You pressed the BUT button at start up.") +// #define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed the BUT button at start up.") // UART pins attached to the USB-serial converter chip #define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1) diff --git a/ports/espressif/boards/espressif_esp32_lyrat/mpconfigboard.h b/ports/espressif/boards/espressif_esp32_lyrat/mpconfigboard.h index 7835e93f21..16ec81fdd0 100644 --- a/ports/espressif/boards/espressif_esp32_lyrat/mpconfigboard.h +++ b/ports/espressif/boards/espressif_esp32_lyrat/mpconfigboard.h @@ -43,7 +43,7 @@ #define CIRCUITPY_BOOT_BUTTON (&pin_GPIO36) // Explanation of how a user got into safe mode -#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed the Rec button at start up.") +#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed the Rec button at start up.") // UART pins attached to the USB-serial converter chip #define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1) diff --git a/ports/espressif/boards/hardkernel_odroid_go/mpconfigboard.h b/ports/espressif/boards/hardkernel_odroid_go/mpconfigboard.h index 49d49f2427..90c4eafb9f 100644 --- a/ports/espressif/boards/hardkernel_odroid_go/mpconfigboard.h +++ b/ports/espressif/boards/hardkernel_odroid_go/mpconfigboard.h @@ -35,7 +35,7 @@ #define CIRCUITPY_BOOT_BUTTON (&pin_GPIO0) // Explanation of how a user got into safe mode -#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed the VOLUME button at start up.") +#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed the VOLUME button at start up.") // UART pins attached to the USB-serial converter chip #define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1) diff --git a/ports/espressif/boards/m5stack_atom_echo/mpconfigboard.h b/ports/espressif/boards/m5stack_atom_echo/mpconfigboard.h index 426d5c3bf7..d5ec6d6bc6 100644 --- a/ports/espressif/boards/m5stack_atom_echo/mpconfigboard.h +++ b/ports/espressif/boards/m5stack_atom_echo/mpconfigboard.h @@ -38,7 +38,7 @@ #define CIRCUITPY_BOOT_BUTTON (&pin_GPIO39) // Explanation of how a user got into safe mode -#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed the central button at start up.") +#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed the central button at start up.") // UART pins attached to the USB-serial converter chip #define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1) diff --git a/ports/espressif/boards/m5stack_atom_lite/mpconfigboard.h b/ports/espressif/boards/m5stack_atom_lite/mpconfigboard.h index 9ec15fa0f2..dc256ab2f2 100644 --- a/ports/espressif/boards/m5stack_atom_lite/mpconfigboard.h +++ b/ports/espressif/boards/m5stack_atom_lite/mpconfigboard.h @@ -42,7 +42,7 @@ #define CIRCUITPY_BOOT_BUTTON (&pin_GPIO39) // Explanation of how a user got into safe mode -#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed the central button at start up.") +#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed the central button at start up.") // UART pins attached to the USB-serial converter chip #define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1) diff --git a/ports/espressif/boards/m5stack_atom_matrix/mpconfigboard.h b/ports/espressif/boards/m5stack_atom_matrix/mpconfigboard.h index 77eba4ab92..1af4430916 100644 --- a/ports/espressif/boards/m5stack_atom_matrix/mpconfigboard.h +++ b/ports/espressif/boards/m5stack_atom_matrix/mpconfigboard.h @@ -42,7 +42,7 @@ #define CIRCUITPY_BOOT_BUTTON (&pin_GPIO39) // Explanation of how a user got into safe mode -#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed the central button at start up.") +#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed the central button at start up.") // UART pins attached to the USB-serial converter chip #define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1) diff --git a/ports/espressif/boards/m5stack_atom_u/mpconfigboard.h b/ports/espressif/boards/m5stack_atom_u/mpconfigboard.h index b5b2101134..7425311420 100644 --- a/ports/espressif/boards/m5stack_atom_u/mpconfigboard.h +++ b/ports/espressif/boards/m5stack_atom_u/mpconfigboard.h @@ -41,7 +41,7 @@ #define CIRCUITPY_BOOT_BUTTON (&pin_GPIO39) // Explanation of how a user got into safe mode -#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed the central button at start up.") +#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed the central button at start up.") // UART pins attached to the USB-serial converter chip #define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1) diff --git a/ports/espressif/boards/m5stack_core_basic/mpconfigboard.h b/ports/espressif/boards/m5stack_core_basic/mpconfigboard.h index 0135b66661..4a806fd7f9 100755 --- a/ports/espressif/boards/m5stack_core_basic/mpconfigboard.h +++ b/ports/espressif/boards/m5stack_core_basic/mpconfigboard.h @@ -42,7 +42,7 @@ #define CIRCUITPY_BOOT_BUTTON (&pin_GPIO39) // Explanation of how a user got into safe mode -#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed button A at start up.") +#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed button A at start up.") // UART pins attached to the USB-serial converter chip #define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1) diff --git a/ports/espressif/boards/m5stack_core_fire/mpconfigboard.h b/ports/espressif/boards/m5stack_core_fire/mpconfigboard.h index 2073473e1a..f4bb2b56e1 100755 --- a/ports/espressif/boards/m5stack_core_fire/mpconfigboard.h +++ b/ports/espressif/boards/m5stack_core_fire/mpconfigboard.h @@ -43,7 +43,7 @@ #define CIRCUITPY_BOOT_BUTTON (&pin_GPIO39) // Explanation of how a user got into safe mode -#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed button A at start up.") +#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed button A at start up.") // UART pins attached to the USB-serial converter chip #define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1) diff --git a/ports/espressif/boards/m5stack_m5paper/mpconfigboard.h b/ports/espressif/boards/m5stack_m5paper/mpconfigboard.h index f80bf4b550..23c7cfdb8b 100644 --- a/ports/espressif/boards/m5stack_m5paper/mpconfigboard.h +++ b/ports/espressif/boards/m5stack_m5paper/mpconfigboard.h @@ -43,7 +43,7 @@ #define CIRCUITPY_BOOT_BUTTON (&pin_GPIO39) // Explanation of how a user got into safe mode -#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed button DOWN at start up.") +#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed button DOWN at start up.") // UART pins attached to the USB-serial converter chip #define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1) diff --git a/ports/espressif/boards/m5stack_stick_c/mpconfigboard.h b/ports/espressif/boards/m5stack_stick_c/mpconfigboard.h index 1614a9ddad..93df8fd2b8 100644 --- a/ports/espressif/boards/m5stack_stick_c/mpconfigboard.h +++ b/ports/espressif/boards/m5stack_stick_c/mpconfigboard.h @@ -40,7 +40,7 @@ #define CIRCUITPY_BOOT_BUTTON (&pin_GPIO37) // Explanation of how a user got into safe mode -#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed button A at start up.") +#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed button A at start up.") // UART pins attached to the USB-serial converter chip #define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1) diff --git a/ports/espressif/boards/m5stack_stick_c_plus/mpconfigboard.h b/ports/espressif/boards/m5stack_stick_c_plus/mpconfigboard.h index 3e988248c6..e63ec84cc4 100644 --- a/ports/espressif/boards/m5stack_stick_c_plus/mpconfigboard.h +++ b/ports/espressif/boards/m5stack_stick_c_plus/mpconfigboard.h @@ -40,7 +40,7 @@ #define CIRCUITPY_BOOT_BUTTON (&pin_GPIO37) // Explanation of how a user got into safe mode -#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed button A at start up.") +#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed button A at start up.") // UART pins attached to the USB-serial converter chip #define CIRCUITPY_CONSOLE_UART_TX (&pin_GPIO1) diff --git a/ports/espressif/common-hal/_bleio/Adapter.c b/ports/espressif/common-hal/_bleio/Adapter.c index b03bf7c439..f1c1ee986c 100644 --- a/ports/espressif/common-hal/_bleio/Adapter.c +++ b/ports/espressif/common-hal/_bleio/Adapter.c @@ -219,7 +219,7 @@ mp_obj_t common_hal_bleio_adapter_start_scan(bleio_adapter_obj_t *self, uint8_t mp_float_t interval, mp_float_t window, mp_int_t minimum_rssi, bool active) { if (self->scan_results != NULL) { if (!shared_module_bleio_scanresults_get_done(self->scan_results)) { - mp_raise_bleio_BluetoothError(translate("Scan already in progress. Stop with stop_scan.")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Scan already in progress. Stop with stop_scan.")); } self->scan_results = NULL; } @@ -389,7 +389,7 @@ mp_obj_t common_hal_bleio_adapter_connect(bleio_adapter_obj_t *self, bleio_addre } } - mp_raise_bleio_BluetoothError(translate("Failed to connect: internal error")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Failed to connect: internal error")); return mp_const_none; } @@ -535,7 +535,7 @@ uint32_t _common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, STATIC void check_data_fit(size_t data_len, bool connectable) { if (data_len > MYNEWT_VAL(BLE_EXT_ADV_MAX_SIZE) || (connectable && data_len > MYNEWT_VAL(BLE_EXT_ADV_MAX_SIZE))) { - mp_raise_ValueError(translate("Data too large for advertisement packet")); + mp_raise_ValueError(MP_ERROR_TEXT("Data too large for advertisement packet")); } } @@ -544,7 +544,7 @@ void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, bool mp_buffer_info_t *advertising_data_bufinfo, mp_buffer_info_t *scan_response_data_bufinfo, mp_int_t tx_power, const bleio_address_obj_t *directed_to) { if (self->user_advertising) { - mp_raise_bleio_BluetoothError(translate("Already advertising.")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Already advertising.")); } else { // If the user isn't advertising, then the background is. So, stop the // background advertising so the user can. @@ -556,12 +556,12 @@ void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, bool check_data_fit(scan_response_data_bufinfo->len, connectable); if (advertising_data_bufinfo->len > 31 && scan_response_data_bufinfo->len > 0) { - mp_raise_bleio_BluetoothError(translate("Extended advertisements with scan response not supported.")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Extended advertisements with scan response not supported.")); } if (advertising_data_bufinfo->len > 0 && directed_to != NULL) { - mp_raise_bleio_BluetoothError(translate("Data not supported with directed advertising")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Data not supported with directed advertising")); } if (anonymous) { @@ -571,7 +571,7 @@ void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, bool if (!timeout) { timeout = BLE_HS_FOREVER; } else if (timeout > INT32_MAX) { - mp_raise_bleio_BluetoothError(translate("Timeout is too long: Maximum timeout length is %d seconds"), + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Timeout is too long: Maximum timeout length is %d seconds"), INT32_MAX / 1000); } diff --git a/ports/espressif/common-hal/_bleio/Characteristic.c b/ports/espressif/common-hal/_bleio/Characteristic.c index 0344e38df1..f639b75edf 100644 --- a/ports/espressif/common-hal/_bleio/Characteristic.c +++ b/ports/espressif/common-hal/_bleio/Characteristic.c @@ -165,10 +165,10 @@ void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self, // Validate data length for local characteristics only. // TODO: Test this once we can get servers going. if (self->fixed_length && bufinfo->len != self->max_length) { - mp_raise_ValueError(translate("Value length != required fixed length")); + mp_raise_ValueError(MP_ERROR_TEXT("Value length != required fixed length")); } if (bufinfo->len > self->max_length) { - mp_raise_ValueError(translate("Value length > max_length")); + mp_raise_ValueError(MP_ERROR_TEXT("Value length > max_length")); } if (bufinfo == NULL) { @@ -216,11 +216,11 @@ void common_hal_bleio_characteristic_add_descriptor(bleio_characteristic_obj_t * void common_hal_bleio_characteristic_set_cccd(bleio_characteristic_obj_t *self, bool notify, bool indicate) { if (self->cccd_handle == BLEIO_HANDLE_INVALID) { - mp_raise_bleio_BluetoothError(translate("No CCCD for this Characteristic")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("No CCCD for this Characteristic")); } if (!common_hal_bleio_service_get_is_remote(self->service)) { - mp_raise_bleio_RoleError(translate("Can't set CCCD on local Characteristic")); + mp_raise_bleio_RoleError(MP_ERROR_TEXT("Can't set CCCD on local Characteristic")); } const uint16_t conn_handle = bleio_connection_get_conn_handle(self->service->connection); diff --git a/ports/espressif/common-hal/_bleio/Connection.c b/ports/espressif/common-hal/_bleio/Connection.c index 8861137210..575d8d0894 100644 --- a/ports/espressif/common-hal/_bleio/Connection.c +++ b/ports/espressif/common-hal/_bleio/Connection.c @@ -320,7 +320,7 @@ STATIC void discover_remote_services(bleio_connection_internal_t *self, mp_obj_t mp_obj_t uuid_obj; while ((uuid_obj = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { if (!mp_obj_is_type(uuid_obj, &bleio_uuid_type)) { - mp_raise_TypeError(translate("non-UUID found in service_uuids_whitelist")); + mp_raise_TypeError(MP_ERROR_TEXT("non-UUID found in service_uuids_whitelist")); } bleio_uuid_obj_t *uuid = MP_OBJ_TO_PTR(uuid_obj); diff --git a/ports/espressif/common-hal/_bleio/Descriptor.c b/ports/espressif/common-hal/_bleio/Descriptor.c index 31bdca51b0..e72ec7d9e2 100644 --- a/ports/espressif/common-hal/_bleio/Descriptor.c +++ b/ports/espressif/common-hal/_bleio/Descriptor.c @@ -45,7 +45,7 @@ void common_hal_bleio_descriptor_construct(bleio_descriptor_obj_t *self, bleio_c const mp_int_t max_length_max = BLE_ATT_ATTR_MAX_LEN; if (max_length < 0 || max_length > max_length_max) { - mp_raise_ValueError_varg(translate("max_length must be 0-%d when fixed_length is %s"), + mp_raise_ValueError_varg(MP_ERROR_TEXT("max_length must be 0-%d when fixed_length is %s"), max_length_max, fixed_length ? "True" : "False"); } self->max_length = max_length; @@ -83,10 +83,10 @@ void common_hal_bleio_descriptor_set_value(bleio_descriptor_obj_t *self, mp_buff } else { // Validate data length for local descriptors only. if (self->fixed_length && bufinfo->len != self->max_length) { - mp_raise_ValueError(translate("Value length != required fixed length")); + mp_raise_ValueError(MP_ERROR_TEXT("Value length != required fixed length")); } if (bufinfo->len > self->max_length) { - mp_raise_ValueError(translate("Value length > max_length")); + mp_raise_ValueError(MP_ERROR_TEXT("Value length > max_length")); } // common_hal_bleio_gatts_write(self->handle, conn_handle, bufinfo); diff --git a/ports/espressif/common-hal/_bleio/PacketBuffer.c b/ports/espressif/common-hal/_bleio/PacketBuffer.c index 4e2268f350..f6ef412855 100644 --- a/ports/espressif/common-hal/_bleio/PacketBuffer.c +++ b/ports/espressif/common-hal/_bleio/PacketBuffer.c @@ -267,7 +267,7 @@ mp_int_t common_hal_bleio_packet_buffer_readinto(bleio_packet_buffer_obj_t *self mp_int_t common_hal_bleio_packet_buffer_write(bleio_packet_buffer_obj_t *self, const uint8_t *data, size_t len, uint8_t *header, size_t header_len) { if (self->outgoing[0] == NULL) { - mp_raise_bleio_BluetoothError(translate("Writes not supported on Characteristic")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Writes not supported on Characteristic")); } if (self->conn_handle == BLEIO_HANDLE_INVALID) { return -1; @@ -280,11 +280,11 @@ mp_int_t common_hal_bleio_packet_buffer_write(bleio_packet_buffer_obj_t *self, c mp_int_t total_len = len + header_len; if (total_len > outgoing_packet_length) { // Supplied data will not fit in a single BLE packet. - mp_raise_ValueError_varg(translate("Total data to write is larger than %q"), MP_QSTR_outgoing_packet_length); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Total data to write is larger than %q"), MP_QSTR_outgoing_packet_length); } if (total_len > self->max_packet_size) { // Supplied data will not fit in a single BLE packet. - mp_raise_ValueError_varg(translate("Total data to write is larger than %q"), MP_QSTR_max_packet_size); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Total data to write is larger than %q"), MP_QSTR_max_packet_size); } outgoing_packet_length = MIN(outgoing_packet_length, self->max_packet_size); diff --git a/ports/espressif/common-hal/_bleio/__init__.c b/ports/espressif/common-hal/_bleio/__init__.c index e25f9b0ef1..f6ac17012d 100644 --- a/ports/espressif/common-hal/_bleio/__init__.c +++ b/ports/espressif/common-hal/_bleio/__init__.c @@ -85,26 +85,26 @@ void check_nimble_error(int rc, const char *file, size_t line) { } switch (rc) { case BLE_HS_ENOMEM: - mp_raise_msg(&mp_type_MemoryError, translate("Nimble out of memory")); + mp_raise_msg(&mp_type_MemoryError, MP_ERROR_TEXT("Nimble out of memory")); return; case BLE_HS_ETIMEOUT: mp_raise_msg(&mp_type_TimeoutError, NULL); return; case BLE_HS_EINVAL: - mp_raise_ValueError(translate("Invalid BLE parameter")); + mp_raise_ValueError(MP_ERROR_TEXT("Invalid BLE parameter")); return; case BLE_HS_ENOTCONN: - mp_raise_ConnectionError(translate("Not connected")); + mp_raise_ConnectionError(MP_ERROR_TEXT("Not connected")); return; default: #if CIRCUITPY_VERBOSE_BLE if (file) { - mp_raise_bleio_BluetoothError(translate("Unknown system firmware error at %s:%d: %d"), file, line, rc); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Unknown system firmware error at %s:%d: %d"), file, line, rc); } #else (void)file; (void)line; - mp_raise_bleio_BluetoothError(translate("Unknown system firmware error: %d"), rc); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Unknown system firmware error: %d"), rc); #endif break; @@ -119,12 +119,12 @@ void check_ble_error(int error_code, const char *file, size_t line) { default: #if CIRCUITPY_VERBOSE_BLE if (file) { - mp_raise_bleio_BluetoothError(translate("Unknown BLE error at %s:%d: %d"), file, line, error_code); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Unknown BLE error at %s:%d: %d"), file, line, error_code); } #else (void)file; (void)line; - mp_raise_bleio_BluetoothError(translate("Unknown BLE error: %d"), error_code); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Unknown BLE error: %d"), error_code); #endif break; @@ -140,6 +140,6 @@ void check_notify(BaseType_t result) { void common_hal_bleio_check_connected(uint16_t conn_handle) { if (conn_handle == BLEIO_HANDLE_INVALID) { - mp_raise_ConnectionError(translate("Not connected")); + mp_raise_ConnectionError(MP_ERROR_TEXT("Not connected")); } } diff --git a/ports/espressif/common-hal/alarm/pin/PinAlarm.c b/ports/espressif/common-hal/alarm/pin/PinAlarm.c index 7d35b66d0c..28ba2fa87a 100644 --- a/ports/espressif/common-hal/alarm/pin/PinAlarm.c +++ b/ports/espressif/common-hal/alarm/pin/PinAlarm.c @@ -41,11 +41,11 @@ void common_hal_alarm_pin_pinalarm_construct(alarm_pin_pinalarm_obj_t *self, const mcu_pin_obj_t *pin, bool value, bool edge, bool pull) { if (edge) { - mp_raise_ValueError(translate("Cannot wake on pin edge. Only level.")); + mp_raise_ValueError(MP_ERROR_TEXT("Cannot wake on pin edge. Only level.")); } if (pull && !GPIO_IS_VALID_OUTPUT_GPIO(pin->number)) { - mp_raise_ValueError(translate("Cannot pull on input-only pin.")); + mp_raise_ValueError(MP_ERROR_TEXT("Cannot pull on input-only pin.")); } self->pin = pin; self->value = value; @@ -205,16 +205,16 @@ void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ob return; } if (deep_sleep && low_count > 2 && high_count == 0) { - mp_raise_ValueError(translate("Can only alarm on two low pins from deep sleep.")); + mp_raise_ValueError(MP_ERROR_TEXT("Can only alarm on two low pins from deep sleep.")); } if (deep_sleep && low_count > 1 && high_count > 0) { - mp_raise_ValueError(translate("Can only alarm on one low pin while others alarm high from deep sleep.")); + mp_raise_ValueError(MP_ERROR_TEXT("Can only alarm on one low pin while others alarm high from deep sleep.")); } // Only use ext0 and ext1 during deep sleep. if (deep_sleep) { if (high_count > 0) { if (esp_sleep_enable_ext1_wakeup(high_alarms, ESP_EXT1_WAKEUP_ANY_HIGH) != ESP_OK) { - mp_raise_ValueError(translate("Can only alarm on RTC IO from deep sleep.")); + mp_raise_ValueError(MP_ERROR_TEXT("Can only alarm on RTC IO from deep sleep.")); } esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON); } @@ -231,13 +231,13 @@ void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ob } if (low_count > 1) { if (esp_sleep_enable_ext1_wakeup(1ull << low_pins[1], ESP_EXT1_WAKEUP_ALL_LOW) != ESP_OK) { - mp_raise_ValueError(translate("Can only alarm on RTC IO from deep sleep.")); + mp_raise_ValueError(MP_ERROR_TEXT("Can only alarm on RTC IO from deep sleep.")); } esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON); } if (low_count > 0) { if (esp_sleep_enable_ext0_wakeup(low_pins[0], 0) != ESP_OK) { - mp_raise_ValueError(translate("Can only alarm on RTC IO from deep sleep.")); + mp_raise_ValueError(MP_ERROR_TEXT("Can only alarm on RTC IO from deep sleep.")); } } } else { @@ -249,7 +249,7 @@ void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ob pin_31_0_status = 0; pin_63_32_status = 0; if (gpio_isr_register(gpio_interrupt, NULL, 0, &gpio_interrupt_handle) != ESP_OK) { - mp_raise_ValueError(translate("Can only alarm on RTC IO from deep sleep.")); + mp_raise_ValueError(MP_ERROR_TEXT("Can only alarm on RTC IO from deep sleep.")); } for (size_t i = 0; i < 64; i++) { uint64_t mask = 1ull << i; diff --git a/ports/espressif/common-hal/alarm/time/TimeAlarm.c b/ports/espressif/common-hal/alarm/time/TimeAlarm.c index 758e3c8f58..13811ae3a9 100644 --- a/ports/espressif/common-hal/alarm/time/TimeAlarm.c +++ b/ports/espressif/common-hal/alarm/time/TimeAlarm.c @@ -91,7 +91,7 @@ void alarm_time_timealarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ continue; } if (timealarm_set) { - mp_raise_ValueError(translate("Only one alarm.time alarm can be set.")); + mp_raise_ValueError(MP_ERROR_TEXT("Only one alarm.time alarm can be set.")); } timealarm = MP_OBJ_TO_PTR(alarms[i]); timealarm_set = true; diff --git a/ports/espressif/common-hal/alarm/touch/TouchAlarm.c b/ports/espressif/common-hal/alarm/touch/TouchAlarm.c index f85ca5ad92..1432f7cd4c 100644 --- a/ports/espressif/common-hal/alarm/touch/TouchAlarm.c +++ b/ports/espressif/common-hal/alarm/touch/TouchAlarm.c @@ -98,7 +98,7 @@ void alarm_touch_touchalarm_set_alarm(const bool deep_sleep, const size_t n_alar for (size_t i = 0; i < n_alarms; i++) { if (mp_obj_is_type(alarms[i], &alarm_touch_touchalarm_type)) { if (deep_sleep && touch_alarm_set) { - mp_raise_ValueError_varg(translate("Only one %q can be set in deep sleep."), MP_QSTR_TouchAlarm); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Only one %q can be set in deep sleep."), MP_QSTR_TouchAlarm); } touch_alarm = MP_OBJ_TO_PTR(alarms[i]); touch_channel_mask |= 1 << touch_alarm->pin->number; diff --git a/ports/espressif/common-hal/analogbufio/BufferedIn.c b/ports/espressif/common-hal/analogbufio/BufferedIn.c index 47942c7c33..5c3a0c0977 100644 --- a/ports/espressif/common-hal/analogbufio/BufferedIn.c +++ b/ports/espressif/common-hal/analogbufio/BufferedIn.c @@ -249,7 +249,7 @@ uint32_t common_hal_analogbufio_bufferedin_readinto(analogbufio_bufferedin_obj_t adc_digi_output_format_t output_format = ADC_DIGI_OUTPUT_FORMAT_TYPE1; if (bytes_per_sample != 2) { - mp_raise_ValueError_varg(translate("%q must be array of type 'H'"), MP_QSTR_buffer); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q must be array of type 'H'"), MP_QSTR_buffer); } start_dma(self, &convert_mode, &output_format); diff --git a/ports/espressif/common-hal/audiobusio/I2SOut.c b/ports/espressif/common-hal/audiobusio/I2SOut.c index 7020f7cf59..ec914db8ff 100644 --- a/ports/espressif/common-hal/audiobusio/I2SOut.c +++ b/ports/espressif/common-hal/audiobusio/I2SOut.c @@ -50,7 +50,7 @@ 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, const mcu_pin_obj_t *main_clock, bool left_justified) { if (main_clock != NULL) { - mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_main_clock); + mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_main_clock); } port_i2s_allocate_init(&self->i2s, left_justified); diff --git a/ports/espressif/common-hal/audiobusio/__init__.c b/ports/espressif/common-hal/audiobusio/__init__.c index d05e40c772..1c46358aaf 100644 --- a/ports/espressif/common-hal/audiobusio/__init__.c +++ b/ports/espressif/common-hal/audiobusio/__init__.c @@ -138,7 +138,7 @@ void port_i2s_allocate_init(i2s_t *self, bool left_justified) { }; esp_err_t err = i2s_new_channel(&chan_config, &self->handle, NULL); if (err == ESP_ERR_NOT_FOUND) { - mp_raise_RuntimeError(translate("Peripheral in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Peripheral in use")); } i2s_event_callbacks_t callbacks = { diff --git a/ports/espressif/common-hal/busio/I2C.c b/ports/espressif/common-hal/busio/I2C.c index d3017e9587..a7b1cab906 100644 --- a/ports/espressif/common-hal/busio/I2C.c +++ b/ports/espressif/common-hal/busio/I2C.c @@ -70,13 +70,13 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, if (gpio_get_level(sda->number) == 0 || gpio_get_level(scl->number) == 0) { reset_pin_number(sda->number); reset_pin_number(scl->number); - mp_raise_RuntimeError(translate("No pull up found on SDA or SCL; check your wiring")); + mp_raise_RuntimeError(MP_ERROR_TEXT("No pull up found on SDA or SCL; check your wiring")); } #endif self->xSemaphore = xSemaphoreCreateMutex(); if (self->xSemaphore == NULL) { - mp_raise_RuntimeError(translate("Unable to create lock")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Unable to create lock")); } self->sda_pin = sda; self->scl_pin = scl; @@ -84,7 +84,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, self->has_lock = 0; if (self->i2c_num == I2C_NUM_MAX) { - mp_raise_ValueError(translate("All I2C peripherals are in use")); + mp_raise_ValueError(MP_ERROR_TEXT("All I2C peripherals are in use")); } // Delete any previous driver. @@ -113,7 +113,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, if (err == ESP_FAIL) { mp_raise_OSError(MP_EIO); } else { - mp_raise_RuntimeError(translate("init I2C")); + mp_raise_RuntimeError(MP_ERROR_TEXT("init I2C")); } } diff --git a/ports/espressif/common-hal/busio/SPI.c b/ports/espressif/common-hal/busio/SPI.c index 96a2226553..b79b908ef9 100644 --- a/ports/espressif/common-hal/busio/SPI.c +++ b/ports/espressif/common-hal/busio/SPI.c @@ -67,7 +67,7 @@ static void set_spi_config(busio_spi_obj_t *self, }; esp_err_t result = spi_bus_add_device(self->host_id, &device_config, &spi_handle[self->host_id]); if (result != ESP_OK) { - mp_raise_RuntimeError(translate("SPI configuration failed")); + mp_raise_RuntimeError(MP_ERROR_TEXT("SPI configuration failed")); } self->baudrate = closest_clock; self->polarity = polarity; @@ -88,7 +88,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, }; if (half_duplex) { - mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("Half duplex SPI is not implemented")); } for (spi_host_device_t host_id = SPI2_HOST; host_id < SOC_SPI_PERIPH_NUM; host_id++) { @@ -98,12 +98,12 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, } if (self->host_id == 0) { - mp_raise_ValueError(translate("All SPI peripherals are in use")); + mp_raise_ValueError(MP_ERROR_TEXT("All SPI peripherals are in use")); } esp_err_t result = spi_bus_initialize(self->host_id, &bus_config, SPI_DMA_CH_AUTO); if (result == ESP_ERR_NO_MEM) { - mp_raise_msg(&mp_type_MemoryError, translate("ESP-IDF memory allocation failed")); + mp_raise_msg(&mp_type_MemoryError, MP_ERROR_TEXT("ESP-IDF memory allocation failed")); } else if (result == ESP_ERR_INVALID_ARG) { raise_ValueError_invalid_pins(); } @@ -186,7 +186,7 @@ void common_hal_busio_spi_unlock(busio_spi_obj_t *self) { bool common_hal_busio_spi_write(busio_spi_obj_t *self, const uint8_t *data, size_t len) { if (self->MOSI == NULL) { - mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_mosi); + mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_mosi); } return common_hal_busio_spi_transfer(self, data, NULL, len); } @@ -194,7 +194,7 @@ bool common_hal_busio_spi_write(busio_spi_obj_t *self, bool common_hal_busio_spi_read(busio_spi_obj_t *self, uint8_t *data, size_t len, uint8_t write_value) { if (self->MISO == NULL) { - mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_miso); + mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_miso); } if (self->MOSI == NULL) { return common_hal_busio_spi_transfer(self, NULL, data, len); @@ -210,10 +210,10 @@ bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, return true; } if (self->MOSI == NULL && data_out != NULL) { - mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_mosi); + mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_mosi); } if (self->MISO == NULL && data_in != NULL) { - mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_miso); + mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_miso); } spi_transaction_t transactions[MAX_SPI_TRANSACTIONS]; diff --git a/ports/espressif/common-hal/busio/UART.c b/ports/espressif/common-hal/busio/UART.c index 386fe1f1b3..1770f88bd1 100644 --- a/ports/espressif/common-hal/busio/UART.c +++ b/ports/espressif/common-hal/busio/UART.c @@ -117,10 +117,10 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, // Filter for sane settings for RS485 if (have_rs485_dir) { if (have_rts || have_cts) { - mp_raise_ValueError(translate("Cannot specify RTS or CTS in RS485 mode")); + mp_raise_ValueError(MP_ERROR_TEXT("Cannot specify RTS or CTS in RS485 mode")); } } else if (rs485_invert) { - mp_raise_ValueError(translate("RS485 inversion specified when not in RS485 mode")); + mp_raise_ValueError(MP_ERROR_TEXT("RS485 inversion specified when not in RS485 mode")); } self->timeout_ms = timeout * 1000; @@ -132,7 +132,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, } } if (self->uart_num == UART_NUM_MAX) { - mp_raise_ValueError(translate("All UART peripherals are in use")); + mp_raise_ValueError(MP_ERROR_TEXT("All UART peripherals are in use")); } uart_mode_t mode = UART_MODE_UART; @@ -159,7 +159,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, // Install the driver before we change the settings. if (uart_driver_install(self->uart_num, receiver_buffer_size, 0, 20, &self->event_queue, 0) != ESP_OK || uart_set_mode(self->uart_num, mode) != ESP_OK) { - mp_raise_RuntimeError(translate("UART init")); + mp_raise_RuntimeError(MP_ERROR_TEXT("UART init")); } // On the console uart, enable pattern detection to look for CTRL+C @@ -233,7 +233,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, // config all in one? if (uart_param_config(self->uart_num, &uart_config) != ESP_OK) { - mp_raise_RuntimeError(translate("UART init")); + mp_raise_RuntimeError(MP_ERROR_TEXT("UART init")); } self->tx_pin = NULL; @@ -303,7 +303,7 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { // Read characters. size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) { if (self->rx_pin == NULL) { - mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_rx); + mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_rx); } if (len == 0) { // Nothing to read. @@ -356,7 +356,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t // Write characters. size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) { if (self->tx_pin == NULL) { - mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_tx); + mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_tx); } size_t left_to_write = len; diff --git a/ports/espressif/common-hal/canio/CAN.c b/ports/espressif/common-hal/canio/CAN.c index 67cf7b9591..c1c7f418cf 100644 --- a/ports/espressif/common-hal/canio/CAN.c +++ b/ports/espressif/common-hal/canio/CAN.c @@ -113,7 +113,7 @@ STATIC twai_timing_config_t get_t_config(int baudrate) { } #endif default: - mp_raise_ValueError(translate("Baudrate not supported by peripheral")); + mp_raise_ValueError(MP_ERROR_TEXT("Baudrate not supported by peripheral")); } } @@ -121,11 +121,11 @@ void common_hal_canio_can_construct(canio_can_obj_t *self, const mcu_pin_obj_t * #define DIV_ROUND(a, b) (((a) + (b) / 2) / (b)) #define DIV_ROUND_UP(a, b) (((a) + (b) - 1) / (b)) if (reserved_can) { - mp_raise_ValueError(translate("All CAN peripherals are in use")); + mp_raise_ValueError(MP_ERROR_TEXT("All CAN peripherals are in use")); } if (loopback && silent) { - mp_raise_ValueError(translate("loopback + silent mode not supported by peripheral")); + mp_raise_ValueError(MP_ERROR_TEXT("loopback + silent mode not supported by peripheral")); } twai_timing_config_t t_config = get_t_config(baudrate); @@ -143,16 +143,16 @@ void common_hal_canio_can_construct(canio_can_obj_t *self, const mcu_pin_obj_t * esp_err_t result = twai_driver_install(&g_config, &t_config, &f_config); if (result == ESP_ERR_NO_MEM) { - mp_raise_msg(&mp_type_MemoryError, translate("ESP-IDF memory allocation failed")); + mp_raise_msg(&mp_type_MemoryError, MP_ERROR_TEXT("ESP-IDF memory allocation failed")); } else if (result == ESP_ERR_INVALID_ARG) { raise_ValueError_invalid_pins(); } else if (result != ESP_OK) { - mp_raise_OSError_msg_varg(translate("twai_driver_install returned esp-idf error #%d"), (int)result); + mp_raise_OSError_msg_varg(MP_ERROR_TEXT("twai_driver_install returned esp-idf error #%d"), (int)result); } result = twai_start(); if (result != ESP_OK) { - mp_raise_OSError_msg_varg(translate("twai_start returned esp-idf error #%d"), (int)result); + mp_raise_OSError_msg_varg(MP_ERROR_TEXT("twai_start returned esp-idf error #%d"), (int)result); } self->silent = silent; diff --git a/ports/espressif/common-hal/canio/Listener.c b/ports/espressif/common-hal/canio/Listener.c index a6c0dbf90c..498cee45b0 100644 --- a/ports/espressif/common-hal/canio/Listener.c +++ b/ports/espressif/common-hal/canio/Listener.c @@ -88,10 +88,10 @@ STATIC void set_filters(canio_listener_obj_t *self, size_t nmatch, canio_match_o void common_hal_canio_listener_construct(canio_listener_obj_t *self, canio_can_obj_t *can, size_t nmatch, canio_match_obj_t **matches, float timeout) { if (can->fifo_in_use) { - mp_raise_ValueError(translate("All RX FIFOs in use")); + mp_raise_ValueError(MP_ERROR_TEXT("All RX FIFOs in use")); } if (nmatch > 1) { - mp_raise_ValueError(translate("Filters too complex")); + mp_raise_ValueError(MP_ERROR_TEXT("Filters too complex")); } // Nothing can fail now so it's safe to assign self->can diff --git a/ports/espressif/common-hal/countio/Counter.c b/ports/espressif/common-hal/countio/Counter.c index 4bea059b17..7ab7349bb6 100644 --- a/ports/espressif/common-hal/countio/Counter.c +++ b/ports/espressif/common-hal/countio/Counter.c @@ -51,7 +51,7 @@ void common_hal_countio_counter_construct(countio_counter_obj_t *self, // Initialize PCNT unit const int8_t unit = peripherals_pcnt_init(&pcnt_config); if (unit == -1) { - mp_raise_RuntimeError(translate("All PCNT units in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("All PCNT units in use")); } self->pin = pin->number; diff --git a/ports/espressif/common-hal/dotclockframebuffer/DotClockFramebuffer.c b/ports/espressif/common-hal/dotclockframebuffer/DotClockFramebuffer.c index ade19da396..7204a97d85 100644 --- a/ports/espressif/common-hal/dotclockframebuffer/DotClockFramebuffer.c +++ b/ports/espressif/common-hal/dotclockframebuffer/DotClockFramebuffer.c @@ -75,7 +75,7 @@ static void claim_and_record(const mcu_pin_obj_t *pin, uint64_t *used_pins_mask) static int valid_pin(const mcu_pin_obj_t *pin, qstr name) { int result = common_hal_mcu_pin_number(pin); if (result == NO_PIN) { - mp_raise_ValueError_varg(translate("Invalid %q pin"), name); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Invalid %q pin"), name); } return result; } @@ -94,7 +94,7 @@ void common_hal_dotclockframebuffer_framebuffer_construct(dotclockframebuffer_fr bool de_idle_high, bool pclk_active_high, bool pclk_idle_high, int overscan_left) { if (num_red != 5 || num_green != 6 || num_blue != 5) { - mp_raise_ValueError(translate("Must provide 5/6/5 RGB pins")); + mp_raise_ValueError(MP_ERROR_TEXT("Must provide 5/6/5 RGB pins")); } claim_and_record(de, &self->used_pins_mask); diff --git a/ports/espressif/common-hal/dualbank/__init__.c b/ports/espressif/common-hal/dualbank/__init__.c index b3151f268d..303dc7d7cf 100644 --- a/ports/espressif/common-hal/dualbank/__init__.c +++ b/ports/espressif/common-hal/dualbank/__init__.c @@ -47,7 +47,7 @@ void dualbank_reset(void) { static void __attribute__((noreturn)) task_fatal_error(void) { ESP_LOGE(TAG, "Exiting task due to fatal error..."); - mp_raise_RuntimeError(translate("Update Failed")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Update Failed")); } void common_hal_dualbank_flash(const void *buf, const size_t len, const size_t offset) { @@ -86,14 +86,14 @@ void common_hal_dualbank_flash(const void *buf, const size_t len, const size_t o // check new version with running version if (memcmp(new_app_info.version, running_app_info.version, sizeof(new_app_info.version)) == 0) { ESP_LOGW(TAG, "New version is the same as running version."); - mp_raise_RuntimeError(translate("Firmware is duplicate")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Firmware is duplicate")); } // check new version with last invalid partition if (last_invalid != NULL) { if (memcmp(new_app_info.version, invalid_app_info.version, sizeof(new_app_info.version)) == 0) { ESP_LOGW(TAG, "New version is the same as invalid version."); - mp_raise_RuntimeError(translate("Firmware is invalid")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Firmware is invalid")); } } @@ -104,7 +104,7 @@ void common_hal_dualbank_flash(const void *buf, const size_t len, const size_t o } } else { ESP_LOGE(TAG, "received package is not fit len"); - mp_raise_RuntimeError(translate("Firmware is too big")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Firmware is too big")); } } @@ -128,7 +128,7 @@ void common_hal_dualbank_switch(void) { if (err != ESP_OK) { if (err == ESP_ERR_OTA_VALIDATE_FAILED) { ESP_LOGE(TAG, "Image validation failed, image is corrupted"); - mp_raise_RuntimeError(translate("Firmware is invalid")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Firmware is invalid")); } ESP_LOGE(TAG, "esp_ota_set_boot_partition failed (%s)!", esp_err_to_name(err)); task_fatal_error(); diff --git a/ports/espressif/common-hal/espcamera/Camera.c b/ports/espressif/common-hal/espcamera/Camera.c index cdf7ab63c8..446e83d226 100644 --- a/ports/espressif/common-hal/espcamera/Camera.c +++ b/ports/espressif/common-hal/espcamera/Camera.c @@ -78,7 +78,7 @@ void common_hal_espcamera_camera_construct( camera_grab_mode_t grab_mode) { if (common_hal_espidf_get_reserved_psram() == 0) { - mp_raise_msg(&mp_type_MemoryError, translate( + mp_raise_msg(&mp_type_MemoryError, MP_ERROR_TEXT( "espcamera.Camera requires reserved PSRAM to be configured. See the documentation for instructions.")); } for (int i = 0; i < 8; i++) { @@ -197,7 +197,7 @@ camera_fb_t *common_hal_espcamera_camera_take(espcamera_camera_obj_t *self, int sensor_t *sensor = esp_camera_sensor_get(); \ i2c_unlock(self); \ if (!sensor->setter_function_name) { \ - mp_raise_AttributeError(translate("no such attribute")); \ + mp_raise_AttributeError(MP_ERROR_TEXT("no such attribute")); \ } \ return sensor->status_field_name; \ } @@ -208,10 +208,10 @@ camera_fb_t *common_hal_espcamera_camera_take(espcamera_camera_obj_t *self, int sensor_t *sensor = esp_camera_sensor_get(); \ i2c_unlock(self); \ if (!sensor->setter_function_name) { \ - mp_raise_AttributeError(translate("no such attribute")); \ + mp_raise_AttributeError(MP_ERROR_TEXT("no such attribute")); \ } \ if (sensor->setter_function_name(sensor, value) < 0) { \ - mp_raise_ValueError(translate("invalid setting")); \ + mp_raise_ValueError(MP_ERROR_TEXT("invalid setting")); \ } \ } diff --git a/ports/espressif/common-hal/espidf/__init__.c b/ports/espressif/common-hal/espidf/__init__.c index 377faab166..c81a961e89 100644 --- a/ports/espressif/common-hal/espidf/__init__.c +++ b/ports/espressif/common-hal/espidf/__init__.c @@ -126,41 +126,41 @@ void raise_esp_error(esp_err_t err) { const mp_obj_type_t *exception_type = &mp_type_espidf_IDFError; switch (err) { case ESP_FAIL: - msg = translate("Generic Failure"); + msg = MP_ERROR_TEXT("Generic Failure"); break; case ESP_ERR_NO_MEM: exception_type = &mp_type_espidf_MemoryError; - msg = translate("Out of memory"); + msg = MP_ERROR_TEXT("Out of memory"); break; case ESP_ERR_INVALID_ARG: - msg = translate("Invalid argument"); + msg = MP_ERROR_TEXT("Invalid argument"); break; case ESP_ERR_INVALID_STATE: - msg = translate("Invalid state"); + msg = MP_ERROR_TEXT("Invalid state"); break; case ESP_ERR_INVALID_SIZE: - msg = translate("Invalid size"); + msg = MP_ERROR_TEXT("Invalid size"); break; case ESP_ERR_NOT_FOUND: - msg = translate("Requested resource not found"); + msg = MP_ERROR_TEXT("Requested resource not found"); break; case ESP_ERR_NOT_SUPPORTED: - msg = translate("Operation or feature not supported"); + msg = MP_ERROR_TEXT("Operation or feature not supported"); break; case ESP_ERR_TIMEOUT: - msg = translate("Operation timed out"); + msg = MP_ERROR_TEXT("Operation timed out"); break; case ESP_ERR_INVALID_RESPONSE: - msg = translate("Received response was invalid"); + msg = MP_ERROR_TEXT("Received response was invalid"); break; case ESP_ERR_INVALID_CRC: - msg = translate("CRC or checksum was invalid"); + msg = MP_ERROR_TEXT("CRC or checksum was invalid"); break; case ESP_ERR_INVALID_VERSION: - msg = translate("Version was invalid"); + msg = MP_ERROR_TEXT("Version was invalid"); break; case ESP_ERR_INVALID_MAC: - msg = translate("MAC address was invalid"); + msg = MP_ERROR_TEXT("MAC address was invalid"); break; } if (msg) { @@ -184,7 +184,7 @@ void raise_esp_error(esp_err_t err) { group = "WiFi"; } - mp_raise_msg_varg(exception_type, translate("%s error 0x%x"), group, err); + mp_raise_msg_varg(exception_type, MP_ERROR_TEXT("%s error 0x%x"), group, err); } void cp_check_esp_error(esp_err_t err) { diff --git a/ports/espressif/common-hal/espulp/ULP.c b/ports/espressif/common-hal/espulp/ULP.c index d8bb0be597..ef050c6e03 100644 --- a/ports/espressif/common-hal/espulp/ULP.c +++ b/ports/espressif/common-hal/espulp/ULP.c @@ -56,7 +56,7 @@ void espulp_reset(void) { void common_hal_espulp_ulp_run(espulp_ulp_obj_t *self, uint32_t *program, size_t length, uint32_t pin_mask) { if (length > CONFIG_ULP_COPROC_RESERVE_MEM) { - mp_raise_ValueError(translate("Program too long")); + mp_raise_ValueError(MP_ERROR_TEXT("Program too long")); } if ( @@ -66,7 +66,7 @@ void common_hal_espulp_ulp_run(espulp_ulp_obj_t *self, uint32_t *program, size_t GET_PERI_REG_MASK(RTC_CNTL_ULP_CP_TIMER_REG, RTC_CNTL_ULP_CP_SLP_TIMER_EN) #endif ) { - mp_raise_RuntimeError(translate("Already running")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Already running")); } if (pin_mask >= (1 << 22)) { @@ -75,7 +75,7 @@ void common_hal_espulp_ulp_run(espulp_ulp_obj_t *self, uint32_t *program, size_t for (uint8_t i = 0; i < 32; i++) { if ((pin_mask & (1 << i)) != 0 && !pin_number_is_free(i)) { - mp_raise_ValueError_varg(translate("%q in use"), MP_QSTR_Pin); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q in use"), MP_QSTR_Pin); } } @@ -140,7 +140,7 @@ void common_hal_espulp_ulp_construct(espulp_ulp_obj_t *self, espulp_architecture // use a running ULP. This is only to prevent multiple portions of user code // from using the ULP concurrently. if (ulp_used) { - mp_raise_ValueError_varg(translate("%q in use"), MP_QSTR_ULP); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q in use"), MP_QSTR_ULP); } switch (arch) { diff --git a/ports/espressif/common-hal/espulp/ULPAlarm.c b/ports/espressif/common-hal/espulp/ULPAlarm.c index 798d86ce29..1a1a5d33b5 100644 --- a/ports/espressif/common-hal/espulp/ULPAlarm.c +++ b/ports/espressif/common-hal/espulp/ULPAlarm.c @@ -69,7 +69,7 @@ void espulp_ulpalarm_set_alarm(const bool deep_sleep, const size_t n_alarms, con for (size_t i = 0; i < n_alarms; i++) { if (mp_obj_is_type(alarms[i], &espulp_ulpalarm_type)) { if (alarm != MP_OBJ_NULL) { - mp_raise_ValueError_varg(translate("Only one %q can be set."), MP_QSTR_ULPAlarm); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Only one %q can be set."), MP_QSTR_ULPAlarm); } alarm = MP_OBJ_TO_PTR(alarms[i]); } diff --git a/ports/espressif/common-hal/frequencyio/FrequencyIn.c b/ports/espressif/common-hal/frequencyio/FrequencyIn.c index 92e76f1207..362a186104 100644 --- a/ports/espressif/common-hal/frequencyio/FrequencyIn.c +++ b/ports/espressif/common-hal/frequencyio/FrequencyIn.c @@ -95,7 +95,7 @@ static void init_pcnt(frequencyio_frequencyin_obj_t *self) { // initialize PCNT const int8_t unit = peripherals_pcnt_init(&pcnt_config); if (unit == -1) { - mp_raise_RuntimeError(translate("All PCNT units in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("All PCNT units in use")); } // set the GPIO back to high-impedance, as pcnt_unit_config sets it as pull-up @@ -123,7 +123,7 @@ static void init_timer(frequencyio_frequencyin_obj_t *self) { // initialize Timer peripherals_timer_init(&config, &self->timer); if (self->timer.idx == TIMER_MAX || self->timer.group == TIMER_GROUP_MAX) { - mp_raise_RuntimeError(translate("All timers in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("All timers in use")); } timer_idx_t idx = self->timer.idx; diff --git a/ports/espressif/common-hal/i2ctarget/I2CTarget.c b/ports/espressif/common-hal/i2ctarget/I2CTarget.c index ad0d09967a..a4cce8df7b 100644 --- a/ports/espressif/common-hal/i2ctarget/I2CTarget.c +++ b/ports/espressif/common-hal/i2ctarget/I2CTarget.c @@ -44,7 +44,7 @@ void common_hal_i2ctarget_i2c_target_construct(i2ctarget_i2c_target_obj_t *self, } if (num_addresses > 1) { - mp_raise_ValueError(translate("Only one address is allowed")); + mp_raise_ValueError(MP_ERROR_TEXT("Only one address is allowed")); } self->addresses = addresses; self->num_addresses = num_addresses; @@ -54,7 +54,7 @@ void common_hal_i2ctarget_i2c_target_construct(i2ctarget_i2c_target_obj_t *self, self->i2c_num = peripherals_i2c_get_free_num(); if (self->i2c_num == I2C_NUM_MAX) { - mp_raise_ValueError(translate("All I2C peripherals are in use")); + mp_raise_ValueError(MP_ERROR_TEXT("All I2C peripherals are in use")); } const i2c_config_t i2c_conf = { diff --git a/ports/espressif/common-hal/imagecapture/ParallelImageCapture.c b/ports/espressif/common-hal/imagecapture/ParallelImageCapture.c index 7456e474a9..ba5aa869bd 100644 --- a/ports/espressif/common-hal/imagecapture/ParallelImageCapture.c +++ b/ports/espressif/common-hal/imagecapture/ParallelImageCapture.c @@ -115,7 +115,7 @@ void common_hal_imagecapture_parallelimagecapture_continuous_capture_start(image if (buffer2 != mp_const_none) { mp_get_buffer_raise(buffer2, &bufinfo2, MP_BUFFER_RW); if (bufinfo1.len != bufinfo2.len) { - mp_raise_ValueError(translate("Buffers must be same size")); + mp_raise_ValueError(MP_ERROR_TEXT("Buffers must be same size")); } } @@ -148,7 +148,7 @@ STATIC void common_hal_imagecapture_parallelimagecapture_continuous_capture_give mp_obj_t common_hal_imagecapture_parallelimagecapture_continuous_capture_get_frame(imagecapture_parallelimagecapture_obj_t *self) { if (self->buffer1 == NULL) { - mp_raise_RuntimeError(translate("No capture in progress")); + mp_raise_RuntimeError(MP_ERROR_TEXT("No capture in progress")); } common_hal_imagecapture_parallelimagecapture_continuous_capture_give_frame(self); diff --git a/ports/espressif/common-hal/mdns/Server.c b/ports/espressif/common-hal/mdns/Server.c index 3ee15e1025..5511b8d683 100644 --- a/ports/espressif/common-hal/mdns/Server.c +++ b/ports/espressif/common-hal/mdns/Server.c @@ -78,12 +78,12 @@ void mdns_server_construct(mdns_server_obj_t *self, bool workflow) { void common_hal_mdns_server_construct(mdns_server_obj_t *self, mp_obj_t network_interface) { if (network_interface != MP_OBJ_FROM_PTR(&common_hal_wifi_radio_obj)) { - mp_raise_ValueError(translate("mDNS only works with built-in WiFi")); + mp_raise_ValueError(MP_ERROR_TEXT("mDNS only works with built-in WiFi")); return; } mdns_server_construct(self, false); if (common_hal_mdns_server_deinited(self)) { - mp_raise_RuntimeError(translate("mDNS already initialized")); + mp_raise_RuntimeError(MP_ERROR_TEXT("mDNS already initialized")); } } @@ -167,7 +167,7 @@ size_t mdns_server_find(mdns_server_obj_t *self, const char *service_type, const mp_obj_t common_hal_mdns_server_find(mdns_server_obj_t *self, const char *service_type, const char *protocol, mp_float_t timeout) { mdns_search_once_t *search = mdns_query_async_new(NULL, service_type, protocol, MDNS_TYPE_PTR, timeout * 1000, 255, NULL); if (search == NULL) { - mp_raise_RuntimeError(translate("Unable to start mDNS query")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Unable to start mDNS query")); } uint8_t num_results; mdns_result_t *results; diff --git a/ports/espressif/common-hal/memorymap/AddressRange.c b/ports/espressif/common-hal/memorymap/AddressRange.c index 9e87e5384b..121221df77 100644 --- a/ports/espressif/common-hal/memorymap/AddressRange.c +++ b/ports/espressif/common-hal/memorymap/AddressRange.c @@ -53,7 +53,7 @@ void common_hal_memorymap_addressrange_construct(memorymap_addressrange_obj_t *s } if (!allowed) { - mp_raise_ValueError(translate("Address range not allowed")); + mp_raise_ValueError(MP_ERROR_TEXT("Address range not allowed")); } self->start_address = start_address; diff --git a/ports/espressif/common-hal/neopixel_write/__init__.c b/ports/espressif/common-hal/neopixel_write/__init__.c index 6d91cc7766..7361524cc6 100644 --- a/ports/espressif/common-hal/neopixel_write/__init__.c +++ b/ports/espressif/common-hal/neopixel_write/__init__.c @@ -95,7 +95,7 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t *digitalinout, uint8_t number = digitalinout->pin->number; rmt_channel_t channel = peripherals_find_and_reserve_rmt(TRANSMIT_MODE); if (channel == RMT_CHANNEL_MAX) { - mp_raise_RuntimeError(translate("All timers in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("All timers in use")); } // Configure Channel @@ -107,7 +107,7 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t *digitalinout, // Convert NS timings to ticks uint32_t counter_clk_hz = 0; if (rmt_get_counter_clock(config.channel, &counter_clk_hz) != ESP_OK) { - mp_raise_RuntimeError(translate("Could not retrieve clock")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Could not retrieve clock")); } size_t ns_per_tick = 1e9 / counter_clk_hz; ws2812_t0h_ticks = WS2812_T0H_NS / ns_per_tick; @@ -125,7 +125,7 @@ void common_hal_neopixel_write(const digitalio_digitalinout_obj_t *digitalinout, // Write and wait to finish if (rmt_write_sample(config.channel, pixels, (size_t)numBytes, true) != ESP_OK) { - mp_raise_RuntimeError(translate("Input/output error")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Input/output error")); } rmt_wait_tx_done(config.channel, pdMS_TO_TICKS(100)); diff --git a/ports/espressif/common-hal/nvm/ByteArray.c b/ports/espressif/common-hal/nvm/ByteArray.c index d74de38164..4c6c370d43 100644 --- a/ports/espressif/common-hal/nvm/ByteArray.c +++ b/ports/espressif/common-hal/nvm/ByteArray.c @@ -51,7 +51,7 @@ static void get_nvs_handle(nvs_handle_t *nvs_handle) { // Open NVS handle if (nvs_open("CPY", NVS_READWRITE, nvs_handle) != ESP_OK) { - mp_raise_RuntimeError(translate("NVS Error")); + mp_raise_RuntimeError(MP_ERROR_TEXT("NVS Error")); } } diff --git a/ports/espressif/common-hal/paralleldisplaybus/ParallelBus.c b/ports/espressif/common-hal/paralleldisplaybus/ParallelBus.c index 352c6d4a9b..61a08c163c 100644 --- a/ports/espressif/common-hal/paralleldisplaybus/ParallelBus.c +++ b/ports/espressif/common-hal/paralleldisplaybus/ParallelBus.c @@ -49,12 +49,12 @@ void common_hal_paralleldisplaybus_parallelbus_construct_nonsequential(paralleld const mcu_pin_obj_t *write, const mcu_pin_obj_t *read, const mcu_pin_obj_t *reset, uint32_t frequency) { if (n_pins != 8 && n_pins != 16) { - mp_raise_ValueError_varg(translate("Number of data_pins must be 8 or 16, not %d"), n_pins); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Number of data_pins must be 8 or 16, not %d"), n_pins); } for (uint8_t i = 0; i < n_pins; i++) { if (!common_hal_mcu_pin_is_free(data_pins[i])) { - mp_raise_ValueError_varg(translate("Bus pin %d is already in use"), i); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Bus pin %d is already in use"), i); } } @@ -106,7 +106,7 @@ void common_hal_paralleldisplaybus_parallelbus_construct_nonsequential(paralleld if (!self->handle) { port_i2s_reset_instance(0); - mp_raise_RuntimeError(translate("Internal error")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Internal error")); } } diff --git a/ports/espressif/common-hal/pulseio/PulseIn.c b/ports/espressif/common-hal/pulseio/PulseIn.c index c873f13b4a..cecefa6419 100644 --- a/ports/espressif/common-hal/pulseio/PulseIn.c +++ b/ports/espressif/common-hal/pulseio/PulseIn.c @@ -118,7 +118,7 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t *self, const mcu // Find a free RMT Channel and configure it rmt_channel_t channel = peripherals_find_and_reserve_rmt(RECEIVE_MODE); if (channel == RMT_CHANNEL_MAX) { - mp_raise_RuntimeError(translate("All timers in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("All timers in use")); } rmt_config_t config = RMT_DEFAULT_CONFIG_RX(pin->number, channel); config.rx_config.filter_en = true; @@ -189,7 +189,7 @@ uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t *self, int16_ index += self->len; } if (index < 0 || index >= self->len) { - mp_raise_IndexError(translate("index out of range")); + mp_raise_IndexError(MP_ERROR_TEXT("index out of range")); } uint16_t value = self->buffer[(self->start + index) % self->maxlen]; return value; @@ -199,7 +199,7 @@ uint16_t common_hal_pulseio_pulsein_popleft(pulseio_pulsein_obj_t *self) { update_internal_buffer(self); if (self->len == 0) { - mp_raise_IndexError(translate("pop from an empty PulseIn")); + mp_raise_IndexError(MP_ERROR_TEXT("pop from an empty PulseIn")); } uint16_t value = self->buffer[self->start]; diff --git a/ports/espressif/common-hal/pulseio/PulseOut.c b/ports/espressif/common-hal/pulseio/PulseOut.c index 773c2bf107..2c37816bdc 100644 --- a/ports/espressif/common-hal/pulseio/PulseOut.c +++ b/ports/espressif/common-hal/pulseio/PulseOut.c @@ -39,7 +39,7 @@ void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t *self, rmt_channel_t channel = peripherals_find_and_reserve_rmt(TRANSMIT_MODE); if (channel == RMT_CHANNEL_MAX) { - mp_raise_RuntimeError(translate("All timers in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("All timers in use")); } // Configure Channel diff --git a/ports/espressif/common-hal/rotaryio/IncrementalEncoder.c b/ports/espressif/common-hal/rotaryio/IncrementalEncoder.c index 088f4a15dc..bbb8df9534 100644 --- a/ports/espressif/common-hal/rotaryio/IncrementalEncoder.c +++ b/ports/espressif/common-hal/rotaryio/IncrementalEncoder.c @@ -52,7 +52,7 @@ void common_hal_rotaryio_incrementalencoder_construct(rotaryio_incrementalencode // Allocate and initialize PCNT unit, CHANNEL_0. const int8_t unit = peripherals_pcnt_init(&pcnt_config_channel_0); if (unit == -1) { - mp_raise_RuntimeError(translate("All PCNT units in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("All PCNT units in use")); } pcnt_config_t pcnt_config_channel_1 = { diff --git a/ports/espressif/common-hal/rtc/RTC.c b/ports/espressif/common-hal/rtc/RTC.c index 866f9b65a0..82a85d5c28 100644 --- a/ports/espressif/common-hal/rtc/RTC.c +++ b/ports/espressif/common-hal/rtc/RTC.c @@ -48,5 +48,5 @@ int common_hal_rtc_get_calibration(void) { } void common_hal_rtc_set_calibration(int calibration) { - mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_calibration); + mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_calibration); } diff --git a/ports/espressif/common-hal/socketpool/Socket.c b/ports/espressif/common-hal/socketpool/Socket.c index f063873df9..1e59054fb1 100644 --- a/ports/espressif/common-hal/socketpool/Socket.c +++ b/ports/espressif/common-hal/socketpool/Socket.c @@ -243,14 +243,14 @@ bool 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) { if (family != SOCKETPOOL_AF_INET) { - mp_raise_NotImplementedError(translate("Only IPv4 sockets supported")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("Only IPv4 sockets supported")); } socketpool_socket_obj_t *sock = m_new_obj_with_finaliser(socketpool_socket_obj_t); sock->base.type = &socketpool_socket_type; if (!_socketpool_socket(self, family, type, sock)) { - mp_raise_RuntimeError(translate("Out of sockets")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Out of sockets")); } mark_user_socket(sock->num, sock); return sock; @@ -349,7 +349,7 @@ bool common_hal_socketpool_socket_bind(socketpool_socket_obj_t *self, int opt = 1; int err = lwip_setsockopt(self->num, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)); if (err != 0) { - mp_raise_RuntimeError(translate("Cannot set socket options")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Cannot set socket options")); } int result = lwip_bind(self->num, (struct sockaddr *)&bind_addr, sizeof(bind_addr)); return result == 0; diff --git a/ports/espressif/common-hal/socketpool/SocketPool.c b/ports/espressif/common-hal/socketpool/SocketPool.c index 9137ac3c8f..6d58126c31 100644 --- a/ports/espressif/common-hal/socketpool/SocketPool.c +++ b/ports/espressif/common-hal/socketpool/SocketPool.c @@ -36,7 +36,7 @@ void common_hal_socketpool_socketpool_construct(socketpool_socketpool_obj_t *self, mp_obj_t radio) { if (radio != MP_OBJ_FROM_PTR(&common_hal_wifi_radio_obj)) { - mp_raise_ValueError(translate("SocketPool can only be used with wifi.radio")); + mp_raise_ValueError(MP_ERROR_TEXT("SocketPool can only be used with wifi.radio")); } } diff --git a/ports/espressif/common-hal/ssl/SSLContext.c b/ports/espressif/common-hal/ssl/SSLContext.c index c583cecaa7..fd41549e75 100644 --- a/ports/espressif/common-hal/ssl/SSLContext.c +++ b/ports/espressif/common-hal/ssl/SSLContext.c @@ -42,7 +42,7 @@ ssl_sslsocket_obj_t *common_hal_ssl_sslcontext_wrap_socket(ssl_sslcontext_obj_t socketpool_socket_obj_t *socket, bool server_side, const char *server_hostname) { if (socket->type != SOCK_STREAM) { - mp_raise_RuntimeError(translate("Invalid socket for TLS")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Invalid socket for TLS")); } ssl_sslsocket_obj_t *sock = m_new_obj_with_finaliser(ssl_sslsocket_obj_t); diff --git a/ports/espressif/common-hal/ssl/SSLSocket.c b/ports/espressif/common-hal/ssl/SSLSocket.c index b94924000b..68028e774c 100644 --- a/ports/espressif/common-hal/ssl/SSLSocket.c +++ b/ports/espressif/common-hal/ssl/SSLSocket.c @@ -71,9 +71,9 @@ void common_hal_ssl_sslsocket_connect(ssl_sslsocket_obj_t *self, if (err == ESP_ERR_MBEDTLS_SSL_SETUP_FAILED) { mp_raise_espidf_MemoryError(); } else if (err == ESP_ERR_MBEDTLS_SSL_HANDSHAKE_FAILED) { - mp_raise_OSError_msg_varg(translate("Failed SSL handshake")); + mp_raise_OSError_msg_varg(MP_ERROR_TEXT("Failed SSL handshake")); } else { - mp_raise_OSError_msg_varg(translate("Unhandled ESP TLS error %d %d %x %d"), esp_tls_code, flags, err, result); + mp_raise_OSError_msg_varg(MP_ERROR_TEXT("Unhandled ESP TLS error %d %d %x %d"), esp_tls_code, flags, err, result); } } else { // Connection successful, set the timeout on the underlying socket. We can't rely on the IDF @@ -167,9 +167,9 @@ mp_uint_t common_hal_ssl_sslsocket_send(ssl_sslsocket_obj_t *self, const uint8_t if (err == ESP_ERR_MBEDTLS_SSL_SETUP_FAILED) { mp_raise_espidf_MemoryError(); } else if (err == ESP_ERR_MBEDTLS_SSL_HANDSHAKE_FAILED) { - mp_raise_OSError_msg_varg(translate("Failed SSL handshake")); + mp_raise_OSError_msg_varg(MP_ERROR_TEXT("Failed SSL handshake")); } else { - mp_raise_OSError_msg_varg(translate("Unhandled ESP TLS error %d %d %x %d"), esp_tls_code, flags, err, sent); + mp_raise_OSError_msg_varg(MP_ERROR_TEXT("Unhandled ESP TLS error %d %d %x %d"), esp_tls_code, flags, err, sent); } } return sent; diff --git a/ports/espressif/common-hal/watchdog/WatchDogTimer.c b/ports/espressif/common-hal/watchdog/WatchDogTimer.c index 68437958e5..1410b67b8d 100644 --- a/ports/espressif/common-hal/watchdog/WatchDogTimer.c +++ b/ports/espressif/common-hal/watchdog/WatchDogTimer.c @@ -90,7 +90,7 @@ void common_hal_watchdog_set_timeout(watchdog_watchdogtimer_obj_t *self, mp_floa } if ((uint64_t)new_timeout > UINT32_MAX) { - mp_raise_ValueError_varg(translate("%q must be <= %u"), MP_QSTR_timeout, UINT32_MAX); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q must be <= %u"), MP_QSTR_timeout, UINT32_MAX); } self->timeout = new_timeout; diff --git a/ports/espressif/common-hal/wifi/Monitor.c b/ports/espressif/common-hal/wifi/Monitor.c index f4d3a9f135..1fe99f955b 100644 --- a/ports/espressif/common-hal/wifi/Monitor.c +++ b/ports/espressif/common-hal/wifi/Monitor.c @@ -78,7 +78,7 @@ static void wifi_monitor_cb(void *recv_buf, wifi_promiscuous_pkt_type_t type) { } void common_hal_wifi_monitor_construct(wifi_monitor_obj_t *self, uint8_t channel, size_t queue) { - mp_rom_error_text_t monitor_mode_init_error = translate("monitor init failed"); + mp_rom_error_text_t monitor_mode_init_error = MP_ERROR_TEXT("monitor init failed"); self->queue = xQueueCreate(queue, sizeof(monitor_packet_t)); if (!self->queue) { diff --git a/ports/espressif/common-hal/wifi/Radio.c b/ports/espressif/common-hal/wifi/Radio.c index 752fd88d22..8ab299f006 100644 --- a/ports/espressif/common-hal/wifi/Radio.c +++ b/ports/espressif/common-hal/wifi/Radio.c @@ -132,10 +132,10 @@ mp_obj_t common_hal_wifi_radio_get_mac_address(wifi_radio_obj_t *self) { void common_hal_wifi_radio_set_mac_address(wifi_radio_obj_t *self, const uint8_t *mac) { if (!self->sta_mode) { - mp_raise_RuntimeError(translate("Interface must be started")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Interface must be started")); } if ((mac[0] & 0b1) == 0b1) { - mp_raise_RuntimeError(translate("Invalid multicast MAC address")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Invalid multicast MAC address")); } esp_wifi_set_mac(ESP_IF_WIFI_STA, mac); } @@ -158,20 +158,20 @@ mp_obj_t common_hal_wifi_radio_get_mac_address_ap(wifi_radio_obj_t *self) { void common_hal_wifi_radio_set_mac_address_ap(wifi_radio_obj_t *self, const uint8_t *mac) { if (!self->ap_mode) { - mp_raise_RuntimeError(translate("Interface must be started")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Interface must be started")); } if ((mac[0] & 0b1) == 0b1) { - mp_raise_RuntimeError(translate("Invalid multicast MAC address")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Invalid multicast MAC address")); } esp_wifi_set_mac(ESP_IF_WIFI_AP, mac); } mp_obj_t common_hal_wifi_radio_start_scanning_networks(wifi_radio_obj_t *self, uint8_t start_channel, uint8_t stop_channel) { if (self->current_scan != NULL) { - mp_raise_RuntimeError(translate("Already scanning for wifi networks")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Already scanning for wifi networks")); } if (!common_hal_wifi_radio_get_enabled(self)) { - mp_raise_RuntimeError(translate("wifi is not enabled")); + mp_raise_RuntimeError(MP_ERROR_TEXT("wifi is not enabled")); } set_mode_station(self, true); @@ -252,7 +252,7 @@ void common_hal_wifi_radio_stop_ap(wifi_radio_obj_t *self) { 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) { if (!common_hal_wifi_radio_get_enabled(self)) { - mp_raise_RuntimeError(translate("wifi is not enabled")); + mp_raise_RuntimeError(MP_ERROR_TEXT("wifi is not enabled")); } wifi_config_t *config = &self->sta_config; diff --git a/ports/espressif/common-hal/wifi/ScannedNetworks.c b/ports/espressif/common-hal/wifi/ScannedNetworks.c index e37bdc2f44..d6527969da 100644 --- a/ports/espressif/common-hal/wifi/ScannedNetworks.c +++ b/ports/espressif/common-hal/wifi/ScannedNetworks.c @@ -105,7 +105,7 @@ mp_obj_t common_hal_wifi_scannednetworks_next(wifi_scannednetworks_obj_t *self) } else { if (self->max_results == 0) { // No room for any results should error. - mp_raise_msg(&mp_type_MemoryError, translate("Failed to allocate wifi scan memory")); + mp_raise_msg(&mp_type_MemoryError, MP_ERROR_TEXT("Failed to allocate wifi scan memory")); } // Unable to allocate more results, so load what we can. self->total_results = self->max_results; diff --git a/ports/espressif/common-hal/wifi/__init__.c b/ports/espressif/common-hal/wifi/__init__.c index 970eb8eb04..1d226ea6fd 100644 --- a/ports/espressif/common-hal/wifi/__init__.c +++ b/ports/espressif/common-hal/wifi/__init__.c @@ -204,7 +204,7 @@ void common_hal_wifi_init(bool user_initiated) { esp_err_t result = esp_wifi_init(&config); if (result == ESP_ERR_NO_MEM) { if (gc_alloc_possible()) { - mp_raise_msg(&mp_type_MemoryError, translate("Failed to allocate Wifi memory")); + mp_raise_msg(&mp_type_MemoryError, MP_ERROR_TEXT("Failed to allocate Wifi memory")); } ESP_LOGE(TAG, "Failed to allocate Wifi memory"); } else if (result != ESP_OK) { @@ -253,7 +253,7 @@ void wifi_reset(void) { void ipaddress_ipaddress_to_esp_idf(mp_obj_t ip_address, ip_addr_t *esp_ip_address) { if (!mp_obj_is_type(ip_address, &ipaddress_ipv4address_type)) { - mp_raise_ValueError(translate("Only IPv4 addresses supported")); + mp_raise_ValueError(MP_ERROR_TEXT("Only IPv4 addresses supported")); } mp_obj_t packed = common_hal_ipaddress_ipv4address_get_packed(ip_address); size_t len; @@ -264,7 +264,7 @@ void ipaddress_ipaddress_to_esp_idf(mp_obj_t ip_address, ip_addr_t *esp_ip_addre void ipaddress_ipaddress_to_esp_idf_ip4(mp_obj_t ip_address, esp_ip4_addr_t *esp_ip_address) { if (!mp_obj_is_type(ip_address, &ipaddress_ipv4address_type)) { - mp_raise_ValueError(translate("Only IPv4 addresses supported")); + mp_raise_ValueError(MP_ERROR_TEXT("Only IPv4 addresses supported")); } mp_obj_t packed = common_hal_ipaddress_ipv4address_get_packed(ip_address); size_t len; diff --git a/ports/mimxrt10xx/common-hal/analogio/AnalogOut.c b/ports/mimxrt10xx/common-hal/analogio/AnalogOut.c index 28c134f2b2..616ca187b9 100644 --- a/ports/mimxrt10xx/common-hal/analogio/AnalogOut.c +++ b/ports/mimxrt10xx/common-hal/analogio/AnalogOut.c @@ -31,7 +31,7 @@ #include "shared-bindings/microcontroller/Pin.h" void common_hal_analogio_analogout_construct(analogio_analogout_obj_t *self, const mcu_pin_obj_t *pin) { - mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_AnalogOut); + mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_AnalogOut); } bool common_hal_analogio_analogout_deinited(analogio_analogout_obj_t *self) { diff --git a/ports/mimxrt10xx/common-hal/audiobusio/__init__.c b/ports/mimxrt10xx/common-hal/audiobusio/__init__.c index 96f9ed8138..7bf54778ab 100644 --- a/ports/mimxrt10xx/common-hal/audiobusio/__init__.c +++ b/ports/mimxrt10xx/common-hal/audiobusio/__init__.c @@ -320,13 +320,13 @@ void port_i2s_initialize(i2s_t *self, int instance, sai_transceiver_t *config) { I2S_Type *peripheral = SAI_GetPeripheral(instance); if (!peripheral) { - mp_raise_ValueError_varg(translate("Invalid %q"), MP_QSTR_I2SOut); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Invalid %q"), MP_QSTR_I2SOut); } if (i2s_in_use & (1 << instance)) { - mp_raise_ValueError_varg(translate("%q in use"), MP_QSTR_I2SOut); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q in use"), MP_QSTR_I2SOut); } if (!i2s_clocking(peripheral)) { - mp_raise_ValueError_varg(translate("Invalid %q"), MP_QSTR_I2SOut); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Invalid %q"), MP_QSTR_I2SOut); } for (size_t i = 0; i < MP_ARRAY_SIZE(self->buffers); i++) { self->buffers[i] = m_malloc(AUDIO_BUFFER_FRAME_COUNT * sizeof(uint32_t)); diff --git a/ports/mimxrt10xx/common-hal/busio/I2C.c b/ports/mimxrt10xx/common-hal/busio/I2C.c index de1b94e80e..4ce9cc8986 100644 --- a/ports/mimxrt10xx/common-hal/busio/I2C.c +++ b/ports/mimxrt10xx/common-hal/busio/I2C.c @@ -117,7 +117,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, if (!GPIO_PinRead(sda->gpio, sda->number) || !GPIO_PinRead(scl->gpio, scl->number)) { common_hal_reset_pin(sda); common_hal_reset_pin(scl); - mp_raise_RuntimeError(translate("No pull up found on SDA or SCL; check your wiring")); + mp_raise_RuntimeError(MP_ERROR_TEXT("No pull up found on SDA or SCL; check your wiring")); } #endif diff --git a/ports/mimxrt10xx/common-hal/busio/SPI.c b/ports/mimxrt10xx/common-hal/busio/SPI.c index 11dea30a48..5d61028950 100644 --- a/ports/mimxrt10xx/common-hal/busio/SPI.c +++ b/ports/mimxrt10xx/common-hal/busio/SPI.c @@ -99,7 +99,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, bool spi_taken = false; if (half_duplex) { - mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("Half duplex SPI is not implemented")); } for (uint i = 0; i < sck_count; i++) { @@ -174,7 +174,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, } } else { // throw an error immediately - mp_raise_ValueError(translate("Must provide MISO or MOSI pin")); + mp_raise_ValueError(MP_ERROR_TEXT("Must provide MISO or MOSI pin")); } } @@ -182,7 +182,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, self->spi = mcu_spi_banks[self->clock->bank_idx - 1]; } else { if (spi_taken) { - mp_raise_ValueError(translate("Hardware in use, try alternative pins")); + mp_raise_ValueError(MP_ERROR_TEXT("Hardware in use, try alternative pins")); } else { raise_ValueError_invalid_pins(); } @@ -331,7 +331,7 @@ bool common_hal_busio_spi_write(busio_spi_obj_t *self, return true; } if (self->mosi == NULL) { - mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_mosi); + mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_mosi); } lpspi_transfer_t xfer = { 0 }; @@ -349,7 +349,7 @@ bool common_hal_busio_spi_read(busio_spi_obj_t *self, return true; } if (self->miso == NULL) { - mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_miso); + mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_miso); } LPSPI_SetDummyData(self->spi, write_value); @@ -368,10 +368,10 @@ bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, const uint8_t *data_ou return true; } if (self->mosi == NULL && data_out != NULL) { - mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_mosi); + mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_mosi); } if (self->miso == NULL && data_in != NULL) { - mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_miso); + mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_miso); } LPSPI_SetDummyData(self->spi, 0xFF); diff --git a/ports/mimxrt10xx/common-hal/busio/UART.c b/ports/mimxrt10xx/common-hal/busio/UART.c index c40b2601a0..7285c0d84a 100644 --- a/ports/mimxrt10xx/common-hal/busio/UART.c +++ b/ports/mimxrt10xx/common-hal/busio/UART.c @@ -197,11 +197,11 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, } if (uart_taken) { - mp_raise_ValueError(translate("Hardware in use, try alternative pins")); + mp_raise_ValueError(MP_ERROR_TEXT("Hardware in use, try alternative pins")); } if (is_onedirection && ((rts != NULL) || (cts != NULL))) { - mp_raise_ValueError(translate("Both RX and TX required for flow control")); + mp_raise_ValueError(MP_ERROR_TEXT("Both RX and TX required for flow control")); } // Filter for sane settings for RS485 @@ -210,13 +210,13 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, rs485_dir->gpio, rs485_dir->number, rs485_dir->mux_idx, rs485_dir->mux_reg, rs485_dir->cfg_reg, rs485_dir->mux_reset, rs485_dir->pad_reset); if ((rts != NULL) || (cts != NULL)) { - mp_raise_ValueError(translate("Cannot specify RTS or CTS in RS485 mode")); + mp_raise_ValueError(MP_ERROR_TEXT("Cannot specify RTS or CTS in RS485 mode")); } // For IMXRT the RTS pin is used for RS485 direction ???? - Can be will try // it if this is an rts pin. } else { if (rs485_invert) { - mp_raise_ValueError(translate("RS485 inversion specified when not in RS485 mode")); + mp_raise_ValueError(MP_ERROR_TEXT("RS485 inversion specified when not in RS485 mode")); } } @@ -401,7 +401,7 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { // Read characters. size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) { if (self->rx == NULL) { - mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_rx); + mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_rx); } if (len == 0) { @@ -458,7 +458,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t // Write characters. size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) { if (self->tx == NULL) { - mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_tx); + mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_tx); } if (self->rs485_dir && len) { GPIO_PinWrite(self->rs485_dir->gpio, self->rs485_dir->number, !self->rs485_invert); diff --git a/ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c b/ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c index c37646b098..b15846205d 100644 --- a/ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c +++ b/ports/mimxrt10xx/common-hal/digitalio/DigitalInOut.c @@ -171,7 +171,7 @@ digitalinout_result_t common_hal_digitalio_digitalinout_set_pull( digitalio_pull_t common_hal_digitalio_digitalinout_get_pull( digitalio_digitalinout_obj_t *self) { if (self->output) { - mp_raise_AttributeError(translate("Cannot get pull while in output mode")); + mp_raise_AttributeError(MP_ERROR_TEXT("Cannot get pull while in output mode")); return PULL_NONE; } else { return self->pull; diff --git a/ports/mimxrt10xx/common-hal/microcontroller/Pin.c b/ports/mimxrt10xx/common-hal/microcontroller/Pin.c index 2cd53e9560..11ca034693 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/Pin.c +++ b/ports/mimxrt10xx/common-hal/microcontroller/Pin.c @@ -139,5 +139,5 @@ const mcu_periph_obj_t *find_pin_function_sz(const mcu_periph_obj_t *list, size_ return &list[i]; } } - mp_raise_ValueError_varg(translate("Invalid %q pin"), name); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Invalid %q pin"), name); } diff --git a/ports/mimxrt10xx/common-hal/microcontroller/Processor.c b/ports/mimxrt10xx/common-hal/microcontroller/Processor.c index fb1b5b9c1c..e7e9f2d42b 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/Processor.c +++ b/ports/mimxrt10xx/common-hal/microcontroller/Processor.c @@ -63,7 +63,7 @@ void common_hal_mcu_processor_set_frequency(mcu_processor_obj_t *self, uint32_t freq = frequency / 1000000; if (freq != 24 && freq != 150 && freq != 396 && freq != 450 && freq != 528 && freq != 600 && freq != 720 && freq != 816 && freq != 912 && freq != 960 && freq != 1008) { - mp_raise_ValueError(translate("Frequency must be 24, 150, 396, 450, 528, 600, 720, 816, 912, 960 or 1008 Mhz")); + mp_raise_ValueError(MP_ERROR_TEXT("Frequency must be 24, 150, 396, 450, 528, 600, 720, 816, 912, 960 or 1008 Mhz")); } SystemCoreClock = setarmclock(frequency); } diff --git a/ports/mimxrt10xx/common-hal/microcontroller/__init__.c b/ports/mimxrt10xx/common-hal/microcontroller/__init__.c index ef7e481330..3ab8c605c1 100644 --- a/ports/mimxrt10xx/common-hal/microcontroller/__init__.c +++ b/ports/mimxrt10xx/common-hal/microcontroller/__init__.c @@ -67,7 +67,7 @@ void PLACE_IN_ITCM(common_hal_mcu_enable_interrupts)(void) { void common_hal_mcu_on_next_reset(mcu_runmode_t runmode) { if (runmode == RUNMODE_BOOTLOADER) { if (!bootloader_available()) { - mp_raise_ValueError(translate("Cannot reset into bootloader because no bootloader is present")); + mp_raise_ValueError(MP_ERROR_TEXT("Cannot reset into bootloader because no bootloader is present")); } // Pretend to be the first of the two reset presses needed to enter the // bootloader. That way one reset will end in the bootloader. diff --git a/ports/mimxrt10xx/common-hal/pwmio/PWMOut.c b/ports/mimxrt10xx/common-hal/pwmio/PWMOut.c index cb1e7b0529..a4d00cb2b1 100644 --- a/ports/mimxrt10xx/common-hal/pwmio/PWMOut.c +++ b/ports/mimxrt10xx/common-hal/pwmio/PWMOut.c @@ -324,7 +324,7 @@ void common_hal_pwmio_pwmout_set_duty_cycle(pwmio_pwmout_obj_t *self, uint16_t d if (duty == 65535) { // X channels can't do a full 100% duty cycle. if (self->pwm->channel == kPWM_PwmX) { - mp_raise_ValueError_varg(translate("Invalid %q"), MP_QSTR_duty_cycle); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Invalid %q"), MP_QSTR_duty_cycle); } duty_scaled = self->pulse_count + 1; } else { diff --git a/ports/mimxrt10xx/common-hal/rtc/RTC.c b/ports/mimxrt10xx/common-hal/rtc/RTC.c index 3cbaac9ccf..4d523c564d 100644 --- a/ports/mimxrt10xx/common-hal/rtc/RTC.c +++ b/ports/mimxrt10xx/common-hal/rtc/RTC.c @@ -82,5 +82,5 @@ int common_hal_rtc_get_calibration(void) { void common_hal_rtc_set_calibration(int calibration) { // SNVS has HPCALB_VAL bits for calibration. - mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_calibration); + mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_calibration); } diff --git a/ports/mimxrt10xx/common-hal/usb_host/Port.c b/ports/mimxrt10xx/common-hal/usb_host/Port.c index 444c410729..c1307928f0 100644 --- a/ports/mimxrt10xx/common-hal/usb_host/Port.c +++ b/ports/mimxrt10xx/common-hal/usb_host/Port.c @@ -49,7 +49,7 @@ usb_host_port_obj_t *common_hal_usb_host_port_construct(const mcu_pin_obj_t *dp, usb_host_port_obj_t *self = &usb_host_instance; if (self->dp != NULL) { if (self->dp != dp || self->dm != dm) { - mp_raise_msg_varg(&mp_type_RuntimeError, translate("%q in use"), MP_QSTR_usb_host); + mp_raise_msg_varg(&mp_type_RuntimeError, MP_ERROR_TEXT("%q in use"), MP_QSTR_usb_host); } return self; } diff --git a/ports/nrf/boards/aramcon2_badge/mpconfigboard.h b/ports/nrf/boards/aramcon2_badge/mpconfigboard.h index 58df3a4058..c1fa1e74df 100644 --- a/ports/nrf/boards/aramcon2_badge/mpconfigboard.h +++ b/ports/nrf/boards/aramcon2_badge/mpconfigboard.h @@ -52,7 +52,7 @@ #define CIRCUITPY_BOOT_BUTTON (&pin_P0_29) -#define BOARD_USER_SAFE_MODE_ACTION translate("You pressed the left button at start up.") +#define BOARD_USER_SAFE_MODE_ACTION MP_ERROR_TEXT("You pressed the left button at start up.") #define CIRCUITPY_INTERNAL_NVM_SIZE (4096) diff --git a/ports/nrf/boards/arduino_nano_33_ble/mpconfigboard.mk b/ports/nrf/boards/arduino_nano_33_ble/mpconfigboard.mk index 9b16834b50..cf6203bf18 100644 --- a/ports/nrf/boards/arduino_nano_33_ble/mpconfigboard.mk +++ b/ports/nrf/boards/arduino_nano_33_ble/mpconfigboard.mk @@ -6,3 +6,4 @@ USB_MANUFACTURER = "Arduino" MCU_CHIP = nrf52840 INTERNAL_FLASH_FILESYSTEM = 1 +CIRCUITPY_ULAB = 0 diff --git a/ports/nrf/common-hal/_bleio/Adapter.c b/ports/nrf/common-hal/_bleio/Adapter.c index e3b8fc22f5..be3ffb763e 100644 --- a/ports/nrf/common-hal/_bleio/Adapter.c +++ b/ports/nrf/common-hal/_bleio/Adapter.c @@ -528,7 +528,7 @@ STATIC bool scan_on_ble_evt(ble_evt_t *ble_evt, void *scan_results_in) { 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) { if (self->scan_results != NULL) { if (!shared_module_bleio_scanresults_get_done(self->scan_results)) { - mp_raise_bleio_BluetoothError(translate("Scan already in progress. Stop with stop_scan.")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Scan already in progress. Stop with stop_scan.")); } self->scan_results = NULL; } @@ -560,11 +560,11 @@ mp_obj_t common_hal_bleio_adapter_start_scan(bleio_adapter_obj_t *self, uint8_t uint32_t nrf_timeout = SEC_TO_UNITS(timeout, UNIT_10_MS) + 0.5f; if (nrf_timeout > UINT16_MAX) { // 0xffff / 100 - mp_raise_ValueError(translate("timeout must be < 655.35 secs")); + mp_raise_ValueError(MP_ERROR_TEXT("timeout must be < 655.35 secs")); } if (nrf_timeout == 0 && timeout > 0.0f) { // Make sure converted timeout is > 0 if original timeout is > 0. - mp_raise_ValueError(translate("non-zero timeout must be > 0.01")); + mp_raise_ValueError(MP_ERROR_TEXT("non-zero timeout must be > 0.01")); } if (nrf_timeout == 0) { @@ -674,7 +674,7 @@ mp_obj_t common_hal_bleio_adapter_connect(bleio_adapter_obj_t *self, bleio_addre uint16_t conn_handle = event_info.conn_handle; if (conn_handle == BLE_CONN_HANDLE_INVALID) { - mp_raise_bleio_BluetoothError(translate("Failed to connect: timeout")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Failed to connect: timeout")); } // If we have keys, then try and encrypt the connection. const ble_gap_enc_key_t *encryption_key = bonding_load_peer_encryption_key(true, &addr); @@ -708,7 +708,7 @@ mp_obj_t common_hal_bleio_adapter_connect(bleio_adapter_obj_t *self, bleio_addre } } - mp_raise_bleio_BluetoothError(translate("Failed to connect: internal error")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Failed to connect: internal error")); return mp_const_none; } @@ -717,7 +717,7 @@ mp_obj_t common_hal_bleio_adapter_connect(bleio_adapter_obj_t *self, bleio_addre STATIC void check_data_fit(size_t data_len, bool connectable) { if (data_len > BLE_GAP_ADV_SET_DATA_SIZE_EXTENDED_MAX_SUPPORTED || (connectable && data_len > BLE_GAP_ADV_SET_DATA_SIZE_EXTENDED_CONNECTABLE_MAX_SUPPORTED)) { - mp_raise_ValueError(translate("Data too large for advertisement packet")); + mp_raise_ValueError(MP_ERROR_TEXT("Data too large for advertisement packet")); } } @@ -868,7 +868,7 @@ void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, bool mp_buffer_info_t *advertising_data_bufinfo, mp_buffer_info_t *scan_response_data_bufinfo, mp_int_t tx_power, const bleio_address_obj_t *directed_to) { if (self->user_advertising) { - mp_raise_bleio_BluetoothError(translate("Already advertising.")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Already advertising.")); } else if (self->current_advertising_data != NULL) { // If the user isn't advertising, then the background is. So, stop the // background advertising so the user can. @@ -880,12 +880,12 @@ void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, bool check_data_fit(scan_response_data_bufinfo->len, connectable); if (advertising_data_bufinfo->len > 31 && scan_response_data_bufinfo->len > 0) { - mp_raise_bleio_BluetoothError(translate("Extended advertisements with scan response not supported.")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Extended advertisements with scan response not supported.")); } if (advertising_data_bufinfo->len > 0 && directed_to != NULL) { - mp_raise_bleio_BluetoothError(translate("Data not supported with directed advertising")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Data not supported with directed advertising")); } // Anonymous mode requires a timeout so that we don't continue to broadcast @@ -902,7 +902,7 @@ void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self, bool } } else { if (SEC_TO_UNITS(timeout, UNIT_10_MS) > BLE_GAP_ADV_TIMEOUT_LIMITED_MAX) { - mp_raise_bleio_BluetoothError(translate("Timeout is too long: Maximum timeout length is %d seconds"), + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Timeout is too long: Maximum timeout length is %d seconds"), UNITS_TO_SEC(BLE_GAP_ADV_TIMEOUT_LIMITED_MAX, UNIT_10_MS)); } } diff --git a/ports/nrf/common-hal/_bleio/Characteristic.c b/ports/nrf/common-hal/_bleio/Characteristic.c index 5a70fb9cea..5771b1db8d 100644 --- a/ports/nrf/common-hal/_bleio/Characteristic.c +++ b/ports/nrf/common-hal/_bleio/Characteristic.c @@ -117,7 +117,7 @@ void common_hal_bleio_characteristic_construct(bleio_characteristic_obj_t *self, const mp_int_t max_length_max = fixed_length ? BLE_GATTS_FIX_ATTR_LEN_MAX : BLE_GATTS_VAR_ATTR_LEN_MAX; if (max_length < 0 || max_length > max_length_max) { - mp_raise_ValueError_varg(translate("max_length must be 0-%d when fixed_length is %s"), + mp_raise_ValueError_varg(MP_ERROR_TEXT("max_length must be 0-%d when fixed_length is %s"), max_length_max, fixed_length ? "True" : "False"); } self->max_length = max_length; @@ -172,10 +172,10 @@ void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self, } else { // Validate data length for local characteristics only. if (self->fixed_length && bufinfo->len != self->max_length) { - mp_raise_ValueError(translate("Value length != required fixed length")); + mp_raise_ValueError(MP_ERROR_TEXT("Value length != required fixed length")); } if (bufinfo->len > self->max_length) { - mp_raise_ValueError(translate("Value length > max_length")); + mp_raise_ValueError(MP_ERROR_TEXT("Value length > max_length")); } // Always write the value locally even if no connections are active. @@ -255,11 +255,11 @@ void common_hal_bleio_characteristic_add_descriptor(bleio_characteristic_obj_t * void common_hal_bleio_characteristic_set_cccd(bleio_characteristic_obj_t *self, bool notify, bool indicate) { if (self->cccd_handle == BLE_GATT_HANDLE_INVALID) { - mp_raise_bleio_BluetoothError(translate("No CCCD for this Characteristic")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("No CCCD for this Characteristic")); } if (!common_hal_bleio_service_get_is_remote(self->service)) { - mp_raise_bleio_RoleError(translate("Can't set CCCD on local Characteristic")); + mp_raise_bleio_RoleError(MP_ERROR_TEXT("Can't set CCCD on local Characteristic")); } const uint16_t conn_handle = bleio_connection_get_conn_handle(self->service->connection); diff --git a/ports/nrf/common-hal/_bleio/Connection.c b/ports/nrf/common-hal/_bleio/Connection.c index 5f185de999..136b94c795 100644 --- a/ports/nrf/common-hal/_bleio/Connection.c +++ b/ports/nrf/common-hal/_bleio/Connection.c @@ -653,7 +653,7 @@ STATIC void discover_remote_services(bleio_connection_internal_t *self, mp_obj_t mp_obj_t uuid_obj; while ((uuid_obj = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { if (!mp_obj_is_type(uuid_obj, &bleio_uuid_type)) { - mp_raise_TypeError(translate("non-UUID found in service_uuids_whitelist")); + mp_raise_TypeError(MP_ERROR_TEXT("non-UUID found in service_uuids_whitelist")); } bleio_uuid_obj_t *uuid = MP_OBJ_TO_PTR(uuid_obj); diff --git a/ports/nrf/common-hal/_bleio/Descriptor.c b/ports/nrf/common-hal/_bleio/Descriptor.c index 7ec287260b..10a6a5c299 100644 --- a/ports/nrf/common-hal/_bleio/Descriptor.c +++ b/ports/nrf/common-hal/_bleio/Descriptor.c @@ -43,7 +43,7 @@ void common_hal_bleio_descriptor_construct(bleio_descriptor_obj_t *self, bleio_c const mp_int_t max_length_max = fixed_length ? BLE_GATTS_FIX_ATTR_LEN_MAX : BLE_GATTS_VAR_ATTR_LEN_MAX; if (max_length < 0 || max_length > max_length_max) { - mp_raise_ValueError_varg(translate("max_length must be 0-%d when fixed_length is %s"), + mp_raise_ValueError_varg(MP_ERROR_TEXT("max_length must be 0-%d when fixed_length is %s"), max_length_max, fixed_length ? "True" : "False"); } self->max_length = max_length; @@ -82,10 +82,10 @@ void common_hal_bleio_descriptor_set_value(bleio_descriptor_obj_t *self, mp_buff } else { // Validate data length for local descriptors only. if (self->fixed_length && bufinfo->len != self->max_length) { - mp_raise_ValueError(translate("Value length != required fixed length")); + mp_raise_ValueError(MP_ERROR_TEXT("Value length != required fixed length")); } if (bufinfo->len > self->max_length) { - mp_raise_ValueError(translate("Value length > max_length")); + mp_raise_ValueError(MP_ERROR_TEXT("Value length > max_length")); } common_hal_bleio_gatts_write(self->handle, conn_handle, bufinfo); diff --git a/ports/nrf/common-hal/_bleio/PacketBuffer.c b/ports/nrf/common-hal/_bleio/PacketBuffer.c index 7a2ccae673..45544c90ed 100644 --- a/ports/nrf/common-hal/_bleio/PacketBuffer.c +++ b/ports/nrf/common-hal/_bleio/PacketBuffer.c @@ -348,7 +348,7 @@ mp_int_t common_hal_bleio_packet_buffer_readinto(bleio_packet_buffer_obj_t *self mp_int_t common_hal_bleio_packet_buffer_write(bleio_packet_buffer_obj_t *self, const uint8_t *data, size_t len, uint8_t *header, size_t header_len) { if (self->outgoing[0] == NULL) { - mp_raise_bleio_BluetoothError(translate("Writes not supported on Characteristic")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Writes not supported on Characteristic")); } if (self->conn_handle == BLE_CONN_HANDLE_INVALID) { return -1; @@ -361,11 +361,11 @@ mp_int_t common_hal_bleio_packet_buffer_write(bleio_packet_buffer_obj_t *self, c mp_int_t total_len = len + header_len; if (total_len > outgoing_packet_length) { // Supplied data will not fit in a single BLE packet. - mp_raise_ValueError_varg(translate("Total data to write is larger than %q"), MP_QSTR_outgoing_packet_length); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Total data to write is larger than %q"), MP_QSTR_outgoing_packet_length); } if (total_len > self->max_packet_size) { // Supplied data will not fit in a single BLE packet. - mp_raise_ValueError_varg(translate("Total data to write is larger than %q"), MP_QSTR_max_packet_size); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Total data to write is larger than %q"), MP_QSTR_max_packet_size); } outgoing_packet_length = MIN(outgoing_packet_length, self->max_packet_size); diff --git a/ports/nrf/common-hal/_bleio/UUID.c b/ports/nrf/common-hal/_bleio/UUID.c index 2d94b4c0ce..71096b9fdf 100644 --- a/ports/nrf/common-hal/_bleio/UUID.c +++ b/ports/nrf/common-hal/_bleio/UUID.c @@ -78,7 +78,7 @@ void common_hal_bleio_uuid_pack_into(bleio_uuid_obj_t *self, uint8_t *buf) { void bleio_uuid_construct_from_nrf_ble_uuid(bleio_uuid_obj_t *self, ble_uuid_t *nrf_ble_uuid) { if (nrf_ble_uuid->type == BLE_UUID_TYPE_UNKNOWN) { - mp_raise_bleio_BluetoothError(translate("Unexpected nrfx uuid type")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Unexpected nrfx uuid type")); } self->nrf_ble_uuid.uuid = nrf_ble_uuid->uuid; self->nrf_ble_uuid.type = nrf_ble_uuid->type; diff --git a/ports/nrf/common-hal/_bleio/__init__.c b/ports/nrf/common-hal/_bleio/__init__.c index 75bfb60342..f3edbc97d9 100644 --- a/ports/nrf/common-hal/_bleio/__init__.c +++ b/ports/nrf/common-hal/_bleio/__init__.c @@ -47,19 +47,19 @@ void check_nrf_error(uint32_t err_code) { } switch (err_code) { case NRF_ERROR_NO_MEM: - mp_raise_msg(&mp_type_MemoryError, translate("Nordic system firmware out of memory")); + mp_raise_msg(&mp_type_MemoryError, MP_ERROR_TEXT("Nordic system firmware out of memory")); return; case NRF_ERROR_TIMEOUT: mp_raise_msg(&mp_type_TimeoutError, NULL); return; case NRF_ERROR_INVALID_PARAM: - mp_raise_ValueError(translate("Invalid BLE parameter")); + mp_raise_ValueError(MP_ERROR_TEXT("Invalid BLE parameter")); return; case BLE_ERROR_INVALID_CONN_HANDLE: - mp_raise_ConnectionError(translate("Not connected")); + mp_raise_ConnectionError(MP_ERROR_TEXT("Not connected")); return; default: - mp_raise_bleio_BluetoothError(translate("Unknown system firmware error: %04x"), err_code); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Unknown system firmware error: %04x"), err_code); break; } } @@ -70,13 +70,13 @@ void check_gatt_status(uint16_t gatt_status) { } switch (gatt_status) { case BLE_GATT_STATUS_ATTERR_INSUF_AUTHENTICATION: - mp_raise_bleio_SecurityError(translate("Insufficient authentication")); + mp_raise_bleio_SecurityError(MP_ERROR_TEXT("Insufficient authentication")); return; case BLE_GATT_STATUS_ATTERR_INSUF_ENCRYPTION: - mp_raise_bleio_SecurityError(translate("Insufficient encryption")); + mp_raise_bleio_SecurityError(MP_ERROR_TEXT("Insufficient encryption")); return; default: - mp_raise_bleio_BluetoothError(translate("Unknown gatt error: 0x%04x"), gatt_status); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Unknown gatt error: 0x%04x"), gatt_status); } } @@ -87,10 +87,10 @@ void check_sec_status(uint8_t sec_status) { switch (sec_status) { case BLE_GAP_SEC_STATUS_UNSPECIFIED: - mp_raise_bleio_SecurityError(translate("Unspecified issue. Can be that the pairing prompt on the other device was declined or ignored.")); + mp_raise_bleio_SecurityError(MP_ERROR_TEXT("Unspecified issue. Can be that the pairing prompt on the other device was declined or ignored.")); return; default: - mp_raise_bleio_SecurityError(translate("Unknown security error: 0x%04x"), sec_status); + mp_raise_bleio_SecurityError(MP_ERROR_TEXT("Unknown security error: 0x%04x"), sec_status); } } @@ -126,7 +126,7 @@ bleio_adapter_obj_t common_hal_bleio_adapter_obj; void common_hal_bleio_check_connected(uint16_t conn_handle) { if (conn_handle == BLE_CONN_HANDLE_INVALID) { - mp_raise_ConnectionError(translate("Not connected")); + mp_raise_ConnectionError(MP_ERROR_TEXT("Not connected")); } } diff --git a/ports/nrf/common-hal/alarm/__init__.c b/ports/nrf/common-hal/alarm/__init__.c index 0835522f48..8af90b19d6 100644 --- a/ports/nrf/common-hal/alarm/__init__.c +++ b/ports/nrf/common-hal/alarm/__init__.c @@ -253,7 +253,7 @@ mp_obj_t common_hal_alarm_light_sleep_until_alarms(size_t n_alarms, const mp_obj void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *alarms, size_t n_dios, digitalio_digitalinout_obj_t **preserve_dios) { if (n_dios > 0) { - mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_preserve_dios); + mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_preserve_dios); } _setup_sleep_alarms(true, n_alarms, alarms); } diff --git a/ports/nrf/common-hal/alarm/pin/PinAlarm.c b/ports/nrf/common-hal/alarm/pin/PinAlarm.c index 5bef48773e..a1d72d07c8 100644 --- a/ports/nrf/common-hal/alarm/pin/PinAlarm.c +++ b/ports/nrf/common-hal/alarm/pin/PinAlarm.c @@ -48,7 +48,7 @@ extern uint32_t reset_reason_saved; void common_hal_alarm_pin_pinalarm_construct(alarm_pin_pinalarm_obj_t *self, const mcu_pin_obj_t *pin, bool value, bool edge, bool pull) { if (edge) { - mp_raise_ValueError(translate("Cannot wake on pin edge, only level")); + mp_raise_ValueError(MP_ERROR_TEXT("Cannot wake on pin edge, only level")); } if (pin->number >= NUMBER_OF_PINS) { raise_ValueError_invalid_pin(); diff --git a/ports/nrf/common-hal/alarm/time/TimeAlarm.c b/ports/nrf/common-hal/alarm/time/TimeAlarm.c index a69e299bc2..ce09926fc6 100644 --- a/ports/nrf/common-hal/alarm/time/TimeAlarm.c +++ b/ports/nrf/common-hal/alarm/time/TimeAlarm.c @@ -86,7 +86,7 @@ void alarm_time_timealarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ continue; } if (timealarm_set) { - mp_raise_ValueError(translate("Only one alarm.time alarm can be set")); + mp_raise_ValueError(MP_ERROR_TEXT("Only one alarm.time alarm can be set")); } timealarm = MP_OBJ_TO_PTR(alarms[i]); timealarm_set = true; diff --git a/ports/nrf/common-hal/analogio/AnalogOut.c b/ports/nrf/common-hal/analogio/AnalogOut.c index 03e0515f49..4ae258fd02 100644 --- a/ports/nrf/common-hal/analogio/AnalogOut.c +++ b/ports/nrf/common-hal/analogio/AnalogOut.c @@ -33,7 +33,7 @@ #include "py/runtime.h" void common_hal_analogio_analogout_construct(analogio_analogout_obj_t *self, const mcu_pin_obj_t *pin) { - mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_AnalogOut); + mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_AnalogOut); } bool common_hal_analogio_analogout_deinited(analogio_analogout_obj_t *self) { diff --git a/ports/nrf/common-hal/audiobusio/I2SOut.c b/ports/nrf/common-hal/audiobusio/I2SOut.c index 1071fa5980..34270a8f5b 100644 --- a/ports/nrf/common-hal/audiobusio/I2SOut.c +++ b/ports/nrf/common-hal/audiobusio/I2SOut.c @@ -204,10 +204,10 @@ 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, const mcu_pin_obj_t *main_clock, bool left_justified) { if (main_clock != NULL) { - mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_main_clock); + mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_main_clock); } if (instance) { - mp_raise_RuntimeError(translate("Device in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Device in use")); } instance = self; diff --git a/ports/nrf/common-hal/audiobusio/PDMIn.c b/ports/nrf/common-hal/audiobusio/PDMIn.c index 9c9afbcb50..a92a42796d 100644 --- a/ports/nrf/common-hal/audiobusio/PDMIn.c +++ b/ports/nrf/common-hal/audiobusio/PDMIn.c @@ -51,10 +51,10 @@ void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t *self, self->data_pin_number = data_pin->number; if (sample_rate != 16000) { - mp_raise_ValueError(translate("only sample_rate=16000 is supported")); + mp_raise_ValueError(MP_ERROR_TEXT("only sample_rate=16000 is supported")); } if (bit_depth != 16) { - mp_raise_ValueError(translate("only bit_depth=16 is supported")); + mp_raise_ValueError(MP_ERROR_TEXT("only bit_depth=16 is supported")); } nrf_pdm->PSEL.CLK = self->clock_pin_number; nrf_pdm->PSEL.DIN = self->data_pin_number; diff --git a/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c b/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c index 88843e81b1..667632c644 100644 --- a/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c +++ b/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c @@ -188,7 +188,7 @@ void common_hal_audiopwmio_pwmaudioout_construct(audiopwmio_pwmaudioout_obj_t *s self->pwm = pwmout_allocate(256, PWM_PRESCALER_PRESCALER_DIV_1, true, NULL, NULL, &self->pwm_irq); if (!self->pwm) { - mp_raise_RuntimeError(translate("All timers in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("All timers in use")); } self->pwm->PRESCALER = PWM_PRESCALER_PRESCALER_DIV_1; diff --git a/ports/nrf/common-hal/busio/I2C.c b/ports/nrf/common-hal/busio/I2C.c index 03c8931e7e..4f999fc1e7 100644 --- a/ports/nrf/common-hal/busio/I2C.c +++ b/ports/nrf/common-hal/busio/I2C.c @@ -110,7 +110,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, const mcu_pin_obj_t * } if (self->twim_peripheral == NULL) { - mp_raise_ValueError(translate("All I2C peripherals are in use")); + mp_raise_ValueError(MP_ERROR_TEXT("All I2C peripherals are in use")); } #if CIRCUITPY_REQUIRE_I2C_PULLUPS @@ -129,7 +129,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, const mcu_pin_obj_t * if (!nrf_gpio_pin_read(sda->number) || !nrf_gpio_pin_read(scl->number)) { reset_pin_number(sda->number); reset_pin_number(scl->number); - mp_raise_RuntimeError(translate("No pull up found on SDA or SCL; check your wiring")); + mp_raise_RuntimeError(MP_ERROR_TEXT("No pull up found on SDA or SCL; check your wiring")); } #endif diff --git a/ports/nrf/common-hal/busio/SPI.c b/ports/nrf/common-hal/busio/SPI.c index 7258d2149e..fa4845b19b 100644 --- a/ports/nrf/common-hal/busio/SPI.c +++ b/ports/nrf/common-hal/busio/SPI.c @@ -146,7 +146,7 @@ static nrf_spim_frequency_t baudrate_to_spim_frequency(const uint32_t baudrate) 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, bool half_duplex) { if (half_duplex) { - mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("Half duplex SPI is not implemented")); } // Find a free instance, with most desirable (highest freq and not shared) allocated first. @@ -159,7 +159,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, const mcu_pin_obj_t * } if (self->spim_peripheral == NULL) { - mp_raise_ValueError(translate("All SPI peripherals are in use")); + mp_raise_ValueError(MP_ERROR_TEXT("All SPI peripherals are in use")); } nrfx_spim_config_t config = NRFX_SPIM_DEFAULT_CONFIG(NRFX_SPIM_PIN_NOT_USED, NRFX_SPIM_PIN_NOT_USED, diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c index 7fe936209f..5c843705fd 100644 --- a/ports/nrf/common-hal/busio/UART.c +++ b/ports/nrf/common-hal/busio/UART.c @@ -43,7 +43,7 @@ do { \ uint32_t _err = (_exp); \ if (NRFX_SUCCESS != _err) { \ - mp_raise_msg_varg(&mp_type_RuntimeError, translate("error = 0x%08lX"), _err); \ + mp_raise_msg_varg(&mp_type_RuntimeError, MP_ERROR_TEXT("error = 0x%08lX"), _err); \ } \ } while (0) @@ -166,7 +166,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, mp_arg_validate_int(bits, 8, MP_QSTR_bits); if ((rs485_dir != NULL) || (rs485_invert)) { - mp_raise_NotImplementedError(translate("RS485")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("RS485")); } // Find a free UART peripheral. @@ -179,7 +179,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, } if (self->uarte == NULL) { - mp_raise_ValueError(translate("All UART peripherals are in use")); + mp_raise_ValueError(MP_ERROR_TEXT("All UART peripherals are in use")); } // shared-bindings checks that TX and RX are not both None, so we don't need to check here. @@ -187,7 +187,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, mp_arg_validate_int_min(receiver_buffer_size, 1, MP_QSTR_receiver_buffer_size); if (parity == BUSIO_UART_PARITY_ODD) { - mp_raise_ValueError(translate("Odd parity is not supported")); + mp_raise_ValueError(MP_ERROR_TEXT("Odd parity is not supported")); } bool hwfc = rts != NULL || cts != NULL; @@ -283,7 +283,7 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { // Read characters. size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) { if (nrf_uarte_rx_pin_get(self->uarte->p_reg) == NRF_UARTE_PSEL_DISCONNECTED) { - mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_rx); + mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_rx); } uint64_t start_ticks = supervisor_ticks_ms64(); @@ -291,7 +291,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t // check removed to reduce code size /* if (len > ringbuf_size(&self->ringbuf)) { - mp_raise_ValueError(translate("Reading >receiver_buffer_size bytes is not supported")); + mp_raise_ValueError(MP_ERROR_TEXT("Reading >receiver_buffer_size bytes is not supported")); } */ @@ -333,7 +333,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t // Write characters. size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) { if (nrf_uarte_tx_pin_get(self->uarte->p_reg) == NRF_UARTE_PSEL_DISCONNECTED) { - mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_tx); + mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_tx); } if (len == 0) { diff --git a/ports/nrf/common-hal/countio/Counter.c b/ports/nrf/common-hal/countio/Counter.c index 32dc6af74b..825fcd0a28 100644 --- a/ports/nrf/common-hal/countio/Counter.c +++ b/ports/nrf/common-hal/countio/Counter.c @@ -61,7 +61,7 @@ void common_hal_countio_counter_construct(countio_counter_obj_t *self, nrfx_err_t err = nrfx_gpiote_in_init(self->pin, &cfg, _intr_handler); if (err != NRFX_SUCCESS) { - mp_raise_RuntimeError(translate("All channels in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("All channels in use")); } nrfx_gpiote_in_event_enable(self->pin, true); diff --git a/ports/nrf/common-hal/digitalio/DigitalInOut.c b/ports/nrf/common-hal/digitalio/DigitalInOut.c index e1e9e24e34..041730a660 100644 --- a/ports/nrf/common-hal/digitalio/DigitalInOut.c +++ b/ports/nrf/common-hal/digitalio/DigitalInOut.c @@ -147,7 +147,7 @@ digitalio_pull_t common_hal_digitalio_digitalinout_get_pull( NRF_GPIO_Type *reg = nrf_gpio_pin_port_decode(&pin); if (nrf_gpio_pin_dir_get(self->pin->number) == NRF_GPIO_PIN_DIR_OUTPUT) { - mp_raise_AttributeError(translate("Cannot get pull while in output mode")); + mp_raise_AttributeError(MP_ERROR_TEXT("Cannot get pull while in output mode")); } switch ((reg->PIN_CNF[pin] & GPIO_PIN_CNF_PULL_Msk) >> GPIO_PIN_CNF_PULL_Pos) { diff --git a/ports/nrf/common-hal/memorymap/AddressRange.c b/ports/nrf/common-hal/memorymap/AddressRange.c index b829cbb253..0cc90abe5e 100644 --- a/ports/nrf/common-hal/memorymap/AddressRange.c +++ b/ports/nrf/common-hal/memorymap/AddressRange.c @@ -83,7 +83,7 @@ void common_hal_memorymap_addressrange_construct(memorymap_addressrange_obj_t *s } if (!allowed) { - mp_raise_ValueError(translate("Address range not allowed")); + mp_raise_ValueError(MP_ERROR_TEXT("Address range not allowed")); } self->start_address = start_address; diff --git a/ports/nrf/common-hal/microcontroller/Processor.c b/ports/nrf/common-hal/microcontroller/Processor.c index 2fca3a3c0a..12aee38caa 100644 --- a/ports/nrf/common-hal/microcontroller/Processor.c +++ b/ports/nrf/common-hal/microcontroller/Processor.c @@ -50,7 +50,7 @@ float common_hal_mcu_processor_get_temperature(void) { if (sd_en) { uint32_t err_code = sd_temp_get(&temp); if (err_code != NRF_SUCCESS) { - mp_raise_OSError_msg(translate("Cannot get temperature")); + mp_raise_OSError_msg(MP_ERROR_TEXT("Cannot get temperature")); } return temp / 4.0f; } // Fall through if SD not enabled. diff --git a/ports/nrf/common-hal/paralleldisplaybus/ParallelBus.c b/ports/nrf/common-hal/paralleldisplaybus/ParallelBus.c index 55a722f47e..1c9e46da5e 100644 --- a/ports/nrf/common-hal/paralleldisplaybus/ParallelBus.c +++ b/ports/nrf/common-hal/paralleldisplaybus/ParallelBus.c @@ -39,11 +39,11 @@ void common_hal_paralleldisplaybus_parallelbus_construct(paralleldisplaybus_para uint8_t data_pin = data0->number; if (data_pin % 8 != 0) { - mp_raise_ValueError(translate("Data 0 pin must be byte aligned")); + mp_raise_ValueError(MP_ERROR_TEXT("Data 0 pin must be byte aligned")); } for (uint8_t i = 0; i < 8; i++) { if (!pin_number_is_free(data_pin + i)) { - mp_raise_ValueError_varg(translate("Bus pin %d is already in use"), i); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Bus pin %d is already in use"), i); } } NRF_GPIO_Type *g; diff --git a/ports/nrf/common-hal/pulseio/PulseIn.c b/ports/nrf/common-hal/pulseio/PulseIn.c index 0c1452f5a0..eb548a8aa7 100644 --- a/ports/nrf/common-hal/pulseio/PulseIn.c +++ b/ports/nrf/common-hal/pulseio/PulseIn.c @@ -135,7 +135,7 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t *self, const mcu if (refcount == 0) { timer = nrf_peripherals_allocate_timer(); if (timer == NULL) { - mp_raise_RuntimeError(translate("All timers in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("All timers in use")); } overflow_count = 0; @@ -175,7 +175,7 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t *self, const mcu }; nrfx_err_t err = nrfx_gpiote_in_init(self->pin, &cfg, _pulsein_handler); if (err != NRFX_SUCCESS) { - mp_raise_RuntimeError(translate("All channels in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("All channels in use")); } nrfx_gpiote_in_event_enable(self->pin, true); } @@ -271,7 +271,7 @@ uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t *self, int16_ if (!self->paused) { nrfx_gpiote_in_event_enable(self->pin, true); } - mp_raise_IndexError_varg(translate("%q out of range"), MP_QSTR_index); + mp_raise_IndexError_varg(MP_ERROR_TEXT("%q out of range"), MP_QSTR_index); } uint16_t value = self->buffer[(self->start + index) % self->maxlen]; @@ -284,7 +284,7 @@ uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t *self, int16_ uint16_t common_hal_pulseio_pulsein_popleft(pulseio_pulsein_obj_t *self) { if (self->len == 0) { - mp_raise_IndexError_varg(translate("pop from empty %q"), MP_QSTR_PulseIn); + mp_raise_IndexError_varg(MP_ERROR_TEXT("pop from empty %q"), MP_QSTR_PulseIn); } if (!self->paused) { diff --git a/ports/nrf/common-hal/rotaryio/IncrementalEncoder.c b/ports/nrf/common-hal/rotaryio/IncrementalEncoder.c index 51e83b56af..899296a8ba 100644 --- a/ports/nrf/common-hal/rotaryio/IncrementalEncoder.c +++ b/ports/nrf/common-hal/rotaryio/IncrementalEncoder.c @@ -67,12 +67,12 @@ void common_hal_rotaryio_incrementalencoder_construct(rotaryio_incrementalencode }; nrfx_err_t err = nrfx_gpiote_in_init(self->pin_a, &cfg, _intr_handler); if (err != NRFX_SUCCESS) { - mp_raise_RuntimeError(translate("All channels in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("All channels in use")); } err = nrfx_gpiote_in_init(self->pin_b, &cfg, _intr_handler); if (err != NRFX_SUCCESS) { nrfx_gpiote_in_uninit(self->pin_a); - mp_raise_RuntimeError(translate("All channels in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("All channels in use")); } nrfx_gpiote_in_event_enable(self->pin_a, true); nrfx_gpiote_in_event_enable(self->pin_b, true); diff --git a/ports/nrf/common-hal/rtc/RTC.c b/ports/nrf/common-hal/rtc/RTC.c index a7bc89afb0..a6d2981175 100644 --- a/ports/nrf/common-hal/rtc/RTC.c +++ b/ports/nrf/common-hal/rtc/RTC.c @@ -79,5 +79,5 @@ int common_hal_rtc_get_calibration(void) { } void common_hal_rtc_set_calibration(int calibration) { - mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_calibration); + mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_calibration); } diff --git a/ports/nrf/common-hal/watchdog/WatchDogTimer.c b/ports/nrf/common-hal/watchdog/WatchDogTimer.c index 1ac0ee1076..4d93b01c36 100644 --- a/ports/nrf/common-hal/watchdog/WatchDogTimer.c +++ b/ports/nrf/common-hal/watchdog/WatchDogTimer.c @@ -96,7 +96,7 @@ void common_hal_watchdog_feed(watchdog_watchdogtimer_obj_t *self) { void common_hal_watchdog_deinit(watchdog_watchdogtimer_obj_t *self) { if (self->mode == WATCHDOGMODE_RESET) { if (gc_alloc_possible()) { - mp_raise_RuntimeError(translate("WatchDogTimer cannot be deinitialized once mode is set to RESET")); + mp_raise_RuntimeError(MP_ERROR_TEXT("WatchDogTimer cannot be deinitialized once mode is set to RESET")); } // Don't change anything because RESET cannot be undone. return; @@ -117,7 +117,7 @@ void common_hal_watchdog_set_timeout(watchdog_watchdogtimer_obj_t *self, mp_floa // with the new value. uint64_t ticks = timeout * 31250ULL; if (ticks > UINT32_MAX) { - mp_raise_ValueError(translate("timeout duration exceeded the maximum supported value")); + mp_raise_ValueError(MP_ERROR_TEXT("timeout duration exceeded the maximum supported value")); } nrfx_timer_clear(timer); nrfx_timer_compare(timer, NRF_TIMER_CC_CHANNEL0, ticks, true); @@ -151,7 +151,7 @@ void common_hal_watchdog_set_mode(watchdog_watchdogtimer_obj_t *self, watchdog_w uint64_t ticks = nrfx_timer_ms_to_ticks(timer, self->timeout * 1000); if (ticks > UINT32_MAX) { - mp_raise_ValueError(translate("timeout duration exceeded the maximum supported value")); + mp_raise_ValueError(MP_ERROR_TEXT("timeout duration exceeded the maximum supported value")); } // true enables interrupt. @@ -162,7 +162,7 @@ void common_hal_watchdog_set_mode(watchdog_watchdogtimer_obj_t *self, watchdog_w } else if (new_mode == WATCHDOGMODE_RESET) { uint64_t ticks = self->timeout * 1000.0f; if (ticks > UINT32_MAX) { - mp_raise_ValueError(translate("timeout duration exceeded the maximum supported value")); + mp_raise_ValueError(MP_ERROR_TEXT("timeout duration exceeded the maximum supported value")); } nrfx_wdt_config_t config = { diff --git a/ports/nrf/peripherals/nrf/timers.c b/ports/nrf/peripherals/nrf/timers.c index f3a16b7e11..1a63bbc179 100644 --- a/ports/nrf/peripherals/nrf/timers.c +++ b/ports/nrf/peripherals/nrf/timers.c @@ -112,7 +112,7 @@ nrfx_timer_t *nrf_peripherals_allocate_timer(void) { nrfx_timer_t *nrf_peripherals_allocate_timer_or_throw(void) { nrfx_timer_t *result = nrf_peripherals_allocate_timer(); if (!result) { - mp_raise_RuntimeError(translate("All timers in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("All timers in use")); } return result; } diff --git a/ports/nrf/sd_mutex.c b/ports/nrf/sd_mutex.c index f94feb951b..14e1986cd6 100644 --- a/ports/nrf/sd_mutex.c +++ b/ports/nrf/sd_mutex.c @@ -32,7 +32,7 @@ void sd_mutex_acquire_check(nrf_mutex_t *p_mutex) { uint32_t err_code = sd_mutex_acquire(p_mutex); if (err_code != NRF_SUCCESS) { - mp_raise_OSError_msg_varg(translate("Failed to acquire mutex, err 0x%04x"), err_code); + mp_raise_OSError_msg_varg(MP_ERROR_TEXT("Failed to acquire mutex, err 0x%04x"), err_code); } } @@ -50,6 +50,6 @@ void sd_mutex_acquire_wait_no_vm(nrf_mutex_t *p_mutex) { void sd_mutex_release_check(nrf_mutex_t *p_mutex) { uint32_t err_code = sd_mutex_release(p_mutex); if (err_code != NRF_SUCCESS) { - mp_raise_OSError_msg_varg(translate("Failed to release mutex, err 0x%04x"), err_code); + mp_raise_OSError_msg_varg(MP_ERROR_TEXT("Failed to release mutex, err 0x%04x"), err_code); } } diff --git a/ports/raspberrypi/audio_dma.c b/ports/raspberrypi/audio_dma.c index 1095a88308..59de746df6 100644 --- a/ports/raspberrypi/audio_dma.c +++ b/ports/raspberrypi/audio_dma.c @@ -57,7 +57,7 @@ STATIC size_t audio_dma_convert_samples(audio_dma_t *dma, uint8_t *input, uint32 uint32_t output_length_used = input_length / dma->sample_spacing; if (output_length_used > output_length) { - mp_raise_RuntimeError(translate("Internal audio buffer too small")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Internal audio buffer too small")); } uint32_t out_i = 0; @@ -66,7 +66,7 @@ STATIC size_t audio_dma_convert_samples(audio_dma_t *dma, uint8_t *input, uint32 output_length_used *= 2; if (output_length_used > output_length) { - mp_raise_RuntimeError(translate("Internal audio buffer too small")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Internal audio buffer too small")); } // Correct "rail-to-rail" scaling of arbitrary-depth input to output @@ -120,7 +120,7 @@ STATIC size_t audio_dma_convert_samples(audio_dma_t *dma, uint8_t *input, uint32 } else { // (dma->sample_resolution > 8 && dma->output_resolution <= 8) // Not currently used, but might be in the future. - mp_raise_RuntimeError(translate("Audio conversion not implemented")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Audio conversion not implemented")); } #pragma GCC diagnostic pop return output_length_used; diff --git a/ports/raspberrypi/bindings/cyw43/__init__.c b/ports/raspberrypi/bindings/cyw43/__init__.c index 2a7ec217f4..372bb57487 100644 --- a/ports/raspberrypi/bindings/cyw43/__init__.c +++ b/ports/raspberrypi/bindings/cyw43/__init__.c @@ -118,7 +118,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(cyw43_get_power_management_obj, cyw43_get_power const mcu_pin_obj_t *validate_obj_is_pin_including_cyw43(mp_obj_t obj, qstr arg_name) { if (!mp_obj_is_type(obj, &mcu_pin_type) && !mp_obj_is_type(obj, &cyw43_pin_type)) { - mp_raise_TypeError_varg(translate("%q must be of type %q or %q, not %q"), arg_name, mcu_pin_type.name, cyw43_pin_type.name, mp_obj_get_type(obj)->name); + mp_raise_TypeError_varg(MP_ERROR_TEXT("%q must be of type %q or %q, not %q"), arg_name, mcu_pin_type.name, cyw43_pin_type.name, mp_obj_get_type(obj)->name); } return MP_OBJ_TO_PTR(obj); } diff --git a/ports/raspberrypi/bindings/picodvi/Framebuffer.c b/ports/raspberrypi/bindings/picodvi/Framebuffer.c index 8a34a90b8b..a652b0c93d 100644 --- a/ports/raspberrypi/bindings/picodvi/Framebuffer.c +++ b/ports/raspberrypi/bindings/picodvi/Framebuffer.c @@ -122,7 +122,7 @@ STATIC mp_obj_t picodvi_framebuffer_make_new(const mp_obj_type_t *type, size_t n mp_uint_t height = (mp_uint_t)mp_arg_validate_int_min(args[ARG_height].u_int, 0, MP_QSTR_height); mp_uint_t color_depth = args[ARG_color_depth].u_int; if (color_depth != 1 && color_depth != 2 && color_depth != 8 && color_depth != 16) { - mp_raise_ValueError_varg(translate("Invalid %q"), MP_QSTR_color_depth); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Invalid %q"), MP_QSTR_color_depth); } common_hal_picodvi_framebuffer_construct(self, width, height, diff --git a/ports/raspberrypi/bindings/rp2pio/StateMachine.c b/ports/raspberrypi/bindings/rp2pio/StateMachine.c index 37a3fd6f7f..a47f8f438b 100644 --- a/ports/raspberrypi/bindings/rp2pio/StateMachine.c +++ b/ports/raspberrypi/bindings/rp2pio/StateMachine.c @@ -263,12 +263,12 @@ STATIC mp_obj_t rp2pio_statemachine_make_new(const mp_obj_type_t *type, size_t n mp_arg_validate_length_range(bufinfo.len, 2, 64, MP_QSTR_program); if (bufinfo.len % 2 != 0) { - mp_raise_ValueError(translate("Program size invalid")); + mp_raise_ValueError(MP_ERROR_TEXT("Program size invalid")); } mp_arg_validate_length_range(init_bufinfo.len, 0, 64, MP_QSTR_init); if (init_bufinfo.len % 2 != 0) { - mp_raise_ValueError(translate("Init program size invalid")); + mp_raise_ValueError(MP_ERROR_TEXT("Init program size invalid")); } int wrap = args[ARG_wrap].u_int; @@ -357,7 +357,7 @@ STATIC mp_obj_t rp2pio_statemachine_run(mp_obj_t self_obj, mp_obj_t instruction_ mp_get_buffer_raise(instruction_obj, &bufinfo, MP_BUFFER_READ); if (bufinfo.len % 2 != 0) { - mp_raise_ValueError(translate("Program size invalid")); + mp_raise_ValueError(MP_ERROR_TEXT("Program size invalid")); } common_hal_rp2pio_statemachine_run(self, bufinfo.buf, (size_t)bufinfo.len / 2); return mp_const_none; @@ -415,7 +415,7 @@ STATIC mp_obj_t rp2pio_statemachine_write(size_t n_args, const mp_obj_t *pos_arg mp_get_buffer_raise(args[ARG_buffer].u_obj, &bufinfo, MP_BUFFER_READ); int stride_in_bytes = mp_binary_get_size('@', bufinfo.typecode, NULL); if (stride_in_bytes > 4) { - mp_raise_ValueError(translate("Buffer elements must be 4 bytes long or less")); + mp_raise_ValueError(MP_ERROR_TEXT("Buffer elements must be 4 bytes long or less")); } int32_t start = args[ARG_start].u_int; size_t length = bufinfo.len / stride_in_bytes; @@ -491,10 +491,10 @@ STATIC void fill_buf_info(sm_buf_info *info, mp_obj_t obj, size_t *stride_in_byt mp_get_buffer_raise(obj, &info->info, MP_BUFFER_READ); size_t stride = mp_binary_get_size('@', info->info.typecode, NULL); if (stride > 4) { - mp_raise_ValueError(translate("Buffer elements must be 4 bytes long or less")); + mp_raise_ValueError(MP_ERROR_TEXT("Buffer elements must be 4 bytes long or less")); } if (*stride_in_bytes && stride != *stride_in_bytes) { - mp_raise_ValueError(translate("Mismatched data size")); + mp_raise_ValueError(MP_ERROR_TEXT("Mismatched data size")); } *stride_in_bytes = stride; } else { @@ -627,7 +627,7 @@ STATIC mp_obj_t rp2pio_statemachine_readinto(size_t n_args, const mp_obj_t *pos_ mp_get_buffer_raise(args[ARG_buffer].u_obj, &bufinfo, MP_BUFFER_WRITE); int stride_in_bytes = mp_binary_get_size('@', bufinfo.typecode, NULL); if (stride_in_bytes > 4) { - mp_raise_ValueError(translate("Buffer elements must be 4 bytes long or less")); + mp_raise_ValueError(MP_ERROR_TEXT("Buffer elements must be 4 bytes long or less")); } int32_t start = args[ARG_start].u_int; size_t length = bufinfo.len / stride_in_bytes; @@ -701,7 +701,7 @@ STATIC mp_obj_t rp2pio_statemachine_write_readinto(size_t n_args, const mp_obj_t mp_get_buffer_raise(args[ARG_buffer_out].u_obj, &buf_out_info, MP_BUFFER_READ); int out_stride_in_bytes = mp_binary_get_size('@', buf_out_info.typecode, NULL); if (out_stride_in_bytes > 4) { - mp_raise_ValueError(translate("Out-buffer elements must be <= 4 bytes long")); + mp_raise_ValueError(MP_ERROR_TEXT("Out-buffer elements must be <= 4 bytes long")); } int32_t out_start = args[ARG_out_start].u_int; size_t out_length = buf_out_info.len / out_stride_in_bytes; @@ -711,7 +711,7 @@ STATIC mp_obj_t rp2pio_statemachine_write_readinto(size_t n_args, const mp_obj_t mp_get_buffer_raise(args[ARG_buffer_in].u_obj, &buf_in_info, MP_BUFFER_WRITE); int in_stride_in_bytes = mp_binary_get_size('@', buf_in_info.typecode, NULL); if (in_stride_in_bytes > 4) { - mp_raise_ValueError(translate("In-buffer elements must be <= 4 bytes long")); + mp_raise_ValueError(MP_ERROR_TEXT("In-buffer elements must be <= 4 bytes long")); } int32_t in_start = args[ARG_in_start].u_int; size_t in_length = buf_in_info.len / in_stride_in_bytes; diff --git a/ports/raspberrypi/common-hal/alarm/__init__.c b/ports/raspberrypi/common-hal/alarm/__init__.c index da081351dc..e1281613a2 100644 --- a/ports/raspberrypi/common-hal/alarm/__init__.c +++ b/ports/raspberrypi/common-hal/alarm/__init__.c @@ -204,7 +204,7 @@ mp_obj_t common_hal_alarm_light_sleep_until_alarms(size_t n_alarms, const mp_obj void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *alarms, size_t n_dios, digitalio_digitalinout_obj_t **preserve_dios) { if (n_dios > 0) { - mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_preserve_dios); + mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_preserve_dios); } _setup_sleep_alarms(true, n_alarms, alarms); } diff --git a/ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c b/ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c index 9bfe5cf262..302f5ed716 100644 --- a/ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c +++ b/ports/raspberrypi/common-hal/alarm/time/TimeAlarm.c @@ -86,7 +86,7 @@ void alarm_time_timealarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ continue; } if (timealarm_set) { - mp_raise_ValueError(translate("Only one alarm.time alarm can be set.")); + mp_raise_ValueError(MP_ERROR_TEXT("Only one alarm.time alarm can be set.")); } timealarm = MP_OBJ_TO_PTR(alarms[i]); timealarm_set = true; diff --git a/ports/raspberrypi/common-hal/alarm/touch/TouchAlarm.c b/ports/raspberrypi/common-hal/alarm/touch/TouchAlarm.c index 88c73726ee..ea3437ec89 100644 --- a/ports/raspberrypi/common-hal/alarm/touch/TouchAlarm.c +++ b/ports/raspberrypi/common-hal/alarm/touch/TouchAlarm.c @@ -28,5 +28,5 @@ #include "shared-bindings/microcontroller/__init__.h" void common_hal_alarm_touch_touchalarm_construct(alarm_touch_touchalarm_obj_t *self, const mcu_pin_obj_t *pin) { - mp_raise_NotImplementedError(translate("Touch alarms not available")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("Touch alarms not available")); } diff --git a/ports/raspberrypi/common-hal/analogio/AnalogOut.c b/ports/raspberrypi/common-hal/analogio/AnalogOut.c index 03e0515f49..4ae258fd02 100644 --- a/ports/raspberrypi/common-hal/analogio/AnalogOut.c +++ b/ports/raspberrypi/common-hal/analogio/AnalogOut.c @@ -33,7 +33,7 @@ #include "py/runtime.h" void common_hal_analogio_analogout_construct(analogio_analogout_obj_t *self, const mcu_pin_obj_t *pin) { - mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_AnalogOut); + mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_AnalogOut); } bool common_hal_analogio_analogout_deinited(analogio_analogout_obj_t *self) { diff --git a/ports/raspberrypi/common-hal/audiobusio/I2SOut.c b/ports/raspberrypi/common-hal/audiobusio/I2SOut.c index c7d4b7c635..67dfe4b336 100644 --- a/ports/raspberrypi/common-hal/audiobusio/I2SOut.c +++ b/ports/raspberrypi/common-hal/audiobusio/I2SOut.c @@ -104,10 +104,10 @@ 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, const mcu_pin_obj_t *main_clock, bool left_justified) { if (main_clock != NULL) { - mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_main_clock); + mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_main_clock); } if (bit_clock->number != word_select->number - 1) { - mp_raise_ValueError(translate("Bit clock and word select must be sequential GPIO pins")); + mp_raise_ValueError(MP_ERROR_TEXT("Bit clock and word select must be sequential GPIO pins")); } const uint16_t *program = i2s_program; @@ -182,7 +182,7 @@ void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t *self, uint32_t frequency = bits_per_sample_output * audiosample_sample_rate(sample); uint8_t channel_count = audiosample_channel_count(sample); if (channel_count > 2) { - mp_raise_ValueError(translate("Too many channels in sample.")); + mp_raise_ValueError(MP_ERROR_TEXT("Too many channels in sample.")); } common_hal_rp2pio_statemachine_set_frequency(&self->state_machine, clocks_per_bit * frequency); @@ -206,10 +206,10 @@ void common_hal_audiobusio_i2sout_play(audiobusio_i2sout_obj_t *self, if (result == AUDIO_DMA_DMA_BUSY) { common_hal_audiobusio_i2sout_stop(self); - mp_raise_RuntimeError(translate("No DMA channel found")); + mp_raise_RuntimeError(MP_ERROR_TEXT("No DMA channel found")); } else if (result == AUDIO_DMA_MEMORY_ERROR) { common_hal_audiobusio_i2sout_stop(self); - mp_raise_RuntimeError(translate("Unable to allocate buffers for signed conversion")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Unable to allocate buffers for signed conversion")); } self->playing = true; diff --git a/ports/raspberrypi/common-hal/audiobusio/PDMIn.c b/ports/raspberrypi/common-hal/audiobusio/PDMIn.c index 1e7e882277..3e1c140a93 100644 --- a/ports/raspberrypi/common-hal/audiobusio/PDMIn.c +++ b/ports/raspberrypi/common-hal/audiobusio/PDMIn.c @@ -57,7 +57,7 @@ void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t *self, bool mono, uint8_t oversample) { if (!(bit_depth == 16 || bit_depth == 8) || !mono || oversample != OVERSAMPLING) { - mp_raise_NotImplementedError(translate("Only 8 or 16 bit mono with " MP_STRINGIFY(OVERSAMPLING) "x oversampling is supported.")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("Only 8 or 16 bit mono with " MP_STRINGIFY(OVERSAMPLING) "x oversampling is supported.")); } // Use the state machine to manage pins. @@ -83,7 +83,7 @@ void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t *self, PIO_ANY_OFFSET); uint32_t actual_frequency = common_hal_rp2pio_statemachine_get_frequency(&self->state_machine); if (actual_frequency < MIN_MIC_CLOCK) { - mp_raise_ValueError(translate("sampling rate out of range")); + mp_raise_ValueError(MP_ERROR_TEXT("sampling rate out of range")); } self->sample_rate = actual_frequency / oversample; diff --git a/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c b/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c index 67141c2a18..541d10e9d7 100644 --- a/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c +++ b/ports/raspberrypi/common-hal/audiopwmio/PWMAudioOut.c @@ -115,13 +115,13 @@ void common_hal_audiopwmio_pwmaudioout_construct(audiopwmio_pwmaudioout_obj_t *s if (self->stereo) { if (pwm_gpio_to_slice_num(left_channel->number) != pwm_gpio_to_slice_num(right_channel->number)) { - mp_raise_ValueError(translate("Pins must share PWM slice")); + mp_raise_ValueError(MP_ERROR_TEXT("Pins must share PWM slice")); } if (pwm_gpio_to_channel(left_channel->number) != 0) { - mp_raise_ValueError(translate("Stereo left must be on PWM channel A")); + mp_raise_ValueError(MP_ERROR_TEXT("Stereo left must be on PWM channel A")); } if (pwm_gpio_to_channel(right_channel->number) != 1) { - mp_raise_ValueError(translate("Stereo right must be on PWM channel B")); + mp_raise_ValueError(MP_ERROR_TEXT("Stereo right must be on PWM channel B")); } } @@ -149,7 +149,7 @@ void common_hal_audiopwmio_pwmaudioout_construct(audiopwmio_pwmaudioout_obj_t *s } } if (result != PWMOUT_OK) { - mp_raise_RuntimeError(translate("All timers in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("All timers in use")); } self->quiescent_value = quiescent_value >> SAMPLE_BITS_TO_DISCARD; @@ -199,7 +199,7 @@ void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t *self, } } if (pacing_timer == NUM_DMA_TIMERS) { - mp_raise_RuntimeError(translate("No DMA pacing timer found")); + mp_raise_RuntimeError(MP_ERROR_TEXT("No DMA pacing timer found")); } uint32_t tx_register = (uint32_t)&pwm_hw->slice[self->left_pwm.slice].cc; if (self->stereo) { @@ -237,11 +237,11 @@ void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t *self, if (result == AUDIO_DMA_DMA_BUSY) { common_hal_audiopwmio_pwmaudioout_stop(self); - mp_raise_RuntimeError(translate("No DMA channel found")); + mp_raise_RuntimeError(MP_ERROR_TEXT("No DMA channel found")); } if (result == AUDIO_DMA_MEMORY_ERROR) { common_hal_audiopwmio_pwmaudioout_stop(self); - mp_raise_RuntimeError(translate("Unable to allocate buffers for signed conversion")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Unable to allocate buffers for signed conversion")); } // OK! We got all of the resources we need and dma is ready. } diff --git a/ports/raspberrypi/common-hal/busio/I2C.c b/ports/raspberrypi/common-hal/busio/I2C.c index c68499591c..9b45d26bc7 100644 --- a/ports/raspberrypi/common-hal/busio/I2C.c +++ b/ports/raspberrypi/common-hal/busio/I2C.c @@ -69,7 +69,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, raise_ValueError_invalid_pins(); } if ((i2c_get_hw(self->peripheral)->enable & I2C_IC_ENABLE_ENABLE_BITS) != 0) { - mp_raise_ValueError(translate("I2C peripheral in use")); + mp_raise_ValueError(MP_ERROR_TEXT("I2C peripheral in use")); } mp_arg_validate_int_max(frequency, 1000000, MP_QSTR_frequency); @@ -96,7 +96,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, if (!gpio_get(sda->number) || !gpio_get(scl->number)) { reset_pin_number(sda->number); reset_pin_number(scl->number); - mp_raise_RuntimeError(translate("No pull up found on SDA or SCL; check your wiring")); + mp_raise_RuntimeError(MP_ERROR_TEXT("No pull up found on SDA or SCL; check your wiring")); } #endif diff --git a/ports/raspberrypi/common-hal/busio/SPI.c b/ports/raspberrypi/common-hal/busio/SPI.c index 67323790bf..30958cfcdc 100644 --- a/ports/raspberrypi/common-hal/busio/SPI.c +++ b/ports/raspberrypi/common-hal/busio/SPI.c @@ -58,7 +58,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, size_t instance_index = NO_INSTANCE; if (half_duplex) { - mp_raise_NotImplementedError(translate("Half duplex SPI is not implemented")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("Half duplex SPI is not implemented")); } if (clock->number % 4 == 2) { @@ -92,7 +92,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, } if ((spi_get_hw(self->peripheral)->cr1 & SPI_SSPCR1_SSE_BITS) != 0) { - mp_raise_ValueError(translate("SPI peripheral in use")); + mp_raise_ValueError(MP_ERROR_TEXT("SPI peripheral in use")); } self->target_frequency = 250000; diff --git a/ports/raspberrypi/common-hal/busio/UART.c b/ports/raspberrypi/common-hal/busio/UART.c index 2e200a5abf..bc3f341b05 100644 --- a/ports/raspberrypi/common-hal/busio/UART.c +++ b/ports/raspberrypi/common-hal/busio/UART.c @@ -111,7 +111,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, uint8_t uart_id = ((((tx != NULL) ? tx->number : rx->number) + 4) / 8) % NUM_UARTS; if (uart_status[uart_id] != STATUS_FREE) { - mp_raise_ValueError(translate("UART peripheral in use")); + mp_raise_ValueError(MP_ERROR_TEXT("UART peripheral in use")); } // These may raise exceptions if pins are already in use. self->tx_pin = pin_init(uart_id, tx, 0); @@ -205,7 +205,7 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { // Write characters. size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) { if (self->tx_pin == NO_PIN) { - mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_tx); + mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_tx); } if (self->rs485_dir_pin != NO_PIN) { @@ -233,7 +233,7 @@ size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, // Read characters. size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) { if (self->rx_pin == NO_PIN) { - mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_rx); + mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_rx); } if (len == 0) { diff --git a/ports/raspberrypi/common-hal/countio/Counter.c b/ports/raspberrypi/common-hal/countio/Counter.c index c68bc62945..239fc4b752 100644 --- a/ports/raspberrypi/common-hal/countio/Counter.c +++ b/ports/raspberrypi/common-hal/countio/Counter.c @@ -16,22 +16,22 @@ void common_hal_countio_counter_construct(countio_counter_obj_t *self, const mcu_pin_obj_t *pin, countio_edge_t edge, digitalio_pull_t pull) { if (pwm_gpio_to_channel(pin->number) != PWM_CHAN_B) { - mp_raise_RuntimeError(translate("Pin must be on PWM Channel B")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Pin must be on PWM Channel B")); } if (edge == EDGE_RISE_AND_FALL) { - mp_raise_NotImplementedError(translate("RISE_AND_FALL not available on this chip")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("RISE_AND_FALL not available on this chip")); } self->pin = pin->number; self->slice_num = pwm_gpio_to_slice_num(self->pin); if (MP_STATE_PORT(counting)[self->slice_num] != NULL) { - mp_raise_RuntimeError(translate("PWM slice already in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("PWM slice already in use")); } if (!pwmio_claim_slice_ab_channels(self->slice_num)) { - mp_raise_RuntimeError(translate("PWM slice channel A already in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("PWM slice channel A already in use")); } pwm_clear_irq(self->slice_num); diff --git a/ports/raspberrypi/common-hal/digitalio/DigitalInOut.c b/ports/raspberrypi/common-hal/digitalio/DigitalInOut.c index 4eb2a6de9c..a21feec106 100644 --- a/ports/raspberrypi/common-hal/digitalio/DigitalInOut.c +++ b/ports/raspberrypi/common-hal/digitalio/DigitalInOut.c @@ -209,7 +209,7 @@ digitalio_pull_t common_hal_digitalio_digitalinout_get_pull( digitalio_digitalinout_obj_t *self) { uint32_t pin = self->pin->number; if (self->output) { - mp_raise_AttributeError(translate("Cannot get pull while in output mode")); + mp_raise_AttributeError(MP_ERROR_TEXT("Cannot get pull while in output mode")); return PULL_NONE; } else { if (gpio_is_pulled_up(pin)) { diff --git a/ports/raspberrypi/common-hal/i2ctarget/I2CTarget.c b/ports/raspberrypi/common-hal/i2ctarget/I2CTarget.c index fc9bf55327..785fb08257 100644 --- a/ports/raspberrypi/common-hal/i2ctarget/I2CTarget.c +++ b/ports/raspberrypi/common-hal/i2ctarget/I2CTarget.c @@ -57,11 +57,11 @@ void common_hal_i2ctarget_i2c_target_construct(i2ctarget_i2c_target_obj_t *self, } if ((i2c_get_hw(self->peripheral)->enable & I2C_IC_ENABLE_ENABLE_BITS) != 0) { - mp_raise_ValueError(translate("I2C peripheral in use")); + mp_raise_ValueError(MP_ERROR_TEXT("I2C peripheral in use")); } if (num_addresses > 1) { - mp_raise_ValueError(translate("Only one address is allowed")); + mp_raise_ValueError(MP_ERROR_TEXT("Only one address is allowed")); } self->addresses = addresses; diff --git a/ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c b/ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c index 501e905af1..1670b5b5b0 100644 --- a/ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c +++ b/ports/raspberrypi/common-hal/imagecapture/ParallelImageCapture.c @@ -92,7 +92,7 @@ void common_hal_imagecapture_parallelimagecapture_construct(imagecapture_paralle for (int i = 1; i < data_count; i++) { if (data_pins[i] - data_pins[0] != i) { - mp_raise_RuntimeError(translate("Pins must be sequential")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Pins must be sequential")); } } diff --git a/ports/raspberrypi/common-hal/mdns/Server.c b/ports/raspberrypi/common-hal/mdns/Server.c index c21d813040..2a66e170ef 100644 --- a/ports/raspberrypi/common-hal/mdns/Server.c +++ b/ports/raspberrypi/common-hal/mdns/Server.c @@ -77,11 +77,11 @@ void mdns_server_construct(mdns_server_obj_t *self, bool workflow) { void common_hal_mdns_server_construct(mdns_server_obj_t *self, mp_obj_t network_interface) { if (network_interface != MP_OBJ_FROM_PTR(&common_hal_wifi_radio_obj)) { - mp_raise_ValueError(translate("mDNS only works with built-in WiFi")); + mp_raise_ValueError(MP_ERROR_TEXT("mDNS only works with built-in WiFi")); return; } if (object_inited) { - mp_raise_RuntimeError(translate("mDNS already initialized")); + mp_raise_RuntimeError(MP_ERROR_TEXT("mDNS already initialized")); } mdns_server_construct(self, false); } @@ -263,7 +263,7 @@ mp_obj_t common_hal_mdns_server_find(mdns_server_obj_t *self, const char *servic NETIF_STA, &alloc_search_result_cb, &state, &state.request_id); if (err != ERR_OK) { - mp_raise_RuntimeError(translate("Unable to start mDNS query")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Unable to start mDNS query")); } uint64_t start_ticks = supervisor_ticks_ms64(); @@ -315,7 +315,7 @@ void common_hal_mdns_server_advertise_service(mdns_server_obj_t *self, const cha } int8_t slot = mdns_resp_add_service(NETIF_STA, self->instance_name, service_type, proto, port, NULL, NULL); if (slot < 0) { - mp_raise_RuntimeError(translate("Out of MDNS service slots")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Out of MDNS service slots")); return; } self->service_type[slot] = service_type; diff --git a/ports/raspberrypi/common-hal/memorymap/AddressRange.c b/ports/raspberrypi/common-hal/memorymap/AddressRange.c index 185be10ab4..c2cccf3747 100644 --- a/ports/raspberrypi/common-hal/memorymap/AddressRange.c +++ b/ports/raspberrypi/common-hal/memorymap/AddressRange.c @@ -71,7 +71,7 @@ void common_hal_memorymap_addressrange_construct(memorymap_addressrange_obj_t *s } } - mp_raise_ValueError(translate("Address range not allowed")); + mp_raise_ValueError(MP_ERROR_TEXT("Address range not allowed")); } size_t common_hal_memorymap_addressrange_get_length(const memorymap_addressrange_obj_t *self) { @@ -90,7 +90,7 @@ void common_hal_memorymap_addressrange_set_bytes(const memorymap_addressrange_ob case IO: if ((size_t)dest_addr & 0x03 || len & 0x03) { // Unaligned access or unaligned length not supported by RP2 for IO registers - mp_raise_RuntimeError(translate("Unable to access unaligned IO register")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Unable to access unaligned IO register")); } else { // Aligned access and length, use 32-bit writes uint32_t *dest_addr32 = (uint32_t *)dest_addr; @@ -103,7 +103,7 @@ void common_hal_memorymap_addressrange_set_bytes(const memorymap_addressrange_ob case XIP: case ROM: // XIP and ROM are read-only - mp_raise_RuntimeError(translate("Unable to write to read-only memory")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Unable to write to read-only memory")); break; } } @@ -122,7 +122,7 @@ void common_hal_memorymap_addressrange_get_bytes(const memorymap_addressrange_ob case IO: if ((size_t)src_addr & 0x03 || len & 0x03) { // Unaligned access or unaligned length not supported by RP2 for IO registers - mp_raise_RuntimeError(translate("Unable to access unaligned IO register")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Unable to access unaligned IO register")); } else { // Aligned access and length, use 32-bit reads uint32_t *src_addr32 = (uint32_t *)src_addr; diff --git a/ports/raspberrypi/common-hal/paralleldisplaybus/ParallelBus.c b/ports/raspberrypi/common-hal/paralleldisplaybus/ParallelBus.c index 00ca844cf6..51acd0f6e7 100644 --- a/ports/raspberrypi/common-hal/paralleldisplaybus/ParallelBus.c +++ b/ports/raspberrypi/common-hal/paralleldisplaybus/ParallelBus.c @@ -50,13 +50,13 @@ void common_hal_paralleldisplaybus_parallelbus_construct(paralleldisplaybus_para uint8_t data_pin = data0->number; for (uint8_t i = 0; i < 8; i++) { if (!pin_number_is_free(data_pin + i)) { - mp_raise_ValueError_varg(translate("Bus pin %d is already in use"), i); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Bus pin %d is already in use"), i); } } uint8_t write_pin = write->number; if (!pin_number_is_free(write_pin)) { - mp_raise_ValueError_varg(translate("Bus pin %d is already in use"), write_pin); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Bus pin %d is already in use"), write_pin); } self->command.base.type = &digitalio_digitalinout_type; diff --git a/ports/raspberrypi/common-hal/picodvi/Framebuffer.c b/ports/raspberrypi/common-hal/picodvi/Framebuffer.c index 6ad824d080..e6be4abc13 100644 --- a/ports/raspberrypi/common-hal/picodvi/Framebuffer.c +++ b/ports/raspberrypi/common-hal/picodvi/Framebuffer.c @@ -139,7 +139,7 @@ void common_hal_picodvi_framebuffer_construct(picodvi_framebuffer_obj_t *self, const mcu_pin_obj_t *blue_dp, const mcu_pin_obj_t *blue_dn, mp_uint_t color_depth) { if (active_picodvi != NULL) { - mp_raise_msg_varg(&mp_type_RuntimeError, translate("%q in use"), MP_QSTR_picodvi); + mp_raise_msg_varg(&mp_type_RuntimeError, MP_ERROR_TEXT("%q in use"), MP_QSTR_picodvi); } bool color_framebuffer = color_depth >= 8; @@ -152,15 +152,15 @@ void common_hal_picodvi_framebuffer_construct(picodvi_framebuffer_obj_t *self, timing = &dvi_timing_800x480p_60hz; } else { if (height != 480 && height != 240) { - mp_raise_ValueError_varg(translate("Invalid %q"), MP_QSTR_height); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Invalid %q"), MP_QSTR_height); } - mp_raise_ValueError_varg(translate("Invalid %q"), MP_QSTR_width); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Invalid %q"), MP_QSTR_width); } // If the width is > 400, then it must not be color frame buffer and vice // versa. if ((width > 400) == color_framebuffer) { - mp_raise_ValueError_varg(translate("Invalid %q"), MP_QSTR_color_depth); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Invalid %q"), MP_QSTR_color_depth); } bool invert_diffpairs = clk_dn->number < clk_dp->number; @@ -215,7 +215,7 @@ void common_hal_picodvi_framebuffer_construct(picodvi_framebuffer_obj_t *self, } if (pio_index == NUM_PIOS) { - mp_raise_RuntimeError(translate("All state machines in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("All state machines in use")); } self->width = width; @@ -251,7 +251,7 @@ void common_hal_picodvi_framebuffer_construct(picodvi_framebuffer_obj_t *self, // Do the pwmio check last because it claims the pwm slice. if (!pwmio_claim_slice_ab_channels(slice)) { - mp_raise_ValueError(translate("All timers for this pin are in use")); + mp_raise_ValueError(MP_ERROR_TEXT("All timers for this pin are in use")); } self->pwm_slice = slice; diff --git a/ports/raspberrypi/common-hal/pulseio/PulseIn.c b/ports/raspberrypi/common-hal/pulseio/PulseIn.c index cd81e61e92..a67f115b53 100644 --- a/ports/raspberrypi/common-hal/pulseio/PulseIn.c +++ b/ports/raspberrypi/common-hal/pulseio/PulseIn.c @@ -171,7 +171,7 @@ void common_hal_pulseio_pulsein_clear(pulseio_pulsein_obj_t *self) { uint16_t common_hal_pulseio_pulsein_popleft(pulseio_pulsein_obj_t *self) { if (self->len == 0) { - mp_raise_IndexError_varg(translate("pop from empty %q"), MP_QSTR_PulseIn); + mp_raise_IndexError_varg(MP_ERROR_TEXT("pop from empty %q"), MP_QSTR_PulseIn); } uint16_t value = self->buffer[self->start]; self->start = (self->start + 1) % self->maxlen; diff --git a/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c b/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c index 54d0fd7858..4023b02191 100644 --- a/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c +++ b/ports/raspberrypi/common-hal/rotaryio/IncrementalEncoder.c @@ -70,7 +70,7 @@ void common_hal_rotaryio_incrementalencoder_construct(rotaryio_incrementalencode pins[1] = pin_a; self->swapped = false; if (!common_hal_rp2pio_pins_are_sequential(2, pins)) { - mp_raise_RuntimeError(translate("Pins must be sequential GPIO pins")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Pins must be sequential GPIO pins")); } } diff --git a/ports/raspberrypi/common-hal/rp2pio/StateMachine.c b/ports/raspberrypi/common-hal/rp2pio/StateMachine.c index 7e3be9d3e3..357e6e45cf 100644 --- a/ports/raspberrypi/common-hal/rp2pio/StateMachine.c +++ b/ports/raspberrypi/common-hal/rp2pio/StateMachine.c @@ -162,11 +162,11 @@ STATIC uint32_t _check_pins_free(const mcu_pin_obj_t *first_pin, uint8_t pin_cou for (size_t i = 0; i < pin_count; i++) { uint8_t pin_number = first_pin->number + i; if (pin_number >= NUM_BANK0_GPIOS) { - mp_raise_ValueError(translate("Pin count too large")); + mp_raise_ValueError(MP_ERROR_TEXT("Pin count too large")); } const mcu_pin_obj_t *pin = mcu_get_pin_by_number(pin_number); if (!pin) { - mp_raise_ValueError_varg(translate("%q in use"), MP_QSTR_Pin); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q in use"), MP_QSTR_Pin); } if (exclusive_pin_use || _pin_reference_count[pin_number] == 0) { @@ -428,21 +428,21 @@ static void consider_instruction(introspect_t *state, uint16_t full_instruction, if (instruction == pio_instr_bits_jmp) { uint16_t condition = (full_instruction & 0x00e0) >> 5; if ((condition == 0x6) && !state->inputs.has_jmp_pin) { - mp_raise_ValueError_varg(translate("Missing jmp_pin. %q[%u] jumps on pin"), what_program, i); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Missing jmp_pin. %q[%u] jumps on pin"), what_program, i); } } if (instruction == pio_instr_bits_wait) { uint16_t wait_source = (full_instruction & 0x0060) >> 5; uint16_t wait_index = full_instruction & 0x001f; if (wait_source == 0 && (state->inputs.pins_we_use & (1 << wait_index)) == 0) { // GPIO - mp_raise_ValueError_varg(translate("%q[%u] uses extra pin"), what_program, i); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q[%u] uses extra pin"), what_program, i); } if (wait_source == 1) { // Input pin if (!state->inputs.has_in_pin) { - mp_raise_ValueError_varg(translate("Missing first_in_pin. %q[%u] waits based on pin"), what_program, i); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Missing first_in_pin. %q[%u] waits based on pin"), what_program, i); } if (wait_index >= state->inputs.in_pin_count) { - mp_raise_ValueError_varg(translate("%q[%u] waits on input outside of count"), what_program, i); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q[%u] waits on input outside of count"), what_program, i); } } } @@ -451,10 +451,10 @@ static void consider_instruction(introspect_t *state, uint16_t full_instruction, uint16_t bit_count = full_instruction & 0x001f; if (source == 0) { if (!state->inputs.has_in_pin) { - mp_raise_ValueError_varg(translate("Missing first_in_pin. %q[%u] shifts in from pin(s)"), what_program, i); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Missing first_in_pin. %q[%u] shifts in from pin(s)"), what_program, i); } if (bit_count > state->inputs.in_pin_count) { - mp_raise_ValueError_varg(translate("%q[%u] shifts in more bits than pin count"), what_program, i); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q[%u] shifts in more bits than pin count"), what_program, i); } } if (state->inputs.auto_push) { @@ -469,10 +469,10 @@ static void consider_instruction(introspect_t *state, uint16_t full_instruction, // Check for pins or pindirs destination. if (destination == 0x0 || destination == 0x4) { if (!state->inputs.has_out_pin) { - mp_raise_ValueError_varg(translate("Missing first_out_pin. %q[%u] shifts out to pin(s)"), what_program, i); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Missing first_out_pin. %q[%u] shifts out to pin(s)"), what_program, i); } if (bit_count > state->inputs.out_pin_count) { - mp_raise_ValueError_varg(translate("%q[%u] shifts out more bits than pin count"), what_program, i); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q[%u] shifts out more bits than pin count"), what_program, i); } } if (state->inputs.auto_pull) { @@ -485,7 +485,7 @@ static void consider_instruction(introspect_t *state, uint16_t full_instruction, uint16_t destination = (full_instruction & 0x00e0) >> 5; // Check for pins or pindirs destination. if ((destination == 0x00 || destination == 0x4) && !state->inputs.has_set_pin) { - mp_raise_ValueError_varg(translate("Missing first_set_pin. %q[%u] sets pin(s)"), what_program, i); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Missing first_set_pin. %q[%u] sets pin(s)"), what_program, i); } } if (instruction == pio_instr_bits_mov) { @@ -493,10 +493,10 @@ static void consider_instruction(introspect_t *state, uint16_t full_instruction, uint16_t destination = (full_instruction & 0x00e0) >> 5; // Check for pins or pindirs destination. if (destination == 0x0 && !state->inputs.has_out_pin) { - mp_raise_ValueError_varg(translate("Missing first_out_pin. %q[%u] writes pin(s)"), what_program, i); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Missing first_out_pin. %q[%u] writes pin(s)"), what_program, i); } if (source == 0x0 && !state->inputs.has_in_pin) { - mp_raise_ValueError_varg(translate("Missing first_in_pin. %q[%u] reads pin(s)"), what_program, i); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Missing first_in_pin. %q[%u] reads pin(s)"), what_program, i); } if (destination == 0x6) { state->outputs.in_loaded = true; @@ -560,10 +560,10 @@ void common_hal_rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self, consider_program(&state, may_exec, may_exec_len, MP_QSTR_may_exec); if (!state.outputs.in_loaded && state.outputs.in_used) { - mp_raise_ValueError_varg(translate("Program does IN without loading ISR")); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Program does IN without loading ISR")); } if (!state.outputs.out_loaded && state.outputs.out_used) { - mp_raise_ValueError_varg(translate("Program does OUT without loading OSR")); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Program does OUT without loading OSR")); } uint32_t initial_pin_state = mask_and_rotate(first_out_pin, out_pin_count, initial_out_pin_state); @@ -574,10 +574,10 @@ void common_hal_rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self, mask_and_rotate(first_set_pin, set_pin_count, 0xffffffff); // Check that OUT and SET settings agree because we don't have a way of picking one over the other. if ((initial_pin_state & set_out_overlap) != (initial_set_pin_state & set_out_overlap)) { - mp_raise_ValueError(translate("Initial set pin state conflicts with initial out pin state")); + mp_raise_ValueError(MP_ERROR_TEXT("Initial set pin state conflicts with initial out pin state")); } if ((initial_pin_direction & set_out_overlap) != (initial_set_pin_direction & set_out_overlap)) { - mp_raise_ValueError(translate("Initial set pin direction conflicts with initial out pin direction")); + mp_raise_ValueError(MP_ERROR_TEXT("Initial set pin direction conflicts with initial out pin direction")); } initial_pin_state |= initial_set_pin_state; initial_pin_direction |= initial_set_pin_direction; @@ -601,7 +601,7 @@ void common_hal_rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self, } } if (initial_pin_direction & (pull_up | pull_down)) { - mp_raise_ValueError(translate("pull masks conflict with direction masks")); + mp_raise_ValueError(MP_ERROR_TEXT("pull masks conflict with direction masks")); } bool ok = rp2pio_statemachine_construct( self, @@ -624,7 +624,7 @@ void common_hal_rp2pio_statemachine_construct(rp2pio_statemachine_obj_t *self, sideset_enable, wrap_target, wrap, offset); if (!ok) { - mp_raise_RuntimeError(translate("All state machines in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("All state machines in use")); } } @@ -668,7 +668,7 @@ void common_hal_rp2pio_statemachine_set_frequency(rp2pio_statemachine_obj_t *sel } // 0 is interpreted as 0x10000 so it's valid. if (div256 / 256 > 0x10000 || frequency > clock_get_hz(clk_sys)) { - mp_raise_ValueError_varg(translate("%q out of range"), MP_QSTR_frequency); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q out of range"), MP_QSTR_frequency); } self->actual_frequency = frequency256 / div256; @@ -893,14 +893,14 @@ static bool _transfer(rp2pio_statemachine_obj_t *self, bool common_hal_rp2pio_statemachine_write(rp2pio_statemachine_obj_t *self, const uint8_t *data, size_t len, uint8_t stride_in_bytes, bool swap) { if (!self->out) { - mp_raise_RuntimeError(translate("No out in program")); + mp_raise_RuntimeError(MP_ERROR_TEXT("No out in program")); } return _transfer(self, data, len, stride_in_bytes, NULL, 0, 0, swap, false); } bool common_hal_rp2pio_statemachine_readinto(rp2pio_statemachine_obj_t *self, uint8_t *data, size_t len, uint8_t stride_in_bytes, bool swap) { if (!self->in) { - mp_raise_RuntimeError(translate("No in in program")); + mp_raise_RuntimeError(MP_ERROR_TEXT("No in in program")); } return _transfer(self, NULL, 0, 0, data, len, stride_in_bytes, false, swap); } @@ -909,7 +909,7 @@ bool common_hal_rp2pio_statemachine_write_readinto(rp2pio_statemachine_obj_t *se const uint8_t *data_out, size_t out_len, uint8_t out_stride_in_bytes, uint8_t *data_in, size_t in_len, uint8_t in_stride_in_bytes, bool swap_out, bool swap_in) { if (!self->in || !self->out) { - mp_raise_RuntimeError(translate("No in or out in program")); + mp_raise_RuntimeError(MP_ERROR_TEXT("No in or out in program")); } return _transfer(self, data_out, out_len, out_stride_in_bytes, data_in, in_len, in_stride_in_bytes, swap_out, swap_in); } @@ -993,10 +993,10 @@ bool common_hal_rp2pio_statemachine_background_write(rp2pio_statemachine_obj_t * if (SM_DMA_ALLOCATED(pio_index, sm)) { if (stride_in_bytes != self->background_stride_in_bytes) { - mp_raise_ValueError(translate("Mismatched data size")); + mp_raise_ValueError(MP_ERROR_TEXT("Mismatched data size")); } if (swap != self->byteswap) { - mp_raise_ValueError(translate("Mismatched swap flag")); + mp_raise_ValueError(MP_ERROR_TEXT("Mismatched swap flag")); } while (self->pending_buffers) { diff --git a/ports/raspberrypi/common-hal/rtc/RTC.c b/ports/raspberrypi/common-hal/rtc/RTC.c index 9bfda0af31..20a5a18fa7 100644 --- a/ports/raspberrypi/common-hal/rtc/RTC.c +++ b/ports/raspberrypi/common-hal/rtc/RTC.c @@ -92,5 +92,5 @@ int common_hal_rtc_get_calibration(void) { } void common_hal_rtc_set_calibration(int calibration) { - mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_calibration); + mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_calibration); } diff --git a/ports/raspberrypi/common-hal/socketpool/Socket.c b/ports/raspberrypi/common-hal/socketpool/Socket.c index b2a4ea63c6..cb1ed8c7c3 100644 --- a/ports/raspberrypi/common-hal/socketpool/Socket.c +++ b/ports/raspberrypi/common-hal/socketpool/Socket.c @@ -732,14 +732,14 @@ bool 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) { if (family != SOCKETPOOL_AF_INET) { - mp_raise_NotImplementedError(translate("Only IPv4 sockets supported")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("Only IPv4 sockets supported")); } socketpool_socket_obj_t *socket = m_new_obj_with_finaliser(socketpool_socket_obj_t); socket->base.type = &socketpool_socket_type; if (!socketpool_socket(self, family, type, socket)) { - mp_raise_RuntimeError(translate("Out of sockets")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Out of sockets")); } mark_user_socket(socket); return socket; @@ -856,7 +856,7 @@ socketpool_socket_obj_t *common_hal_socketpool_socket_accept(socketpool_socket_o DEBUG_printf("collecting garbage to open socket\n"); gc_collect(); if (!register_open_socket(accepted)) { - mp_raise_RuntimeError(translate("Out of sockets")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Out of sockets")); } } mark_user_socket(accepted); diff --git a/ports/raspberrypi/common-hal/socketpool/SocketPool.c b/ports/raspberrypi/common-hal/socketpool/SocketPool.c index e562314d69..e27a56a423 100644 --- a/ports/raspberrypi/common-hal/socketpool/SocketPool.c +++ b/ports/raspberrypi/common-hal/socketpool/SocketPool.c @@ -35,7 +35,7 @@ void common_hal_socketpool_socketpool_construct(socketpool_socketpool_obj_t *self, mp_obj_t radio) { if (radio != MP_OBJ_FROM_PTR(&common_hal_wifi_radio_obj)) { - mp_raise_ValueError(translate("SocketPool can only be used with wifi.radio")); + mp_raise_ValueError(MP_ERROR_TEXT("SocketPool can only be used with wifi.radio")); } } diff --git a/ports/raspberrypi/common-hal/ssl/SSLSocket.c b/ports/raspberrypi/common-hal/ssl/SSLSocket.c index 06fe350cb6..c881eb79da 100644 --- a/ports/raspberrypi/common-hal/ssl/SSLSocket.c +++ b/ports/raspberrypi/common-hal/ssl/SSLSocket.c @@ -137,7 +137,7 @@ ssl_sslsocket_obj_t *common_hal_ssl_sslcontext_wrap_socket(ssl_sslcontext_obj_t socketpool_socket_obj_t *socket, bool server_side, const char *server_hostname) { if (socket->type != SOCKETPOOL_SOCK_STREAM) { - mp_raise_RuntimeError(translate("Invalid socket for TLS")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Invalid socket for TLS")); } ssl_sslsocket_obj_t *o = m_new_obj_with_finaliser(ssl_sslsocket_obj_t); diff --git a/ports/raspberrypi/common-hal/usb_host/Port.c b/ports/raspberrypi/common-hal/usb_host/Port.c index 93d19acd69..700f2f1ba6 100644 --- a/ports/raspberrypi/common-hal/usb_host/Port.c +++ b/ports/raspberrypi/common-hal/usb_host/Port.c @@ -111,7 +111,7 @@ usb_host_port_obj_t *common_hal_usb_host_port_construct(const mcu_pin_obj_t *dp, // Return the singleton if given the same pins. if (self->dp != NULL) { if (self->dp != dp || self->dm != dm) { - mp_raise_msg_varg(&mp_type_RuntimeError, translate("%q in use"), MP_QSTR_usb_host); + mp_raise_msg_varg(&mp_type_RuntimeError, MP_ERROR_TEXT("%q in use"), MP_QSTR_usb_host); } return self; } @@ -128,11 +128,11 @@ usb_host_port_obj_t *common_hal_usb_host_port_construct(const mcu_pin_obj_t *dp, // PIO with room for 31 instructions and two free SM. if (!_has_program_room(pio_cfg.pio_tx_num, 22) || _sm_free_count(pio_cfg.pio_tx_num) < 1 || !_has_program_room(pio_cfg.pio_rx_num, 31) || _sm_free_count(pio_cfg.pio_rx_num) < 2) { - mp_raise_RuntimeError(translate("All state machines in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("All state machines in use")); } pio_cfg.tx_ch = dma_claim_unused_channel(false); // DMA channel if (pio_cfg.tx_ch < 0) { - mp_raise_RuntimeError(translate("All dma channels in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("All dma channels in use")); } self->base.type = &usb_host_port_type; diff --git a/ports/raspberrypi/common-hal/wifi/Monitor.c b/ports/raspberrypi/common-hal/wifi/Monitor.c index f288cd1ea1..e4bb58d6d1 100644 --- a/ports/raspberrypi/common-hal/wifi/Monitor.c +++ b/ports/raspberrypi/common-hal/wifi/Monitor.c @@ -40,7 +40,7 @@ typedef struct { } monitor_packet_t; void common_hal_wifi_monitor_construct(wifi_monitor_obj_t *self, uint8_t channel, size_t queue) { - mp_raise_NotImplementedError(translate("wifi.Monitor not available")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("wifi.Monitor not available")); } bool common_hal_wifi_monitor_deinited(void) { diff --git a/ports/raspberrypi/common-hal/wifi/Radio.c b/ports/raspberrypi/common-hal/wifi/Radio.c index 0d196415fc..96ab404fbe 100644 --- a/ports/raspberrypi/common-hal/wifi/Radio.c +++ b/ports/raspberrypi/common-hal/wifi/Radio.c @@ -67,7 +67,7 @@ static inline void nw_put_le32(uint8_t *buf, uint32_t x) { } NORETURN static void ro_attribute(qstr attr) { - mp_raise_NotImplementedError_varg(translate("%q is read-only for this board"), attr); + mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q is read-only for this board"), attr); } bool common_hal_wifi_radio_get_enabled(wifi_radio_obj_t *self) { @@ -137,10 +137,10 @@ void common_hal_wifi_radio_set_mac_address_ap(wifi_radio_obj_t *self, const uint mp_obj_t common_hal_wifi_radio_start_scanning_networks(wifi_radio_obj_t *self, uint8_t start_channel, uint8_t stop_channel) { // channel bounds are ignored; not implemented in driver if (self->current_scan) { - mp_raise_RuntimeError(translate("Already scanning for wifi networks")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Already scanning for wifi networks")); } if (!common_hal_wifi_radio_get_enabled(self)) { - mp_raise_RuntimeError(translate("Wifi is not enabled")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Wifi is not enabled")); } wifi_scannednetworks_obj_t *scan = mp_obj_malloc(wifi_scannednetworks_obj_t, &wifi_scannednetworks_type); mp_obj_t args[] = { mp_const_empty_tuple, MP_OBJ_NEW_SMALL_INT(16) }; @@ -176,7 +176,7 @@ void common_hal_wifi_radio_stop_station(wifi_radio_obj_t *self) { void common_hal_wifi_radio_start_ap(wifi_radio_obj_t *self, uint8_t *ssid, size_t ssid_len, uint8_t *password, size_t password_len, uint8_t channel, uint32_t authmode, uint8_t max_connections) { if (!common_hal_wifi_radio_get_enabled(self)) { - mp_raise_RuntimeError(translate("Wifi is not enabled")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Wifi is not enabled")); } /* TODO: If the AP is stopped once it cannot be restarted. @@ -216,7 +216,7 @@ void common_hal_wifi_radio_start_ap(wifi_radio_obj_t *self, uint8_t *ssid, size_ if (cyw43_tcpip_link_status(&cyw43_state, CYW43_ITF_AP) != CYW43_LINK_UP) { common_hal_wifi_radio_stop_ap(self); // This is needed since it leaves a broken AP up. - mp_raise_RuntimeError(translate("AP could not be started")); + mp_raise_RuntimeError(MP_ERROR_TEXT("AP could not be started")); } } @@ -226,7 +226,7 @@ bool common_hal_wifi_radio_get_ap_active(wifi_radio_obj_t *self) { void common_hal_wifi_radio_stop_ap(wifi_radio_obj_t *self) { if (!common_hal_wifi_radio_get_enabled(self)) { - mp_raise_RuntimeError(translate("wifi is not enabled")); + mp_raise_RuntimeError(MP_ERROR_TEXT("wifi is not enabled")); } cyw43_arch_disable_ap_mode(); @@ -259,7 +259,7 @@ static bool connection_unchanged(wifi_radio_obj_t *self, const uint8_t *ssid, si 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) { if (!common_hal_wifi_radio_get_enabled(self)) { - mp_raise_RuntimeError(translate("Wifi is not enabled")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Wifi is not enabled")); } if (ssid_len > 32) { diff --git a/ports/raspberrypi/common-hal/wifi/__init__.c b/ports/raspberrypi/common-hal/wifi/__init__.c index 63f09fc774..7c8352399a 100644 --- a/ports/raspberrypi/common-hal/wifi/__init__.c +++ b/ports/raspberrypi/common-hal/wifi/__init__.c @@ -107,14 +107,14 @@ void raise_cyw_error(int err) { mp_errno = MP_ETIMEDOUT; break; default: - mp_raise_OSError_msg_varg(translate("Unknown error code %d"), err); + mp_raise_OSError_msg_varg(MP_ERROR_TEXT("Unknown error code %d"), err); } mp_raise_OSError(mp_errno); } void ipaddress_ipaddress_to_lwip(mp_obj_t ip_address, ip_addr_t *lwip_ip_address) { if (!mp_obj_is_type(ip_address, &ipaddress_ipv4address_type)) { - mp_raise_ValueError(translate("Only IPv4 addresses supported")); + mp_raise_ValueError(MP_ERROR_TEXT("Only IPv4 addresses supported")); } mp_obj_t packed = common_hal_ipaddress_ipv4address_get_packed(ip_address); size_t len; diff --git a/ports/silabs/boards/devkit_xg24_brd2601b/sensor.c b/ports/silabs/boards/devkit_xg24_brd2601b/sensor.c index a3b0b68993..2adfd67c4b 100644 --- a/ports/silabs/boards/devkit_xg24_brd2601b/sensor.c +++ b/ports/silabs/boards/devkit_xg24_brd2601b/sensor.c @@ -41,7 +41,7 @@ STATIC mp_obj_t sensor_init(mp_obj_t i2c_in) { sl_status_t sc; if (!common_hal_mcu_pin_is_free(&pin_PC9)) { - mp_raise_ValueError(translate("Pin PC9 is busy ")); + mp_raise_ValueError(MP_ERROR_TEXT("Pin PC9 is busy ")); return mp_const_false; } diff --git a/ports/silabs/common-hal/_bleio/Adapter.c b/ports/silabs/common-hal/_bleio/Adapter.c index 4d592f4422..d469172ae9 100644 --- a/ports/silabs/common-hal/_bleio/Adapter.c +++ b/ports/silabs/common-hal/_bleio/Adapter.c @@ -93,7 +93,7 @@ void common_hal_bleio_adapter_set_enabled(bleio_adapter_obj_t *self, sc = sl_bt_system_get_identity_address(&get_address, &address_type); if (SL_STATUS_OK != sc) { - mp_raise_bleio_BluetoothError(translate("Get address fail.")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Get address fail.")); } snprintf((char *)device_name, DEVICE_NAME_LEN + 1, "CIRCUITPY-%X%X", get_address.addr[1], get_address.addr[0]); @@ -202,7 +202,7 @@ mp_obj_t common_hal_bleio_adapter_start_scan(bleio_adapter_obj_t *self, if (self->scan_results != NULL) { if (!shared_module_bleio_scanresults_get_done(self->scan_results)) { mp_raise_bleio_BluetoothError( - translate("Scan already in progress. Stop with stop_scan.")); + MP_ERROR_TEXT("Scan already in progress. Stop with stop_scan.")); } self->scan_results = NULL; } @@ -295,7 +295,7 @@ uint32_t _common_hal_bleio_adapter_start_advertising( sc = sl_bt_advertiser_create_set(&self->advertising_handle); if (SL_STATUS_OK != sc) { - mp_raise_bleio_BluetoothError(translate("Create_set fail.")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Create_set fail.")); return sc; } sc = sl_bt_advertiser_set_channel_map(self->advertising_handle, 7); @@ -306,7 +306,7 @@ uint32_t _common_hal_bleio_adapter_start_advertising( sc = sl_bt_system_get_identity_address(&address, &address_type); if (SL_STATUS_OK != sc) { - mp_raise_bleio_BluetoothError(translate("Get address fail.")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Get address fail.")); return sc; } // Pad and reverse unique ID to get System ID. @@ -343,7 +343,7 @@ uint32_t _common_hal_bleio_adapter_start_advertising( 0); // max. num. adv. events if (SL_STATUS_OK != sc) { - mp_raise_bleio_BluetoothError(translate("Set_timing fail.")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Set_timing fail.")); return sc; } @@ -354,7 +354,7 @@ uint32_t _common_hal_bleio_adapter_start_advertising( advertising_data); if (SL_STATUS_OK != sc) { - mp_raise_bleio_BluetoothError(translate("Set data fail.")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Set data fail.")); return sc; } @@ -367,7 +367,7 @@ uint32_t _common_hal_bleio_adapter_start_advertising( enable_connect); if (SL_STATUS_OK != sc) { - mp_raise_bleio_BluetoothError(translate("Start advertise fail.")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Start advertise fail.")); } else { self->user_advertising = true; } @@ -380,7 +380,7 @@ STATIC void check_data_fit(size_t data_len, bool connectable) { if (data_len > BLE_EXT_ADV_MAX_SIZE || (connectable && data_len > BLE_EXT_ADV_MAX_SIZE)) { mp_raise_ValueError( - translate("Data too large for advertisement packet")); + MP_ERROR_TEXT("Data too large for advertisement packet")); } } @@ -406,12 +406,12 @@ void common_hal_bleio_adapter_start_advertising( if (advertising_data_bufinfo->len > 31 && scan_response_data_bufinfo->len > 0) { mp_raise_bleio_BluetoothError( - translate("Extended advertisements not supported")); + MP_ERROR_TEXT("Extended advertisements not supported")); } if (advertising_data_bufinfo->len > 0 && directed_to != NULL) { mp_raise_bleio_BluetoothError( - translate("Data not supported with directed advertising")); + MP_ERROR_TEXT("Data not supported with directed advertising")); } if (anonymous) { @@ -422,7 +422,7 @@ void common_hal_bleio_adapter_start_advertising( timeout = INT32_MAX; } else if (timeout > INT32_MAX) { mp_raise_bleio_BluetoothError( - translate("Maximum timeout length is %d seconds"), INT32_MAX / 1000); + MP_ERROR_TEXT("Maximum timeout length is %d seconds"), INT32_MAX / 1000); } _common_hal_bleio_adapter_start_advertising(self, connectable, anonymous, @@ -525,7 +525,7 @@ mp_obj_t common_hal_bleio_adapter_connect(bleio_adapter_obj_t *self, } mp_raise_bleio_BluetoothError( - translate("Failed to connect: internal error")); + MP_ERROR_TEXT("Failed to connect: internal error")); return mp_const_none; } @@ -587,7 +587,7 @@ void common_hal_bleio_adapter_erase_bonding(bleio_adapter_obj_t *self) { sl_status_t sc; sc = sl_bt_sm_delete_bondings(); if (SL_STATUS_OK != sc) { - mp_raise_bleio_BluetoothError(translate("All bonding deleted fail.")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("All bonding deleted fail.")); } } diff --git a/ports/silabs/common-hal/_bleio/Characteristic.c b/ports/silabs/common-hal/_bleio/Characteristic.c index d713e04d00..d5cd567a60 100644 --- a/ports/silabs/common-hal/_bleio/Characteristic.c +++ b/ports/silabs/common-hal/_bleio/Characteristic.c @@ -51,7 +51,7 @@ bool set_characteristic_value_on_ble_evt(uint8_t conn_handle, bleio_connection_internal_t *connection = bleio_conn_handle_to_connection(conn_handle); if (NULL == connection) { - mp_raise_bleio_BluetoothError(translate("Get connection fail.")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Get connection fail.")); return false; } for (serv_index = 0; serv_index < connection->remote_service_list->len; serv_index++) { @@ -88,7 +88,7 @@ STATIC bool get_characteristic_value(uint8_t conn_handle, bleio_connection_internal_t *connection = bleio_conn_handle_to_connection(conn_handle); if (NULL == connection) { - mp_raise_bleio_BluetoothError(translate("Get connection fail.")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Get connection fail.")); return false; } for (serv_index = 0; serv_index < connection->remote_service_list->len; serv_index++) { @@ -234,7 +234,7 @@ size_t common_hal_bleio_characteristic_get_value( (uint8_t *)buf); if (SL_STATUS_OK != sc) { mp_raise_bleio_BluetoothError( - translate("Read_attribute_value fail!")); + MP_ERROR_TEXT("Read_attribute_value fail!")); } return len; } @@ -280,7 +280,7 @@ void common_hal_bleio_characteristic_set_value(bleio_characteristic_obj_t *self, (uint8_t *)bufinfo->buf); if (SL_STATUS_OK != sc) { mp_raise_bleio_BluetoothError( - translate("Write_attribute_value fail!")); + MP_ERROR_TEXT("Write_attribute_value fail!")); } } @@ -328,7 +328,7 @@ void common_hal_bleio_characteristic_add_descriptor( sc = sl_bt_gattdb_new_session(&gattdb_session); if (SL_STATUS_OK != sc && SL_STATUS_ALREADY_EXISTS != sc) { - mp_raise_bleio_BluetoothError(translate("Create new session fail.")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Create new session fail.")); return; } @@ -362,7 +362,7 @@ void common_hal_bleio_characteristic_add_descriptor( sc = sl_bt_gattdb_commit(gattdb_session); if (SL_STATUS_OK != sc) { - mp_raise_bleio_BluetoothError(translate("Commit descriptor fail.")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Commit descriptor fail.")); return; } @@ -385,7 +385,7 @@ void common_hal_bleio_characteristic_set_cccd(bleio_characteristic_obj_t *self, sc = sl_bt_gatt_set_characteristic_notification(conn_handle, self->handle, sl_bt_gatt_notification); if (SL_STATUS_OK != sc) { - mp_raise_bleio_BluetoothError(translate("Notify fail")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Notify fail")); } } @@ -393,7 +393,7 @@ void common_hal_bleio_characteristic_set_cccd(bleio_characteristic_obj_t *self, sc = sl_bt_gatt_set_characteristic_notification(conn_handle, self->handle, sl_bt_gatt_indication); if (SL_STATUS_OK != sc) { - mp_raise_bleio_BluetoothError(translate("Indicate fail")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Indicate fail")); } } @@ -401,7 +401,7 @@ void common_hal_bleio_characteristic_set_cccd(bleio_characteristic_obj_t *self, sc = sl_bt_gatt_set_characteristic_notification(conn_handle, self->handle, sl_bt_gatt_disable); if (SL_STATUS_OK != sc) { - mp_raise_bleio_BluetoothError(translate("Indicate fail")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Indicate fail")); } } } diff --git a/ports/silabs/common-hal/_bleio/Connection.c b/ports/silabs/common-hal/_bleio/Connection.c index 27adc49e91..3e8d273c06 100644 --- a/ports/silabs/common-hal/_bleio/Connection.c +++ b/ports/silabs/common-hal/_bleio/Connection.c @@ -103,7 +103,7 @@ mp_int_t common_hal_bleio_connection_get_max_packet_length( sl_status_t sc = sl_bt_gatt_server_get_mtu(self->conn_handle, &self->mtu); if (sc != SL_STATUS_OK) { - mp_raise_bleio_BluetoothError(translate("gatt_server_get_mtu fail.")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("gatt_server_get_mtu fail.")); } return self->mtu; @@ -142,7 +142,7 @@ mp_obj_tuple_t *common_hal_bleio_connection_discover_remote_services( bleio_connection_ensure_connected(self); if (NULL == self->connection->remote_service_list) { mp_raise_bleio_BluetoothError( - translate("Create new remote service list fail.")); + MP_ERROR_TEXT("Create new remote service list fail.")); return mp_const_none; } vTaskDelay(500 / portTICK_PERIOD_MS); @@ -151,7 +151,7 @@ mp_obj_tuple_t *common_hal_bleio_connection_discover_remote_services( sc = sl_bt_gatt_discover_primary_services(self->connection->conn_handle); if (SL_STATUS_OK != sc) { - mp_raise_bleio_BluetoothError(translate("Discover uuid fail.")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Discover uuid fail.")); return mp_const_none; } @@ -181,7 +181,7 @@ mp_obj_tuple_t *common_hal_bleio_connection_discover_remote_services( while ((uuid_obj = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { if (!mp_obj_is_type(uuid_obj, &bleio_uuid_type)) { mp_raise_TypeError( - translate("non-UUID found in service_uuids_whitelist")); + MP_ERROR_TEXT("non-UUID found in service_uuids_whitelist")); } uuid = MP_OBJ_TO_PTR(uuid_obj); @@ -199,7 +199,7 @@ mp_obj_tuple_t *common_hal_bleio_connection_discover_remote_services( } if (SL_STATUS_OK != sc) { - mp_raise_bleio_BluetoothError(translate("Discover fail.")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Discover fail.")); return mp_const_none; } @@ -230,7 +230,7 @@ mp_obj_tuple_t *common_hal_bleio_connection_discover_remote_services( self->connection->remote_service_list->items); if (NULL == services_tuple) { - mp_raise_ValueError(translate("Create new service tuple fail.")); + mp_raise_ValueError(MP_ERROR_TEXT("Create new service tuple fail.")); return mp_const_none; } return services_tuple; diff --git a/ports/silabs/common-hal/_bleio/Descriptor.c b/ports/silabs/common-hal/_bleio/Descriptor.c index 6a40f1f859..d13118d1b2 100644 --- a/ports/silabs/common-hal/_bleio/Descriptor.c +++ b/ports/silabs/common-hal/_bleio/Descriptor.c @@ -49,7 +49,7 @@ void common_hal_bleio_descriptor_construct( if (max_length < 0 || max_length > max_length_max) { mp_raise_ValueError_varg( - translate("max_length must be 0-%d when fixed_length is %s"), + MP_ERROR_TEXT("max_length must be 0-%d when fixed_length is %s"), max_length_max, fixed_length ? "True" : "False"); } self->max_length = max_length; @@ -104,10 +104,10 @@ void common_hal_bleio_descriptor_set_value(bleio_descriptor_obj_t *self, // Validate data length for local descriptors only. if (self->fixed_length && bufinfo->len != self->max_length) { mp_raise_ValueError( - translate("Value length != required fixed length")); + MP_ERROR_TEXT("Value length != required fixed length")); } if (bufinfo->len > self->max_length) { - mp_raise_ValueError(translate("Value length > max_length")); + mp_raise_ValueError(MP_ERROR_TEXT("Value length > max_length")); } } } diff --git a/ports/silabs/common-hal/_bleio/PacketBuffer.c b/ports/silabs/common-hal/_bleio/PacketBuffer.c index f771983a61..d450cd4de1 100644 --- a/ports/silabs/common-hal/_bleio/PacketBuffer.c +++ b/ports/silabs/common-hal/_bleio/PacketBuffer.c @@ -289,7 +289,7 @@ mp_int_t common_hal_bleio_packet_buffer_write(bleio_packet_buffer_obj_t *self, } if (self->outgoing[0] == NULL) { mp_raise_bleio_BluetoothError( - translate("Writes not supported on Characteristic")); + MP_ERROR_TEXT("Writes not supported on Characteristic")); } if (self->conn_handle == BLE_CONN_HANDLE_INVALID) { return -1; @@ -305,13 +305,13 @@ mp_int_t common_hal_bleio_packet_buffer_write(bleio_packet_buffer_obj_t *self, if (total_len > outgoing_packet_length) { // Supplied data will not fit in a single BLE packet. mp_raise_ValueError_varg( - translate("Total data to write is larger than %q"), + MP_ERROR_TEXT("Total data to write is larger than %q"), MP_QSTR_outgoing_packet_length); } if (total_len > self->max_packet_size) { // Supplied data will not fit in a single BLE packet. mp_raise_ValueError_varg( - translate("Total data to write is larger than %q"), + MP_ERROR_TEXT("Total data to write is larger than %q"), MP_QSTR_max_packet_size); } outgoing_packet_length = MIN(outgoing_packet_length, self->max_packet_size); diff --git a/ports/silabs/common-hal/_bleio/Service.c b/ports/silabs/common-hal/_bleio/Service.c index 5fd06a2111..3e668e569a 100644 --- a/ports/silabs/common-hal/_bleio/Service.c +++ b/ports/silabs/common-hal/_bleio/Service.c @@ -62,7 +62,7 @@ uint32_t _common_hal_bleio_service_construct( sc = sl_bt_gattdb_new_session(&gattdb_session); if (SL_STATUS_OK != sc && SL_STATUS_ALREADY_EXISTS != sc) { - mp_raise_bleio_BluetoothError(translate("Create new session fail.")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Create new session fail.")); return sc; } if (BLE_UUID_TYPE_16 == self->uuid->efr_ble_uuid.uuid.type) { @@ -81,18 +81,18 @@ uint32_t _common_hal_bleio_service_construct( } if (SL_STATUS_OK != sc) { - mp_raise_bleio_BluetoothError(translate("Create new session fail.")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Create new session fail.")); return sc; } sc = sl_bt_gattdb_start_service(gattdb_session, self->handle); if (SL_STATUS_OK != sc) { - mp_raise_bleio_BluetoothError(translate("Start service fail.")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Start service fail.")); } sc = sl_bt_gattdb_commit(gattdb_session); if (SL_STATUS_OK != sc) { - mp_raise_bleio_BluetoothError(translate("Commit service fail.")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Commit service fail.")); } bleio_service_list.data[bleio_service_list.len] = self; @@ -165,7 +165,7 @@ void common_hal_bleio_service_add_characteristic(bleio_service_obj_t *self, sc = sl_bt_gattdb_new_session(&gattdb_session); if (SL_STATUS_OK != sc && SL_STATUS_ALREADY_EXISTS != sc) { - mp_raise_bleio_BluetoothError(translate("Create new session fail.")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Create new session fail.")); return; } characteristic->props = (broadcast << 0) | (read << 1) | @@ -207,19 +207,19 @@ void common_hal_bleio_service_add_characteristic(bleio_service_obj_t *self, } if (SL_STATUS_OK != sc) { - mp_raise_bleio_BluetoothError(translate("Add charateristic fail.")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Add charateristic fail.")); } sc = sl_bt_gattdb_start_characteristic(gattdb_session, characteristic->handle); if (SL_STATUS_OK != sc) { - mp_raise_bleio_BluetoothError(translate("Start charateristic fail.")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Start charateristic fail.")); return; } sc = sl_bt_gattdb_commit(gattdb_session); if (SL_STATUS_OK != sc) { - mp_raise_bleio_BluetoothError(translate("Commit charateristic fail.")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Commit charateristic fail.")); return; } mp_obj_list_append(self->characteristic_list, diff --git a/ports/silabs/common-hal/_bleio/UUID.c b/ports/silabs/common-hal/_bleio/UUID.c index 482a23d8f8..ada9fd16d4 100644 --- a/ports/silabs/common-hal/_bleio/UUID.c +++ b/ports/silabs/common-hal/_bleio/UUID.c @@ -72,7 +72,7 @@ void bleio_uuid_construct_from_efr_ble_uuid(bleio_uuid_obj_t *self, ble_uuid_any_t *efr_ble_uuid) { if (self->efr_ble_uuid.uuid.type == BLE_UUID_TYPE_16) { - mp_raise_bleio_BluetoothError(translate("Unexpected efr uuid type")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Unexpected efr uuid type")); } self->efr_ble_uuid.uuid16.value = efr_ble_uuid->uuid16.value; } diff --git a/ports/silabs/common-hal/_bleio/__init__.c b/ports/silabs/common-hal/_bleio/__init__.c index 041fdc38b7..b5d9270af5 100644 --- a/ports/silabs/common-hal/_bleio/__init__.c +++ b/ports/silabs/common-hal/_bleio/__init__.c @@ -94,14 +94,14 @@ void check_ble_error(int error_code) { return; default: mp_raise_bleio_BluetoothError( - translate("Unknown BLE error: %d"), error_code); + MP_ERROR_TEXT("Unknown BLE error: %d"), error_code); break; } } void common_hal_bleio_check_connected(uint16_t conn_handle) { if (conn_handle == BLEIO_HANDLE_INVALID) { - mp_raise_ConnectionError(translate("Not connected")); + mp_raise_ConnectionError(MP_ERROR_TEXT("Not connected")); } } @@ -192,7 +192,7 @@ void sl_bt_on_event(sl_bt_msg_t *evt) { if (NULL == uuid) { osMutexRelease(bluetooth_connection_mutex_id); mp_raise_bleio_BluetoothError( - translate("Create new service uuid obj fail")); + MP_ERROR_TEXT("Create new service uuid obj fail")); break; } uuid->base.type = &bleio_uuid_type; diff --git a/ports/silabs/common-hal/analogio/AnalogIn.c b/ports/silabs/common-hal/analogio/AnalogIn.c index bfdce02415..dc2846ff41 100644 --- a/ports/silabs/common-hal/analogio/AnalogIn.c +++ b/ports/silabs/common-hal/analogio/AnalogIn.c @@ -65,7 +65,7 @@ void common_hal_analogio_analogin_construct(analogio_analogin_obj_t *self, } if (self->id == NUM_INPUTS + 1) { - mp_raise_ValueError(translate("ADC busy pin")); + mp_raise_ValueError(MP_ERROR_TEXT("ADC busy pin")); } // Declare init structs diff --git a/ports/silabs/common-hal/analogio/AnalogOut.c b/ports/silabs/common-hal/analogio/AnalogOut.c index ae5a8a6903..f3fd63a32c 100644 --- a/ports/silabs/common-hal/analogio/AnalogOut.c +++ b/ports/silabs/common-hal/analogio/AnalogOut.c @@ -63,7 +63,7 @@ void common_hal_analogio_analogout_construct(analogio_analogout_obj_t *self, } if (self->dac == NULL) { - mp_raise_ValueError(translate("DAC Device Init Error")); + mp_raise_ValueError(MP_ERROR_TEXT("DAC Device Init Error")); } // Use default settings diff --git a/ports/silabs/common-hal/busio/I2C.c b/ports/silabs/common-hal/busio/I2C.c index cedd7371c1..4875501f7b 100644 --- a/ports/silabs/common-hal/busio/I2C.c +++ b/ports/silabs/common-hal/busio/I2C.c @@ -71,7 +71,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, common_hal_mcu_pin_claim(sda); in_used = true; } else { - mp_raise_ValueError(translate("Hardware in use, try alternative pins")); + mp_raise_ValueError(MP_ERROR_TEXT("Hardware in use, try alternative pins")); } } else { raise_ValueError_invalid_pins(); diff --git a/ports/silabs/common-hal/busio/SPI.c b/ports/silabs/common-hal/busio/SPI.c index e3b743309e..ff41b89054 100644 --- a/ports/silabs/common-hal/busio/SPI.c +++ b/ports/silabs/common-hal/busio/SPI.c @@ -58,7 +58,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, if (half_duplex) { mp_raise_NotImplementedError( - translate("Half duplex SPI is not implemented")); + MP_ERROR_TEXT("Half duplex SPI is not implemented")); } if ((sck != NULL) && (mosi != NULL) && (miso != NULL)) { @@ -91,10 +91,10 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, sc = SPIDRV_Init(self->handle, &spidrv_eusart_init); if (sc != ECODE_EMDRV_SPIDRV_OK) { - mp_raise_ValueError(translate("SPI init error")); + mp_raise_ValueError(MP_ERROR_TEXT("SPI init error")); } } else { - mp_raise_ValueError(translate("Hardware in use, try alternative pins")); + mp_raise_ValueError(MP_ERROR_TEXT("Hardware in use, try alternative pins")); } } else { raise_ValueError_invalid_pins(); @@ -128,7 +128,7 @@ void common_hal_busio_spi_deinit(busio_spi_obj_t *self) { Ecode_t sc = SPIDRV_DeInit(self->handle); if (sc != ECODE_EMDRV_SPIDRV_OK) { - mp_raise_RuntimeError(translate("SPI re-init")); + mp_raise_RuntimeError(MP_ERROR_TEXT("SPI re-init")); } in_used = false; @@ -156,7 +156,7 @@ bool common_hal_busio_spi_configure(busio_spi_obj_t *self, sc = SPIDRV_DeInit(self->handle); if (sc != ECODE_EMDRV_SPIDRV_OK) { - mp_raise_RuntimeError(translate("SPI re-init")); + mp_raise_RuntimeError(MP_ERROR_TEXT("SPI re-init")); } in_used = false; self->baudrate = baudrate; @@ -178,7 +178,7 @@ bool common_hal_busio_spi_configure(busio_spi_obj_t *self, sc = SPIDRV_Init(self->handle, &spidrv_eusart_init); if (sc != ECODE_EMDRV_SPIDRV_OK) { - mp_raise_RuntimeError(translate("SPI re-init")); + mp_raise_RuntimeError(MP_ERROR_TEXT("SPI re-init")); } in_used = true; return true; diff --git a/ports/silabs/common-hal/busio/UART.c b/ports/silabs/common-hal/busio/UART.c index 37273769ba..8a598cfb90 100644 --- a/ports/silabs/common-hal/busio/UART.c +++ b/ports/silabs/common-hal/busio/UART.c @@ -53,7 +53,7 @@ volatile Ecode_t errflag; // Used to restart read halts void uart_reset(void) { if ((!never_reset) && in_used) { if (UARTDRV_DeInit(&uartdrv_usart_handle) != ECODE_EMDRV_UARTDRV_OK) { - mp_raise_ValueError(translate("UART Deinit fail")); + mp_raise_ValueError(MP_ERROR_TEXT("UART Deinit fail")); } in_used = false; } @@ -78,7 +78,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, if ((rts != NULL) || (cts != NULL) || (rs485_dir != NULL) || (rs485_invert == true)) { - mp_raise_NotImplementedError(translate("RS485")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("RS485")); } if ((tx != NULL) && (rx != NULL)) { @@ -112,7 +112,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, if (UARTDRV_InitUart(self->handle, &uartdrv_usart_init) != ECODE_EMDRV_UARTDRV_OK) { - mp_raise_RuntimeError(translate("UART init")); + mp_raise_RuntimeError(MP_ERROR_TEXT("UART init")); } common_hal_mcu_pin_claim(tx); common_hal_mcu_pin_claim(rx); @@ -130,7 +130,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, context = self; } else { - mp_raise_ValueError(translate("Hardware in use, try alternative pins")); + mp_raise_ValueError(MP_ERROR_TEXT("Hardware in use, try alternative pins")); } } else { @@ -158,7 +158,7 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { } if (UARTDRV_DeInit(self->handle) != ECODE_EMDRV_UARTDRV_OK) { - mp_raise_RuntimeError(translate("UART de-init")); + mp_raise_RuntimeError(MP_ERROR_TEXT("UART de-init")); } common_hal_reset_pin(self->rx); @@ -241,7 +241,7 @@ size_t common_hal_busio_uart_write(busio_uart_obj_t *self, Ecode_t ret = UARTDRV_TransmitB(self->handle, (uint8_t *)data, len); if (ret != ECODE_EMDRV_UARTDRV_OK) { - mp_raise_RuntimeError(translate("UART write")); + mp_raise_RuntimeError(MP_ERROR_TEXT("UART write")); } return len; } @@ -262,7 +262,7 @@ void common_hal_busio_uart_set_baudrate(busio_uart_obj_t *self, uartdrv_usart_init.baudRate = baudrate; if (UARTDRV_InitUart(self->handle, &uartdrv_usart_init) != ECODE_EMDRV_UARTDRV_OK) { - mp_raise_RuntimeError(translate("UART re-init")); + mp_raise_RuntimeError(MP_ERROR_TEXT("UART re-init")); } } diff --git a/ports/silabs/common-hal/nvm/ByteArray.c b/ports/silabs/common-hal/nvm/ByteArray.c index acdc7f131b..e8b56f7c72 100644 --- a/ports/silabs/common-hal/nvm/ByteArray.c +++ b/ports/silabs/common-hal/nvm/ByteArray.c @@ -73,7 +73,7 @@ bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self, err = nvm3_read(self); if (err != ECODE_NVM3_OK) { - mp_raise_RuntimeError(translate("NVM3 read false")); + mp_raise_RuntimeError(MP_ERROR_TEXT("NVM3 read false")); } // Set bytes in buffer memmove(nvm_array + start_index, values, len); @@ -82,7 +82,7 @@ bool common_hal_nvm_bytearray_set_bytes(nvm_bytearray_obj_t *self, NVM_BYTEARRAY_BUFFER_SIZE); if (err != ECODE_NVM3_OK) { - mp_raise_RuntimeError(translate("NVM3 write false")); + mp_raise_RuntimeError(MP_ERROR_TEXT("NVM3 write false")); } return true; diff --git a/ports/silabs/common-hal/rtc/RTC.c b/ports/silabs/common-hal/rtc/RTC.c index 956412c7b6..1a0070a65f 100644 --- a/ports/silabs/common-hal/rtc/RTC.c +++ b/ports/silabs/common-hal/rtc/RTC.c @@ -73,5 +73,5 @@ int common_hal_rtc_get_calibration(void) { } void common_hal_rtc_set_calibration(int calibration) { - mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_calibration); + mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_calibration); } diff --git a/ports/silabs/common-hal/watchdog/WatchDogTimer.c b/ports/silabs/common-hal/watchdog/WatchDogTimer.c index 21b6cc6126..97d9dcfc31 100644 --- a/ports/silabs/common-hal/watchdog/WatchDogTimer.c +++ b/ports/silabs/common-hal/watchdog/WatchDogTimer.c @@ -93,7 +93,7 @@ void common_hal_watchdog_set_timeout(watchdog_watchdogtimer_obj_t *self, break; default: mp_raise_ValueError( - translate("Timeout value supported: 1,2,4,8,16,32,64,128,256")); + MP_ERROR_TEXT("Timeout value supported: 1,2,4,8,16,32,64,128,256")); } @@ -125,7 +125,7 @@ void common_hal_watchdog_set_mode(watchdog_watchdogtimer_obj_t *self, if (self->mode != new_mode) { if (new_mode == WATCHDOGMODE_RAISE) { mp_raise_NotImplementedError( - translate("RAISE mode is not implemented")); + MP_ERROR_TEXT("RAISE mode is not implemented")); } else if (new_mode == WATCHDOGMODE_NONE) { self->mode = WATCHDOGMODE_NONE; common_hal_watchdog_deinit(self); diff --git a/ports/silabs/supervisor/serial.c b/ports/silabs/supervisor/serial.c index 01aaa49835..62dc9899d8 100644 --- a/ports/silabs/supervisor/serial.c +++ b/ports/silabs/supervisor/serial.c @@ -59,7 +59,7 @@ void EUSART0_RX_IRQHandler(void) { received_data = EUSART0->RXDATA; if (1 != ringbuf_put_n(&con_uart_rx_ringbuf, (uint8_t *)&received_data, 1)) { - mp_raise_OverflowError_varg(translate("Console UART RX buffer overflow")); + mp_raise_OverflowError_varg(MP_ERROR_TEXT("Console UART RX buffer overflow")); } CORE_EXIT_ATOMIC(); diff --git a/ports/stm/common-hal/alarm/__init__.c b/ports/stm/common-hal/alarm/__init__.c index 3d5f43a91a..68999e9dea 100644 --- a/ports/stm/common-hal/alarm/__init__.c +++ b/ports/stm/common-hal/alarm/__init__.c @@ -150,7 +150,7 @@ mp_obj_t common_hal_alarm_light_sleep_until_alarms(size_t n_alarms, const mp_obj void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *alarms, size_t n_dios, digitalio_digitalinout_obj_t **preserve_dios) { if (n_dios > 0) { - mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_preserve_dios); + mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_preserve_dios); } _setup_sleep_alarms(true, n_alarms, alarms); } diff --git a/ports/stm/common-hal/alarm/pin/PinAlarm.c b/ports/stm/common-hal/alarm/pin/PinAlarm.c index fe1f595f88..63ee2d4598 100644 --- a/ports/stm/common-hal/alarm/pin/PinAlarm.c +++ b/ports/stm/common-hal/alarm/pin/PinAlarm.c @@ -45,10 +45,10 @@ STATIC void pin_alarm_callback(uint8_t num) { void common_hal_alarm_pin_pinalarm_construct(alarm_pin_pinalarm_obj_t *self, const mcu_pin_obj_t *pin, bool value, bool edge, bool pull) { if (!edge) { - mp_raise_NotImplementedError(translate("Only edge detection is available on this hardware")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("Only edge detection is available on this hardware")); } if (!stm_peripherals_exti_is_free(pin->number)) { - mp_raise_RuntimeError(translate("Pin interrupt already in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Pin interrupt already in use")); } GPIO_InitTypeDef GPIO_InitStruct = {0}; GPIO_InitStruct.Pin = pin_mask(pin->number); @@ -132,11 +132,11 @@ void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ob // Deep sleep only wakes on a rising edge from one pin, WKUP (PA00) // All pin settings are handled automatically. if (alarm->pin != &pin_PA00) { - mp_raise_ValueError(translate("Pin cannot wake from Deep Sleep")); + mp_raise_ValueError(MP_ERROR_TEXT("Pin cannot wake from Deep Sleep")); } if (alarm->value == false || alarm->pull == false) { // Enabling WakeUp automatically sets this, but warn anyway to set expectations - mp_raise_ValueError(translate("Deep sleep pins must use a rising edge with pulldown")); + mp_raise_ValueError(MP_ERROR_TEXT("Deep sleep pins must use a rising edge with pulldown")); } // We can't actually turn WakeUp on here, since enabling it disables EXTI, // so we put it off until right before sleeping. @@ -145,7 +145,7 @@ void alarm_pin_pinalarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ob stm_peripherals_exti_never_reset(alarm->pin->number); } if (!stm_peripherals_exti_reserve(alarm->pin->number)) { - mp_raise_RuntimeError(translate("Pin interrupt already in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Pin interrupt already in use")); } stm_peripherals_exti_set_callback(pin_alarm_callback, alarm->pin->number); stm_peripherals_exti_enable(alarm->pin->number); diff --git a/ports/stm/common-hal/alarm/time/TimeAlarm.c b/ports/stm/common-hal/alarm/time/TimeAlarm.c index e53b8160da..012debedf9 100644 --- a/ports/stm/common-hal/alarm/time/TimeAlarm.c +++ b/ports/stm/common-hal/alarm/time/TimeAlarm.c @@ -85,7 +85,7 @@ void alarm_time_timealarm_set_alarms(bool deep_sleep, size_t n_alarms, const mp_ continue; } if (timealarm_set) { - mp_raise_ValueError(translate("Only one alarm.time alarm can be set")); + mp_raise_ValueError(MP_ERROR_TEXT("Only one alarm.time alarm can be set")); } timealarm = MP_OBJ_TO_PTR(alarms[i]); timealarm_set = true; diff --git a/ports/stm/common-hal/alarm/touch/TouchAlarm.c b/ports/stm/common-hal/alarm/touch/TouchAlarm.c index 88c73726ee..ea3437ec89 100644 --- a/ports/stm/common-hal/alarm/touch/TouchAlarm.c +++ b/ports/stm/common-hal/alarm/touch/TouchAlarm.c @@ -28,5 +28,5 @@ #include "shared-bindings/microcontroller/__init__.h" void common_hal_alarm_touch_touchalarm_construct(alarm_touch_touchalarm_obj_t *self, const mcu_pin_obj_t *pin) { - mp_raise_NotImplementedError(translate("Touch alarms not available")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("Touch alarms not available")); } diff --git a/ports/stm/common-hal/analogio/AnalogIn.c b/ports/stm/common-hal/analogio/AnalogIn.c index ccf11f96bf..494fe29975 100644 --- a/ports/stm/common-hal/analogio/AnalogIn.c +++ b/ports/stm/common-hal/analogio/AnalogIn.c @@ -64,7 +64,7 @@ void common_hal_analogio_analogin_construct(analogio_analogin_obj_t *self, LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_ADC3); #endif } else { - mp_raise_RuntimeError(translate("Invalid ADC Unit value")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Invalid ADC Unit value")); } common_hal_mcu_pin_claim(pin); self->pin = pin; @@ -146,7 +146,7 @@ uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) { ADCx = ADC3; #endif } else { - mp_raise_RuntimeError(translate("Invalid ADC Unit value")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Invalid ADC Unit value")); } LL_GPIO_SetPinMode(pin_port(self->pin->port), (uint32_t)pin_mask(self->pin->number), LL_GPIO_MODE_ANALOG); diff --git a/ports/stm/common-hal/analogio/AnalogOut.c b/ports/stm/common-hal/analogio/AnalogOut.c index 23b8631c94..58f572aa8a 100644 --- a/ports/stm/common-hal/analogio/AnalogOut.c +++ b/ports/stm/common-hal/analogio/AnalogOut.c @@ -58,7 +58,7 @@ STATIC bool dac_on[2]; void common_hal_analogio_analogout_construct(analogio_analogout_obj_t *self, const mcu_pin_obj_t *pin) { #if !(HAS_DAC) - mp_raise_ValueError(translate("No DAC on chip")); + mp_raise_ValueError(MP_ERROR_TEXT("No DAC on chip")); #else if (pin == &pin_PA04) { self->channel = DAC_CHANNEL_1; @@ -75,7 +75,7 @@ void common_hal_analogio_analogout_construct(analogio_analogout_obj_t *self, __HAL_RCC_DAC_CLK_ENABLE(); handle.Instance = DAC; if (HAL_DAC_Init(&handle) != HAL_OK) { - mp_raise_ValueError(translate("DAC Device Init Error")); + mp_raise_ValueError(MP_ERROR_TEXT("DAC Device Init Error")); } } @@ -89,7 +89,7 @@ void common_hal_analogio_analogout_construct(analogio_analogout_obj_t *self, self->ch_handle.DAC_Trigger = DAC_TRIGGER_NONE; self->ch_handle.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE; if (HAL_DAC_ConfigChannel(&handle, &self->ch_handle, self->channel) != HAL_OK) { - mp_raise_ValueError(translate("DAC Channel Init Error")); + mp_raise_ValueError(MP_ERROR_TEXT("DAC Channel Init Error")); } dac_on[self->dac_index] = true; diff --git a/ports/stm/common-hal/audiobusio/PDMIn.c b/ports/stm/common-hal/audiobusio/PDMIn.c index 5deb785371..c29760ff5d 100644 --- a/ports/stm/common-hal/audiobusio/PDMIn.c +++ b/ports/stm/common-hal/audiobusio/PDMIn.c @@ -55,16 +55,16 @@ void common_hal_audiobusio_pdmin_construct(audiobusio_pdmin_obj_t *self, if (!mono) { - mp_raise_ValueError(translate("only mono is supported")); + mp_raise_ValueError(MP_ERROR_TEXT("only mono is supported")); } if (sample_rate != 16000) { - mp_raise_ValueError(translate("only sample_rate=16000 is supported")); + mp_raise_ValueError(MP_ERROR_TEXT("only sample_rate=16000 is supported")); } if (bit_depth != 16) { - mp_raise_ValueError(translate("only bit_depth=16 is supported")); + mp_raise_ValueError(MP_ERROR_TEXT("only bit_depth=16 is supported")); } if (oversample != 64) { - mp_raise_ValueError(translate("only oversample=64 is supported")); + mp_raise_ValueError(MP_ERROR_TEXT("only oversample=64 is supported")); } // wait for the previous instance to finish. diff --git a/ports/stm/common-hal/audiopwmio/PWMAudioOut.c b/ports/stm/common-hal/audiopwmio/PWMAudioOut.c index 00a1bce488..e96c2a9968 100644 --- a/ports/stm/common-hal/audiopwmio/PWMAudioOut.c +++ b/ports/stm/common-hal/audiopwmio/PWMAudioOut.c @@ -261,7 +261,7 @@ void common_hal_audiopwmio_pwmaudioout_deinit(audiopwmio_pwmaudioout_obj_t *self void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t *self, mp_obj_t sample, bool loop) { common_hal_audiopwmio_pwmaudioout_stop(self); if (active_audio) { - mp_raise_RuntimeError(translate("Another PWMAudioOut is already active")); // TODO + mp_raise_RuntimeError(MP_ERROR_TEXT("Another PWMAudioOut is already active")); // TODO } self->sample = sample; self->loop = loop; @@ -281,7 +281,7 @@ void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t *self, free_buffers(self); if (max_buffer_length > UINT16_MAX) { - mp_raise_ValueError_varg(translate("Buffer length %d too big. It must be less than %d"), max_buffer_length, UINT16_MAX); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Buffer length %d too big. It must be less than %d"), max_buffer_length, UINT16_MAX); } uint16_t buffer_length = (uint16_t)max_buffer_length / self->bytes_per_sample; self->buffer[0] = m_malloc(buffer_length * sizeof(uint16_t)); @@ -298,7 +298,7 @@ void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t *self, self->stopping = false; self->paused = false; if (!fill_buffers(self)) { - mp_raise_RuntimeError(translate("Failed to buffer the sample")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Failed to buffer the sample")); } // Calculate period (TODO: supersample to 1 MHz?) diff --git a/ports/stm/common-hal/busio/I2C.c b/ports/stm/common-hal/busio/I2C.c index 7c3a0d59ad..1bfad8700d 100644 --- a/ports/stm/common-hal/busio/I2C.c +++ b/ports/stm/common-hal/busio/I2C.c @@ -116,7 +116,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, I2Cx = mcu_i2c_banks[self->sda->periph_index - 1]; } else { if (i2c_taken) { - mp_raise_ValueError(translate("Hardware in use, try alternative pins")); + mp_raise_ValueError(MP_ERROR_TEXT("Hardware in use, try alternative pins")); } else { raise_ValueError_invalid_pins(); } @@ -169,7 +169,7 @@ void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, self->handle.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE; self->handle.State = HAL_I2C_STATE_RESET; if (HAL_I2C_Init(&(self->handle)) != HAL_OK) { - mp_raise_RuntimeError(translate("I2C init error")); + mp_raise_RuntimeError(MP_ERROR_TEXT("I2C init error")); } common_hal_mcu_pin_claim(sda); common_hal_mcu_pin_claim(scl); diff --git a/ports/stm/common-hal/busio/SPI.c b/ports/stm/common-hal/busio/SPI.c index d4975e9fc5..aef04c15ad 100644 --- a/ports/stm/common-hal/busio/SPI.c +++ b/ports/stm/common-hal/busio/SPI.c @@ -159,7 +159,7 @@ STATIC int check_pins(busio_spi_obj_t *self, } if (spi_taken) { - mp_raise_ValueError(translate("Hardware in use, try alternative pins")); + mp_raise_ValueError(MP_ERROR_TEXT("Hardware in use, try alternative pins")); } else { raise_ValueError_invalid_pin(); } @@ -224,7 +224,7 @@ void common_hal_busio_spi_construct(busio_spi_obj_t *self, self->handle.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; self->handle.Init.CRCPolynomial = 10; if (HAL_SPI_Init(&self->handle) != HAL_OK) { - mp_raise_ValueError(translate("SPI init error")); + mp_raise_ValueError(MP_ERROR_TEXT("SPI init error")); } self->baudrate = default_baudrate; // self->prescaler = 16; // Initialised above by stm32_baud_to_spi_div @@ -306,7 +306,7 @@ bool common_hal_busio_spi_configure(busio_spi_obj_t *self, get_busclock(self->handle.Instance)); if (HAL_SPI_Init(&self->handle) != HAL_OK) { - mp_raise_RuntimeError(translate("SPI re-init")); + mp_raise_RuntimeError(MP_ERROR_TEXT("SPI re-init")); } self->baudrate = baudrate; @@ -346,7 +346,7 @@ void common_hal_busio_spi_unlock(busio_spi_obj_t *self) { bool common_hal_busio_spi_write(busio_spi_obj_t *self, const uint8_t *data, size_t len) { if (self->mosi == NULL) { - mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_mosi); + mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_mosi); } HAL_StatusTypeDef result = HAL_SPI_Transmit(&self->handle, (uint8_t *)data, (uint16_t)len, HAL_MAX_DELAY); return result == HAL_OK; @@ -355,9 +355,9 @@ bool common_hal_busio_spi_write(busio_spi_obj_t *self, bool common_hal_busio_spi_read(busio_spi_obj_t *self, uint8_t *data, size_t len, uint8_t write_value) { if (self->miso == NULL && !self->half_duplex) { - mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_miso); + mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_miso); } else if (self->half_duplex && self->mosi == NULL) { - mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_mosi); + mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_mosi); } HAL_StatusTypeDef result = HAL_OK; if ((!self->half_duplex && self->mosi == NULL) || (self->half_duplex && self->mosi != NULL && self->miso == NULL)) { @@ -372,10 +372,10 @@ bool common_hal_busio_spi_read(busio_spi_obj_t *self, bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, const uint8_t *data_out, uint8_t *data_in, size_t len) { if (self->mosi == NULL && data_out != NULL) { - mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_mosi); + mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_mosi); } if (self->miso == NULL && data_in != NULL) { - mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_miso); + mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_miso); } HAL_StatusTypeDef result = HAL_SPI_TransmitReceive(&self->handle, (uint8_t *)data_out, data_in, (uint16_t)len, HAL_MAX_DELAY); diff --git a/ports/stm/common-hal/busio/UART.c b/ports/stm/common-hal/busio/UART.c index 7635c4aaf3..3075d9550f 100644 --- a/ports/stm/common-hal/busio/UART.c +++ b/ports/stm/common-hal/busio/UART.c @@ -55,7 +55,7 @@ STATIC USART_TypeDef *assign_uart_or_throw(busio_uart_obj_t *self, bool pin_eval return mcu_uart_banks[periph_index]; } else { if (uart_taken) { - mp_raise_ValueError(translate("Hardware in use, try alternative pins")); + mp_raise_ValueError(MP_ERROR_TEXT("Hardware in use, try alternative pins")); } else { raise_ValueError_invalid_pin(); } @@ -92,7 +92,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, uint8_t periph_index = 0; // origin 0 corrected if ((rts != NULL) || (cts != NULL) || (rs485_dir != NULL) || (rs485_invert == true)) { - mp_raise_NotImplementedError(translate("RS485")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("RS485")); } // Can have both pins, or either @@ -167,7 +167,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, mp_arg_validate_int_range(bits, 8, 9, MP_QSTR_bits); if (USARTx == NULL) { // this can only be hit if the periph file is wrong - mp_raise_RuntimeError(translate("Internal define error")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Internal define error")); } // GPIO Init @@ -207,7 +207,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, self->handle.Init.HwFlowCtl = UART_HWCONTROL_NONE; self->handle.Init.OverSampling = UART_OVERSAMPLING_16; if (HAL_UART_Init(&self->handle) != HAL_OK) { - mp_raise_RuntimeError(translate("UART init")); + mp_raise_RuntimeError(MP_ERROR_TEXT("UART init")); } @@ -232,7 +232,7 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self, // start the interrupt series if ((HAL_UART_GetState(&self->handle) & HAL_UART_STATE_BUSY_RX) == HAL_UART_STATE_BUSY_RX) { - mp_raise_RuntimeError(translate("Could not start interrupt, RX busy")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Could not start interrupt, RX busy")); } // start the receive interrupt chain @@ -286,7 +286,7 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) { size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) { if (self->rx == NULL) { - mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_rx); + mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_rx); } uint64_t start_ticks = supervisor_ticks_ms64(); @@ -320,7 +320,7 @@ size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t // Write characters. size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) { if (self->tx == NULL) { - mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_tx); + mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_tx); } // Disable UART IRQ to avoid resource hazards in Rx IRQ handler @@ -335,7 +335,7 @@ size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, Status = HAL_UART_GetState(&self->handle); } } else { - mp_raise_RuntimeError(translate("UART write")); + mp_raise_RuntimeError(MP_ERROR_TEXT("UART write")); } return len; @@ -405,11 +405,11 @@ void common_hal_busio_uart_set_baudrate(busio_uart_obj_t *self, uint32_t baudrat // Otherwise de-init and set new rate if (HAL_UART_DeInit(&self->handle) != HAL_OK) { - mp_raise_RuntimeError(translate("UART de-init")); + mp_raise_RuntimeError(MP_ERROR_TEXT("UART de-init")); } self->handle.Init.BaudRate = baudrate; if (HAL_UART_Init(&self->handle) != HAL_OK) { - mp_raise_RuntimeError(translate("UART re-init")); + mp_raise_RuntimeError(MP_ERROR_TEXT("UART re-init")); } self->baudrate = baudrate; diff --git a/ports/stm/common-hal/canio/CAN.c b/ports/stm/common-hal/canio/CAN.c index ca857d5643..db0d1ef141 100644 --- a/ports/stm/common-hal/canio/CAN.c +++ b/ports/stm/common-hal/canio/CAN.c @@ -69,7 +69,7 @@ void common_hal_canio_can_construct(canio_can_obj_t *self, const mcu_pin_obj_t * } if (reserved_can[periph_index]) { - mp_raise_ValueError(translate("Hardware in use, try alternative pins")); + mp_raise_ValueError(MP_ERROR_TEXT("Hardware in use, try alternative pins")); } const uint32_t can_frequency = 42000000; diff --git a/ports/stm/common-hal/canio/Listener.c b/ports/stm/common-hal/canio/Listener.c index 36c138ddd2..bf31c5aca5 100644 --- a/ports/stm/common-hal/canio/Listener.c +++ b/ports/stm/common-hal/canio/Listener.c @@ -105,7 +105,7 @@ STATIC int next_filter(canio_can_obj_t *can) { return i; } } - mp_raise_msg_varg(&mp_type_RuntimeError, translate("%q"), MP_QSTR_Listener); + mp_raise_msg_varg(&mp_type_RuntimeError, MP_ERROR_TEXT("%q"), MP_QSTR_Listener); } // IDE = "extended ID" flag of packet header. We always add this bit to the @@ -232,11 +232,11 @@ void common_hal_canio_listener_construct(canio_listener_obj_t *self, canio_can_o self->rfr = &can->handle.Instance->RF1R; can->fifo1_in_use = true; } else { - mp_raise_ValueError(translate("All RX FIFOs in use")); + mp_raise_ValueError(MP_ERROR_TEXT("All RX FIFOs in use")); } if (num_filters_needed(nmatch, matches) > num_filters_available(can)) { - mp_raise_ValueError(translate("Filters too complex")); + mp_raise_ValueError(MP_ERROR_TEXT("Filters too complex")); } // Nothing can fail now so it's safe to assign self->can diff --git a/ports/stm/common-hal/microcontroller/Processor.c b/ports/stm/common-hal/microcontroller/Processor.c index e4952d8fbd..f803d3e9ef 100644 --- a/ports/stm/common-hal/microcontroller/Processor.c +++ b/ports/stm/common-hal/microcontroller/Processor.c @@ -86,7 +86,7 @@ float common_hal_mcu_processor_get_temperature(void) { HAL_ADC_Start(&AdcHandle); if (HAL_ADC_PollForConversion(&AdcHandle, 1) != HAL_OK) { - mp_raise_RuntimeError(translate("Temperature read timed out")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Temperature read timed out")); } uint32_t value = (uint32_t)HAL_ADC_GetValue(&AdcHandle); HAL_ADC_Stop(&AdcHandle); @@ -118,7 +118,7 @@ float common_hal_mcu_processor_get_voltage(void) { HAL_ADC_Start(&AdcHandle); if (HAL_ADC_PollForConversion(&AdcHandle, 1) != HAL_OK) { - mp_raise_RuntimeError(translate("Voltage read timed out")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Voltage read timed out")); } uint32_t value = (uint32_t)HAL_ADC_GetValue(&AdcHandle); HAL_ADC_Stop(&AdcHandle); diff --git a/ports/stm/common-hal/os/__init__.c b/ports/stm/common-hal/os/__init__.c index fccaa00bcd..c7dc5038b4 100644 --- a/ports/stm/common-hal/os/__init__.c +++ b/ports/stm/common-hal/os/__init__.c @@ -70,7 +70,7 @@ bool common_hal_os_urandom(uint8_t *buffer, uint32_t length) { RNG_HandleTypeDef handle; handle.Instance = RNG; if (HAL_RNG_Init(&handle) != HAL_OK) { - mp_raise_ValueError(translate("RNG Init Error")); + mp_raise_ValueError(MP_ERROR_TEXT("RNG Init Error")); } // Assign bytes @@ -83,7 +83,7 @@ bool common_hal_os_urandom(uint8_t *buffer, uint32_t length) { ; } if (HAL_RNG_GenerateRandomNumber(&handle, &new_random) != HAL_OK) { - mp_raise_ValueError(translate("Random number generation error")); + mp_raise_ValueError(MP_ERROR_TEXT("Random number generation error")); } for (int j = 0; j < 4 && i < length; j++) { buffer[i] = new_random & 0xff; @@ -94,7 +94,7 @@ bool common_hal_os_urandom(uint8_t *buffer, uint32_t length) { // shut down the peripheral if (HAL_RNG_DeInit(&handle) != HAL_OK) { - mp_raise_ValueError(translate("RNG DeInit Error")); + mp_raise_ValueError(MP_ERROR_TEXT("RNG DeInit Error")); } __HAL_RCC_RNG_CLK_DISABLE(); diff --git a/ports/stm/common-hal/pulseio/PulseIn.c b/ports/stm/common-hal/pulseio/PulseIn.c index 0754130e17..0de1f3a7c0 100644 --- a/ports/stm/common-hal/pulseio/PulseIn.c +++ b/ports/stm/common-hal/pulseio/PulseIn.c @@ -116,7 +116,7 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t *self, const mcu uint16_t maxlen, bool idle_state) { // STM32 has one shared EXTI for each pin number, 0-15 if (!stm_peripherals_exti_is_free(pin->number)) { - mp_raise_RuntimeError(translate("Pin interrupt already in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Pin interrupt already in use")); } // Allocate pulse buffer @@ -167,7 +167,7 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t *self, const mcu refcount++; if (!stm_peripherals_exti_reserve(pin->number)) { - mp_raise_RuntimeError(translate("Pin interrupt already in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Pin interrupt already in use")); } GPIO_InitTypeDef GPIO_InitStruct = {0}; GPIO_InitStruct.Pin = pin_mask(pin->number); @@ -256,7 +256,7 @@ uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t *self, int16_ } if (index < 0 || index >= self->len) { stm_peripherals_exti_enable(self->pin->number); - mp_raise_IndexError_varg(translate("%q out of range"), MP_QSTR_index); + mp_raise_IndexError_varg(MP_ERROR_TEXT("%q out of range"), MP_QSTR_index); } uint16_t value = self->buffer[(self->start + index) % self->maxlen]; stm_peripherals_exti_enable(self->pin->number); @@ -265,7 +265,7 @@ uint16_t common_hal_pulseio_pulsein_get_item(pulseio_pulsein_obj_t *self, int16_ uint16_t common_hal_pulseio_pulsein_popleft(pulseio_pulsein_obj_t *self) { if (self->len == 0) { - mp_raise_IndexError_varg(translate("pop from empty %q"), MP_QSTR_PulseIn); + mp_raise_IndexError_varg(MP_ERROR_TEXT("pop from empty %q"), MP_QSTR_PulseIn); } stm_peripherals_exti_disable(self->pin->number); uint16_t value = self->buffer[self->start]; diff --git a/ports/stm/common-hal/pulseio/PulseOut.c b/ports/stm/common-hal/pulseio/PulseOut.c index f558c8f776..53e6c50e3b 100644 --- a/ports/stm/common-hal/pulseio/PulseOut.c +++ b/ports/stm/common-hal/pulseio/PulseOut.c @@ -176,7 +176,7 @@ void common_hal_pulseio_pulseout_send(pulseio_pulseout_obj_t *self, uint16_t *pu // // Use when debugging, or issues are irrecoverable // if ((supervisor_ticks_ms64() - starttime ) > timeout ) { - // mp_raise_RuntimeError(translate("Error: Send Timeout")); + // mp_raise_RuntimeError(MP_ERROR_TEXT("Error: Send Timeout")); // } } // turn off timer counter. diff --git a/ports/stm/common-hal/pwmio/PWMOut.c b/ports/stm/common-hal/pwmio/PWMOut.c index 2bb3f1f7ab..1495cae62f 100644 --- a/ports/stm/common-hal/pwmio/PWMOut.c +++ b/ports/stm/common-hal/pwmio/PWMOut.c @@ -284,16 +284,16 @@ void common_hal_pwmio_pwmout_set_frequency(pwmio_pwmout_obj_t *self, uint32_t fr // restart everything, adjusting for new speed if (HAL_TIM_PWM_Init(&self->handle) != HAL_OK) { - mp_raise_RuntimeError(translate("timer re-init")); + mp_raise_RuntimeError(MP_ERROR_TEXT("timer re-init")); } self->chan_handle.Pulse = timer_get_internal_duty(self->duty_cycle, period); if (HAL_TIM_PWM_ConfigChannel(&self->handle, &self->chan_handle, self->channel) != HAL_OK) { - mp_raise_RuntimeError(translate("channel re-init")); + mp_raise_RuntimeError(MP_ERROR_TEXT("channel re-init")); } if (HAL_TIM_PWM_Start(&self->handle, self->channel) != HAL_OK) { - mp_raise_RuntimeError(translate("PWM restart")); + mp_raise_RuntimeError(MP_ERROR_TEXT("PWM restart")); } tim_frequencies[self->tim->tim_index] = frequency; diff --git a/ports/stm/common-hal/rtc/RTC.c b/ports/stm/common-hal/rtc/RTC.c index 2c34ab5ad6..bff574c099 100644 --- a/ports/stm/common-hal/rtc/RTC.c +++ b/ports/stm/common-hal/rtc/RTC.c @@ -45,5 +45,5 @@ int common_hal_rtc_get_calibration(void) { } void common_hal_rtc_set_calibration(int calibration) { - mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_calibration); + mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_calibration); } diff --git a/ports/stm/common-hal/sdioio/SDCard.c b/ports/stm/common-hal/sdioio/SDCard.c index a1b22a2047..1fac960978 100644 --- a/ports/stm/common-hal/sdioio/SDCard.c +++ b/ports/stm/common-hal/sdioio/SDCard.c @@ -112,7 +112,7 @@ STATIC int check_pins(sdioio_sdcard_obj_t *self, } if (sdio_taken) { - mp_raise_ValueError(translate("Hardware in use, try alternative pins")); + mp_raise_ValueError(MP_ERROR_TEXT("Hardware in use, try alternative pins")); } else { raise_ValueError_invalid_pin(); } @@ -160,13 +160,13 @@ void common_hal_sdioio_sdcard_construct(sdioio_sdcard_obj_t *self, HAL_StatusTypeDef r = HAL_SD_Init(&self->handle); if (r != HAL_OK) { - mp_raise_ValueError_varg(translate("SDIO Init Error %d"), (int)r); + mp_raise_ValueError_varg(MP_ERROR_TEXT("SDIO Init Error %d"), (int)r); } HAL_SD_CardInfoTypeDef info; r = HAL_SD_GetCardInfo(&self->handle, &info); if (r != HAL_OK) { - mp_raise_ValueError_varg(translate("SDIO GetCardInfo Error %d"), (int)r); + mp_raise_ValueError_varg(MP_ERROR_TEXT("SDIO GetCardInfo Error %d"), (int)r); } self->num_data = 1; @@ -206,7 +206,7 @@ uint8_t common_hal_sdioio_sdcard_get_width(sdioio_sdcard_obj_t *self) { STATIC void check_whole_block(mp_buffer_info_t *bufinfo) { if (bufinfo->len % 512) { - mp_raise_ValueError(translate("Buffer must be a multiple of 512 bytes")); + mp_raise_ValueError(MP_ERROR_TEXT("Buffer must be a multiple of 512 bytes")); } } diff --git a/ports/stm/peripherals/timers.c b/ports/stm/peripherals/timers.c index 47fb33c59e..085b44ccb2 100644 --- a/ports/stm/peripherals/timers.c +++ b/ports/stm/peripherals/timers.c @@ -259,7 +259,7 @@ TIM_TypeDef *stm_peripherals_find_timer(void) { return mcu_tim_banks[i]; } } - mp_raise_RuntimeError(translate("All timers in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("All timers in use")); return NULL; } diff --git a/py/makeqstrdefs.py b/py/makeqstrdefs.py index cb229f9e5c..65f429ed54 100644 --- a/py/makeqstrdefs.py +++ b/py/makeqstrdefs.py @@ -146,7 +146,7 @@ def process_file(f): ) elif args.mode == _MODE_ROOT_POINTER: re_match = re.compile(r"MP_REGISTER_ROOT_POINTER\(.*?\);") - re_translate = re.compile(r"translate\(\"((?:(?=(\\?))\2.)*?)\"\)") + re_translate = re.compile(r"MP_COMPRESSED_ROM_TEXT\(\"((?:(?=(\\?))\2.)*?)\"\)") output = [] last_fname = None for line in f: diff --git a/py/objmodule.c b/py/objmodule.c index a127449bcf..a8d91b65ad 100644 --- a/py/objmodule.c +++ b/py/objmodule.c @@ -70,24 +70,24 @@ STATIC void module_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { if (self == &displayio_module) { #if CIRCUITPY_BUSDISPLAY if (attr == MP_QSTR_Display) { - warnings_warn(&mp_type_FutureWarning, translate("%q moved from %q to %q"), MP_QSTR_Display, MP_QSTR_displayio, MP_QSTR_busdisplay); - warnings_warn(&mp_type_FutureWarning, translate("%q renamed %q"), MP_QSTR_Display, MP_QSTR_BusDisplay); + warnings_warn(&mp_type_FutureWarning, MP_ERROR_TEXT("%q moved from %q to %q"), MP_QSTR_Display, MP_QSTR_displayio, MP_QSTR_busdisplay); + warnings_warn(&mp_type_FutureWarning, MP_ERROR_TEXT("%q renamed %q"), MP_QSTR_Display, MP_QSTR_BusDisplay); } #endif #if CIRCUITPY_EPAPERDISPLAY if (attr == MP_QSTR_EPaperDisplay) { - warnings_warn(&mp_type_FutureWarning, translate("%q moved from %q to %q"), MP_QSTR_EPaperDisplay, MP_QSTR_displayio, MP_QSTR_epaperdisplay); + warnings_warn(&mp_type_FutureWarning, MP_ERROR_TEXT("%q moved from %q to %q"), MP_QSTR_EPaperDisplay, MP_QSTR_displayio, MP_QSTR_epaperdisplay); } #endif #if CIRCUITPY_FOURWIRE if (attr == MP_QSTR_FourWire) { - warnings_warn(&mp_type_FutureWarning, translate("%q moved from %q to %q"), MP_QSTR_FourWire, MP_QSTR_displayio, MP_QSTR_fourwire); + warnings_warn(&mp_type_FutureWarning, MP_ERROR_TEXT("%q moved from %q to %q"), MP_QSTR_FourWire, MP_QSTR_displayio, MP_QSTR_fourwire); } #endif #if CIRCUITPY_I2CDISPLAYBUS if (attr == MP_QSTR_I2CDisplay) { - warnings_warn(&mp_type_FutureWarning, translate("%q moved from %q to %q"), MP_QSTR_I2CDisplay, MP_QSTR_displayio, MP_QSTR_i2cdisplaybus); - warnings_warn(&mp_type_FutureWarning, translate("%q renamed %q"), MP_QSTR_I2CDisplay, MP_QSTR_I2CDisplayBus); + warnings_warn(&mp_type_FutureWarning, MP_ERROR_TEXT("%q moved from %q to %q"), MP_QSTR_I2CDisplay, MP_QSTR_displayio, MP_QSTR_i2cdisplaybus); + warnings_warn(&mp_type_FutureWarning, MP_ERROR_TEXT("%q renamed %q"), MP_QSTR_I2CDisplay, MP_QSTR_I2CDisplayBus); } #endif } @@ -205,7 +205,7 @@ STATIC const mp_module_delegation_entry_t mp_builtin_module_delegation_table[] = mp_obj_t mp_module_get_builtin(qstr module_name, bool extensible) { #if CIRCUITPY_PARALLELDISPLAYBUS && CIRCUITPY_WARNINGS if (module_name == MP_QSTR_paralleldisplay) { - warnings_warn(&mp_type_FutureWarning, translate("%q renamed %q"), MP_QSTR_paralleldisplay, MP_QSTR_paralleldisplaybus); + warnings_warn(&mp_type_FutureWarning, MP_ERROR_TEXT("%q renamed %q"), MP_QSTR_paralleldisplay, MP_QSTR_paralleldisplaybus); } #endif mp_map_elem_t *elem = mp_map_lookup((mp_map_t *)(extensible ? &mp_builtin_extensible_module_map : &mp_builtin_module_map), MP_OBJ_NEW_QSTR(module_name), MP_MAP_LOOKUP); diff --git a/py/runtime.c b/py/runtime.c index fc9ab1790e..1d9116ef38 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -1666,18 +1666,18 @@ void mp_import_all(mp_obj_t module) { #if CIRCUITPY_DISPLAYIO && CIRCUITPY_WARNINGS if (module == &displayio_module) { #if CIRCUITPY_BUSDISPLAY - warnings_warn(&mp_type_FutureWarning, translate("%q moved from %q to %q"), MP_QSTR_Display, MP_QSTR_displayio, MP_QSTR_busdisplay); - warnings_warn(&mp_type_FutureWarning, translate("%q renamed %q"), MP_QSTR_Display, MP_QSTR_BusDisplay); + warnings_warn(&mp_type_FutureWarning, MP_ERROR_TEXT("%q moved from %q to %q"), MP_QSTR_Display, MP_QSTR_displayio, MP_QSTR_busdisplay); + warnings_warn(&mp_type_FutureWarning, MP_ERROR_TEXT("%q renamed %q"), MP_QSTR_Display, MP_QSTR_BusDisplay); #endif #if CIRCUITPY_EPAPERDISPLAY - warnings_warn(&mp_type_FutureWarning, translate("%q moved from %q to %q"), MP_QSTR_EPaperDisplay, MP_QSTR_displayio, MP_QSTR_epaperdisplay); + warnings_warn(&mp_type_FutureWarning, MP_ERROR_TEXT("%q moved from %q to %q"), MP_QSTR_EPaperDisplay, MP_QSTR_displayio, MP_QSTR_epaperdisplay); #endif #if CIRCUITPY_FOURWIRE - warnings_warn(&mp_type_FutureWarning, translate("%q moved from %q to %q"), MP_QSTR_FourWire, MP_QSTR_displayio, MP_QSTR_fourwire); + warnings_warn(&mp_type_FutureWarning, MP_ERROR_TEXT("%q moved from %q to %q"), MP_QSTR_FourWire, MP_QSTR_displayio, MP_QSTR_fourwire); #endif #if CIRCUITPY_I2CDISPLAYBUS - warnings_warn(&mp_type_FutureWarning, translate("%q moved from %q to %q"), MP_QSTR_I2CDisplay, MP_QSTR_displayio, MP_QSTR_i2cdisplaybus); - warnings_warn(&mp_type_FutureWarning, translate("%q renamed %q"), MP_QSTR_I2CDisplay, MP_QSTR_I2CDisplayBus); + warnings_warn(&mp_type_FutureWarning, MP_ERROR_TEXT("%q moved from %q to %q"), MP_QSTR_I2CDisplay, MP_QSTR_displayio, MP_QSTR_i2cdisplaybus); + warnings_warn(&mp_type_FutureWarning, MP_ERROR_TEXT("%q renamed %q"), MP_QSTR_I2CDisplay, MP_QSTR_I2CDisplayBus); #endif } #endif diff --git a/shared-bindings/_bleio/Adapter.c b/shared-bindings/_bleio/Adapter.c index fcc5959491..43d146434b 100644 --- a/shared-bindings/_bleio/Adapter.c +++ b/shared-bindings/_bleio/Adapter.c @@ -106,7 +106,7 @@ STATIC mp_obj_t bleio_adapter_make_new(const mp_obj_type_t *type, size_t n_args, return MP_OBJ_FROM_PTR(self); #else - mp_raise_NotImplementedError(translate("Cannot create a new Adapter; use _bleio.adapter;")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("Cannot create a new Adapter; use _bleio.adapter;")); return mp_const_none; #endif // CIRCUITPY_BLEIO_HCI } @@ -141,7 +141,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(bleio_adapter_get_address_obj, bleio_adapter_get_addre STATIC mp_obj_t bleio_adapter_set_address(mp_obj_t self, mp_obj_t new_address) { if (!common_hal_bleio_adapter_set_address(self, new_address)) { - mp_raise_bleio_BluetoothError(translate("Could not set address")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Could not set address")); } return mp_const_none; } @@ -234,7 +234,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"), + mp_raise_ValueError_varg(MP_ERROR_TEXT("interval must be in range %s-%s"), ADV_INTERVAL_MIN_STRING, ADV_INTERVAL_MAX_STRING); } @@ -242,13 +242,13 @@ STATIC mp_obj_t bleio_adapter_start_advertising(mp_uint_t n_args, const mp_obj_t bool anonymous = args[ARG_anonymous].u_bool; uint32_t timeout = args[ARG_timeout].u_int; if (data_bufinfo.len > 31 && connectable && scan_response_bufinfo.len > 0) { - mp_raise_bleio_BluetoothError(translate("Cannot have scan responses for extended, connectable advertisements.")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Cannot have scan responses for extended, connectable advertisements.")); } const bleio_address_obj_t *address = NULL; if (args[ARG_directed_to].u_obj != mp_const_none) { if (!connectable) { - mp_raise_bleio_BluetoothError(translate("Only connectable advertisements can be directed")); + mp_raise_bleio_BluetoothError(MP_ERROR_TEXT("Only connectable advertisements can be directed")); } address = mp_arg_validate_type(args[ARG_directed_to].u_obj, &bleio_address_type, MP_QSTR_directed_to); } @@ -334,19 +334,19 @@ STATIC mp_obj_t bleio_adapter_start_scan(size_t n_args, const mp_obj_t *pos_args const mp_float_t interval = mp_obj_get_float(args[ARG_interval].u_obj); if (interval < INTERVAL_MIN || interval > INTERVAL_MAX) { - mp_raise_ValueError_varg(translate("interval must be in range %s-%s"), INTERVAL_MIN_STRING, INTERVAL_MAX_STRING); + mp_raise_ValueError_varg(MP_ERROR_TEXT("interval must be in range %s-%s"), INTERVAL_MIN_STRING, INTERVAL_MAX_STRING); } #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")); + mp_raise_ValueError(MP_ERROR_TEXT("non-zero timeout must be >= interval")); } #pragma GCC diagnostic pop const mp_float_t window = mp_obj_get_float(args[ARG_window].u_obj); if (window > interval) { - mp_raise_ValueError(translate("window must be <= interval")); + mp_raise_ValueError(MP_ERROR_TEXT("window must be <= interval")); } mp_buffer_info_t prefix_bufinfo; @@ -354,7 +354,7 @@ STATIC mp_obj_t bleio_adapter_start_scan(size_t n_args, const mp_obj_t *pos_args if (args[ARG_prefixes].u_obj != MP_OBJ_NULL) { mp_get_buffer_raise(args[ARG_prefixes].u_obj, &prefix_bufinfo, MP_BUFFER_READ); if (gc_nbytes(prefix_bufinfo.buf) == 0) { - mp_raise_ValueError(translate("Prefix buffer must be on the heap")); + mp_raise_ValueError(MP_ERROR_TEXT("Prefix buffer must be on the heap")); } } diff --git a/shared-bindings/_bleio/Address.c b/shared-bindings/_bleio/Address.c index 977d731a3e..f8c4efbbca 100644 --- a/shared-bindings/_bleio/Address.c +++ b/shared-bindings/_bleio/Address.c @@ -62,7 +62,7 @@ STATIC mp_obj_t bleio_address_make_new(const mp_obj_type_t *type, size_t n_args, mp_buffer_info_t buf_info; mp_get_buffer_raise(address, &buf_info, MP_BUFFER_READ); if (buf_info.len != NUM_BLEIO_ADDRESS_BYTES) { - mp_raise_ValueError_varg(translate("Address must be %d bytes long"), NUM_BLEIO_ADDRESS_BYTES); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Address must be %d bytes long"), NUM_BLEIO_ADDRESS_BYTES); } const mp_int_t address_type = args[ARG_address_type].u_int; diff --git a/shared-bindings/_bleio/Characteristic.c b/shared-bindings/_bleio/Characteristic.c index 1dbf7f4a08..a0e2e3dc2a 100644 --- a/shared-bindings/_bleio/Characteristic.c +++ b/shared-bindings/_bleio/Characteristic.c @@ -133,7 +133,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(MP_ERROR_TEXT("initial_value length is wrong")); } const char *user_description = NULL; diff --git a/shared-bindings/_bleio/CharacteristicBuffer.c b/shared-bindings/_bleio/CharacteristicBuffer.c index b5a35ac095..b6a56a48a7 100644 --- a/shared-bindings/_bleio/CharacteristicBuffer.c +++ b/shared-bindings/_bleio/CharacteristicBuffer.c @@ -37,7 +37,7 @@ STATIC void raise_error_if_not_connected(bleio_characteristic_buffer_obj_t *self) { if (!common_hal_bleio_characteristic_buffer_connected(self)) { - mp_raise_ConnectionError(translate("Not connected")); + mp_raise_ConnectionError(MP_ERROR_TEXT("Not connected")); } } @@ -128,7 +128,7 @@ STATIC mp_uint_t bleio_characteristic_buffer_read(mp_obj_t self_in, void *buf_in } STATIC mp_uint_t bleio_characteristic_buffer_write(mp_obj_t self_in, const void *buf_in, mp_uint_t size, int *errcode) { - mp_raise_NotImplementedError(translate("CharacteristicBuffer writing not provided")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("CharacteristicBuffer writing not provided")); return 0; } diff --git a/shared-bindings/_bleio/Connection.c b/shared-bindings/_bleio/Connection.c index 1f33749438..4330b2344a 100644 --- a/shared-bindings/_bleio/Connection.c +++ b/shared-bindings/_bleio/Connection.c @@ -63,7 +63,7 @@ void bleio_connection_ensure_connected(bleio_connection_obj_t *self) { if (!common_hal_bleio_connection_get_connected(self)) { - mp_raise_ConnectionError(translate("Connection has been disconnected and can no longer be used. Create a new connection.")); + mp_raise_ConnectionError(MP_ERROR_TEXT("Connection has been disconnected and can no longer be used. Create a new connection.")); } } diff --git a/shared-bindings/_bleio/Descriptor.c b/shared-bindings/_bleio/Descriptor.c index fd28e924e8..f91e7cb6e6 100644 --- a/shared-bindings/_bleio/Descriptor.c +++ b/shared-bindings/_bleio/Descriptor.c @@ -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(MP_ERROR_TEXT("initial_value length is wrong")); } bleio_descriptor_obj_t *descriptor = mp_obj_malloc(bleio_descriptor_obj_t, &bleio_descriptor_type); diff --git a/shared-bindings/_bleio/PacketBuffer.c b/shared-bindings/_bleio/PacketBuffer.c index fbdb5ffc2b..9cd2c37379 100644 --- a/shared-bindings/_bleio/PacketBuffer.c +++ b/shared-bindings/_bleio/PacketBuffer.c @@ -114,7 +114,7 @@ STATIC mp_obj_t bleio_packet_buffer_readinto(mp_obj_t self_in, mp_obj_t buffer_o mp_int_t size = common_hal_bleio_packet_buffer_readinto(self, bufinfo.buf, bufinfo.len); if (size < 0) { - mp_raise_ValueError_varg(translate("Buffer too short by %d bytes"), size * -1); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Buffer too short by %d bytes"), size * -1); } return MP_OBJ_NEW_SMALL_INT(size); @@ -164,7 +164,7 @@ STATIC mp_obj_t bleio_packet_buffer_write(mp_uint_t n_args, const mp_obj_t *pos_ // gatts write events, which may not have been sent yet. // // IDEAL: - // mp_raise_ConnectionError(translate("Not connected")); + // mp_raise_ConnectionError(MP_ERROR_TEXT("Not connected")); // TEMPORARY: num_bytes_written = 0; } @@ -189,7 +189,7 @@ STATIC mp_obj_t bleio_packet_buffer_get_incoming_packet_length(mp_obj_t self_in) mp_int_t size = common_hal_bleio_packet_buffer_get_incoming_packet_length(self); if (size < 0) { - mp_raise_ValueError(translate("No connection: length cannot be determined")); + mp_raise_ValueError(MP_ERROR_TEXT("No connection: length cannot be determined")); } return MP_OBJ_NEW_SMALL_INT(size); } @@ -206,7 +206,7 @@ STATIC mp_obj_t bleio_packet_buffer_get_outgoing_packet_length(mp_obj_t self_in) mp_int_t size = common_hal_bleio_packet_buffer_get_outgoing_packet_length(self); if (size < 0) { - mp_raise_ValueError(translate("No connection: length cannot be determined")); + mp_raise_ValueError(MP_ERROR_TEXT("No connection: length cannot be determined")); } return MP_OBJ_NEW_SMALL_INT(size); } diff --git a/shared-bindings/_bleio/UUID.c b/shared-bindings/_bleio/UUID.c index 5bb668553b..9025c57aa8 100644 --- a/shared-bindings/_bleio/UUID.c +++ b/shared-bindings/_bleio/UUID.c @@ -61,7 +61,7 @@ STATIC mp_obj_t bleio_uuid_make_new(const mp_obj_type_t *type, size_t n_args, si if (mp_obj_is_int(value)) { mp_int_t uuid16 = mp_obj_get_int(value); if (uuid16 < 0 || uuid16 > 0xffff) { - mp_raise_ValueError(translate("UUID integer value must be 0-0xffff")); + mp_raise_ValueError(MP_ERROR_TEXT("UUID integer value must be 0-0xffff")); } // NULL means no 128-bit value. @@ -86,7 +86,7 @@ STATIC mp_obj_t bleio_uuid_make_new(const mp_obj_type_t *type, size_t n_args, si good_uuid = hex_idx == 32; } if (!good_uuid) { - mp_raise_ValueError(translate("UUID string not 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'")); + mp_raise_ValueError(MP_ERROR_TEXT("UUID string not 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'")); } size_t hex_idx = 0; @@ -98,11 +98,11 @@ STATIC mp_obj_t bleio_uuid_make_new(const mp_obj_type_t *type, size_t n_args, si // Last possibility is that it's a buf. mp_buffer_info_t bufinfo; if (!mp_get_buffer(value, &bufinfo, MP_BUFFER_READ)) { - mp_raise_ValueError(translate("UUID value is not str, int or byte buffer")); + mp_raise_ValueError(MP_ERROR_TEXT("UUID value is not str, int or byte buffer")); } if (bufinfo.len != 16) { - mp_raise_ValueError(translate("Byte buffer must be 16 bytes.")); + mp_raise_ValueError(MP_ERROR_TEXT("Byte buffer must be 16 bytes.")); } memcpy(uuid128, bufinfo.buf, 16); @@ -142,7 +142,7 @@ STATIC mp_obj_t bleio_uuid_get_uuid128(mp_obj_t self_in) { uint8_t uuid128[16]; if (common_hal_bleio_uuid_get_size(self) != 128) { - mp_raise_AttributeError(translate("not a 128-bit UUID")); + mp_raise_AttributeError(MP_ERROR_TEXT("not a 128-bit UUID")); } common_hal_bleio_uuid_get_uuid128(self, uuid128); return mp_obj_new_bytes(uuid128, 16); @@ -190,7 +190,7 @@ STATIC mp_obj_t bleio_uuid_pack_into(mp_uint_t n_args, const mp_obj_t *pos_args, size_t offset = args[ARG_offset].u_int; if (offset + common_hal_bleio_uuid_get_size(self) / 8 > bufinfo.len) { - mp_raise_ValueError(translate("Buffer + offset too small %d %d %d")); + mp_raise_ValueError(MP_ERROR_TEXT("Buffer + offset too small %d %d %d")); } common_hal_bleio_uuid_pack_into(self, bufinfo.buf + offset); diff --git a/shared-bindings/_bleio/__init__.c b/shared-bindings/_bleio/__init__.c index f754f569a3..157a633a51 100644 --- a/shared-bindings/_bleio/__init__.c +++ b/shared-bindings/_bleio/__init__.c @@ -131,7 +131,7 @@ mp_obj_t bleio_set_adapter(mp_obj_t adapter_obj) { elem->value = adapter_obj; } #else - mp_raise_NotImplementedError(translate("Read-only")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("Read-only")); #endif return mp_const_none; } diff --git a/shared-bindings/_pew/PewPew.c b/shared-bindings/_pew/PewPew.c index 5309baa0e2..94142aa132 100644 --- a/shared-bindings/_pew/PewPew.c +++ b/shared-bindings/_pew/PewPew.c @@ -85,7 +85,7 @@ STATIC mp_obj_t pewpew_make_new(const mp_obj_type_t *type, size_t n_args, size_t mp_obj_get_array(args[ARG_cols].u_obj, &cols_size, &cols); if (bufinfo.len != rows_size * cols_size) { - mp_raise_ValueError(translate("Incorrect buffer size")); + mp_raise_ValueError(MP_ERROR_TEXT("Incorrect buffer size")); } for (size_t i = 0; i < rows_size; ++i) { diff --git a/shared-bindings/_pixelmap/PixelMap.c b/shared-bindings/_pixelmap/PixelMap.c index 6297ef38f4..d61bd7bf43 100644 --- a/shared-bindings/_pixelmap/PixelMap.c +++ b/shared-bindings/_pixelmap/PixelMap.c @@ -78,12 +78,12 @@ STATIC mp_obj_t pixelmap_pixelmap_make_new(const mp_obj_type_t *type, size_t n_a for (size_t j = 0; j < len1; j++) { mp_obj_t item1 = items1[j]; if (!mp_obj_is_small_int(item1)) { - mp_raise_TypeError(translate("nested index must be int")); + mp_raise_TypeError(MP_ERROR_TEXT("nested index must be int")); } mp_arg_validate_index_range(MP_OBJ_SMALL_INT_VALUE(item1), 0, buflen - 1, MP_QSTR_index); } } else { - mp_raise_TypeError(translate("index must be tuple or int")); + mp_raise_TypeError(MP_ERROR_TEXT("index must be tuple or int")); } } diff --git a/shared-bindings/_stage/Layer.c b/shared-bindings/_stage/Layer.c index d2780ac352..b1493230eb 100644 --- a/shared-bindings/_stage/Layer.c +++ b/shared-bindings/_stage/Layer.c @@ -70,20 +70,20 @@ STATIC mp_obj_t layer_make_new(const mp_obj_type_t *type, size_t n_args, mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_READ); self->graphic = bufinfo.buf; if (bufinfo.len != 2048) { - mp_raise_ValueError(translate("graphic must be 2048 bytes long")); + mp_raise_ValueError(MP_ERROR_TEXT("graphic must be 2048 bytes long")); } mp_get_buffer_raise(args[3], &bufinfo, MP_BUFFER_READ); self->palette = bufinfo.buf; if (bufinfo.len != 32) { - mp_raise_ValueError(translate("palette must be 32 bytes long")); + mp_raise_ValueError(MP_ERROR_TEXT("palette must be 32 bytes long")); } if (n_args > 4) { mp_get_buffer_raise(args[4], &bufinfo, MP_BUFFER_READ); self->map = bufinfo.buf; if (bufinfo.len < (self->width * self->height) / 2) { - mp_raise_ValueError(translate("map buffer too small")); + mp_raise_ValueError(MP_ERROR_TEXT("map buffer too small")); } } else { self->map = NULL; diff --git a/shared-bindings/_stage/Text.c b/shared-bindings/_stage/Text.c index 1b003d93f7..f94902e6cc 100644 --- a/shared-bindings/_stage/Text.c +++ b/shared-bindings/_stage/Text.c @@ -68,19 +68,19 @@ STATIC mp_obj_t text_make_new(const mp_obj_type_t *type, size_t n_args, mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_READ); self->font = bufinfo.buf; if (bufinfo.len != 2048) { - mp_raise_ValueError(translate("font must be 2048 bytes long")); + mp_raise_ValueError(MP_ERROR_TEXT("font must be 2048 bytes long")); } mp_get_buffer_raise(args[3], &bufinfo, MP_BUFFER_READ); self->palette = bufinfo.buf; if (bufinfo.len != 32) { - mp_raise_ValueError(translate("palette must be 32 bytes long")); + mp_raise_ValueError(MP_ERROR_TEXT("palette must be 32 bytes long")); } mp_get_buffer_raise(args[4], &bufinfo, MP_BUFFER_READ); self->chars = bufinfo.buf; if (bufinfo.len < self->width * self->height) { - mp_raise_ValueError(translate("chars buffer too small")); + mp_raise_ValueError(MP_ERROR_TEXT("chars buffer too small")); } return MP_OBJ_FROM_PTR(self); diff --git a/shared-bindings/_stage/__init__.c b/shared-bindings/_stage/__init__.c index c5b139323d..82f8e11808 100644 --- a/shared-bindings/_stage/__init__.c +++ b/shared-bindings/_stage/__init__.c @@ -88,7 +88,7 @@ STATIC mp_obj_t stage_render(size_t n_args, const mp_obj_t *args) { mp_obj_t native_display = mp_obj_cast_to_native_base(args[6], &busdisplay_busdisplay_type); if (!mp_obj_is_type(native_display, &busdisplay_busdisplay_type)) { - mp_raise_TypeError(translate("argument num/types mismatch")); + mp_raise_TypeError(MP_ERROR_TEXT("argument num/types mismatch")); } busdisplay_busdisplay_obj_t *display = MP_OBJ_TO_PTR(native_display); uint8_t scale = mp_obj_get_int(args[7]); diff --git a/shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c b/shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c index 34b2c0e25b..07cc6c60a4 100644 --- a/shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c +++ b/shared-bindings/adafruit_bus_device/spi_device/SPIDevice.c @@ -104,7 +104,7 @@ STATIC mp_obj_t adafruit_bus_device_spidevice_make_new(const mp_obj_type_t *type true, DRIVE_MODE_PUSH_PULL); #if CIRCUITPY_DIGITALIO_HAVE_INPUT_ONLY if (result == DIGITALINOUT_INPUT_ONLY) { - mp_raise_NotImplementedError(translate("Pin is input only")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("Pin is input only")); } #else (void)result; diff --git a/shared-bindings/adafruit_pixelbuf/PixelBuf.c b/shared-bindings/adafruit_pixelbuf/PixelBuf.c index a7970366a5..44eebb5c22 100644 --- a/shared-bindings/adafruit_pixelbuf/PixelBuf.c +++ b/shared-bindings/adafruit_pixelbuf/PixelBuf.c @@ -333,7 +333,7 @@ STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp size_t num_items = mp_obj_get_int(mp_obj_len(value)); if (num_items != slice_len && num_items != (slice_len * common_hal_adafruit_pixelbuf_pixelbuf_get_bpp(self_in))) { - mp_raise_ValueError_varg(translate("Unmatched number of items on RHS (expected %d, got %d)."), slice_len, num_items); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Unmatched number of items on RHS (expected %d, got %d)."), slice_len, num_items); } common_hal_adafruit_pixelbuf_pixelbuf_set_pixels(self_in, slice.start, slice.step, slice_len, value, num_items != slice_len ? &flat_item_tuple : mp_const_none); diff --git a/shared-bindings/aesio/aes.c b/shared-bindings/aesio/aes.c index 3d8758346d..04ed4c0d9e 100644 --- a/shared-bindings/aesio/aes.c +++ b/shared-bindings/aesio/aes.c @@ -68,7 +68,7 @@ STATIC mp_obj_t aesio_aes_make_new(const mp_obj_type_t *type, size_t n_args, uint32_t key_length = 0; mp_get_buffer_raise(args[ARG_key].u_obj, &bufinfo, MP_BUFFER_READ); if ((bufinfo.len != 16) && (bufinfo.len != 24) && (bufinfo.len != 32)) { - mp_raise_ValueError(translate("Key must be 16, 24, or 32 bytes long")); + mp_raise_ValueError(MP_ERROR_TEXT("Key must be 16, 24, or 32 bytes long")); } key = bufinfo.buf; key_length = bufinfo.len; @@ -80,7 +80,7 @@ STATIC mp_obj_t aesio_aes_make_new(const mp_obj_type_t *type, size_t n_args, case AES_MODE_CTR: break; default: - mp_raise_NotImplementedError(translate("Requested AES mode is unsupported")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("Requested AES mode is unsupported")); } // IV is required for CBC mode and is ignored for other modes. @@ -125,7 +125,7 @@ STATIC mp_obj_t aesio_aes_rekey(size_t n_args, const mp_obj_t *pos_args, mp_map_ size_t key_length = bufinfo.len; if ((key_length != 16) && (key_length != 24) && (key_length != 32)) { - mp_raise_ValueError(translate("Key must be 16, 24, or 32 bytes long")); + mp_raise_ValueError(MP_ERROR_TEXT("Key must be 16, 24, or 32 bytes long")); } const uint8_t *iv = NULL; @@ -145,18 +145,18 @@ 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")); + MP_ERROR_TEXT("Source and destination buffers must be the same length")); } switch (self->mode) { case AES_MODE_ECB: if (src_length != 16) { - mp_raise_ValueError(translate("ECB only operates on 16 bytes at a time")); + mp_raise_ValueError(MP_ERROR_TEXT("ECB only operates on 16 bytes at a time")); } break; case AES_MODE_CBC: if ((src_length & 15) != 0) { - mp_raise_ValueError(translate("CBC blocks must be multiples of 16 bytes")); + mp_raise_ValueError(MP_ERROR_TEXT("CBC blocks must be multiples of 16 bytes")); } break; case AES_MODE_CTR: @@ -227,7 +227,7 @@ STATIC mp_obj_t aesio_aes_set_mode(mp_obj_t self_in, mp_obj_t mode_obj) { case AES_MODE_CTR: break; default: - mp_raise_NotImplementedError(translate("Requested AES mode is unsupported")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("Requested AES mode is unsupported")); } common_hal_aesio_aes_set_mode(self, mode); diff --git a/shared-bindings/alarm/SleepMemory.c b/shared-bindings/alarm/SleepMemory.c index ab4659629a..0d2212fbc5 100644 --- a/shared-bindings/alarm/SleepMemory.c +++ b/shared-bindings/alarm/SleepMemory.c @@ -105,7 +105,7 @@ STATIC mp_obj_t alarm_sleep_memory_subscr(mp_obj_t self_in, mp_obj_t index_in, m } 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)) { - mp_raise_NotImplementedError(translate("only slices with step=1 (aka None) are supported")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("only slices with step=1 (aka None) are supported")); } if (value != MP_OBJ_SENTINEL) { #if MICROPY_PY_ARRAY_SLICE_ASSIGN @@ -119,19 +119,19 @@ STATIC mp_obj_t alarm_sleep_memory_subscr(mp_obj_t self_in, mp_obj_t index_in, m mp_buffer_info_t bufinfo; mp_get_buffer_raise(value, &bufinfo, MP_BUFFER_READ); if (bufinfo.len != src_len) { - mp_raise_ValueError(translate("Slice and value different lengths.")); + mp_raise_ValueError(MP_ERROR_TEXT("Slice and value different lengths.")); } src_len = bufinfo.len; src_items = bufinfo.buf; if (1 != mp_binary_get_size('@', bufinfo.typecode, NULL)) { - mp_raise_ValueError(translate("Array values should be single bytes.")); + mp_raise_ValueError(MP_ERROR_TEXT("Array values should be single bytes.")); } } else { - mp_raise_NotImplementedError(translate("array/bytes required on right side")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("array/bytes required on right side")); } if (!common_hal_alarm_sleep_memory_set_bytes(self, slice.start, src_items, src_len)) { - mp_raise_RuntimeError(translate("Unable to write to sleep_memory.")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Unable to write to sleep_memory.")); } return mp_const_none; #else @@ -161,7 +161,7 @@ STATIC mp_obj_t alarm_sleep_memory_subscr(mp_obj_t self_in, mp_obj_t index_in, m uint8_t short_value = byte_value; if (!common_hal_alarm_sleep_memory_set_bytes(self, index, &short_value, 1)) { - mp_raise_RuntimeError(translate("Unable to write to sleep_memory.")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Unable to write to sleep_memory.")); } return mp_const_none; } diff --git a/shared-bindings/alarm/__init__.c b/shared-bindings/alarm/__init__.c index 7f927df016..211aee78ea 100644 --- a/shared-bindings/alarm/__init__.c +++ b/shared-bindings/alarm/__init__.c @@ -87,7 +87,7 @@ STATIC void validate_objs_are_alarms(size_t n_args, const mp_obj_t *objs) { mp_obj_is_type(objs[i], &alarm_touch_touchalarm_type)) { continue; } - mp_raise_TypeError_varg(translate("Expected a kind of %q"), MP_QSTR_Alarm); + mp_raise_TypeError_varg(MP_ERROR_TEXT("Expected a kind of %q"), MP_QSTR_Alarm); } } diff --git a/shared-bindings/alarm/time/TimeAlarm.c b/shared-bindings/alarm/time/TimeAlarm.c index 960f93d1c0..24eb0b9115 100644 --- a/shared-bindings/alarm/time/TimeAlarm.c +++ b/shared-bindings/alarm/time/TimeAlarm.c @@ -35,7 +35,7 @@ #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE mp_obj_t MP_WEAK rtc_get_time_source_time(void) { - mp_raise_RuntimeError(translate("RTC is not supported on this board")); + mp_raise_RuntimeError(MP_ERROR_TEXT("RTC is not supported on this board")); } #endif @@ -74,7 +74,7 @@ STATIC mp_obj_t alarm_time_timealarm_make_new(const mp_obj_type_t *type, bool have_epoch = args[ARG_epoch_time].u_obj != mp_const_none; if (!(have_monotonic ^ have_epoch)) { - mp_raise_ValueError(translate("Supply one of monotonic_time or epoch_time")); + mp_raise_ValueError(MP_ERROR_TEXT("Supply one of monotonic_time or epoch_time")); } mp_float_t monotonic_time = 0; // To avoid compiler warning. @@ -86,7 +86,7 @@ STATIC mp_obj_t alarm_time_timealarm_make_new(const mp_obj_type_t *type, if (have_epoch) { #if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_NONE - mp_raise_ValueError(translate("epoch_time not supported on this board")); + mp_raise_ValueError(MP_ERROR_TEXT("epoch_time not supported on this board")); #else mp_uint_t epoch_time_secs = mp_obj_int_get_checked(args[ARG_epoch_time].u_obj); @@ -102,7 +102,7 @@ STATIC mp_obj_t alarm_time_timealarm_make_new(const mp_obj_type_t *type, } if (monotonic_time < monotonic_time_now) { - mp_raise_ValueError(translate("Time is in the past.")); + mp_raise_ValueError(MP_ERROR_TEXT("Time is in the past.")); } common_hal_alarm_time_timealarm_construct(self, monotonic_time); diff --git a/shared-bindings/analogbufio/BufferedIn.c b/shared-bindings/analogbufio/BufferedIn.c index 1e64dc6d7b..68680d74af 100644 --- a/shared-bindings/analogbufio/BufferedIn.c +++ b/shared-bindings/analogbufio/BufferedIn.c @@ -145,7 +145,7 @@ STATIC mp_obj_t analogbufio_bufferedin_obj_readinto(mp_obj_t self_in, mp_obj_t b if (bufinfo.typecode == 'H') { bytes_per_sample = 2; } else if (bufinfo.typecode != 'B' && bufinfo.typecode != BYTEARRAY_TYPECODE) { - mp_raise_ValueError_varg(translate("%q must be a bytearray or array of type 'H' or 'B'"), MP_QSTR_buffer); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q must be a bytearray or array of type 'H' or 'B'"), MP_QSTR_buffer); } mp_uint_t captured = common_hal_analogbufio_bufferedin_readinto(self, bufinfo.buf, bufinfo.len, bytes_per_sample); diff --git a/shared-bindings/audiobusio/I2SOut.c b/shared-bindings/audiobusio/I2SOut.c index d3b722ebcb..e85cb098ee 100644 --- a/shared-bindings/audiobusio/I2SOut.c +++ b/shared-bindings/audiobusio/I2SOut.c @@ -98,7 +98,7 @@ //| ... STATIC mp_obj_t audiobusio_i2sout_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { #if !CIRCUITPY_AUDIOBUSIO_I2SOUT - mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_I2SOut); + mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_I2SOut); return NULL; // Not reachable. #else enum { ARG_bit_clock, ARG_word_select, ARG_data, ARG_main_clock, ARG_left_justified }; @@ -217,7 +217,7 @@ STATIC mp_obj_t audiobusio_i2sout_obj_pause(mp_obj_t self_in) { check_for_deinit(self); if (!common_hal_audiobusio_i2sout_get_playing(self)) { - mp_raise_RuntimeError(translate("Not playing")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Not playing")); } common_hal_audiobusio_i2sout_pause(self); return mp_const_none; diff --git a/shared-bindings/audiobusio/PDMIn.c b/shared-bindings/audiobusio/PDMIn.c index 118ba69177..520061f69a 100644 --- a/shared-bindings/audiobusio/PDMIn.c +++ b/shared-bindings/audiobusio/PDMIn.c @@ -93,7 +93,7 @@ //| ... STATIC mp_obj_t audiobusio_pdmin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { #if !CIRCUITPY_AUDIOBUSIO_PDMIN - mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_PDMIn); + mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_PDMIn); #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[] = { @@ -120,11 +120,11 @@ STATIC mp_obj_t audiobusio_pdmin_make_new(const mp_obj_type_t *type, size_t n_ar uint32_t sample_rate = args[ARG_sample_rate].u_int; uint8_t bit_depth = args[ARG_bit_depth].u_int; if (bit_depth % 8 != 0) { - mp_raise_ValueError(translate("Bit depth must be multiple of 8.")); + mp_raise_ValueError(MP_ERROR_TEXT("Bit depth must be multiple of 8.")); } uint8_t oversample = args[ARG_oversample].u_int; if (oversample % 8 != 0) { - mp_raise_ValueError(translate("Oversample must be multiple of 8.")); + mp_raise_ValueError(MP_ERROR_TEXT("Oversample must be multiple of 8.")); } bool mono = args[ARG_mono].u_bool; @@ -132,7 +132,7 @@ STATIC mp_obj_t audiobusio_pdmin_make_new(const mp_obj_type_t *type, size_t n_ar ? (mp_float_t)STARTUP_DELAY_DEFAULT : mp_obj_get_float(args[ARG_startup_delay].u_obj); if (startup_delay < 0.0 || startup_delay > 1.0) { - mp_raise_ValueError(translate("Microphone startup delay must be in range 0.0 to 1.0")); + mp_raise_ValueError(MP_ERROR_TEXT("Microphone startup delay must be in range 0.0 to 1.0")); } common_hal_audiobusio_pdmin_construct(self, clock_pin, data_pin, sample_rate, @@ -196,16 +196,16 @@ STATIC mp_obj_t audiobusio_pdmin_obj_record(mp_obj_t self_obj, mp_obj_t destinat mp_buffer_info_t bufinfo; if (mp_obj_is_type(destination, &mp_type_fileio)) { - mp_raise_NotImplementedError(translate("Cannot record to a file")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("Cannot record to a file")); } else if (mp_get_buffer(destination, &bufinfo, MP_BUFFER_WRITE)) { if (bufinfo.len / mp_binary_get_size('@', bufinfo.typecode, NULL) < length) { - mp_raise_ValueError(translate("Destination capacity is smaller than destination_length.")); + mp_raise_ValueError(MP_ERROR_TEXT("Destination capacity is smaller than destination_length.")); } uint8_t bit_depth = common_hal_audiobusio_pdmin_get_bit_depth(self); if (bufinfo.typecode != 'H' && bit_depth == 16) { - mp_raise_ValueError(translate("destination buffer must be an array of type 'H' for bit_depth = 16")); + mp_raise_ValueError(MP_ERROR_TEXT("destination buffer must be an array of type 'H' for bit_depth = 16")); } else if (bufinfo.typecode != 'B' && bufinfo.typecode != BYTEARRAY_TYPECODE && bit_depth == 8) { - mp_raise_ValueError(translate("destination buffer must be a bytearray or array of type 'B' for bit_depth = 8")); + mp_raise_ValueError(MP_ERROR_TEXT("destination buffer must be a bytearray or array of type 'B' for bit_depth = 8")); } // length is the buffer length in slots, not bytes. uint32_t length_written = diff --git a/shared-bindings/audiocore/RawSample.c b/shared-bindings/audiocore/RawSample.c index 46f5d4c748..2e49f84093 100644 --- a/shared-bindings/audiocore/RawSample.c +++ b/shared-bindings/audiocore/RawSample.c @@ -87,7 +87,7 @@ STATIC mp_obj_t audioio_rawsample_make_new(const mp_obj_type_t *type, size_t n_a if (bufinfo.typecode == 'h' || bufinfo.typecode == 'H') { bytes_per_sample = 2; } else if (bufinfo.typecode != 'b' && bufinfo.typecode != 'B' && bufinfo.typecode != BYTEARRAY_TYPECODE) { - mp_raise_ValueError_varg(translate("%q must be a bytearray or array of type 'h', 'H', 'b', or 'B'"), MP_QSTR_buffer); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q must be a bytearray or array of type 'h', 'H', 'b', or 'B'"), MP_QSTR_buffer); } common_hal_audioio_rawsample_construct(self, ((uint8_t *)bufinfo.buf), bufinfo.len, bytes_per_sample, signed_samples, args[ARG_channel_count].u_int, diff --git a/shared-bindings/audiocore/WaveFile.c b/shared-bindings/audiocore/WaveFile.c index 98a0a564f8..88ded90cfa 100644 --- a/shared-bindings/audiocore/WaveFile.c +++ b/shared-bindings/audiocore/WaveFile.c @@ -80,7 +80,7 @@ STATIC mp_obj_t audioio_wavefile_make_new(const mp_obj_type_t *type, size_t n_ar audioio_wavefile_obj_t *self = mp_obj_malloc(audioio_wavefile_obj_t, &audioio_wavefile_type); if (!mp_obj_is_type(arg, &mp_type_vfs_fat_fileio)) { - mp_raise_TypeError(translate("file must be a file opened in byte mode")); + mp_raise_TypeError(MP_ERROR_TEXT("file must be a file opened in byte mode")); } uint8_t *buffer = NULL; size_t buffer_size = 0; diff --git a/shared-bindings/audioio/AudioOut.c b/shared-bindings/audioio/AudioOut.c index 72b7828c48..4c7231c0ce 100644 --- a/shared-bindings/audioio/AudioOut.c +++ b/shared-bindings/audioio/AudioOut.c @@ -207,7 +207,7 @@ STATIC mp_obj_t audioio_audioout_obj_pause(mp_obj_t self_in) { check_for_deinit(self); if (!common_hal_audioio_audioout_get_playing(self)) { - mp_raise_RuntimeError(translate("Not playing")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Not playing")); } common_hal_audioio_audioout_pause(self); return mp_const_none; diff --git a/shared-bindings/audiomixer/Mixer.c b/shared-bindings/audiomixer/Mixer.c index 03d21728dc..c891e70722 100644 --- a/shared-bindings/audiomixer/Mixer.c +++ b/shared-bindings/audiomixer/Mixer.c @@ -100,7 +100,7 @@ STATIC mp_obj_t audiomixer_mixer_make_new(const mp_obj_type_t *type, size_t n_ar mp_int_t sample_rate = mp_arg_validate_int_min(args[ARG_sample_rate].u_int, 1, MP_QSTR_sample_rate); mp_int_t bits_per_sample = args[ARG_bits_per_sample].u_int; if (bits_per_sample != 8 && bits_per_sample != 16) { - mp_raise_ValueError(translate("bits_per_sample must be 8 or 16")); + mp_raise_ValueError(MP_ERROR_TEXT("bits_per_sample must be 8 or 16")); } audiomixer_mixer_obj_t *self = mp_obj_malloc_var(audiomixer_mixer_obj_t, mp_obj_t, voice_count, &audiomixer_mixer_type); diff --git a/shared-bindings/audiomixer/MixerVoice.c b/shared-bindings/audiomixer/MixerVoice.c index e2d00ebc5b..f4285b2f43 100644 --- a/shared-bindings/audiomixer/MixerVoice.c +++ b/shared-bindings/audiomixer/MixerVoice.c @@ -114,7 +114,7 @@ STATIC mp_obj_t audiomixer_mixervoice_obj_set_level(size_t n_args, const mp_obj_ mp_float_t 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")); + mp_raise_ValueError(MP_ERROR_TEXT("level must be between 0 and 1")); } common_hal_audiomixer_mixervoice_set_level(self, level); diff --git a/shared-bindings/audiomp3/MP3Decoder.c b/shared-bindings/audiomp3/MP3Decoder.c index b27383aa98..3cb1ac4a68 100644 --- a/shared-bindings/audiomp3/MP3Decoder.c +++ b/shared-bindings/audiomp3/MP3Decoder.c @@ -96,7 +96,7 @@ STATIC mp_obj_t audiomp3_mp3file_make_new(const mp_obj_type_t *type, size_t n_ar audiomp3_mp3file_obj_t *self = mp_obj_malloc(audiomp3_mp3file_obj_t, &audiomp3_mp3file_type); if (!mp_obj_is_type(arg, &mp_type_fileio)) { - mp_raise_TypeError(translate("file must be a file opened in byte mode")); + mp_raise_TypeError(MP_ERROR_TEXT("file must be a file opened in byte mode")); } uint8_t *buffer = NULL; size_t buffer_size = 0; @@ -157,7 +157,7 @@ STATIC mp_obj_t audiomp3_mp3file_obj_set_file(mp_obj_t self_in, mp_obj_t file) { audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); if (!mp_obj_is_type(file, &mp_type_fileio)) { - mp_raise_TypeError(translate("file must be a file opened in byte mode")); + mp_raise_TypeError(MP_ERROR_TEXT("file must be a file opened in byte mode")); } common_hal_audiomp3_mp3file_set_file(self, file); return mp_const_none; diff --git a/shared-bindings/audiopwmio/PWMAudioOut.c b/shared-bindings/audiopwmio/PWMAudioOut.c index b7d2a6d8a0..1901794cdb 100644 --- a/shared-bindings/audiopwmio/PWMAudioOut.c +++ b/shared-bindings/audiopwmio/PWMAudioOut.c @@ -216,7 +216,7 @@ STATIC mp_obj_t audiopwmio_pwmaudioout_obj_pause(mp_obj_t self_in) { check_for_deinit(self); if (!common_hal_audiopwmio_pwmaudioout_get_playing(self)) { - mp_raise_RuntimeError(translate("Not playing")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Not playing")); } common_hal_audiopwmio_pwmaudioout_pause(self); return mp_const_none; diff --git a/shared-bindings/bitbangio/I2C.c b/shared-bindings/bitbangio/I2C.c index 5ca950c3e3..3ad15c3c8d 100644 --- a/shared-bindings/bitbangio/I2C.c +++ b/shared-bindings/bitbangio/I2C.c @@ -118,7 +118,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitbangio_i2c_obj___exit___obj, 4, 4, static void check_lock(bitbangio_i2c_obj_t *self) { if (!shared_module_bitbangio_i2c_has_lock(self)) { - mp_raise_RuntimeError(translate("Function requires lock")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Function requires lock")); } } diff --git a/shared-bindings/bitbangio/SPI.c b/shared-bindings/bitbangio/SPI.c index e78b96bc09..0310f06fc8 100644 --- a/shared-bindings/bitbangio/SPI.c +++ b/shared-bindings/bitbangio/SPI.c @@ -128,7 +128,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bitbangio_spi_obj___exit___obj, 4, 4, static void check_lock(bitbangio_spi_obj_t *self) { if (!shared_module_bitbangio_spi_has_lock(self)) { - mp_raise_RuntimeError(translate("Function requires lock")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Function requires lock")); } } @@ -377,7 +377,7 @@ STATIC mp_obj_t bitbangio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_ in_length *= in_stride_in_bytes; if (out_length != in_length) { - mp_raise_ValueError(translate("buffer slices must be of equal length")); + mp_raise_ValueError(MP_ERROR_TEXT("buffer slices must be of equal length")); } if (out_length == 0) { diff --git a/shared-bindings/bitmaptools/__init__.c b/shared-bindings/bitmaptools/__init__.c index eef80a654a..b21db9c23e 100644 --- a/shared-bindings/bitmaptools/__init__.c +++ b/shared-bindings/bitmaptools/__init__.c @@ -67,7 +67,7 @@ STATIC void extract_tuple(mp_obj_t xy_tuple, int16_t *x, int16_t *y, int16_t x_d *x = x_default; *y = y_default; } else if (!mp_obj_is_obj(xy_tuple)) { - mp_raise_ValueError(translate("clip point must be (x,y) tuple")); + mp_raise_ValueError(MP_ERROR_TEXT("clip point must be (x,y) tuple")); } else { mp_obj_t *items; mp_obj_get_array_fixed_n(xy_tuple, 2, &items); @@ -209,7 +209,7 @@ STATIC mp_obj_t bitmaptools_obj_rotozoom(size_t n_args, const mp_obj_t *pos_args // ensure that the destination bitmap has at least as many `bits_per_value` as the source if (destination->bits_per_value < source->bits_per_value) { - mp_raise_ValueError(translate("source palette too large")); + mp_raise_ValueError(MP_ERROR_TEXT("source palette too large")); } // Confirm the destination location target (ox,oy); if None, default to bitmap midpoint @@ -361,13 +361,13 @@ STATIC mp_obj_t bitmaptools_alphablend(size_t n_args, const mp_obj_t *pos_args, || destination->height != source2->height || destination->bits_per_value != source2->bits_per_value ) { - mp_raise_ValueError(translate("Bitmap size and bits per value must match")); + mp_raise_ValueError(MP_ERROR_TEXT("Bitmap size and bits per value must match")); } switch (colorspace) { case DISPLAYIO_COLORSPACE_L8: if (destination->bits_per_value != 8) { - mp_raise_ValueError(translate("For L8 colorspace, input bitmap must have 8 bits per pixel")); + mp_raise_ValueError(MP_ERROR_TEXT("For L8 colorspace, input bitmap must have 8 bits per pixel")); } break; @@ -376,12 +376,12 @@ STATIC mp_obj_t bitmaptools_alphablend(size_t n_args, const mp_obj_t *pos_args, case DISPLAYIO_COLORSPACE_BGR565: case DISPLAYIO_COLORSPACE_BGR565_SWAPPED: if (destination->bits_per_value != 16) { - mp_raise_ValueError(translate("For RGB colorspaces, input bitmap must have 16 bits per pixel")); + mp_raise_ValueError(MP_ERROR_TEXT("For RGB colorspaces, input bitmap must have 16 bits per pixel")); } break; default: - mp_raise_ValueError(translate("Unsupported colorspace")); + mp_raise_ValueError(MP_ERROR_TEXT("Unsupported colorspace")); } uint32_t skip_source1_index; @@ -448,7 +448,7 @@ 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(MP_ERROR_TEXT("out of range of target")); } int16_t x1 = args[ARG_x1].u_int; @@ -501,23 +501,23 @@ STATIC mp_obj_t bitmaptools_obj_boundary_fill(size_t n_args, const mp_obj_t *pos fill_color_value = args[ARG_fill_color_value].u_int; color_depth = (1 << destination->bits_per_value); if (color_depth <= fill_color_value) { - mp_raise_ValueError(translate("value out of range of target")); + mp_raise_ValueError(MP_ERROR_TEXT("value out of range of target")); } uint32_t replaced_color_value; replaced_color_value = args[ARG_replaced_color_value].u_int; if (replaced_color_value != INT_MAX && color_depth <= replaced_color_value) { - mp_raise_ValueError(translate("background value out of range of target")); + mp_raise_ValueError(MP_ERROR_TEXT("background value out of range of target")); } int16_t x = args[ARG_x].u_int; int16_t y = args[ARG_y].u_int; if (x < 0 || x >= destination->width) { - mp_raise_ValueError(translate("out of range of target")); + mp_raise_ValueError(MP_ERROR_TEXT("out of range of target")); } if (y < 0 || y >= destination->height) { - mp_raise_ValueError(translate("out of range of target")); + mp_raise_ValueError(MP_ERROR_TEXT("out of range of target")); } common_hal_bitmaptools_boundary_fill(destination, x, y, fill_color_value, replaced_color_value); @@ -562,7 +562,7 @@ 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(MP_ERROR_TEXT("out of range of target")); } int16_t x1 = args[ARG_x1].u_int; @@ -651,17 +651,17 @@ STATIC mp_obj_t bitmaptools_obj_draw_polygon(size_t n_args, const mp_obj_t *pos_ size_t xs_len = xs_buf.len / xs_size; size_t ys_len = ys_buf.len / ys_size; if (xs_size != ys_size) { - mp_raise_ValueError(translate("Coordinate arrays types have different sizes")); + mp_raise_ValueError(MP_ERROR_TEXT("Coordinate arrays types have different sizes")); } if (xs_len != ys_len) { - mp_raise_ValueError(translate("Coordinate arrays have different lengths")); + mp_raise_ValueError(MP_ERROR_TEXT("Coordinate arrays have different lengths")); } uint32_t value, color_depth; 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(MP_ERROR_TEXT("out of range of target")); } bool close = args[ARG_close].u_bool; @@ -735,7 +735,7 @@ STATIC mp_obj_t bitmaptools_arrayblit(size_t n_args, const mp_obj_t *pos_args, m int y2 = args[ARG_y2].u_int == -1 ? bitmap->height : args[ARG_y2].u_int; if ((x1 < 0) || (y1 < 0) || (x1 > x2) || (y1 > y2) || (x2 > bitmap->width) || (y2 > bitmap->height)) { - mp_raise_IndexError(translate("pixel coordinates out of bounds")); + mp_raise_IndexError(MP_ERROR_TEXT("pixel coordinates out of bounds")); } size_t output_element_count = (x2 - x1) * (y2 - y1); @@ -745,7 +745,7 @@ STATIC mp_obj_t bitmaptools_arrayblit(size_t n_args, const mp_obj_t *pos_args, m bool skip_specified = args[ARG_skip_index].u_obj != mp_const_none; uint32_t skip_index = skip_specified ? mp_obj_get_int(args[ARG_skip_index].u_obj) : 0; if (input_element_count < output_element_count) { - mp_raise_IndexError(translate("index out of range")); + mp_raise_IndexError(MP_ERROR_TEXT("index out of range")); } common_hal_bitmaptools_arrayblit(bitmap, bufinfo.buf, element_size, x1, y1, x2, y2, skip_specified, skip_index); @@ -805,14 +805,14 @@ STATIC mp_obj_t bitmaptools_readinto(size_t n_args, const mp_obj_t *pos_args, mp int element_size = args[ARG_element_size].u_int; if (element_size != 1 && element_size != 2 && element_size != 4) { - mp_raise_ValueError_varg(translate("invalid element_size %d, must be, 1, 2, or 4"), element_size); + mp_raise_ValueError_varg(MP_ERROR_TEXT("invalid element_size %d, must be, 1, 2, or 4"), element_size); } int bits_per_pixel = args[ARG_bits_per_pixel].u_int; switch (bits_per_pixel) { case 24: if (element_size != 1) { - mp_raise_ValueError_varg(translate("invalid element size %d for bits_per_pixel %d\n"), element_size, bits_per_pixel); + mp_raise_ValueError_varg(MP_ERROR_TEXT("invalid element size %d for bits_per_pixel %d\n"), element_size, bits_per_pixel); } break; case 1: @@ -823,7 +823,7 @@ STATIC mp_obj_t bitmaptools_readinto(size_t n_args, const mp_obj_t *pos_args, mp case 32: break; default: - mp_raise_ValueError_varg(translate("invalid bits_per_pixel %d, must be, 1, 2, 4, 8, 16, 24, or 32"), bits_per_pixel); + mp_raise_ValueError_varg(MP_ERROR_TEXT("invalid bits_per_pixel %d, must be, 1, 2, 4, 8, 16, 24, or 32"), bits_per_pixel); } bool reverse_pixels_in_element = args[ARG_reverse_pixels_in_element].u_bool; @@ -889,11 +889,11 @@ STATIC mp_obj_t bitmaptools_dither(size_t n_args, const mp_obj_t *pos_args, mp_m displayio_colorspace_t colorspace = cp_enum_value(&displayio_colorspace_type, args[ARG_source_colorspace].u_obj, MP_QSTR_source_colorspace); if (source_bitmap->width != dest_bitmap->width || source_bitmap->height != dest_bitmap->height) { - mp_raise_TypeError(translate("bitmap sizes must match")); + mp_raise_TypeError(MP_ERROR_TEXT("bitmap sizes must match")); } if (dest_bitmap->bits_per_value != 16 && dest_bitmap->bits_per_value != 1) { - mp_raise_TypeError(translate("source_bitmap must have value_count of 2 or 65536")); + mp_raise_TypeError(MP_ERROR_TEXT("source_bitmap must have value_count of 2 or 65536")); } @@ -903,18 +903,18 @@ STATIC mp_obj_t bitmaptools_dither(size_t n_args, const mp_obj_t *pos_args, mp_m case DISPLAYIO_COLORSPACE_BGR565: case DISPLAYIO_COLORSPACE_BGR565_SWAPPED: if (source_bitmap->bits_per_value != 16) { - mp_raise_TypeError(translate("source_bitmap must have value_count of 65536")); + mp_raise_TypeError(MP_ERROR_TEXT("source_bitmap must have value_count of 65536")); } break; case DISPLAYIO_COLORSPACE_L8: if (source_bitmap->bits_per_value != 8) { - mp_raise_TypeError(translate("source_bitmap must have value_count of 8")); + mp_raise_TypeError(MP_ERROR_TEXT("source_bitmap must have value_count of 8")); } break; default: - mp_raise_TypeError(translate("unsupported colorspace for dither")); + mp_raise_TypeError(MP_ERROR_TEXT("unsupported colorspace for dither")); } @@ -985,7 +985,7 @@ STATIC mp_obj_t bitmaptools_obj_draw_circle(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(MP_ERROR_TEXT("out of range of target")); } @@ -1068,7 +1068,7 @@ STATIC mp_obj_t bitmaptools_obj_blit(size_t n_args, const mp_obj_t *pos_args, mp // ensure that the target bitmap (self) has at least as many `bits_per_value` as the source if (destination->bits_per_value < source->bits_per_value) { - mp_raise_ValueError(translate("source palette too large")); + mp_raise_ValueError(MP_ERROR_TEXT("source palette too large")); } // Check x1,y1,x2,y2 are within source bitmap boundary diff --git a/shared-bindings/bitops/__init__.c b/shared-bindings/bitops/__init__.c index 48cf1df0d6..3c21a10a19 100644 --- a/shared-bindings/bitops/__init__.c +++ b/shared-bindings/bitops/__init__.c @@ -72,7 +72,7 @@ STATIC mp_obj_t bit_transpose(size_t n_args, const mp_obj_t *pos_args, mp_map_t mp_get_buffer_raise(args[ARG_input].u_obj, &input_bufinfo, MP_BUFFER_READ); int inlen = input_bufinfo.len; if (inlen % width != 0) { - mp_raise_ValueError_varg(translate("Input buffer length (%d) must be a multiple of the strand count (%d)"), inlen, width); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Input buffer length (%d) must be a multiple of the strand count (%d)"), inlen, width); } mp_buffer_info_t output_bufinfo; diff --git a/shared-bindings/board/__init__.c b/shared-bindings/board/__init__.c index 273ef7ff90..c7d2a399cf 100644 --- a/shared-bindings/board/__init__.c +++ b/shared-bindings/board/__init__.c @@ -72,7 +72,7 @@ STATIC mp_obj_t board_i2c_0(void) { } #else STATIC mp_obj_t board_i2c_0(void) { - mp_raise_NotImplementedError_varg(translate("No default %q bus"), MP_QSTR_I2C); + mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("No default %q bus"), MP_QSTR_I2C); return MP_ROM_NONE; } #endif @@ -90,7 +90,7 @@ STATIC mp_obj_t board_spi_0(void) { } #else STATIC mp_obj_t board_spi_0(void) { - mp_raise_NotImplementedError_varg(translate("No default %q bus"), MP_QSTR_SPI); + mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("No default %q bus"), MP_QSTR_SPI); return MP_ROM_NONE; } #endif @@ -108,7 +108,7 @@ STATIC mp_obj_t board_uart_0(void) { } #else STATIC mp_obj_t board_uart_0(void) { - mp_raise_NotImplementedError_varg(translate("No default %q bus"), MP_QSTR_UART); + mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("No default %q bus"), MP_QSTR_UART); return MP_ROM_NONE; } #endif diff --git a/shared-bindings/busdisplay/BusDisplay.c b/shared-bindings/busdisplay/BusDisplay.c index 0566fa609f..321859f16b 100644 --- a/shared-bindings/busdisplay/BusDisplay.c +++ b/shared-bindings/busdisplay/BusDisplay.c @@ -199,13 +199,13 @@ STATIC mp_obj_t busdisplay_busdisplay_make_new(const mp_obj_type_t *type, size_t mp_int_t rotation = args[ARG_rotation].u_int; if (rotation % 90 != 0) { - mp_raise_ValueError(translate("Display rotation must be in 90 degree increments")); + mp_raise_ValueError(MP_ERROR_TEXT("Display rotation must be in 90 degree increments")); } const bool sh1107_addressing = args[ARG_SH1107_addressing].u_bool; const mp_int_t color_depth = args[ARG_color_depth].u_int; if (sh1107_addressing && color_depth != 1) { - mp_raise_ValueError_varg(translate("%q must be 1 when %q is True"), MP_QSTR_color_depth, MP_QSTR_SH1107_addressing); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q must be 1 when %q is True"), MP_QSTR_color_depth, MP_QSTR_SH1107_addressing); } primary_display_t *disp = allocate_display_or_raise(); @@ -247,7 +247,7 @@ static busdisplay_busdisplay_obj_t *native_display(mp_obj_t display_obj) { // Undocumented show() implementation with a friendly error message. STATIC mp_obj_t busdisplay_busdisplay_obj_show(mp_obj_t self_in, mp_obj_t group_in) { - mp_raise_AttributeError(translate(".show(x) removed. Use .root_group = x")); + mp_raise_AttributeError(MP_ERROR_TEXT(".show(x) removed. Use .root_group = x")); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_2(busdisplay_busdisplay_show_obj, busdisplay_busdisplay_obj_show); @@ -334,7 +334,7 @@ STATIC mp_obj_t busdisplay_busdisplay_obj_get_brightness(mp_obj_t self_in) { busdisplay_busdisplay_obj_t *self = native_display(self_in); mp_float_t brightness = common_hal_busdisplay_busdisplay_get_brightness(self); if (brightness < 0) { - mp_raise_RuntimeError(translate("Brightness not adjustable")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Brightness not adjustable")); } return mp_obj_new_float(brightness); } @@ -344,11 +344,11 @@ STATIC mp_obj_t busdisplay_busdisplay_obj_set_brightness(mp_obj_t self_in, mp_ob busdisplay_busdisplay_obj_t *self = native_display(self_in); mp_float_t brightness = mp_obj_get_float(brightness_obj); if (brightness < 0 || brightness > 1.0) { - mp_raise_ValueError_varg(translate("%q must be %d-%d"), MP_QSTR_brightness, 0, 1); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q must be %d-%d"), MP_QSTR_brightness, 0, 1); } bool ok = common_hal_busdisplay_busdisplay_set_brightness(self, brightness); if (!ok) { - mp_raise_RuntimeError(translate("Brightness not adjustable")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Brightness not adjustable")); } return mp_const_none; } @@ -462,7 +462,7 @@ STATIC mp_obj_t busdisplay_busdisplay_obj_fill_row(size_t n_args, const mp_obj_t mp_get_buffer_raise(result, &bufinfo, MP_BUFFER_WRITE); if (self->core.colorspace.depth != 16) { - mp_raise_ValueError(translate("Display must have a 16 bit colorspace.")); + mp_raise_ValueError(MP_ERROR_TEXT("Display must have a 16 bit colorspace.")); } displayio_area_t area = { @@ -492,7 +492,7 @@ STATIC mp_obj_t busdisplay_busdisplay_obj_fill_row(size_t n_args, const mp_obj_t displayio_display_core_fill_area(&self->core, &area, mask, result_buffer); return result; } else { - mp_raise_ValueError(translate("Buffer too small")); + mp_raise_ValueError(MP_ERROR_TEXT("Buffer too small")); } } MP_DEFINE_CONST_FUN_OBJ_KW(busdisplay_busdisplay_fill_row_obj, 1, busdisplay_busdisplay_obj_fill_row); diff --git a/shared-bindings/busio/I2C.c b/shared-bindings/busio/I2C.c index 376969847f..fe134b51b2 100644 --- a/shared-bindings/busio/I2C.c +++ b/shared-bindings/busio/I2C.c @@ -120,7 +120,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_i2c___exit___obj, 4, 4, busio_i static void check_lock(busio_i2c_obj_t *self) { asm (""); if (!common_hal_busio_i2c_has_lock(self)) { - mp_raise_RuntimeError(translate("Function requires lock")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Function requires lock")); } } diff --git a/shared-bindings/busio/SPI.c b/shared-bindings/busio/SPI.c index 1f02927bb1..45c9327a3f 100644 --- a/shared-bindings/busio/SPI.c +++ b/shared-bindings/busio/SPI.c @@ -121,7 +121,7 @@ STATIC mp_obj_t busio_spi_make_new(const mp_obj_type_t *type, size_t n_args, siz const mcu_pin_obj_t *miso = validate_obj_is_free_pin_or_none(args[ARG_MISO].u_obj, MP_QSTR_miso); if (!miso && !mosi) { - mp_raise_ValueError(translate("Must provide MISO or MOSI pin")); + mp_raise_ValueError(MP_ERROR_TEXT("Must provide MISO or MOSI pin")); } common_hal_busio_spi_construct(self, clock, mosi, miso, args[ARG_half_duplex].u_bool); @@ -161,7 +161,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_spi_obj___exit___obj, 4, 4, bus STATIC void check_lock(busio_spi_obj_t *self) { asm (""); if (!common_hal_busio_spi_has_lock(self)) { - mp_raise_RuntimeError(translate("Function requires lock")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Function requires lock")); } } @@ -436,7 +436,7 @@ STATIC mp_obj_t busio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args in_length *= in_stride_in_bytes; if (out_length != in_length) { - mp_raise_ValueError(translate("buffer slices must be of equal length")); + mp_raise_ValueError(MP_ERROR_TEXT("buffer slices must be of equal length")); } if (out_length == 0) { diff --git a/shared-bindings/busio/UART.c b/shared-bindings/busio/UART.c index 1036534a61..34f91ca0c2 100644 --- a/shared-bindings/busio/UART.c +++ b/shared-bindings/busio/UART.c @@ -142,7 +142,7 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, si const mcu_pin_obj_t *cts = validate_obj_is_free_pin_or_none(args[ARG_cts].u_obj, MP_QSTR_cts); const mcu_pin_obj_t *rs485_dir = validate_obj_is_free_pin_or_none(args[ARG_rs485_dir].u_obj, MP_QSTR_rs485_dir); if ((tx == NULL) && (rx == NULL)) { - mp_raise_ValueError(translate("tx and rx cannot both be None")); + mp_raise_ValueError(MP_ERROR_TEXT("tx and rx cannot both be None")); } // Pins must be distinct. @@ -187,7 +187,7 @@ STATIC mp_obj_t busio_uart_make_new(const mp_obj_type_t *type, size_t n_args, si STATIC busio_uart_obj_t *native_uart(mp_obj_t uart_obj) { mp_obj_t native_uart = mp_obj_cast_to_native_base(uart_obj, MP_OBJ_FROM_PTR(&busio_uart_type)); if (native_uart == MP_OBJ_NULL) { - mp_raise_ValueError_varg(translate("Must be a %q subclass."), MP_QSTR_UART); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Must be a %q subclass."), MP_QSTR_UART); } mp_obj_assert_native_inited(native_uart); return MP_OBJ_TO_PTR(native_uart); diff --git a/shared-bindings/canio/CAN.c b/shared-bindings/canio/CAN.c index 10fd752508..2d0af0dc38 100644 --- a/shared-bindings/canio/CAN.c +++ b/shared-bindings/canio/CAN.c @@ -80,7 +80,7 @@ STATIC mp_obj_t canio_can_make_new(const mp_obj_type_t *type, size_t n_args, siz const mcu_pin_obj_t *rx_pin = validate_obj_is_free_pin_or_none(args[ARG_rx].u_obj, MP_QSTR_rx); const mcu_pin_obj_t *tx_pin = validate_obj_is_free_pin_or_none(args[ARG_tx].u_obj, MP_QSTR_tx); if (!rx_pin && !tx_pin) { - mp_raise_ValueError(translate("tx and rx cannot both be None")); + mp_raise_ValueError(MP_ERROR_TEXT("tx and rx cannot both be None")); } canio_can_obj_t *self = mp_obj_malloc(canio_can_obj_t, &canio_can_type); @@ -267,7 +267,7 @@ STATIC mp_obj_t canio_can_send(mp_obj_t self_in, mp_obj_t message_in) { common_hal_canio_can_check_for_deinit(self); const mp_obj_type_t *message_type = mp_obj_get_type(message_in); if (message_type != &canio_message_type && message_type != &canio_remote_transmission_request_type) { - mp_raise_TypeError_varg(translate("%q must be of type %q or %q, not %q"), MP_QSTR_message, MP_QSTR_Message, MP_QSTR_RemoteTransmissionRequest, message_type->name); + mp_raise_TypeError_varg(MP_ERROR_TEXT("%q must be of type %q or %q, not %q"), MP_QSTR_message, MP_QSTR_Message, MP_QSTR_RemoteTransmissionRequest, message_type->name); } canio_message_obj_t *message = message_in; diff --git a/shared-bindings/canio/Match.c b/shared-bindings/canio/Match.c index 2265ba8c46..537121e47f 100644 --- a/shared-bindings/canio/Match.c +++ b/shared-bindings/canio/Match.c @@ -57,11 +57,11 @@ STATIC mp_obj_t canio_match_make_new(const mp_obj_type_t *type, size_t n_args, s int mask = args[ARG_mask].u_obj == mp_const_none ? id_bits : mp_obj_get_int(args[ARG_mask].u_obj); if (id & ~id_bits) { - mp_raise_ValueError_varg(translate("%q out of range"), MP_QSTR_id); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q out of range"), MP_QSTR_id); } if (mask & ~id_bits) { - mp_raise_ValueError_varg(translate("%q out of range"), MP_QSTR_mask); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q out of range"), MP_QSTR_mask); } canio_match_obj_t *self = mp_obj_malloc(canio_match_obj_t, &canio_match_type); diff --git a/shared-bindings/canio/RemoteTransmissionRequest.c b/shared-bindings/canio/RemoteTransmissionRequest.c index 22eb2c5bc7..a60463b665 100644 --- a/shared-bindings/canio/RemoteTransmissionRequest.c +++ b/shared-bindings/canio/RemoteTransmissionRequest.c @@ -55,7 +55,7 @@ STATIC mp_obj_t canio_remote_transmission_request_make_new(const mp_obj_type_t * int length = args[ARG_length].u_int; if (length < 0 || length > 8) { - mp_raise_ValueError(translate("RemoteTransmissionRequests limited to 8 bytes")); + mp_raise_ValueError(MP_ERROR_TEXT("RemoteTransmissionRequests limited to 8 bytes")); } canio_remote_transmission_request_obj_t *self = @@ -117,7 +117,7 @@ STATIC mp_obj_t canio_remote_transmission_request_length_set(const mp_obj_t self canio_remote_transmission_request_obj_t *self = self_in; int length = mp_obj_get_int(length_in); if (length < 0 || length > 8) { - mp_raise_ValueError(translate("RemoteTransmissionRequests limited to 8 bytes")); + mp_raise_ValueError(MP_ERROR_TEXT("RemoteTransmissionRequests limited to 8 bytes")); } common_hal_canio_remote_transmission_request_set_length(self, length); return mp_const_none; diff --git a/shared-bindings/digitalio/DigitalInOut.c b/shared-bindings/digitalio/DigitalInOut.c index c73d552855..af996e538b 100644 --- a/shared-bindings/digitalio/DigitalInOut.c +++ b/shared-bindings/digitalio/DigitalInOut.c @@ -51,18 +51,18 @@ STATIC void check_result(digitalinout_result_t result) { case DIGITALINOUT_OK: return; case DIGITALINOUT_PIN_BUSY: - mp_raise_ValueError_varg(translate("%q in use"), MP_QSTR_Pin); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q in use"), MP_QSTR_Pin); #if CIRCUITPY_DIGITALIO_HAVE_INPUT_ONLY case DIGITALINOUT_INPUT_ONLY: - mp_raise_ValueError_varg(translate("Invalid %q"), MP_QSTR_direction); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Invalid %q"), MP_QSTR_direction); #endif #if CIRCUITPY_DIGITALIO_HAVE_INVALID_PULL case DIGITALINOUT_INVALID_PULL: - mp_raise_ValueError_varg(translate("Invalid %q"), MP_QSTR_pull); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Invalid %q"), MP_QSTR_pull); #endif #if CIRCUITPY_DIGITALIO_HAVE_INVALID_DRIVE_MODE case DIGITALINOUT_INVALID_DRIVE_MODE: - mp_raise_ValueError_varg(translate("Invalid %q"), MP_QSTR_drive_mode); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Invalid %q"), MP_QSTR_drive_mode); #endif } } @@ -247,7 +247,7 @@ STATIC mp_obj_t digitalio_digitalinout_obj_set_value(mp_obj_t self_in, mp_obj_t digitalio_digitalinout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); if (common_hal_digitalio_digitalinout_get_direction(self) == DIRECTION_INPUT) { - mp_raise_AttributeError(translate("Cannot set value when direction is input.")); + mp_raise_AttributeError(MP_ERROR_TEXT("Cannot set value when direction is input.")); return mp_const_none; } common_hal_digitalio_digitalinout_set_value(self, mp_obj_is_true(value)); @@ -268,7 +268,7 @@ STATIC mp_obj_t digitalio_digitalinout_obj_get_drive_mode(mp_obj_t self_in) { digitalio_digitalinout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); if (common_hal_digitalio_digitalinout_get_direction(self) == DIRECTION_INPUT) { - mp_raise_AttributeError(translate("Drive mode not used when direction is input.")); + mp_raise_AttributeError(MP_ERROR_TEXT("Drive mode not used when direction is input.")); return mp_const_none; } digitalio_drive_mode_t drive_mode = common_hal_digitalio_digitalinout_get_drive_mode(self); @@ -283,7 +283,7 @@ STATIC mp_obj_t digitalio_digitalinout_obj_set_drive_mode(mp_obj_t self_in, mp_o digitalio_digitalinout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); if (common_hal_digitalio_digitalinout_get_direction(self) == DIRECTION_INPUT) { - mp_raise_AttributeError(translate("Drive mode not used when direction is input.")); + mp_raise_AttributeError(MP_ERROR_TEXT("Drive mode not used when direction is input.")); return mp_const_none; } digitalio_drive_mode_t c_drive_mode = DRIVE_MODE_PUSH_PULL; @@ -312,7 +312,7 @@ STATIC mp_obj_t digitalio_digitalinout_obj_get_pull(mp_obj_t self_in) { digitalio_digitalinout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); if (common_hal_digitalio_digitalinout_get_direction(self) == DIRECTION_OUTPUT) { - mp_raise_AttributeError(translate("Pull not used when direction is output.")); + mp_raise_AttributeError(MP_ERROR_TEXT("Pull not used when direction is output.")); return mp_const_none; } digitalio_pull_t pull = common_hal_digitalio_digitalinout_get_pull(self); @@ -329,7 +329,7 @@ STATIC mp_obj_t digitalio_digitalinout_obj_set_pull(mp_obj_t self_in, mp_obj_t p digitalio_digitalinout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); if (common_hal_digitalio_digitalinout_get_direction(self) == DIRECTION_OUTPUT) { - mp_raise_AttributeError(translate("Pull not used when direction is output.")); + mp_raise_AttributeError(MP_ERROR_TEXT("Pull not used when direction is output.")); return mp_const_none; } @@ -370,7 +370,7 @@ MP_DEFINE_CONST_OBJ_TYPE( // Helper for validating digitalio.DigitalInOut arguments digitalio_digitalinout_obj_t *assert_digitalinout(mp_obj_t obj) { if (!mp_obj_is_type(obj, &digitalio_digitalinout_type)) { - mp_raise_TypeError(translate("argument num/types mismatch")); + mp_raise_TypeError(MP_ERROR_TEXT("argument num/types mismatch")); } digitalio_digitalinout_obj_t *pin = MP_OBJ_TO_PTR(obj); check_for_deinit(pin); diff --git a/shared-bindings/digitalio/Pull.c b/shared-bindings/digitalio/Pull.c index 3be38ef78c..a8cce81a33 100644 --- a/shared-bindings/digitalio/Pull.c +++ b/shared-bindings/digitalio/Pull.c @@ -83,5 +83,5 @@ digitalio_pull_t validate_pull(mp_rom_obj_t obj, qstr arg_name) { if (obj == MP_ROM_NONE) { return PULL_NONE; } - mp_raise_TypeError_varg(translate("%q must be of type %q or %q, not %q"), arg_name, MP_QSTR_Pull, MP_QSTR_None, mp_obj_get_type(obj)->name); + mp_raise_TypeError_varg(MP_ERROR_TEXT("%q must be of type %q or %q, not %q"), arg_name, MP_QSTR_Pull, MP_QSTR_None, mp_obj_get_type(obj)->name); } diff --git a/shared-bindings/displayio/Bitmap.c b/shared-bindings/displayio/Bitmap.c index 3d0479c612..116d82c498 100644 --- a/shared-bindings/displayio/Bitmap.c +++ b/shared-bindings/displayio/Bitmap.c @@ -150,7 +150,7 @@ MP_PROPERTY_GETTER(displayio_bitmap_bits_per_value_obj, STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value_obj) { if (value_obj == mp_const_none) { // delete item - mp_raise_AttributeError(translate("Cannot delete values")); + mp_raise_AttributeError(MP_ERROR_TEXT("Cannot delete values")); return mp_const_none; } @@ -159,7 +159,7 @@ STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t val if (mp_obj_is_type(index_obj, &mp_type_slice)) { // TODO(tannewt): Implement subscr after slices support start, stop and step tuples. - mp_raise_NotImplementedError(translate("Slices not supported")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("Slices not supported")); return mp_const_none; } @@ -169,7 +169,7 @@ STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t val mp_int_t i = MP_OBJ_SMALL_INT_VALUE(index_obj); int total_length = self->width * self->height; if (i < 0 || i >= total_length) { - mp_raise_IndexError_varg(translate("%q must be %d-%d"), MP_QSTR_index, 0, total_length - 1); + mp_raise_IndexError_varg(MP_ERROR_TEXT("%q must be %d-%d"), MP_QSTR_index, 0, total_length - 1); } x = i % self->width; @@ -179,11 +179,11 @@ STATIC mp_obj_t bitmap_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t val mp_obj_get_array_fixed_n(index_obj, 2, &items); mp_int_t x_in = mp_obj_get_int(items[0]); if (x_in < 0 || x_in >= self->width) { - mp_raise_IndexError_varg(translate("%q must be %d-%d"), MP_QSTR_x, 0, self->width - 1); + mp_raise_IndexError_varg(MP_ERROR_TEXT("%q must be %d-%d"), MP_QSTR_x, 0, self->width - 1); } mp_int_t y_in = mp_obj_get_int(items[1]); if (y_in < 0 || y_in >= self->height) { - mp_raise_IndexError_varg(translate("%q must be %d-%d"), MP_QSTR_y, 0, self->height - 1); + mp_raise_IndexError_varg(MP_ERROR_TEXT("%q must be %d-%d"), MP_QSTR_y, 0, self->height - 1); } x = x_in; y = y_in; diff --git a/shared-bindings/displayio/Group.c b/shared-bindings/displayio/Group.c index 3253a6adee..111cf41cdf 100644 --- a/shared-bindings/displayio/Group.c +++ b/shared-bindings/displayio/Group.c @@ -67,7 +67,7 @@ STATIC mp_obj_t displayio_group_make_new(const mp_obj_type_t *type, size_t n_arg displayio_group_t *native_group(mp_obj_t group_obj) { mp_obj_t native_group = mp_obj_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); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Must be a %q subclass."), MP_QSTR_Group); } mp_obj_assert_native_inited(native_group); return MP_OBJ_TO_PTR(native_group); @@ -201,7 +201,7 @@ STATIC mp_obj_t displayio_group_obj_index(mp_obj_t self_in, mp_obj_t layer) { displayio_group_t *self = native_group(self_in); mp_int_t index = common_hal_displayio_group_index(self, layer); if (index < 0) { - mp_raise_ValueError(translate("object not in sequence")); + mp_raise_ValueError(MP_ERROR_TEXT("object not in sequence")); } return MP_OBJ_NEW_SMALL_INT(index); } @@ -303,7 +303,7 @@ STATIC mp_obj_t group_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t valu displayio_group_t *self = native_group(self_in); if (mp_obj_is_type(index_obj, &mp_type_slice)) { - mp_raise_NotImplementedError(translate("Slices not supported")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("Slices not supported")); } else { size_t index = mp_get_index(&displayio_group_type, common_hal_displayio_group_get_len(self), index_obj, false); diff --git a/shared-bindings/displayio/OnDiskBitmap.c b/shared-bindings/displayio/OnDiskBitmap.c index d608a32d4b..205c70e998 100644 --- a/shared-bindings/displayio/OnDiskBitmap.c +++ b/shared-bindings/displayio/OnDiskBitmap.c @@ -86,7 +86,7 @@ STATIC mp_obj_t displayio_ondiskbitmap_make_new(const mp_obj_type_t *type, size_ arg = mp_call_function_2(MP_OBJ_FROM_PTR(&mp_builtin_open_obj), arg, MP_ROM_QSTR(MP_QSTR_rb)); } if (!mp_obj_is_type(arg, &mp_type_fileio)) { - mp_raise_TypeError(translate("file must be a file opened in byte mode")); + mp_raise_TypeError(MP_ERROR_TEXT("file must be a file opened in byte mode")); } displayio_ondiskbitmap_t *self = mp_obj_malloc(displayio_ondiskbitmap_t, &displayio_ondiskbitmap_type); diff --git a/shared-bindings/displayio/Palette.c b/shared-bindings/displayio/Palette.c index 4d68c109be..7beaa2ae32 100644 --- a/shared-bindings/displayio/Palette.c +++ b/shared-bindings/displayio/Palette.c @@ -149,21 +149,21 @@ STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t val mp_buffer_info_t bufinfo; if (mp_get_buffer(value, &bufinfo, MP_BUFFER_READ)) { 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'")); + mp_raise_ValueError(MP_ERROR_TEXT("color buffer must be a bytearray or array of type 'b' or 'B'")); } uint8_t *buf = bufinfo.buf; if (bufinfo.len == 3 || bufinfo.len == 4) { color = buf[0] << 16 | buf[1] << 8 | buf[2]; } else { - mp_raise_ValueError(translate("color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)")); + mp_raise_ValueError(MP_ERROR_TEXT("color buffer must be 3 bytes (RGB) or 4 bytes (RGB + pad byte)")); } } else if (mp_obj_get_int_maybe(value, &int_value)) { if (int_value < 0 || int_value > 0xffffff) { - mp_raise_TypeError(translate("color must be between 0x000000 and 0xffffff")); + mp_raise_TypeError(MP_ERROR_TEXT("color must be between 0x000000 and 0xffffff")); } color = int_value; } else { - mp_raise_TypeError(translate("color buffer must be a buffer, tuple, list, or int")); + mp_raise_TypeError(MP_ERROR_TEXT("color buffer must be a buffer, tuple, list, or int")); } common_hal_displayio_palette_set_color(self, index, color); return mp_const_none; diff --git a/shared-bindings/displayio/TileGrid.c b/shared-bindings/displayio/TileGrid.c index f7a47474bc..7675319593 100644 --- a/shared-bindings/displayio/TileGrid.c +++ b/shared-bindings/displayio/TileGrid.c @@ -105,12 +105,12 @@ STATIC mp_obj_t displayio_tilegrid_make_new(const mp_obj_type_t *type, size_t n_ bitmap_width = bmp->width; bitmap_height = bmp->height; } else { - mp_raise_TypeError_varg(translate("unsupported %q type"), MP_QSTR_bitmap); + mp_raise_TypeError_varg(MP_ERROR_TEXT("unsupported %q type"), MP_QSTR_bitmap); } mp_obj_t pixel_shader = args[ARG_pixel_shader].u_obj; if (!mp_obj_is_type(pixel_shader, &displayio_colorconverter_type) && !mp_obj_is_type(pixel_shader, &displayio_palette_type)) { - mp_raise_TypeError_varg(translate("unsupported %q type"), MP_QSTR_pixel_shader); + mp_raise_TypeError_varg(MP_ERROR_TEXT("unsupported %q type"), MP_QSTR_pixel_shader); } uint16_t tile_width = args[ARG_tile_width].u_int; if (tile_width == 0) { @@ -121,10 +121,10 @@ STATIC mp_obj_t displayio_tilegrid_make_new(const mp_obj_type_t *type, size_t n_ tile_height = bitmap_height; } if (bitmap_width % tile_width != 0) { - mp_raise_ValueError(translate("Tile width must exactly divide bitmap width")); + mp_raise_ValueError(MP_ERROR_TEXT("Tile width must exactly divide bitmap width")); } if (bitmap_height % tile_height != 0) { - mp_raise_ValueError(translate("Tile height must exactly divide bitmap height")); + mp_raise_ValueError(MP_ERROR_TEXT("Tile height must exactly divide bitmap height")); } int16_t x = args[ARG_x].u_int; @@ -341,7 +341,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(displayio_tilegrid_get_pixel_shader_obj, displayio_til STATIC mp_obj_t displayio_tilegrid_obj_set_pixel_shader(mp_obj_t self_in, mp_obj_t pixel_shader) { displayio_tilegrid_t *self = native_tilegrid(self_in); if (!mp_obj_is_type(pixel_shader, &displayio_palette_type) && !mp_obj_is_type(pixel_shader, &displayio_colorconverter_type)) { - mp_raise_TypeError_varg(translate("unsupported %q type"), MP_QSTR_pixel_shader); + mp_raise_TypeError_varg(MP_ERROR_TEXT("unsupported %q type"), MP_QSTR_pixel_shader); } common_hal_displayio_tilegrid_set_pixel_shader(self, pixel_shader); @@ -376,18 +376,18 @@ STATIC mp_obj_t displayio_tilegrid_obj_set_bitmap(mp_obj_t self_in, mp_obj_t bit new_bitmap_width = bmp->width; new_bitmap_height = bmp->height; } else { - mp_raise_TypeError_varg(translate("unsupported %q type"), MP_QSTR_bitmap); + mp_raise_TypeError_varg(MP_ERROR_TEXT("unsupported %q type"), MP_QSTR_bitmap); } if (mp_obj_is_type(self->bitmap, &displayio_bitmap_type)) { displayio_bitmap_t *old_bmp = MP_OBJ_TO_PTR(self->bitmap); if (old_bmp->width != new_bitmap_width || old_bmp->height != new_bitmap_height) { - mp_raise_ValueError(translate("New bitmap must be same size as old bitmap")); + mp_raise_ValueError(MP_ERROR_TEXT("New bitmap must be same size as old bitmap")); } } else if (mp_obj_is_type(self->bitmap, &displayio_ondiskbitmap_type)) { displayio_ondiskbitmap_t *old_bmp = MP_OBJ_TO_PTR(self->bitmap); if (old_bmp->width != new_bitmap_width || old_bmp->height != new_bitmap_height) { - mp_raise_ValueError(translate("New bitmap must be same size as old bitmap")); + mp_raise_ValueError(MP_ERROR_TEXT("New bitmap must be same size as old bitmap")); } } @@ -427,7 +427,7 @@ STATIC mp_obj_t tilegrid_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t v if (mp_obj_is_type(index_obj, &mp_type_slice)) { - mp_raise_NotImplementedError(translate("Slices not supported")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("Slices not supported")); } else { uint16_t x = 0; uint16_t y = 0; @@ -444,7 +444,7 @@ STATIC mp_obj_t tilegrid_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t v } if (x >= common_hal_displayio_tilegrid_get_width(self) || y >= common_hal_displayio_tilegrid_get_height(self)) { - mp_raise_IndexError(translate("Tile index out of bounds")); + mp_raise_IndexError(MP_ERROR_TEXT("Tile index out of bounds")); } if (value_obj == MP_OBJ_SENTINEL) { diff --git a/shared-bindings/dualbank/__init__.c b/shared-bindings/dualbank/__init__.c index 0bb095ddac..31cdd741b8 100644 --- a/shared-bindings/dualbank/__init__.c +++ b/shared-bindings/dualbank/__init__.c @@ -70,7 +70,7 @@ #if CIRCUITPY_STORAGE_EXTEND STATIC void raise_error_if_storage_extended(void) { if (supervisor_flash_get_extended()) { - mp_raise_msg_varg(&mp_type_RuntimeError, translate("%q is %q"), MP_QSTR_storage, MP_QSTR_extended); + mp_raise_msg_varg(&mp_type_RuntimeError, MP_ERROR_TEXT("%q is %q"), MP_QSTR_storage, MP_QSTR_extended); } } #endif @@ -100,7 +100,7 @@ STATIC mp_obj_t dualbank_flash(size_t n_args, const mp_obj_t *pos_args, mp_map_t mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); if (args[ARG_offset].u_int < 0) { - mp_raise_ValueError(translate("offset must be >= 0")); + mp_raise_ValueError(MP_ERROR_TEXT("offset must be >= 0")); } mp_buffer_info_t bufinfo; diff --git a/shared-bindings/epaperdisplay/EPaperDisplay.c b/shared-bindings/epaperdisplay/EPaperDisplay.c index 15806be253..0770c329c7 100644 --- a/shared-bindings/epaperdisplay/EPaperDisplay.c +++ b/shared-bindings/epaperdisplay/EPaperDisplay.c @@ -183,7 +183,7 @@ STATIC mp_obj_t epaperdisplay_epaperdisplay_make_new(const mp_obj_type_t *type, mp_int_t rotation = args[ARG_rotation].u_int; if (rotation % 90 != 0) { - mp_raise_ValueError(translate("Display rotation must be in 90 degree increments")); + mp_raise_ValueError(MP_ERROR_TEXT("Display rotation must be in 90 degree increments")); } primary_display_t *disp = allocate_display_or_raise(); @@ -217,7 +217,7 @@ STATIC mp_obj_t epaperdisplay_epaperdisplay_make_new(const mp_obj_type_t *type, refresh_buf = refresh_bufinfo.buf; refresh_buf_len = refresh_bufinfo.len; } else { - mp_raise_ValueError_varg(translate("Invalid %q"), MP_QSTR_refresh_display_command); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Invalid %q"), MP_QSTR_refresh_display_command); } self->base.type = &epaperdisplay_epaperdisplay_type; @@ -248,7 +248,7 @@ static epaperdisplay_epaperdisplay_obj_t *native_display(mp_obj_t display_obj) { // Undocumented show() implementation with a friendly error message. STATIC mp_obj_t epaperdisplay_epaperdisplay_obj_show(mp_obj_t self_in, mp_obj_t group_in) { - mp_raise_AttributeError(translate(".show(x) removed. Use .root_group = x")); + mp_raise_AttributeError(MP_ERROR_TEXT(".show(x) removed. Use .root_group = x")); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_2(epaperdisplay_epaperdisplay_show_obj, epaperdisplay_epaperdisplay_obj_show); @@ -287,7 +287,7 @@ STATIC mp_obj_t epaperdisplay_epaperdisplay_obj_refresh(mp_obj_t self_in) { epaperdisplay_epaperdisplay_obj_t *self = native_display(self_in); bool ok = common_hal_epaperdisplay_epaperdisplay_refresh(self); if (!ok) { - mp_raise_RuntimeError(translate("Refresh too soon")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Refresh too soon")); } return mp_const_none; } diff --git a/shared-bindings/floppyio/__init__.c b/shared-bindings/floppyio/__init__.c index 86c5813bdc..fa45cd53a8 100644 --- a/shared-bindings/floppyio/__init__.c +++ b/shared-bindings/floppyio/__init__.c @@ -104,7 +104,7 @@ STATIC mp_obj_t floppyio_mfm_readinto(size_t n_args, const mp_obj_t *pos_args, m digitalio_digitalinout_obj_t *index = assert_digitalinout(args[ARG_index].u_obj); if (bufinfo.len % 512 != 0) { - mp_raise_ValueError(translate("Buffer must be a multiple of 512 bytes")); + mp_raise_ValueError(MP_ERROR_TEXT("Buffer must be a multiple of 512 bytes")); } size_t n_sectors = bufinfo.len / 512; return MP_OBJ_NEW_SMALL_INT(common_hal_floppyio_mfm_readinto(bufinfo.buf, n_sectors, data, index)); diff --git a/shared-bindings/fourwire/FourWire.c b/shared-bindings/fourwire/FourWire.c index 23c032ff31..86ce13d36e 100644 --- a/shared-bindings/fourwire/FourWire.c +++ b/shared-bindings/fourwire/FourWire.c @@ -113,7 +113,7 @@ STATIC mp_obj_t fourwire_fourwire_obj_reset(mp_obj_t self_in) { fourwire_fourwire_obj_t *self = self_in; if (!common_hal_fourwire_fourwire_reset(self)) { - mp_raise_RuntimeError_varg(translate("No %q pin"), MP_QSTR_reset); + mp_raise_RuntimeError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_reset); } return mp_const_none; } diff --git a/shared-bindings/framebufferio/FramebufferDisplay.c b/shared-bindings/framebufferio/FramebufferDisplay.c index 03019e739a..3e0c75cd74 100644 --- a/shared-bindings/framebufferio/FramebufferDisplay.c +++ b/shared-bindings/framebufferio/FramebufferDisplay.c @@ -75,7 +75,7 @@ STATIC mp_obj_t framebufferio_framebufferdisplay_make_new(const mp_obj_type_t *t mp_int_t rotation = args[ARG_rotation].u_int; if (rotation % 90 != 0) { - mp_raise_ValueError(translate("Display rotation must be in 90 degree increments")); + mp_raise_ValueError(MP_ERROR_TEXT("Display rotation must be in 90 degree increments")); } primary_display_t *disp = allocate_display_or_raise(); @@ -100,7 +100,7 @@ static framebufferio_framebufferdisplay_obj_t *native_display(mp_obj_t display_o // Undocumented show() implementation with a friendly error message. STATIC mp_obj_t framebufferio_framebufferdisplay_obj_show(mp_obj_t self_in, mp_obj_t group_in) { - mp_raise_AttributeError(translate(".show(x) removed. Use .root_group = x")); + mp_raise_AttributeError(MP_ERROR_TEXT(".show(x) removed. Use .root_group = x")); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_2(framebufferio_framebufferdisplay_show_obj, framebufferio_framebufferdisplay_obj_show); @@ -185,7 +185,7 @@ STATIC mp_obj_t framebufferio_framebufferdisplay_obj_get_brightness(mp_obj_t sel framebufferio_framebufferdisplay_obj_t *self = native_display(self_in); mp_float_t brightness = common_hal_framebufferio_framebufferdisplay_get_brightness(self); if (brightness < 0) { - mp_raise_RuntimeError(translate("Brightness not adjustable")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Brightness not adjustable")); } return mp_obj_new_float(brightness); } @@ -195,11 +195,11 @@ STATIC mp_obj_t framebufferio_framebufferdisplay_obj_set_brightness(mp_obj_t sel framebufferio_framebufferdisplay_obj_t *self = native_display(self_in); mp_float_t brightness = mp_obj_get_float(brightness_obj); if (brightness < 0.0f || brightness > 1.0f) { - mp_raise_ValueError_varg(translate("%q must be %d-%d"), MP_QSTR_brightness, 0, 1); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q must be %d-%d"), MP_QSTR_brightness, 0, 1); } bool ok = common_hal_framebufferio_framebufferdisplay_set_brightness(self, brightness); if (!ok) { - mp_raise_RuntimeError(translate("Brightness not adjustable")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Brightness not adjustable")); } return mp_const_none; } @@ -285,10 +285,10 @@ 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(MP_ERROR_TEXT("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(MP_ERROR_TEXT("Display must have a 16 bit colorspace.")); } displayio_area_t area = { @@ -318,7 +318,7 @@ STATIC mp_obj_t framebufferio_framebufferdisplay_obj_fill_row(size_t n_args, con displayio_display_core_fill_area(&self->core, &area, mask, result_buffer); return result; } else { - mp_raise_ValueError(translate("Buffer too small")); + mp_raise_ValueError(MP_ERROR_TEXT("Buffer too small")); } } MP_DEFINE_CONST_FUN_OBJ_KW(framebufferio_framebufferdisplay_fill_row_obj, 1, framebufferio_framebufferdisplay_obj_fill_row); @@ -344,7 +344,7 @@ STATIC mp_obj_t framebufferio_framebufferdisplay_obj_set_root_group(mp_obj_t sel bool ok = common_hal_framebufferio_framebufferdisplay_set_root_group(self, group); if (!ok) { - mp_raise_ValueError(translate("Group already used")); + mp_raise_ValueError(MP_ERROR_TEXT("Group already used")); } return mp_const_none; } diff --git a/shared-bindings/getpass/__init__.c b/shared-bindings/getpass/__init__.c index d6b65ec945..b6ff97fc78 100644 --- a/shared-bindings/getpass/__init__.c +++ b/shared-bindings/getpass/__init__.c @@ -63,7 +63,7 @@ STATIC mp_obj_t getpass_getpass(size_t n_args, const mp_obj_t *pos_args, mp_map_ print.data = MP_OBJ_TO_PTR(args[ARG_stream].u_obj); print.print_strn = mp_stream_write_adaptor; #else - mp_raise_NotImplementedError(translate("stream operation not supported")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("stream operation not supported")); #endif } diff --git a/shared-bindings/gifio/GifWriter.c b/shared-bindings/gifio/GifWriter.c index a230478bb7..6ce3dea69a 100644 --- a/shared-bindings/gifio/GifWriter.c +++ b/shared-bindings/gifio/GifWriter.c @@ -137,7 +137,7 @@ static mp_obj_t gifio_gifwriter_add_frame(size_t n_args, const mp_obj_t *pos_arg mp_float_t delay = mp_arg_validate_obj_float_non_negative(args[ARG_delay].u_obj, MICROPY_FLOAT_CONST(0.1), MP_QSTR_delay); if (delay > MICROPY_FLOAT_CONST(655.)) { - mp_raise_ValueError_varg(translate("%q must be <= %d"), MP_QSTR_delay, 655); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q must be <= %d"), MP_QSTR_delay, 655); } int delay_centiseconds = (int)(delay * 100); diff --git a/shared-bindings/gifio/OnDiskGif.c b/shared-bindings/gifio/OnDiskGif.c index 1fb75d6245..103c1eb3a5 100644 --- a/shared-bindings/gifio/OnDiskGif.c +++ b/shared-bindings/gifio/OnDiskGif.c @@ -137,7 +137,7 @@ STATIC mp_obj_t gifio_ondiskgif_make_new(const mp_obj_type_t *type, size_t n_arg } if (!mp_obj_is_type(filename, &mp_type_fileio)) { - mp_raise_TypeError(translate("file must be a file opened in byte mode")); + mp_raise_TypeError(MP_ERROR_TEXT("file must be a file opened in byte mode")); } gifio_ondiskgif_t *self = mp_obj_malloc(gifio_ondiskgif_t, &gifio_ondiskgif_type); diff --git a/shared-bindings/gnss/GNSS.c b/shared-bindings/gnss/GNSS.c index 07962a682e..75093e7b55 100644 --- a/shared-bindings/gnss/GNSS.c +++ b/shared-bindings/gnss/GNSS.c @@ -54,12 +54,12 @@ STATIC mp_obj_t gnss_make_new(const mp_obj_type_t *type, size_t n_args, size_t n mp_obj_list_get(args[ARG_system].u_obj, &systems_size, &systems); for (size_t i = 0; i < systems_size; ++i) { if (!mp_obj_is_type(systems[i], &gnss_satellitesystem_type)) { - mp_raise_TypeError(translate("System entry must be gnss.SatelliteSystem")); + mp_raise_TypeError(MP_ERROR_TEXT("System entry must be gnss.SatelliteSystem")); } selection |= gnss_satellitesystem_obj_to_type(systems[i]); } } else { - mp_raise_TypeError(translate("System entry must be gnss.SatelliteSystem")); + mp_raise_TypeError(MP_ERROR_TEXT("System entry must be gnss.SatelliteSystem")); } common_hal_gnss_construct(self, selection); diff --git a/shared-bindings/hashlib/__init__.c b/shared-bindings/hashlib/__init__.c index 4179926ea5..cf0f3c3c36 100644 --- a/shared-bindings/hashlib/__init__.c +++ b/shared-bindings/hashlib/__init__.c @@ -59,7 +59,7 @@ STATIC mp_obj_t hashlib_new(size_t n_args, const mp_obj_t *pos_args, mp_map_t *k hashlib_hash_obj_t *self = mp_obj_malloc(hashlib_hash_obj_t, &hashlib_hash_type); if (!common_hal_hashlib_new(self, algorithm)) { - mp_raise_ValueError(translate("Unsupported hash algorithm")); + mp_raise_ValueError(MP_ERROR_TEXT("Unsupported hash algorithm")); } if (args[ARG_data].u_obj != mp_const_none) { diff --git a/shared-bindings/i2cdisplaybus/I2CDisplayBus.c b/shared-bindings/i2cdisplaybus/I2CDisplayBus.c index 2d8b003938..bd9d2154c0 100644 --- a/shared-bindings/i2cdisplaybus/I2CDisplayBus.c +++ b/shared-bindings/i2cdisplaybus/I2CDisplayBus.c @@ -90,7 +90,7 @@ STATIC mp_obj_t i2cdisplaybus_i2cdisplaybus_obj_reset(mp_obj_t self_in) { i2cdisplaybus_i2cdisplaybus_obj_t *self = self_in; if (!common_hal_i2cdisplaybus_i2cdisplaybus_reset(self)) { - mp_raise_RuntimeError_varg(translate("No %q pin"), MP_QSTR_reset); + mp_raise_RuntimeError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_reset); } return mp_const_none; } diff --git a/shared-bindings/i2ctarget/I2CTarget.c b/shared-bindings/i2ctarget/I2CTarget.c index 79d234c5dc..582242a332 100644 --- a/shared-bindings/i2ctarget/I2CTarget.c +++ b/shared-bindings/i2ctarget/I2CTarget.c @@ -94,7 +94,7 @@ STATIC mp_obj_t i2ctarget_i2c_target_make_new(const mp_obj_type_t *type, size_t addresses[i++] = value; } if (i == 0) { - mp_raise_ValueError(translate("addresses is empty")); + mp_raise_ValueError(MP_ERROR_TEXT("addresses is empty")); } common_hal_i2ctarget_i2c_target_construct(self, scl, sda, addresses, i, args[ARG_smbus].u_bool); diff --git a/shared-bindings/ipaddress/IPv4Address.c b/shared-bindings/ipaddress/IPv4Address.c index 95a683e94d..05c0289209 100644 --- a/shared-bindings/ipaddress/IPv4Address.c +++ b/shared-bindings/ipaddress/IPv4Address.c @@ -63,14 +63,14 @@ STATIC mp_obj_t ipaddress_ipv4address_make_new(const mp_obj_type_t *type, size_t } 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)) { - mp_raise_ValueError(translate("Not a valid IP string")); + mp_raise_ValueError(MP_ERROR_TEXT("Not a valid IP string")); } buf = (uint8_t *)&value; } else { mp_buffer_info_t buf_info; if (mp_get_buffer(address, &buf_info, MP_BUFFER_READ)) { if (buf_info.len != 4) { - mp_raise_ValueError_varg(translate("Address must be %d bytes long"), 4); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Address must be %d bytes long"), 4); } buf = buf_info.buf; } diff --git a/shared-bindings/ipaddress/__init__.c b/shared-bindings/ipaddress/__init__.c index eb2b8f8ff6..6c97e6d793 100644 --- a/shared-bindings/ipaddress/__init__.c +++ b/shared-bindings/ipaddress/__init__.c @@ -88,10 +88,10 @@ STATIC mp_obj_t ipaddress_ip_address(mp_obj_t ip_in) { } 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)) { - mp_raise_ValueError(translate("Not a valid IP string")); + mp_raise_ValueError(MP_ERROR_TEXT("Not a valid IP string")); } } else { - mp_raise_ValueError(translate("Only int or string supported for ip")); + mp_raise_ValueError(MP_ERROR_TEXT("Only int or string supported for ip")); } return common_hal_ipaddress_new_ipv4address(value); diff --git a/shared-bindings/is31fl3741/FrameBuffer.c b/shared-bindings/is31fl3741/FrameBuffer.c index 5804707228..5f7a60f051 100644 --- a/shared-bindings/is31fl3741/FrameBuffer.c +++ b/shared-bindings/is31fl3741/FrameBuffer.c @@ -89,13 +89,13 @@ STATIC mp_obj_t is31fl3741_FrameBuffer_make_new(const mp_obj_type_t *type, size_ self->base.type = &is31fl3741_FrameBuffer_type; if (args[ARG_width].u_int <= 0) { - mp_raise_ValueError(translate("width must be greater than zero")); + mp_raise_ValueError(MP_ERROR_TEXT("width must be greater than zero")); } self->scale = args[ARG_scale].u_bool; if (self->scale) { if (((args[ARG_height].u_int % 3) != 0) || ((args[ARG_width].u_int % 3) != 0)) { - mp_raise_ValueError(translate("Scale dimensions must divide by 3")); + mp_raise_ValueError(MP_ERROR_TEXT("Scale dimensions must divide by 3")); } self->scale_width = args[ARG_width].u_int / 3; @@ -162,7 +162,7 @@ STATIC mp_obj_t is31fl3741_FrameBuffer_set_brightness(mp_obj_t self_in, mp_obj_t check_for_deinit(self); mp_float_t brightness = mp_obj_get_float(value_in); if (brightness < 0.0f || brightness > 1.0f) { - mp_raise_ValueError_varg(translate("%q must be %d-%d"), MP_QSTR_brightness, 0, 1); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q must be %d-%d"), MP_QSTR_brightness, 0, 1); } uint8_t current = (uint8_t)(brightness * 0xFF); diff --git a/shared-bindings/is31fl3741/IS31FL3741.c b/shared-bindings/is31fl3741/IS31FL3741.c index 6debc82dc5..ef04467475 100644 --- a/shared-bindings/is31fl3741/IS31FL3741.c +++ b/shared-bindings/is31fl3741/IS31FL3741.c @@ -147,7 +147,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(is31fl3741_IS31FL3741_set_led_obj, 4, 4, is3 STATIC mp_obj_t is31fl3741_IS31FL3741_write(mp_obj_t self_in, mp_obj_t mapping, mp_obj_t buffer) { is31fl3741_IS31FL3741_obj_t *self = MP_OBJ_TO_PTR(self_in); if (!mp_obj_is_tuple_compatible(mapping)) { - mp_raise_ValueError(translate("Mapping must be a tuple")); + mp_raise_ValueError(MP_ERROR_TEXT("Mapping must be a tuple")); } mp_obj_t *map_items; diff --git a/shared-bindings/keypad/KeyMatrix.c b/shared-bindings/keypad/KeyMatrix.c index 21f83c5e8e..d035f2d6d7 100644 --- a/shared-bindings/keypad/KeyMatrix.c +++ b/shared-bindings/keypad/KeyMatrix.c @@ -130,7 +130,7 @@ STATIC mp_obj_t keypad_keymatrix_make_new(const mp_obj_type_t *type, size_t n_ar common_hal_keypad_keymatrix_construct(self, num_row_pins, row_pins_array, num_column_pins, column_pins_array, args[ARG_columns_to_anodes].u_bool, interval, max_events); return MP_OBJ_FROM_PTR(self); #else - mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_KeyMatrix); + mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_KeyMatrix); #endif } diff --git a/shared-bindings/keypad/Keys.c b/shared-bindings/keypad/Keys.c index ff6052e271..94a8b76da0 100644 --- a/shared-bindings/keypad/Keys.c +++ b/shared-bindings/keypad/Keys.c @@ -122,7 +122,7 @@ STATIC mp_obj_t keypad_keys_make_new(const mp_obj_type_t *type, size_t n_args, s return MP_OBJ_FROM_PTR(self); #else - mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_Keys); + mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_Keys); #endif } diff --git a/shared-bindings/keypad/ShiftRegisterKeys.c b/shared-bindings/keypad/ShiftRegisterKeys.c index e9df19e324..872f270847 100644 --- a/shared-bindings/keypad/ShiftRegisterKeys.c +++ b/shared-bindings/keypad/ShiftRegisterKeys.c @@ -175,7 +175,7 @@ STATIC mp_obj_t keypad_shiftregisterkeys_make_new(const mp_obj_type_t *type, siz return MP_OBJ_FROM_PTR(self); #else - mp_raise_NotImplementedError_varg(translate("%q"), MP_QSTR_ShiftRegisterKeys); + mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q"), MP_QSTR_ShiftRegisterKeys); #endif } diff --git a/shared-bindings/math/__init__.c b/shared-bindings/math/__init__.c index 1ab07170f3..93af53769d 100644 --- a/shared-bindings/math/__init__.c +++ b/shared-bindings/math/__init__.c @@ -46,7 +46,7 @@ //| """ STATIC NORETURN void math_error(void) { - mp_raise_ValueError(translate("math domain error")); + mp_raise_ValueError(MP_ERROR_TEXT("math domain error")); } #define MATH_FUN_1(py_name, c_name) \ diff --git a/shared-bindings/memorymap/AddressRange.c b/shared-bindings/memorymap/AddressRange.c index 9df36db665..0915f9d270 100644 --- a/shared-bindings/memorymap/AddressRange.c +++ b/shared-bindings/memorymap/AddressRange.c @@ -103,7 +103,7 @@ STATIC mp_obj_t memorymap_addressrange_make_new(const mp_obj_type_t *type, size_ mp_arg_validate_int_min(args[ARG_length].u_int, 1, MP_QSTR_length); // Check for address range wrap here as this can break port-specific code due to size_t overflow. if (start + length - 1 < start) { - mp_raise_ValueError(translate("Address range wraps around")); + mp_raise_ValueError(MP_ERROR_TEXT("Address range wraps around")); } memorymap_addressrange_obj_t *self = mp_obj_malloc(memorymap_addressrange_obj_t, &memorymap_addressrange_type); @@ -168,7 +168,7 @@ STATIC mp_obj_t memorymap_addressrange_subscr(mp_obj_t self_in, mp_obj_t index_i } 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_memorymap_addressrange_get_length(self), index_in, &slice)) { - mp_raise_NotImplementedError(translate("only slices with step=1 (aka None) are supported")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("only slices with step=1 (aka None) are supported")); } if (value != MP_OBJ_SENTINEL) { #if MICROPY_PY_ARRAY_SLICE_ASSIGN @@ -182,15 +182,15 @@ STATIC mp_obj_t memorymap_addressrange_subscr(mp_obj_t self_in, mp_obj_t index_i mp_buffer_info_t bufinfo; mp_get_buffer_raise(value, &bufinfo, MP_BUFFER_READ); if (bufinfo.len != src_len) { - mp_raise_ValueError(translate("Slice and value different lengths.")); + mp_raise_ValueError(MP_ERROR_TEXT("Slice and value different lengths.")); } src_len = bufinfo.len; src_items = bufinfo.buf; if (1 != mp_binary_get_size('@', bufinfo.typecode, NULL)) { - mp_raise_ValueError(translate("Array values should be single bytes.")); + mp_raise_ValueError(MP_ERROR_TEXT("Array values should be single bytes.")); } } else { - mp_raise_NotImplementedError(translate("array/bytes required on right side")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("array/bytes required on right side")); } common_hal_memorymap_addressrange_set_bytes(self, slice.start, src_items, src_len); diff --git a/shared-bindings/memorymonitor/AllocationSize.c b/shared-bindings/memorymonitor/AllocationSize.c index 449f8d825c..0b3bc353ce 100644 --- a/shared-bindings/memorymonitor/AllocationSize.c +++ b/shared-bindings/memorymonitor/AllocationSize.c @@ -135,19 +135,19 @@ STATIC mp_obj_t memorymonitor_allocationsize_unary_op(mp_unary_op_t op, mp_obj_t STATIC mp_obj_t memorymonitor_allocationsize_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value) { if (value == mp_const_none) { // delete item - mp_raise_AttributeError(translate("Cannot delete values")); + mp_raise_AttributeError(MP_ERROR_TEXT("Cannot delete values")); } else { memorymonitor_allocationsize_obj_t *self = MP_OBJ_TO_PTR(self_in); if (mp_obj_is_type(index_obj, &mp_type_slice)) { - mp_raise_NotImplementedError(translate("Slices not supported")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("Slices not supported")); } else { size_t index = mp_get_index(&memorymonitor_allocationsize_type, common_hal_memorymonitor_allocationsize_get_len(self), index_obj, false); if (value == MP_OBJ_SENTINEL) { // load return MP_OBJ_NEW_SMALL_INT(common_hal_memorymonitor_allocationsize_get_item(self, index)); } else { - mp_raise_AttributeError(translate("Read-only")); + mp_raise_AttributeError(MP_ERROR_TEXT("Read-only")); } } } diff --git a/shared-bindings/microcontroller/Pin.c b/shared-bindings/microcontroller/Pin.c index 8472414550..354c4e8270 100644 --- a/shared-bindings/microcontroller/Pin.c +++ b/shared-bindings/microcontroller/Pin.c @@ -125,7 +125,7 @@ void validate_no_duplicate_pins(mp_obj_t seq, qstr arg_name) { mp_obj_t pin2_obj = mp_obj_subscr(seq, MP_OBJ_NEW_SMALL_INT(pin_cnt_2), MP_OBJ_SENTINEL); const mcu_pin_obj_t *pin2 = validate_obj_is_pin_in(pin2_obj, arg_name); if (pin1 == pin2) { - mp_raise_TypeError_varg(translate("%q contains duplicate pins"), arg_name); + mp_raise_TypeError_varg(MP_ERROR_TEXT("%q contains duplicate pins"), arg_name); } } } @@ -146,7 +146,7 @@ void validate_no_duplicate_pins_2(mp_obj_t seq1, mp_obj_t seq2, qstr arg_name1, mp_obj_t pin2_obj = mp_obj_subscr(seq2, MP_OBJ_NEW_SMALL_INT(pin_cnt_2), MP_OBJ_SENTINEL); const mcu_pin_obj_t *pin2 = validate_obj_is_pin_in(pin2_obj, arg_name2); if (pin1 == pin2) { - mp_raise_TypeError_varg(translate("%q and %q contain duplicate pins"), arg_name1, arg_name2); + mp_raise_TypeError_varg(MP_ERROR_TEXT("%q and %q contain duplicate pins"), arg_name1, arg_name2); } } } @@ -181,7 +181,7 @@ void assert_pin_free(const mcu_pin_obj_t *pin) { qstr name = MP_QSTR_Pin; get_pin_name(pin, &package, &module, &name); - mp_raise_ValueError_varg(translate("%q in use"), name); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q in use"), name); } } @@ -202,5 +202,5 @@ NORETURN void raise_ValueError_invalid_pins(void) { } NORETURN void raise_ValueError_invalid_pin_name(qstr pin_name) { - mp_raise_ValueError_varg(translate("Invalid %q pin"), pin_name); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Invalid %q pin"), pin_name); } diff --git a/shared-bindings/msgpack/ExtType.c b/shared-bindings/msgpack/ExtType.c index ad8044490a..537aac08fd 100644 --- a/shared-bindings/msgpack/ExtType.c +++ b/shared-bindings/msgpack/ExtType.c @@ -69,7 +69,7 @@ STATIC mp_obj_t mod_msgpack_exttype_set_code(mp_obj_t self_in, mp_obj_t code_in) mod_msgpack_extype_obj_t *self = MP_OBJ_TO_PTR(self_in); int code = mp_obj_get_int(code_in); if (code < 0 || code > 127) { - mp_raise_AttributeError(translate("code outside range 0~127")); + mp_raise_AttributeError(MP_ERROR_TEXT("code outside range 0~127")); } self->code = code; return mp_const_none; diff --git a/shared-bindings/msgpack/__init__.c b/shared-bindings/msgpack/__init__.c index fb4fe63304..a6d7ad737b 100644 --- a/shared-bindings/msgpack/__init__.c +++ b/shared-bindings/msgpack/__init__.c @@ -114,7 +114,7 @@ STATIC mp_obj_t mod_msgpack_pack(size_t n_args, const mp_obj_t *pos_args, mp_map mp_obj_t handler = args[ARG_default].u_obj; if (handler != mp_const_none && !mp_obj_is_fun(handler) && !MP_OBJ_IS_METH(handler)) { - mp_raise_ValueError(translate("default is not a function")); + mp_raise_ValueError(MP_ERROR_TEXT("default is not a function")); } common_hal_msgpack_pack(args[ARG_obj].u_obj, args[ARG_buffer].u_obj, handler); @@ -152,7 +152,7 @@ STATIC mp_obj_t mod_msgpack_unpack(size_t n_args, const mp_obj_t *pos_args, mp_m mp_obj_t hook = args[ARG_ext_hook].u_obj; if (hook != mp_const_none && !mp_obj_is_fun(hook) && !MP_OBJ_IS_METH(hook)) { - mp_raise_ValueError(translate("ext_hook is not a function")); + mp_raise_ValueError(MP_ERROR_TEXT("ext_hook is not a function")); } return common_hal_msgpack_unpack(args[ARG_buffer].u_obj, hook, args[ARG_use_list].u_bool); diff --git a/shared-bindings/nvm/ByteArray.c b/shared-bindings/nvm/ByteArray.c index f5b3f83e08..843708b486 100644 --- a/shared-bindings/nvm/ByteArray.c +++ b/shared-bindings/nvm/ByteArray.c @@ -94,7 +94,7 @@ STATIC mp_obj_t nvm_bytearray_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj } 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)) { - mp_raise_NotImplementedError(translate("only slices with step=1 (aka None) are supported")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("only slices with step=1 (aka None) are supported")); } if (value != MP_OBJ_SENTINEL) { #if MICROPY_PY_ARRAY_SLICE_ASSIGN @@ -108,19 +108,19 @@ STATIC mp_obj_t nvm_bytearray_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj mp_buffer_info_t bufinfo; mp_get_buffer_raise(value, &bufinfo, MP_BUFFER_READ); if (bufinfo.len != src_len) { - mp_raise_ValueError(translate("Slice and value different lengths.")); + mp_raise_ValueError(MP_ERROR_TEXT("Slice and value different lengths.")); } src_len = bufinfo.len; src_items = bufinfo.buf; if (1 != mp_binary_get_size('@', bufinfo.typecode, NULL)) { - mp_raise_ValueError(translate("Array values should be single bytes.")); + mp_raise_ValueError(MP_ERROR_TEXT("Array values should be single bytes.")); } } else { - mp_raise_NotImplementedError(translate("array/bytes required on right side")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("array/bytes required on right side")); } if (!common_hal_nvm_bytearray_set_bytes(self, slice.start, src_items, src_len)) { - mp_raise_RuntimeError(translate("Unable to write to nvm.")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Unable to write to nvm.")); } return mp_const_none; #else @@ -150,7 +150,7 @@ STATIC mp_obj_t nvm_bytearray_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj uint8_t short_value = byte_value; if (!common_hal_nvm_bytearray_set_bytes(self, index, &short_value, 1)) { - mp_raise_RuntimeError(translate("Unable to write to nvm.")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Unable to write to nvm.")); } return mp_const_none; } diff --git a/shared-bindings/os/__init__.c b/shared-bindings/os/__init__.c index 85b54aaa18..717d4e92de 100644 --- a/shared-bindings/os/__init__.c +++ b/shared-bindings/os/__init__.c @@ -267,7 +267,7 @@ 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)) { - mp_raise_NotImplementedError(translate("No hardware random available")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("No hardware random available")); } return result; } diff --git a/shared-bindings/paralleldisplaybus/ParallelBus.c b/shared-bindings/paralleldisplaybus/ParallelBus.c index 84afa22343..89dd266edc 100644 --- a/shared-bindings/paralleldisplaybus/ParallelBus.c +++ b/shared-bindings/paralleldisplaybus/ParallelBus.c @@ -97,7 +97,7 @@ STATIC mp_obj_t paralleldisplaybus_parallelbus_make_new(const mp_obj_type_t *typ bool specified_data_pins = args[ARG_data_pins].u_obj != mp_const_none; if (specified_data0 == specified_data_pins) { - mp_raise_ValueError(translate("Specify exactly one of data0 or data_pins")); + mp_raise_ValueError(MP_ERROR_TEXT("Specify exactly one of data0 or data_pins")); } if (specified_data0) { @@ -121,7 +121,7 @@ STATIC mp_obj_t paralleldisplaybus_parallelbus_obj_reset(mp_obj_t self_in) { paralleldisplaybus_parallelbus_obj_t *self = self_in; if (!common_hal_paralleldisplaybus_parallelbus_reset(self)) { - mp_raise_RuntimeError_varg(translate("No %q pin"), MP_QSTR_reset); + mp_raise_RuntimeError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_reset); } return mp_const_none; } diff --git a/shared-bindings/ps2io/Ps2.c b/shared-bindings/ps2io/Ps2.c index 076cb4ca73..09bc1e35bf 100644 --- a/shared-bindings/ps2io/Ps2.c +++ b/shared-bindings/ps2io/Ps2.c @@ -127,7 +127,7 @@ STATIC mp_obj_t ps2io_ps2_obj_popleft(mp_obj_t self_in) { int b = common_hal_ps2io_ps2_popleft(self); if (b < 0) { - mp_raise_IndexError_varg(translate("pop from empty %q"), MP_QSTR_Ps2_space_buffer); + mp_raise_IndexError_varg(MP_ERROR_TEXT("pop from empty %q"), MP_QSTR_Ps2_space_buffer); } return MP_OBJ_NEW_SMALL_INT(b); } @@ -151,7 +151,7 @@ STATIC mp_obj_t ps2io_ps2_obj_sendcmd(mp_obj_t self_in, mp_obj_t ob) { mp_int_t cmd = mp_obj_get_int(ob) & 0xff; int resp = common_hal_ps2io_ps2_sendcmd(self, cmd); if (resp < 0) { - mp_raise_RuntimeError(translate("Failed sending command.")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Failed sending command.")); } return MP_OBJ_NEW_SMALL_INT(resp); } diff --git a/shared-bindings/pulseio/PulseIn.c b/shared-bindings/pulseio/PulseIn.c index cfb24d0dd4..8a94da1dfd 100644 --- a/shared-bindings/pulseio/PulseIn.c +++ b/shared-bindings/pulseio/PulseIn.c @@ -252,20 +252,20 @@ STATIC mp_obj_t pulsein_unary_op(mp_unary_op_t op, mp_obj_t self_in) { STATIC mp_obj_t pulsein_subscr(mp_obj_t self_in, mp_obj_t index_obj, mp_obj_t value) { if (value == mp_const_none) { // delete item - mp_raise_AttributeError(translate("Cannot delete values")); + mp_raise_AttributeError(MP_ERROR_TEXT("Cannot delete values")); } else { pulseio_pulsein_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); if (mp_obj_is_type(index_obj, &mp_type_slice)) { - mp_raise_NotImplementedError(translate("Slices not supported")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("Slices not supported")); } else { size_t index = mp_get_index(&pulseio_pulsein_type, common_hal_pulseio_pulsein_get_len(self), index_obj, false); if (value == MP_OBJ_SENTINEL) { // load return MP_OBJ_NEW_SMALL_INT(common_hal_pulseio_pulsein_get_item(self, index)); } else { - mp_raise_AttributeError(translate("Read-only")); + mp_raise_AttributeError(MP_ERROR_TEXT("Read-only")); } } } diff --git a/shared-bindings/pulseio/PulseOut.c b/shared-bindings/pulseio/PulseOut.c index 8d130d2a70..3a7151768c 100644 --- a/shared-bindings/pulseio/PulseOut.c +++ b/shared-bindings/pulseio/PulseOut.c @@ -131,7 +131,7 @@ STATIC mp_obj_t pulseio_pulseout_obj_send(mp_obj_t self_in, mp_obj_t pulses) { mp_buffer_info_t bufinfo; mp_get_buffer_raise(pulses, &bufinfo, MP_BUFFER_READ); if (bufinfo.typecode != 'H') { - mp_raise_TypeError(translate("Array must contain halfwords (type 'H')")); + mp_raise_TypeError(MP_ERROR_TEXT("Array must contain halfwords (type 'H')")); } common_hal_pulseio_pulseout_send(self, (uint16_t *)bufinfo.buf, bufinfo.len / 2); return mp_const_none; diff --git a/shared-bindings/pwmio/PWMOut.c b/shared-bindings/pwmio/PWMOut.c index 1408696c11..fcb9d75fb1 100644 --- a/shared-bindings/pwmio/PWMOut.c +++ b/shared-bindings/pwmio/PWMOut.c @@ -46,23 +46,23 @@ void common_hal_pwmio_pwmout_raise_error(pwmout_result_t result) { mp_arg_error_invalid(MP_QSTR_frequency); break; case PWMOUT_INVALID_FREQUENCY_ON_PIN: - mp_raise_ValueError(translate("Frequency must match existing PWMOut using this timer")); + mp_raise_ValueError(MP_ERROR_TEXT("Frequency must match existing PWMOut using this timer")); break; case PWMOUT_VARIABLE_FREQUENCY_NOT_AVAILABLE: - mp_raise_ValueError(translate("Cannot vary frequency on a timer that is already in use")); + mp_raise_ValueError(MP_ERROR_TEXT("Cannot vary frequency on a timer that is already in use")); break; case PWMOUT_ALL_TIMERS_ON_PIN_IN_USE: - mp_raise_ValueError(translate("All timers for this pin are in use")); + mp_raise_ValueError(MP_ERROR_TEXT("All timers for this pin are in use")); break; case PWMOUT_ALL_TIMERS_IN_USE: - mp_raise_RuntimeError(translate("All timers in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("All timers in use")); break; case PWMOUT_ALL_CHANNELS_IN_USE: - mp_raise_RuntimeError(translate("All channels in use")); + mp_raise_RuntimeError(MP_ERROR_TEXT("All channels in use")); break; default: case PWMOUT_INITIALIZATION_ERROR: - mp_raise_RuntimeError(translate("Could not start PWM")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Could not start PWM")); break; } } @@ -268,7 +268,7 @@ STATIC mp_obj_t pwmio_pwmout_obj_set_frequency(mp_obj_t self_in, mp_obj_t freque pwmio_pwmout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); if (!common_hal_pwmio_pwmout_get_variable_frequency(self)) { - mp_raise_AttributeError(translate( + mp_raise_AttributeError(MP_ERROR_TEXT( "PWM frequency not writable when variable_frequency is False on construction.")); } mp_int_t freq = mp_obj_get_int(frequency); diff --git a/shared-bindings/random/__init__.c b/shared-bindings/random/__init__.c index 16bdf95df4..92cd775fb7 100644 --- a/shared-bindings/random/__init__.c +++ b/shared-bindings/random/__init__.c @@ -89,7 +89,7 @@ STATIC mp_obj_t random_randrange(size_t n_args, const mp_obj_t *args) { if (n_args == 1) { // range(stop) if (stop <= 0) { - mp_raise_ValueError(translate("stop not reachable from start")); + mp_raise_ValueError(MP_ERROR_TEXT("stop not reachable from start")); } } else { start = stop; @@ -97,7 +97,7 @@ STATIC mp_obj_t random_randrange(size_t n_args, const mp_obj_t *args) { if (n_args == 2) { // range(start, stop) if (start >= stop) { - mp_raise_ValueError(translate("stop not reachable from start")); + mp_raise_ValueError(MP_ERROR_TEXT("stop not reachable from start")); } } else { // range(start, stop, step) @@ -111,7 +111,7 @@ STATIC mp_obj_t random_randrange(size_t n_args, const mp_obj_t *args) { mp_raise_ValueError_varg(MP_ERROR_TEXT("%q step cannot be zero"), MP_QSTR_randrange); } if (n <= 0) { - mp_raise_ValueError(translate("invalid step")); + mp_raise_ValueError(MP_ERROR_TEXT("invalid step")); } } } @@ -143,7 +143,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(random_randint_obj, random_randint); STATIC mp_obj_t random_choice(mp_obj_t seq) { mp_int_t len = mp_obj_get_int(mp_obj_len(seq)); if (len == 0) { - mp_raise_IndexError(translate("empty sequence")); + mp_raise_IndexError(MP_ERROR_TEXT("empty sequence")); } return mp_obj_subscr(seq, mp_obj_new_int(shared_modules_random_randrange(0, len, 1)), MP_OBJ_SENTINEL); } diff --git a/shared-bindings/rgbmatrix/RGBMatrix.c b/shared-bindings/rgbmatrix/RGBMatrix.c index fb645d3050..4f47ef3814 100644 --- a/shared-bindings/rgbmatrix/RGBMatrix.c +++ b/shared-bindings/rgbmatrix/RGBMatrix.c @@ -63,7 +63,7 @@ STATIC void claim_and_never_reset_pins(mp_obj_t seq) { STATIC void preflight_pins_or_throw(uint8_t clock_pin, uint8_t *rgb_pins, uint8_t rgb_pin_count, bool allow_inefficient) { if (rgb_pin_count <= 0 || rgb_pin_count % 6 != 0 || rgb_pin_count > 30) { - mp_raise_ValueError_varg(translate("The length of rgb_pins must be 6, 12, 18, 24, or 30")); + mp_raise_ValueError_varg(MP_ERROR_TEXT("The length of rgb_pins must be 6, 12, 18, 24, or 30")); } // Most ports have a strict requirement for how the rgbmatrix pins are laid @@ -77,13 +77,13 @@ STATIC void preflight_pins_or_throw(uint8_t clock_pin, uint8_t *rgb_pins, uint8_ if (pin_port != port) { mp_raise_ValueError_varg( - translate("rgb_pins[%d] is not on the same port as clock"), i); + MP_ERROR_TEXT("rgb_pins[%d] is not on the same port as clock"), i); } uint32_t pin_mask = 1 << (rgb_pins[i] % 32); if (pin_mask & bit_mask) { mp_raise_ValueError_varg( - translate("rgb_pins[%d] duplicates another pin assignment"), i); + MP_ERROR_TEXT("rgb_pins[%d] duplicates another pin assignment"), i); } bit_mask |= pin_mask; @@ -130,7 +130,7 @@ STATIC void preflight_pins_or_throw(uint8_t clock_pin, uint8_t *rgb_pins, uint8_ if (bytes_per_element != ideal_bytes_per_element) { mp_raise_ValueError_varg( - translate("Pinout uses %d bytes per element, which consumes more than the ideal %d bytes. If this cannot be avoided, pass allow_inefficient=True to the constructor"), + MP_ERROR_TEXT("Pinout uses %d bytes per element, which consumes more than the ideal %d bytes. If this cannot be avoided, pass allow_inefficient=True to the constructor"), bytes_per_element, ideal_bytes_per_element); } #endif @@ -249,7 +249,7 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n validate_pins(MP_QSTR_addr_pins, addr_pins, MP_ARRAY_SIZE(self->addr_pins), args[ARG_addr_list].u_obj, &addr_count); if (rgb_count % 6) { - mp_raise_ValueError_varg(translate("Must use a multiple of 6 rgb pins, not %d"), rgb_count); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Must use a multiple of 6 rgb pins, not %d"), rgb_count); } int tile = mp_arg_validate_int_min(args[ARG_tile].u_int, 1, MP_QSTR_tile); @@ -258,7 +258,7 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_make_new(const mp_obj_type_t *type, size_t n if (args[ARG_height].u_int != 0) { if (computed_height != args[ARG_height].u_int) { mp_raise_ValueError_varg( - translate("%d address pins, %d rgb pins and %d tiles indicate a height of %d, not %d"), addr_count, rgb_count, tile, computed_height, args[ARG_height].u_int); + MP_ERROR_TEXT("%d address pins, %d rgb pins and %d tiles indicate a height of %d, not %d"), addr_count, rgb_count, tile, computed_height, args[ARG_height].u_int); } } @@ -318,7 +318,7 @@ STATIC mp_obj_t rgbmatrix_rgbmatrix_set_brightness(mp_obj_t self_in, mp_obj_t va check_for_deinit(self); mp_float_t brightness = mp_obj_get_float(value_in); if (brightness < 0.0f || brightness > 1.0f) { - mp_raise_ValueError_varg(translate("%q must be %d-%d"), MP_QSTR_brightness, 0, 1); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q must be %d-%d"), MP_QSTR_brightness, 0, 1); } common_hal_rgbmatrix_rgbmatrix_set_paused(self, brightness <= 0); diff --git a/shared-bindings/socketpool/Socket.c b/shared-bindings/socketpool/Socket.c index b404c38662..af045533be 100644 --- a/shared-bindings/socketpool/Socket.c +++ b/shared-bindings/socketpool/Socket.c @@ -103,12 +103,12 @@ STATIC mp_obj_t socketpool_socket_bind(mp_obj_t self_in, mp_obj_t addr_in) { 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")); + mp_raise_ValueError(MP_ERROR_TEXT("port must be >= 0")); } bool ok = common_hal_socketpool_socket_bind(self, host, hostlen, (uint32_t)port); if (!ok) { - mp_raise_ValueError(translate("Error: Failure to bind")); + mp_raise_ValueError(MP_ERROR_TEXT("Error: Failure to bind")); } return mp_const_none; @@ -139,7 +139,7 @@ STATIC mp_obj_t socketpool_socket_connect(mp_obj_t self_in, mp_obj_t addr_in) { 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")); + mp_raise_ValueError(MP_ERROR_TEXT("port must be >= 0")); } common_hal_socketpool_socket_connect(self, host, hostlen, (uint32_t)port); @@ -217,7 +217,7 @@ STATIC mp_obj_t _socketpool_socket_recv_into(size_t n_args, const mp_obj_t *args if (n_args == 3) { mp_int_t given_len = mp_obj_get_int(args[2]); if (given_len > len) { - mp_raise_ValueError(translate("buffer too small for requested bytes")); + mp_raise_ValueError(MP_ERROR_TEXT("buffer too small for requested bytes")); } if (given_len > 0 && given_len < len) { len = given_len; @@ -319,7 +319,7 @@ STATIC mp_obj_t socketpool_socket_sendto(mp_obj_t self_in, mp_obj_t data_in, mp_ 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")); + mp_raise_ValueError(MP_ERROR_TEXT("port must be >= 0")); } mp_int_t ret = common_hal_socketpool_socket_sendto(self, host, hostlen, (uint32_t)port, bufinfo.buf, bufinfo.len); diff --git a/shared-bindings/socketpool/SocketPool.c b/shared-bindings/socketpool/SocketPool.c index 3db72a86c1..b9560ba180 100644 --- a/shared-bindings/socketpool/SocketPool.c +++ b/shared-bindings/socketpool/SocketPool.c @@ -216,7 +216,7 @@ void common_hal_socketpool_socketpool_raise_gaierror_noname(void) { vstr_t vstr; mp_print_t print; vstr_init_print(&vstr, 64, &print); - mp_printf(&print, "%S", translate("Name or service not known")); + mp_printf(&print, "%S", MP_ERROR_TEXT("Name or service not known")); mp_obj_t exc_args[] = { MP_OBJ_NEW_SMALL_INT(SOCKETPOOL_EAI_NONAME), diff --git a/shared-bindings/ssl/SSLContext.c b/shared-bindings/ssl/SSLContext.c index 0ed98d7a7c..544f6f3774 100644 --- a/shared-bindings/ssl/SSLContext.c +++ b/shared-bindings/ssl/SSLContext.c @@ -179,7 +179,7 @@ STATIC mp_obj_t ssl_sslcontext_wrap_socket(size_t n_args, const mp_obj_t *pos_ar } bool server_side = args[ARG_server_side].u_bool; if (server_side && server_hostname != NULL) { - mp_raise_ValueError(translate("Server side context cannot have hostname")); + mp_raise_ValueError(MP_ERROR_TEXT("Server side context cannot have hostname")); } socketpool_socket_obj_t *sock = args[ARG_sock].u_obj; diff --git a/shared-bindings/ssl/SSLSocket.c b/shared-bindings/ssl/SSLSocket.c index d9ffe196eb..e2601f7f81 100644 --- a/shared-bindings/ssl/SSLSocket.c +++ b/shared-bindings/ssl/SSLSocket.c @@ -100,12 +100,12 @@ STATIC mp_obj_t ssl_sslsocket_bind(mp_obj_t self_in, mp_obj_t addr_in) { 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")); + mp_raise_ValueError(MP_ERROR_TEXT("port must be >= 0")); } bool ok = common_hal_ssl_sslsocket_bind(self, host, hostlen, (uint32_t)port); if (!ok) { - mp_raise_ValueError(translate("Error: Failure to bind")); + mp_raise_ValueError(MP_ERROR_TEXT("Error: Failure to bind")); } return mp_const_none; @@ -136,7 +136,7 @@ STATIC mp_obj_t ssl_sslsocket_connect(mp_obj_t self_in, mp_obj_t addr_in) { 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")); + mp_raise_ValueError(MP_ERROR_TEXT("port must be >= 0")); } common_hal_ssl_sslsocket_connect(self, host, hostlen, (uint32_t)port); @@ -189,7 +189,7 @@ STATIC mp_obj_t ssl_sslsocket_recv_into(size_t n_args, const mp_obj_t *args) { if (n_args == 3) { mp_int_t given_len = mp_obj_get_int(args[2]); if (given_len > len) { - mp_raise_ValueError(translate("buffer too small for requested bytes")); + mp_raise_ValueError(MP_ERROR_TEXT("buffer too small for requested bytes")); } if (given_len > 0 && given_len < len) { len = given_len; diff --git a/shared-bindings/storage/__init__.c b/shared-bindings/storage/__init__.c index 8eaf19cf0f..71bd421e3b 100644 --- a/shared-bindings/storage/__init__.c +++ b/shared-bindings/storage/__init__.c @@ -79,7 +79,7 @@ STATIC mp_obj_t storage_mount(size_t n_args, const mp_obj_t *pos_args, mp_map_t mp_obj_t dest[2]; mp_load_method_maybe(vfs_obj, MP_QSTR_mount, dest); if (dest[0] == MP_OBJ_NULL) { - mp_raise_ValueError(translate("filesystem must provide mount method")); + mp_raise_ValueError(MP_ERROR_TEXT("filesystem must provide mount method")); } common_hal_storage_mount(vfs_obj, mnt_str, args[ARG_readonly].u_bool); @@ -187,7 +187,7 @@ STATIC mp_obj_t storage_erase_filesystem(size_t n_args, const mp_obj_t *pos_args common_hal_storage_erase_filesystem(extended); #else if (mp_obj_is_true(args[ARG_extended].u_obj)) { - mp_raise_NotImplementedError_varg(translate("%q=%q"), MP_QSTR_extended, MP_QSTR_True); + mp_raise_NotImplementedError_varg(MP_ERROR_TEXT("%q=%q"), MP_QSTR_extended, MP_QSTR_True); } common_hal_storage_erase_filesystem(false); #endif @@ -208,7 +208,7 @@ STATIC mp_obj_t storage_disable_usb_drive(void) { #else if (true) { #endif - mp_raise_RuntimeError(translate("Cannot change USB devices now")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Cannot change USB devices now")); } return mp_const_none; } @@ -233,7 +233,7 @@ STATIC mp_obj_t storage_enable_usb_drive(void) { #else if (true) { #endif - mp_raise_RuntimeError(translate("Cannot change USB devices now")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Cannot change USB devices now")); } return mp_const_none; } diff --git a/shared-bindings/struct/__init__.c b/shared-bindings/struct/__init__.c index 964d690a38..623210064e 100644 --- a/shared-bindings/struct/__init__.c +++ b/shared-bindings/struct/__init__.c @@ -91,7 +91,7 @@ STATIC mp_obj_t struct_pack_into(size_t n_args, const mp_obj_t *args) { // negative offsets are relative to the end of the buffer offset = (mp_int_t)bufinfo.len + offset; if (offset < 0) { - mp_raise_RuntimeError(translate("Buffer too small")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Buffer too small")); } } byte *p = (byte *)bufinfo.buf; @@ -150,7 +150,7 @@ STATIC mp_obj_t struct_unpack_from(size_t n_args, const mp_obj_t *pos_args, mp_m // negative offsets are relative to the end of the buffer offset = bufinfo.len + offset; if (offset < 0) { - mp_raise_RuntimeError(translate("Buffer too small")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Buffer too small")); } } p += offset; diff --git a/shared-bindings/supervisor/__init__.c b/shared-bindings/supervisor/__init__.c index 8b93866655..51278ddccc 100644 --- a/shared-bindings/supervisor/__init__.c +++ b/shared-bindings/supervisor/__init__.c @@ -130,7 +130,7 @@ STATIC mp_obj_t supervisor_set_next_code_file(size_t n_args, const mp_obj_t *pos } args; mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, (mp_arg_val_t *)&args); if (!mp_obj_is_str_or_bytes(args.filename.u_obj) && args.filename.u_obj != mp_const_none) { - mp_raise_TypeError(translate("argument has wrong type")); + mp_raise_TypeError(MP_ERROR_TEXT("argument has wrong type")); } if (args.filename.u_obj == mp_const_none) { args.filename.u_obj = mp_const_empty_bytes; diff --git a/shared-bindings/synthio/__init__.c b/shared-bindings/synthio/__init__.c index 67c65fc62e..34c1675c60 100644 --- a/shared-bindings/synthio/__init__.c +++ b/shared-bindings/synthio/__init__.c @@ -225,7 +225,7 @@ STATIC mp_obj_t synthio_from_file(size_t n_args, const mp_obj_t *pos_args, mp_ma 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); if (!mp_obj_is_type(args[ARG_file].u_obj, &mp_type_vfs_fat_fileio)) { - mp_raise_TypeError(translate("file must be a file opened in byte mode")); + mp_raise_TypeError(MP_ERROR_TEXT("file must be a file opened in byte mode")); } pyb_file_obj_t *file = MP_OBJ_TO_PTR(args[ARG_file].u_obj); diff --git a/shared-bindings/time/__init__.c b/shared-bindings/time/__init__.c index 4bd501667a..91344eb84a 100644 --- a/shared-bindings/time/__init__.c +++ b/shared-bindings/time/__init__.c @@ -83,7 +83,7 @@ STATIC mp_obj_t time_sleep(mp_obj_t seconds_o) { mp_int_t msecs = 1000 * seconds; #endif if (seconds < 0) { - mp_raise_ValueError(translate("sleep length must be non-negative")); + mp_raise_ValueError(MP_ERROR_TEXT("sleep length must be non-negative")); } common_hal_time_delay_ms(msecs); return mp_const_none; @@ -161,12 +161,12 @@ void struct_time_to_tm(mp_obj_t t, timeutils_struct_time_t *tm) { size_t len; if (!mp_obj_is_type(t, &mp_type_tuple) && !mp_obj_is_type(t, (mp_obj_type_t *)&struct_time_type_obj.base)) { - mp_raise_TypeError(translate("Tuple or struct_time argument required")); + mp_raise_TypeError(MP_ERROR_TEXT("Tuple or struct_time argument required")); } mp_obj_tuple_get(t, &len, &elems); if (len != 9) { - mp_raise_TypeError(translate("function takes exactly 9 arguments")); + mp_raise_TypeError(MP_ERROR_TEXT("function takes exactly 9 arguments")); } tm->tm_year = mp_obj_get_int(elems[0]); @@ -183,14 +183,14 @@ void struct_time_to_tm(mp_obj_t t, timeutils_struct_time_t *tm) { // Function to return a NotImplementedError on platforms that don't // support long integers STATIC mp_obj_t time_not_implemented(void) { - mp_raise_NotImplementedError(translate("No long integer support")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("No long integer support")); } MP_DEFINE_CONST_FUN_OBJ_0(time_not_implemented_obj, time_not_implemented); #endif #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE mp_obj_t MP_WEAK rtc_get_time_source_time(void) { - mp_raise_RuntimeError(translate("RTC is not supported on this board")); + mp_raise_RuntimeError(MP_ERROR_TEXT("RTC is not supported on this board")); } //| def time() -> int: @@ -250,7 +250,7 @@ STATIC mp_obj_t time_localtime(size_t n_args, const mp_obj_t *args) { #else if (secs < 0) { #endif - mp_raise_msg(&mp_type_OverflowError, translate("timestamp out of range for platform time_t")); + mp_raise_msg(&mp_type_OverflowError, MP_ERROR_TEXT("timestamp out of range for platform time_t")); } timeutils_struct_time_t tm; @@ -275,16 +275,16 @@ STATIC mp_obj_t time_mktime(mp_obj_t t) { size_t len; if (!mp_obj_is_type(t, &mp_type_tuple) && !mp_obj_is_type(t, (mp_obj_type_t *)&struct_time_type_obj.base)) { - mp_raise_TypeError(translate("Tuple or struct_time argument required")); + mp_raise_TypeError(MP_ERROR_TEXT("Tuple or struct_time argument required")); } mp_obj_tuple_get(t, &len, &elem); if (len != 9) { - mp_raise_TypeError_varg(translate("function takes %d positional arguments but %d were given"), 9, len); + mp_raise_TypeError_varg(MP_ERROR_TEXT("function takes %d positional arguments but %d were given"), 9, len); } if (mp_obj_get_int(elem[0]) < 2000) { - mp_raise_msg(&mp_type_OverflowError, translate("timestamp out of range for platform time_t")); + mp_raise_msg(&mp_type_OverflowError, MP_ERROR_TEXT("timestamp out of range for platform time_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]), diff --git a/shared-bindings/traceback/__init__.c b/shared-bindings/traceback/__init__.c index 773a41904d..6117515e87 100644 --- a/shared-bindings/traceback/__init__.c +++ b/shared-bindings/traceback/__init__.c @@ -77,12 +77,12 @@ STATIC void traceback_exception_common(bool is_print_exception, mp_print_t *prin print->data = MP_OBJ_TO_PTR(args[ARG_file].u_obj); print->print_strn = mp_stream_write_adaptor; #else - mp_raise_NotImplementedError(translate("file write is not available")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("file write is not available")); #endif } if (!mp_obj_is_exception_instance(value)) { - mp_raise_TypeError(translate("invalid exception")); + mp_raise_TypeError(MP_ERROR_TEXT("invalid exception")); } mp_int_t limit = 0; diff --git a/shared-bindings/usb_cdc/__init__.c b/shared-bindings/usb_cdc/__init__.c index 8b3ca345bc..f4d46eb9e7 100644 --- a/shared-bindings/usb_cdc/__init__.c +++ b/shared-bindings/usb_cdc/__init__.c @@ -69,7 +69,7 @@ //| STATIC mp_obj_t usb_cdc_disable(void) { if (!common_hal_usb_cdc_disable()) { - mp_raise_RuntimeError(translate("Cannot change USB devices now")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Cannot change USB devices now")); } return mp_const_none; } @@ -100,7 +100,7 @@ STATIC mp_obj_t usb_cdc_enable(size_t n_args, const mp_obj_t *pos_args, mp_map_t mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); if (!common_hal_usb_cdc_enable(args[ARG_console].u_bool, args[ARG_data].u_bool)) { - mp_raise_RuntimeError(translate("Cannot change USB devices now")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Cannot change USB devices now")); } return mp_const_none; } diff --git a/shared-bindings/usb_hid/Device.c b/shared-bindings/usb_hid/Device.c index ab0e600046..b9f8a24a88 100644 --- a/shared-bindings/usb_hid/Device.c +++ b/shared-bindings/usb_hid/Device.c @@ -125,7 +125,7 @@ STATIC mp_obj_t usb_hid_device_make_new(const mp_obj_type_t *type, size_t n_args if ((size_t)MP_OBJ_SMALL_INT_VALUE(mp_obj_len(in_report_lengths)) != report_ids_count || (size_t)MP_OBJ_SMALL_INT_VALUE(mp_obj_len(out_report_lengths)) != report_ids_count) { - mp_raise_ValueError_varg(translate("%q, %q, and %q must all be the same length"), + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q, %q, and %q must all be the same length"), MP_QSTR_report_ids, MP_QSTR_in_report_lengths, MP_QSTR_out_report_lengths); } @@ -153,7 +153,7 @@ STATIC mp_obj_t usb_hid_device_make_new(const mp_obj_type_t *type, size_t n_args } if (report_ids_array[0] == 0 && report_ids_count > 1) { - mp_raise_ValueError_varg(translate("%q length must be %d"), MP_QSTR_report_id_space_0, 1); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q length must be %d"), MP_QSTR_report_id_space_0, 1); } common_hal_usb_hid_device_construct( diff --git a/shared-bindings/usb_hid/__init__.c b/shared-bindings/usb_hid/__init__.c index 412e0918e9..15a08eb5f0 100644 --- a/shared-bindings/usb_hid/__init__.c +++ b/shared-bindings/usb_hid/__init__.c @@ -58,7 +58,7 @@ //| STATIC mp_obj_t usb_hid_disable(void) { if (!common_hal_usb_hid_disable()) { - mp_raise_RuntimeError(translate("Cannot change USB devices now")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Cannot change USB devices now")); } return mp_const_none; } @@ -129,7 +129,7 @@ STATIC mp_obj_t usb_hid_enable(size_t n_args, const mp_obj_t *pos_args, mp_map_t (uint8_t)mp_arg_validate_int_range(args[ARG_boot_device].u_int, 0, 2, MP_QSTR_boot_device); if (!common_hal_usb_hid_enable(devices, boot_device)) { - mp_raise_RuntimeError(translate("Cannot change USB devices now")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Cannot change USB devices now")); } return mp_const_none; diff --git a/shared-bindings/usb_midi/__init__.c b/shared-bindings/usb_midi/__init__.c index 3790ea501e..f0e94d62bb 100644 --- a/shared-bindings/usb_midi/__init__.c +++ b/shared-bindings/usb_midi/__init__.c @@ -52,7 +52,7 @@ //| STATIC mp_obj_t usb_midi_disable(void) { if (!common_hal_usb_midi_disable()) { - mp_raise_RuntimeError(translate("Cannot change USB devices now")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Cannot change USB devices now")); } return mp_const_none; } @@ -72,7 +72,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(usb_midi_disable_obj, usb_midi_disable); //| STATIC mp_obj_t usb_midi_enable(void) { if (!common_hal_usb_midi_enable()) { - mp_raise_RuntimeError(translate("Cannot change USB devices now")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Cannot change USB devices now")); } return mp_const_none; } diff --git a/shared-bindings/util.c b/shared-bindings/util.c index 4b882375d1..2f15b9936c 100644 --- a/shared-bindings/util.c +++ b/shared-bindings/util.c @@ -30,7 +30,7 @@ // If so, deinit() has already been called on the object, so complain. void raise_deinited_error(void) { - mp_raise_ValueError(translate("Object has been deinitialized and can no longer be used. Create a new object.")); + mp_raise_ValueError(MP_ERROR_TEXT("Object has been deinitialized and can no longer be used. Create a new object.")); } void properties_print_helper(const mp_print_t *print, mp_obj_t self_in, const mp_arg_t *properties, size_t n_properties) { diff --git a/shared-bindings/vectorio/VectorShape.c b/shared-bindings/vectorio/VectorShape.c index 95960c51f2..f872a21e03 100644 --- a/shared-bindings/vectorio/VectorShape.c +++ b/shared-bindings/vectorio/VectorShape.c @@ -24,7 +24,7 @@ mp_obj_t vectorio_vector_shape_make_new(const mp_obj_t shape, const mp_obj_t pixel_shader, int32_t x, int32_t y) { if (!mp_obj_is_type(pixel_shader, &displayio_colorconverter_type) && !mp_obj_is_type(pixel_shader, &displayio_palette_type)) { - mp_raise_TypeError_varg(translate("unsupported %q type"), MP_QSTR_pixel_shader); + mp_raise_TypeError_varg(MP_ERROR_TEXT("unsupported %q type"), MP_QSTR_pixel_shader); } vectorio_ishape_t ishape; @@ -42,7 +42,7 @@ mp_obj_t vectorio_vector_shape_make_new(const mp_obj_t shape, const mp_obj_t pix ishape.get_area = &common_hal_vectorio_circle_get_area; ishape.get_pixel = &common_hal_vectorio_circle_get_pixel; } else { - mp_raise_TypeError_varg(translate("unsupported %q type"), MP_QSTR_shape); + mp_raise_TypeError_varg(MP_ERROR_TEXT("unsupported %q type"), MP_QSTR_shape); } vectorio_vector_shape_t *self = mp_obj_malloc(vectorio_vector_shape_t, &vectorio_vector_shape_type); @@ -63,7 +63,7 @@ mp_obj_t vectorio_vector_shape_make_new(const mp_obj_t shape, const mp_obj_t pix } else if (mp_obj_is_type(shape, &vectorio_circle_type)) { common_hal_vectorio_circle_set_on_dirty(self->ishape.shape, on_dirty); } else { - mp_raise_TypeError_varg(translate("unsupported %q type"), MP_QSTR_shape); + mp_raise_TypeError_varg(MP_ERROR_TEXT("unsupported %q type"), MP_QSTR_shape); } return MP_OBJ_FROM_PTR(self); @@ -223,7 +223,7 @@ STATIC mp_obj_t vectorio_vector_shape_obj_set_pixel_shader(mp_obj_t wrapper_shap vectorio_vector_shape_t *self = MP_OBJ_TO_PTR(draw_protocol->draw_get_protocol_self(wrapper_shape)); if (!mp_obj_is_type(pixel_shader, &displayio_palette_type) && !mp_obj_is_type(pixel_shader, &displayio_colorconverter_type)) { - mp_raise_TypeError_varg(translate("unsupported %q type"), MP_QSTR_pixel_shader); + mp_raise_TypeError_varg(MP_ERROR_TEXT("unsupported %q type"), MP_QSTR_pixel_shader); } common_hal_vectorio_vector_shape_set_pixel_shader(self, pixel_shader); diff --git a/shared-bindings/warnings/__init__.c b/shared-bindings/warnings/__init__.c index ca051953f7..2da64bdf4c 100644 --- a/shared-bindings/warnings/__init__.c +++ b/shared-bindings/warnings/__init__.c @@ -65,7 +65,7 @@ STATIC mp_obj_t warnings_warn(size_t n_args, const mp_obj_t *pos_args, mp_map_t mp_obj_t category_obj = args[ARG_category].u_obj; if (!mp_obj_is_type(category_obj, &mp_type_type) || !mp_obj_is_subclass_fast(category_obj, MP_OBJ_FROM_PTR(&mp_type_Warning))) { - mp_raise_TypeError_varg(translate("%q must be a subclass of %q"), MP_QSTR_category, MP_QSTR_Warning); + mp_raise_TypeError_varg(MP_ERROR_TEXT("%q must be a subclass of %q"), MP_QSTR_category, MP_QSTR_Warning); } common_hal_warnings_warn(mp_obj_str_get_str(args[ARG_message].u_obj), MP_OBJ_TO_PTR(category_obj)); diff --git a/shared-bindings/wifi/Monitor.c b/shared-bindings/wifi/Monitor.c index e2a6e3db4e..07f5fc890d 100644 --- a/shared-bindings/wifi/Monitor.c +++ b/shared-bindings/wifi/Monitor.c @@ -77,7 +77,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(wifi_monitor_get_channel_obj, wifi_monitor_obj_get_cha STATIC mp_obj_t wifi_monitor_obj_set_channel(mp_obj_t self_in, mp_obj_t channel) { mp_int_t c = mp_obj_get_int(channel); if (c < 1 || c > 13) { - mp_raise_ValueError_varg(translate("%q out of bounds"), MP_QSTR_channel); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q out of bounds"), MP_QSTR_channel); } common_hal_wifi_monitor_set_channel(self_in, c); return mp_const_none; diff --git a/shared-bindings/wifi/Radio.c b/shared-bindings/wifi/Radio.c index 065ee56a73..794bba2578 100644 --- a/shared-bindings/wifi/Radio.c +++ b/shared-bindings/wifi/Radio.c @@ -74,7 +74,7 @@ STATIC bool hostname_valid(const char *ptr, size_t len) { STATIC void validate_hex_password(const uint8_t *buf, size_t len) { for (size_t i = 0; i < len; i++) { if (!unichar_isxdigit(buf[i])) { - mp_raise_ValueError_varg(translate("Invalid hex password")); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Invalid hex password")); } } } @@ -132,7 +132,7 @@ STATIC mp_obj_t wifi_radio_set_hostname(mp_obj_t self_in, mp_obj_t hostname_in) mp_arg_validate_length_range(hostname.len, 1, 253, MP_QSTR_hostname); if (!hostname_valid(hostname.buf, hostname.len)) { - mp_raise_ValueError(translate("invalid hostname")); + mp_raise_ValueError(MP_ERROR_TEXT("invalid hostname")); } wifi_radio_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -166,7 +166,7 @@ STATIC mp_obj_t wifi_radio_set_mac_address(mp_obj_t self_in, mp_obj_t mac_addres mp_get_buffer_raise(mac_address_in, &mac_address, MP_BUFFER_READ); if (mac_address.len != MAC_ADDRESS_LENGTH) { - mp_raise_ValueError(translate("Invalid MAC address")); + mp_raise_ValueError(MP_ERROR_TEXT("Invalid MAC address")); } wifi_radio_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -224,7 +224,7 @@ STATIC mp_obj_t wifi_radio_set_mac_address_ap(mp_obj_t self_in, mp_obj_t mac_add mp_get_buffer_raise(mac_address_in, &mac_address, MP_BUFFER_READ); if (mac_address.len != MAC_ADDRESS_LENGTH) { - mp_raise_ValueError(translate("Invalid MAC address")); + mp_raise_ValueError(MP_ERROR_TEXT("Invalid MAC address")); } wifi_radio_obj_t *self = MP_OBJ_TO_PTR(self_in); @@ -386,7 +386,7 @@ STATIC mp_obj_t wifi_radio_start_ap(size_t n_args, const mp_obj_t *pos_args, mp_ mp_int_t channel = mp_arg_validate_int_range(args[ARG_channel].u_int, 1, 13, MP_QSTR_channel); if (authmode == AUTHMODE_OPEN && password.len > 0) { - mp_raise_ValueError(translate("AuthMode.OPEN is not used with password")); + mp_raise_ValueError(MP_ERROR_TEXT("AuthMode.OPEN is not used with password")); } if (authmode != AUTHMODE_OPEN) { @@ -489,17 +489,17 @@ STATIC mp_obj_t wifi_radio_connect(size_t n_args, const mp_obj_t *pos_args, mp_m if (args[ARG_bssid].u_obj != mp_const_none) { mp_get_buffer_raise(args[ARG_bssid].u_obj, &bssid, MP_BUFFER_READ); if (bssid.len != MAC_ADDRESS_LENGTH) { - mp_raise_ValueError(translate("Invalid BSSID")); + mp_raise_ValueError(MP_ERROR_TEXT("Invalid BSSID")); } } wifi_radio_error_t error = common_hal_wifi_radio_connect(self, ssid.buf, ssid.len, password.buf, password.len, args[ARG_channel].u_int, timeout, bssid.buf, bssid.len); if (error == WIFI_RADIO_ERROR_AUTH_FAIL) { - mp_raise_ConnectionError(translate("Authentication failure")); + mp_raise_ConnectionError(MP_ERROR_TEXT("Authentication failure")); } else if (error == WIFI_RADIO_ERROR_NO_AP_FOUND) { - mp_raise_ConnectionError(translate("No network with that ssid")); + mp_raise_ConnectionError(MP_ERROR_TEXT("No network with that ssid")); } else if (error != WIFI_RADIO_ERROR_NONE) { - mp_raise_msg_varg(&mp_type_ConnectionError, translate("Unknown failure %d"), error); + mp_raise_msg_varg(&mp_type_ConnectionError, MP_ERROR_TEXT("Unknown failure %d"), error); } return mp_const_none; diff --git a/shared-module/_pixelmap/PixelMap.c b/shared-module/_pixelmap/PixelMap.c index 5eaad0b2f8..bbaaf2db96 100644 --- a/shared-module/_pixelmap/PixelMap.c +++ b/shared-module/_pixelmap/PixelMap.c @@ -121,7 +121,7 @@ mp_obj_t shared_module_pixelmap_pixelmap_getslice(pixelmap_pixelmap_obj_t *self, void shared_module_pixelmap_pixelmap_setslice(pixelmap_pixelmap_obj_t *self, const mp_obj_t values, mp_bound_slice_t slice, size_t slice_len) { size_t num_items = mp_obj_get_int(mp_obj_len(values)); if (num_items != slice_len) { - mp_raise_ValueError_varg(translate("Unmatched number of items on RHS (expected %d, got %d)."), slice_len, num_items); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Unmatched number of items on RHS (expected %d, got %d)."), slice_len, num_items); } bool auto_write = auto_write_get_and_clear(self); diff --git a/shared-module/adafruit_bus_device/i2c_device/I2CDevice.c b/shared-module/adafruit_bus_device/i2c_device/I2CDevice.c index a630f1e2b8..85bd430a96 100644 --- a/shared-module/adafruit_bus_device/i2c_device/I2CDevice.c +++ b/shared-module/adafruit_bus_device/i2c_device/I2CDevice.c @@ -79,7 +79,7 @@ void common_hal_adafruit_bus_device_i2cdevice_probe_for_device(adafruit_bus_devi common_hal_adafruit_bus_device_i2cdevice_unlock(self); if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(((mp_obj_base_t *)nlr.ret_val)->type), MP_OBJ_FROM_PTR(&mp_type_OSError))) { - mp_raise_ValueError_varg(translate("No I2C device at address: 0x%x"), self->device_address); + mp_raise_ValueError_varg(MP_ERROR_TEXT("No I2C device at address: 0x%x"), self->device_address); } else { /* In case we receive an unrelated exception pass it up */ nlr_raise(MP_OBJ_FROM_PTR(nlr.ret_val)); diff --git a/shared-module/adafruit_pixelbuf/PixelBuf.c b/shared-module/adafruit_pixelbuf/PixelBuf.c index 9c12dd68de..10ef46b45e 100644 --- a/shared-module/adafruit_pixelbuf/PixelBuf.c +++ b/shared-module/adafruit_pixelbuf/PixelBuf.c @@ -151,7 +151,7 @@ STATIC uint8_t _pixelbuf_get_as_uint8(mp_obj_t obj) { return (uint8_t)mp_obj_get_float(obj); } mp_raise_TypeError_varg( - translate("can't convert %q to %q"), mp_obj_get_type_qstr(obj), MP_QSTR_int); + MP_ERROR_TEXT("can't convert %q to %q"), mp_obj_get_type_qstr(obj), MP_QSTR_int); } static void pixelbuf_parse_color(pixelbuf_pixelbuf_obj_t *self, mp_obj_t color, uint8_t *r, uint8_t *g, uint8_t *b, uint8_t *w) { diff --git a/shared-module/atexit/__init__.c b/shared-module/atexit/__init__.c index 02749a45a1..640bfe0173 100644 --- a/shared-module/atexit/__init__.c +++ b/shared-module/atexit/__init__.c @@ -43,7 +43,7 @@ void atexit_gc_collect(void) { void shared_module_atexit_register(mp_obj_t *func, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { if (!mp_obj_is_callable(func)) { - mp_raise_TypeError_varg(translate("'%q' object is not callable"), mp_obj_get_type_qstr(func)); + mp_raise_TypeError_varg(MP_ERROR_TEXT("'%q' object is not callable"), mp_obj_get_type_qstr(func)); } size_t n_kw_args = (kw_args) ? kw_args->used : 0; atexit_callback_t cb = { diff --git a/shared-module/audiocore/WaveFile.c b/shared-module/audiocore/WaveFile.c index 021bb63449..10d9775d80 100644 --- a/shared-module/audiocore/WaveFile.c +++ b/shared-module/audiocore/WaveFile.c @@ -67,7 +67,7 @@ void common_hal_audioio_wavefile_construct(audioio_wavefile_obj_t *self, } if (bytes_read != 4 || format_size > sizeof(struct wave_format_chunk)) { - mp_raise_ValueError(translate("Invalid format chunk size")); + mp_raise_ValueError(MP_ERROR_TEXT("Invalid format chunk size")); } struct wave_format_chunk format; if (f_read(&self->file->fp, &format, format_size, &bytes_read) != FR_OK) { @@ -81,7 +81,7 @@ void common_hal_audioio_wavefile_construct(audioio_wavefile_obj_t *self, format.bits_per_sample > 16 || (format_size == 18 && format.extra_params != 0)) { - mp_raise_ValueError(translate("Unsupported format")); + mp_raise_ValueError(MP_ERROR_TEXT("Unsupported format")); } // Get the sample_rate self->sample_rate = format.sample_rate; @@ -96,7 +96,7 @@ void common_hal_audioio_wavefile_construct(audioio_wavefile_obj_t *self, } if (bytes_read != 4 || memcmp((uint8_t *)data_tag, "data", 4) != 0) { - mp_raise_ValueError(translate("Data chunk must follow fmt chunk")); + mp_raise_ValueError(MP_ERROR_TEXT("Data chunk must follow fmt chunk")); } uint32_t data_length; diff --git a/shared-module/audiomixer/MixerVoice.c b/shared-module/audiomixer/MixerVoice.c index f4d2a6514e..4bdd6119c4 100644 --- a/shared-module/audiomixer/MixerVoice.c +++ b/shared-module/audiomixer/MixerVoice.c @@ -52,13 +52,13 @@ void common_hal_audiomixer_mixervoice_set_level(audiomixer_mixervoice_obj_t *sel void common_hal_audiomixer_mixervoice_play(audiomixer_mixervoice_obj_t *self, mp_obj_t sample, bool loop) { if (audiosample_sample_rate(sample) != self->parent->sample_rate) { - mp_raise_ValueError(translate("The sample's sample rate does not match the mixer's")); + mp_raise_ValueError(MP_ERROR_TEXT("The sample's sample rate does not match the mixer's")); } if (audiosample_channel_count(sample) != self->parent->channel_count) { - mp_raise_ValueError(translate("The sample's channel count does not match the mixer's")); + mp_raise_ValueError(MP_ERROR_TEXT("The sample's channel count does not match the mixer's")); } if (audiosample_bits_per_sample(sample) != self->parent->bits_per_sample) { - mp_raise_ValueError(translate("The sample's bits_per_sample does not match the mixer's")); + mp_raise_ValueError(MP_ERROR_TEXT("The sample's bits_per_sample does not match the mixer's")); } bool single_buffer; bool samples_signed; @@ -67,7 +67,7 @@ void common_hal_audiomixer_mixervoice_play(audiomixer_mixervoice_obj_t *self, mp audiosample_get_buffer_structure(sample, false, &single_buffer, &samples_signed, &max_buffer_length, &spacing); if (samples_signed != self->parent->samples_signed) { - mp_raise_ValueError(translate("The sample's signedness does not match the mixer's")); + mp_raise_ValueError(MP_ERROR_TEXT("The sample's signedness does not match the mixer's")); } self->sample = sample; self->loop = loop; diff --git a/shared-module/audiomp3/MP3Decoder.c b/shared-module/audiomp3/MP3Decoder.c index 2049c6aa1d..51cb37d916 100644 --- a/shared-module/audiomp3/MP3Decoder.c +++ b/shared-module/audiomp3/MP3Decoder.c @@ -198,7 +198,7 @@ void common_hal_audiomp3_mp3file_construct(audiomp3_mp3file_obj_t *self, if (self->decoder == NULL) { common_hal_audiomp3_mp3file_deinit(self); mp_raise_msg(&mp_type_MemoryError, - translate("Couldn't allocate decoder")); + MP_ERROR_TEXT("Couldn't allocate decoder")); } if ((intptr_t)buffer & 1) { @@ -247,7 +247,7 @@ void common_hal_audiomp3_mp3file_set_file(audiomp3_mp3file_obj_t *self, pyb_file background_callback_end_critical_section(); if (!result) { mp_raise_msg(&mp_type_RuntimeError, - translate("Failed to parse MP3 file")); + MP_ERROR_TEXT("Failed to parse MP3 file")); } self->sample_rate = fi.samprate; diff --git a/shared-module/bitbangio/I2C.c b/shared-module/bitbangio/I2C.c index 4ee33fd8f5..abeabcf56f 100644 --- a/shared-module/bitbangio/I2C.c +++ b/shared-module/bitbangio/I2C.c @@ -55,7 +55,7 @@ STATIC void scl_release(bitbangio_i2c_obj_t *self) { common_hal_digitalio_digitalinout_switch_to_output(&self->scl, true, DRIVE_MODE_OPEN_DRAIN); // raise exception on timeout if (count == 0) { - mp_raise_msg(&mp_type_TimeoutError, translate("Clock stretch too long")); + mp_raise_msg(&mp_type_TimeoutError, MP_ERROR_TEXT("Clock stretch too long")); } } diff --git a/shared-module/bitbangio/SPI.c b/shared-module/bitbangio/SPI.c index 60d216f619..7e2d8d46eb 100644 --- a/shared-module/bitbangio/SPI.c +++ b/shared-module/bitbangio/SPI.c @@ -40,7 +40,7 @@ void shared_module_bitbangio_spi_construct(bitbangio_spi_obj_t *self, const mcu_pin_obj_t *miso) { digitalinout_result_t result = common_hal_digitalio_digitalinout_construct(&self->clock, clock); if (result != DIGITALINOUT_OK) { - mp_raise_ValueError_varg(translate("%q init failed"), MP_QSTR_clock); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q init failed"), MP_QSTR_clock); } common_hal_digitalio_digitalinout_switch_to_output(&self->clock, self->polarity == 1, DRIVE_MODE_PUSH_PULL); @@ -48,7 +48,7 @@ void shared_module_bitbangio_spi_construct(bitbangio_spi_obj_t *self, result = common_hal_digitalio_digitalinout_construct(&self->mosi, mosi); if (result != DIGITALINOUT_OK) { common_hal_digitalio_digitalinout_deinit(&self->clock); - mp_raise_ValueError_varg(translate("%q init failed"), MP_QSTR_mosi); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q init failed"), MP_QSTR_mosi); } self->has_mosi = true; common_hal_digitalio_digitalinout_switch_to_output(&self->mosi, false, DRIVE_MODE_PUSH_PULL); @@ -62,7 +62,7 @@ void shared_module_bitbangio_spi_construct(bitbangio_spi_obj_t *self, if (mosi != NULL) { common_hal_digitalio_digitalinout_deinit(&self->mosi); } - mp_raise_ValueError_varg(translate("%q init failed"), MP_QSTR_miso); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q init failed"), MP_QSTR_miso); } self->has_miso = true; } @@ -122,7 +122,7 @@ void shared_module_bitbangio_spi_unlock(bitbangio_spi_obj_t *self) { // Writes out the given data. bool shared_module_bitbangio_spi_write(bitbangio_spi_obj_t *self, const uint8_t *data, size_t len) { if (len > 0 && !self->has_mosi) { - mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_mosi); + mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_mosi); } uint32_t delay_half = self->delay_half; @@ -177,7 +177,7 @@ bool shared_module_bitbangio_spi_write(bitbangio_spi_obj_t *self, const uint8_t // Reads in len bytes while outputting zeroes. bool shared_module_bitbangio_spi_read(bitbangio_spi_obj_t *self, uint8_t *data, size_t len, uint8_t write_data) { if (len > 0 && !self->has_miso) { - mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_miso); + mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_miso); } uint32_t delay_half = self->delay_half; @@ -245,10 +245,10 @@ bool shared_module_bitbangio_spi_read(bitbangio_spi_obj_t *self, uint8_t *data, // transfer bool shared_module_bitbangio_spi_transfer(bitbangio_spi_obj_t *self, const uint8_t *dout, uint8_t *din, size_t len) { if (!self->has_mosi && dout != NULL) { - mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_mosi); + mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_mosi); } if (!self->has_miso && din != NULL) { - mp_raise_ValueError_varg(translate("No %q pin"), MP_QSTR_miso); + mp_raise_ValueError_varg(MP_ERROR_TEXT("No %q pin"), MP_QSTR_miso); } uint32_t delay_half = self->delay_half; diff --git a/shared-module/bitmaptools/__init__.c b/shared-module/bitmaptools/__init__.c index 02eaae2d46..fe7e08208e 100644 --- a/shared-module/bitmaptools/__init__.c +++ b/shared-module/bitmaptools/__init__.c @@ -1059,7 +1059,7 @@ void common_hal_bitmaptools_blit(displayio_bitmap_t *destination, displayio_bitm bool skip_dest_index_none) { if (destination->read_only) { - mp_raise_RuntimeError(translate("Read-only")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Read-only")); } // Copy region of "source" bitmap into "destination" bitmap at location x,y in the "destination" // If skip_value is encountered in the source bitmap, it will not be copied. diff --git a/shared-module/busdisplay/BusDisplay.c b/shared-module/busdisplay/BusDisplay.c index 7b39d33db0..64f800143b 100644 --- a/shared-module/busdisplay/BusDisplay.c +++ b/shared-module/busdisplay/BusDisplay.c @@ -365,7 +365,7 @@ bool common_hal_busdisplay_busdisplay_refresh(busdisplay_busdisplay_obj_t *self, uint32_t current_ms_since_real_refresh = current_time - self->core.last_refresh; // Test to see if the real frame time is below our minimum. if (current_ms_since_real_refresh > maximum_ms_per_real_frame) { - mp_raise_RuntimeError(translate("Below minimum frame rate")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Below minimum frame rate")); } uint32_t current_ms_since_last_call = current_time - self->last_refresh_call; self->last_refresh_call = current_time; @@ -404,7 +404,7 @@ void common_hal_busdisplay_busdisplay_set_auto_refresh(busdisplay_busdisplay_obj mp_obj_t common_hal_busdisplay_busdisplay_set_root_group(busdisplay_busdisplay_obj_t *self, displayio_group_t *root_group) { bool ok = displayio_display_core_set_root_group(&self->core, root_group); if (!ok) { - mp_raise_ValueError(translate("Group already used")); + mp_raise_ValueError(MP_ERROR_TEXT("Group already used")); } return mp_const_none; } diff --git a/shared-module/displayio/Bitmap.c b/shared-module/displayio/Bitmap.c index 82eca02197..e34ad6ef71 100644 --- a/shared-module/displayio/Bitmap.c +++ b/shared-module/displayio/Bitmap.c @@ -59,7 +59,7 @@ void common_hal_displayio_bitmap_construct_from_buffer(displayio_bitmap_t *self, self->bits_per_value = bits_per_value; if (bits_per_value > 8 && bits_per_value != 16 && bits_per_value != 32) { - mp_raise_NotImplementedError(translate("Invalid bits per value")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("Invalid bits per value")); } // Division and modulus can be slow because it has to handle any integer. We know bits_per_value @@ -130,7 +130,7 @@ uint32_t common_hal_displayio_bitmap_get_pixel(displayio_bitmap_t *self, int16_t void displayio_bitmap_set_dirty_area(displayio_bitmap_t *self, const displayio_area_t *dirty_area) { if (self->read_only) { - mp_raise_RuntimeError(translate("Read-only")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Read-only")); } displayio_area_t area = *dirty_area; @@ -142,7 +142,7 @@ void displayio_bitmap_set_dirty_area(displayio_bitmap_t *self, const displayio_a void displayio_bitmap_write_pixel(displayio_bitmap_t *self, int16_t x, int16_t y, uint32_t value) { if (self->read_only) { - mp_raise_RuntimeError(translate("Read-only")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Read-only")); } // Writes the color index value into a pixel position // Must update the dirty area separately @@ -176,7 +176,7 @@ void displayio_bitmap_write_pixel(displayio_bitmap_t *self, int16_t x, int16_t y void common_hal_displayio_bitmap_set_pixel(displayio_bitmap_t *self, int16_t x, int16_t y, uint32_t value) { if (self->read_only) { - mp_raise_RuntimeError(translate("Read-only")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Read-only")); } // update the dirty region displayio_area_t a = {x, y, x + 1, y + 1, NULL}; @@ -205,7 +205,7 @@ void displayio_bitmap_finish_refresh(displayio_bitmap_t *self) { void common_hal_displayio_bitmap_fill(displayio_bitmap_t *self, uint32_t value) { if (self->read_only) { - mp_raise_RuntimeError(translate("Read-only")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Read-only")); } displayio_area_t a = {0, 0, self->width, self->height, NULL}; displayio_bitmap_set_dirty_area(self, &a); diff --git a/shared-module/displayio/ColorConverter.c b/shared-module/displayio/ColorConverter.c index 9c81ec27a1..b6bf4da312 100644 --- a/shared-module/displayio/ColorConverter.c +++ b/shared-module/displayio/ColorConverter.c @@ -187,7 +187,7 @@ bool common_hal_displayio_colorconverter_get_dither(displayio_colorconverter_t * void common_hal_displayio_colorconverter_make_transparent(displayio_colorconverter_t *self, uint32_t transparent_color) { if (self->transparent_color != NO_TRANSPARENT_COLOR) { - mp_raise_RuntimeError(translate("Only one color can be transparent at a time")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Only one color can be transparent at a time")); } self->transparent_color = transparent_color; } diff --git a/shared-module/displayio/Group.c b/shared-module/displayio/Group.c index bd92d20c2d..06e9b9cc39 100644 --- a/shared-module/displayio/Group.c +++ b/shared-module/displayio/Group.c @@ -268,7 +268,7 @@ static void _add_layer(displayio_group_t *self, mp_obj_t layer) { if (native_layer != MP_OBJ_NULL) { displayio_tilegrid_t *tilegrid = native_layer; if (tilegrid->in_group) { - mp_raise_ValueError(translate("Layer already in a group")); + mp_raise_ValueError(MP_ERROR_TEXT("Layer already in a group")); } else { tilegrid->in_group = true; } @@ -281,7 +281,7 @@ static void _add_layer(displayio_group_t *self, mp_obj_t layer) { if (native_layer != MP_OBJ_NULL) { displayio_group_t *group = native_layer; if (group->in_group) { - mp_raise_ValueError(translate("Layer already in a group")); + mp_raise_ValueError(MP_ERROR_TEXT("Layer already in a group")); } else { group->in_group = true; } @@ -290,7 +290,7 @@ static void _add_layer(displayio_group_t *self, mp_obj_t layer) { group, self->hidden || self->hidden_by_parent); return; } - mp_raise_ValueError(translate("Layer must be a Group or TileGrid subclass")); + mp_raise_ValueError(MP_ERROR_TEXT("Layer must be a Group or TileGrid subclass")); } static void _remove_layer(displayio_group_t *self, size_t index) { diff --git a/shared-module/displayio/OnDiskBitmap.c b/shared-module/displayio/OnDiskBitmap.c index 789b84787a..ae152c068e 100644 --- a/shared-module/displayio/OnDiskBitmap.c +++ b/shared-module/displayio/OnDiskBitmap.c @@ -105,7 +105,7 @@ void common_hal_displayio_ondiskbitmap_construct(displayio_ondiskbitmap_t *self, mp_raise_OSError(MP_EIO); } if (palette_bytes_read != palette_size) { - mp_raise_ValueError(translate("Unable to read color palette data")); + mp_raise_ValueError(MP_ERROR_TEXT("Unable to read color palette data")); } for (uint16_t i = 0; i < number_of_colors; i++) { common_hal_displayio_palette_set_color(palette, i, palette_data[i]); @@ -118,11 +118,11 @@ void common_hal_displayio_ondiskbitmap_construct(displayio_ondiskbitmap_t *self, self->palette = palette; } else if (!(header_size == 12 || header_size == 40 || header_size == 108 || header_size == 124)) { - mp_raise_ValueError_varg(translate("Only Windows format, uncompressed BMP supported: given header size is %d"), header_size); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Only Windows format, uncompressed BMP supported: given header size is %d"), header_size); } if (bits_per_pixel == 8 && number_of_colors == 0) { - mp_raise_ValueError_varg(translate("Only monochrome, indexed 4bpp or 8bpp, and 16bpp or greater BMPs supported: %d bpp given"), bits_per_pixel); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Only monochrome, indexed 4bpp or 8bpp, and 16bpp or greater BMPs supported: %d bpp given"), bits_per_pixel); } uint8_t bytes_per_pixel = (self->bits_per_pixel / 8) ? (self->bits_per_pixel / 8) : 1; diff --git a/shared-module/displayio/TileGrid.c b/shared-module/displayio/TileGrid.c index d027e12834..696de59d97 100644 --- a/shared-module/displayio/TileGrid.c +++ b/shared-module/displayio/TileGrid.c @@ -264,7 +264,7 @@ uint8_t common_hal_displayio_tilegrid_get_tile(displayio_tilegrid_t *self, uint1 void common_hal_displayio_tilegrid_set_tile(displayio_tilegrid_t *self, uint16_t x, uint16_t y, uint8_t tile_index) { if (tile_index >= self->tiles_in_bitmap) { - mp_raise_ValueError(translate("Tile index out of bounds")); + mp_raise_ValueError(MP_ERROR_TEXT("Tile index out of bounds")); } uint8_t *tiles = self->tiles; if (self->inline_tiles) { @@ -303,7 +303,7 @@ void common_hal_displayio_tilegrid_set_tile(displayio_tilegrid_t *self, uint16_t void common_hal_displayio_tilegrid_set_all_tiles(displayio_tilegrid_t *self, uint8_t tile_index) { if (tile_index >= self->tiles_in_bitmap) { - mp_raise_ValueError(translate("Tile index out of bounds")); + mp_raise_ValueError(MP_ERROR_TEXT("Tile index out of bounds")); } uint8_t *tiles = self->tiles; if (self->inline_tiles) { diff --git a/shared-module/displayio/__init__.c b/shared-module/displayio/__init__.c index 4f565226d2..3d5ccd5317 100644 --- a/shared-module/displayio/__init__.c +++ b/shared-module/displayio/__init__.c @@ -404,7 +404,7 @@ primary_display_t *allocate_display_or_raise(void) { if (result) { return result; } - mp_raise_RuntimeError(translate("Too many displays")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Too many displays")); } primary_display_bus_t *allocate_display_bus(void) { @@ -425,5 +425,5 @@ primary_display_bus_t *allocate_display_bus_or_raise(void) { if (result) { return result; } - mp_raise_RuntimeError(translate("Too many display busses; forgot displayio.release_displays() ?")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Too many display busses; forgot displayio.release_displays() ?")); } diff --git a/shared-module/displayio/bus_core.c b/shared-module/displayio/bus_core.c index 87173c27eb..f045ba288c 100644 --- a/shared-module/displayio/bus_core.c +++ b/shared-module/displayio/bus_core.c @@ -97,7 +97,7 @@ void displayio_display_bus_construct(displayio_display_bus_t *self, } else #endif { - mp_raise_ValueError(translate("Unsupported display bus type")); + mp_raise_ValueError(MP_ERROR_TEXT("Unsupported display bus type")); } self->bus = bus; } diff --git a/shared-module/framebufferio/FramebufferDisplay.c b/shared-module/framebufferio/FramebufferDisplay.c index 88c7bdd351..7a5fdaa911 100644 --- a/shared-module/framebufferio/FramebufferDisplay.c +++ b/shared-module/framebufferio/FramebufferDisplay.c @@ -278,7 +278,7 @@ bool common_hal_framebufferio_framebufferdisplay_refresh(framebufferio_framebuff uint32_t current_ms_since_real_refresh = current_time - self->core.last_refresh; // Test to see if the real frame time is below our minimum. if (current_ms_since_real_refresh > maximum_ms_per_real_frame) { - mp_raise_RuntimeError(translate("Below minimum frame rate")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Below minimum frame rate")); } uint32_t current_ms_since_last_call = current_time - self->last_refresh_call; self->last_refresh_call = current_time; @@ -360,7 +360,7 @@ mp_obj_t common_hal_framebufferio_framebufferdisplay_get_root_group(framebufferi mp_obj_t common_hal_framebufferio_framebufferdisplay_set_root_group(framebufferio_framebufferdisplay_obj_t *self, displayio_group_t *root_group) { bool ok = displayio_display_core_set_root_group(&self->core, root_group); if (!ok) { - mp_raise_ValueError(translate("Group already used")); + mp_raise_ValueError(MP_ERROR_TEXT("Group already used")); } return mp_const_none; } diff --git a/shared-module/gifio/GifWriter.c b/shared-module/gifio/GifWriter.c index 9167de75a0..698e2e7144 100644 --- a/shared-module/gifio/GifWriter.c +++ b/shared-module/gifio/GifWriter.c @@ -80,7 +80,7 @@ void shared_module_gifio_gifwriter_construct(gifio_gifwriter_t *self, mp_obj_t * self->file = file; self->file_proto = mp_get_stream_raise(file, MP_STREAM_OP_WRITE | MP_STREAM_OP_IOCTL); if (self->file_proto->is_text) { - mp_raise_TypeError(translate("file must be a file opened in byte mode")); + mp_raise_TypeError(MP_ERROR_TEXT("file must be a file opened in byte mode")); } self->width = width; self->height = height; @@ -108,7 +108,7 @@ void shared_module_gifio_gifwriter_construct(gifio_gifwriter_t *self, mp_obj_t * break; default: - mp_raise_TypeError(translate("unsupported colorspace for GifWriter")); + mp_raise_TypeError(MP_ERROR_TEXT("unsupported colorspace for GifWriter")); } bool color = (colorspace != DISPLAYIO_COLORSPACE_L8); diff --git a/shared-module/gifio/OnDiskGif.c b/shared-module/gifio/OnDiskGif.c index 3f021cb33e..7e27810bf2 100644 --- a/shared-module/gifio/OnDiskGif.c +++ b/shared-module/gifio/OnDiskGif.c @@ -171,7 +171,7 @@ void common_hal_gifio_ondiskgif_construct(gifio_ondiskgif_t *self, pyb_file_obj_ if (result != 1) { switch (self->gif.iError) { case GIF_TOO_WIDE: - mp_raise_ValueError_varg(translate("%q must be <= %d"), MP_QSTR_width, MAX_WIDTH); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q must be <= %d"), MP_QSTR_width, MAX_WIDTH); break; default: mp_arg_error_invalid(MP_QSTR_file); diff --git a/shared-module/i2cdisplaybus/I2CDisplayBus.c b/shared-module/i2cdisplaybus/I2CDisplayBus.c index 78ac36d61a..b92eff2d4f 100644 --- a/shared-module/i2cdisplaybus/I2CDisplayBus.c +++ b/shared-module/i2cdisplaybus/I2CDisplayBus.c @@ -55,7 +55,7 @@ void common_hal_i2cdisplaybus_i2cdisplaybus_construct(i2cdisplaybus_i2cdisplaybu if (!common_hal_busio_i2c_probe(i2c, device_address)) { self->base.type = &mp_type_NoneType; common_hal_i2cdisplaybus_i2cdisplaybus_deinit(self); - mp_raise_ValueError_varg(translate("Unable to find I2C Display at %x"), device_address); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Unable to find I2C Display at %x"), device_address); } // Write to the device and return 0 on success or an appropriate error code from mperrno.h diff --git a/shared-module/imagecapture/ParallelImageCapture.c b/shared-module/imagecapture/ParallelImageCapture.c index 346bc76479..6d2197fcfc 100644 --- a/shared-module/imagecapture/ParallelImageCapture.c +++ b/shared-module/imagecapture/ParallelImageCapture.c @@ -30,15 +30,15 @@ // If the continuous-capture mode isn't supported, then this default (weak) implementation will raise exceptions for you __attribute__((weak)) void common_hal_imagecapture_parallelimagecapture_continuous_capture_start(imagecapture_parallelimagecapture_obj_t *self, mp_obj_t buffer1, mp_obj_t buffer2) { - mp_raise_NotImplementedError(translate("This microcontroller does not support continuous capture.")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("This microcontroller does not support continuous capture.")); } __attribute__((weak)) void common_hal_imagecapture_parallelimagecapture_continuous_capture_stop(imagecapture_parallelimagecapture_obj_t *self) { - mp_raise_NotImplementedError(translate("This microcontroller does not support continuous capture.")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("This microcontroller does not support continuous capture.")); } __attribute__((weak)) mp_obj_t common_hal_imagecapture_parallelimagecapture_continuous_capture_get_frame(imagecapture_parallelimagecapture_obj_t *self) { - mp_raise_NotImplementedError(translate("This microcontroller does not support continuous capture.")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("This microcontroller does not support continuous capture.")); } diff --git a/shared-module/is31fl3741/FrameBuffer.c b/shared-module/is31fl3741/FrameBuffer.c index 07bd3324f9..9403abc738 100644 --- a/shared-module/is31fl3741/FrameBuffer.c +++ b/shared-module/is31fl3741/FrameBuffer.c @@ -58,7 +58,7 @@ void common_hal_is31fl3741_FrameBuffer_construct(is31fl3741_FrameBuffer_obj_t *s mp_obj_tuple_get(mapping, &len, &items); if (len != (size_t)(self->scale_width * self->scale_height * 3)) { - mp_raise_ValueError(translate("LED mappings must match display size")); + mp_raise_ValueError(MP_ERROR_TEXT("LED mappings must match display size")); } self->mapping = common_hal_is31fl3741_allocator_impl(sizeof(uint16_t) * len); diff --git a/shared-module/is31fl3741/IS31FL3741.c b/shared-module/is31fl3741/IS31FL3741.c index 08598743b7..b4d814ff1b 100644 --- a/shared-module/is31fl3741/IS31FL3741.c +++ b/shared-module/is31fl3741/IS31FL3741.c @@ -40,7 +40,7 @@ void common_hal_is31fl3741_IS31FL3741_construct(is31fl3741_IS31FL3741_obj_t *sel // Probe the bus to see if a device acknowledges the given address. if (!common_hal_busio_i2c_probe(i2c, addr)) { self->base.type = &mp_type_NoneType; - mp_raise_ValueError_varg(translate("Unable to find I2C Display at %x"), addr); + mp_raise_ValueError_varg(MP_ERROR_TEXT("Unable to find I2C Display at %x"), addr); } self->i2c = i2c; diff --git a/shared-module/memorymonitor/AllocationAlarm.c b/shared-module/memorymonitor/AllocationAlarm.c index 473a19396a..d15829f896 100644 --- a/shared-module/memorymonitor/AllocationAlarm.c +++ b/shared-module/memorymonitor/AllocationAlarm.c @@ -54,7 +54,7 @@ void common_hal_memorymonitor_allocationalarm_pause(memorymonitor_allocationalar void common_hal_memorymonitor_allocationalarm_resume(memorymonitor_allocationalarm_obj_t *self) { if (self->previous != NULL) { - mp_raise_RuntimeError(translate("Already running")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Already running")); } self->next = MP_STATE_VM(active_allocationalarms); self->previous = (memorymonitor_allocationalarm_obj_t **)&MP_STATE_VM(active_allocationalarms); @@ -85,7 +85,7 @@ void memorymonitor_allocationalarms_allocation(size_t block_count) { alarm = next; } if (alert_count > 0) { - mp_raise_memorymonitor_AllocationError(translate("Attempt to allocate %d blocks"), block_count); + mp_raise_memorymonitor_AllocationError(MP_ERROR_TEXT("Attempt to allocate %d blocks"), block_count); } } diff --git a/shared-module/memorymonitor/AllocationSize.c b/shared-module/memorymonitor/AllocationSize.c index 76b1590682..70b57780f1 100644 --- a/shared-module/memorymonitor/AllocationSize.c +++ b/shared-module/memorymonitor/AllocationSize.c @@ -44,7 +44,7 @@ void common_hal_memorymonitor_allocationsize_pause(memorymonitor_allocationsize_ void common_hal_memorymonitor_allocationsize_resume(memorymonitor_allocationsize_obj_t *self) { if (self->previous != NULL) { - mp_raise_RuntimeError(translate("Already running")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Already running")); } self->next = MP_STATE_VM(active_allocationsizes); self->previous = (memorymonitor_allocationsize_obj_t **)&MP_STATE_VM(active_allocationsizes); diff --git a/shared-module/msgpack/__init__.c b/shared-module/msgpack/__init__.c index aac38607cb..9ea9279997 100644 --- a/shared-module/msgpack/__init__.c +++ b/shared-module/msgpack/__init__.c @@ -71,7 +71,7 @@ STATIC void read(msgpack_stream_t *s, void *buf, mp_uint_t size) { mp_raise_msg(&mp_type_EOFError, NULL); } if (ret < size) { - mp_raise_ValueError(translate("short read")); + mp_raise_ValueError(MP_ERROR_TEXT("short read")); } } @@ -336,7 +336,7 @@ STATIC void pack(mp_obj_t obj, msgpack_stream_t *s, mp_obj_t default_handler) { // this also precludes some valid outputs pack(mp_call_function_1(default_handler, obj), s, mp_const_none); } else { - mp_raise_ValueError(translate("no default packer")); + mp_raise_ValueError(MP_ERROR_TEXT("no default packer")); } } } @@ -509,7 +509,7 @@ STATIC mp_obj_t unpack(msgpack_stream_t *s, mp_obj_t ext_hook, bool use_list) { return unpack_ext(s, read_size(s, code - 0xc7), ext_hook); case 0xc1: // never used default: - mp_raise_ValueError(translate("Invalid format")); + mp_raise_ValueError(MP_ERROR_TEXT("Invalid format")); } } diff --git a/shared-module/os/getenv.c b/shared-module/os/getenv.c index 4644453da9..1f84c2e7ba 100644 --- a/shared-module/os/getenv.c +++ b/shared-module/os/getenv.c @@ -338,20 +338,20 @@ STATIC void handle_getenv_error(os_getenv_err_t error, void (*handle)(const mp_o } else { mp_str_print_quoted(&print, (byte *)"EOF", 3, true); } - handle(&mp_type_ValueError, translate("Invalid byte %.*s"), vstr.len, vstr.buf); + handle(&mp_type_ValueError, MP_ERROR_TEXT("Invalid byte %.*s"), vstr.len, vstr.buf); } else { switch (error) { case GETENV_ERR_OPEN: - handle(&mp_type_ValueError, translate("%S"), translate("File not found")); + handle(&mp_type_ValueError, MP_ERROR_TEXT("%S"), MP_ERROR_TEXT("File not found")); break; case GETENV_ERR_UNICODE: - handle(&mp_type_ValueError, translate("%S"), translate("Invalid unicode escape")); + handle(&mp_type_ValueError, MP_ERROR_TEXT("%S"), MP_ERROR_TEXT("Invalid unicode escape")); break; case GETENV_ERR_NOT_FOUND: - handle(&mp_type_ValueError, translate("%S"), translate("Key not found")); + handle(&mp_type_ValueError, MP_ERROR_TEXT("%S"), MP_ERROR_TEXT("Key not found")); break; default: - handle(&mp_type_RuntimeError, translate("%S"), translate("Internal error")); + handle(&mp_type_RuntimeError, MP_ERROR_TEXT("%S"), MP_ERROR_TEXT("Internal error")); break; } } @@ -359,7 +359,7 @@ STATIC void handle_getenv_error(os_getenv_err_t error, void (*handle)(const mp_o STATIC void common_hal_os_getenv_showerr(const char *key, os_getenv_err_t result) { if (result != GETENV_OK && result != GETENV_ERR_OPEN && result != GETENV_ERR_NOT_FOUND) { - mp_cprintf(&mp_plat_print, translate("An error occurred while retrieving '%s':\n"), key); + mp_cprintf(&mp_plat_print, MP_ERROR_TEXT("An error occurred while retrieving '%s':\n"), key); handle_getenv_error(result, print_dont_raise); } } diff --git a/shared-module/paralleldisplaybus/ParallelBus.c b/shared-module/paralleldisplaybus/ParallelBus.c index cb6ebfb32a..2b6f5ea4de 100644 --- a/shared-module/paralleldisplaybus/ParallelBus.c +++ b/shared-module/paralleldisplaybus/ParallelBus.c @@ -33,5 +33,5 @@ __attribute__((weak)) void common_hal_paralleldisplaybus_parallelbus_construct_nonsequential(paralleldisplaybus_parallelbus_obj_t *self, uint8_t n_pins, const mcu_pin_obj_t **data_pins, 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, uint32_t frequency) { - mp_raise_NotImplementedError(translate("This microcontroller only supports data0=, not data_pins=, because it requires contiguous pins.")); + mp_raise_NotImplementedError(MP_ERROR_TEXT("This microcontroller only supports data0=, not data_pins=, because it requires contiguous pins.")); } diff --git a/shared-module/rgbmatrix/RGBMatrix.c b/shared-module/rgbmatrix/RGBMatrix.c index 4d2458a6b6..554c8e4fa4 100644 --- a/shared-module/rgbmatrix/RGBMatrix.c +++ b/shared-module/rgbmatrix/RGBMatrix.c @@ -60,7 +60,7 @@ void common_hal_rgbmatrix_rgbmatrix_construct(rgbmatrix_rgbmatrix_obj_t *self, i self->timer = timer ? timer : common_hal_rgbmatrix_timer_allocate(self); if (self->timer == NULL) { - mp_raise_ValueError(translate("No timer available")); + mp_raise_ValueError(MP_ERROR_TEXT("No timer available")); } self->width = width; @@ -123,11 +123,11 @@ STATIC void common_hal_rgbmatrix_rgbmatrix_construct1(rgbmatrix_rgbmatrix_obj_t mp_arg_error_invalid(MP_QSTR_args); break; case PROTOMATTER_ERR_MALLOC: - mp_raise_msg_varg(&mp_type_MemoryError, translate("Failed to allocate %q buffer"), MP_QSTR_RGBMatrix); + mp_raise_msg_varg(&mp_type_MemoryError, MP_ERROR_TEXT("Failed to allocate %q buffer"), MP_QSTR_RGBMatrix); break; default: mp_raise_msg_varg(&mp_type_RuntimeError, - translate("Internal error #%d"), (int)stat); + MP_ERROR_TEXT("Internal error #%d"), (int)stat); break; } } diff --git a/shared-module/sdcardio/SDCard.c b/shared-module/sdcardio/SDCard.c index f4fa8b77f2..0ff156f8f8 100644 --- a/shared-module/sdcardio/SDCard.c +++ b/shared-module/sdcardio/SDCard.c @@ -205,7 +205,7 @@ STATIC mp_rom_error_text_t init_card_v1(sdcardio_sdcard_obj_t *self) { return NULL; } } - return translate("timeout waiting for v1 card"); + return MP_ERROR_TEXT("timeout waiting for v1 card"); } STATIC mp_rom_error_text_t init_card_v2(sdcardio_sdcard_obj_t *self) { @@ -222,7 +222,7 @@ STATIC mp_rom_error_text_t init_card_v2(sdcardio_sdcard_obj_t *self) { return NULL; } } - return translate("timeout waiting for v2 card"); + return MP_ERROR_TEXT("timeout waiting for v2 card"); } STATIC mp_rom_error_text_t init_card(sdcardio_sdcard_obj_t *self) { @@ -247,7 +247,7 @@ STATIC mp_rom_error_text_t init_card(sdcardio_sdcard_obj_t *self) { } } if (!reached_idle_state) { - return translate("no SD card"); + return MP_ERROR_TEXT("no SD card"); } } @@ -267,7 +267,7 @@ STATIC mp_rom_error_text_t init_card(sdcardio_sdcard_obj_t *self) { } } else { DEBUG_PRINT("Reading card version, response=0x%02x\n", response); - return translate("couldn't determine SD card version"); + return MP_ERROR_TEXT("couldn't determine SD card version"); } } @@ -276,11 +276,11 @@ STATIC mp_rom_error_text_t init_card(sdcardio_sdcard_obj_t *self) { uint8_t csd[16]; int response = cmd(self, 9, 0, csd, sizeof(csd), true, true); if (response != 0) { - return translate("no response from SD card"); + return MP_ERROR_TEXT("no response from SD card"); } int csd_version = (csd[0] & 0xC0) >> 6; if (csd_version >= 2) { - return translate("SD card CSD format not supported"); + return MP_ERROR_TEXT("SD card CSD format not supported"); } if (csd_version == 1) { @@ -297,7 +297,7 @@ STATIC mp_rom_error_text_t init_card(sdcardio_sdcard_obj_t *self) { { int response = cmd(self, 16, 512, NULL, 0, true, true); if (response != 0) { - return translate("can't set 512 block size"); + return MP_ERROR_TEXT("can't set 512 block size"); } } @@ -398,7 +398,7 @@ STATIC int readblocks(sdcardio_sdcard_obj_t *self, uint32_t start_block, mp_buff int common_hal_sdcardio_sdcard_readblocks(sdcardio_sdcard_obj_t *self, uint32_t start_block, mp_buffer_info_t *buf) { common_hal_sdcardio_check_for_deinit(self); if (buf->len % 512 != 0) { - mp_raise_ValueError(translate("Buffer length must be a multiple of 512")); + mp_raise_ValueError(MP_ERROR_TEXT("Buffer length must be a multiple of 512")); } lock_and_configure_bus(self); @@ -495,7 +495,7 @@ int common_hal_sdcardio_sdcard_sync(sdcardio_sdcard_obj_t *self) { int common_hal_sdcardio_sdcard_writeblocks(sdcardio_sdcard_obj_t *self, uint32_t start_block, mp_buffer_info_t *buf) { common_hal_sdcardio_check_for_deinit(self); if (buf->len % 512 != 0) { - mp_raise_ValueError(translate("Buffer length must be a multiple of 512")); + mp_raise_ValueError(MP_ERROR_TEXT("Buffer length must be a multiple of 512")); } lock_and_configure_bus(self); int r = writeblocks(self, start_block, buf); diff --git a/shared-module/storage/__init__.c b/shared-module/storage/__init__.c index e961f83e31..5dc071435c 100644 --- a/shared-module/storage/__init__.c +++ b/shared-module/storage/__init__.c @@ -259,7 +259,7 @@ void common_hal_storage_remount(const char *mount_path, bool readonly, bool disa #if CIRCUITPY_USB_MSC if (!usb_msc_ejected() && storage_usb_is_enabled) { - mp_raise_RuntimeError(translate("Cannot remount '/' when visible via USB.")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Cannot remount '/' when visible via USB.")); } #endif diff --git a/shared-module/struct/__init__.c b/shared-module/struct/__init__.c index 3cd9d37e03..9a49f5c774 100644 --- a/shared-module/struct/__init__.c +++ b/shared-module/struct/__init__.c @@ -36,7 +36,7 @@ STATIC void struct_validate_format(char fmt) { #if MICROPY_NONSTANDARD_TYPECODES if (fmt == 'S' || fmt == 'O') { - mp_raise_RuntimeError(translate("'S' and 'O' are not supported format types")); + mp_raise_RuntimeError(MP_ERROR_TEXT("'S' and 'O' are not supported format types")); } #endif } @@ -125,7 +125,7 @@ void shared_modules_struct_pack_into(mp_obj_t fmt_in, byte *p, byte *end_p, size const mp_uint_t total_sz = shared_modules_struct_calcsize(fmt_in); if (p + total_sz > end_p) { - mp_raise_RuntimeError(translate("Buffer too small")); + mp_raise_RuntimeError(MP_ERROR_TEXT("Buffer too small")); } size_t i = 0; @@ -181,11 +181,11 @@ mp_obj_tuple_t *shared_modules_struct_unpack_from(mp_obj_t fmt_in, byte *p, byte // Otherwise just make sure it's big enough. if (exact_size) { if (p + total_sz != end_p) { - mp_raise_RuntimeError(translate("buffer size must match format")); + mp_raise_RuntimeError(MP_ERROR_TEXT("buffer size must match format")); } } else { if (p + total_sz > end_p) { - mp_raise_RuntimeError(translate("buffer too small")); + mp_raise_RuntimeError(MP_ERROR_TEXT("buffer too small")); } } diff --git a/shared-module/synthio/Synthesizer.c b/shared-module/synthio/Synthesizer.c index 672ac5b9e6..fb98ffa15f 100644 --- a/shared-module/synthio/Synthesizer.c +++ b/shared-module/synthio/Synthesizer.c @@ -110,7 +110,7 @@ STATIC mp_obj_t validate_note(mp_obj_t note_in) { } else { const mp_obj_type_t *note_type = mp_obj_get_type(note_in); if (note_type != &synthio_note_type) { - mp_raise_TypeError_varg(translate("%q must be of type %q or %q, not %q"), MP_QSTR_note, MP_QSTR_int, MP_QSTR_Note, note_type->name); + mp_raise_TypeError_varg(MP_ERROR_TEXT("%q must be of type %q or %q, not %q"), MP_QSTR_note, MP_QSTR_int, MP_QSTR_Note, note_type->name); } } return note_in; diff --git a/shared-module/synthio/__init__.c b/shared-module/synthio/__init__.c index daf41191f1..b0c1437887 100644 --- a/shared-module/synthio/__init__.c +++ b/shared-module/synthio/__init__.c @@ -425,7 +425,7 @@ STATIC void parse_common(mp_buffer_info_t *bufinfo, mp_obj_t o, int16_t what, mp if (o != mp_const_none) { mp_get_buffer_raise(o, bufinfo, MP_BUFFER_READ); if (bufinfo->typecode != 'h') { - mp_raise_ValueError_varg(translate("%q must be array of type 'h'"), what); + mp_raise_ValueError_varg(MP_ERROR_TEXT("%q must be array of type 'h'"), what); } bufinfo->len /= 2; mp_arg_validate_length_range(bufinfo->len, 2, max_len, what); @@ -550,7 +550,7 @@ bool synthio_block_assign_slot_maybe(mp_obj_t obj, synthio_block_slot_t *slot) { void synthio_block_assign_slot(mp_obj_t obj, synthio_block_slot_t *slot, qstr arg_name) { if (!synthio_block_assign_slot_maybe(obj, slot)) { - mp_raise_TypeError_varg(translate("%q must be of type %q, not %q"), arg_name, MP_QSTR_BlockInput, mp_obj_get_type_qstr(obj)); + mp_raise_TypeError_varg(MP_ERROR_TEXT("%q must be of type %q, not %q"), arg_name, MP_QSTR_BlockInput, mp_obj_get_type_qstr(obj)); } } diff --git a/shared-module/touchio/TouchIn.c b/shared-module/touchio/TouchIn.c index bc98fa05f7..f5b1b44e32 100644 --- a/shared-module/touchio/TouchIn.c +++ b/shared-module/touchio/TouchIn.c @@ -78,7 +78,7 @@ void common_hal_touchio_touchin_construct(touchio_touchin_obj_t *self, const mcu uint16_t raw_reading = get_raw_reading(self); if (raw_reading == TIMEOUT_TICKS) { common_hal_touchio_touchin_deinit(self); - mp_raise_ValueError(translate("No pulldown on pin; 1Mohm recommended")); + mp_raise_ValueError(MP_ERROR_TEXT("No pulldown on pin; 1Mohm recommended")); } self->threshold = raw_reading * 1.05 + 100; } diff --git a/shared-module/usb/core/Device.c b/shared-module/usb/core/Device.c index b6f7a57676..38d38b3dfe 100644 --- a/shared-module/usb/core/Device.c +++ b/shared-module/usb/core/Device.c @@ -52,7 +52,7 @@ STATIC xfer_result_t _xfer_result; STATIC size_t _actual_len; bool common_hal_usb_core_device_construct(usb_core_device_obj_t *self, uint8_t device_number) { if (!tuh_inited()) { - mp_raise_RuntimeError(translate("No usb host port initialized")); + mp_raise_RuntimeError(MP_ERROR_TEXT("No usb host port initialized")); } if (device_number == 0 || device_number > CFG_TUH_DEVICE_MAX + CFG_TUH_HUB) { @@ -179,7 +179,7 @@ STATIC size_t _xfer(tuh_xfer_t *xfer, mp_int_t timeout) { xfer_result_t result = _xfer_result; _xfer_result = 0xff; if (result == XFER_RESULT_STALLED) { - mp_raise_usb_core_USBError(translate("Pipe error")); + mp_raise_usb_core_USBError(MP_ERROR_TEXT("Pipe error")); } if (result == 0xff) { tuh_edpt_abort_xfer(xfer->daddr, xfer->ep_addr); @@ -208,7 +208,7 @@ STATIC bool _open_endpoint(usb_core_device_obj_t *self, mp_int_t endpoint) { } if (self->configuration_descriptor == NULL) { - mp_raise_usb_core_USBError(translate("No configuration set")); + mp_raise_usb_core_USBError(MP_ERROR_TEXT("No configuration set")); } tusb_desc_configuration_t *desc_cfg = (tusb_desc_configuration_t *)self->configuration_descriptor; @@ -305,7 +305,7 @@ mp_int_t common_hal_usb_core_device_ctrl_transfer(usb_core_device_obj_t *self, xfer_result_t result = _xfer_result; _xfer_result = 0xff; if (result == XFER_RESULT_STALLED) { - mp_raise_usb_core_USBError(translate("Pipe error")); + mp_raise_usb_core_USBError(MP_ERROR_TEXT("Pipe error")); } if (result == 0xff) { tuh_edpt_abort_xfer(xfer.daddr, xfer.ep_addr); diff --git a/shared-module/usb_hid/Device.c b/shared-module/usb_hid/Device.c index 00736906c4..b28de9c1b1 100644 --- a/shared-module/usb_hid/Device.c +++ b/shared-module/usb_hid/Device.c @@ -230,11 +230,11 @@ void common_hal_usb_hid_device_send_report(usb_hid_device_obj_t *self, uint8_t * } if (!tud_hid_ready()) { - mp_raise_msg(&mp_type_OSError, translate("USB busy")); + mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("USB busy")); } if (!tud_hid_report(report_id, report, len)) { - mp_raise_msg(&mp_type_OSError, translate("USB error")); + mp_raise_msg(&mp_type_OSError, MP_ERROR_TEXT("USB error")); } } diff --git a/shared-module/vectorio/Circle.c b/shared-module/vectorio/Circle.c index 4f89e46163..a304ec58ad 100644 --- a/shared-module/vectorio/Circle.c +++ b/shared-module/vectorio/Circle.c @@ -15,7 +15,7 @@ void common_hal_vectorio_circle_construct(vectorio_circle_t *self, uint16_t radi void common_hal_vectorio_circle_set_on_dirty(vectorio_circle_t *self, vectorio_event_t on_dirty) { if (self->on_dirty.obj != NULL) { - mp_raise_TypeError(translate("can only have one parent")); + mp_raise_TypeError(MP_ERROR_TEXT("can only have one parent")); } self->on_dirty = on_dirty; } diff --git a/shared-module/vectorio/Polygon.c b/shared-module/vectorio/Polygon.c index d35d489c61..cc21bdda2d 100644 --- a/shared-module/vectorio/Polygon.c +++ b/shared-module/vectorio/Polygon.c @@ -23,7 +23,7 @@ static void _clobber_points_list(vectorio_polygon_t *self, mp_obj_t points_tuple VECTORIO_POLYGON_DEBUG(" self.len: %d, len: %d, ", self->len, len); if (len < 3) { - mp_raise_TypeError(translate("Polygon needs at least 3 points")); + mp_raise_TypeError(MP_ERROR_TEXT("Polygon needs at least 3 points")); } int16_t *points_list = gc_realloc(self->points_list, 2 * len * sizeof(uint16_t), true); @@ -97,7 +97,7 @@ void common_hal_vectorio_polygon_set_points(vectorio_polygon_t *self, mp_obj_t p void common_hal_vectorio_polygon_set_on_dirty(vectorio_polygon_t *self, vectorio_event_t notification) { if (self->on_dirty.obj != NULL) { - mp_raise_TypeError(translate("can only have one parent")); + mp_raise_TypeError(MP_ERROR_TEXT("can only have one parent")); } self->on_dirty = notification; } diff --git a/shared-module/vectorio/Rectangle.c b/shared-module/vectorio/Rectangle.c index 4c2bdc66cb..f9d4b56824 100644 --- a/shared-module/vectorio/Rectangle.c +++ b/shared-module/vectorio/Rectangle.c @@ -14,7 +14,7 @@ void common_hal_vectorio_rectangle_construct(vectorio_rectangle_t *self, uint32_ void common_hal_vectorio_rectangle_set_on_dirty(vectorio_rectangle_t *self, vectorio_event_t on_dirty) { if (self->on_dirty.obj != NULL) { - mp_raise_TypeError(translate("can only have one parent")); + mp_raise_TypeError(MP_ERROR_TEXT("can only have one parent")); } self->on_dirty = on_dirty; } diff --git a/supervisor/shared/bluetooth/bluetooth.c b/supervisor/shared/bluetooth/bluetooth.c index bb44ab0f00..f96c73d661 100644 --- a/supervisor/shared/bluetooth/bluetooth.c +++ b/supervisor/shared/bluetooth/bluetooth.c @@ -116,16 +116,16 @@ void supervisor_bluetooth_status(void) { serial_write("BLE:"); if (advertising) { if (_private_advertising) { - serial_write_compressed(translate("Reconnecting")); + serial_write_compressed(MP_ERROR_TEXT("Reconnecting")); } else { const char *name = (char *)circuitpython_scan_response_data + 2; int len = MIN(strlen(name), sizeof(circuitpython_scan_response_data) - 2); serial_write_substring(name, len); } } else if (was_connected) { - serial_write_compressed(translate("Ok")); + serial_write_compressed(MP_ERROR_TEXT("Ok")); } else { - serial_write_compressed(translate("Off")); + serial_write_compressed(MP_ERROR_TEXT("Off")); } _last_connected = was_connected; diff --git a/supervisor/shared/micropython.c b/supervisor/shared/micropython.c index 5ee0061544..2600d8715d 100644 --- a/supervisor/shared/micropython.c +++ b/supervisor/shared/micropython.c @@ -62,7 +62,7 @@ void mp_hal_stdout_tx_strn(const char *str, size_t len) { #ifdef CIRCUITPY_BOOT_OUTPUT_FILE if (boot_output != NULL) { // Ensure boot_out.txt is capped at 1 filesystem block and ends with a newline - #define TRUNCATED translate("[truncated due to length]") + #define TRUNCATED MP_ERROR_TEXT("[truncated due to length]") size_t truncated_message_len = decompress_length(TRUNCATED); size_t maxlen = 512 - truncated_message_len; // includes trailing '\0' so we do not need to account for trailing newline '\n' in vstr_add_byte if (len + boot_output->len > maxlen) { diff --git a/supervisor/shared/safe_mode.c b/supervisor/shared/safe_mode.c index ee79d88233..2bd9ce3d41 100644 --- a/supervisor/shared/safe_mode.c +++ b/supervisor/shared/safe_mode.c @@ -146,7 +146,7 @@ void print_safe_mode_message(safe_mode_t reason) { return; } - serial_write_compressed(translate("\nYou are in safe mode because:\n")); + serial_write_compressed(MP_ERROR_TEXT("\nYou are in safe mode because:\n")); mp_rom_error_text_t message = NULL; @@ -154,42 +154,42 @@ void print_safe_mode_message(safe_mode_t reason) { switch (reason) { case SAFE_MODE_BROWNOUT: - message = translate("Power dipped. Make sure you are providing enough power."); + message = MP_ERROR_TEXT("Power dipped. Make sure you are providing enough power."); break; case SAFE_MODE_USER: #if defined(BOARD_USER_SAFE_MODE_ACTION) message = BOARD_USER_SAFE_MODE_ACTION; #elif defined(CIRCUITPY_BOOT_BUTTON) - message = translate("You pressed the BOOT button at start up"); + message = MP_ERROR_TEXT("You pressed the BOOT button at start up"); #else - message = translate("You pressed the reset button during boot."); + message = MP_ERROR_TEXT("You pressed the reset button during boot."); #endif break; case SAFE_MODE_NO_CIRCUITPY: - message = translate("CIRCUITPY drive could not be found or created."); + message = MP_ERROR_TEXT("CIRCUITPY drive could not be found or created."); break; case SAFE_MODE_PROGRAMMATIC: - message = translate("The `microcontroller` module was used to boot into safe mode."); + message = MP_ERROR_TEXT("The `microcontroller` module was used to boot into safe mode."); break; #if CIRCUITPY_SAFEMODE_PY case SAFE_MODE_SAFEMODE_PY_ERROR: - message = translate("Error in safemode.py."); + message = MP_ERROR_TEXT("Error in safemode.py."); break; #endif case SAFE_MODE_STACK_OVERFLOW: - message = translate("Heap was corrupted because the stack was too small. Increase stack size."); + message = MP_ERROR_TEXT("Heap was corrupted because the stack was too small. Increase stack size."); break; case SAFE_MODE_USB_TOO_MANY_ENDPOINTS: - message = translate("USB devices need more endpoints than are available."); + message = MP_ERROR_TEXT("USB devices need more endpoints than are available."); break; case SAFE_MODE_USB_TOO_MANY_INTERFACE_NAMES: - message = translate("USB devices specify too many interface names."); + message = MP_ERROR_TEXT("USB devices specify too many interface names."); break; case SAFE_MODE_USB_BOOT_DEVICE_NOT_INTERFACE_ZERO: - message = translate("Boot device must be first (interface #0)."); + message = MP_ERROR_TEXT("Boot device must be first (interface #0)."); break; case SAFE_MODE_WATCHDOG: - message = translate("Internal watchdog timer expired."); + message = MP_ERROR_TEXT("Internal watchdog timer expired."); break; default: break; @@ -200,37 +200,37 @@ void print_safe_mode_message(safe_mode_t reason) { serial_write_compressed(message); } else { // Something worse happened. - serial_write_compressed(translate("CircuitPython core code crashed hard. Whoops!\n")); + serial_write_compressed(MP_ERROR_TEXT("CircuitPython core code crashed hard. Whoops!\n")); switch (reason) { case SAFE_MODE_GC_ALLOC_OUTSIDE_VM: - message = translate("Heap allocation when VM not running."); + message = MP_ERROR_TEXT("Heap allocation when VM not running."); break; case SAFE_MODE_FLASH_WRITE_FAIL: - message = translate("Failed to write internal flash."); + message = MP_ERROR_TEXT("Failed to write internal flash."); break; case SAFE_MODE_HARD_FAULT: - message = translate("Hard fault: memory access or instruction error."); + message = MP_ERROR_TEXT("Hard fault: memory access or instruction error."); break; case SAFE_MODE_INTERRUPT_ERROR: - message = translate("Interrupt error."); + message = MP_ERROR_TEXT("Interrupt error."); break; case SAFE_MODE_NLR_JUMP_FAIL: - message = translate("NLR jump failed. Likely memory corruption."); + message = MP_ERROR_TEXT("NLR jump failed. Likely memory corruption."); break; case SAFE_MODE_NO_HEAP: - message = translate("Unable to allocate the heap."); + message = MP_ERROR_TEXT("Unable to allocate the heap."); break; case SAFE_MODE_SDK_FATAL_ERROR: - message = translate("Third-party firmware fatal error."); + message = MP_ERROR_TEXT("Third-party firmware fatal error."); break; default: - message = translate("Unknown reason."); + message = MP_ERROR_TEXT("Unknown reason."); break; } serial_write_compressed(message); - serial_write_compressed(translate("\nPlease file an issue with your program at github.com/adafruit/circuitpython/issues.")); + serial_write_compressed(MP_ERROR_TEXT("\nPlease file an issue with your program at github.com/adafruit/circuitpython/issues.")); } // Always tell user how to get out of safe mode. - serial_write_compressed(translate("\nPress reset to exit safe mode.\n")); + serial_write_compressed(MP_ERROR_TEXT("\nPress reset to exit safe mode.\n")); } diff --git a/supervisor/shared/translate/compressed_string.h b/supervisor/shared/translate/compressed_string.h index 917f763d7d..442933a9c5 100644 --- a/supervisor/shared/translate/compressed_string.h +++ b/supervisor/shared/translate/compressed_string.h @@ -99,7 +99,7 @@ typedef struct compressed_string { // Return the compressed, translated version of a source string // Usually, due to LTO, this is optimized into a load of a constant // pointer. -// mp_rom_error_text_t translate(const char *c); +// mp_rom_error_text_t MP_ERROR_TEXT(const char *c); void serial_write_compressed(mp_rom_error_text_t compressed); char *decompress(mp_rom_error_text_t compressed, char *decompressed); uint16_t decompress_length(mp_rom_error_text_t compressed); diff --git a/supervisor/shared/translate/translate.h b/supervisor/shared/translate/translate.h index 76bc462625..fddf82675d 100644 --- a/supervisor/shared/translate/translate.h +++ b/supervisor/shared/translate/translate.h @@ -34,9 +34,8 @@ // Map MicroPython's error messages to our translations. #if !defined(MICROPY_ENABLE_DYNRUNTIME) || !MICROPY_ENABLE_DYNRUNTIME #include "supervisor/shared/translate/compressed_string.h" -#define MP_COMPRESSED_ROM_TEXT(x) translate(x) -// translate() is a giant function with many strcmp calls. The assumption is +// MP_ERROR_TEXT() is a giant function with many strcmp calls. The assumption is // that the build process will optimize this away and replace it with the // appropriate compressed data for each call site. @@ -48,7 +47,7 @@ #else // In link time optimized (LTO) builds, we can compile this once into a .o and // at link time the calls will be optimized. -mp_rom_error_text_t translate(const char *c); +mp_rom_error_text_t MP_COMPRESSED_ROM_TEXT(const char *c); #endif #else diff --git a/supervisor/shared/translate/translate_impl.h b/supervisor/shared/translate/translate_impl.h index a57f90ff41..e00480b58a 100644 --- a/supervisor/shared/translate/translate_impl.h +++ b/supervisor/shared/translate/translate_impl.h @@ -50,7 +50,7 @@ __attribute__((always_inline)) #endif // Prevent instrumenting this because that disables the inlining we rely of for code size // optimization. -__attribute__((no_instrument_function)) mp_rom_error_text_t translate(const char *original) { +__attribute__((no_instrument_function)) mp_rom_error_text_t MP_COMPRESSED_ROM_TEXT(const char *original) { #ifndef NO_QSTR #define QDEF(id, hash, len, str) #define TRANSLATION(english_id, number) if (strcmp(original, english_id) == 0) { return (mp_rom_error_text_t)&translation##number; } else diff --git a/supervisor/shared/web_workflow/web_workflow.c b/supervisor/shared/web_workflow/web_workflow.c index f4b81977be..e2c1eee5f3 100644 --- a/supervisor/shared/web_workflow/web_workflow.c +++ b/supervisor/shared/web_workflow/web_workflow.c @@ -238,22 +238,22 @@ void supervisor_web_workflow_status(void) { // TODO: Use these unicode to show signal strength: ▂▄▆█ return; } - serial_write_compressed(translate("Wi-Fi: ")); + serial_write_compressed(MP_ERROR_TEXT("Wi-Fi: ")); _last_wifi_status = _wifi_status; if (_wifi_status == WIFI_RADIO_ERROR_AUTH_EXPIRE || _wifi_status == WIFI_RADIO_ERROR_AUTH_FAIL) { - serial_write_compressed(translate("Authentication failure")); + serial_write_compressed(MP_ERROR_TEXT("Authentication failure")); } else if (_wifi_status != WIFI_RADIO_ERROR_NONE) { mp_printf(&mp_plat_print, "%d", _wifi_status); } else if (ipv4_address == 0) { _last_ip = 0; - serial_write_compressed(translate("No IP")); + serial_write_compressed(MP_ERROR_TEXT("No IP")); } else { } } else { // Keep Wi-Fi print separate so its data can be matched with the one above. - serial_write_compressed(translate("Wi-Fi: ")); - serial_write_compressed(translate("off")); + serial_write_compressed(MP_ERROR_TEXT("Wi-Fi: ")); + serial_write_compressed(MP_ERROR_TEXT("off")); } } #endif