timex_datalink_client 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/lib/timex_datalink_client/helpers/char_encoders.rb +2 -2
  3. data/lib/timex_datalink_client/protocol_1/eeprom/anniversary.rb +44 -0
  4. data/lib/timex_datalink_client/protocol_1/eeprom/appointment.rb +49 -0
  5. data/lib/timex_datalink_client/protocol_1/eeprom/list.rb +43 -0
  6. data/lib/timex_datalink_client/protocol_1/eeprom/phone_number.rb +56 -0
  7. data/lib/timex_datalink_client/protocol_1/end.rb +12 -2
  8. data/lib/timex_datalink_client/protocol_1/sync.rb +33 -3
  9. data/lib/timex_datalink_client/protocol_3/eeprom/anniversary.rb +44 -0
  10. data/lib/timex_datalink_client/protocol_3/eeprom/appointment.rb +49 -0
  11. data/lib/timex_datalink_client/protocol_3/eeprom/list.rb +43 -0
  12. data/lib/timex_datalink_client/protocol_3/eeprom/phone_number.rb +56 -0
  13. data/lib/timex_datalink_client/protocol_3/end.rb +12 -2
  14. data/lib/timex_datalink_client/protocol_3/sync.rb +33 -3
  15. data/lib/timex_datalink_client/protocol_9/alarm.rb +63 -0
  16. data/lib/timex_datalink_client/protocol_9/eeprom/chrono.rb +47 -0
  17. data/lib/timex_datalink_client/protocol_9/eeprom/phone_number.rb +74 -0
  18. data/lib/timex_datalink_client/protocol_9/eeprom.rb +85 -0
  19. data/lib/timex_datalink_client/protocol_9/end.rb +20 -0
  20. data/lib/timex_datalink_client/protocol_9/sound_options.rb +42 -0
  21. data/lib/timex_datalink_client/protocol_9/start.rb +20 -0
  22. data/lib/timex_datalink_client/protocol_9/sync.rb +40 -0
  23. data/lib/timex_datalink_client/protocol_9/time.rb +61 -0
  24. data/lib/timex_datalink_client/protocol_9/time_name.rb +46 -0
  25. data/lib/timex_datalink_client/protocol_9/timer.rb +54 -0
  26. data/lib/timex_datalink_client/version.rb +1 -1
  27. data/lib/timex_datalink_client.rb +25 -8
  28. metadata +22 -9
  29. data/lib/timex_datalink_client/eeprom/anniversary.rb +0 -42
  30. data/lib/timex_datalink_client/eeprom/appointment.rb +0 -47
  31. data/lib/timex_datalink_client/eeprom/list.rb +0 -41
  32. data/lib/timex_datalink_client/eeprom/phone_number.rb +0 -56
  33. data/lib/timex_datalink_client/end.rb +0 -18
  34. data/lib/timex_datalink_client/sync.rb +0 -37
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "timex_datalink_client/helpers/char_encoders"
4
+ require "timex_datalink_client/helpers/length_packet_wrapper"
5
+
6
+ class TimexDatalinkClient
7
+ class Protocol9
8
+ class Eeprom
9
+ class PhoneNumber
10
+ include Helpers::CharEncoders
11
+ prepend Helpers::LengthPacketWrapper
12
+
13
+ NAME_CHARS = 15
14
+ PHONE_DIGITS = 12
15
+ TYPE_DIGITS = 2
16
+
17
+ attr_accessor :name, :number, :type
18
+
19
+ # Create a PhoneNumber instance.
20
+ #
21
+ # @param name [String] Name associated to phone number.
22
+ # @param number [String] Phone number text.
23
+ # @param type [String] Phone number type.
24
+ # @return [PhoneNumber] PhoneNumber instance.
25
+ def initialize(name:, number:, type: " ")
26
+ @name = name
27
+ @number = number
28
+ @type = type
29
+ end
30
+
31
+ # Compile a packet for a phone number.
32
+ #
33
+ # @return [Array<Integer>] Array of integers that represent bytes.
34
+ def packet
35
+ [
36
+ number_with_type_characters,
37
+ name_characters
38
+ ].flatten
39
+ end
40
+
41
+ private
42
+
43
+ def number_with_type_characters
44
+ phone_chars_for(number_with_type_padded)
45
+ end
46
+
47
+ def name_characters
48
+ eeprom_chars_for(name_with_number_rollover, length: NAME_CHARS)
49
+ end
50
+
51
+ def number_with_type_padded
52
+ type_padded = type.rjust(TYPE_DIGITS)
53
+ number_with_type = "#{number}#{type_padded}"
54
+
55
+ number_with_type.rjust(PHONE_DIGITS)
56
+ end
57
+
58
+ def number_rollover
59
+ "-" + number[PHONE_DIGITS..]
60
+ end
61
+
62
+ def name_with_number_rollover
63
+ return name unless number.length > PHONE_DIGITS
64
+
65
+ truncate_length = NAME_CHARS - (name.length + number_rollover.length)
66
+
67
+ return "#{name}#{number_rollover}" unless truncate_length.negative?
68
+
69
+ "#{name[..truncate_length - 1]}#{number_rollover}"
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "timex_datalink_client/helpers/cpacket_paginator"
4
+ require "timex_datalink_client/helpers/crc_packets_wrapper"
5
+
6
+ class TimexDatalinkClient
7
+ class Protocol9
8
+ class Eeprom
9
+ include Helpers::CpacketPaginator
10
+ prepend Helpers::CrcPacketsWrapper
11
+
12
+ CPACKET_MEM = [0x70]
13
+ CPACKET_JMPMEM = [0x23]
14
+ CPACKET_SECT = [0x60]
15
+ CPACKET_DATA = [0x61]
16
+ CPACKET_END = [0x62]
17
+
18
+ SETUP_PACKETS = [
19
+ CPACKET_MEM + [
20
+ 0x02, 0x40, 0x05, 0xa9, 0x22, 0x5f, 0xe6, 0xb2, 0xe8, 0xbb, 0xe7, 0xb2, 0xe8, 0xbb, 0xe7, 0xbb, 0xe8, 0xb2,
21
+ 0xe7, 0xb2, 0x5c, 0xa3, 0x09, 0x26, 0xed, 0x15, 0xa9, 0x01
22
+ ],
23
+ CPACKET_MEM + [0x02, 0x5a, 0xa9, 0x02, 0x14, 0xa9, 0xb6, 0xa9, 0xa4, 0x07, 0x47, 0xb7, 0xa9, 0xcc, 0x74, 0x6f],
24
+ CPACKET_JMPMEM + [0x02, 0x40]
25
+ ]
26
+
27
+ PAYLOAD_HEADER = [0x00, 0x0e, 0x00]
28
+
29
+ CPACKET_DATA_LENGTH = 27
30
+ START_INDEX = 14
31
+ APPOINTMENT_NO_NOTIFICATION = 0xff
32
+
33
+ def self.empty_chrono
34
+ Chrono.new(label: "chrono", laps: 2)
35
+ end
36
+
37
+ attr_accessor :chrono, :phone_numbers
38
+
39
+ # Create an Eeprom instance.
40
+ #
41
+ # @param chrono [Chrono] Chrono to be added to EEPROM data.
42
+ # @param phone_numbers [Array<PhoneNumber>] Phone numbers to be added to EEPROM data.
43
+ # @return [Eeprom] Eeprom instance.
44
+ def initialize(chrono: nil, phone_numbers: [])
45
+ @chrono = chrono || self.class.empty_chrono
46
+ @phone_numbers = phone_numbers
47
+ end
48
+
49
+ # Compile packets for EEPROM data.
50
+ #
51
+ # @return [Array<Array<Integer>>] Two-dimensional array of integers that represent bytes.
52
+ def packets
53
+ SETUP_PACKETS + [header] + payloads + [CPACKET_END]
54
+ end
55
+
56
+ private
57
+
58
+ def header
59
+ CPACKET_SECT + [payloads.length]
60
+ end
61
+
62
+ def payload
63
+ [
64
+ PAYLOAD_HEADER,
65
+ chrono.chrono_bytesize,
66
+ chrono.laps,
67
+ phone_numbers.length,
68
+ all_packets
69
+ ].flatten
70
+ end
71
+
72
+ def payloads
73
+ paginate_cpackets(header: CPACKET_DATA, length: CPACKET_DATA_LENGTH, cpackets: payload)
74
+ end
75
+
76
+ def all_items
77
+ [[chrono], phone_numbers]
78
+ end
79
+
80
+ def all_packets
81
+ all_items.flatten.map(&:packet).flatten
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "timex_datalink_client/helpers/crc_packets_wrapper"
4
+
5
+ class TimexDatalinkClient
6
+ class Protocol9
7
+ class End
8
+ prepend Helpers::CrcPacketsWrapper
9
+
10
+ CPACKET_SKIP = [0x21]
11
+
12
+ # Compile packets for data end command.
13
+ #
14
+ # @return [Array<Array<Integer>>] Two-dimensional array of integers that represent bytes.
15
+ def packets
16
+ [CPACKET_SKIP]
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "timex_datalink_client/helpers/crc_packets_wrapper"
4
+
5
+ class TimexDatalinkClient
6
+ class Protocol9
7
+ class SoundOptions
8
+ prepend Helpers::CrcPacketsWrapper
9
+
10
+ CPACKET_BEEPS = [0x32]
11
+
12
+ attr_accessor :hourly_chime, :button_beep
13
+
14
+ # Create a SoundOptions instance.
15
+ #
16
+ # @param hourly_chime [Boolean] Toggle hourly chime sounds.
17
+ # @param button_beep [Boolean] Toggle button beep sounds.
18
+ # @return [SoundOptions] SoundOptions instance.
19
+ def initialize(hourly_chime:, button_beep:)
20
+ @hourly_chime = hourly_chime
21
+ @button_beep = button_beep
22
+ end
23
+
24
+ # Compile packets for sound options.
25
+ #
26
+ # @return [Array<Array<Integer>>] Two-dimensional array of integers that represent bytes.
27
+ def packets
28
+ [
29
+ CPACKET_BEEPS + [hourly_chime_value + button_beep_value]
30
+ ]
31
+ end
32
+
33
+ def hourly_chime_value
34
+ hourly_chime ? 1 : 0
35
+ end
36
+
37
+ def button_beep_value
38
+ button_beep ? 2 : 0
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "timex_datalink_client/helpers/crc_packets_wrapper"
4
+
5
+ class TimexDatalinkClient
6
+ class Protocol9
7
+ class Start
8
+ prepend Helpers::CrcPacketsWrapper
9
+
10
+ CPACKET_START = [0x20, 0x00, 0x00, 0x09]
11
+
12
+ # Compile packets for data start command.
13
+ #
14
+ # @return [Array<Array<Integer>>] Two-dimensional array of integers that represent bytes.
15
+ def packets
16
+ [CPACKET_START]
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ class TimexDatalinkClient
4
+ class Protocol9
5
+ class Sync
6
+ PING_BYTE = [0x78]
7
+ SYNC_1_BYTE = [0x55]
8
+ SYNC_2_BYTE = [0xaa]
9
+
10
+ SYNC_2_LENGTH = 40
11
+
12
+ attr_accessor :length
13
+
14
+ # Create a Sync instance.
15
+ #
16
+ # @param length [Integer] Number of 0x55 sync bytes to use.
17
+ # @return [Sync] Sync instance.
18
+ def initialize(length: 300)
19
+ @length = length
20
+ end
21
+
22
+ # Compile packets for syncronization data.
23
+ #
24
+ # @return [Array<Array<Integer>>] Two-dimensional array of integers that represent bytes.
25
+ def packets
26
+ [PING_BYTE + render_sync_1 + render_sync_2]
27
+ end
28
+
29
+ private
30
+
31
+ def render_sync_1
32
+ SYNC_1_BYTE * length
33
+ end
34
+
35
+ def render_sync_2
36
+ SYNC_2_BYTE * SYNC_2_LENGTH
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "timex_datalink_client/helpers/crc_packets_wrapper"
4
+
5
+ class TimexDatalinkClient
6
+ class Protocol9
7
+ class Time
8
+ prepend Helpers::CrcPacketsWrapper
9
+
10
+ CPACKET_TIME = [0x30]
11
+
12
+ attr_accessor :zone, :is_24h, :time
13
+
14
+ # Create a Time instance.
15
+ #
16
+ # @param zone [Integer] Time zone number (1 or 2).
17
+ # @param is_24h [Boolean] Toggle 24 hour time.
18
+ # @param time [::Time] Time to set.
19
+ # @return [Time] Time instance.
20
+ def initialize(zone:, is_24h:, time:)
21
+ @zone = zone
22
+ @is_24h = is_24h
23
+ @time = time
24
+ end
25
+
26
+ # Compile packets for a time.
27
+ #
28
+ # @return [Array<Array<Integer>>] Two-dimensional array of integers that represent bytes.
29
+ def packets
30
+ [
31
+ [
32
+ CPACKET_TIME,
33
+ zone,
34
+ time.hour,
35
+ time.min,
36
+ time.month,
37
+ time.day,
38
+ year_mod_1900,
39
+ wday_from_monday,
40
+ time.sec,
41
+ is_24h_value
42
+ ].flatten
43
+ ]
44
+ end
45
+
46
+ private
47
+
48
+ def year_mod_1900
49
+ time.year % 100
50
+ end
51
+
52
+ def wday_from_monday
53
+ (time.wday + 6) % 7
54
+ end
55
+
56
+ def is_24h_value
57
+ is_24h ? 2 : 1
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "timex_datalink_client/helpers/char_encoders"
4
+ require "timex_datalink_client/helpers/crc_packets_wrapper"
5
+
6
+ class TimexDatalinkClient
7
+ class Protocol9
8
+ class TimeName
9
+ include Helpers::CharEncoders
10
+ prepend Helpers::CrcPacketsWrapper
11
+
12
+ CPACKET_NAME = [0x31]
13
+
14
+ attr_accessor :zone, :name
15
+
16
+ # Create a TimeName instance.
17
+ #
18
+ # @param zone [Integer] Time zone number (1 or 2).
19
+ # @param name [String] Name of time zone (3 chars max)
20
+ # @return [TimeName] TimeName instance.
21
+ def initialize(zone:, name:)
22
+ @zone = zone
23
+ @name = name
24
+ end
25
+
26
+ # Compile packets for a time name.
27
+ #
28
+ # @return [Array<Array<Integer>>] Two-dimensional array of integers that represent bytes.
29
+ def packets
30
+ [
31
+ [
32
+ CPACKET_NAME,
33
+ zone,
34
+ name_characters
35
+ ].flatten
36
+ ]
37
+ end
38
+
39
+ private
40
+
41
+ def name_characters
42
+ chars_for(name, length: 3, pad: true)
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "timex_datalink_client/helpers/char_encoders"
4
+ require "timex_datalink_client/helpers/crc_packets_wrapper"
5
+
6
+ class TimexDatalinkClient
7
+ class Protocol9
8
+ class Timer
9
+ include Helpers::CharEncoders
10
+ prepend Helpers::CrcPacketsWrapper
11
+
12
+ CPACKET_TIMER = [0x43]
13
+
14
+ attr_accessor :number, :label, :time, :action_at_end
15
+
16
+ # Create a Timer instance.
17
+ #
18
+ # @param number [Integer] Entry number for timer.
19
+ # @param label [String] Label for timer.
20
+ # @param time [Time] Time of timer.
21
+ # @param action_at_end [Integer] Action at end of timer.
22
+ # @return [Timer] Timer instance.
23
+ def initialize(number:, label:, time:, action_at_end:)
24
+ @number = number
25
+ @label = label
26
+ @time = time
27
+ @action_at_end = action_at_end
28
+ end
29
+
30
+ # Compile packets for a timer.
31
+ #
32
+ # @return [Array<Array<Integer>>] Two-dimensional array of integers that represent bytes.
33
+ def packets
34
+ [
35
+ [
36
+ CPACKET_TIMER,
37
+ number,
38
+ time.hour,
39
+ time.min,
40
+ time.sec,
41
+ action_at_end,
42
+ label_characters
43
+ ].flatten
44
+ ]
45
+ end
46
+
47
+ private
48
+
49
+ def label_characters
50
+ chars_for(label, length: 8, pad: true)
51
+ end
52
+ end
53
+ end
54
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class TimexDatalinkClient
4
- VERSION = "0.5.0"
4
+ VERSION = "0.6.0"
5
5
  end
