From 08602639c7c3764de5096636dc90cdb18abeedbb Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 13 Nov 2019 16:00:18 +0100 Subject: ptalog: Support barcode synchronization --- include/object/ptalog.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'include/object') diff --git a/include/object/ptalog.h b/include/object/ptalog.h index 01aac8f..c3ffdf6 100644 --- a/include/object/ptalog.h +++ b/include/object/ptalog.h @@ -6,7 +6,7 @@ #ifdef PTALOG_GPIO #include "driver/gpio.h" -#ifdef PTALOG_GPIO_BEFORE +#if defined(PTALOG_GPIO_BEFORE) || defined(PTALOG_GPIO_BAR) #include "arch.h" #endif #endif @@ -94,6 +94,20 @@ class PTALog { } } +#ifdef PTALOG_GPIO_BAR + void startTransition(char const *code, uint8_t code_length) + { + arch.sleep_ms(10); + for (uint8_t byte = 0; byte < code_length; byte++) { + for (uint16_t mask = 0x01; mask <= 0x80; mask <<= 1) { + gpio.write(sync_pin, code[byte] & mask ? 1 : 0); + arch.sleep_ms(10); + } + } + gpio.write(sync_pin, 0); + arch.sleep_ms(10); + } +#else inline void startTransition() { #ifdef PTALOG_GPIO_BEFORE @@ -105,6 +119,7 @@ class PTALog { gpio.write(sync_pin, 1); #endif } +#endif #ifdef PTALOG_WITH_RETURNVALUES inline void logReturn(uint16_t ret) @@ -120,7 +135,7 @@ class PTALog { #endif { #ifdef PTALOG_GPIO -#ifndef PTALOG_GPIO_BEFORE +#if !defined(PTALOG_GPIO_BEFORE) && !defined(PTALOG_GPIO_BAR) gpio.write(sync_pin, 0); #endif #endif -- cgit v1.2.3