Pebble Run
I’ve been working with my co-worker Mike Walton to build out a proof of concept pebble watch app for one of our fast food clients. Our goal is to make it so users can check out at any location using only a pebble watch. A companion iOS app allows users to enter gift card codes and then sync those on to the pebble watch app in the form of a small QRC image which is compatible with our clients existing POS system. Typically most other pebble watch apps that use QR codes communicate back to the iOS app to retrieve the image, but inconsistent pairing and the delay of loading in files via Bluetooth often leads the user to reach for their wallet instead.
We’ve been experimented with storing the QRC locally on the device itself, but the problem we ran into right away is that Pebble apps are running under very limited resources.
We initially found that the storage restriction for saving data was limited to files no larger than 256bytes, which was insufficient to actually store a fullscreen QR code image on the pebble. By breaking the image up into smaller byte arrays and saving out separate files we were able to create a means by which we could save and load local images without the need to communicate back to the companion app. This is a drastic improvement in the usability of the watch face and it’s something I’ve been using personally for more than a few weeks with great success.
static void save_qr_image() { uint32_t dataSize = sizeof(imageData); uint32_t i = 0; uint32_t j = 0; //split image data into chunks less than 256bytes and save with numerically ordered keys while(i < dataSize) { uint8_t byte_array[255]; memcpy(byte_array, imageData +i, 255); persist_write_data(j,byte_array,sizeof(byte_array)); j++; i += 255; } }
static void load_local_image(void *data) { uint32_t t = 1; uint32_t k = 0; //read image data back in with numerically ordered keys while (t ==1) { if (persist_exists(k)) { uint8_t test_byteArray[255]; persist_read_data(k, test_byteArray, sizeof(test_byteArray)); memcpy(imageData + k*255, test_byteArray, sizeof(test_byteArray)); k++; } else { t = 0; } } if(k > 2) { //at least there's a something in there.. display_qr_image(); } }