Class: TimexDatalinkClient::Protocol6::NightModeOptions

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

Constant Summary collapse

CPACKET_NIGHT_MODE =
0x72

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(night_mode_deactivate_hours: 8, indiglo_timeout_seconds: 4, night_mode_on_notification: false) ⇒ NightModeOptions

Create a NightModeOptions instance.

Parameters:

  • night_mode_deactivate_hours (Integer) (defaults to: 8)

    Automatically deactivate night mode after specified hours.

  • indiglo_timeout_seconds (Integer) (defaults to: 4)

    Turn Indiglo light off after specified seconds after each button push.

  • night_mode_on_notification (Boolean) (defaults to: false)

    Toggle activating night mode on any pager or alarm event.



31
32
33
34
35
# File 'lib/timex_datalink_client/protocol_6/night_mode_options.rb', line 31

def initialize(night_mode_deactivate_hours: 8, indiglo_timeout_seconds: 4, night_mode_on_notification: false)
  @night_mode_deactivate_hours = night_mode_deactivate_hours
  @indiglo_timeout_seconds = indiglo_timeout_seconds
  @night_mode_on_notification = night_mode_on_notification
end

Instance Attribute Details

#indiglo_timeout_secondsObject

Returns the value of attribute indiglo_timeout_seconds.



23
24
25
# File 'lib/timex_datalink_client/protocol_6/night_mode_options.rb', line 23

def indiglo_timeout_seconds
  @indiglo_timeout_seconds
end

#night_mode_deactivate_hoursObject

Returns the value of attribute night_mode_deactivate_hours.



23
24
25
# File 'lib/timex_datalink_client/protocol_6/night_mode_options.rb', line 23

def night_mode_deactivate_hours
  @night_mode_deactivate_hours
end

#night_mode_on_notificationObject

Returns the value of attribute night_mode_on_notification.



23
24
25
# File 'lib/timex_datalink_client/protocol_6/night_mode_options.rb', line 23

def night_mode_on_notification
  @night_mode_on_notification
end

Instance Method Details

#night_mode_on_notification_formattedObject



54
55
56
# File 'lib/timex_datalink_client/protocol_6/night_mode_options.rb', line 54

def night_mode_on_notification_formatted
  night_mode_on_notification ? 1 : 0
end

#packetsArray<Array<Integer>>

Compile packets for night mode options.

Returns:

  • (Array<Array<Integer>>)

    Two-dimensional array of integers that represent bytes.

Raises:

  • (ActiveModel::ValidationError)

    One or more model values are invalid.



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/timex_datalink_client/protocol_6/night_mode_options.rb', line 41

def packets
  validate!

  [
    [
      CPACKET_NIGHT_MODE,
      night_mode_on_notification_formatted,
      night_mode_deactivate_hours,
      indiglo_timeout_seconds
    ]
  ]
end