Skip to content

Commit 5410d03

Browse files
author
Chris McKeever
committed
shuffle
1 parent cd3154a commit 5410d03

File tree

7 files changed

+95
-245
lines changed

7 files changed

+95
-245
lines changed

esp32/camera/motion-camera/v2-motion-camera/OV2640.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,37 @@
22

33
void OV2640::run(void)
44
{
5-
//return the frame buffer back to the driver for reuse
6-
if (fb) esp_camera_fb_return(fb);
7-
fb = esp_camera_fb_get();
5+
if (buffer) esp_camera_fb_return(buffer);
6+
buffer = esp_camera_fb_get();
87
}
98

109
void OV2640::runIfNeeded(void)
1110
{
12-
if (!fb) run();
11+
if (!buffer) run();
1312
}
1413

1514
int OV2640::getWidth(void)
1615
{
1716
runIfNeeded();
18-
return fb->width;
17+
return buffer->width;
1918
}
2019

2120
int OV2640::getHeight(void)
2221
{
2322
runIfNeeded();
24-
return fb->height;
23+
return buffer->height;
2524
}
2625

2726
size_t OV2640::getSize(void)
2827
{
2928
runIfNeeded();
30-
// FIXME - this shouldn't be possible but apparently the new cam board returns null sometimes?
31-
if (!fb) return 0;
32-
return fb->len;
29+
return (!buffer) ? 0 : buffer->len;
3330
}
3431

35-
uint8_t *OV2640::getfb(void)
32+
uint8_t *OV2640::getBuffer(void)
3633
{
3734
runIfNeeded();
38-
// FIXME - this shouldn't be possible but apparently the new cam board returns null sometimes?
39-
if (!fb) return NULL;
40-
41-
return fb->buf;
35+
return (!buffer) ? NULL : buffer->buf;
4236
}
4337

4438
esp_err_t OV2640::init(camera_config_t camConfig)
Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,28 @@
11
#ifndef OV2640_H_
22
#define OV2640_H_
33

4-
#include <Arduino.h>
5-
#include <pgmspace.h>
6-
#include <stdio.h>
7-
#include "esp_log.h"
8-
#include "esp_attr.h"
94
#include "esp_camera.h"
105

11-
extern camera_config_t esp32cam_config, esp32cam_aithinker_config, esp32cam_ttgo_t_config;
12-
136
class OV2640
147
{
158
public:
16-
OV2640(){
17-
fb = NULL;
18-
};
19-
~OV2640(){
9+
OV2640() {
10+
buffer = NULL;
2011
};
12+
~OV2640() {};
13+
2114
esp_err_t init(camera_config_t config);
2215
void run(void);
2316
size_t getSize(void);
24-
uint8_t *getfb(void);
17+
uint8_t *getBuffer(void);
2518
int getWidth(void);
2619
int getHeight(void);
27-
framesize_t getFrameSize(void);
28-
pixformat_t getPixelFormat(void);
29-
30-
void setFrameSize(framesize_t size);
31-
void setPixelFormat(pixformat_t format);
3220

3321
private:
34-
void runIfNeeded(); // grab a frame if we don't already have one
35-
36-
// camera_framesize_t _frame_size;
37-
// camera_pixelformat_t _pixel_format;
38-
camera_config_t _cam_config;
22+
// grab a frame if we don't already have one
23+
void runIfNeeded();
3924

40-
camera_fb_t *fb;
25+
camera_fb_t *buffer;
4126
};
4227

4328
#endif //OV2640_H_

esp32/camera/motion-camera/v2-motion-camera/camera.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#include "esp_camera.h"
21
#include "camera_pins.h"
32

4-
#include "fd_forward.h"
3+
#include "OV2640.h"
4+
OV2640 cam;
55

6-
bool cameraOK = false;
6+
bool cameraStatus = false;
77
bool *cameraInUse = new bool(false);
88

99
enum cameraModes { isReady, isStream, isCapture, isMotion };
@@ -45,10 +45,9 @@ camera_config_t getConfig() {
4545
}
4646

4747
bool initCamera() {
48+
cameraStatus = cam.init(getConfig());
4849

49-
camera_config_t cameraConfig = getConfig();
50-
cameraOK = esp_camera_init(&cameraConfig) == ESP_OK;
51-
50+
// camera class?
5251
sensor_t *s = esp_camera_sensor_get();
5352
s->set_aec_value(s, config.camera_exposure);
5453
s->set_exposure_ctrl(s, config.camera_exposure_control);
@@ -57,9 +56,11 @@ bool initCamera() {
5756
s->set_hmirror(s, config.camera_hmirror);
5857
s->set_raw_gma(s, config.camera_raw_gma);
5958

59+
// move these to camera class
6060
*cameraMode = isReady;
6161
*cameraInUse = false;
62-
return cameraOK;
62+
63+
return cameraStatus;
6364
}
6465

6566
void flash(bool on) {

esp32/camera/motion-camera/v2-motion-camera/configmanager.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
ConfigManager configManager;
44
bool wifiConnected = false;
55

6-
void streamServer(WebServer* server);
6+
void apModeCallback(WebServer* server);
7+
void stationModeCallback(WebServer* server);
78

89
/* == Brownout Handler ==*/
910
#include "soc/soc.h"
@@ -100,8 +101,8 @@ void configSetup() {
100101
configManager.addParameter("cameraRawGMA", &config.camera_raw_gma);
101102

102103
configManager.setInitCallback(configDefaults);
103-
configManager.setAPCallback(streamServer);
104-
configManager.setAPICallback(streamServer);
104+
configManager.setAPCallback(stationModeCallback);
105+
configManager.setAPICallback(stationModeCallback);
105106
configManager.setAPFilename("/wifiConfig.html");
106107

107108
configManager.setAPName("Spy-Cam-v2");

esp32/camera/motion-camera/v2-motion-camera/standard.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,6 @@ void initHTTP(int port=80) {
133133
request->send(SPIFFS, "/index.html", "text/html");
134134
});
135135
136-
webServer.addHandler(&logSocket);
137-
webServer.begin();
138-
139136
logger("Ready at: http://");
140137
logger(deviceIP());
141138
logger(":");

0 commit comments

Comments
 (0)