Search code examples
pebble-watchpebble-sdk

Not storing correct persist value


Having a problem where after reopening the app the i1-i5 values are all replaced with the user_cur_inv value. Cannot find why this is happening.

Link to the code: https://github.com/sleedham1991/FantasyTrader/blob/master/src/main.c


Solution

  • These constants are all keys, not values. Make them unique and the problem is solved.

    • define PERSIST_USER_GP 1000
    • define PERSIST_MAX_INV 10
    • define PERSIST_CUR_INV 0
    • define PERSIST_I1 0
    • define PERSIST_I2 0
    • define PERSIST_I3 0
    • define PERSIST_I4 0
    • define PERSIST_I5 0

    See https://developer.pebble.com/docs/c/Foundation/Storage/#persist_write_int