Merge pull request #10 from synthead/add-beepwear-pro-support
Fix BeepwearPRO 1.03 not recognizing this device as a working Notebook Adapter
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
+22
-5
@@ -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 <Arduino.h>
|
||||
|
||||
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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
+25
-30
@@ -1,50 +1,45 @@
|
||||
#define COMMAND_PING 'x'
|
||||
#define COMMAND_QUERY '?'
|
||||
#define COMMAND_FAST 'V'
|
||||
#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
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "led_blaster.h"
|
||||
|
||||
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) {
|
||||
LedBlaster::enable_fast_mode(false);
|
||||
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_FAST:
|
||||
if (command_mode) {
|
||||
LedBlaster::enable_fast_mode(true);
|
||||
}
|
||||
|
||||
break;
|
||||
case COMMAND_TRANSMIT:
|
||||
command_mode = false;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
#include <Arduino.h>
|
||||
|
||||
namespace NotebookAdapter {
|
||||
void emulate_command_mode(uint8_t serial_byte);
|
||||
void emulate_data_mode(uint8_t serial_byte);
|
||||
void emulate(uint8_t serial_byte);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user