From bfa5cd9c13e308df5462653a53fe99eeb0543bc3 Mon Sep 17 00:00:00 2001 From: Daniel Pollard Date: Tue, 5 May 2020 15:23:38 +1000 Subject: refactor countio based on feedback --- py/circuitpy_defns.mk | 5 +++++ py/circuitpy_mpconfig.h | 8 ++++++++ py/circuitpy_mpconfig.mk | 11 +++++++++++ 3 files changed, 24 insertions(+) (limited to 'py') diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index ec8e6c3e9..a253f2fa8 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -136,6 +136,9 @@ endif ifeq ($(CIRCUITPY_BUSIO),1) SRC_PATTERNS += busio/% bitbangio/OneWire.% endif +ifeq ($(CIRCUITPY_COUNTIO),1) +SRC_PATTERNS += countio/% +endif ifeq ($(CIRCUITPY_DIGITALIO),1) SRC_PATTERNS += digitalio/% endif @@ -263,6 +266,8 @@ SRC_COMMON_HAL_ALL = \ busio/SPI.c \ busio/UART.c \ busio/__init__.c \ + countio/Counter.c \ + countio/__init__.c \ digitalio/DigitalInOut.c \ digitalio/__init__.c \ displayio/ParallelBus.c \ diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 29a4d524c..a3ab4da94 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -314,6 +314,13 @@ extern const struct _mp_obj_module_t busio_module; #define BUSIO_MODULE #endif +#if CIRCUITPY_COUNTIO +extern const struct _mp_obj_module_t countio_module; +#define COUNTIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_countio), (mp_obj_t)&countio_module }, +#else +#define COUNTIO_MODULE +#endif + #if CIRCUITPY_DIGITALIO extern const struct _mp_obj_module_t digitalio_module; #define DIGITALIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_digitalio), (mp_obj_t)&digitalio_module }, @@ -630,6 +637,7 @@ extern const struct _mp_obj_module_t ustack_module; BLEIO_MODULE \ BOARD_MODULE \ BUSIO_MODULE \ + COUNTIO_MODULE \ DIGITALIO_MODULE \ DISPLAYIO_MODULE \ FONTIO_MODULE \ diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 30ab720d7..7ef87a7ea 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -109,6 +109,12 @@ CIRCUITPY_DIGITALIO = 1 endif CFLAGS += -DCIRCUITPY_DIGITALIO=$(CIRCUITPY_DIGITALIO) +ifndef CIRCUITPY_COUNTIO +CIRCUITPY_COUNTIO = 1 +endif +CFLAGS += -DCIRCUITPY_COUNTIO=$(CIRCUITPY_COUNTIO) + + ifndef CIRCUITPY_DISPLAYIO CIRCUITPY_DISPLAYIO = $(CIRCUITPY_FULL_BUILD) endif @@ -207,6 +213,11 @@ CIRCUITPY_ROTARYIO = 1 endif CFLAGS += -DCIRCUITPY_ROTARYIO=$(CIRCUITPY_ROTARYIO) +ifndef CIRCUITPY_COUNTIO +CIRCUITPY_COUNTIO = 1 +endif +CFLAGS += -DCIRCUITPY_COUNTIO=$(CIRCUITPY_COUNTIO) + ifndef CIRCUITPY_RTC CIRCUITPY_RTC = 1 endif -- cgit v1.2.3 From 8961dd9fe74a3ba6e55bfb1b8132a93de920a1dc Mon Sep 17 00:00:00 2001 From: Daniel Pollard Date: Wed, 6 May 2020 09:05:14 +1000 Subject: changed build variables as per advice --- py/circuitpy_mpconfig.mk | 4 ++-- shared-bindings/countio/Counter.c | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'py') diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 7ef87a7ea..be1e0ad9a 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -110,7 +110,7 @@ endif CFLAGS += -DCIRCUITPY_DIGITALIO=$(CIRCUITPY_DIGITALIO) ifndef CIRCUITPY_COUNTIO -CIRCUITPY_COUNTIO = 1 +CIRCUITPY_COUNTIO ?= 1 endif CFLAGS += -DCIRCUITPY_COUNTIO=$(CIRCUITPY_COUNTIO) @@ -214,7 +214,7 @@ endif CFLAGS += -DCIRCUITPY_ROTARYIO=$(CIRCUITPY_ROTARYIO) ifndef CIRCUITPY_COUNTIO -CIRCUITPY_COUNTIO = 1 +CIRCUITPY_COUNTIO = $(CIRCUITPY_FULL_BUILD) endif CFLAGS += -DCIRCUITPY_COUNTIO=$(CIRCUITPY_COUNTIO) diff --git a/shared-bindings/countio/Counter.c b/shared-bindings/countio/Counter.c index c10294199..efa3387a6 100644 --- a/shared-bindings/countio/Counter.c +++ b/shared-bindings/countio/Counter.c @@ -31,10 +31,9 @@ //| from board import * //| //| pin_counter = countio.Counter(board.D1) -//| +//| #reset the count after 100 counts //| while True: -//| count = pin_counter.count -//| if count == None 10: +//| if pin_counter.count == 100: //| pin_counter.reset() //| print(pin_counter.count) //| -- cgit v1.2.3 From 84c806a4bebb72b8deaae8cb5cada9d5ab7aa41b Mon Sep 17 00:00:00 2001 From: Daniel Pollard Date: Thu, 7 May 2020 12:42:46 +1000 Subject: updated descriptions and build variable --- py/circuitpy_mpconfig.mk | 2 +- shared-bindings/countio/Counter.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'py') diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index be1e0ad9a..95e3512f1 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -110,7 +110,7 @@ endif CFLAGS += -DCIRCUITPY_DIGITALIO=$(CIRCUITPY_DIGITALIO) ifndef CIRCUITPY_COUNTIO -CIRCUITPY_COUNTIO ?= 1 +CIRCUITPY_COUNTIO = 1 endif CFLAGS += -DCIRCUITPY_COUNTIO=$(CIRCUITPY_COUNTIO) diff --git a/shared-bindings/countio/Counter.c b/shared-bindings/countio/Counter.c index efa3387a6..1777acc8a 100644 --- a/shared-bindings/countio/Counter.c +++ b/shared-bindings/countio/Counter.c @@ -11,15 +11,15 @@ //| .. currentmodule:: countio //| -//| :class:`Counter` -- Track the count of edge transistions (pulses) on a given pin +//| :class:`Counter` -- Track the count of falling edge transistions (pulses) on a given pin //| ==================================================================================== //| -//| Counter will keep track of the number of edge transistions (pulses) on a given pin +//| Counter will keep track of the number of falling edge transistions (pulses) on a given pin //| //| .. class:: Counter(pin_a) //| //| Create an Counter object associated with the given pin. It tracks the number of -//| pulses relative when the object is contructed. +//| falling pulses relative when the object is constructed. //| //| :param ~microcontroller.Pin pin_a: Pin to read pulses from. //| -- cgit v1.2.3 From 94ca233d976a9641c207a244f7c92097cb75da91 Mon Sep 17 00:00:00 2001 From: Daniel Pollard Date: Fri, 8 May 2020 07:55:11 +1000 Subject: Update py/circuitpy_mpconfig.mk Co-authored-by: Scott Shawcroft --- py/circuitpy_mpconfig.mk | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'py') diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 95e3512f1..c805b0501 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -109,9 +109,7 @@ CIRCUITPY_DIGITALIO = 1 endif CFLAGS += -DCIRCUITPY_DIGITALIO=$(CIRCUITPY_DIGITALIO) -ifndef CIRCUITPY_COUNTIO -CIRCUITPY_COUNTIO = 1 -endif +CIRCUITPY_COUNTIO ?= 1 CFLAGS += -DCIRCUITPY_COUNTIO=$(CIRCUITPY_COUNTIO) -- cgit v1.2.3 From e947e4eb580e080d37445240ec88610fc1787975 Mon Sep 17 00:00:00 2001 From: Daniel Pollard Date: Sat, 9 May 2020 17:56:38 +1000 Subject: removed duplicate build param --- py/circuitpy_mpconfig.mk | 4 ---- 1 file changed, 4 deletions(-) (limited to 'py') diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index c805b0501..73eb4fa5a 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -211,10 +211,6 @@ CIRCUITPY_ROTARYIO = 1 endif CFLAGS += -DCIRCUITPY_ROTARYIO=$(CIRCUITPY_ROTARYIO) -ifndef CIRCUITPY_COUNTIO -CIRCUITPY_COUNTIO = $(CIRCUITPY_FULL_BUILD) -endif -CFLAGS += -DCIRCUITPY_COUNTIO=$(CIRCUITPY_COUNTIO) ifndef CIRCUITPY_RTC CIRCUITPY_RTC = 1 -- cgit v1.2.3 From 4612270f98988ac4646c5cbf4bebddb35e71f660 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 12 May 2020 19:00:51 -0700 Subject: Only enable COUNTIO in full builds --- py/circuitpy_mpconfig.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'py') diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 74ad7a2cc..0801540bc 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -88,7 +88,7 @@ CFLAGS += -DCIRCUITPY_BUSIO=$(CIRCUITPY_BUSIO) CIRCUITPY_DIGITALIO ?= 1 CFLAGS += -DCIRCUITPY_DIGITALIO=$(CIRCUITPY_DIGITALIO) -CIRCUITPY_COUNTIO ?= 1 +CIRCUITPY_COUNTIO ?= $(CIRCUITPY_FULL_BUILD) CFLAGS += -DCIRCUITPY_COUNTIO=$(CIRCUITPY_COUNTIO) CIRCUITPY_DISPLAYIO ?= $(CIRCUITPY_FULL_BUILD) -- cgit v1.2.3