From f020b78a52053ef81b6bb2d0a56d01184f48d2e4 Mon Sep 17 00:00:00 2001 From: Maxwell Pray Date: Tue, 21 Feb 2023 01:42:02 -0800 Subject: [PATCH 1/6] Use "107\r M764 rev 764100" in query payload response. --- notebook_adapter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notebook_adapter.cpp b/notebook_adapter.cpp index e7d92ff..e960a91 100644 --- a/notebook_adapter.cpp +++ b/notebook_adapter.cpp @@ -1,7 +1,7 @@ #define COMMAND_PING 'x' #define COMMAND_QUERY '?' #define COMMAND_TRANSMIT 'U' -#define COMMAND_QUERY_PAYLOAD "?126\r M764 rev 764002" +#define COMMAND_QUERY_PAYLOAD "?107\r M764 rev 764100" #define DATA_MODE_TIMEOUT_MS 1000 From 4b96df400b6886dc8b9605b51640511590d26f2f Mon Sep 17 00:00:00 2001 From: Maxwell Pray Date: Tue, 21 Feb 2023 01:44:19 -0800 Subject: [PATCH 2/6] Repeat all received bytes to serial host. --- notebook_adapter.cpp | 46 +++++++++++++++----------------------------- notebook_adapter.h | 2 -- 2 files changed, 16 insertions(+), 32 deletions(-) diff --git a/notebook_adapter.cpp b/notebook_adapter.cpp index e960a91..000160a 100644 --- a/notebook_adapter.cpp +++ b/notebook_adapter.cpp @@ -1,7 +1,6 @@ -#define COMMAND_PING 'x' #define COMMAND_QUERY '?' #define COMMAND_TRANSMIT 'U' -#define COMMAND_QUERY_PAYLOAD "?107\r M764 rev 764100" +#define COMMAND_QUERY_PAYLOAD "107\r M764 rev 764100" #define DATA_MODE_TIMEOUT_MS 1000 @@ -11,40 +10,27 @@ namespace NotebookAdapter { unsigned long last_data_ms = 0; bool command_mode = true; - void emulate_command_mode(uint8_t serial_byte) { - switch(serial_byte) { - case COMMAND_PING: - Serial.write(COMMAND_PING); - - break; - - case COMMAND_QUERY: - Serial.print(COMMAND_QUERY_PAYLOAD); - Serial.write(0); - - break; - - case COMMAND_TRANSMIT: - Serial.write(COMMAND_TRANSMIT); - command_mode = false; - - break; - } - } - - void emulate_data_mode(uint8_t serial_byte) { + void emulate(uint8_t serial_byte) { if (millis() - last_data_ms > DATA_MODE_TIMEOUT_MS) { command_mode = true; } Serial.write(serial_byte); + switch(serial_byte) { + case COMMAND_QUERY: + if (command_mode) { + Serial.print(COMMAND_QUERY_PAYLOAD); + Serial.write(0); + } + + break; + case COMMAND_TRANSMIT: + command_mode = true; + + break; + } + last_data_ms = millis(); } - - void emulate(uint8_t serial_byte) { - void(*function)(uint8_t) = command_mode ? emulate_command_mode : emulate_data_mode; - - function(serial_byte); - } } diff --git a/notebook_adapter.h b/notebook_adapter.h index b33f448..0adec12 100644 --- a/notebook_adapter.h +++ b/notebook_adapter.h @@ -4,8 +4,6 @@ #include namespace NotebookAdapter { - void emulate_command_mode(uint8_t serial_byte); - void emulate_data_mode(uint8_t serial_byte); void emulate(uint8_t serial_byte); } From 85d688258fc7c08e5848ec1b34344104ac6ddac8 Mon Sep 17 00:00:00 2001 From: Maxwell Pray Date: Tue, 21 Feb 2023 01:53:40 -0800 Subject: [PATCH 3/6] Add Timex BeepwearPRO 1.03 to compatible software list. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 234211a..83ed8f1 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ This Notebook Adapter emulator is tested to be compatible with: - [Timex Data Link® Software 2.1d](https://assets.timex.com/html/data_link_software.html) - [Timex Ironman Triathlon® Data Link® 2.01](https://assets.timex.com/html/data_link_software.html) +- [Timex BeepwearPRO 1.03](https://assets.timex.com/beepwear) - [DSI Electronics e-BRAIN v1.1.6](https://archive.org/details/ebrain-1.1.6) - [timex\_datalink\_client Ruby library](https://github.com/synthead/timex_datalink_client) From 756cb8936c5f1722065fe81363e3a406bbc16b98 Mon Sep 17 00:00:00 2001 From: Maxwell Pray Date: Tue, 21 Feb 2023 03:42:37 -0800 Subject: [PATCH 4/6] Disable command mode on data transmit. --- notebook_adapter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notebook_adapter.cpp b/notebook_adapter.cpp index 000160a..8aded56 100644 --- a/notebook_adapter.cpp +++ b/notebook_adapter.cpp @@ -26,7 +26,7 @@ namespace NotebookAdapter { break; case COMMAND_TRANSMIT: - command_mode = true; + command_mode = false; break; } From 63ed9c4ac93571cb67dbdae320a82fe0d3c936ba Mon Sep 17 00:00:00 2001 From: Maxwell Pray Date: Tue, 21 Feb 2023 03:57:48 -0800 Subject: [PATCH 5/6] Add enable_fast_mode to LedBlaster. --- led_blaster.cpp | 27 ++++++++++++++++++++++----- led_blaster.h | 1 + 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/led_blaster.cpp b/led_blaster.cpp index c43b3c8..75d9bc6 100644 --- a/led_blaster.cpp +++ b/led_blaster.cpp @@ -1,25 +1,42 @@ #define LED_PIN 13 -#define LED_ON_MS 15 -#define LED_OFF_MS 450 +#define LED_ON_MS_NORMAL 15 +#define LED_OFF_MS_NORMAL 450 + +#define LED_ON_MS_FAST 6 +#define LED_OFF_MS_FAST 408 #include namespace LedBlaster { + uint16_t led_on_ms; + uint16_t led_off_ms; + + void enable_fast_mode(bool fast_mode_enabled) { + if (fast_mode_enabled) { + led_on_ms = LED_ON_MS_FAST; + led_off_ms = LED_OFF_MS_FAST; + } else { + led_on_ms = LED_ON_MS_NORMAL; + led_off_ms = LED_OFF_MS_NORMAL; + } + } + void setup() { pinMode(LED_PIN, OUTPUT); + enable_fast_mode(false); } void emit_0() { digitalWrite(LED_PIN, HIGH); - delayMicroseconds(LED_ON_MS); + delayMicroseconds(led_on_ms); digitalWrite(LED_PIN, LOW); - delayMicroseconds(LED_OFF_MS); + delayMicroseconds(led_off_ms); } void emit_1() { - delayMicroseconds(LED_ON_MS + LED_OFF_MS); + delayMicroseconds(led_on_ms + led_off_ms); } void emit_byte(uint8_t serial_byte) { diff --git a/led_blaster.h b/led_blaster.h index e1af3fb..3a003e8 100644 --- a/led_blaster.h +++ b/led_blaster.h @@ -5,6 +5,7 @@ namespace LedBlaster { void setup(); + void enable_fast_mode(bool fast_mode_enabled); void emit_0(); void emit_1(); void emit_byte(uint8_t serial_byte); From 2d81324aaec800e940f387dcca16472b31c16911 Mon Sep 17 00:00:00 2001 From: Maxwell Pray Date: Tue, 21 Feb 2023 03:59:51 -0800 Subject: [PATCH 6/6] Make "V" command enable fast mode. --- notebook_adapter.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/notebook_adapter.cpp b/notebook_adapter.cpp index 8aded56..47696ac 100644 --- a/notebook_adapter.cpp +++ b/notebook_adapter.cpp @@ -1,10 +1,12 @@ #define COMMAND_QUERY '?' +#define COMMAND_FAST 'V' #define COMMAND_TRANSMIT 'U' #define COMMAND_QUERY_PAYLOAD "107\r M764 rev 764100" #define DATA_MODE_TIMEOUT_MS 1000 #include +#include "led_blaster.h" namespace NotebookAdapter { unsigned long last_data_ms = 0; @@ -12,6 +14,7 @@ namespace NotebookAdapter { void emulate(uint8_t serial_byte) { if (millis() - last_data_ms > DATA_MODE_TIMEOUT_MS) { + LedBlaster::enable_fast_mode(false); command_mode = true; } @@ -24,6 +27,12 @@ namespace NotebookAdapter { Serial.write(0); } + break; + case COMMAND_FAST: + if (command_mode) { + LedBlaster::enable_fast_mode(true); + } + break; case COMMAND_TRANSMIT: command_mode = false;