timex_datalink_client 0.3.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/timex_datalink_client/alarm.rb +2 -4
- data/lib/timex_datalink_client/eeprom/anniversary.rb +1 -1
- data/lib/timex_datalink_client/eeprom/appointment.rb +1 -1
- data/lib/timex_datalink_client/helpers/char_encoders.rb +12 -7
- data/lib/timex_datalink_client/time.rb +11 -5
- data/lib/timex_datalink_client/version.rb +1 -1
- data/lib/timex_datalink_client.rb +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '082ddc8969ac82b8858b2f68fd9c8f34b7f53b46eccc407200615eba75b00821'
|
4
|
+
data.tar.gz: 99ae5a09d43fe26bf849808be2bceb18350d1c97e8fce962ee2a367a07a12677
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13adc215949a1c2af60c9d65da0e5ad8b780e27bf4f1009cc29ff85f7ffab3f9b912ae7f8cab1b785c14de28ece73036335eff2f7f85b78da9e2ca0e16e63eaa
|
7
|
+
data.tar.gz: 43a8a73d8e9194295e83f7794e4b0c86d90b0b04b236b1f8b6779a267d33a6cc3af2de9b45efbab5112fa1dd26a4858a7a3c6755f49c6636e90782d5a49e6ce8
|
@@ -18,7 +18,7 @@ class TimexDatalinkClient
|
|
18
18
|
#
|
19
19
|
# @param number [Integer] Alarm number (from 1 to 5).
|
20
20
|
# @param audible [Boolean] Toggle alarm sounds.
|
21
|
-
# @param time [Time] Time of alarm.
|
21
|
+
# @param time [::Time] Time of alarm.
|
22
22
|
# @param message [String] Alarm message text.
|
23
23
|
# @return [Alarm] Alarm instance.
|
24
24
|
def initialize(number:, audible:, time:, message:)
|
@@ -49,9 +49,7 @@ class TimexDatalinkClient
|
|
49
49
|
private
|
50
50
|
|
51
51
|
def message_characters
|
52
|
-
|
53
|
-
|
54
|
-
chars_for(message_padded)
|
52
|
+
chars_for(message, length: 8, pad: true)
|
55
53
|
end
|
56
54
|
|
57
55
|
def audible_integer
|
@@ -13,7 +13,7 @@ class TimexDatalinkClient
|
|
13
13
|
|
14
14
|
# Create an Anniversary instance.
|
15
15
|
#
|
16
|
-
# @param time [Time] Time of anniversary.
|
16
|
+
# @param time [::Time] Time of anniversary.
|
17
17
|
# @param anniversary [String] Anniversary text.
|
18
18
|
# @return [Anniversary] Anniversary instance.
|
19
19
|
def initialize(time:, anniversary:)
|
@@ -13,7 +13,7 @@ class TimexDatalinkClient
|
|
13
13
|
|
14
14
|
# Create an Appointment instance.
|
15
15
|
#
|
16
|
-
# @param time [Time] Time of appointment.
|
16
|
+
# @param time [::Time] Time of appointment.
|
17
17
|
# @param message [String] Appointment text.
|
18
18
|
# @return [Appointment] Appointment instance.
|
19
19
|
def initialize(time:, message:)
|
@@ -3,19 +3,24 @@
|
|
3
3
|
class TimexDatalinkClient
|
4
4
|
class Helpers
|
5
5
|
module CharEncoders
|
6
|
-
CHARS = "0123456789abcdefghijklmnopqrstuvwxyz !\"#$%&'()*+,-./:\\;=@?
|
6
|
+
CHARS = "0123456789abcdefghijklmnopqrstuvwxyz !\"#$%&'()*+,-./:\\;=@?_|<>[]"
|
7
|
+
EEPROM_CHARS = "0123456789abcdefghijklmnopqrstuvwxyz !\"#$%&'()*+,-./:\\;=@?_|<>["
|
8
|
+
PHONE_CHARS = "0123456789cfhpw "
|
9
|
+
INVALID_CHAR = " "
|
10
|
+
|
7
11
|
EEPROM_TERMINATOR = 0x3f
|
8
12
|
|
9
|
-
|
13
|
+
def chars_for(string_chars, char_map: CHARS, length: nil, pad: false)
|
14
|
+
formatted_chars = string_chars.downcase[0..length.to_i - 1]
|
15
|
+
formatted_chars = formatted_chars.ljust(length) if pad
|
10
16
|
|
11
|
-
|
12
|
-
|
13
|
-
char_map.index(string_char)
|
17
|
+
formatted_chars.each_char.map do |char|
|
18
|
+
char_map.index(char) || char_map.index(INVALID_CHAR)
|
14
19
|
end
|
15
20
|
end
|
16
21
|
|
17
22
|
def eeprom_chars_for(string_chars)
|
18
|
-
chars = chars_for(string_chars).append(EEPROM_TERMINATOR)
|
23
|
+
chars = chars_for(string_chars, char_map: EEPROM_CHARS, length: 31).append(EEPROM_TERMINATOR)
|
19
24
|
|
20
25
|
packed_int = chars.each_with_index.sum do |char, index|
|
21
26
|
char << (6 * index)
|
@@ -25,7 +30,7 @@ class TimexDatalinkClient
|
|
25
30
|
end
|
26
31
|
|
27
32
|
def phone_chars_for(string_chars)
|
28
|
-
chars = chars_for(string_chars, char_map: PHONE_CHARS)
|
33
|
+
chars = chars_for(string_chars, char_map: PHONE_CHARS, length: 12)
|
29
34
|
|
30
35
|
packed_int = chars.each_with_index.sum do |char, index|
|
31
36
|
char << (4 * index)
|
@@ -17,13 +17,15 @@ class TimexDatalinkClient
|
|
17
17
|
# @param zone [Integer] Time zone number (1 or 2).
|
18
18
|
# @param is_24h [Boolean] Toggle 24 hour time.
|
19
19
|
# @param date_format [Integer] Date format.
|
20
|
-
# @param time [Time] Time to set (including time zone).
|
20
|
+
# @param time [::Time] Time to set (including time zone).
|
21
|
+
# @param name [String, nil] Name of time zone (defaults to zone from time; 3 chars max)
|
21
22
|
# @return [Time] Time instance.
|
22
|
-
def initialize(zone:, is_24h:, date_format:, time:)
|
23
|
+
def initialize(zone:, is_24h:, date_format:, time:, name: nil)
|
23
24
|
@zone = zone
|
24
25
|
@is_24h = is_24h
|
25
26
|
@date_format = date_format
|
26
27
|
@time = time
|
28
|
+
@name = name
|
27
29
|
end
|
28
30
|
|
29
31
|
# Compile packets for a time.
|
@@ -40,7 +42,7 @@ class TimexDatalinkClient
|
|
40
42
|
time.month,
|
41
43
|
time.day,
|
42
44
|
year_mod_1900,
|
43
|
-
|
45
|
+
name_characters,
|
44
46
|
wday_from_monday,
|
45
47
|
is_24h_value,
|
46
48
|
date_format
|
@@ -50,8 +52,12 @@ class TimexDatalinkClient
|
|
50
52
|
|
51
53
|
private
|
52
54
|
|
53
|
-
def
|
54
|
-
|
55
|
+
def name
|
56
|
+
@name || time.zone.downcase
|
57
|
+
end
|
58
|
+
|
59
|
+
def name_characters
|
60
|
+
chars_for(name, length: 3, pad: true)
|
55
61
|
end
|
56
62
|
|
57
63
|
def year_mod_1900
|
@@ -24,8 +24,8 @@ class TimexDatalinkClient
|
|
24
24
|
# @param serial_device [String] Path to serial device.
|
25
25
|
# @param models [Array<Alarm, Eeprom, End, SoundOptions, SoundTheme, Start, Sync, Time, WristApp>] Models to compile
|
26
26
|
# data for.
|
27
|
-
# @param byte_sleep [Integer] Time to sleep after sending byte.
|
28
|
-
# @param packet_sleep [Integer] Time to sleep after sending packet of bytes.
|
27
|
+
# @param byte_sleep [Integer, nil] Time to sleep after sending byte.
|
28
|
+
# @param packet_sleep [Integer, nil] Time to sleep after sending packet of bytes.
|
29
29
|
# @param verbose [Boolean] Write verbose output to console.
|
30
30
|
# @return [TimexDatalinkClient] TimexDatalinkClient instance.
|
31
31
|
def initialize(serial_device:, models: [], byte_sleep: nil, packet_sleep: nil, verbose: false)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timex_datalink_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maxwell Pray
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
11
|
+
date: 2022-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: crc
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 0.0.9
|
83
|
-
description:
|
83
|
+
description:
|
84
84
|
email: synthead@gmail.com
|
85
85
|
executables: []
|
86
86
|
extensions: []
|
@@ -106,7 +106,7 @@ files:
|
|
106
106
|
- lib/timex_datalink_client/time.rb
|
107
107
|
- lib/timex_datalink_client/version.rb
|
108
108
|
- lib/timex_datalink_client/wrist_app.rb
|
109
|
-
homepage: https://github.com/synthead/timex_datalink_client
|
109
|
+
homepage: https://github.com/synthead/timex_datalink_client/tree/v0.4.1
|
110
110
|
licenses:
|
111
111
|
- MIT
|
112
112
|
metadata: {}
|
@@ -128,5 +128,5 @@ requirements: []
|
|
128
128
|
rubygems_version: 3.3.7
|
129
129
|
signing_key:
|
130
130
|
specification_version: 4
|
131
|
-
summary:
|
131
|
+
summary: Write data to Timex Datalink devices with an optical sensor
|
132
132
|
test_files: []
|