Skip to content

Commit 11894ba

Browse files
committed
Improved readme.
1 parent c403821 commit 11894ba

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ If you are not familiar with building a custom firmware, you can go to the [rele
1616
from camera import Camera, GrabMode, PixelFormat, FrameSize, GainCeiling
1717

1818
# Camera construction and initialization
19+
# These pins are just examples and if you use them just like that will get a watchdog error. Adapt them to your board!
1920
camera = Camera(
2021
data_pins=[1,2,3,4,5,6,7,8],
2122
vsync_pin=9,
@@ -87,12 +88,12 @@ Example for Xiao sense:
8788
#define MICROPY_CAMERA_PIN_XCLK (10)
8889
#define MICROPY_CAMERA_PIN_PWDN (-1)
8990
#define MICROPY_CAMERA_PIN_RESET (-1)
90-
#define MICROPY_CAMERA_PIN_SIOD (40)
91-
#define MICROPY_CAMERA_PIN_SIOC (39)
92-
#define MICROPY_CAMERA_XCLK_FREQ (20000000)
93-
#define MICROPY_CAMERA_FB_COUNT (2)
94-
#define MICROPY_CAMERA_JPEG_QUALITY (10)
95-
#define MICROPY_CAMERA_GRAB_MODE (1)
91+
#define MICROPY_CAMERA_PIN_SIOD (40) // SDA
92+
#define MICROPY_CAMERA_PIN_SIOC (39) // SCL
93+
#define MICROPY_CAMERA_XCLK_FREQ (20000000) // Frequencies are normally either 10 MHz or 20 MHz
94+
#define MICROPY_CAMERA_FB_COUNT (2) // Usually the value is between 1 (slow) and 2 (fast, but more load on CPU)
95+
#define MICROPY_CAMERA_JPEG_QUALITY (10) // Quality of JPEG output. 0-63 lower means higher quality. Definition will change in the future
96+
#define MICROPY_CAMERA_GRAB_MODE (1) // 0=WHEN_EMPTY (might have old data, but less resources), 1=LATEST (best, but more resources)
9697

9798
```
9899

src/modcamera.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,14 @@ const mp_rom_map_elem_t mp_camera_hal_gainceiling_table[] = {
290290
{ MP_ROM_QSTR(MP_QSTR_128X), MP_ROM_INT(GAINCEILING_128X) },
291291
};
292292

293+
// Supporting functions
294+
static int map(int value, int fromLow, int fromHigh, int toLow, int toHigh) {
295+
if (fromHigh == fromLow) {
296+
mp_raise_ValueError(MP_ERROR_TEXT("fromLow und fromHigh shall not be equal"));
297+
}
298+
return (int)((int32_t)(value - fromLow) * (toHigh - toLow) / (fromHigh - fromLow) + toLow);
299+
}
300+
293301
//TODO: Makros with convertion function, since the API will use standarized values.
294302
// Helper functions to get and set camera and sensor information
295303
#define SENSOR_STATUS_GETSET_IN_RANGE(type, name, status_field_name, setter_function_name, min_val, max_val) \

0 commit comments

Comments
 (0)