kopia lustrzana https://github.com/pimoroni/pimoroni-pico
MicroPython: Add MP_ERROR_TEXT() for mp_raise_msg() calls.
rodzic
5ed7913a2c
commit
cd2e412ef4
|
@ -40,7 +40,7 @@ mp_obj_t BreakoutAS7262_make_new(const mp_obj_type_t *type, size_t n_args, size_
|
|||
self->breakout = m_new_class(BreakoutAS7262, (pimoroni::I2C *)(self->i2c->i2c), args[ARG_int].u_int);
|
||||
|
||||
if(!self->breakout->init()) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "BreakoutAS7262: breakout not found when initialising");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("BreakoutAS7262: breakout not found when initialising"));
|
||||
}
|
||||
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
|
|
|
@ -40,7 +40,7 @@ mp_obj_t BreakoutAS7343_make_new(const mp_obj_type_t *type, size_t n_args, size_
|
|||
self->breakout = m_new_class(AS7343, (pimoroni::I2C *)(self->i2c->i2c), args[ARG_int].u_int);
|
||||
|
||||
if(!self->breakout->init()) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "BreakoutAS7343: breakout not found when initialising");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("BreakoutAS7343: breakout not found when initialising"));
|
||||
}
|
||||
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
|
|
|
@ -38,7 +38,7 @@ mp_obj_t BreakoutBH1745_make_new(const mp_obj_type_t *type, size_t n_args, size_
|
|||
self->breakout = m_new_class(BreakoutBH1745, (pimoroni::I2C *)(self->i2c->i2c), args[ARG_address].u_int);
|
||||
|
||||
if(!self->breakout->init()) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "BreakoutBH1745: breakout not found when initialising");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("BreakoutBH1745: breakout not found when initialising"));
|
||||
}
|
||||
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
|
|
|
@ -38,7 +38,7 @@ mp_obj_t BreakoutBME280_make_new(const mp_obj_type_t *type, size_t n_args, size_
|
|||
self->breakout = m_new_class(BME280, (pimoroni::I2C *)(self->i2c->i2c), args[ARG_address].u_int, args[ARG_int].u_int);
|
||||
|
||||
if(!self->breakout->init()) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "BreakoutBME280: breakout not found when initialising");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("BreakoutBME280: breakout not found when initialising"));
|
||||
}
|
||||
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
|
@ -56,7 +56,7 @@ mp_obj_t BreakoutBME280_read(mp_obj_t self_in) {
|
|||
return mp_obj_new_tuple(3, tuple);
|
||||
}
|
||||
|
||||
mp_raise_msg(&mp_type_RuntimeError, "BME280: read failed.");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("BME280: read failed."));
|
||||
}
|
||||
|
||||
mp_obj_t BreakoutBME280_configure(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
|
|
|
@ -39,7 +39,7 @@ mp_obj_t BreakoutBME68X_make_new(const mp_obj_type_t *type, size_t n_args, size_
|
|||
self->breakout = m_new_class(BME68X, (pimoroni::I2C *)(self->i2c->i2c), args[ARG_address].u_int, args[ARG_int].u_int);
|
||||
|
||||
if(!self->breakout->init()) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "BreakoutBME68X: breakout not found when initialising");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("BreakoutBME68X: breakout not found when initialising"));
|
||||
}
|
||||
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
|
@ -71,7 +71,7 @@ mp_obj_t BreakoutBME68X_read(size_t n_args, const mp_obj_t *pos_args, mp_map_t *
|
|||
return mp_obj_new_tuple(7, tuple);
|
||||
}
|
||||
else {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "BreakoutBME68X: failed read_forced");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("BreakoutBME68X: failed read_forced"));
|
||||
return mp_const_none;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ mp_obj_t BreakoutBMP280_make_new(const mp_obj_type_t *type, size_t n_args, size_
|
|||
self->breakout = m_new_class(BMP280, (pimoroni::I2C *)(self->i2c->i2c), args[ARG_address].u_int, args[ARG_int].u_int);
|
||||
|
||||
if(!self->breakout->init()) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "BreakoutBMP280: breakout not found when initialising");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("BreakoutBMP280: breakout not found when initialising"));
|
||||
}
|
||||
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
|
|
|
@ -40,7 +40,7 @@ mp_obj_t BreakoutDotMatrix_make_new(const mp_obj_type_t *type, size_t n_args, si
|
|||
self->breakout = m_new_class(BreakoutDotMatrix, (pimoroni::I2C *)(self->i2c->i2c), args[ARG_address].u_int);
|
||||
|
||||
if(!self->breakout->init()) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "DotMatrix breakout not found when initialising");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("DotMatrix breakout not found when initialising"));
|
||||
}
|
||||
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
|
|
|
@ -40,7 +40,7 @@ mp_obj_t BreakoutEncoder_make_new(const mp_obj_type_t *type, size_t n_args, size
|
|||
self->breakout = m_new_class(BreakoutEncoder, (pimoroni::I2C *)(self->i2c->i2c), args[ARG_address].u_int, args[ARG_interrupt].u_int);
|
||||
|
||||
if(!self->breakout->init()) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "BreakoutEncoder: breakout not found when initialising");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("BreakoutEncoder: breakout not found when initialising"));
|
||||
}
|
||||
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
|
|
|
@ -42,7 +42,7 @@ mp_obj_t BreakoutEncoderWheel_make_new(const mp_obj_type_t *type, size_t n_args,
|
|||
self->breakout = m_new_class(BreakoutEncoderWheel, (pimoroni::I2C *)(self->i2c->i2c), args[ARG_ioe_address].u_int, args[ARG_led_address].u_int, args[ARG_interrupt].u_int);
|
||||
|
||||
if(!self->breakout->init()) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "BreakoutEncoderWheel: breakout not found when initialising");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("BreakoutEncoderWheel: breakout not found when initialising"));
|
||||
}
|
||||
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
|
|
|
@ -37,7 +37,7 @@ mp_obj_t BreakoutICP10125_make_new(const mp_obj_type_t *type, size_t n_args, siz
|
|||
self->breakout = m_new_class(ICP10125, (pimoroni::I2C *)(self->i2c->i2c));
|
||||
|
||||
if(!self->breakout->init()) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "BreakoutICP10125: breakout not found when initialising");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("BreakoutICP10125: breakout not found when initialising"));
|
||||
}
|
||||
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
|
|
|
@ -40,7 +40,7 @@ mp_obj_t BreakoutIOExpander_make_new(const mp_obj_type_t *type, size_t n_args, s
|
|||
self->breakout = m_new_class(BreakoutIOExpander, (pimoroni::I2C *)(self->i2c->i2c), args[ARG_address].u_int, args[ARG_interrupt].u_int);
|
||||
|
||||
if(!self->breakout->init()) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "BreakoutIOExpander: breakout not found when initialising");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("BreakoutIOExpander: breakout not found when initialising"));
|
||||
}
|
||||
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
|
|
|
@ -39,7 +39,7 @@ mp_obj_t BreakoutLTR559_make_new(const mp_obj_type_t *type, size_t n_args, size_
|
|||
self->breakout = m_new_class(BreakoutLTR559, (pimoroni::I2C *)(self->i2c->i2c), args[ARG_interrupt].u_int);
|
||||
|
||||
if(!self->breakout->init()) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "BreakoutLTR559: breakout not found when initialising");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("BreakoutLTR559: breakout not found when initialising"));
|
||||
}
|
||||
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
|
|
|
@ -38,7 +38,7 @@ mp_obj_t BreakoutMatrix11x7_make_new(const mp_obj_type_t *type, size_t n_args, s
|
|||
self->breakout = m_new_class(BreakoutMatrix11x7, (pimoroni::I2C *)(self->i2c->i2c), args[ARG_address].u_int);
|
||||
|
||||
if(!self->breakout->init()) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "BreakoutMatrix11x7: breakout not found when initialising");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("BreakoutMatrix11x7: breakout not found when initialising"));
|
||||
}
|
||||
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
|
|
|
@ -40,7 +40,7 @@ mp_obj_t BreakoutMICS6814_make_new(const mp_obj_type_t *type, size_t n_args, siz
|
|||
self->breakout = m_new_class(BreakoutMICS6814, (pimoroni::I2C *)(self->i2c->i2c), args[ARG_address].u_int, args[ARG_interrupt].u_int);
|
||||
|
||||
if(!self->breakout->init()) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "BreakoutMICS6814: breakout not found when initialising");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("BreakoutMICS6814: breakout not found when initialising"));
|
||||
}
|
||||
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
|
|
|
@ -37,7 +37,7 @@ mp_obj_t BreakoutMSA301_make_new(const mp_obj_type_t *type, size_t n_args, size_
|
|||
self->breakout = m_new_class(BreakoutMSA301, (pimoroni::I2C *)(self->i2c->i2c), args[ARG_interrupt].u_int);
|
||||
|
||||
if(!self->breakout->init()) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "BreakoutMSA301: breakout not found when initialising");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("BreakoutMSA301: breakout not found when initialising"));
|
||||
}
|
||||
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
|
|
|
@ -80,14 +80,14 @@ mp_obj_t make_new(enum ChipType chip, const mp_obj_type_t *type, size_t n_args,
|
|||
BreakoutPMW3901 *breakout = m_new_class(BreakoutPMW3901, (BG_SPI_SLOT)slot);
|
||||
if (!breakout->init()) {
|
||||
m_del_class(BreakoutPMW3901, breakout);
|
||||
mp_raise_msg(&mp_type_RuntimeError, "BreakoutPMW3901: Init failed");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("BreakoutPMW3901: Init failed"));
|
||||
}
|
||||
self->breakout = breakout;
|
||||
} else {
|
||||
BreakoutPAA5100 *breakout = m_new_class(BreakoutPAA5100, (BG_SPI_SLOT)slot);
|
||||
if (!breakout->init()) {
|
||||
m_del_class(BreakoutPAA5100, breakout);
|
||||
mp_raise_msg(&mp_type_RuntimeError, "BreakoutPAA5100: Init failed");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("BreakoutPAA5100: Init failed"));
|
||||
}
|
||||
self->breakout = breakout;
|
||||
}
|
||||
|
@ -143,14 +143,14 @@ mp_obj_t make_new(enum ChipType chip, const mp_obj_type_t *type, size_t n_args,
|
|||
BreakoutPMW3901 *breakout = m_new_class(BreakoutPMW3901, spi, args[ARG_cs].u_int, sck, mosi, miso, args[ARG_interrupt].u_int);
|
||||
if (!breakout->init()) {
|
||||
m_del_class(BreakoutPMW3901, breakout);
|
||||
mp_raise_msg(&mp_type_RuntimeError, "BreakoutPMW3901: Init failed");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("BreakoutPMW3901: Init failed"));
|
||||
}
|
||||
self->breakout = breakout;
|
||||
} else {
|
||||
BreakoutPAA5100 *breakout = m_new_class(BreakoutPAA5100, spi, args[ARG_cs].u_int, sck, mosi, miso, args[ARG_interrupt].u_int);
|
||||
if (!breakout->init()) {
|
||||
m_del_class(BreakoutPAA5100, breakout);
|
||||
mp_raise_msg(&mp_type_RuntimeError, "BreakoutPAA5100: Init failed");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("BreakoutPAA5100: Init failed"));
|
||||
}
|
||||
self->breakout = breakout;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ mp_obj_t BreakoutPotentiometer_make_new(const mp_obj_type_t *type, size_t n_args
|
|||
self->breakout = m_new_class(BreakoutPotentiometer, (pimoroni::I2C *)(self->i2c->i2c), args[ARG_interrupt].u_int);
|
||||
|
||||
if(!self->breakout->init()) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "BreakoutPotentiometer: breakout not found when initialising");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("BreakoutPotentiometer: breakout not found when initialising"));
|
||||
}
|
||||
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
|
|
|
@ -39,7 +39,7 @@ mp_obj_t BreakoutRGBMatrix5x5_make_new(const mp_obj_type_t *type, size_t n_args,
|
|||
self->breakout = m_new_class(BreakoutRGBMatrix5x5, (pimoroni::I2C *)(self->i2c->i2c), args[ARG_address].u_int);
|
||||
|
||||
if(!self->breakout->init()) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "BreakoutRGBMatrix5x5: breakout not found when initialising");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("BreakoutRGBMatrix5x5: breakout not found when initialising"));
|
||||
}
|
||||
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
|
|
|
@ -41,7 +41,7 @@ mp_obj_t BreakoutRTC_make_new(const mp_obj_type_t *type, size_t n_args, size_t n
|
|||
self->breakout = m_new_class(BreakoutRTC, (pimoroni::I2C *)(self->i2c->i2c), args[ARG_interrupt].u_int);
|
||||
|
||||
if(!self->breakout->init()) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "BreakoutRTC: breakout not found when initialising");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("BreakoutRTC: breakout not found when initialising"));
|
||||
}
|
||||
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
|
|
|
@ -16,10 +16,10 @@ extern "C" {
|
|||
#include "breakout_scd41.h"
|
||||
#include "pimoroni_i2c.h"
|
||||
|
||||
#define NOT_INITIALISED_MSG "SCD41: Not initialised. Call scd41.init(<i2c instance>) first."
|
||||
#define READ_FAIL_MSG "SCD41: Reading failed."
|
||||
#define FAIL_MSG "SCD41: Error."
|
||||
#define SAMPLE_FAIL_MSG "SCD41: Read invalid sample."
|
||||
#define NOT_INITIALISED_MSG MP_ERROR_TEXT("SCD41: Not initialised. Call scd41.init(<i2c instance>) first.")
|
||||
#define READ_FAIL_MSG MP_ERROR_TEXT("SCD41: Reading failed.")
|
||||
#define FAIL_MSG MP_ERROR_TEXT("SCD41: Error.")
|
||||
#define SAMPLE_FAIL_MSG MP_ERROR_TEXT("SCD41: Read invalid sample.")
|
||||
|
||||
mp_obj_t scd41_init(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ mp_obj_t BreakoutSGP30_make_new(const mp_obj_type_t *type, size_t n_args, size_t
|
|||
self->breakout = m_new_class(BreakoutSGP30, (pimoroni::I2C *)(self->i2c->i2c));
|
||||
|
||||
if(!self->breakout->init()) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "BreakoutSGP30: breakout not found when initialising");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("BreakoutSGP30: breakout not found when initialising"));
|
||||
}
|
||||
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
|
|
|
@ -40,7 +40,7 @@ mp_obj_t BreakoutTrackball_make_new(const mp_obj_type_t *type, size_t n_args, si
|
|||
self->breakout = m_new_class(BreakoutTrackball, (pimoroni::I2C *)(self->i2c->i2c), args[ARG_address].u_int, args[ARG_interrupt].u_int);
|
||||
|
||||
if(!self->breakout->init()) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "Trackball breakout not found when initialising");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("Trackball breakout not found when initialising"));
|
||||
}
|
||||
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
|
|
|
@ -94,7 +94,7 @@ mp_obj_t VL53L5CX_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw
|
|||
self->breakout = m_new_class(pimoroni::VL53L5CX, (pimoroni::I2C*)self->i2c->i2c, (uint8_t *)bufinfo.buf, addr, self->configuration, self->motion_configuration);
|
||||
|
||||
if(!self->breakout->init()) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "VL53L5CX: init error");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("VL53L5CX: init error"));
|
||||
}
|
||||
|
||||
if(args[ARG_firmware].u_obj == nullptr) {
|
||||
|
@ -108,7 +108,7 @@ mp_obj_t VL53L5CX_start_ranging(mp_obj_t self_in) {
|
|||
_VL53L5CX_obj_t *self = MP_OBJ_TO_PTR2(self_in, _VL53L5CX_obj_t);
|
||||
bool status = self->breakout->start_ranging();
|
||||
if(!status) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "VL53L5CX: start_ranging error");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("VL53L5CX: start_ranging error"));
|
||||
}
|
||||
return mp_const_none;
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ mp_obj_t VL53L5CX_stop_ranging(mp_obj_t self_in) {
|
|||
_VL53L5CX_obj_t *self = MP_OBJ_TO_PTR2(self_in, _VL53L5CX_obj_t);
|
||||
bool status = self->breakout->stop_ranging();
|
||||
if(!status) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "VL53L5CX: stop_ranging error");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("VL53L5CX: stop_ranging error"));
|
||||
}
|
||||
return mp_const_none;
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ mp_obj_t VL53L5CX_enable_motion_indicator(mp_obj_t self_in, mp_obj_t value) {
|
|||
_VL53L5CX_obj_t *self = MP_OBJ_TO_PTR2(self_in, _VL53L5CX_obj_t);
|
||||
bool status = self->breakout->enable_motion_indicator((pimoroni::VL53L5CX::Resolution)mp_obj_get_int(value));
|
||||
if(!status) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "VL53L5CX: enable_motion_indicator error");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("VL53L5CX: enable_motion_indicator error"));
|
||||
}
|
||||
return mp_const_none;
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ mp_obj_t VL53L5CX_set_motion_distance(mp_obj_t self_in, mp_obj_t distance_min, m
|
|||
_VL53L5CX_obj_t *self = MP_OBJ_TO_PTR2(self_in, _VL53L5CX_obj_t);
|
||||
bool status = self->breakout->set_motion_distance(mp_obj_get_int(distance_min), mp_obj_get_int(distance_max));
|
||||
if(!status) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "VL53L5CX: set_motion_distance error");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("VL53L5CX: set_motion_distance error"));
|
||||
}
|
||||
return mp_const_none;
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ mp_obj_t VL53L5CX_set_i2c_address(mp_obj_t self_in, mp_obj_t value) {
|
|||
_VL53L5CX_obj_t *self = MP_OBJ_TO_PTR2(self_in, _VL53L5CX_obj_t);
|
||||
bool status = self->breakout->set_i2c_address(mp_obj_get_int(value));
|
||||
if(!status) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "VL53L5CX: set_i2c_address error");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("VL53L5CX: set_i2c_address error"));
|
||||
}
|
||||
return mp_const_none;
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ mp_obj_t VL53L5CX_set_ranging_mode(mp_obj_t self_in, mp_obj_t value) {
|
|||
_VL53L5CX_obj_t *self = MP_OBJ_TO_PTR2(self_in, _VL53L5CX_obj_t);
|
||||
bool status = self->breakout->set_ranging_mode((pimoroni::VL53L5CX::RangingMode)mp_obj_get_int(value));
|
||||
if(!status) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "VL53L5CX: set_ranging_mode error");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("VL53L5CX: set_ranging_mode error"));
|
||||
}
|
||||
return mp_const_none;
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ mp_obj_t VL53L5CX_set_ranging_frequency_hz(mp_obj_t self_in, mp_obj_t value) {
|
|||
_VL53L5CX_obj_t *self = MP_OBJ_TO_PTR2(self_in, _VL53L5CX_obj_t);
|
||||
bool status = self->breakout->set_ranging_frequency_hz(mp_obj_get_int(value));
|
||||
if(!status) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "VL53L5CX: set_ranging_frequency_hz error");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("VL53L5CX: set_ranging_frequency_hz error"));
|
||||
}
|
||||
return mp_const_none;
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ mp_obj_t VL53L5CX_set_resolution(mp_obj_t self_in, mp_obj_t value) {
|
|||
_VL53L5CX_obj_t *self = MP_OBJ_TO_PTR2(self_in, _VL53L5CX_obj_t);
|
||||
bool status = self->breakout->set_resolution((pimoroni::VL53L5CX::Resolution)mp_obj_get_int(value));
|
||||
if(!status) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "VL53L5CX: set_resolution error");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("VL53L5CX: set_resolution error"));
|
||||
}
|
||||
return mp_const_none;
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ mp_obj_t VL53L5CX_set_integration_time_ms(mp_obj_t self_in, mp_obj_t value) {
|
|||
_VL53L5CX_obj_t *self = MP_OBJ_TO_PTR2(self_in, _VL53L5CX_obj_t);
|
||||
bool status = self->breakout->set_integration_time_ms(mp_obj_get_int(value));
|
||||
if(!status) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "VL53L5CX: set_integration_time_ms error");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("VL53L5CX: set_integration_time_ms error"));
|
||||
}
|
||||
return mp_const_none;
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ mp_obj_t VL53L5CX_set_sharpener_percent(mp_obj_t self_in, mp_obj_t value) {
|
|||
_VL53L5CX_obj_t *self = MP_OBJ_TO_PTR2(self_in, _VL53L5CX_obj_t);
|
||||
bool status = self->breakout->set_sharpener_percent(mp_obj_get_int(value));
|
||||
if(!status) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "VL53L5CX: set_sharpener_percent error");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("VL53L5CX: set_sharpener_percent error"));
|
||||
}
|
||||
return mp_const_none;
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ mp_obj_t VL53L5CX_set_target_order(mp_obj_t self_in, mp_obj_t value) {
|
|||
_VL53L5CX_obj_t *self = MP_OBJ_TO_PTR2(self_in, _VL53L5CX_obj_t);
|
||||
bool status = self->breakout->set_target_order((pimoroni::VL53L5CX::TargetOrder)mp_obj_get_int(value));
|
||||
if(!status) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "VL53L5CX: set_target_order error");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("VL53L5CX: set_target_order error"));
|
||||
}
|
||||
return mp_const_none;
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ mp_obj_t VL53L5CX_set_power_mode(mp_obj_t self_in, mp_obj_t value) {
|
|||
_VL53L5CX_obj_t *self = MP_OBJ_TO_PTR2(self_in, _VL53L5CX_obj_t);
|
||||
bool status = self->breakout->set_power_mode((pimoroni::VL53L5CX::PowerMode)mp_obj_get_int(value));
|
||||
if(!status) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "VL53L5CX: set_power_mode error");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("VL53L5CX: set_power_mode error"));
|
||||
}
|
||||
return mp_const_none;
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ mp_obj_t VL53L5CX_get_data(mp_obj_t self_in) {
|
|||
pimoroni::VL53L5CX::ResultsData *results = (pimoroni::VL53L5CX::ResultsData *)self->results;
|
||||
bool status = self->breakout->get_data(results);
|
||||
if(!status) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "VL53L5CX: get_data error");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("VL53L5CX: get_data error"));
|
||||
}
|
||||
|
||||
// Get the current resolution so we only look at valid results.
|
||||
|
|
|
@ -34,7 +34,7 @@ void Channel_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t ki
|
|||
|
||||
/***** Constructor *****/
|
||||
mp_obj_t Channel_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "Cannot create Channel objects. They can only be accessed from CosmicUnicorn.synth_channel()");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("Cannot create Channel objects. They can only be accessed from CosmicUnicorn.synth_channel()"));
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ mp_obj_t Encoder_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw,
|
|||
Encoder *encoder = m_new_class(Encoder, pio, sm, pins, args[ARG_common_pin].u_int, (Direction)direction, counts_per_rev, count_microsteps, freq_divider);
|
||||
if(!encoder->init()) {
|
||||
m_del_class(Encoder, encoder);
|
||||
mp_raise_msg(&mp_type_RuntimeError, "unable to allocate the hardware resources needed to initialise this Encoder. Try running `import gc` followed by `gc.collect()` before creating it");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("unable to allocate the hardware resources needed to initialise this Encoder. Try running `import gc` followed by `gc.collect()` before creating it"));
|
||||
}
|
||||
|
||||
self = mp_obj_malloc_with_finaliser(_Encoder_obj_t, &Encoder_type);
|
||||
|
|
|
@ -34,7 +34,7 @@ void Channel_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t ki
|
|||
|
||||
/***** Constructor *****/
|
||||
mp_obj_t Channel_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "Cannot create Channel objects. They can only be accessed from GalacticUnicorn.synth_channel()");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("Cannot create Channel objects. They can only be accessed from GalacticUnicorn.synth_channel()"));
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ void jpegdec_open_helper(_JPEG_obj_t *self) {
|
|||
result = self->jpeg->openRAM((uint8_t *)self->buf.buf, self->buf.len, JPEGDraw);
|
||||
}
|
||||
|
||||
if(result != 1) mp_raise_msg(&mp_type_RuntimeError, "JPEG: could not read file/buffer.");
|
||||
if(result != 1) mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("JPEG: could not read file/buffer."));
|
||||
}
|
||||
|
||||
mp_obj_t _JPEG_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
|
||||
|
|
|
@ -737,7 +737,7 @@ mp_obj_t MotorCluster_make_new(const mp_obj_type_t *type, size_t n_args, size_t
|
|||
|
||||
if(!cluster->init()) {
|
||||
m_del_class(MotorCluster, cluster);
|
||||
mp_raise_msg(&mp_type_RuntimeError, "unable to allocate the hardware resources needed to initialise this MotorCluster. Try running `import gc` followed by `gc.collect()` before creating it");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("unable to allocate the hardware resources needed to initialise this MotorCluster. Try running `import gc` followed by `gc.collect()` before creating it"));
|
||||
}
|
||||
|
||||
self = mp_obj_malloc_with_finaliser(_MotorCluster_obj_t, &MotorCluster_type);
|
||||
|
|
|
@ -18,9 +18,6 @@ extern "C" {
|
|||
#include "micropython/modules/pimoroni_i2c/pimoroni_i2c.h"
|
||||
#include "py/builtin.h"
|
||||
|
||||
#define BUFFER_TOO_SMALL_MSG "bytearray too small: len(image) < width * height."
|
||||
#define INCORRECT_SIZE_MSG "Scroll height wrong: > 8 pixels."
|
||||
|
||||
typedef struct _PicoScroll_obj_t {
|
||||
mp_obj_base_t base;
|
||||
PicoScroll* scroll;
|
||||
|
@ -152,7 +149,7 @@ mp_obj_t picoscroll_set_pixels(mp_obj_t self_in, mp_obj_t image_obj) {
|
|||
mp_get_buffer_raise(image_obj, &bufinfo, MP_BUFFER_RW);
|
||||
|
||||
if (bufinfo.len < (PicoScroll::WIDTH * PicoScroll::HEIGHT)) {
|
||||
mp_raise_msg(&mp_type_IndexError, BUFFER_TOO_SMALL_MSG);
|
||||
mp_raise_msg(&mp_type_IndexError, MP_ERROR_TEXT("bytearray too small: len(image) < width * height."));
|
||||
}
|
||||
|
||||
self->scroll->set_pixels((const char*)bufinfo.buf);
|
||||
|
|
|
@ -13,7 +13,7 @@ PicoWireless *wireless = nullptr;
|
|||
extern "C" {
|
||||
#include "pico_wireless.h"
|
||||
|
||||
#define NOT_INITIALISED_MSG "Cannot call this function, as picowireless is not initialised. Call picowireless.init() first."
|
||||
#define NOT_INITIALISED_MSG MP_ERROR_TEXT("Cannot call this function, as picowireless is not initialised. Call picowireless.init() first.")
|
||||
|
||||
static void mp_obj_to_string(const mp_obj_t &obj, std::string &string_out) {
|
||||
if(mp_obj_is_str_or_bytes(obj)) {
|
||||
|
|
|
@ -116,7 +116,7 @@ void pngdec_open_helper(_PNG_obj_t *self) {
|
|||
result = self->png->openRAM((uint8_t *)self->buf.buf, self->buf.len, self->decode_callback);
|
||||
}
|
||||
|
||||
if(result != 0) mp_raise_msg(&mp_type_RuntimeError, "PNG: could not read file/buffer.");
|
||||
if(result != 0) mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("PNG: could not read file/buffer."));
|
||||
}
|
||||
|
||||
void PNGDraw(PNGDRAW *pDraw) {
|
||||
|
|
|
@ -785,7 +785,7 @@ mp_obj_t Calibration_value_to_pulse(size_t n_args, const mp_obj_t *pos_args, mp_
|
|||
return mp_obj_new_tuple(2, tuple);
|
||||
}
|
||||
else {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "Unable to convert value to pulse. Calibration needs at least 2 pairs");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("Unable to convert value to pulse. Calibration needs at least 2 pairs"));
|
||||
}
|
||||
return mp_const_none;
|
||||
}
|
||||
|
@ -813,7 +813,7 @@ mp_obj_t Calibration_pulse_to_value(size_t n_args, const mp_obj_t *pos_args, mp_
|
|||
return mp_obj_new_tuple(2, tuple);
|
||||
}
|
||||
else {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "Unable to convert pulse to value. Calibration needs at least 2 pairs");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("Unable to convert pulse to value. Calibration needs at least 2 pairs"));
|
||||
}
|
||||
return mp_const_none;
|
||||
}
|
||||
|
@ -1348,7 +1348,7 @@ mp_obj_t ServoCluster_make_new(const mp_obj_type_t *type, size_t n_args, size_t
|
|||
|
||||
if(!cluster->init()) {
|
||||
m_del_class(ServoCluster, cluster);
|
||||
mp_raise_msg(&mp_type_RuntimeError, "unable to allocate the hardware resources needed to initialise this ServoCluster. Try running `import gc` followed by `gc.collect()` before creating it");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("unable to allocate the hardware resources needed to initialise this ServoCluster. Try running `import gc` followed by `gc.collect()` before creating it"));
|
||||
}
|
||||
|
||||
self = mp_obj_malloc_with_finaliser(_ServoCluster_obj_t, &ServoCluster_type);
|
||||
|
|
|
@ -34,7 +34,7 @@ void Channel_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t ki
|
|||
|
||||
/***** Constructor *****/
|
||||
mp_obj_t Channel_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "Cannot create Channel objects. They can only be accessed from StellarUnicorn.synth_channel()");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("Cannot create Channel objects. They can only be accessed from StellarUnicorn.synth_channel()"));
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ mp_obj_t Wakeup_reset_gpio_state() {
|
|||
}
|
||||
|
||||
void err_no_sr() {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "Wakeup_get_shift_state: board does not have a shift register.");
|
||||
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("Wakeup_get_shift_state: board does not have a shift register."));
|
||||
}
|
||||
|
||||
mp_obj_t Wakeup_reset_shift_state() {
|
||||
|
|
Ładowanie…
Reference in New Issue