Class: TimexDatalinkClient::Protocol6::SoundScrollOptions

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations, Helpers::CrcPacketsWrapper
Defined in:
lib/timex_datalink_client/protocol_6/sound_scroll_options.rb

Constant Summary collapse

CPACKET_SOUND_SCROLL =
0x71

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hourly_chime: false, button_beep: false, scroll_speed: 1) ⇒ SoundScrollOptions

Create a SoundScrollOptions instance.

Parameters:

  • hourly_chime (Boolean) (defaults to: false)

    Toggle hourly chime.

  • button_beep (Boolean) (defaults to: false)

    Toggle button beep.

  • scroll_speed (Integer) (defaults to: 1)

    Message scroll speed (0 to 2).



26
27
28
29
30
# File 'lib/timex_datalink_client/protocol_6/sound_scroll_options.rb', line 26

def initialize(hourly_chime: false, button_beep: false, scroll_speed: 1)
  @hourly_chime = hourly_chime
  @button_beep = button_beep
  @scroll_speed = scroll_speed
end

Instance Attribute Details

#button_beepObject

Returns the value of attribute button_beep.



18
19
20
# File 'lib/timex_datalink_client/protocol_6/sound_scroll_options.rb', line 18

def button_beep
  @button_beep
end

#hourly_chimeObject

Returns the value of attribute hourly_chime.



18
19
20
# File 'lib/timex_datalink_client/protocol_6/sound_scroll_options.rb', line 18

def hourly_chime
  @hourly_chime
end

#scroll_speedObject

Returns the value of attribute scroll_speed.



18
19
20
# File 'lib/timex_datalink_client/protocol_6/sound_scroll_options.rb', line 18

def scroll_speed
  @scroll_speed
end

Instance Method Details

#button_beep_formattedObject



53
54
55
# File 'lib/timex_datalink_client/protocol_6/sound_scroll_options.rb', line 53

def button_beep_formatted
  button_beep ? 1 : 0
end

#hourly_chime_formattedObject



49
50
51
# File 'lib/timex_datalink_client/protocol_6/sound_scroll_options.rb', line 49

def hourly_chime_formatted
  hourly_chime ? 1 : 0
end

#packetsArray<Array<Integer>>

Compile packets for sound and scroll options.

Returns:

  • (Array<Array<Integer>>)

    Two-dimensional array of integers that represent bytes.

Raises:

  • (ActiveModel::ValidationError)

    One or more model values are invalid.



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/timex_datalink_client/protocol_6/sound_scroll_options.rb', line 36

def packets
  validate!

  [
    [
      CPACKET_SOUND_SCROLL,
      hourly_chime_formatted,
      button_beep_formatted,
      scroll_speed
    ]
  ]
end