Switch to using MP_ERROR_TEXT instead of translate, globally

This commit is contained in:
Jeff Epler 2023-10-30 09:49:06 +01:00
parent 6b62df4054
commit 774f6ac6ab
No known key found for this signature in database
GPG Key ID: D5BF15AB975AB4DE
390 changed files with 1114 additions and 1114 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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"));
}

View File

@ -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"));
// }
}

View File

@ -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);

View File

@ -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);

View File

@ -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) {

View File

@ -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));

View File

@ -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"));
}
}

View File

@ -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);
}

View File

@ -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;
}

@ -1 +1 @@
Subproject commit 2df210f87a79deedc9003b1bbd6015a2fea7c03e
Subproject commit aec113300008516614a5ff697520fb2ac3bc20bb

View File

@ -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;

View File

@ -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;
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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];

View File

@ -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);
}

View File

@ -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."));
}
}

View File

@ -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;

View File

@ -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"));
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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];

View File

@ -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

View File

@ -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.

View File

@ -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.

View File

@ -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

View File

@ -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();

View File

@ -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) {

View File

@ -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();
}

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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.

View File

@ -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];

View File

@ -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);

View File

@ -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();

View File

@ -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;

View File

@ -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();

View File

@ -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"));
}
}

View File

@ -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);

View File

@ -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

View File

@ -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) {

View File

@ -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) {

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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"));
}
}

View File

@ -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");
}

View File

@ -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) {

View File

@ -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 &&

View File

@ -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

View File

@ -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);

View File

@ -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"));
}
}

View File

@ -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);
}

View File

@ -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();

View File

@ -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;

View File

@ -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);
}

View File

@ -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"));
}
}

View File

@ -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

View File

@ -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);

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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);
}

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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"));
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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 = {

View File

@ -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"));
}
}

View File

@ -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];

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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);

View File

@ -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();

View File

@ -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")); \
} \
}

View File

@ -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) {

Some files were not shown because too many files have changed in this diff Show More