Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0c9a574

Browse files
iabdalkadergiulcioffi
authored andcommitted
Remove sensor auto-detection (as requested).
* Pass a specific sensor object to Camera class. * Update example to match API changes.
1 parent 143068b commit 0c9a574

File tree

3 files changed

+18
-26
lines changed

3 files changed

+18
-26
lines changed

‎libraries/Portenta_Camera/examples/CameraCaptureRawBytes/CameraCaptureRawBytes.ino‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#include "camera.h"
22
#include "SDRAM.h"
3-
3+
#include"himax.h"
44
//REDIRECT_STDOUT_TO(Serial);
55

6-
Camera cam;
6+
Camera cam(new HM01B0());
77
uint8_t *fb = (uint8_t*) SDRAM_START_ADDRESS;
88

99
void blink_error(uint32_t count)

‎libraries/Portenta_Camera/src/camera.cpp‎

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -305,30 +305,17 @@ int Camera::Reset()
305305
return 0;
306306
}
307307

308-
ImageSensor *Camera::ProbeSensor()
308+
intCamera::ProbeSensor()
309309
{
310310
uint8_t addr;
311-
ImageSensor *sensor = NULL;
312-
313311
for (addr=1; addr<127; addr++) {
314312
Wire.beginTransmission(addr);
315313
if (Wire.endTransmission() == 0) {
316314
break;
317315
}
318316
}
319317

320-
switch (addr) {
321-
case HM01B0_I2C_ADDR:
322-
sensor = new HM01B0();
323-
break;
324-
case GC2145_I2C_ADDR:
325-
sensor = new GC2145();
326-
break;
327-
default:
328-
break;
329-
}
330-
331-
return sensor;
318+
return addr;
332319
}
333320

334321
int Camera::begin(uint32_t resolution, uint32_t framerate)
@@ -348,8 +335,7 @@ int Camera::begin(uint32_t resolution, uint32_t framerate)
348335
Wire.begin();
349336
Wire.setClock(400000);
350337

351-
ImageSensor *sensor = ProbeSensor();
352-
if (sensor == NULL) {
338+
if (ProbeSensor() != this->sensor->GetID()) {
353339
return -1;
354340
}
355341

@@ -359,20 +345,18 @@ int Camera::begin(uint32_t resolution, uint32_t framerate)
359345
HAL_Delay(10);
360346
}
361347

362-
if (sensor->Init() != 0) {
348+
if (this->sensor->Init() != 0) {
363349
return -1;
364350
}
365351

366352
if (BSP_CAMERA_Init() != 0) {
367353
return -1;
368354
}
369355

370-
// Must set sensor first before calling Camera methods.
371-
this->sensor = sensor;
372-
373356
if (SetResolution(resolution) != 0) {
374357
return -1;
375358
}
359+
376360
return 0;
377361
}
378362

‎libraries/Portenta_Camera/src/camera.h‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/*
2+
* TODO: Add license.
3+
* Copyright (c) 2021
4+
*
5+
* This work is licensed under <>, see the file LICENSE for details.
6+
*
7+
* Camera driver.
8+
*/
19
#ifndef __CAMERA_H
210
#define __CAMERA_H
311
#include "Wire.h"
@@ -70,10 +78,10 @@ class Camera {
7078
uint32_t resolution;
7179
ImageSensor *sensor;
7280
int Reset();
73-
ImageSensor *ProbeSensor();
81+
intProbeSensor();
7482
public:
75-
Camera(): sensor(NULL){}
76-
int begin(uint32_t resolution = CAMERA_R320x240, uint32_t framerate = 30);
83+
Camera(ImageSensor *sensor): sensor(sensor){}
84+
int begin(uint32_t resolution=CAMERA_R320x240, uint32_t framerate=30);
7785
int GetID();
7886
int SetFrameRate(uint32_t framerate);
7987
int SetResolution(uint32_t resolution);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /