Friday, April 9, 2021

M3 Brackets: tweaked to address CHDK integer math limitation

Just a quick update on my M3 Brackets script.

Up until now, some of the algorithms I have used in M3 Brackets were taken straight from my Magic Lantern DOFIS script.

When I originally did this, I thought I understood the CHDK environment's limitations, ie only integer maths is available, albeit augmented with the imath library functions. ML uses floating point maths.

When it comes to multiplying and dividing with the imath functions, all is OK. The problem I've just spotted, so shame on me for not seeing this earlier :-(, is when you need to do a square root, where you are limited to taking the sqrt of numbers less than 16384, or 16384'000 in imath parlance.

So I've now changed things to not use an imath.sqrt function and, hopefully, things are now well behaved. Plus, M3 Brackets now only runs with registered EF-M lenses.

I guess the lesson for coding is: test, retest and test again :-)

No comments:

Post a Comment