Description
Hi,
Following @gerph suggestion, I managed to get, and test most commands (as far as I know, only "add-file" is missing), I can't implement this in code for the library, but I can post what I know, and test if you implement it.
Based on my tests, I think the way their app (UsbMonitorL) works is something like this:
1- Gather the selected PC info.
2- Render a full image in BBGGRRAA format.
2a- Play the Video (if one was set as a background).
3- Send the rendered image using a "Full_Image" command.
Then loop the following:
4- Gather PC info again.
5- Render another full image.
6- Compare it with the current image, then generate the changed-pixels message.
7- Send the changed-pixels message using an "Update_Image" command.
8- Apply the changes to the image stored in the app so it can be synced with the monitor.
General Commands:
-
Get the device name/type and firmware (and maybe initialize):
01 ef 69 00 00 00 01 00 00 00 c5 d3
-
Set brightness, L=1-255:
7b ef 69 00 00 00 01 00 00 00 (L)
-
Set options, M=StartMode(1=Default, 2=PlayImage, 3=PlayVideo), F=Album-Flip 180 (1=Enable), S=SleepAfter in minutes (0=Disabled, app range 1-10):
7d ef 69 00 00 00 05 00 00 00 2d (M) 00 (F) (S)
-
TurnOff monitor (it will change it's port number):
83 ef 69 00 00 00 01
-
Restart monitor:
84 ef 69 00 00 00 01
Storage Commands:
-
Query Internal/SDCard storage usage, the reply is (InternalTotal-InternalUsed-InternalFree-SDTotal-SDUsed-SDFree):
64 ef 69 00 00 00 01
-
List Images/Videos in Internal Storage (the folder structure is already created), the reply is a list of files (result:dir:file:f1.ext/f2.ext/fN+.ext/):
65 ef 69 00 00 00 0a 00 00 00 2f 72 6f 6f 74 2f 69 6d 67 2f
65 ef 69 00 00 00 0c 00 00 00 2f 72 6f 6f 74 2f 76 69 64 65 6f 2f
-
List Images/Videos in SD Card:
65 ef 69 00 00 00 10 00 00 00 2f 6d 6e 74 2f 53 44 43 41 52 44 2f 69 6d 67 2f
65 ef 69 00 00 00 12 00 00 00 2f 6d 6e 74 2f 53 44 43 41 52 44 2f 76 69 64 65 6f 2f
-
Get a video file size P=Path, the reply is the size in bytes:
6e ef 69 00 00 00 13 00 00 00 (P)
-
Delete a video file, P=Path:
66 ef 69 00 00 00 14 00 00 00 (P)
Media Commands:
-
Play Video, P=Path, the reply is (play_video_success):
78 ef 69 00 00 00 13 00 00 00 (P)
-
Stop Video:
79 ef 69 00 00 00 01
-
Display a full image (for an image background):
c8 ef 69 00 17 70
-
Display an initial full image overlay (for a video background):
ca ef 69 00 17 70
-
Display a changed-pixels image (for an image background), S=Image-message bytes count (2bytes), N=Serial number of the image starting from 0 (4bytes):
cc ef 69 00 00 (S) 00 00 00 (N)
-
Display a changed-pixels image (for a video background), S=Image-message bytes count (2bytes), N=Serial number of the update starting from 0 (4bytes), V=visible-pixels info bytes count (4bytes):
cc ef 69 00 00 (S) 00 00 00 (N) 00 00 (V)
-
Query monitor render status, reply is (needReSend:0|renderCnt:X), "needReSend" will be 1 if a changed-pixels message was missed, and "renderCnt" will increase with each frame rendered by the monitor it self:
cf ef 69 00 00 00 01
Image Messages (for an image background):
-
Full-Image message:
Basically, list all the pixels in BBGGRRAA hex format (e.g blue: FF0000FF) -
Changed-pixels message:
S(6bytes) C(4bytes) P(6bytes per pixel), where:
S=starting pixel position
C=Count, how many pixels
P=PixelColors in BBGGRR format
There is no X and Y, so the (S) value must be calculated (S = ((X * 800) + Y), e.g. to display 3 White pixels starting at X=20, Y=30:
003E9E 0003 ffffff ffffff ffffff
If it's only a single pixel, then the count variable (C) is omitted, and the position variable's (S) first hex digit is set to "8", e.g. to display a single White pixel at X=20, Y=30:
803E9E ffffff
Image Messages (for a video background):
- Full-Image message:
Same as the Image-background, but an extra command is needed to define the visible pixels, V=visible-pixels-info bytes count (4bytes):
d0 ef 69 00 00 (V)
As for the visible-pixels-info itself, it's the same as the changed-pixels message, but without the PixelColors variable (P), then it needs to end with "00ef69", e.g. to make only 3 pixels visible starting at X=20, Y=30:
003E9E 0003 00ef69
- Changed-pixels message:
It differ from the Image-background version in two ways:
1- Just like the Full-Image, the visible pixels needs to be appended to the message
2- The Alpha channel is somehow added to the pixel colors (BBGGRR) value, but I don't know how exactly, my guess from my tests is that the Alpha channel hex digits replaces the second hex digit of Blue and Green channels.
Note that any pixel not defined in the "visible-pixels-info" will not be shown, regardless of its transparency, and any pixel added at any point can be set to visible/hidden at any changed-pixels message.
In other words, not marking a pixel as visible, does not delete it, just hides it until set to visible again by a changed-pixels message.
Notes:
- The app always starts with the "Get_Device" command, might be used to determine the supported commands, or it could also functions as an initialize command.
- There are commands that the app sends but don't seem to do anything (I can skip them with no visible problems).
- All messages must be 250 bytes of size, or multiple of it.
- All commands must be 250 bytes by themselves, so they must be padded without counting other messages within them.
- Every 250th byte is unused, so an extra byte must added.
- Every reply from the monitor (except for two commands, "Get_Device" and "query storage usage") is padded to 1024 bytes.
- The amount of transparent pixels will affect the frame-rate of the video background.
- Some commands can be truncated and still work, but I opted to list them as the app sent them.