@@ -3,13 +3,12 @@
3
3
  require "timex_datalink_client/version"
4
4
  require "timex_datalink_client/notebook_adapter"
5
5
 
6
- require "timex_datalink_client/eeprom/anniversary"
7
- require "timex_datalink_client/eeprom/appointment"
8
- require "timex_datalink_client/eeprom/list"
9
- require "timex_datalink_client/eeprom/phone_number"
10
-
11
6
  require "timex_datalink_client/protocol_1/alarm"
12
7
  require "timex_datalink_client/protocol_1/eeprom"
8
+ require "timex_datalink_client/protocol_1/eeprom/anniversary"
9
+ require "timex_datalink_client/protocol_1/eeprom/appointment"
10
+ require "timex_datalink_client/protocol_1/eeprom/list"
11
+ require "timex_datalink_client/protocol_1/eeprom/phone_number"
13
12
  require "timex_datalink_client/protocol_1/end"
14
13
  require "timex_datalink_client/protocol_1/start"
15
14
  require "timex_datalink_client/protocol_1/sync"
@@ -18,6 +17,10 @@ require "timex_datalink_client/protocol_1/time_name"
18
17
 
19
18
  require "timex_datalink_client/protocol_3/alarm"
20
19
  require "timex_datalink_client/protocol_3/eeprom"
