Class: TimexDatalinkClient::Protocol4::SoundOptions

Inherits:
Object
  • Object
show all
Includes:
Helpers::CrcPacketsWrapper
Defined in:
lib/timex_datalink_client/protocol_4/sound_options.rb

Constant Summary collapse

CPACKET_BEEPS =
[0x71]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hourly_chime:, button_beep:) ⇒ SoundOptions

Create a SoundOptions instance.

Parameters:

  • hourly_chime (Boolean)

    Toggle hourly chime sounds.

  • button_beep (Boolean)

    Toggle button beep sounds.



19
20
21
22
# File 'lib/timex_datalink_client/protocol_4/sound_options.rb', line 19

def initialize(hourly_chime:, button_beep:)
  @hourly_chime = hourly_chime
  @button_beep = button_beep
end

Instance Attribute Details

#button_beepObject

Returns the value of attribute button_beep.



12
13
14
# File 'lib/timex_datalink_client/protocol_4/sound_options.rb', line 12

def button_beep
  @button_beep
end

#hourly_chimeObject

Returns the value of attribute hourly_chime.



12
13
14
# File 'lib/timex_datalink_client/protocol_4/sound_options.rb', line 12

def hourly_chime
  @hourly_chime
end

Instance Method Details

#button_beep_integerObject



37
38
39
# File 'lib/timex_datalink_client/protocol_4/sound_options.rb', line 37

def button_beep_integer
  button_beep ? 1 : 0
end

#hourly_chime_integerObject



33
34
35
# File 'lib/timex_datalink_client/protocol_4/sound_options.rb', line 33

def hourly_chime_integer
  hourly_chime ? 1 : 0
end

#packetsArray<Array<Integer>>

Compile packets for sound options.

Returns:

  • (Array<Array<Integer>>)

    Two-dimensional array of integers that represent bytes.



27
28
29
30
31
# File 'lib/timex_datalink_client/protocol_4/sound_options.rb', line 27

def packets
  [
    CPACKET_BEEPS + [hourly_chime_integer, button_beep_integer]
  ]
end