Pages: [1] 2 Next   Go Down
  Print  
Author Topic: sprintf()  (Read 2188 times)
0 Members and 1 Guest are viewing this topic.
m2tk
Jr. Member
**

Karma: +0/-0
Offline Offline

Posts: 50

Sheet happens ...


« on: 13 / April / 2008, 20:12:39 »

hi,
how to convince sprintf func to print "3,23 RAD" from long l = 3234?

sprintf(osd_buf, "%ld,%02ld RAD", v/1000, v%1000); prints "3,234 RAD"

can we use floats in sprinf?
thx.
Logged

S5IS 1.01bc
GrAnd
Developers
Hero Member
****

Karma: +76/-2
Offline Offline

Posts: 917


[A610, S3IS]


« Reply #1 on: 13 / April / 2008, 21:15:31 »

sprintf(osd_buf, "%ld,%ld RAD", v/1000, v%1000/10);
or
sprintf(osd_buf, "%ld,%ld RAD", v/1000, v/10%100);


can we use floats in sprinf?

Yes, but it is not recommended to use floating point operations, because they are emulated (CPU does not have FP-coprocessor).
« Last Edit: 13 / April / 2008, 21:18:33 by GrAnd » Logged

CHDK Developer.
fudgey
Global Moderator
Hero Member
*****

Karma: +74/-1
Offline Offline

Posts: 842

a570is


« Reply #2 on: 13 / April / 2008, 22:58:01 »

And since nobody asked: yes, I too think it would be better if the battery voltage reading was 2,43V instead of 2,432 Smiley
Logged
m2tk
Jr. Member
**

Karma: +0/-0
Offline Offline

Posts: 50

Sheet happens ...


« Reply #3 on: 14 / April / 2008, 12:07:12 »

And since nobody asked: yes, I too think it would be better if the battery voltage reading was 2,43V instead of 2,432 Smiley

yes, i'm going to leave only 2,34 Wink but that's not only for that
Logged

S5IS 1.01bc
Barney Fife
Hero Member
*****

Karma: +70/-225
Offline Offline

Posts: 1159



« Reply #4 on: 14 / April / 2008, 12:36:52 »

Deleted
« Last Edit: 22 / April / 2008, 22:43:15 by Barney Fife » Logged

[acseven/admin commented out: please refrain from more direct offensive language to any user. FW complaints to me] I felt it imperative to withdraw my TOTAL participation. Nobody has my permission, nor the right, to reinstate MY posts. Make-do with my quoted text in others' replies only. Bye
m2tk
Jr. Member
**

Karma: +0/-0
Offline Offline

Posts: 50

Sheet happens ...


« Reply #5 on: 14 / April / 2008, 17:54:04 »

as i can see, those measures are not ideal, discharge is not linear and batteries also vary between changings so i don't think you can relay on them. think 2 digit fraction precision is right in place if not too precise...

but don't worry i'm not going to put it into trunk, though it is only changing 3 numbers in source code Wink
i'm thinking about sth else with that sprintf()...
Logged

S5IS 1.01bc
fudgey
Global Moderator
Hero Member
*****

Karma: +74/-1
Offline Offline

Posts: 842

a570is


« Reply #6 on: 14 / April / 2008, 19:31:45 »

I only keep the voltage on display, no icon to waste space. Any percentages the software can calculate can be rude guesses at best and that goes for the icon as well. Battery voltage varies primary with load as much as with capacity. I'm pretty familiar with how batteries behave so for me the voltage is way more clear indicator than an icon or percentage...

That's why I'd like the SI unit "V" letter there, to keep my brain clear that this is the battery voltage and not a part of DoF or anything else. And to put in that extra letter, one digit should be removed to prevent clutter... When a feature really does something for battery load, the voltage sinks significantly at least fast for my camera. The voltage measurement obviously isn't accurate to 4 digits either but that's not an issue here as absolute voltages aren't important, changes are and they are supposedly fairly accurate unless the last digit is all noise.

Moreover, I'd be thrilled if someone found a way to disable Canon's own low battery icon blink. It messes up my precious CHDK displays when it appears and is actually doing this half the time as it seems to be tuned for alkaline batteries instead of the (Eneloop) NiMH cells I use.

But I really don't feel strongly about this, I can perfectly well patch me a build for myself if people think the last digit is important. Maybe it is for cameras with lithium battery packs.

Logged
PhyrePhoX
Global Moderator
Hero Member
*****

