Struct divoom::PixooClient
source · [−]pub struct PixooClient { /* private fields */ }
Expand description
Pixoo device client
Once we have the IP address of the device, we can create the client and start to execute command directly:
use divoom::*;
let pixoo = PixooClient::new("192.168.0.123");
// let result = pixoo.get_current_channel().await?;
// println!("{:?}", result);
Implementations
sourceimpl PixooClient
impl PixooClient
sourcepub async fn select_channel(
&self,
channel_type: DivoomChannelType
) -> DivoomAPIResult<()>
pub async fn select_channel(
&self,
channel_type: DivoomChannelType
) -> DivoomAPIResult<()>
Select channel
Official doc: http://doc.divoom-gz.com/web/#/12?page_id=89
The channel is the top category of the display content.
sourcepub async fn get_current_channel(&self) -> DivoomAPIResult<DivoomChannelType>
pub async fn get_current_channel(&self) -> DivoomAPIResult<DivoomChannelType>
sourcepub async fn select_clock(&self, clock_id: i32) -> DivoomAPIResult<()>
pub async fn select_clock(&self, clock_id: i32) -> DivoomAPIResult<()>
sourcepub async fn get_selected_clock_info(
&self
) -> DivoomAPIResult<DivoomSelectedClockInfo>
pub async fn get_selected_clock_info(
&self
) -> DivoomAPIResult<DivoomSelectedClockInfo>
Get selected clock id
Official doc: http://doc.divoom-gz.com/web/#/12?page_id=239
Sample response:
{
"ClockId": 12,
"Brightness":100
}
sourcepub async fn select_cloud_channel(
&self,
channel_type: DivoomCloudChannelType
) -> DivoomAPIResult<()>
pub async fn select_cloud_channel(
&self,
channel_type: DivoomCloudChannelType
) -> DivoomAPIResult<()>
sourcepub async fn select_visualizer(
&self,
visializer_index: i32
) -> DivoomAPIResult<()>
pub async fn select_visualizer(
&self,
visializer_index: i32
) -> DivoomAPIResult<()>
sourcepub async fn select_custom_page(
&self,
custom_page_index: i32
) -> DivoomAPIResult<()>
pub async fn select_custom_page(
&self,
custom_page_index: i32
) -> DivoomAPIResult<()>
sourceimpl PixooClient
impl PixooClient
sourcepub async fn get_device_settings(
&self
) -> DivoomAPIResult<DivoomPixooDeviceSettings>
pub async fn get_device_settings(
&self
) -> DivoomAPIResult<DivoomPixooDeviceSettings>
Get all settings
Official doc: http://doc.divoom-gz.com/web/#/12?page_id=243
Sample response:
{
"error_code": 0,
"Brightness":100,
"RotationFlag":1,
"ClockTime":60,
"GalleryTime":60,
"SingleGalleyTime":5,
"PowerOnChannelId":1,
"GalleryShowTimeFlag":1,
"CurClockId":1,
"Time24Flag":1,
"TemperatureMode":1,
"GyrateAngle":1,
"MirrorFlag":1,
"LightSwitch":1
}
sourcepub async fn get_device_time(&self) -> DivoomAPIResult<u64>
pub async fn get_device_time(&self) -> DivoomAPIResult<u64>
Get device time
Official doc: http://doc.divoom-gz.com/web/#/12?page_id=337
Sample response:
{
"error_code": 0,
"UTCTime":1647200428,
"LocalTime":"2022-03-14 03:40:28"
}
sourcepub async fn set_device_brightness(&self, brightness: i32) -> DivoomAPIResult<()>
pub async fn set_device_brightness(&self, brightness: i32) -> DivoomAPIResult<()>
Set brightness
Official doc: http://doc.divoom-gz.com/web/#/12?page_id=196
sourcepub async fn set_device_time(&self, utc: u64) -> DivoomAPIResult<()>
pub async fn set_device_time(&self, utc: u64) -> DivoomAPIResult<()>
Set system time
Official doc: http://doc.divoom-gz.com/web/#/12?page_id=222
Sample request:
{
"Command":"Device/SetUTC",
"Utc": 1672416000
}
sourcepub async fn set_device_high_light_mode(
&self,
mode: DivoomDeviceHighLightMode
) -> DivoomAPIResult<()>
pub async fn set_device_high_light_mode(
&self,
mode: DivoomDeviceHighLightMode
) -> DivoomAPIResult<()>
Set high light mode
Official doc: http://doc.divoom-gz.com/web/#/12?page_id=342
Sample request:
{
"Command": "Device/SetHighLightMode",
"Mode": 0
}
sourcepub async fn set_device_hour_mode(
&self,
mode: DivoomDeviceHourMode
) -> DivoomAPIResult<()>
pub async fn set_device_hour_mode(
&self,
mode: DivoomDeviceHourMode
) -> DivoomAPIResult<()>
Set hour mode
Official doc: http://doc.divoom-gz.com/web/#/12?page_id=341
Sample request:
{
"Command": "Device/SetTime24Flag",
"Mode": 0
}
sourcepub async fn set_device_mirror_mode(
&self,
mode: DivoomDeviceMirrorMode
) -> DivoomAPIResult<()>
pub async fn set_device_mirror_mode(
&self,
mode: DivoomDeviceMirrorMode
) -> DivoomAPIResult<()>
Set mirror mode
Official doc: http://doc.divoom-gz.com/web/#/12?page_id=340
Sample request:
{
"Command": "Device/SetMirrorMode",
"Mode": 0
}
sourcepub async fn set_device_rotation_angle(
&self,
mode: DivoomDeviceRotationAngle
) -> DivoomAPIResult<()>
pub async fn set_device_rotation_angle(
&self,
mode: DivoomDeviceRotationAngle
) -> DivoomAPIResult<()>
Set rotation angle
Official doc: http://doc.divoom-gz.com/web/#/12?page_id=339
Sample request:
{
"Command": "Device/SetScreenRotationAngle",
"Mode": 0
}
sourcepub async fn set_device_screen_power_state(
&self,
power_state: DivoomDeviceScreenPowerState
) -> DivoomAPIResult<()>
pub async fn set_device_screen_power_state(
&self,
power_state: DivoomDeviceScreenPowerState
) -> DivoomAPIResult<()>
Set screen power state (on/off)
Official doc: http://doc.divoom-gz.com/web/#/12?page_id=223
Sample request:
{
"Command":"Channel/OnOffScreen",
"OnOff": 1
}
sourcepub async fn set_device_temperature_unit(
&self,
unit: DivoomDeviceTemperatureUnit
) -> DivoomAPIResult<()>
pub async fn set_device_temperature_unit(
&self,
unit: DivoomDeviceTemperatureUnit
) -> DivoomAPIResult<()>
Set temperature unit
Official doc: http://doc.divoom-gz.com/web/#/12?page_id=338
Sample request:
{
"Command":"Device/SetDisTempMode",
"Mode":0
}
sourcepub async fn set_device_time_zone(
&self,
time_zone: String
) -> DivoomAPIResult<()>
pub async fn set_device_time_zone(
&self,
time_zone: String
) -> DivoomAPIResult<()>
Set time zone
Official doc: http://doc.divoom-gz.com/web/#/12?page_id=221
Sample request:
{
"Command":"Sys/TimeZone",
"TimeZoneValue": "GMT-5"
}
sourcepub async fn set_device_weather_area(
&self,
longitude: String,
latitude: String
) -> DivoomAPIResult<()>
pub async fn set_device_weather_area(
&self,
longitude: String,
latitude: String
) -> DivoomAPIResult<()>
Set weather area
Official doc: http://doc.divoom-gz.com/web/#/12?page_id=220
Sample request:
{
"Command":"Sys/LogAndLat",
"Longitude": "30.29",
"Latitude":"20.58"
}
sourcepub async fn set_device_white_balance(
&self,
r: i32,
g: i32,
b: i32
) -> DivoomAPIResult<()>
pub async fn set_device_white_balance(
&self,
r: i32,
g: i32,
b: i32
) -> DivoomAPIResult<()>
Set white balance
Official doc: http://doc.divoom-gz.com/web/#/12?page_id=343
Sample request:
{
"Command":"Device/SetWhiteBalance",
"RValue":100,
"GValue":100,
"BValue":100
}
sourceimpl PixooClient
impl PixooClient
sourcepub async fn set_countdown_tool(
&self,
minute: i32,
second: i32,
action: DivoomToolCountdownAction
) -> DivoomAPIResult<()>
pub async fn set_countdown_tool(
&self,
minute: i32,
second: i32,
action: DivoomToolCountdownAction
) -> DivoomAPIResult<()>
Set countdown tool
Official doc: http://doc.divoom-gz.com/web/#/12?page_id=224
Sample request:
{
"Command":"Tools/SetTimer",
"Minute": 1,
"Second": 0,
"Status": 1
}
sourcepub async fn set_noise_tool(
&self,
action: DivoomToolNoiseAction
) -> DivoomAPIResult<()>
pub async fn set_noise_tool(
&self,
action: DivoomToolNoiseAction
) -> DivoomAPIResult<()>
Set noise tool
Official doc: http://doc.divoom-gz.com/web/#/12?page_id=227
Sample request:
{
"Command":"Tools/SetNoiseStatus",
"NoiseStatus": 1
}
sourcepub async fn set_scoreboard_tool(
&self,
blue_score: i32,
red_score: i32
) -> DivoomAPIResult<()>
pub async fn set_scoreboard_tool(
&self,
blue_score: i32,
red_score: i32
) -> DivoomAPIResult<()>
Set scroeboard tool
Official doc: http://doc.divoom-gz.com/web/#/12?page_id=226
Sample request:
{
"Command":"Tools/SetScoreBoard",
"BlueScore": 100,
"RedScore": 79
}
sourcepub async fn set_stopwatch_tool(
&self,
action: DivoomToolStopwatchAction
) -> DivoomAPIResult<()>
pub async fn set_stopwatch_tool(
&self,
action: DivoomToolStopwatchAction
) -> DivoomAPIResult<()>
Set stopwatch tool
Official doc: http://doc.divoom-gz.com/web/#/12?page_id=225
Sample request:
{
"Command":"Tools/SetStopWatch",
"Status": 1
}
sourceimpl PixooClient
impl PixooClient
sourcepub async fn play_gif_file(
&self,
file_type: DivoomFileAnimationSourceType,
file_name: String
) -> DivoomAPIResult<()>
pub async fn play_gif_file(
&self,
file_type: DivoomFileAnimationSourceType,
file_name: String
) -> DivoomAPIResult<()>
Play gif file
Play GIF file from specific location.
NOTE: this API onliy supports 16x16, 32x32 and 64x64 GIFs. If other format is specified, it could cause the device to crash and reboot.
Official doc: http://doc.divoom-gz.com/web/#/12?page_id=195
This API will generate requests like below:
{
"Command":"Device/PlayTFGif",
"FileType": 0,
"FileName":"divoom_gif/1.gif"
},
{
"Command":"Device/PlayTFGif",
"FileType": 1,
"FileName":"divoom_gif"
},
{
"Command":"Device/PlayTFGif",
"FileType": 2,
"FileName":"http://f.divoom-gz.com/64_64.gif"
}
sourcepub async fn get_next_animation_id(&self) -> DivoomAPIResult<i32>
pub async fn get_next_animation_id(&self) -> DivoomAPIResult<i32>
sourcepub async fn reset_next_animation_id(&self) -> DivoomAPIResult<()>
pub async fn reset_next_animation_id(&self) -> DivoomAPIResult<()>
sourcepub async fn send_gif_as_animation(
&self,
canvas_size: u32,
speed: Duration,
file_path: &str
) -> DivoomAPIResult<()>
pub async fn send_gif_as_animation(
&self,
canvas_size: u32,
speed: Duration,
file_path: &str
) -> DivoomAPIResult<()>
Send GIF to the device to play as an animation.
This API is different from play_gif_file
, which is provided by divoom device directly. This API will try to leverage the animation API,
create a new animation, load the gif files and draw all the frames into the animation, and send the to device to play.
The API play_gif_file
doesn’t seems to be very stable when the package is published, hence send_gif_as_animation
is more preferred
as of now.
sourcepub async fn send_image_animation(
&self,
animation: DivoomImageAnimation
) -> DivoomAPIResult<()>
pub async fn send_image_animation(
&self,
animation: DivoomImageAnimation
) -> DivoomAPIResult<()>
Send image animation
This API sends the image animation definitions to Pixoo devices and trigger it play.
To create an animation, the first request to draw the frame should always have with PicOffset
set to 0, because it creates the image, otherwise other request cannot go through correctly.
When using the API in our library, we will ask for the id
in the parameter, which maps to PicId
in the final request. Note that:
- This
id
should be the id that returned byget_next_animation_id
. - If
DIVOOM_IMAGE_ANIMATION_ID_AUTO
is used, we will automatically get the latest animation id and use it.
Official doc: http://doc.divoom-gz.com/web/#/12?page_id=93
This API will generate requests like below:
{
"Command":"Draw/SendHttpGif",
"PicNum":2,
"PicWidth":64,
"PicOffset":0,
"PicID":3,
"PicSpeed":100,
"PicData":"AAIpAAIp..."
}
sourcepub async fn send_image_animation_with_id(
&self,
id: i32,
animation: DivoomImageAnimation
) -> DivoomAPIResult<()>
pub async fn send_image_animation_with_id(
&self,
id: i32,
animation: DivoomImageAnimation
) -> DivoomAPIResult<()>
Send image animation
This API sends the image animation definitions to Pixoo devices and trigger it play.
To create an animation, the first request to draw the frame should always have with PicOffset
set to 0, because it creates the image, otherwise other request cannot go through correctly.
When using the API in our library, we will ask for the id
in the parameter, which maps to PicId
in the final request. Note that:
- This
id
should be the id that returned byget_next_animation_id
. - If
DIVOOM_IMAGE_ANIMATION_ID_AUTO
is used, we will automatically get the latest animation id and use it.
Official doc: http://doc.divoom-gz.com/web/#/12?page_id=93
This API will generate requests like below:
{
"Command":"Draw/SendHttpGif",
"PicNum":2,
"PicWidth":64,
"PicOffset":0,
"PicID":3,
"PicSpeed":100,
"PicData":"AAIpAAIp..."
}
sourcepub async fn send_text_animation(
&self,
animation: DivoomTextAnimation
) -> DivoomAPIResult<()>
pub async fn send_text_animation(
&self,
animation: DivoomTextAnimation
) -> DivoomAPIResult<()>
Send text animation
The text animation will only work when the device is in the drawing mode (showing image animation).
If we send text animation when device is showing other things such as clock, the text animation will simply be ignored.
Official doc: http://doc.divoom-gz.com/web/#/12?page_id=219
This API will generate requests like below:
{
"Command":"Draw/SendHttpText",
"TextId":4,
"x":0,
"y":40,
"dir":0,
"font":4,
"TextWidth":56,
"speed":10,
"TextString":"hello, Divoom",
"color":"#FFFF00",
"align":1
}
sourcepub async fn clear_all_text_area(&self) -> DivoomAPIResult<()>
pub async fn clear_all_text_area(&self) -> DivoomAPIResult<()>
sourcepub async fn play_buzzer(
&self,
play_total_time: i32,
active_time_in_cycle: i32,
off_time_in_cycle: i32
) -> DivoomAPIResult<()>
pub async fn play_buzzer(
&self,
play_total_time: i32,
active_time_in_cycle: i32,
off_time_in_cycle: i32
) -> DivoomAPIResult<()>
Play buzzer
Trigger buzzer to make some beeps sound:
NOTE: For Pixoo-64 device, every buzz is about 50ms long and the device cannot handle request <100ms very well. Hence:
- For active time longer than 100ms, it will play buzz in each cycle multiple times.
- If we set active time smaller than 50ms or off time smaller than 100ms, it might not buzz or off at all.
Official doc: http://doc.divoom-gz.com/web/#/12?page_id=347
This API will generate requests like below:
{
"Command":"Device/PlayTFGif",
"ActiveTimeInCycle": 500,
"OffTimeInCycle": 500,
"PlayTotalTime": 3000
}
sourceimpl PixooClient
impl PixooClient
sourcepub async fn execute_commands_from_url(
&self,
command_url: String
) -> DivoomAPIResult<()>
pub async fn execute_commands_from_url(
&self,
command_url: String
) -> DivoomAPIResult<()>
Execute URL from text file URL
Official doc: http://doc.divoom-gz.com/web/#/12?page_id=242
This API will generate requests like below:
{
"Command":"Draw/UseHTTPCommandSource",
"CommandUrl": "http://f.divoom-gz.com/all_command.txt"
}
sourcepub fn start_batch(&self) -> PixooCommandBuilder
pub fn start_batch(&self) -> PixooCommandBuilder
Batch mode
This function returns the command builder, which allows us to build multiple commands and execute them at once.
sourceimpl PixooClient
impl PixooClient
pub async fn send_raw_request(&self, request: String) -> DivoomAPIResult<String>
Auto Trait Implementations
impl !RefUnwindSafe for PixooClient
impl !Send for PixooClient
impl !Sync for PixooClient
impl Unpin for PixooClient
impl !UnwindSafe for PixooClient
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more