Warning Older Docs! - You are viewing documentation for a previous released version of RhoMobile Suite.

Notification.Led

The LED API is a child of the Notification API and allows access to the LEDs on your device

Enabling the API

This API is part of the coreapi extension that is included automatically.

extensions: ["coreapi"]

JavaScript Usage

Be sure to review the JavaScript API Usage guide for important information about using this API in JavaScript

Ruby Usage

Be sure to review the Ruby API Usage guide for important information about using this API in Ruby

Methods

extinguish()

Called on an LED object returned from the enumerate method, the specified LED will be extinguished.

Synchronous Return:

  • Void

Method Access:

  • Instance Method: This method can be accessed via an instance object of this class:
    • myObject.extinguish()

flash(HASH propertyMap)

Called on an LED object returned from the enumerate method, the specified LED will be flashed.

Parameters

  • propertyMap : HASH

    The properties associated with the LED flash.

    • onDuration : Integer Default: 1000

      When flashing, the LED will remain on for this number of milliseconds

    • offDuration : Integer Default: 1000

      When flashing, the LED will remain off for this number of milliseconds

    • numberOfCycles : Integer Default: 1

      The LED will flash this number of times.

Synchronous Return:

  • Void

Method Access:

  • Instance Method: This method can be accessed via an instance object of this class:
    • myObject.flash(HASH propertyMap)

illuminate()

Called on an LED object returned from the enumerate method, the specified LED will be illuminated.

Synchronous Return:

  • Void

Method Access:

  • Instance Method: This method can be accessed via an instance object of this class:
    • myObject.illuminate()

Properties

name : STRING Read Only 1.0.0

Human readable name for the notification object, e.g. ‘Green LED’.

Property Access:

  • Instance: This property can be accessed via an instance object of this class:
    • myObject.name

Examples

Flash a specific LED

Enumerating the LEDs will return an array objects which will map to the real LEDs on the device, using these returned objects you can control the device LEDs

# ---------------
# controller.rb  
# ---------------
         
def choose_led
  # Obtain list of available leds on the device. 
  $leds = Rho::Notification::Led.enumerate
  render
end

def flash_led
  # receive an integer as parameter, which represents the number of the LED we wish to use
  led = $leds[@params["ledIndex"].to_i]
  led.numberOfCycles = 4
  led.flash({})
end


# ---------------
# choose_led.erb
# ---------------
<ul data-role="listview">
  <% $leds.each_with_index do |led, index| %>
    <li><a href="<%= url_for(:action => :flash_led, :query => {:ledIndex => index}) %>"><%= led.name %></li> 
  <% end %>
</ul>
                   
                 

Remarks

Underlying hardware

The LED API relies on Zebra drivers on Windows Mobile / CE and therefore will not work on non-Zebra platforms. Depending on your device configuration, not all LEDs reported by the API may exist physically on the device.