Rockbox.org home
Downloads
Release release
Dev builds dev builds
Extras extras
themes themes
Documentation
Manual manual
Wiki wiki
Device Status device status
Support
Forums forums
Mailing lists mailing lists
IRC IRC
Development
Bugs bugs
Patches patches
Dev Guide dev guide
Search



Donate

Rockbox Technical Forums


Login with username, password and session length
Home Help Search Staff List Login Register
News:

Thank You for your continued support and contributions!

+  Rockbox Technical Forums
|-+  Rockbox Development
| |-+  Feature Ideas
| | |-+  Disk usage pie-chart?
« previous next »
  • Print
Pages: [1] 2

Author Topic: Disk usage pie-chart?  (Read 8943 times)

Offline Frankenpod

  • Member
  • *
  • Posts: 415
Disk usage pie-chart?
« on: March 20, 2015, 08:11:46 AM »
Just a suggestion for anyone who could write a plug-in - a way of displaying disk usage akin to how it works on windows (and on Macs I assume!), with a little coloured pie-chart - perhaps with different pie segments for different types of media (video/music/podcasts/free space/etc). 

Or if it's not that easy to differentiate between different types of media for this purpose, it could just show the sizes of the first level of folders (so 'podcasts' folder vs 'music' folder vs 'rockbox' folder, etc).

« Last Edit: March 20, 2015, 08:14:10 AM by Frankenpod »
Logged

Offline __builtin

  • Developer
  • Member
  • *
  • Posts: 385
  • iPod 6G, c200v1 (RIP), e200v1 (RIP)
    • FWEI.TK
Re: Disk usage pie-chart?
« Reply #1 on: March 20, 2015, 08:39:30 PM »
This is totally doable. The 'stats' plugin gets all the data that's needed. Just add in a fancy drawing function and... *BOOM* ;)
Logged
No support questions by PM, please.

Offline Frankenpod

  • Member
  • *
  • Posts: 415
Re: Disk usage pie-chart?
« Reply #2 on: March 23, 2015, 09:48:50 AM »
Though, looking at it, the 'stats' plugin only reports number of files, rather than the disk space they use, so presumably it would need a slightly modified version of that plugin?  Can't be hard to collect size information while counting files though, surely?

Also, file-type I guess wouldn't distinguish between music and podcasts or audiobooks, which is why I was thinking maybe there could be an option of reporting the sizes of the top-level folders - though I don't know how common it is for poeple to organise their media files in 'music' 'podcast' 'audiobooks' folders.
Logged

Offline Frankenpod

  • Member
  • *
  • Posts: 415
Re: Disk usage pie-chart?
« Reply #3 on: March 28, 2015, 06:53:24 PM »
Am very vaguely thinking I might try and implement this myself.  Though I might be being over-ambitious, as am not very skilled at c programming.  But, on the plus side, I don't think its a very demanding project.

Not sure if this is the right forum for the rest of this post, but...

Having installed the rockbox package, and looked at the code for the stats plug-in, it seems as if all it would take is making a modified version to total up the sizes of the files instead of just counting them.  And then another bit of code to draw a pie-chart.

But (and this is how out-of-my-depth I am), I don't know how to get the size of a file. 

Can one call linux system functions from within Rockbox (as I know that's one way to do it), or is that a silly question given the platforms it runs on?  I don't even understand this much - does Rockbox sit on a kind of linux 'layer' when its installed on a DAP or is it a totally stand-alone?

Otherwise does one have to open files and read to the end of them to find out their size?

This is a dumb question, I know, but to be fair, I think that's the only problematic bit of this idea, the rest seems pretty straightforward.
« Last Edit: March 28, 2015, 06:55:36 PM by Frankenpod »
Logged

Offline saratoga

  • Developer
  • Member
  • *
  • Posts: 8974
Re: Disk usage pie-chart?
« Reply #4 on: March 28, 2015, 07:08:33 PM »
Quote from: Frankenpod on March 28, 2015, 06:53:24 PM
But (and this is how out-of-my-depth I am), I don't know how to get the size of a file. 

The plugin API struct has a filesize function. 

Quote from: Frankenpod on March 28, 2015, 06:53:24 PM
Can one call linux system functions from within Rockbox (as I know that's one way to do it), or is that a silly question given the platforms it runs on?  I don't even understand this much - does Rockbox sit on a kind of linux 'layer' when its installed on a DAP or is it a totally stand-alone?

No theres no linux system in rockbox, but rockbox does have its own APIs.  Plugins are stricted to the functions exported by the plugin API:

http://git.rockbox.org/?p=rockbox.git;a=blob;f=apps/plugin.h;h=f781f60350d79f6438296900f525aa1dda61596c;hb=HEAD#l445

« Last Edit: March 28, 2015, 07:54:20 PM by saratoga »
Logged

Offline Frankenpod

  • Member
  • *
  • Posts: 415
Re: Disk usage pie-chart?
« Reply #5 on: March 29, 2015, 09:46:37 AM »
Thanks - I'll give it a go (but don't hold your breath!).  Testing will be the tricky bit - there's an emulator, yes?  Will need to figure out how to get that working.
Logged

Offline saratoga

  • Developer
  • Member
  • *
  • Posts: 8974
Re: Disk usage pie-chart?
« Reply #6 on: March 29, 2015, 11:24:37 AM »
Simulator, it doesn't emulate the hardware. Its compiled the same way as a device build except you choose simulator instead of normal build in the configure script.
Logged

Offline __builtin

  • Developer
  • Member
  • *
  • Posts: 385
  • iPod 6G, c200v1 (RIP), e200v1 (RIP)
    • FWEI.TK
Re: Disk usage pie-chart?
« Reply #7 on: March 29, 2015, 11:42:17 AM »
Quote from: Frankenpod on March 29, 2015, 09:46:37 AM
Thanks - I'll give it a go (but don't hold your breath!).  Testing will be the tricky bit - there's an emulator, yes?  Will need to figure out how to get that working.

