Skip to content

Commit 50ce02b

Browse files
committed
docs: Add documentation for ImageSensor.
1 parent 3531197 commit 50ce02b

File tree

1 file changed

+146
-3
lines changed

1 file changed

+146
-3
lines changed

libraries/Camera/src/camera.h

Lines changed: 146 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* @brief Header file for the Arduino Camera library.
2222
*
2323
* This library allows capturing pixels from supported cameras on Arduino products.
24-
* Supported cameras: OV7670, Himax HM0360, and GC2145.
24+
* Supported cameras: OV7670, HM0360, HM01B0, and GC2145.
2525
* The pixels are returned in a frame buffer from which frames can be retrieved continuously.
2626
*/
2727

@@ -153,28 +153,158 @@ class FrameBuffer {
153153
typedef void (*md_callback_t)();
154154

155155

156+
/**
157+
* @class ImageSensor
158+
* @brief Abstract base class for image sensor drivers.
159+
*/
156160
class ImageSensor {
157161
public:
158162
virtual ~ImageSensor() { }
163+
164+
/**
165+
* @brief Initialize the image sensor.
166+
* This prepares the sensor for capturing frames by setting the registers to their default values.
167+
* @return int 0 on success, non-zero on failure
168+
*/
159169
virtual int init() = 0;
170+
171+
/**
172+
* @brief Reset the image sensor.
173+
* The effect differs between the camera models.
174+
* It has no effect on the GC2145. On the OV7670, it resets all configuration registers to the default values.
175+
* On HM0360 and HM01B0 the registers are reset to the defaults. The camera also enters Standby Mode, where there is no video output and the power consumption is lowered.
176+
* @return int 0 on success, non-zero on failure
177+
*/
160178
virtual int reset() = 0;
179+
180+
/**
181+
* @brief Get the I2C address of the image sensor.
182+
* @return int The sensor ID
183+
*/
161184
virtual int getID() = 0;
185+
186+
/**
187+
* @brief Check if the image sensor is monochrome aka grayscale.
188+
*
189+
* @return true If the sensor is monochrome
190+
* @return false Otherwise
191+
*/
162192
virtual bool getMono() = 0;
193+
194+
/**
195+
* @brief Get the clock frequency of the image sensor.
196+
*
197+
* @return uint32_t The clock frequency in Hz
198+
*/
163199
virtual uint32_t getClockFrequency() = 0;
200+
201+
/**
202+
* @brief Set the frame rate of the image sensor.
203+
* @note This has no effect on cameras that do not support variable frame rates.
204+
* @param framerate The desired frame rate in frames per second
205+
* @return int 0 on success, non-zero on failure
206+
*/
164207
virtual int setFrameRate(int32_t framerate) = 0;
208+
209+
/**
210+
* @brief Set the resolution of the image sensor.
211+
* @note This has no effect on cameras that do not support variable resolutions.
212+
* @param resolution The desired resolution, as defined in the resolution enum
213+
* @return int 0 on success, non-zero on failure
214+
*/
165215
virtual int setResolution(int32_t resolution) = 0;
216+
217+
/**
218+
* @brief Set the pixel (color) format of the image sensor.
219+
* @note This has no effect on cameras that do not support variable pixel formats.
220+
* e.g. the Himax HM01B0 only supports grayscale.
221+
* @param pixelformat The desired pixel format, as defined in the pixel format enum
222+
* @return int 0 on success, non-zero on failure
223+
*/
166224
virtual int setPixelFormat(int32_t pixelformat) = 0;
225+
226+
/**
227+
* @brief Enable motion detection with the specified callback.
228+
*
229+
* @note This has no effect on cameras that do not support motion detection.
230+
* Currently only the Himax HM01B0 and HM0360 support motion detection.
231+
* @note This has no effect on cameras that do not support motion detection.
232+
* @param callback Function to be called when motion is detected
233+
* @return int 0 on success, non-zero on failure
234+
*/
167235
virtual int enableMotionDetection(md_callback_t callback) = 0;
236+
237+
/**
238+
* @brief Disable motion detection.
239+
*
240+
* @note This has no effect on cameras that do not support motion detection.
241+
* Currently only the Himax HM01B0 and HM0360 support motion detection.
242+
* @return int 0 on success, non-zero on failure
243+
*/
168244
virtual int disableMotionDetection() = 0;
245+
246+
/**
247+
* @brief Set the motion detection window.
248+
*
249+
* @note This has no effect on cameras that do not support motion detection.
250+
* Currently only the Himax HM01B0 and HM0360 support motion detection.
251+
* @param x The x-coordinate of the window origin
252+
* @param y The y-coordinate of the window origin
253+
* @param w The width of the window
254+
* @param h The height of the window
255+
* @return int 0 on success, non-zero on failure
256+
*/
169257
virtual int setMotionDetectionWindow(uint32_t x, uint32_t y, uint32_t w, uint32_t h) = 0;
258+
259+
/**
260+
* @brief Set the motion detection threshold.
261+
*
262+
* @note This has no effect on cameras that do not support motion detection.
263+
* Currently only the Himax HM01B0 and HM0360 support motion detection.
264+
* On the Himax HM01B0, the recommended threshold range is 3 - 240 (0x03 to 0xF0).
265+
* @param threshold The motion detection threshold
266+
* @return int 0 on success, non-zero on failure
267+
*/
170268
virtual int setMotionDetectionThreshold(uint32_t threshold) = 0;
269+
270+
/**
271+
* @brief Check if motion was detected and clear the motion detection flag.
272+
*
273+
* @note This has no effect on cameras that do not support motion detection.
274+
* Currently only the Himax HM01B0 and HM0360 support motion detection.
275+
* @note This function must be called after the motion detection callback was executed to clear the motion detection flag.
276+
* @return int 0 if no motion is detected, non-zero if motion is detected
277+
*/
171278
virtual int motionDetected() = 0;
279+
280+
/**
281+
* @brief Output debug information to a stream.
282+
* You can use this function to output debug information to the serial port by passing Serial as the stream.
283+
* @param stream Stream to output the debug information
284+
*/
172285
virtual void debug(Stream &stream) = 0;
173286

287+
/**
288+
* @brief Set the sensor in standby mode.
289+
* @note This has no effect on cameras that do not support standby mode.
290+
* @note None of the currently supported camera drivers implement this function.
291+
* The HM01B0 and HM0360 cameras can be set in standby mode by calling reset() instead.
292+
* @param enable true to enable standby mode, false to disable
293+
* @return int 0 on success, non-zero on failure (or not implemented)
294+
*/
174295
virtual int setStandby(bool enable) {
175296
return -1;
176297
}
177298

299+
/**
300+
* @brief Set the test pattern mode for the sensor.
301+
*
302+
* @note This has no effect on cameras that do not support test pattern mode.
303+
* @param enable true to enable test pattern, false to disable
304+
* @param walking true for walking test pattern, false for other test pattern (if supported)
305+
* The walking test pattern alternates between black and white pixels which is useful for detecting stuck-at faults
306+
* @return int 0 on success, non-zero on failure (or not implemented)
307+
*/
178308
virtual int setTestPattern(bool enable, bool walking) {
179309
return -1;
180310
}
@@ -285,6 +415,7 @@ class Camera {
285415
/**
286416
* @brief Set the test pattern mode for the sensor.
287417
*
418+
* @note This has no effect on cameras that do not support test pattern mode.
288419
* @param enable true to enable test pattern, false to disable
289420
* @param walking true for walking test pattern, false for other test pattern (if supported)
290421
* The walking test pattern alternates between black and white pixels which is useful for detecting stuck-at faults
@@ -310,22 +441,28 @@ class Camera {
310441

311442
/**
312443
* @brief Enable motion detection with the specified callback.
313-
* @note This has no effect on cameras that do not support motion detection.
444+
*
445+
* @note This has no effect on cameras that do not support motion detection.
446+
* Currently only the Himax HM01B0 and HM0360 support motion detection.
314447
* @param callback Function to be called when motion is detected
315448
* @return int 0 on success, non-zero on failure
316449
*/
317450
int enableMotionDetection(md_callback_t callback=NULL);
318451

319452
/**
320453
* @brief Disable motion detection.
321-
*
454+
*
455+
* @note This has no effect on cameras that do not support motion detection.
456+
* Currently only the Himax HM01B0 and HM0360 support motion detection.
322457
* @return int 0 on success, non-zero on failure
323458
*/
324459
int disableMotionDetection();
325460

326461
/**
327462
* @brief Set the motion detection window.
328463
*
464+
* @note This has no effect on cameras that do not support motion detection.
465+
* Currently only the Himax HM01B0 and HM0360 support motion detection.
329466
* @param x The x-coordinate of the window origin
330467
* @param y The y-coordinate of the window origin
331468
* @param w The width of the window
@@ -336,6 +473,9 @@ class Camera {
336473

337474
/**
338475
* @brief Set the motion detection threshold.
476+
*
477+
* @note This has no effect on cameras that do not support motion detection.
478+
* Currently only the Himax HM01B0 and HM0360 support motion detection.
339479
* On the Himax HM01B0, the recommended threshold range is 3 - 240 (0x03 to 0xF0).
340480
* @param threshold The motion detection threshold
341481
* @return int 0 on success, non-zero on failure
@@ -344,6 +484,9 @@ class Camera {
344484

345485
/**
346486
* @brief Check if motion was detected and clear the motion detection flag.
487+
*
488+
* @note This has no effect on cameras that do not support motion detection.
489+
* Currently only the Himax HM01B0 and HM0360 support motion detection.
347490
* @note This function must be called after the motion detection callback was executed to clear the motion detection flag.
348491
* @return int 0 if no motion is detected, non-zero if motion is detected
349492
*/

0 commit comments

Comments
 (0)