Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include "MicroBit.h"
  2.  
  3. MicroBit    uBit;
  4.  
  5. int main()
  6. {
  7.     uBit.init();
  8.  
  9.     KeyValuePair* firstTime = uBit.storage.get("boot");
  10.  
  11.     int stored;
  12.  
  13.     if(firstTime == NULL)
  14.     {
  15.         //this is the first boot after a flash. Store a value!
  16.         stored = 1;
  17.         uBit.storage.put("boot", (uint8_t *)&stored, sizeof(int));
  18.         uBit.display.scroll("Stored!");
  19.     }
  20.     else
  21.     {
  22.         //this is not the first boot, scroll our stored value.
  23.         memcpy(&stored, firstTime->value, sizeof(int));
  24.         delete firstTime;
  25.         uBit.display.scroll(stored);
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement