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

    Code for UiFlow-execute block needed for reading and writing the sd-card

    UIFlow
    uiflow
    2
    4
    10.2k
    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.
    • G
      Gaviota
      last edited by Gaviota

      Hi everyone!
      Using UiFlow V1.3.5-Beta, i'm buliding a hour counter for my boat engine.

      The new timer blocks are great and very helpful, many thanks to the team.

      To store and restore the cumulated seconds i need code for the UiFlow-execute block for reading and writing the sd-card:

      • Is there anyone who can help me?
      • Or are SD-card blocks foreseeen for the next beta version?

      For a first preview of the hour counter here you can see the display content:

      0_1566830111802_hour_counter.jpg

      ... translation of the german text:
      Title:

      • Betriebsstunden = Operating Hours

      Labels:

      • Stunden = Hours
      • Tag = Day
      • Batterie = Battery

      The Button Labeles are in english

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

      1 Reply Last reply Reply Quote 1
      • lukasmaximusL
        lukasmaximus
        last edited by lukasmaximus

        Hi @Gaviota unfortunately there are no blocks yet to support SD writing. You could try something like this in micropython:

        from m5stack import *
        from m5ui import *
        from uiflow import *
        import os

        sd_mount()

        timeSinceBoot = None
        f = open("/sd/1.TXT", 'w+')

        while True:
        timeSinceBoot = time.ticks_ms()
        if btnA.wasPressed():
        f.write('{}\n'.format(timeSinceBoot))
        wait_ms(100)
        f.close()
        wait_ms(2)

        You may also check this for reference https://github.com/turbinenreiter/micropython/tree/master/examples/SDdatalogger

        G 1 Reply Last reply Reply Quote 0
        • G
          Gaviota @lukasmaximus
          last edited by

          Hi @lukasmaximus thank you for the micropython code.

          This is my test program for writing and reading data to/from SD card:

          0_1566934261928_Test_SD-Read-Write.jpg

          Is there a possebility adding files at the posting? then i can add the Blockly-file here.

          And last but not least a short whish list for improvements at UiFlow:

          • Early implementation of the actual UiFlow-Beta-version to the UiFlow-PC-Version
          • Adding remarks in a easy way, i took thererfore the execute block using a #
          • Blocks for handling SD cards (reading, writing, appending data)
          • Adding files in postings at the M5Stack community

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

          1 Reply Last reply Reply Quote 0
          • lukasmaximusL
            lukasmaximus
            last edited by

            Hi @Gaviota glad I could be of help. The program looks great
            Unfortunately I don't think there is a way to post files on the forum.
            Other than copying and pasting the micropython output
            The only way is to host the file somewhere and paste the link.

            I would suggest the best way would be if you have a github account
            then make a repository with the file there and share it with us here.
            This would also allow for us to add it to our links of resources.

            Thank you for your requests, I will make sure to hand them on to the dev
            team. It is true that the updates on the offline version are lagging behind
            the online version but we will try to improve this. Blockly allows for a rectractable
            comment from the blocks so this shouldn't be hard to implement

            We used to have blocks for handling the SD card in our old platform M5GO
            so I don't see this as being too difficult to add either.

            All the best, Keep us updated on the progress of your project.

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