-
Notifications
You must be signed in to change notification settings - Fork 0
/
camera.h
92 lines (77 loc) · 2.03 KB
/
camera.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/**
* @package Wildlife Camera
* Camera handling header
* @author WizLab.it
* @board AI-Thinker ESP32-CAM
* @version 20240228.018
*/
#ifndef CAMERA_H
#define CAMERA_H
/**
* Includes
*/
#include <Arduino.h>
#include <CRC32.h>
#include "FS.h"
#include "SD_MMC.h"
#include "esp_camera.h"
#include "extern.h"
/**
* Defines
*/
//Camera Parameters (AI-Thinker ESP32-CAM)
#define _CAMERA_PWDN_GPIO_NUM 32
#define _CAMERA_RESET_GPIO_NUM -1
#define _CAMERA_XCLK_GPIO_NUM 0
#define _CAMERA_SIOD_GPIO_NUM 26
#define _CAMERA_SIOC_GPIO_NUM 27
#define _CAMERA_Y9_GPIO_NUM 35
#define _CAMERA_Y8_GPIO_NUM 34
#define _CAMERA_Y7_GPIO_NUM 39
#define _CAMERA_Y6_GPIO_NUM 36
#define _CAMERA_Y5_GPIO_NUM 21
#define _CAMERA_Y4_GPIO_NUM 19
#define _CAMERA_Y3_GPIO_NUM 18
#define _CAMERA_Y2_GPIO_NUM 5
#define _CAMERA_VSYNC_GPIO_NUM 25
#define _CAMERA_HREF_GPIO_NUM 23
#define _CAMERA_PCLK_GPIO_NUM 22
//SD and Photo DB params
#define _CAMERA_SD_BASE_PATH "/WildlifeCameraPics"
#define _CAMERA_PHOTODB _CAMERA_SD_BASE_PATH "/photoDB.dat"
#define _CAMERA_PHOTODB_FILENAME_MAX_LENGTH 100
//Flash PIN
#define _CAMERA_FLASH_PIN GPIO_NUM_4
/**
* Class definition
*/
class Camera {
private:
struct _PhotoDB {
uint16_t photoCounter = 0;
char lastPhotoFilename[_CAMERA_PHOTODB_FILENAME_MAX_LENGTH];
unsigned long lastPhotoTimestamp = 0;
};
struct _PhotoDBPackage {
_PhotoDB photoDB;
uint32_t crc;
};
struct _PhotoDBPackage photoDBPack;
bool _sdIsOpen;
framesize_t _frameSize;
int _jpegQuality;
bool _sdCardEnabled;
void _sdPhotoDbSave();
public:
Camera(framesize_t frameSize, int jpegQuality, bool sdCardEnabled);
bool init();
long takePhoto(uint8_t **image, bool useFlash);
void flashBlink(uint16_t duration);
void flashGpioHold(bool status);
bool sdOpen();
void sdClose();
float sdGetUsedSpace();
uint16_t sdGetPhotoCounter();
unsigned long sdGetLastPhotoTimestamp();
};
#endif