Lovebox-client
A little client allowing you to send picture to a lovebox
Example
import { LoveBoxClient } from 'lovebox-client';
const client = new LoveBoxClient({
email: 'foo@bar.com',
password: 'myPassword'
});
await client.login();
const me = await client.getMe();
const boxes = await client.listBoxes();
await client.sendPicture({
data: Buffer.from('....'),
contentType: 'image/png'
});
const boxWithColor = boxes.find(b => b.hasColor);
const boxWithoutColor = boxes.find(b => !b.hasColor);
if(boxWithColor) {
await client.sendPicture({
picture: 'data:image/png;base64,iVBORw0KGgoAAAANSUh.....',
boxId: boxWithColor,
senderDeviceId: me.device._id
}, boxWithColor, me.device._id);
}
if(boxWithoutColor) {
const bytes = Buffer.from([255,255,255 ,'...'])
await client.sendOLEDPicture(
{
bytes,
boxId: boxWithColor,
senderDeviceId: me.device._id
});
}
OLED picture
When sending oled pictures, you need to pass an array of 1024
bytes .
This bytes will be divided in 64
rows per 128
columns,
Each row is divided by 8 bits, 1 = light off / 0 = light on (common anode)
you can use the editor here to generate an example picture
Sending gif
sending gif is very limited .
original gif are 3 frames only .
I've tested bigger ones, and sometimes the lovebox can't read it (freeze on first frame, need reboot) / or totally crash an need a factory reset.
await client.sendPicture({
picture: 'data:image/gif;base64,iVBORw0KGgoAAAANSUh.....',
frames: [
'data:image/png;base64,iVBORw0KGgoAAAANSUh.....',
'data:image/png;base64,iVBORw0KGgoAAAANSUh.....'
],
boxId: boxWithColor,
senderDeviceId: me.device._id
}, boxWithColor, me.device._id);