20
+ require "timex_datalink_client/protocol_3/eeprom/anniversary"
21
+ require "timex_datalink_client/protocol_3/eeprom/appointment"
22
+ require "timex_datalink_client/protocol_3/eeprom/list"
23
+ require "timex_datalink_client/protocol_3/eeprom/phone_number"
21
24
  require "timex_datalink_client/protocol_3/end"
22
25
  require "timex_datalink_client/protocol_3/sound_options"
23
26
  require "timex_datalink_client/protocol_3/sound_theme"
@@ -26,15 +29,29 @@ require "timex_datalink_client/protocol_3/sync"
26
29
  require "timex_datalink_client/protocol_3/time"
27
30
  require "timex_datalink_client/protocol_3/wrist_app"
28
31
 
32
+ require "timex_datalink_client/protocol_9/alarm"
33
+ require "timex_datalink_client/protocol_9/eeprom"
34
+ require "timex_datalink_client/protocol_9/eeprom/chrono"
35
+ require "timex_datalink_client/protocol_9/eeprom/phone_number"
36
+ require "timex_datalink_client/protocol_9/end"
37
+ require "timex_datalink_client/protocol_9/sound_options"
38
+ require "timex_datalink_client/protocol_9/start"
39
+ require "timex_datalink_client/protocol_9/sync"
40
+ require "timex_datalink_client/protocol_9/time"
41
+ require "timex_datalink_client/protocol_9/time_name"
42
+ require "timex_datalink_client/protocol_9/timer"
43
+
29
44
  class TimexDatalinkClient
