3434#include "py/runtime.h"
3535#include "py/builtin.h"
3636#include "py/stream.h"
37- #include "py/obj.h" /* For get_int */
3837
3938#include "supervisor/shared/translate.h"
4039
@@ -234,41 +233,10 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_hex_obj, mp_builtin_hex);
234233#define mp_hal_readline readline
235234#endif
236235
237- #include "usb.h"
238-
239236STATIC 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 ) {
241238 mp_obj_print (args [0 ], PRINT_STR );
242239 }
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-
272240 vstr_t line ;
273241 vstr_init (& line , 16 );
274242 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) {
280248 }
281249 return mp_obj_new_str_from_vstr (& mp_type_str , & line );
282250}
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 );
284252
285253#endif
286254
0 commit comments