my CHDK space bar indicator is off, what could create this? - page 2 - General Help and Assistance on using CHDK stable releases - CHDK Forum

my CHDK space bar indicator is off, what could create this?

  • 15 Replies
  • 11962 Views
*

Offline Caefix

  • *****
  • 948
  • Sorry, busy deleting test shots...
Re: my CHDK space bar indicator is off, what could create this?
« Reply #10 on: 22 / November / 2019, 11:23:25 »
Advertisements
 ::)
return GetFreeCardSpaceKb()/GetTotalCardSpaceKb()*100;
All lifetime is a loan from eternity.

*

Offline srsa_4c

  • ******
  • 4451
Re: my CHDK space bar indicator is off, what could create this?
« Reply #11 on: 22 / November / 2019, 12:44:39 »
Code: [Select]
return (GetFreeCardSpaceKb()/GetTotalCardSpaceKb())*100;
return GetFreeCardSpaceKb()/GetTotalCardSpaceKb()*100;
(smaller unsigned integer)/(larger unsigned integer)*100
Evaluated from left to right:
(smaller unsigned integer)/(larger unsigned integer) = 0
0 * 100 = 0
Try it and see.

*

Offline Caefix

  • *****
  • 948
  • Sorry, busy deleting test shots...
Re: my CHDK space bar indicator is off, what could create this?
« Reply #12 on: 22 / November / 2019, 14:59:39 »
 :-X
return (int)((double)(GetFreeCardSpaceKb()/(double)GetTotalCardSpaceKb())*100);
All lifetime is a loan from eternity.

*

Offline srsa_4c

  • ******
  • 4451
Re: my CHDK space bar indicator is off, what could create this?
« Reply #13 on: 22 / November / 2019, 15:56:47 »
return (int)((double)(GetFreeCardSpaceKb()/(double)GetTotalCardSpaceKb())*100);
The ARM CPU in our cameras has no floating point hardware, and most cameras have no hardware support for division either.
So,
floating point -> very slow
integer division -> slow
bit shift, multiplication -> ok.
The calculation in question is performed at least a dozen times per second and its precision is not critical: using integers allows for a tiny bit less CPU utilization.

*

Offline reyalp

  • ******
  • 14128
Re: my CHDK space bar indicator is off, what could create this?
« Reply #14 on: 22 / November / 2019, 16:57:06 »
FWIW, FP isn't THAT slow (https://chdk.setepontos.com/index.php?topic=12451.msg123421#msg123421), I wouldn't hesitate to use it here if required, but I completely agree with sticking to integer when it isn't
Don't forget what the H stands for.

*

Offline Mlapse

  • *****
  • 584
  • S95 S110
Re: my CHDK space bar indicator is off, what could create this?
« Reply #15 on: 03 / December / 2019, 12:22:29 »
I committed the above patch. Can you check whether it fixes the free space display?

I just started up 1.5/5296 and the bar looks as expected now, thank you.
it makes glancing at the cam good enough to check for space.

i have stopped the cam today (14 dec) when the bar was at around 15% it turned red, so i assume this fix is perfect.
« Last Edit: 14 / December / 2019, 07:01:18 by Mlapse »
frustration is a key ingredient in progress

 

Related Topics


SimplePortal © 2008-2014, SimplePortal