I’m trying to cache a splash screen (from WIF file) on my Vanessa so you can display contact information (with QR code) by pressing a button. Ideally, I’d like to store the splash screen on the device, so that it’s available even when the Imp looses connectivity.
So I added QRCodeImg and QRCodeImgInv to my ePaper class, setting them both equal to blob(BYTESPERSCREEN). I then load the normal and inverted splash screen from the Agent (via an HTTP request where I push the binary file). For testing purposes, I have a bit of Agent code (which won’t work if I lose connectivity, but that’s a different project) that detects a button press and initiates the splash screen display process. So far, so good.
Then I got greedy and tried to cache the last display image (and its inverse) so I could flip back and forth directly from the Vanessa. That was unfortunate; as soon as Vanessa allocated the memory for the four image buffers, she started flashing a red light and rebooting constantly.
I figured I was out of memory, so I removed the two normal image buffers and added imp.getmemoryfree() when loading the splash screen. When the Vanessa reboots, I get:
2014-07-25 09:44:21 UTC-5 [Device] Device Started, free memory: 28600
Fine and dandy! But when I load the splash screen (and its inverse), I get:
2014-07-25 10:38:36 UTC-5 [Agent] Agent got new HTTP Request
2014-07-25 10:38:36 UTC-5 [Agent] Got new QR Code data, len 5812
2014-07-25 10:38:36 UTC-5 [Agent] Unpacking WIF Image, Height = 176 px, Width = 264 px
2014-07-25 10:38:36 UTC-5 [Agent] Done Unpacking WIF File.
2014-07-25 10:38:37 UTC-5 [Device] Loaded QR Code
2014-07-25 10:38:37 UTC-5 [Device] QR Code, free memory: 29456
2014-07-25 10:38:37 UTC-5 [Device] Loaded inverted QR code
2014-07-25 10:38:37 UTC-5 [Device] Inverted QR Code, free memory: 29456
Is this discrepancy perhaps a result of some internal memory defrag/garbage collection/whatever? More generally, should I not attempt to cache WIF images on the device?
As a peripheral (no pun intended) matter: why is it necessary to send the inverse of an image before sending the normal image to the ePaper display? I’d certainly like to eliminate that QRCodeImgInv blob from my ePaper class.