3232#include "py/mpconfig.h"
3333#include MICROPY_HAL_H
3434#include "py/obj.h"
35+ #include "py/runtime.h"
3536#include "hw_ints.h"
3637#include "hw_types.h"
3738#include "hw_gpio.h"
6364/******************************************************************************
6465 DECLARE PRIVATE DATA
6566 ******************************************************************************/
67+ STATIC const mp_obj_base_t pyb_heartbeat_obj = {& pyb_heartbeat_type };
68+
6669struct mperror_heart_beat {
6770 uint32_t off_time ;
6871 uint32_t on_time ;
@@ -198,6 +201,17 @@ void nlr_jump_fail(void *val) {
198201/******************************************************************************/
199202// Micro Python bindings
200203
204+ /// \classmethod \constructor()
205+ ///
206+ /// Return the heart beat object
207+ STATIC mp_obj_t pyb_heartbeat_make_new (mp_obj_t type_in , mp_uint_t n_args , mp_uint_t n_kw , const mp_obj_t * args ) {
208+ // check arguments
209+ mp_arg_check_num (n_args , n_kw , 0 , 0 , false);
210+
211+ // return constant object
212+ return (mp_obj_t )& pyb_heartbeat_obj ;
213+ }
214+
201215/// \function enable()
202216/// Enables the heartbeat signal
203217STATIC mp_obj_t pyb_enable_heartbeat (mp_obj_t self ) {
@@ -220,11 +234,11 @@ STATIC const mp_map_elem_t pyb_heartbeat_locals_dict_table[] = {
220234};
221235STATIC MP_DEFINE_CONST_DICT (pyb_heartbeat_locals_dict , pyb_heartbeat_locals_dict_table );
222236
223- static const mp_obj_type_t pyb_heartbeat_type = {
237+ const mp_obj_type_t pyb_heartbeat_type = {
224238 { & mp_type_type },
225239 .name = MP_QSTR_HeartBeat ,
240+ .make_new = pyb_heartbeat_make_new ,
226241 .locals_dict = (mp_obj_t )& pyb_heartbeat_locals_dict ,
227242};
228243
229- const mp_obj_base_t pyb_heartbeat_obj = {& pyb_heartbeat_type };
230244#endif
0 commit comments