30
45
  attr_accessor :serial_device, :models, :byte_sleep, :packet_sleep, :verbose
31
46
 
32
47
  # Create a TimexDatalinkClient instance.
33
48
  #
34
49
  # @param serial_device [String] Path to serial device.
35
- # @param models [Array<Protocol3::Alarm, Protocol3::Eeprom, Protocol3::End, Protocol3::SoundOptions,
36
- # Protocol3::SoundTheme, Protocol3::Start, Protocol3::Sync, Protocol3::Time, Protocol3::WristApp>] Models to compile
37
- # data for.
50
+ # @param models [Array<Protocol1::Sync, Protocol1::Start, Protocol1::Time, Protocol1::TimeName, Protocol1::Alarm,
51
+ # Protocol1::Eeprom, Protocol1::End, Protocol3::Sync, Protocol3::Start, Protocol3::Time, Protocol3::Alarm,
52
+ # Protocol3::Eeprom, Protocol3::SoundTheme, Protocol3::SoundOptions, Protocol3::WristApp, Protocol3::End,
53
+ # Protocol9::Sync, Protocol9::Start, Protocol9::Time, Protocol9::TimeName, Protocol9::Timer, Protocol9::Alarm,
54
+ # Protocol9::Eeprom, Protocol9::SoundOptions, Protocol9::End>] Models to compile data for.
38
55
  # @param byte_sleep [Integer, nil] Time to sleep after sending byte.