Karma: +139/-37
Offline Offline

Posts: 1819


Coders Humiliate DSLR Kiddies


« Reply #7 on: 14 / April / 2008, 19:55:00 »

by the way, can the v value be used for some kind of benchmarks?
my s3is shuts down on about 4230 left. does this value depend on something? is it camera dependent? what values work for your s3is, barney? sorry this partly being offtopic.
Logged

fudgey
Global Moderator
Hero Member
*****

Karma: +74/-1
Offline Offline

Posts: 842

a570is


« Reply #8 on: 14 / April / 2008, 20:04:38 »

by the way, can the v value be used for some kind of benchmarks?
my s3is shuts down on about 4230 left. does this value depend on something? is it camera dependent? what values work for your s3is, barney? sorry this partly being offtopic.

It's definitely camera model dependent since the battery voltages are highly different for different technologies. Mine shuts down at about 2,0 V I suppose, but it's easy to be mistaken and think it's 2,2 V because using playback mode on empty batteries will give me more than a 2,2 V reading and the camera may shut down instantly if I do the battery-hogging switch to rec mode.
Logged
m2tk
Jr. Member
**

Karma: +0/-0
Offline Offline

Posts: 50

Sheet happens ...


« Reply #9 on: 14 / April / 2008, 23:18:38 »

for my s5 it is also sth like 4250mV..

btw sprintf(): i have modified a little file browser with minor changes (filesize in b,kb,mb,gb, selected filesize sum, trunk long paths, 10 rows and some fixes to gui)
if you want to try...

edit: added patch file
« Last Edit: 16 / April / 2008, 08:03:29 by m2tk » Logged

S5IS 1.01bc
PhyrePhoX
Global Moderator
Hero Member
*****

Karma: +139/-37
Offline Offline

Posts: 1819


Coders Humiliate DSLR Kiddies


« Reply #10 on: 14 / April / 2008, 23:29:19 »

suggestion: supply diff too, makes one see the differences way better Smiley
Logged

Barney Fife
Hero Member
*****

Karma: +70/-225
Offline Offline

Posts: 1159



« Reply #11 on: 14 / April / 2008, 23:54:08 »

Deleted
« Last Edit: 22 / April / 2008, 22:43:39 by Barney Fife » Logged

[acseven/admin commented out: please refrain from more direct offensive language to any user. FW complaints to me] I felt it imperative to withdraw my TOTAL participation. Nobody has my permission, nor the right, to reinstate MY posts. Make-do with my quoted text in others' replies only. Bye
m2tk
Jr. Member
**

Karma: +0/-0
Offline Offline

Posts: 50

Sheet happens ...


« Reply #12 on: 15 / April / 2008, 14:56:10 »

suggestion: supply diff too, makes one see the differences way better Smiley

hi PhyrePhoX, how to make a .diff file in TortoiseSVN ?
Logged

S5IS 1.01bc
PhyrePhoX
Global Moderator
Hero Member
*****

Karma: +139/-37
Offline Offline

Posts: 1819


Coders Humiliate DSLR Kiddies


« Reply #13 on: 15 / April / 2008, 16:51:13 »

either via commandline - "svn diff > diff.txt" (executed in your working directory) or you rightclick your working copy and in the tortoise svn tool click on "create patch", as described in TortoiseSVN | drupal.org for example Smiley

about the battery issue: ugh, havent thought about the playback mode, that uses less volts. have to make a test how much volts exactly, so that you can have two battery icons, one for playback one for recmode... joking Wink
Logged

m2tk
Jr. Member
**

Karma: +0/-0
Offline Offline

Posts: 50

Sheet happens ...


« Reply #14 on: 15 / April / 2008, 20:57:32 »

thx, will try it tomorrow.

i have one more new idea but still know too little how will make it, though i am learning C one more time ... with chdk, again.

the idea of rename feature in file browser:
- need to add new item into mpopup.c and new frame (enough for rename)
-----------------------
| RENAMEFILENAME.EXT  |
-----------------------

simple actions:
moving navi keys [up-down] changes available chars (..,D,E<-F->G,H,.. ),
moving [left-right] position (F->I->L->..), [set] ok, [?] cancel


btw. some project source code Q: why there are some *.h files in /include/ dir when other together with *.c ?
« Last Edit: 15 / April / 2008, 21:07:16 by m2tk » Logged

S5IS 1.01bc
Pages: [1] 2 Next   Go Up
  Print  
 
Jump to: