diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2019-11-13 16:00:18 +0100 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2019-11-13 16:00:18 +0100 |
commit | 08602639c7c3764de5096636dc90cdb18abeedbb (patch) | |
tree | 94ac11d8951261d2e98a74bfed2f892a8de507eb /include/object | |
parent | d3f4eef9f2f6619fcd1c07742e789725e3b16104 (diff) |
ptalog: Support barcode synchronization
Diffstat (limited to 'include/object')
-rw-r--r-- | include/object/ptalog.h | 19 |
1 files changed, 17 insertions, 2 deletions
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 |