39
56
  # @param packet_sleep [Integer, nil] Time to sleep after sending packet of bytes.
40
57
  # @param verbose [Boolean] Write verbose output to console.
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.5.0
4
+ version: 0.6.0
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-12 00:00:00.000000000 Z
11
+ date: 2022-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: crc
@@ -87,11 +87,6 @@ extensions: []
87
87
  extra_rdoc_files: []
88
88
  files:
89
89
  - lib/timex_datalink_client.rb
90
- - lib/timex_datalink_client/eeprom/anniversary.rb
91
- - lib/timex_datalink_client/eeprom/appointment.rb
92
- - lib/timex_datalink_client/eeprom/list.rb
93
- - lib/timex_datalink_client/eeprom/phone_number.rb
94
- - lib/timex_datalink_client/end.rb
95
90
  - lib/timex_datalink_client/helpers/char_encoders.rb
96
91
  - lib/timex_datalink_client/helpers/cpacket_paginator.rb
97
92
  - lib/timex_datalink_client/helpers/crc_packets_wrapper.rb
@@ -99,6 +94,10 @@ files:
99
94
  - lib/timex_datalink_client/notebook_adapter.rb
100
95
  - lib/timex_datalink_client/protocol_1/alarm.rb
101
96
  - lib/timex_datalink_client/protocol_1/eeprom.rb
