Skip to content

Commit e40fe8f

Browse files
About app: add free, used and total storage space info
1 parent 059e1e5 commit e40fe8f

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
=====
33
- Fri3d Camp 2024 Badge: workaround ADC2+WiFi conflict by temporarily disable WiFi to measure battery level
44
- Fri3d Camp 2024 Badge: improve battery monitor calibration to fix 0.1V delta
5+
- About app: add free, used and total storage space info
56
- AppStore app: remove unnecessary scrollbar over publisher's name
67
- OSUpdate app: pause download when wifi is lost, resume when reconnected
78
- Settings app: fix un-checking of radio button
9+
- ImageView app: add support for grayscale images
810
- API: SharedPreferences: add erase_all() functionality
911
- API: improve and cleanup animations
1012

internal_filesystem/builtin/apps/com.micropythonos.about/assets/about.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,26 @@ def onCreate(self):
8585
print("main.py: WARNING: could not import/run freezefs_mount_builtin: ", e)
8686
label11 = lv.label(screen)
8787
label11.set_text(f"freezefs_mount_builtin exception (normal on dev builds): {e}")
88-
# TODO:
89-
# - add total size, used and free space on internal storage
90-
# - add total size, used and free space on SD card
88+
# Disk usage:
89+
import os
90+
stat = os.statvfs('/')
91+
total_space = stat[0] * stat[2]
92+
free_space = stat[0] * stat[3]
93+
used_space = total_space - free_space
94+
label20 = lv.label(screen)
95+
label20.set_text(f"Total space in /: {total_space} bytes")
96+
label21 = lv.label(screen)
97+
label21.set_text(f"Free space in /: {free_space} bytes")
98+
label22 = lv.label(screen)
99+
label22.set_text(f"Used space in /: {used_space} bytes")
100+
stat = os.statvfs('/sdcard')
101+
total_space = stat[0] * stat[2]
102+
free_space = stat[0] * stat[3]
103+
used_space = total_space - free_space
104+
label23 = lv.label(screen)
105+
label23.set_text(f"Total space /sdcard: {total_space} bytes")
106+
label24 = lv.label(screen)
107+
label24.set_text(f"Free space /sdcard: {free_space} bytes")
108+
label25 = lv.label(screen)
109+
label25.set_text(f"Used space /sdcard: {used_space} bytes")
91110
self.setContentView(screen)

0 commit comments

Comments
 (0)