Style changes, reposition runtime errors
This commit is contained in:
parent
d0d6a951da
commit
da75445cd5
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-08-17 10:10-0400\n"
|
||||
"POT-Creation-Date: 2020-08-18 11:19-0400\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@ -1334,7 +1334,7 @@ msgstr ""
|
||||
#: ports/stm/common-hal/pulseio/PulseOut.c
|
||||
msgid ""
|
||||
"Port does not accept pins or frequency. "
|
||||
"Construct and pass a PWM Carrier instead"
|
||||
"Construct and pass a PWMOut Carrier instead"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/_bleio/Adapter.c
|
||||
|
@ -102,7 +102,7 @@ void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
|
||||
uint16_t duty_cycle) {
|
||||
if (!carrier || pin || frequency) {
|
||||
mp_raise_NotImplementedError(translate("Port does not accept pins or frequency. \
|
||||
Construct and pass a PWM Carrier instead"));
|
||||
Construct and pass a PWMOut Carrier instead"));
|
||||
}
|
||||
|
||||
if (refcount == 0) {
|
||||
|
@ -65,7 +65,7 @@ void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
|
||||
uint16_t duty_cycle) {
|
||||
if (!carrier || pin || frequency) {
|
||||
mp_raise_NotImplementedError(translate("Port does not accept pins or frequency. \
|
||||
Construct and pass a PWM Carrier instead"));
|
||||
Construct and pass a PWMOut Carrier instead"));
|
||||
}
|
||||
|
||||
if (pulse_fd < 0) {
|
||||
|
@ -93,6 +93,9 @@ void common_hal_neopixel_write (const digitalio_digitalinout_obj_t* digitalinout
|
||||
// Reserve channel
|
||||
uint8_t number = digitalinout->pin->number;
|
||||
rmt_channel_t channel = esp32s2_peripherals_find_and_reserve_rmt();
|
||||
if (channel == RMT_CHANNEL_MAX) {
|
||||
mp_raise_RuntimeError(translate("All timers in use"));
|
||||
}
|
||||
|
||||
// Configure Channel
|
||||
rmt_config_t config = RMT_DEFAULT_CONFIG_TX(number, channel);
|
||||
|
@ -105,6 +105,9 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t* self, const mcu
|
||||
|
||||
// Find a free RMT Channel and configure it
|
||||
rmt_channel_t channel = esp32s2_peripherals_find_and_reserve_rmt();
|
||||
if (channel == RMT_CHANNEL_MAX) {
|
||||
mp_raise_RuntimeError(translate("All timers in use"));
|
||||
}
|
||||
rmt_config_t config = RMT_DEFAULT_CONFIG_RX(pin->number, channel);
|
||||
config.rx_config.filter_en = true;
|
||||
config.rx_config.idle_threshold = 30000; // 30*3=90ms idle required to register a sequence
|
||||
|
@ -42,6 +42,9 @@ void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
|
||||
}
|
||||
|
||||
rmt_channel_t channel = esp32s2_peripherals_find_and_reserve_rmt();
|
||||
if (channel == RMT_CHANNEL_MAX) {
|
||||
mp_raise_RuntimeError(translate("All timers in use"));
|
||||
}
|
||||
|
||||
// Configure Channel
|
||||
rmt_config_t config = RMT_DEFAULT_CONFIG_TX(pin->number, channel);
|
||||
@ -82,5 +85,7 @@ void common_hal_pulseio_pulseout_send(pulseio_pulseout_obj_t* self, uint16_t* pu
|
||||
}
|
||||
|
||||
rmt_write_items(self->channel, items, length, true);
|
||||
rmt_wait_tx_done(self->channel, pdMS_TO_TICKS(100));
|
||||
while (rmt_wait_tx_done(self->channel, 0) != ESP_OK) {
|
||||
RUN_BACKGROUND_TASKS();
|
||||
}
|
||||
}
|
||||
|
@ -44,8 +44,8 @@ rmt_channel_t esp32s2_peripherals_find_and_reserve_rmt(void) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
mp_raise_RuntimeError(translate("All timers in use"));
|
||||
return false;
|
||||
// Returning the max indicates a reservation failure.
|
||||
return RMT_CHANNEL_MAX;
|
||||
}
|
||||
|
||||
void esp32s2_peripherals_free_rmt(rmt_channel_t chan) {
|
||||
|
@ -106,7 +106,7 @@ void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
|
||||
uint16_t duty_cycle) {
|
||||
if (!carrier || pin || frequency) {
|
||||
mp_raise_NotImplementedError(translate("Port does not accept pins or frequency. \
|
||||
Construct and pass a PWM Carrier instead"));
|
||||
Construct and pass a PWMOut Carrier instead"));
|
||||
}
|
||||
|
||||
if (refcount == 0) {
|
||||
|
@ -119,7 +119,7 @@ void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
|
||||
uint16_t duty_cycle) {
|
||||
if (!carrier || pin || frequency) {
|
||||
mp_raise_NotImplementedError(translate("Port does not accept pins or frequency. \
|
||||
Construct and pass a PWM Carrier instead"));
|
||||
Construct and pass a PWMOut Carrier instead"));
|
||||
}
|
||||
|
||||
// Add to active PulseOuts
|
||||
|
@ -71,11 +71,11 @@ STATIC mp_obj_t pulseio_pulseout_make_new(const mp_obj_type_t *type, size_t n_ar
|
||||
|
||||
mp_obj_t carrier_obj = pos_args[0];
|
||||
if (MP_OBJ_IS_TYPE(carrier_obj, &pulseio_pwmout_type)) {
|
||||
// PWM Carrier
|
||||
// Use a PWMOut Carrier
|
||||
mp_arg_check_num(n_args, kw_args, 1, 1, false);
|
||||
common_hal_pulseio_pulseout_construct(self, (pulseio_pwmout_obj_t *)MP_OBJ_TO_PTR(carrier_obj), NULL, 0, 0);
|
||||
} else {
|
||||
// Pin and Frequency
|
||||
// Use a Pin, frequency, and duty cycle
|
||||
enum { ARG_pin, ARG_frequency};
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_pin, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
||||
|
Loading…
Reference in New Issue
Block a user