v1.3.0.0
GHUBDevice

Description

Instances of the GHUBDevice class are used to track detected GHUB devices.

A new one is created for each device which reports a battery status.

Public Member Functions

 setActive (active)
 
 resetBatteryData (withUpdate=false)
 
 createStates ()
 
 updateBatteryStates ()
 
 updateBatteryStateImage (imgName, synchronous=_data.aboutToQuit)
 
 updateImageState (img)
 

Member Function Documentation

◆ setActive()

setActive (   active)

Sets the active state of this device.

Updates TP states as needed. If active, subscribes to GHUB battery updates and requests immediate status. If inactive, also updates the battery icon for this device with the default image (if images are enabled).

◆ resetBatteryData()

resetBatteryData (   withUpdate = false)

Resets battery data to default "unknown" values and optionally sends TP state updates for this device.

◆ createStates()

createStates ( )

Creates all TP States for this device.

◆ updateBatteryStates()

updateBatteryStates ( )

Sends TP battery state updates for this device.

The states should already have been created before this.

◆ updateBatteryStateImage()

updateBatteryStateImage (   imgName,
  synchronous = _data.aboutToQuit 
)

Sends a TP state update for this device with image data read from imgName.

The image name is first compared to the last image sent for this device, and the update is skipped if they match. Otherwise the device's last sent image name is set to the new one from imgName and an update is sent. Image name is qualified into a full name & path using ImagesPath, ImagePrefix and ImageSuffix settings. Reads and sends image data asynchronously by default, unless synchronous is to to true or the _data.aboutToQuit flag is true.

◆ updateImageState()

updateImageState (   img)
Parameters
img{ArrayBuffer}