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
|
# VC0706-cam-lib-legato
Library for the Adafruit VC0706 camera used on Legato devices. The majority of this code is ported from Adafruit's [Adafruit-VC0706-Serial-Camera-Library](https://github.com/adafruit/Adafruit-VC0706-Serial-Camera-Library) repository with some C/Legato specific changes.
## Project Status
Still incomplete and not functional. We are hoping to release 1.0.0 in the coming days.
## Usage on Other Platforms
The Legato serial API [`le_tty`](http://legato.io/legato-docs/latest/le__tty_8h.html) returns a file descriptor used to read and write. The file descriptor in the `Camera` struct can be replaced with any other file descriptor serial interface.
## API
```c
void delay (unsigned int secs);
int openCameraFd ();
void sendCommand (Camera *cam, byte cmd, byte args[]);
bool runCommand (Camera *cam, byte cmd, byte args[], int respLen);
int readResponse (Camera *cam, int nBytes, int timeout);
bool verifyResponse (Camera *cam, byte cmd);
bool cameraFrameBuffCtrl (Camera *cam, byte cmd);
bool takePicture (Camera *cam);
size_t bufferToFile (Camera *cam, char *path);
bool reset (Camera *cam);
bool TVon (Camera *cam);
bool TVOff (Camera *cam);
byte *readPicture (Camera *cam);
bool resumeVideo (Camera *cam);
uint32_t frameLength (Camera *cam);
char *getVersion (Camera *cam);
uint8_t available();
uint8_t getDownsize(void);
bool setDownsize(uint8_t);
int getImageSize (Camera *cam);
bool setImageSize (Camera *cam, int size);
bool getMotionDetect (Camera *cam);
byte getMotionStatus(Camera *cam, byte x);
bool motionDetected (Camera *cam);
bool setMotionDetect (bool flag);
bool setMotionStatus (byte x, byte d1, byte d2);
byte getCompression (Camera *cam);
bool setCompression(Camera *cam, byte c);
bool getPTZ(Camera *cam, uint16_t *w, uint16_t *h, uint16_t *wz, uint16_t *hz, uint16_t *pan, uint16_t *tilt);
bool setPTZ(Camera *cam, uint16_t wz, uint16_t hz, uint16_t pan, uint16_t tilt);
```
## Typedefs
### byte
```c
typedef uint8_t byte;
```
### Camera
```c
typedef struct {
int fd; // file descriptor for the serial port
byte serialNum; // camera serial number
byte buff[BUFF_SIZE]; // byte array to store camera data
int bufferLen; // current length of data in buffer
uint16_t frameptr;
} Camera;
```
|