97
+ - lib/timex_datalink_client/protocol_1/eeprom/anniversary.rb
98
+ - lib/timex_datalink_client/protocol_1/eeprom/appointment.rb
99
+ - lib/timex_datalink_client/protocol_1/eeprom/list.rb
100
+ - lib/timex_datalink_client/protocol_1/eeprom/phone_number.rb
102
101
  - lib/timex_datalink_client/protocol_1/end.rb
103
102
  - lib/timex_datalink_client/protocol_1/start.rb
104
103
  - lib/timex_datalink_client/protocol_1/sync.rb
@@ -106,6 +105,10 @@ files:
106
105
  - lib/timex_datalink_client/protocol_1/time_name.rb
107
106
  - lib/timex_datalink_client/protocol_3/alarm.rb
108
107
  - lib/timex_datalink_client/protocol_3/eeprom.rb
108
+ - lib/timex_datalink_client/protocol_3/eeprom/anniversary.rb
109
+ - lib/timex_datalink_client/protocol_3/eeprom/appointment.rb
110
+ - lib/timex_datalink_client/protocol_3/eeprom/list.rb
111
+ - lib/timex_datalink_client/protocol_3/eeprom/phone_number.rb
109
112
  - lib/timex_datalink_client/protocol_3/end.rb
110
113
  - lib/timex_datalink_client/protocol_3/sound_options.rb
