Skip to content
Snippets Groups Projects
Commit a1fd1ccd authored by Václav Jelínek's avatar Václav Jelínek
Browse files

Add function to check flash storage size and free space

parent 515fa8b0
No related branches found
No related tags found
No related merge requests found
import os
from micropython import const
from machine import Pin, I2C, Timer, WDT
from time import sleep, ticks_ms
......@@ -67,6 +68,13 @@ class Robot:
self.wdt_feed_timer = Timer(-1)
self.wdt_feed_timer.init(period=WDT_FEED_TIMER_PERIOD, mode=Timer.PERIODIC,
callback=self.wdt_feed)
def storage(self):
fs_stat = os.statvfs('/')
total = fs_stat[0] * fs_stat[2] # Block size * Total blocks
free = fs_stat[0] * fs_stat[3] # Block size * Free blocks
print(f"Total Flash: {total} bytes")
print(f"Free Space: {free} bytes ({free/total*100:.1f}%)")
# Function called with a timer to feed Watch Dog Timer to prevent rebooting
def wdt_feed(self, t):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment