34
34
#include "py/runtime.h"
35
35
#include "py/builtin.h"
36
36
#include "py/stream.h"
37
- #include "py/obj.h" /* For get_int */
38
37
39
38
#include "supervisor/shared/translate.h"
40
39
@@ -234,41 +233,10 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_hex_obj, mp_builtin_hex);
234
233
#define mp_hal_readline readline
235
234
#endif
236
235
237
- #include "usb.h"
238
-
239
236
STATIC mp_obj_t mp_builtin_input (size_t n_args , const mp_obj_t * args ) {
240
- if (n_args > = 1 ) {
237
+ if (n_args = = 1 ) {
241
238
mp_obj_print (args [0 ], PRINT_STR );
242
239
}
243
- if (n_args == 2 )
244
- {
245
- if (!mp_obj_is_true (args [1 ]))
246
- { /* If they pass 0 or False, return immediately if there's no text available */
247
- if (!usb_bytes_available ())
248
- {
249
- return mp_const_none ;
250
- }
251
- }
252
- else if (MP_OBJ_IS_INT (args [1 ]))
253
- {
254
- /* Timeout has been sent... check for USB input for that # of millis */
255
- mp_uint_t target = mp_hal_ticks_ms () + mp_obj_get_int (args [1 ]);
256
- bool bytesAvaliable = false;
257
-
258
- while (mp_hal_ticks_ms () < target )
259
- {
260
- if (usb_bytes_available ())
261
- {
262
- bytesAvaliable = true;
263
- break ;
264
- }
265
- }
266
- if (!bytesAvaliable )
267
- return mp_const_none ;
268
- }
269
- }
270
-
271
-
272
240
vstr_t line ;
273
241
vstr_init (& line , 16 );
274
242
int ret = mp_hal_readline (& line , "" );
@@ -280,7 +248,7 @@ STATIC mp_obj_t mp_builtin_input(size_t n_args, const mp_obj_t *args) {
280
248
}
281
249
return mp_obj_new_str_from_vstr (& mp_type_str , & line );
282
250
}
283
- MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (mp_builtin_input_obj , 0 , 2 , mp_builtin_input );
251
+ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (mp_builtin_input_obj , 0 , 1 , mp_builtin_input );
284
252
285
253
#endif
286
254
0 commit comments