dimensional-de / napi-canon-cameras

Node AddOn Api module for Canon cameras
GNU General Public License v3.0
53 stars 22 forks source link

How should we use ShutterSpeed #14

Closed swingingtom closed 11 months ago

swingingtom commented 1 year ago

Hi ! First many thanks for this library 👍 Very useful. And this issue is not an issue with the implementation of the library.

Example I found didn't really showed how to use shutterSpeed properties. At end of day, I succeed to get it work

 camera.setProperties(
              {
                  [ CameraProperty.ID.Tv ]: 0x10,
              }
            );

0x10 value has been found from @dimensional/napi-canon-cameras/src/library/shutter-speed.cc https://github.com/dimensional-de/napi-canon-cameras/blob/de572fe31d027f2a386bd4af70e042b8ae5caa56/src/library/shutter-speed.cc#L18

Before finding this solution, I've tried many other ways. Usually resulting in :

Unable to setProperties
Error: EDSDK - INVALID_DEVICEPROP_VALUE
Unable to setProperties
TypeError: Argument 0 must be a number or string.

So Im wondering, how would you use the ShutterSpeed class make to code more readable than 0x10?

Thanks!

ThomasWeinert commented 11 months ago

Check the forLabel factory function: https://github.com/dimensional-de/napi-canon-cameras/blob/0663e4c02f9fb070bb5638f3b8f573fb5eed416c/tests/common/ShutterSpeed.test.ts#L45

wildangunawan commented 4 months ago

Apparently you cannot just pass the class but rather it should be the actual value/number. This should be the expected behavior anyway if we're looking into Option.IDs enum, which its key correspond to a value.

To update a shutter speed, you can either (a) pass the hex (which can be found in the SDK document, e.g. shutter speed at page 114), (b) pass the decimal value of the hex (so 0x10 -> 16, any other examples for shutter speed already mapped by the repo contributor here), or (c) use ShutterSpeed.value property (so it'll be ShutterSpeed.forLabel('1/1000').value).

Here's an example for the (c) option:

camera.setProperties({
  [CameraProperty.ID.Tv]: ShutterSpeed.forLabel('1/1000').value,
});