Class Device
java.lang.Object
de.justofplay.xled.Device
Represents a Twinkly device and provides methods to interact with it via the Twinkly API.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Gets the current brightness value.int
getColor()
Gets the current LED color as a raw HTTP response.Gets device information (gestalt) as a JSON string.Gets the firmware version of the device.int
int
int
getHwId()
getIp()
int
Gets the blue component of the current LED color.int
Gets the green component of the current LED color.int
Gets the red component of the current LED color.int
getLogin()
getMac()
int
int
float
getMode()
Gets the current operating mode of the LEDs.int
int
int
Gets the current saturation value.long
getUuid()
int
login()
Performs login to the device and returns the raw HTTP response.logout()
Logs out from the device.setBrightness
(int brightness) Sets the brightness of the LEDs.setColor
(int red, int green, int blue) Sets the LED color using RGB values.setColorHSV
(int hue, int saturation, int value) Sets the LED color using HSV color space.setCurrentMovie
(int movieId) Sets the current movie by its ID.setDeviceName
(String deviceName) void
Sets the device IP address.Sets the operating mode of the LEDs.setSaturation
(int saturation) Sets the saturation of the LEDs.verify()
Verifies the authentication token with the device.
-
Constructor Details
-
Device
Constructs a Device object and initializes device info by logging in and querying the device.- Parameters:
ip
- The IP address of the Twinkly device.
-
-
Method Details
-
getProductName
- Returns:
- The product name of the device.
-
getHardwareVersion
public int getHardwareVersion()- Returns:
- The hardware version.
-
getBytesPerLed
public int getBytesPerLed()- Returns:
- The number of bytes per LED.
-
getHwId
- Returns:
- The hardware ID.
-
getFlashSize
public int getFlashSize()- Returns:
- The flash size.
-
getLedType
public int getLedType()- Returns:
- The LED type.
-
getProductCode
- Returns:
- The product code.
-
getFwFamily
- Returns:
- The firmware family.
-
getDeviceName
- Returns:
- The device name.
-
getUptime
public long getUptime()- Returns:
- The uptime in seconds.
-
getMac
- Returns:
- The MAC address.
-
getUuid
- Returns:
- The UUID.
-
getMaxSupportedLeds
public int getMaxSupportedLeds()- Returns:
- The maximum supported number of LEDs.
-
getNumberOfLed
public int getNumberOfLed()- Returns:
- The number of LEDs.
-
getLedProfile
- Returns:
- The LED profile.
-
getFrameRate
public int getFrameRate()- Returns:
- The frame rate.
-
getMeasuredFrameRate
public float getMeasuredFrameRate()- Returns:
- The measured frame rate.
-
getMovieCapacity
public int getMovieCapacity()- Returns:
- The movie capacity.
-
getMaxMovies
public int getMaxMovies()- Returns:
- The maximum number of movies.
-
getWireType
public int getWireType()- Returns:
- The wire type.
-
getCopyright
- Returns:
- The copyright string.
-
getLogin
- Returns:
- The Login object containing authentication info.
-
getIp
- Returns:
- The device IP address.
-
setIp
-
login
Performs login to the device and returns the raw HTTP response.- Returns:
- The HTTP response as a string.
-
setDeviceName
-
getDeviceInfo
Gets device information (gestalt) as a JSON string.- Returns:
- The JSON body as a string.
-
getFirmwareVersion
Gets the firmware version of the device.- Returns:
- The firmware version as a string.
-
logout
-
setBrightness
Sets the brightness of the LEDs.- Parameters:
brightness
- Brightness value (0..100)- Returns:
- The HTTP response as a string.
-
getBrightness
public int getBrightness()Gets the current brightness value.- Returns:
- The brightness value (0..100)
-
setColor
Sets the LED color using RGB values.- Parameters:
red
- Red component (0..255)green
- Green component (0..255)blue
- Blue component (0..255)- Returns:
- The HTTP response as a string.
-
setColorHSV
Sets the LED color using HSV color space.- Parameters:
hue
- Hue component (0..359)saturation
- Saturation component (0..255)value
- Value/Brightness component (0..255)- Returns:
- HTTP response as String
-
getColor
Gets the current LED color as a raw HTTP response.- Returns:
- The HTTP response as a string.
-
getLedRed
public int getLedRed()Gets the red component of the current LED color.- Returns:
- The red value (0..255)
-
getLedGreen
public int getLedGreen()Gets the green component of the current LED color.- Returns:
- The green value (0..255)
-
getLedBlue
public int getLedBlue()Gets the blue component of the current LED color.- Returns:
- The blue value (0..255)
-
setSaturation
Sets the saturation of the LEDs.- Parameters:
saturation
- Saturation value (0..255)- Returns:
- The HTTP response as a string.
-
getSaturation
public int getSaturation()Gets the current saturation value.- Returns:
- The saturation value (0..255)
-
setMode
-
getMode
-
setCurrentMovie
Sets the current movie by its ID.- Parameters:
movieId
- The movie ID.- Returns:
- The HTTP response as a string.
-
verify
Verifies the authentication token with the device.- Returns:
- The HTTP response as a string.
-