Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Fetching an image works on IDE, but don't on watch (SDK 6.1)

Hi! I'm trying to put a png image on watch, but I can't... on Fitbit OS Simulator works like a charm, but not on watch...

What I'm doing wrong?

 

This is my app/index.js code:

 

inbox.onnewfile = () => {
let fileName;
do {
fileName = inbox.nextFile();
if (fileName) {
document.getElementById("coin").image = `/private/data/${fileName}`;
}
} while (fileName);
};
Best Answer
0 Votes
12 REPLIES 12

My watch is a Versa 3

Best Answer

If it works on sim but not watch, a common cause is because the image is the wrong size. The watch doesn't like resizing images.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

I tried to print it at full size (300x300) and I got the same behavior 😞

Best Answer
0 Votes

I put a 300x300 image resized to 100x100 directly from resources and I see that image, but when runs this line 

 

document.getElementById("coin").image = `/private/data/${fileName}`;

 

image become invisible...

maybe how I put the image have a problem...

Best Answer
0 Votes

Try .href.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

.image and .href has the same behavior

Best Answer
0 Votes

This is mi companion code:

 

fetch(coinURL)
.then(response => response.arrayBuffer())
.then(buffer => outbox.enqueue(destFilename, buffer))
.then(fileTransfer => {
console.log(`Enqueued ${fileTransfer.name}`);
});

 

Best Answer
0 Votes

Well... using txi conversion it's working, but if I load the same .png directly it load... why I can't pass the file?

 

fetch(coinURL)
.then(response => response.arrayBuffer())
.then(buffer => Image.from(buffer, "image/png"))
.then(image =>
image.export("image/vnd.fitbit.txi", {
background: "#FFFFFF"
})
)
.then(buffer => outbox.enqueue(destFilename, buffer))
.then(fileTransfer => {
console.log(`Enqueued ${fileTransfer.name}`);
}); 

 

Best Answer
0 Votes

The watch doesn't support PNG. It can only display TXI and (some) JPG.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

But I can load PNG from resources 😕

Best Answer
0 Votes

PNG included in the source are converted to TXI as part of the build process.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

SDK could make the same thing if I try to set an image from an url response 😞

Best Answer
0 Votes