HINT: You'll probably need some trig functions to do the drawing. Look in
Code: [Select]
lib/fixedpoint/fixedpoint.h
for some fixed-point ones.
Logged
No support questions by PM, please.

Offline saratoga

  • Developer
  • Member
  • *
  • Posts: 8974
Re: Disk usage pie-chart?
« Reply #8 on: March 29, 2015, 11:51:39 AM »
Or use a bar chart if you want easy math :)
Logged

Offline Frankenpod

  • Member
  • *
  • Posts: 415
Re: Disk usage pie-chart?
« Reply #9 on: March 29, 2015, 12:34:38 PM »
Quote from: theunamedguy on March 29, 2015, 11:42:17 AM
Quote from: Frankenpod on March 29, 2015, 09:46:37 AM
Thanks - I'll give it a go (but don't hold your breath!).  Testing will be the tricky bit - there's an emulator, yes?  Will need to figure out how to get that working.

HINT: You'll probably need some trig functions to do the drawing. Look in
Code: [Select]
lib/fixedpoint/fixedpoint.h
for some fixed-point ones.

Cheers!  Probably will indeed need that.  I expect this will take me a while.
Logged

Offline __builtin

  • Developer
  • Member
  • *
  • Posts: 385
  • iPod 6G, c200v1 (RIP), e200v1 (RIP)
    • FWEI.TK
Re: Disk usage pie-chart?
« Reply #10 on: March 29, 2015, 03:42:59 PM »
If you need any help, feel free to ask on IRC.
Good luck! ;)
Logged
No support questions by PM, please.

Offline Frankenpod

  • Member
  • *
  • Posts: 415
Re: Disk usage pie-chart?
« Reply #11 on: March 31, 2015, 08:27:42 AM »
Not on IRC yet, so asking here!

To my surprise, first-draft (text output only) works in the simulator without trouble..despite not quite knowing what I'm doing.

But, have two stumbling blocks...

1/ Is there a rockbox API call to get the total size of the DAP's disk/flash storage?
2/ I'm struggling to understand the rockbox graphics functions - in particular, why is there an _array_ of screen objects, rather than just the one?  Which one do I use to draw graphics on?

Thanks.

Edit - hmm, have gotten a bar chart working, but only by hard-coding the total disk size, as I still can't work out where to get that information from.  Also still haven't quite worked out how to use IRC (never used it before, believe it or not).
Other issue is am not sure about type conversions - adding up disk usage in bytes leads to numbers too large for int or even long int.  Not sure whether to use floats instead or just to round to kb or Mb.
« Last Edit: March 31, 2015, 02:14:54 PM by Frankenpod »
Logged

Offline gevaerts

  • Administrator
  • Member
  • *
  • Posts: 1053
Re: Disk usage pie-chart?
« Reply #12 on: March 31, 2015, 03:52:46 PM »
Quote from: Frankenpod on March 31, 2015, 08:27:42 AM
1/ Is there a rockbox API call to get the total size of the DAP's disk/flash storage?

No. I suspect you'd have to add this to fat.c and then export it in the plugin api.

Quote
2/ I'm struggling to understand the rockbox graphics functions - in particular, why is there an _array_ of screen objects, rather than just the one?

Because there can be more than one screen. Think remotes.

Quote
Which one do I use to draw graphics on?

SCREEN_MAIN, usually (unless you want to draw on the remote's screem)

Quote
Other issue is am not sure about type conversions - adding up disk usage in bytes leads to numbers too large for int or even long int.  Not sure whether to use floats instead or just to round to kb or Mb.

Going with 512-byte sectors isn't wrong, or you could try to get the FAT cluster size and use that as a unit. It depends on what you want disk usage to mean, actual bytes or used disk blocks.
Logged

Offline __builtin

  • Developer
  • Member
  • *
  • Posts: 385
  • iPod 6G, c200v1 (RIP), e200v1 (RIP)
    • FWEI.TK
Re: Disk usage pie-chart?
« Reply #13 on: March 31, 2015, 05:40:49 PM »
Quote from: Frankenpod on March 31, 2015, 08:27:42 AM
Other issue is am not sure about type conversions - adding up disk usage in bytes leads to numbers too large for int or even long int.  Not sure whether to use floats instead or just to round to kb or Mb.

You /could/ try using 64-bit integers (unsigned long long or uint64_t with <stdint.h>).
Logged
No support questions by PM, please.

Offline Frankenpod

  • Member
  • *
  • Posts: 415
Re: Disk usage pie-chart?
« Reply #14 on: March 31, 2015, 06:18:01 PM »
Quote from: theunamedguy on March 31, 2015, 05:40:49 PM
Quote from: Frankenpod on March 31, 2015, 08:27:42 AM
Other issue is am not sure about type conversions - adding up disk usage in bytes leads to numbers too large for int or even long int.  Not sure whether to use floats instead or just to round to kb or Mb.

You /could/ try using 64-bit integers (unsigned long long or uint64_t with <stdint.h>).

I did consider doing that - nut just, not being at all experienced at this, I wondered what the 'normal' way of dealing with such things would be.  At the moment I just round everything to kb.  Maybe I'll use long long, dunno!
Logged

  • Print
Pages: [1] 2
« previous next »
+  Rockbox Technical Forums
|-+  Rockbox Development
| |-+  Feature Ideas
| | |-+  Disk usage pie-chart?
 

  • SMF 2.0.17 | SMF © 2019, Simple Machines
  • Rockbox Privacy Policy
  • XHTML
  • RSS
  • WAP2

Page created in 0.09 seconds with 15 queries.