111
114
  - lib/timex_datalink_client/protocol_3/sound_theme.rb
@@ -113,9 +116,19 @@ files:
113
116
  - lib/timex_datalink_client/protocol_3/sync.rb
114
117
  - lib/timex_datalink_client/protocol_3/time.rb
115
118
  - lib/timex_datalink_client/protocol_3/wrist_app.rb
116
- - lib/timex_datalink_client/sync.rb
119
+ - lib/timex_datalink_client/protocol_9/alarm.rb
120
+ - lib/timex_datalink_client/protocol_9/eeprom.rb
121
+ - lib/timex_datalink_client/protocol_9/eeprom/chrono.rb
122
+ - lib/timex_datalink_client/protocol_9/eeprom/phone_number.rb
123
+ - lib/timex_datalink_client/protocol_9/end.rb
124
+ - lib/timex_datalink_client/protocol_9/sound_options.rb
125
+ - lib/timex_datalink_client/protocol_9/start.rb
126
+ - lib/timex_datalink_client/protocol_9/sync.rb
127
+ - lib/timex_datalink_client/protocol_9/time.rb
128
+ - lib/timex_datalink_client/protocol_9/time_name.rb
129
+ - lib/timex_datalink_client/protocol_9/timer.rb
117
130
  - lib/timex_datalink_client/version.rb
118
- homepage: https://github.com/synthead/timex_datalink_client/tree/v0.5.0
131
+ homepage: https://github.com/synthead/timex_datalink_client/tree/v0.6.0
119
132
  licenses:
120
133
  - MIT
121
134
  metadata: {}
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "timex_datalink_client/helpers/char_encoders"
4
- require "timex_datalink_client/helpers/length_packet_wrapper"
5
-
6
- class TimexDatalinkClient
7
- class Eeprom
8
- class Anniversary
9
- include Helpers::CharEncoders
10
- prepend Helpers::LengthPacketWrapper
11
-
12
- attr_accessor :time, :anniversary
13
-
14
- # Create an Anniversary instance.
15
- #
16
- # @param time [::Time] Time of anniversary.
17
- # @param anniversary [String] Anniversary text.
18
- # @return [Anniversary] Anniversary instance.
19
- def initialize(time:, anniversary:)
20
- @time = time
21
- @anniversary = anniversary
22
- end
23
-
24
- # Compile a packet for an anniversary.
25
- #
26
- # @return [Array<Integer>] Array of integers that represent bytes.
27
- def packet
28
- [
29
- time.month,
30
- time.day,
31
- anniversary_characters
32
- ].flatten
33
- end
34
-
35
- private
36
-
37
- def anniversary_characters
38
- eeprom_chars_for(anniversary)
39
- end
40
- end
41
- end
42
- end
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "timex_datalink_client/helpers/char_encoders"
4
- require "timex_datalink_client/helpers/length_packet_wrapper"
5
-
6
- class TimexDatalinkClient
7
- class Eeprom
8
- class Appointment
9
- include Helpers::CharEncoders
10
- prepend Helpers::LengthPacketWrapper
11
-
12
- attr_accessor :time, :message
13
-
14
- # Create an Appointment instance.
15
- #
16
- # @param time [::Time] Time of appointment.
17
- # @param message [String] Appointment text.
18
- # @return [Appointment] Appointment instance.
19
- def initialize(time:, message:)
20
- @time = time
21
- @message = message
22
- end
23
-
24
- # Compile a packet for an appointment.
25
- #
26
- # @return [Array<Integer>] Array of integers that represent bytes.
27
- def packet
28
- [
29
- time.month,
30
- time.day,
31
- time_15m,
32
- message_characters
33
- ].flatten
34
- end
35
-
36
- private
37
-
38
- def time_15m
39
- time.hour * 4 + time.min / 15
40
- end
41
-
42
- def message_characters
43
- eeprom_chars_for(message)
44
- end
45
- end
46
- end
47
- end