kopia lustrzana https://github.com/pimoroni/pimoroni-pico
Tidy up constructors, drop unused variables, const single addr
Removes i2c_inst_t from constructors since it's ignored, and updated the Python bindings not to supply this argument. Instance is inferred from the supplied pins.pull/129/head
rodzic
445737088f
commit
77839e2a6a
|
@ -72,18 +72,20 @@ namespace pimoroni {
|
|||
|
||||
// interface pins with our standard defaults where appropriate
|
||||
int8_t address = DEFAULT_I2C_ADDRESS;
|
||||
uint interrupt = PIN_UNUSED;
|
||||
uint interrupt = PIN_UNUSED;
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// Constructors/Destructor
|
||||
//--------------------------------------------------
|
||||
public:
|
||||
AS7262() : AS7262(DEFAULT_I2C_ADDRESS) {};
|
||||
AS7262(uint8_t address) : i2c(new I2C()), address(address) {};
|
||||
AS7262(i2c_inst_t *i2c_inst, uint8_t address, uint sda, uint scl, uint interrupt = PIN_UNUSED) : i2c(new I2C()), address(address), interrupt(interrupt) {}
|
||||
AS7262(uint8_t address = DEFAULT_I2C_ADDRESS, uint interrupt = PIN_UNUSED) : AS7262(new I2C(), address, interrupt) {};
|
||||
|
||||
AS7262(I2C *i2c, uint8_t address = DEFAULT_I2C_ADDRESS, uint interrupt = PIN_UNUSED) : i2c(i2c), address(address), interrupt(interrupt) {}
|
||||
|
||||
// TODO remove MicroPython-binding compatibility constructors
|
||||
AS7262(uint8_t address, uint sda, uint scl, uint interrupt = PIN_UNUSED) : AS7262(new I2C(), address, interrupt) {}
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// Methods
|
||||
|
|
|
@ -297,18 +297,6 @@ namespace pimoroni {
|
|||
this->mode = mode;
|
||||
}
|
||||
|
||||
IOExpander::IOExpander() :
|
||||
IOExpander(new I2C(), DEFAULT_I2C_ADDRESS, DEFAULT_INT_PIN, timeout, debug) {};
|
||||
|
||||
IOExpander::IOExpander(uint8_t address, uint32_t timeout, bool debug) :
|
||||
IOExpander(new I2C(), address, DEFAULT_INT_PIN, timeout, debug) {};
|
||||
|
||||
IOExpander::IOExpander(uint8_t address, uint sda, uint scl, uint interrupt, uint32_t timeout, bool debug) :
|
||||
IOExpander(new I2C(sda, scl), address, interrupt, timeout, debug) {};
|
||||
|
||||
IOExpander::IOExpander(i2c_inst_t *i2c, uint8_t address, uint sda, uint scl, uint interrupt, uint32_t timeout, bool debug) :
|
||||
IOExpander(new I2C(sda, scl), address, interrupt, timeout, debug) {};
|
||||
|
||||
IOExpander::IOExpander(I2C *i2c, uint8_t address, uint interrupt, uint32_t timeout, bool debug) :
|
||||
i2c(i2c),
|
||||
address(address), interrupt(interrupt),
|
||||
|
|
|
@ -28,10 +28,6 @@ namespace pimoroni {
|
|||
|
||||
public:
|
||||
static const uint8_t DEFAULT_I2C_ADDRESS = 0x18;
|
||||
static const uint8_t DEFAULT_SDA_PIN = 20;
|
||||
static const uint8_t DEFAULT_SCL_PIN = 21;
|
||||
static const uint8_t DEFAULT_INT_PIN = 22;
|
||||
static const uint8_t PIN_UNUSED = UINT8_MAX;
|
||||
|
||||
static const uint16_t CHIP_ID = 0xE26A;
|
||||
static const uint8_t CHIP_VERSION = 2;
|
||||
|
@ -148,7 +144,7 @@ namespace pimoroni {
|
|||
|
||||
// interface pins with our standard defaults where appropriate
|
||||
int8_t address = DEFAULT_I2C_ADDRESS;
|
||||
uint interrupt = DEFAULT_INT_PIN;
|
||||
uint interrupt = PIN_UNUSED;
|
||||
|
||||
uint32_t timeout;
|
||||
bool debug;
|
||||
|
@ -162,10 +158,16 @@ namespace pimoroni {
|
|||
// Constructors/Destructor
|
||||
//--------------------------------------------------
|
||||
public:
|
||||
IOExpander();
|
||||
IOExpander(uint8_t address, uint32_t timeout = 1, bool debug = false);
|
||||
IOExpander(uint8_t address, uint sda, uint scl, uint interrupt = PIN_UNUSED, uint32_t timeout = 1, bool debug = false);
|
||||
IOExpander(i2c_inst_t *i2c, uint8_t address, uint sda, uint scl, uint interrupt = PIN_UNUSED, uint32_t timeout = 1, bool debug = false);
|
||||
IOExpander() :
|
||||
IOExpander(new I2C(), DEFAULT_I2C_ADDRESS, PIN_UNUSED, timeout, debug) {};
|
||||
|
||||
IOExpander(uint8_t address, uint32_t timeout = 1, bool debug = false) :
|
||||
IOExpander(new I2C(), address, PIN_UNUSED, timeout, debug) {};
|
||||
|
||||
IOExpander(uint8_t address, uint sda, uint scl, uint interrupt = PIN_UNUSED, uint32_t timeout = 1, bool debug = false) :
|
||||
IOExpander(new I2C(sda, scl), address, interrupt, timeout, debug) {};
|
||||
|
||||
// TODO remove MicroPython-binding compatibility constructors
|
||||
IOExpander(I2C *i2c, uint8_t address=DEFAULT_I2C_ADDRESS, uint interrupt = PIN_UNUSED, uint32_t timeout = 1, bool debug = false);
|
||||
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ namespace pimoroni {
|
|||
LTP305(I2C *i2c, uint8_t address = DEFAULT_I2C_ADDRESS) :
|
||||
i2c(i2c), address(address) {}
|
||||
|
||||
LTP305(i2c_inst_t *i2c, uint8_t address, uint8_t sda, uint8_t scl) : LTP305(new I2C(sda, scl), address) {}
|
||||
LTP305(uint8_t address, uint sda, uint scl) : LTP305(new I2C(sda, scl), address) {}
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
|
|
|
@ -128,8 +128,8 @@ namespace pimoroni {
|
|||
I2C *i2c;
|
||||
|
||||
// interface pins with our standard defaults where appropriate
|
||||
uint8_t address = DEFAULT_I2C_ADDRESS;
|
||||
uint interrupt = PIN_UNUSED;
|
||||
const uint8_t address = DEFAULT_I2C_ADDRESS;
|
||||
uint interrupt = PIN_UNUSED;
|
||||
|
||||
static pimoroni::lookup lookup_led_current;
|
||||
static pimoroni::lookup lookup_led_duty_cycle;
|
||||
|
@ -144,11 +144,12 @@ namespace pimoroni {
|
|||
// Constructors/Destructor
|
||||
//--------------------------------------------------
|
||||
public:
|
||||
LTR559() : LTR559(DEFAULT_I2C_ADDRESS) {};
|
||||
LTR559(uint8_t address) : i2c(new I2C()), address(address) {};
|
||||
LTR559(i2c_inst_t *i2c_inst, uint8_t address, uint sda, uint scl, uint interrupt = PIN_UNUSED) : i2c(new I2C()), address(address), interrupt(interrupt) {}
|
||||
LTR559(I2C *i2c, uint8_t address = DEFAULT_I2C_ADDRESS, uint interrupt = PIN_UNUSED) :
|
||||
i2c(i2c), address(address), interrupt(interrupt) {}
|
||||
LTR559() : LTR559(new I2C()) {};
|
||||
|
||||
LTR559(I2C *i2c, uint interrupt = PIN_UNUSED) : i2c(i2c), interrupt(interrupt) {}
|
||||
|
||||
// TODO remove MicroPython-binding compatibility constructors
|
||||
LTR559(uint sda, uint scl, uint interrupt = PIN_UNUSED) : LTR559(new I2C(), interrupt) {}
|
||||
|
||||
//--------------------------------------------------
|
||||
// Methods
|
||||
|
|
|
@ -105,17 +105,19 @@ namespace pimoroni {
|
|||
//--------------------------------------------------
|
||||
private:
|
||||
I2C *i2c;
|
||||
uint8_t address = DEFAULT_I2C_ADDRESS;
|
||||
uint interrupt = PIN_UNUSED;
|
||||
const uint8_t address = DEFAULT_I2C_ADDRESS;
|
||||
uint interrupt = PIN_UNUSED;
|
||||
|
||||
//--------------------------------------------------
|
||||
// Constructors/Destructor
|
||||
//--------------------------------------------------
|
||||
public:
|
||||
MSA301() : MSA301(DEFAULT_I2C_ADDRESS) {};
|
||||
MSA301(uint8_t address) : i2c(new I2C()), address(address) {};
|
||||
MSA301(i2c_inst_t *i2c_inst, uint8_t address, uint sda, uint scl, uint interrupt = PIN_UNUSED) : i2c(new I2C(sda, scl)), address(address), interrupt(interrupt) {}
|
||||
MSA301(I2C *i2c, uint8_t address = DEFAULT_I2C_ADDRESS, uint interrupt = PIN_UNUSED) : i2c(i2c), address(address), interrupt(interrupt) {}
|
||||
MSA301() : MSA301(new I2C()) {};
|
||||
|
||||
MSA301(I2C *i2c, uint interrupt = PIN_UNUSED) : i2c(i2c), interrupt(interrupt) {}
|
||||
|
||||
// TODO remove MicroPython-binding compatibility constructors
|
||||
MSA301(i2c_inst_t *i2c_inst, uint sda, uint scl, uint interrupt = PIN_UNUSED) : MSA301(new I2C(sda, scl), interrupt) {}
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
|
|
|
@ -209,7 +209,7 @@ namespace pimoroni {
|
|||
I2C *i2c;
|
||||
|
||||
// interface pins with our standard defaults where appropriate
|
||||
int8_t address = DEFAULT_I2C_ADDRESS;
|
||||
const int8_t address = DEFAULT_I2C_ADDRESS;
|
||||
uint interrupt = DEFAULT_INT_PIN;
|
||||
|
||||
uint8_t times[TIME_ARRAY_LENGTH];
|
||||
|
@ -219,15 +219,13 @@ namespace pimoroni {
|
|||
// Constructors/Destructor
|
||||
//--------------------------------------------------
|
||||
public:
|
||||
RV3028() {}
|
||||
RV3028() : RV3028(new I2C()) {}
|
||||
|
||||
RV3028(uint8_t address) :
|
||||
address(address) {}
|
||||
RV3028(I2C *i2c, uint interrupt = DEFAULT_INT_PIN) :
|
||||
i2c(i2c), interrupt(interrupt) {}
|
||||
|
||||
RV3028(I2C *i2c, uint8_t address = DEFAULT_I2C_ADDRESS, uint interrupt = DEFAULT_INT_PIN) :
|
||||
i2c(i2c), address(address), interrupt(interrupt) {}
|
||||
|
||||
RV3028(i2c_inst_t *i2c, uint8_t address, uint8_t sda, uint8_t scl) : RV3028(new I2C(sda, scl), address) {}
|
||||
// TODO remove MicroPython-binding compatibility constructors
|
||||
RV3028(i2c_inst_t *i2c, uint sda, uint scl, uint interrupt = DEFAULT_INT_PIN) : RV3028(new I2C(sda, scl), interrupt) {}
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
|
|
|
@ -39,18 +39,19 @@ namespace pimoroni {
|
|||
private:
|
||||
I2C *i2c;
|
||||
|
||||
int8_t address = DEFAULT_I2C_ADDRESS;
|
||||
const int8_t address = DEFAULT_I2C_ADDRESS;
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// Constructors/Destructor
|
||||
//--------------------------------------------------
|
||||
public:
|
||||
SGP30() : SGP30(DEFAULT_I2C_ADDRESS) {};
|
||||
SGP30(uint8_t address) : i2c(new I2C()), address(address) {};
|
||||
SGP30() : SGP30(new I2C()) {};
|
||||
|
||||
SGP30(I2C *i2c) : i2c(i2c) {}
|
||||
|
||||
// TODO remove MicroPython-binding compatibility constructors
|
||||
SGP30(i2c_inst_t *i2c_inst, uint sda, uint scl) : i2c(new I2C(sda, scl)) { }
|
||||
SGP30(i2c_inst_t *i2c_inst, uint8_t address, uint sda, uint scl) : i2c(new I2C(sda, scl)) , address(address) {}
|
||||
SGP30(I2C *i2c, uint8_t address = DEFAULT_I2C_ADDRESS, uint interrupt = PIN_UNUSED) : i2c(i2c), address(address) {}
|
||||
|
||||
//--------------------------------------------------
|
||||
// Methods
|
||||
|
|
|
@ -48,11 +48,12 @@ namespace pimoroni {
|
|||
// Constructors/Destructor
|
||||
//--------------------------------------------------
|
||||
public:
|
||||
Trackball() : Trackball(DEFAULT_I2C_ADDRESS) {};
|
||||
Trackball(uint8_t address) : i2c(new I2C()), address(address) {};
|
||||
Trackball(i2c_inst_t *i2c_inst, uint8_t address, uint sda, uint scl, uint interrupt = PIN_UNUSED, uint32_t timeout = DEFAULT_TIMEOUT) : i2c(new I2C(sda, scl)), address(address), interrupt(interrupt) {}
|
||||
Trackball(uint8_t address = DEFAULT_I2C_ADDRESS) : i2c(new I2C()), address(address) {};
|
||||
|
||||
Trackball(I2C *i2c, uint8_t address = DEFAULT_I2C_ADDRESS, uint interrupt = PIN_UNUSED, uint32_t timeout = DEFAULT_TIMEOUT) : i2c(i2c), address(address), interrupt(interrupt) {}
|
||||
|
||||
// TODO remove MicroPython-binding compatibility constructors
|
||||
Trackball(i2c_inst_t *i2c_inst, uint8_t address, uint sda, uint scl, uint interrupt = PIN_UNUSED, uint32_t timeout = DEFAULT_TIMEOUT) : Trackball(new I2C(sda, scl), address, interrupt) {}
|
||||
|
||||
//--------------------------------------------------
|
||||
// Methods
|
||||
|
|
|
@ -54,18 +54,13 @@ namespace pimoroni {
|
|||
// Constructors/Destructor
|
||||
//--------------------------------------------------
|
||||
public:
|
||||
BreakoutEncoder() :
|
||||
ioe(DEFAULT_I2C_ADDRESS) {}
|
||||
|
||||
BreakoutEncoder(uint8_t address) :
|
||||
ioe(address) {}
|
||||
BreakoutEncoder(uint8_t address = DEFAULT_I2C_ADDRESS) : BreakoutEncoder(new I2C(), address) {};
|
||||
|
||||
BreakoutEncoder(I2C *i2c, uint8_t address = DEFAULT_I2C_ADDRESS, uint interrupt = PIN_UNUSED, uint32_t timeout = DEFAULT_TIMEOUT, bool debug = false) :
|
||||
ioe(i2c, address, interrupt, timeout, debug) {}
|
||||
|
||||
BreakoutEncoder(i2c_inst_t *i2c, uint8_t address, uint8_t sda, uint8_t scl, uint interrupt = PIN_UNUSED, uint32_t timeout = DEFAULT_TIMEOUT) :
|
||||
ioe(i2c, address, sda, scl, interrupt, timeout),
|
||||
interrupt_pin(interrupt) {}
|
||||
// TODO remove MicroPython-binding compatibility constructors
|
||||
BreakoutEncoder(uint8_t address, uint sda, uint scl, uint interrupt = PIN_UNUSED, uint32_t timeout = DEFAULT_TIMEOUT) : BreakoutEncoder(new I2C(sda, scl), address, interrupt, timeout) {};
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
|
|
|
@ -11,7 +11,6 @@ namespace pimoroni {
|
|||
public:
|
||||
static const uint8_t DEFAULT_I2C_ADDRESS = 0x19;
|
||||
static constexpr float DEFAULT_BRIGHTNESS = 1.0f; //Effectively the maximum fraction of the period that the LED will be on
|
||||
static const uint8_t PIN_UNUSED = UINT8_MAX;
|
||||
static const uint32_t DEFAULT_TIMEOUT = 1;
|
||||
static const uint32_t DEFAULT_ADC_TIMEOUT = 1;
|
||||
|
||||
|
@ -53,15 +52,13 @@ namespace pimoroni {
|
|||
// Constructors/Destructor
|
||||
//--------------------------------------------------
|
||||
public:
|
||||
BreakoutMICS6814() :
|
||||
ioe(DEFAULT_I2C_ADDRESS) {}
|
||||
BreakoutMICS6814(uint8_t address = DEFAULT_I2C_ADDRESS) : BreakoutMICS6814(new I2C(), address) {};
|
||||
|
||||
BreakoutMICS6814(uint8_t address) :
|
||||
ioe(address) {}
|
||||
|
||||
BreakoutMICS6814(i2c_inst_t *i2c, uint8_t address, uint8_t sda, uint8_t scl, uint8_t interrupt = PIN_UNUSED, uint32_t timeout = DEFAULT_TIMEOUT) :
|
||||
ioe(i2c, address, sda, scl, interrupt, timeout) {}
|
||||
BreakoutMICS6814(I2C *i2c, uint8_t address = DEFAULT_I2C_ADDRESS, uint interrupt = PIN_UNUSED, uint32_t timeout = DEFAULT_TIMEOUT, bool debug = false) :
|
||||
ioe(i2c, address, interrupt, timeout, debug) {}
|
||||
|
||||
// TODO remove MicroPython-binding compatibility constructors
|
||||
BreakoutMICS6814(uint8_t address, uint sda, uint scl, uint interrupt = PIN_UNUSED, uint32_t timeout = DEFAULT_TIMEOUT) : BreakoutMICS6814(new I2C(sda, scl), address, interrupt, timeout) {};
|
||||
|
||||
//--------------------------------------------------
|
||||
// Methods
|
||||
|
|
|
@ -22,7 +22,6 @@ namespace pimoroni {
|
|||
static const uint8_t DEFAULT_I2C_ADDRESS = 0x0E;
|
||||
static constexpr float DEFAULT_BRIGHTNESS = 1.0f; //Effectively the maximum fraction of the period that the LED will be on
|
||||
static const Direction DEFAULT_DIRECTION = DIRECTION_CW;
|
||||
static const uint8_t PIN_UNUSED = UINT8_MAX;
|
||||
static const uint32_t DEFAULT_TIMEOUT = 1;
|
||||
static const uint32_t DEFAULT_ADC_TIMEOUT = 1;
|
||||
|
||||
|
@ -51,17 +50,13 @@ namespace pimoroni {
|
|||
// Constructors/Destructor
|
||||
//--------------------------------------------------
|
||||
public:
|
||||
BreakoutPotentiometer() :
|
||||
ioe(DEFAULT_I2C_ADDRESS) {}
|
||||
BreakoutPotentiometer(uint8_t address = DEFAULT_I2C_ADDRESS) : BreakoutPotentiometer(new I2C(), address) {};
|
||||
|
||||
BreakoutPotentiometer(uint8_t address) :
|
||||
ioe(address) {}
|
||||
|
||||
BreakoutPotentiometer(I2C *i2c, uint8_t address = DEFAULT_I2C_ADDRESS, uint8_t interrupt = PIN_UNUSED, uint32_t timeout = DEFAULT_TIMEOUT, bool debug = false) :
|
||||
BreakoutPotentiometer(I2C *i2c, uint8_t address = DEFAULT_I2C_ADDRESS, uint interrupt = PIN_UNUSED, uint32_t timeout = DEFAULT_TIMEOUT, bool debug = false) :
|
||||
ioe(i2c, address, interrupt, timeout, debug) {}
|
||||
|
||||
BreakoutPotentiometer(i2c_inst_t *i2c, uint8_t address, uint8_t sda, uint8_t scl, uint8_t interrupt = PIN_UNUSED, uint32_t timeout = DEFAULT_TIMEOUT) :
|
||||
ioe(i2c, address, sda, scl, interrupt, timeout) {}
|
||||
// TODO remove MicroPython-binding compatibility constructors
|
||||
BreakoutPotentiometer(uint8_t address, uint sda, uint scl, uint interrupt = PIN_UNUSED, uint32_t timeout = DEFAULT_TIMEOUT) : BreakoutPotentiometer(new I2C(sda, scl), address, interrupt, timeout) {};
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
from breakout_rtc import BreakoutRTC
|
||||
import time
|
||||
|
||||
rtc = BreakoutRTC()
|
||||
# rtc = BreakoutRTC(sda=4, scl=5) # i2c pins 4, 5 for Breakout Garden
|
||||
rtc = BreakoutRTC() # Default i2c pins for Pico Explorer
|
||||
|
||||
if rtc.is_12_hour():
|
||||
rtc.set_24_hour()
|
||||
|
@ -12,6 +14,8 @@ while True:
|
|||
rtc.clear_periodic_update_interrupt_flag()
|
||||
|
||||
if rtc.update_time():
|
||||
date = rtc.string_date()
|
||||
time = rtc.string_time()
|
||||
print("Date: ", date, ", Time: ", time, sep="")
|
||||
rtc_date = rtc.string_date()
|
||||
rtc_time = rtc.string_time()
|
||||
print("Date: ", rtc_date, ", Time: ", rtc_time, sep="")
|
||||
|
||||
time.sleep(0.1)
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import time
|
||||
from breakout_sgp30 import BreakoutSGP30
|
||||
|
||||
sgp30 = BreakoutSGP30()
|
||||
# sgp30 = BreakoutSGP30(sda=4, scl=5) # i2c pins 4, 5 for Breakout Garden
|
||||
sgp30 = BreakoutSGP30() # Default i2c pins for Pico Explorer
|
||||
|
||||
print("SGP30 initialised - about to start measuring without waiting")
|
||||
|
||||
sgp30.start_measurement(False)
|
||||
|
|
|
@ -79,8 +79,7 @@ mp_obj_t BreakoutAS7262_make_new(const mp_obj_type_t *type, size_t n_args, size_
|
|||
self = m_new_obj(breakout_as7262_BreakoutAS7262_obj_t);
|
||||
self->base.type = &breakout_as7262_BreakoutAS7262_type;
|
||||
|
||||
i2c_inst_t *i2c = (i2c_id == 0) ? i2c0 : i2c1;
|
||||
self->breakout = new BreakoutAS7262(i2c, sda, scl, args[ARG_int].u_int);
|
||||
self->breakout = new BreakoutAS7262(sda, scl, args[ARG_int].u_int);
|
||||
|
||||
if(!self->breakout->init()) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "AS7262 breakout not found when initialising");
|
||||
|
|
|
@ -82,8 +82,7 @@ mp_obj_t BreakoutDotMatrix_make_new(const mp_obj_type_t *type, size_t n_args, si
|
|||
self = m_new_obj(breakout_dotmatrix_BreakoutDotMatrix_obj_t);
|
||||
self->base.type = &breakout_dotmatrix_BreakoutDotMatrix_type;
|
||||
|
||||
i2c_inst_t *i2c = (i2c_id == 0) ? i2c0 : i2c1;
|
||||
self->breakout = new BreakoutDotMatrix(i2c, args[ARG_address].u_int, sda, scl);
|
||||
self->breakout = new BreakoutDotMatrix(args[ARG_address].u_int, sda, scl);
|
||||
|
||||
if(!self->breakout->init()) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "DotMatrix breakout not found when initialising");
|
||||
|
|
|
@ -86,8 +86,7 @@ mp_obj_t BreakoutEncoder_make_new(const mp_obj_type_t *type, size_t n_args, size
|
|||
self = m_new_obj(breakout_encoder_BreakoutEncoder_obj_t);
|
||||
self->base.type = &breakout_encoder_BreakoutEncoder_type;
|
||||
|
||||
i2c_inst_t *i2c = (i2c_id == 0) ? i2c0 : i2c1;
|
||||
self->breakout = new BreakoutEncoder(i2c, args[ARG_address].u_int, sda, scl, args[ARG_interrupt].u_int);
|
||||
self->breakout = new BreakoutEncoder(args[ARG_address].u_int, sda, scl, args[ARG_interrupt].u_int);
|
||||
|
||||
if(!self->breakout->init()) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "Encoder breakout not found when initialising");
|
||||
|
|
|
@ -86,8 +86,7 @@ mp_obj_t BreakoutIOExpander_make_new(const mp_obj_type_t *type, size_t n_args, s
|
|||
self = m_new_obj(breakout_ioexpander_BreakoutIOExpander_obj_t);
|
||||
self->base.type = &breakout_ioexpander_BreakoutIOExpander_type;
|
||||
|
||||
i2c_inst_t *i2c = (i2c_id == 0) ? i2c0 : i2c1;
|
||||
self->breakout = new BreakoutIOExpander(i2c, args[ARG_address].u_int, sda, scl, args[ARG_interrupt].u_int);
|
||||
self->breakout = new BreakoutIOExpander(args[ARG_address].u_int, sda, scl, args[ARG_interrupt].u_int);
|
||||
|
||||
if(!self->breakout->init()) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "IOExpander breakout not found when initialising");
|
||||
|
|
|
@ -50,10 +50,9 @@ void BreakoutLTR559_print(const mp_print_t *print, mp_obj_t self_in, mp_print_ki
|
|||
mp_obj_t BreakoutLTR559_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
|
||||
breakout_ltr559_BreakoutLTR559_obj_t *self = nullptr;
|
||||
|
||||
enum { ARG_i2c, ARG_address, ARG_sda, ARG_scl, ARG_interrupt };
|
||||
enum { ARG_i2c, ARG_sda, ARG_scl, ARG_interrupt };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_i2c, MP_ARG_INT, {.u_int = -1} },
|
||||
{ MP_QSTR_address, MP_ARG_INT, {.u_int = BreakoutLTR559::DEFAULT_I2C_ADDRESS} },
|
||||
{ MP_QSTR_sda, MP_ARG_INT, {.u_int = I2C_DEFAULT_SDA} },
|
||||
{ MP_QSTR_scl, MP_ARG_INT, {.u_int = I2C_DEFAULT_SCL} },
|
||||
{ MP_QSTR_interrupt, MP_ARG_INT, {.u_int = -1} },
|
||||
|
@ -85,9 +84,8 @@ mp_obj_t BreakoutLTR559_make_new(const mp_obj_type_t *type, size_t n_args, size_
|
|||
|
||||
self = m_new_obj(breakout_ltr559_BreakoutLTR559_obj_t);
|
||||
self->base.type = &breakout_ltr559_BreakoutLTR559_type;
|
||||
|
||||
i2c_inst_t *i2c = (i2c_id == 0) ? i2c0 : i2c1;
|
||||
self->breakout = new BreakoutLTR559(i2c, args[ARG_address].u_int, sda, scl, args[ARG_interrupt].u_int);
|
||||
|
||||
self->breakout = new BreakoutLTR559(sda, scl, args[ARG_interrupt].u_int);
|
||||
|
||||
if(!self->breakout->init()) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "LTR559 breakout not found when initialising");
|
||||
|
|
|
@ -86,8 +86,7 @@ mp_obj_t BreakoutMICS6814_make_new(const mp_obj_type_t *type, size_t n_args, siz
|
|||
self = m_new_obj(breakout_mics6814_BreakoutMICS6814_obj_t);
|
||||
self->base.type = &breakout_mics6814_BreakoutMICS6814_type;
|
||||
|
||||
i2c_inst_t *i2c = (i2c_id == 0) ? i2c0 : i2c1;
|
||||
self->breakout = new BreakoutMICS6814(i2c, args[ARG_address].u_int, sda, scl, args[ARG_interrupt].u_int);
|
||||
self->breakout = new BreakoutMICS6814(args[ARG_address].u_int, sda, scl, args[ARG_interrupt].u_int);
|
||||
|
||||
if(!self->breakout->init()) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "MICS6814 breakout not found when initialising");
|
||||
|
|
|
@ -86,8 +86,7 @@ mp_obj_t BreakoutPotentiometer_make_new(const mp_obj_type_t *type, size_t n_args
|
|||
self = m_new_obj(breakout_potentiometer_BreakoutPotentiometer_obj_t);
|
||||
self->base.type = &breakout_potentiometer_BreakoutPotentiometer_type;
|
||||
|
||||
i2c_inst_t *i2c = (i2c_id == 0) ? i2c0 : i2c1;
|
||||
self->breakout = new BreakoutPotentiometer(i2c, args[ARG_address].u_int, sda, scl, args[ARG_interrupt].u_int);
|
||||
self->breakout = new BreakoutPotentiometer(args[ARG_address].u_int, sda, scl, args[ARG_interrupt].u_int);
|
||||
|
||||
if(!self->breakout->init()) {
|
||||
mp_raise_msg(&mp_type_RuntimeError, "Potentiometer breakout not found when initialising");
|
||||
|
|
Ładowanie…
Reference in New Issue