76
76
STATIC mp_obj_t analogbufio_bufferedin_make_new (const mp_obj_type_t * type , size_t n_args , size_t n_kw , const mp_obj_t * all_args ) {
77
77
enum { ARG_pin , ARG_buffer , ARG_sample_rate };
78
78
static const mp_arg_t allowed_args [] = {
79
- { MP_QSTR_pin , MP_ARG_OBJ | MP_ARG_REQUIRED },
80
- { MP_QSTR_buffer , MP_ARG_OBJ | MP_ARG_REQUIRED },
81
- { MP_QSTR_sample_rate , MP_ARG_KW_ONLY | MP_ARG_INT , {.u_int = 500000 } },
79
+ { MP_QSTR_pin , MP_ARG_OBJ | MP_ARG_REQUIRED },
80
+ { MP_QSTR_buffer , MP_ARG_OBJ | MP_ARG_REQUIRED },
81
+ { MP_QSTR_sample_rate , MP_ARG_KW_ONLY | MP_ARG_INT , {.u_int = 500000 } },
82
82
};
83
83
mp_arg_val_t args [MP_ARRAY_SIZE (allowed_args )];
84
84
mp_arg_parse_all_kw_array (n_args , n_kw , all_args , MP_ARRAY_SIZE (allowed_args ), allowed_args , args );
85
85
86
86
// Validate Pin
87
87
const mcu_pin_obj_t * pin = validate_obj_is_free_pin (args [ARG_pin ].u_obj );
88
88
89
- // Buffer Pointer defined and allocated by user
89
+ // Buffer defined and allocated by user
90
90
mp_buffer_info_t bufinfo ;
91
91
mp_get_buffer_raise (args [ARG_buffer ].u_obj , & bufinfo , MP_BUFFER_READ );
92
92
@@ -96,9 +96,9 @@ STATIC mp_obj_t analogbufio_bufferedin_make_new(const mp_obj_type_t *type, size_
96
96
97
97
// Bytes Per Sample
98
98
if (bufinfo .typecode == 'h' || bufinfo .typecode == 'H' ) {
99
- bytes_per_sample = 2 ;
99
+ bytes_per_sample = 2 ;
100
100
} else if (bufinfo .typecode != 'b' && bufinfo .typecode != 'B' && bufinfo .typecode != BYTEARRAY_TYPECODE ) {
101
- mp_raise_ValueError_varg (translate ("%q ``must`` be a bytearray or array of type 'h', 'H', 'b' or 'B'" ), MP_QSTR_buffer );
101
+ mp_raise_ValueError_varg (translate ("%q ``must`` be a bytearray or array of type 'h', 'H', 'b' or 'B'" ), MP_QSTR_buffer );
102
102
}
103
103
104
104
// Validate sample rate here
@@ -110,13 +110,13 @@ STATIC mp_obj_t analogbufio_bufferedin_make_new(const mp_obj_type_t *type, size_
110
110
111
111
// Call local intereface in ports/common-hal/analogbufio
112
112
common_hal_analogbufio_bufferedin_construct (self ,
113
- pin ,
114
- ((uint8_t * )bufinfo .buf ),
115
- bufinfo .len ,
116
- bytes_per_sample ,
117
- signed_samples ,
118
- sample_rate
119
- );
113
+ pin ,
114
+ ((uint8_t * )bufinfo .buf ),
115
+ bufinfo .len ,
116
+ bytes_per_sample ,
117
+ signed_samples ,
118
+ sample_rate
119
+ );
120
120
121
121
return MP_OBJ_FROM_PTR (self );
122
122
}
@@ -134,7 +134,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(analogbufio_bufferedin_deinit_obj, analogbufio_buffere
134
134
135
135
STATIC void check_for_deinit (analogbufio_bufferedin_obj_t * self ) {
136
136
if (common_hal_analogbufio_bufferedin_deinited (self )) {
137
- raise_deinited_error ();
137
+ raise_deinited_error ();
138
138
}
139
139
}
140
140
//| def __enter__(self) -> BufferedIn:
0 commit comments