@@ -16,11 +16,6 @@ STATIC mp_obj_t tools_wait(mp_obj_t arg) {
1616}
1717MP_DEFINE_CONST_FUN_OBJ_1 (tools_wait_obj , tools_wait );
1818
19- /*
20- class StopWatch():
21- """Time the duration of a program or event."""
22- */
23-
2419// Class structure for StopWatch
2520typedef struct _tools_StopWatch_obj_t {
2621 mp_obj_base_t base ;
@@ -30,15 +25,6 @@ typedef struct _tools_StopWatch_obj_t {
3025 bool running ;
3126} tools_StopWatch_obj_t ;
3227
33- /*
34- StopWatch
35- def reset(self):
36- """Set time to zero and pause."""
37- self.time_start = get_time()
38- self.time_stop = self.time_start
39- self.time_spent_pausing = 0
40- self.running = False
41- */
4228STATIC mp_obj_t tools_StopWatch_reset (mp_obj_t self_in ) {
4329 tools_StopWatch_obj_t * self = MP_OBJ_TO_PTR (self_in );
4430 self -> time_start = mp_hal_ticks_ms ();
@@ -48,20 +34,6 @@ STATIC mp_obj_t tools_StopWatch_reset(mp_obj_t self_in) {
4834}
4935STATIC MP_DEFINE_CONST_FUN_OBJ_1 (tools_StopWatch_reset_obj , tools_StopWatch_reset );
5036
51- /*
52- StopWatch
53- def time(self):
54- """Get the current time of the stopwatch.
55-
56- Returns:
57- int -- time in milliseconds
58-
59- """
60- if self.running:
61- return get_time()-self.time_start-self.time_spent_pausing
62- else:
63- return self.time_stop-self.time_start-self.time_spent_pausing
64- */
6537STATIC mp_obj_t tools_StopWatch_time (mp_obj_t self_in ) {
6638 tools_StopWatch_obj_t * self = MP_OBJ_TO_PTR (self_in );
6739 return mp_obj_new_int (
@@ -72,14 +44,6 @@ STATIC mp_obj_t tools_StopWatch_time(mp_obj_t self_in) {
7244}
7345STATIC MP_DEFINE_CONST_FUN_OBJ_1 (tools_StopWatch_time_obj , tools_StopWatch_time );
7446
75- /*
76- StopWatch
77- def pause(self):
78- """Pause the stopwatch."""
79- if self.running:
80- self.running = False
81- self.time_stop = get_time()
82- */
8347STATIC mp_obj_t tools_StopWatch_pause (mp_obj_t self_in ) {
8448 tools_StopWatch_obj_t * self = MP_OBJ_TO_PTR (self_in );
8549 if (self -> running ) {
@@ -90,14 +54,6 @@ STATIC mp_obj_t tools_StopWatch_pause(mp_obj_t self_in) {
9054}
9155STATIC MP_DEFINE_CONST_FUN_OBJ_1 (tools_StopWatch_pause_obj , tools_StopWatch_pause );
9256
93- /*
94- StopWatch
95- def resume(self):
96- """Resume the stopwatch."""
97- if not self.running:
98- self.running = True
99- self.time_spent_pausing += get_time()-self.time_stop
100- */
10157STATIC mp_obj_t tools_StopWatch_resume (mp_obj_t self_in ) {
10258 tools_StopWatch_obj_t * self = MP_OBJ_TO_PTR (self_in );
10359 if (!self -> running ) {
@@ -108,13 +64,6 @@ STATIC mp_obj_t tools_StopWatch_resume(mp_obj_t self_in) {
10864}
10965STATIC MP_DEFINE_CONST_FUN_OBJ_1 (tools_StopWatch_resume_obj , tools_StopWatch_resume );
11066
111- /*
112- StopWatch
113- def __init__(self):
114- """Create the StopWatch object, reset it, and start it."""
115- self.reset()
116- self.resume()
117- */
11867STATIC mp_obj_t tools_StopWatch_make_new (const mp_obj_type_t * type , size_t n_args , size_t n_kw , const mp_obj_t * args ) {
11968 // Initialize self
12069 tools_StopWatch_obj_t * self = m_new_obj (tools_StopWatch_obj_t );
@@ -124,11 +73,6 @@ STATIC mp_obj_t tools_StopWatch_make_new(const mp_obj_type_t *type, size_t n_arg
12473 return MP_OBJ_FROM_PTR (self );
12574}
12675
127- /*
128- StopWatch
129- def __str__(self):
130- """String representation of StopWatch object."""
131- */
13276STATIC void tools_StopWatch_print (const mp_print_t * print , mp_obj_t self_in , mp_print_kind_t kind ) {
13377 mp_printf (print , qstr_str (MP_QSTR_StopWatch ));
13478}
0 commit comments