Skip to content

Commit

Permalink
Added advanced Frame camera APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
siliconwitch committed Apr 5, 2024
1 parent 6063a28 commit bab5414
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion frame/lua.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ The camera capability of Frame allows for capturing and downloading of single JP

| API                                                                                   | Description |
|:---------|:------------|
| `frame.camera.auto(enable, metering_mode)` | Enables automatic exposure and whitebalance when `enable` is set to `true`. When enabling, `mode` can be given as either `'spot'`, `'center_weighted'` or `'average'`. Each option progressivly takes more of the image into account for exposure metering. Once started, the exposure will take around 1 second to stabilize, and then continiously auto-expose until disabled, or until Frame is put to sleep
| `frame.camera.capture{zoom=1, pan=0, quality=1.0}` | Captures a single image from the camera. `zoom` can be either `1`, `2`, `3`, or `4` returning 720x720, 360x360, 240x240 or 180x180 images respectively. `pan` can be used to tilt the camera view either up or down. A value of `10` represents the highest viewing angle, `0` is center, and `-10` is the lowest. The `quality` factor can help reduce image size by reducing the JPEG quality. A value of `1.0` represents full quality, and can be reduced to `0.01` for the lowest quality and smallest file size
| `frame.camera.read(num_bytes)` | Reads out a number of bytes from the camera capture memory as a byte string. Once all bytes have been read, `nil` will be returned

Expand All @@ -74,6 +75,8 @@ The camera capability of Frame allows for capturing and downloading of single JP
```lua
local mtu = frame.bluetooth.max_length()

frame.camera.auto(true, 'center_weighted') -- Start auto-mode
frame.sleep(1) -- Wait a little for the exposure to stabilize
frame.camera.capture() -- Capture an image using default settings

while true do
Expand All @@ -89,7 +92,10 @@ end
|:---------|:------------|
| `frame.camera.sleep()` | Puts the camera to sleep and reduces power consumption. Note the `frame.sleep()` function will automatically put the camera to sleep
| `frame.camera.wake()` | Wakes up the camera if it has previously been asleep. Note that following wakeups from `frame.sleep()` automatically wakes up the camera
| `frame.camera.set_register(address, value)` | Allows for hacking the camera's internal registers
| `frame.camera.set_exposure(shutter)` | Sets the shutter speed in microseconds when `camera.auto()` is set to `false`. `shutter` can be a value between `20` and `20000`
| `frame.camera.set_gain(gain)` | Sets the analog gain of the sensor when `camera.auto()` is set to `false`. `gain` can be a value between `0` and `255`
| `frame.camera.set_white_balance(r, g, b)` | Sets the digital gains of the R, G and B channels when `camera.auto()` is set to `false`. `r`, `g` and `b` can be values between `0` and `1023`
| `frame.camera.set_register(address, value)` | Allows for hacking the camera's internal registers. `address` can be any 16-bit register address of the camera, and `value` any 8-bit value to write to that address

---

Expand Down

0 comments on commit bab5414

Please sign in to comment.