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
  • 850 Views
*

Offline Caefix

  • **
  • 64
  • 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

  • ******
  • 4046
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

  • **
  • 64
  • 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

  • ******
  • 4046
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.


*

Online reyalp

  • ******
  • 12201
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

  • ***
  • 227
  • A480 A490 S95 M10
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.
« Last Edit: 03 / December / 2019, 12:25:37 by Mlapse »
frustration is a key ingredient in progress

 

Related Topics