🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Saving and reusing variables?

    Lessons and Guides
    4
    7
    13.1k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      ManuXD32
      last edited by

      Hi, i've seen the new block in the beta (EEPROM) and I was wondering how can I save the data of the variables so I can use it after rebooting the M5.
      Example: the score of a game, save it so the next time you turn off and on the device the score is still there

      1 Reply Last reply Reply Quote 0
      • vkichlineV
        vkichline
        last edited by

        Are you talking about NVS (Non Volatile Storage?)
        M5ez uses it for its preferences. Here is a file that reads and writes them in C: https://github.com/vkichline/M5ezSettingsStorage/blob/master/m5ez_prefs_storage.cpp

        Basically, just include preferences.h, call prefs.begin with false for read/write, then use the accessors from preferences.h and finish with prefs.end().

        M 1 Reply Last reply Reply Quote 1
        • M
          ManuXD32 @vkichline
          last edited by

          @vkichline thank youuuu

          world101W 1 Reply Last reply Reply Quote 0
          • world101W
            world101 @ManuXD32
            last edited by

            Hi @manuxd32,
            For uiFlow, there is an example of saving data as a key/value pair in M5 Docs.

            I also created a simple example like this...
            0_1598705685410_Screen Shot 2020-08-29 at 8.52.51 AM.png

            G M 2 Replies Last reply Reply Quote 1
            • G
              Gaviota @world101
              last edited by

              How many write operations are maximal at the EPROM possible?

              A lot of nice M5Stack stuff :) ....

              world101W 1 Reply Last reply Reply Quote 1
              • world101W
                world101 @Gaviota
                last edited by

                @gaviota said in Saving and reusing variables?:

                How many write operations are maximal at the EPROM possible?

                I was wondering the same thing. This source and in more detail this source say the typical is 100,000 write/erase cycles.

                I'm also wondering which address location uiFlow uses to store the key/value data to EEPROM. @m5stack or @lukasmaximus do you know?

                1 Reply Last reply Reply Quote 1
                • M
                  ManuXD32 @world101
                  last edited by

                  @world101 thank you a lot!!!

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post