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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 28aaa8e7fc767be8f9b0afe3f357b23d622ac04f126e141d29d4c7cb9ab7684a
4
- data.tar.gz: 380021a3acfe29dd07b439b85cb2b73ad5ef3085fbea3676ab5905fb454542f7
3
+ metadata.gz: '082ddc8969ac82b8858b2f68fd9c8f34b7f53b46eccc407200615eba75b00821'
4
+ data.tar.gz: 99ae5a09d43fe26bf849808be2bceb18350d1c97e8fce962ee2a367a07a12677
5
5
  SHA512:
6
- metadata.gz: dac7dc2741fdba75032411794be8b6f8aae569ab1c5c1526d50456fb647c41bcbbf1bdd97e6c698a03a85f2a8502a4d75f7e81268e0b4a6a865bf99b99162cef
7
- data.tar.gz: a2e89e0916056a8efc4fdb27901fe92de076641caac96d81ce2d25345b23f6efee371b5efb654e98c7e347c79ffae3a5722359d6c8fc71177354e0a0d4604ee4
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
- message_padded = message.ljust(MESSAGE_LENGTH)
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 !\"#$%&'()*+,-./:\\;=@?ABCDEF"
6
+ CHARS = "0123456789abcdefghijklmnopqrstuvwxyz !\"#$%&'()*+,-./:\\;=@?_|<>[]"
7
+ EEPROM_CHARS = "0123456789abcdefghijklmnopqrstuvwxyz !\"#$%&'()*+,-./:\\;=@?_|<>["
8
+ PHONE_CHARS = "0123456789cfhpw "
9
+ INVALID_CHAR = " "
10
+
7
11
  EEPROM_TERMINATOR = 0x3f
8
12
 
9
- PHONE_CHARS = "0123456789cfhpw "
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
- def chars_for(string_chars, char_map: CHARS)
12
- string_chars.each_char.map do |string_char|
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
- timezone_characters,
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 timezone_characters
54
- chars_for(time.zone.downcase)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class TimexDatalinkClient
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.1"
5
5
  end
@@ -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.3.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-08 00:00:00.000000000 Z
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: Write data to Timex Datalink watches with an optical sensor
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: Library for optical Timex Datalink watches
131
+ summary: Write data to Timex Datalink devices with an optical sensor
132
132
  test_files: []