File tree Expand file tree Collapse file tree 3 files changed +15
-0
lines changed
ports/atmel-samd/common-hal/_pew Expand file tree Collapse file tree 3 files changed +15
-0
lines changed Original file line number Diff line number Diff line change 40
40
41
41
42
42
static uint8_t pewpew_tc_index = 0xff ;
43
+ static volatile uint16_t pewpew_ticks = 0 ;
43
44
44
45
45
46
void pewpew_interrupt_handler (uint8_t index ) {
@@ -52,6 +53,7 @@ void pewpew_interrupt_handler(uint8_t index) {
52
53
}
53
54
54
55
pew_tick ();
56
+ ++ pewpew_ticks ;
55
57
56
58
// Clear the interrupt bit.
57
59
tc -> COUNT16 .INTFLAG .reg = TC_INTFLAG_MC0 ;
@@ -123,3 +125,7 @@ void pew_reset(void) {
123
125
}
124
126
MP_STATE_VM (pew_singleton ) = NULL ;
125
127
}
128
+
129
+ uint16_t pew_get_ticks () {
130
+ return pewpew_ticks ;
131
+ }
Original file line number Diff line number Diff line change @@ -44,5 +44,6 @@ typedef struct {
44
44
void pew_init (void );
45
45
void pewpew_interrupt_handler (uint8_t index );
46
46
void pew_reset (void );
47
+ uint16_t pew_get_ticks (void );
47
48
48
49
#endif // MICROPY_INCLUDED_PEW_PEWPEW_H
Original file line number Diff line number Diff line change 29
29
#include "PewPew.h"
30
30
#include "common-hal/_pew/PewPew.h"
31
31
32
+
32
33
STATIC mp_obj_t get_pressed (void ) {
33
34
pew_obj_t * pew = MP_STATE_VM (pew_singleton );
34
35
if (!pew ) {
@@ -41,12 +42,19 @@ STATIC mp_obj_t get_pressed(void) {
41
42
STATIC MP_DEFINE_CONST_FUN_OBJ_0 (get_pressed_obj , get_pressed );
42
43
43
44
45
+ STATIC mp_obj_t get_ticks (void ) {
46
+ return mp_obj_new_int (pew_get_ticks ());
47
+ }
48
+ STATIC MP_DEFINE_CONST_FUN_OBJ_0 (get_ticks_obj , get_ticks );
49
+
50
+
44
51
//| """LED matrix driver"""
45
52
//|
46
53
STATIC const mp_rom_map_elem_t pew_module_globals_table [] = {
47
54
{ MP_ROM_QSTR (MP_QSTR___name__ ), MP_ROM_QSTR (MP_QSTR__pew ) },
48
55
{ MP_OBJ_NEW_QSTR (MP_QSTR_PewPew ), MP_ROM_PTR (& pewpew_type )},
49
56
{ MP_OBJ_NEW_QSTR (MP_QSTR_get_pressed ), MP_ROM_PTR (& get_pressed_obj )},
57
+ { MP_OBJ_NEW_QSTR (MP_QSTR_get_ticks ), MP_ROM_PTR (& get_ticks_obj )},
50
58
};
51
59
STATIC MP_DEFINE_CONST_DICT (pew_module_globals ,
52
60
pew_module_globals_table );
You can’t perform that action at this time.
0 commit comments