Again with not knowing what number to use to call a given image.
I did what I did last time that seemed to work. Delete all the images under resources and loaded them in order. I want to call an image for a day by the returned value of now.getDay() which should be between 0 and 6. First tests, fail.
I loaded my images in from Sunday to Saturday again, originally in the CloudPebble editor it listed these images in the order I loaded them. Look down when a test failed and find -
No idea why the system decided to re-order them. I tried again and still no luck. So, I walked through the images by setting the day to 0-whatever to see what happened. Fails, and then images, but in the wrong order. Finally, I decided to take what I found and just live with it. This required a case statement to translate the value of now.getDay() to the number I needed to call up the proper image.
let dayCode = 0;
switch(day) {
case 0:
dayCode = 4;
break;
case 1:
dayCode = 6;
break;
case 2:
dayCode = 7;
break;
case 3:
dayCode = 1;
break;
case 4:
dayCode = 2;
break;
case 5:
dayCode = 3;
break;
case 6:
dayCode = 5;
break;
default:
dayCode = 1
}
Well isn’t that a mess. But, a mess that works…for now.
It doesn’t help that all through this the emulator run throws up these:
OK, there is at least visibility. I found when I was making a new version of this that if I mouse over the names of the images in the Resources window it gives you the identifier it was assigned.
Actually, no, that’s the identifier I assigned when uploading the image file. I was trying to see if that helped, but obviously it doesn’t. I identify an image as “1” but that doesn’t change what I have to put in the render options to call it up and display it so far as I can tell.
Seriously. I made image 1, told the code to render image 1, it did.
Did 2, 3, 4. The same.
Added image 5 and now I have to call image 2 to get image 1 and calling image 5 yields the image for 4.
const hours = 2;
let background = new Poco.PebbleBitmap(hours);
This is just really silly. In the Alloy/Javascript environment it doesn't look like I have any control over this.
Not sure how I managed to get another face such that I just needed to call the face by hour number 1-12. So far the only tool I have when this gets messed up somehow is to use a case statement. That's not bad, but I have at least one watch face example of how it ought to work.
Any suggestions?
Worth a try. Even if I’m doing something wrong they might be able to explain how to avoid it in the future.
I decided to try once more, so I deleted all the images I had loaded and loaded them again in order. Mostly correct, but still I need a case statement because two are still not the the order expected.