Merge pull request #381 from pimoroni/patch-optimise-breakout-rtc-args
Breakout RTC: Optimise required kwarg functions to positional.
This commit is contained in:
commit
2721ad682f
|
@ -9,13 +9,13 @@ MP_DEFINE_CONST_FUN_OBJ_1(BreakoutRTC_reset_obj, BreakoutRTC_reset);
|
|||
MP_DEFINE_CONST_FUN_OBJ_1(BreakoutRTC_setup_obj, BreakoutRTC_setup);
|
||||
|
||||
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutRTC_set_time_obj, 8, BreakoutRTC_set_time);
|
||||
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutRTC_set_seconds_obj, 2, BreakoutRTC_set_seconds);
|
||||
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutRTC_set_minutes_obj, 2, BreakoutRTC_set_minutes);
|
||||
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutRTC_set_hours_obj, 2, BreakoutRTC_set_hours);
|
||||
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutRTC_set_weekday_obj, 2, BreakoutRTC_set_weekday);
|
||||
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutRTC_set_date_obj, 2, BreakoutRTC_set_date);
|
||||
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutRTC_set_month_obj, 2, BreakoutRTC_set_month);
|
||||
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutRTC_set_year_obj, 2, BreakoutRTC_set_year);
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(BreakoutRTC_set_seconds_obj, BreakoutRTC_set_seconds);
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(BreakoutRTC_set_minutes_obj, BreakoutRTC_set_minutes);
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(BreakoutRTC_set_hours_obj, BreakoutRTC_set_hours);
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(BreakoutRTC_set_weekday_obj, BreakoutRTC_set_weekday);
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(BreakoutRTC_set_date_obj, BreakoutRTC_set_date);
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(BreakoutRTC_set_month_obj, BreakoutRTC_set_month);
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(BreakoutRTC_set_year_obj, BreakoutRTC_set_year);
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(BreakoutRTC_set_to_compiler_time_obj, BreakoutRTC_set_to_compiler_time);
|
||||
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(BreakoutRTC_update_time_obj, BreakoutRTC_update_time);
|
||||
|
@ -36,7 +36,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(BreakoutRTC_is_pm_obj, BreakoutRTC_is_pm);
|
|||
MP_DEFINE_CONST_FUN_OBJ_1(BreakoutRTC_set_12_hour_obj, BreakoutRTC_set_12_hour);
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(BreakoutRTC_set_24_hour_obj, BreakoutRTC_set_24_hour);
|
||||
|
||||
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutRTC_set_unix_obj, 2, BreakoutRTC_set_unix);
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(BreakoutRTC_set_unix_obj, BreakoutRTC_set_unix);
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(BreakoutRTC_get_unix_obj, BreakoutRTC_get_unix);
|
||||
|
||||
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutRTC_enable_alarm_interrupt_obj, 6, BreakoutRTC_enable_alarm_interrupt);
|
||||
|
@ -60,10 +60,10 @@ MP_DEFINE_CONST_FUN_OBJ_1(BreakoutRTC_clear_periodic_update_interrupt_flag_obj,
|
|||
|
||||
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutRTC_enable_trickle_charge_obj, 2, BreakoutRTC_enable_trickle_charge);
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(BreakoutRTC_disable_trickle_charge_obj, BreakoutRTC_disable_trickle_charge);
|
||||
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutRTC_set_backup_switchover_mode_obj, 2, BreakoutRTC_set_backup_switchover_mode);
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(BreakoutRTC_set_backup_switchover_mode_obj, BreakoutRTC_set_backup_switchover_mode);
|
||||
|
||||
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutRTC_enable_clock_out_obj, 2, BreakoutRTC_enable_clock_out);
|
||||
MP_DEFINE_CONST_FUN_OBJ_KW(BreakoutRTC_enable_interrupt_controlled_clockout_obj, 2, BreakoutRTC_enable_interrupt_controlled_clockout);
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(BreakoutRTC_enable_clock_out_obj, BreakoutRTC_enable_clock_out);
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(BreakoutRTC_enable_interrupt_controlled_clockout_obj, BreakoutRTC_enable_interrupt_controlled_clockout);
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(BreakoutRTC_disable_clock_out_obj, BreakoutRTC_disable_clock_out);
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(BreakoutRTC_read_clock_output_interrupt_flag_obj, BreakoutRTC_read_clock_output_interrupt_flag);
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(BreakoutRTC_clear_clock_output_interrupt_flag_obj, BreakoutRTC_clear_clock_output_interrupt_flag);
|
||||
|
|
|
@ -87,178 +87,85 @@ mp_obj_t BreakoutRTC_set_time(size_t n_args, const mp_obj_t *pos_args, mp_map_t
|
|||
int month = args[ARG_month].u_int;
|
||||
int year = args[ARG_year].u_int;
|
||||
|
||||
if(sec < 0 || sec > 59)
|
||||
mp_raise_ValueError("sec out of range. Expected 0 to 59");
|
||||
else if(min < 0 || min > 59)
|
||||
mp_raise_ValueError("min out of range. Expected 0 to 59");
|
||||
else if(hour < 0 || hour > 23)
|
||||
mp_raise_ValueError("hour out of range. Expected 0 to 23");
|
||||
else if(weekday < 0 || weekday > 6)
|
||||
mp_raise_ValueError("weekday out of range. Expected 0 to 6");
|
||||
else if(date < 1 || date > 31)
|
||||
mp_raise_ValueError("date out of range. Expected 1 to 31");
|
||||
else if(month < 1 || month > 12)
|
||||
mp_raise_ValueError("month out of range. Expected 1 to 12");
|
||||
else if(year < 2000 || year > 2099)
|
||||
mp_raise_ValueError("year out of range. Expected 2000 to 2099");
|
||||
else
|
||||
return mp_obj_new_bool(self->breakout->set_time(sec, min, hour, weekday, date, month, year));
|
||||
if(sec < 0 || sec > 59) mp_raise_ValueError("sec out of range. Expected 0 to 59");
|
||||
if(min < 0 || min > 59) mp_raise_ValueError("min out of range. Expected 0 to 59");
|
||||
if(hour < 0 || hour > 23) mp_raise_ValueError("hour out of range. Expected 0 to 23");
|
||||
if(weekday < 0 || weekday > 6) mp_raise_ValueError("weekday out of range. Expected 0 to 6");
|
||||
if(date < 1 || date > 31) mp_raise_ValueError("date out of range. Expected 1 to 31");
|
||||
if(month < 1 || month > 12) mp_raise_ValueError("month out of range. Expected 1 to 12");
|
||||
if(year < 2000 || year > 2099) mp_raise_ValueError("year out of range. Expected 2000 to 2099");
|
||||
|
||||
return mp_const_none;
|
||||
return mp_obj_new_bool(self->breakout->set_time(sec, min, hour, weekday, date, month, year));
|
||||
}
|
||||
|
||||
mp_obj_t BreakoutRTC_set_seconds(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum { ARG_self, ARG_sec};
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
||||
{ MP_QSTR_sec, MP_ARG_REQUIRED | MP_ARG_INT },
|
||||
};
|
||||
mp_obj_t BreakoutRTC_set_seconds(mp_obj_t self_in, mp_obj_t sec_in) {
|
||||
breakout_rtc_BreakoutRTC_obj_t *self = MP_OBJ_TO_PTR2(self_in, breakout_rtc_BreakoutRTC_obj_t);
|
||||
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
int sec = mp_obj_get_int(sec_in);
|
||||
|
||||
breakout_rtc_BreakoutRTC_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self].u_obj, breakout_rtc_BreakoutRTC_obj_t);
|
||||
if(sec < 0 || sec > 59) mp_raise_ValueError("sec out of range. Expected 0 to 59");
|
||||
|
||||
int sec = args[ARG_sec].u_int;
|
||||
|
||||
if(sec < 0 || sec > 59)
|
||||
mp_raise_ValueError("sec out of range. Expected 0 to 59");
|
||||
else
|
||||
return mp_obj_new_bool(self->breakout->set_seconds(sec));
|
||||
|
||||
return mp_const_none;
|
||||
return mp_obj_new_bool(self->breakout->set_seconds(sec));
|
||||
}
|
||||
|
||||
mp_obj_t BreakoutRTC_set_minutes(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum { ARG_self, ARG_min };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
||||
{ MP_QSTR_min, MP_ARG_REQUIRED | MP_ARG_INT },
|
||||
};
|
||||
mp_obj_t BreakoutRTC_set_minutes(mp_obj_t self_in, mp_obj_t min_in) {
|
||||
breakout_rtc_BreakoutRTC_obj_t *self = MP_OBJ_TO_PTR2(self_in, breakout_rtc_BreakoutRTC_obj_t);
|
||||
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
int min = mp_obj_get_int(min_in);
|
||||
|
||||
breakout_rtc_BreakoutRTC_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self].u_obj, breakout_rtc_BreakoutRTC_obj_t);
|
||||
if(min < 0 || min > 59) mp_raise_ValueError("min out of range. Expected 0 to 59");
|
||||
|
||||
int min = args[ARG_min].u_int;
|
||||
|
||||
if(min < 0 || min > 59)
|
||||
mp_raise_ValueError("min out of range. Expected 0 to 59");
|
||||
else
|
||||
return mp_obj_new_bool(self->breakout->set_minutes(min));
|
||||
|
||||
return mp_const_none;
|
||||
return mp_obj_new_bool(self->breakout->set_minutes(min));
|
||||
}
|
||||
|
||||
mp_obj_t BreakoutRTC_set_hours(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum { ARG_self, ARG_hour };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
||||
{ MP_QSTR_hour, MP_ARG_REQUIRED | MP_ARG_INT },
|
||||
};
|
||||
mp_obj_t BreakoutRTC_set_hours(mp_obj_t self_in, mp_obj_t hour_in) {
|
||||
breakout_rtc_BreakoutRTC_obj_t *self = MP_OBJ_TO_PTR2(self_in, breakout_rtc_BreakoutRTC_obj_t);
|
||||
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
int hour = mp_obj_get_int(hour_in);
|
||||
|
||||
breakout_rtc_BreakoutRTC_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self].u_obj, breakout_rtc_BreakoutRTC_obj_t);
|
||||
if(hour < 0 || hour > 23) mp_raise_ValueError("hour out of range. Expected 0 to 23");
|
||||
|
||||
int hour = args[ARG_hour].u_int;
|
||||
|
||||
if(hour < 0 || hour > 23)
|
||||
mp_raise_ValueError("hour out of range. Expected 0 to 23");
|
||||
else
|
||||
return mp_obj_new_bool(self->breakout->set_hours(hour));
|
||||
|
||||
return mp_const_none;
|
||||
return mp_obj_new_bool(self->breakout->set_hours(hour));
|
||||
}
|
||||
|
||||
mp_obj_t BreakoutRTC_set_weekday(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum { ARG_self, ARG_weekday };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
||||
{ MP_QSTR_weekday, MP_ARG_REQUIRED | MP_ARG_INT },
|
||||
};
|
||||
mp_obj_t BreakoutRTC_set_weekday(mp_obj_t self_in, mp_obj_t weekday_in) {
|
||||
breakout_rtc_BreakoutRTC_obj_t *self = MP_OBJ_TO_PTR2(self_in, breakout_rtc_BreakoutRTC_obj_t);
|
||||
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
int weekday = mp_obj_get_int(weekday_in);
|
||||
|
||||
breakout_rtc_BreakoutRTC_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self].u_obj, breakout_rtc_BreakoutRTC_obj_t);
|
||||
if(weekday < 0 || weekday > 6) mp_raise_ValueError("weekday out of range. Expected 0 to 6");
|
||||
|
||||
int weekday = args[ARG_weekday].u_int;
|
||||
|
||||
if(weekday < 0 || weekday > 6)
|
||||
mp_raise_ValueError("weekday out of range. Expected 0 to 6");
|
||||
else
|
||||
return mp_obj_new_bool(self->breakout->set_weekday(weekday));
|
||||
|
||||
return mp_const_none;
|
||||
return mp_obj_new_bool(self->breakout->set_weekday(weekday));
|
||||
}
|
||||
|
||||
mp_obj_t BreakoutRTC_set_date(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum { ARG_self, ARG_date };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
||||
{ MP_QSTR_date, MP_ARG_REQUIRED | MP_ARG_INT },
|
||||
};
|
||||
mp_obj_t BreakoutRTC_set_date(mp_obj_t self_in, mp_obj_t date_in) {
|
||||
breakout_rtc_BreakoutRTC_obj_t *self = MP_OBJ_TO_PTR2(self_in, breakout_rtc_BreakoutRTC_obj_t);
|
||||
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
int date = mp_obj_get_int(date_in);
|
||||
|
||||
breakout_rtc_BreakoutRTC_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self].u_obj, breakout_rtc_BreakoutRTC_obj_t);
|
||||
|
||||
int date = args[ARG_date].u_int;
|
||||
|
||||
if(date < 1 || date > 31)
|
||||
mp_raise_ValueError("date out of range. Expected 1 to 31");
|
||||
else
|
||||
return mp_obj_new_bool(self->breakout->set_date(date));
|
||||
|
||||
return mp_const_none;
|
||||
if(date < 1 || date > 31) mp_raise_ValueError("date out of range. Expected 1 to 31");
|
||||
|
||||
return mp_obj_new_bool(self->breakout->set_date(date));
|
||||
}
|
||||
|
||||
mp_obj_t BreakoutRTC_set_month(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum { ARG_self, ARG_month };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
||||
{ MP_QSTR_month, MP_ARG_REQUIRED | MP_ARG_INT },
|
||||
};
|
||||
mp_obj_t BreakoutRTC_set_month(mp_obj_t self_in, mp_obj_t month_in) {
|
||||
breakout_rtc_BreakoutRTC_obj_t *self = MP_OBJ_TO_PTR2(self_in, breakout_rtc_BreakoutRTC_obj_t);
|
||||
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
int month = mp_obj_get_int(month_in);
|
||||
|
||||
breakout_rtc_BreakoutRTC_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self].u_obj, breakout_rtc_BreakoutRTC_obj_t);
|
||||
if(month < 1 || month > 12) mp_raise_ValueError("month out of range. Expected 1 to 12");
|
||||
|
||||
int month = args[ARG_month].u_int;
|
||||
|
||||
if(month < 1 || month > 12)
|
||||
mp_raise_ValueError("month out of range. Expected 1 to 12");
|
||||
else
|
||||
return mp_obj_new_bool(self->breakout->set_month(month));
|
||||
|
||||
return mp_const_none;
|
||||
return mp_obj_new_bool(self->breakout->set_month(month));
|
||||
}
|
||||
|
||||
mp_obj_t BreakoutRTC_set_year(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum { ARG_self, ARG_year };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
||||
{ MP_QSTR_year, MP_ARG_REQUIRED | MP_ARG_INT },
|
||||
};
|
||||
mp_obj_t BreakoutRTC_set_year(mp_obj_t self_in, mp_obj_t year_in) {
|
||||
breakout_rtc_BreakoutRTC_obj_t *self = MP_OBJ_TO_PTR2(self_in, breakout_rtc_BreakoutRTC_obj_t);
|
||||
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
int year = mp_obj_get_int(year_in);
|
||||
|
||||
breakout_rtc_BreakoutRTC_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self].u_obj, breakout_rtc_BreakoutRTC_obj_t);
|
||||
if(year < 0 || year > 99) mp_raise_ValueError("year out of range. Expected 0 to 99");
|
||||
|
||||
int year = args[ARG_year].u_int;
|
||||
|
||||
if(year < 0 || year > 99)
|
||||
mp_raise_ValueError("year out of range. Expected 0 to 99");
|
||||
else
|
||||
return mp_obj_new_bool(self->breakout->set_year(year));
|
||||
|
||||
return mp_const_none;
|
||||
return mp_obj_new_bool(self->breakout->set_year(year));
|
||||
}
|
||||
|
||||
mp_obj_t BreakoutRTC_set_to_compiler_time(mp_obj_t self_in) {
|
||||
|
@ -362,19 +269,10 @@ mp_obj_t BreakoutRTC_set_24_hour(mp_obj_t self_in) {
|
|||
return mp_const_none;
|
||||
}
|
||||
|
||||
mp_obj_t BreakoutRTC_set_unix(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum { ARG_self, ARG_value };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
||||
{ MP_QSTR_value, MP_ARG_REQUIRED | MP_ARG_INT },
|
||||
};
|
||||
mp_obj_t BreakoutRTC_set_unix(mp_obj_t self_in, mp_obj_t value_in) {
|
||||
breakout_rtc_BreakoutRTC_obj_t *self = MP_OBJ_TO_PTR2(self_in, breakout_rtc_BreakoutRTC_obj_t);
|
||||
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
breakout_rtc_BreakoutRTC_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self].u_obj, breakout_rtc_BreakoutRTC_obj_t);
|
||||
|
||||
int value = args[ARG_value].u_int;
|
||||
int value = mp_obj_get_int(value_in);
|
||||
|
||||
return mp_obj_new_bool(self->breakout->set_unix((uint32_t)value));
|
||||
}
|
||||
|
@ -604,10 +502,9 @@ mp_obj_t BreakoutRTC_enable_trickle_charge(size_t n_args, const mp_obj_t *pos_ar
|
|||
|
||||
int tcr = args[ARG_tcr].u_int;
|
||||
|
||||
if(tcr < 0 || tcr > 3)
|
||||
mp_raise_ValueError("tcr out of range. Expected 0 to 3 (TCR_3K, TCR_5K, TCR_9K, TCR_15K)");
|
||||
else
|
||||
self->breakout->enable_trickle_charge(tcr);
|
||||
if(tcr < 0 || tcr > 3) mp_raise_ValueError("tcr out of range. Expected 0 to 3 (TCR_3K, TCR_5K, TCR_9K, TCR_15K)");
|
||||
|
||||
self->breakout->enable_trickle_charge(tcr);
|
||||
|
||||
return mp_const_none;
|
||||
}
|
||||
|
@ -619,68 +516,38 @@ mp_obj_t BreakoutRTC_disable_trickle_charge(mp_obj_t self_in) {
|
|||
return mp_const_none;
|
||||
}
|
||||
|
||||
mp_obj_t BreakoutRTC_set_backup_switchover_mode(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum { ARG_self, ARG_val };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
||||
{ MP_QSTR_val, MP_ARG_REQUIRED | MP_ARG_INT },
|
||||
};
|
||||
mp_obj_t BreakoutRTC_set_backup_switchover_mode(mp_obj_t self_in, mp_obj_t val_in) {
|
||||
breakout_rtc_BreakoutRTC_obj_t *self = MP_OBJ_TO_PTR2(self_in, breakout_rtc_BreakoutRTC_obj_t);
|
||||
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
int val = mp_obj_get_int(val_in);
|
||||
|
||||
breakout_rtc_BreakoutRTC_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self].u_obj, breakout_rtc_BreakoutRTC_obj_t);
|
||||
if(val < 0 || val > 3) mp_raise_ValueError("tcr out of range. Expected 0 to 3");
|
||||
|
||||
int val = args[ARG_val].u_int;
|
||||
|
||||
if(val < 0 || val > 3)
|
||||
mp_raise_ValueError("tcr out of range. Expected 0 to 3");
|
||||
else
|
||||
self->breakout->set_backup_switchover_mode(val);
|
||||
self->breakout->set_backup_switchover_mode(val);
|
||||
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
mp_obj_t BreakoutRTC_enable_clock_out(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum { ARG_self, ARG_freq };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
||||
{ MP_QSTR_freq, MP_ARG_REQUIRED | MP_ARG_INT },
|
||||
};
|
||||
mp_obj_t BreakoutRTC_enable_clock_out(mp_obj_t self_in, mp_obj_t freq_in) {
|
||||
breakout_rtc_BreakoutRTC_obj_t *self = MP_OBJ_TO_PTR2(self_in, breakout_rtc_BreakoutRTC_obj_t);
|
||||
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
int freq = mp_obj_get_int(freq_in);
|
||||
|
||||
breakout_rtc_BreakoutRTC_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self].u_obj, breakout_rtc_BreakoutRTC_obj_t);
|
||||
if(freq < 0 || freq > 7) mp_raise_ValueError("freq out of range. Expected 0 to 7");
|
||||
|
||||
int freq = args[ARG_freq].u_int;
|
||||
|
||||
if(freq < 0 || freq > 7)
|
||||
mp_raise_ValueError("freq out of range. Expected 0 to 7");
|
||||
else
|
||||
self->breakout->enable_clock_out(freq);
|
||||
self->breakout->enable_clock_out(freq);
|
||||
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
mp_obj_t BreakoutRTC_enable_interrupt_controlled_clockout(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||
enum { ARG_self, ARG_freq };
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_, MP_ARG_REQUIRED | MP_ARG_OBJ },
|
||||
{ MP_QSTR_freq, MP_ARG_REQUIRED | MP_ARG_INT },
|
||||
};
|
||||
mp_obj_t BreakoutRTC_enable_interrupt_controlled_clockout(mp_obj_t self_in, mp_obj_t freq_in) {
|
||||
breakout_rtc_BreakoutRTC_obj_t *self = MP_OBJ_TO_PTR2(self_in, breakout_rtc_BreakoutRTC_obj_t);
|
||||
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
int freq = mp_obj_get_int(freq_in);
|
||||
|
||||
breakout_rtc_BreakoutRTC_obj_t *self = MP_OBJ_TO_PTR2(args[ARG_self].u_obj, breakout_rtc_BreakoutRTC_obj_t);
|
||||
if(freq < 0 || freq > 7) mp_raise_ValueError("freq out of range. Expected 0 to 7");
|
||||
|
||||
int freq = args[ARG_freq].u_int;
|
||||
|
||||
if(freq < 0 || freq > 7)
|
||||
mp_raise_ValueError("freq out of range. Expected 0 to 7");
|
||||
else
|
||||
self->breakout->enable_interrupt_controlled_clockout(freq);
|
||||
self->breakout->enable_interrupt_controlled_clockout(freq);
|
||||
|
||||
return mp_const_none;
|
||||
}
|
||||
|
|
|
@ -20,13 +20,13 @@ extern mp_obj_t BreakoutRTC_reset(mp_obj_t self_in);
|
|||
extern mp_obj_t BreakoutRTC_setup(mp_obj_t self_in);
|
||||
|
||||
extern mp_obj_t BreakoutRTC_set_time(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
||||
extern mp_obj_t BreakoutRTC_set_seconds(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
||||
extern mp_obj_t BreakoutRTC_set_minutes(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
||||
extern mp_obj_t BreakoutRTC_set_hours(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
||||
extern mp_obj_t BreakoutRTC_set_weekday(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
||||
extern mp_obj_t BreakoutRTC_set_date(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
||||
extern mp_obj_t BreakoutRTC_set_month(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
||||
extern mp_obj_t BreakoutRTC_set_year(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
||||
extern mp_obj_t BreakoutRTC_set_seconds(mp_obj_t self_in, mp_obj_t sec_in);
|
||||
extern mp_obj_t BreakoutRTC_set_minutes(mp_obj_t self_in, mp_obj_t min_in);
|
||||
extern mp_obj_t BreakoutRTC_set_hours(mp_obj_t self_in, mp_obj_t hour_in);
|
||||
extern mp_obj_t BreakoutRTC_set_weekday(mp_obj_t self_in, mp_obj_t weekday_in);
|
||||
extern mp_obj_t BreakoutRTC_set_date(mp_obj_t self_in, mp_obj_t date_in);
|
||||
extern mp_obj_t BreakoutRTC_set_month(mp_obj_t self_in, mp_obj_t month_in);
|
||||
extern mp_obj_t BreakoutRTC_set_year(mp_obj_t self_in, mp_obj_t year_in);
|
||||
extern mp_obj_t BreakoutRTC_set_to_compiler_time(mp_obj_t self_in);
|
||||
|
||||
extern mp_obj_t BreakoutRTC_update_time(mp_obj_t self_in);
|
||||
|
@ -47,7 +47,7 @@ extern mp_obj_t BreakoutRTC_is_pm(mp_obj_t self_in);
|
|||
extern mp_obj_t BreakoutRTC_set_12_hour(mp_obj_t self_in);
|
||||
extern mp_obj_t BreakoutRTC_set_24_hour(mp_obj_t self_in);
|
||||
|
||||
extern mp_obj_t BreakoutRTC_set_unix(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
||||
extern mp_obj_t BreakoutRTC_set_unix(mp_obj_t self_in, mp_obj_t value_in);
|
||||
extern mp_obj_t BreakoutRTC_get_unix(mp_obj_t self_in);
|
||||
|
||||
extern mp_obj_t BreakoutRTC_enable_alarm_interrupt(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
||||
|
@ -71,10 +71,10 @@ extern mp_obj_t BreakoutRTC_clear_periodic_update_interrupt_flag(mp_obj_t self_i
|
|||
|
||||
extern mp_obj_t BreakoutRTC_enable_trickle_charge(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
||||
extern mp_obj_t BreakoutRTC_disable_trickle_charge(mp_obj_t self_in);
|
||||
extern mp_obj_t BreakoutRTC_set_backup_switchover_mode(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
||||
extern mp_obj_t BreakoutRTC_set_backup_switchover_mode(mp_obj_t self_in, mp_obj_t val_in);
|
||||
|
||||
extern mp_obj_t BreakoutRTC_enable_clock_out(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
||||
extern mp_obj_t BreakoutRTC_enable_interrupt_controlled_clockout(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
|
||||
extern mp_obj_t BreakoutRTC_enable_clock_out(mp_obj_t self_in, mp_obj_t freq_in);
|
||||
extern mp_obj_t BreakoutRTC_enable_interrupt_controlled_clockout(mp_obj_t self_in, mp_obj_t freq_in);
|
||||
extern mp_obj_t BreakoutRTC_disable_clock_out(mp_obj_t self_in);
|
||||
extern mp_obj_t BreakoutRTC_read_clock_output_interrupt_flag(mp_obj_t self_in);
|
||||
extern mp_obj_t BreakoutRTC_clear_clock_output_interrupt_flag(mp_obj_t self_in);
|
||||
|
|
Loading…
Reference in New Issue