-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding dynamic topics based on basetopic Added Documentation file
- Loading branch information
Showing
7 changed files
with
318 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ | |
.vscode/launch.json | ||
.vscode/ipch | ||
.vscode/ | ||
data/* | ||
orig/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,8 @@ platform = espressif8266 | |
board = d1_mini | ||
framework = arduino | ||
upload_protocol = espota | ||
upload_port = 192.168.2.154 | ||
monitor_speed = 115200 | ||
upload_port = 10.0.30.23 | ||
monitor_speed = 9600 | ||
lib_deps = | ||
ESP8266WiFi | ||
ESP8266WebServer | ||
|
@@ -23,6 +23,4 @@ lib_deps = | |
PubSubClient | ||
tzapu/WiFiManager@^0.15.0 | ||
ArduinoOTA | ||
|
||
lib_deps_external = | ||
plerup/[email protected] ; this version compiles with a standard 8266 platform | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include <Arduino.h> | ||
#pragma once | ||
#define MAXX 800 | ||
#define MAXY 212 | ||
#define MAXZ 2305 | ||
#define MAXF 65535 | ||
#define NUM_CAMS 7 | ||
|
||
|
||
class PTZCam { | ||
public: | ||
// Constructor | ||
PTZCam(int xValue = MAXX / 2, int yValue = MAXY / 2, int zValue = MAXZ / 2, | ||
int focusValue = MAXF / 2) | ||
: x(xValue), y(yValue), z(zValue), focus(focusValue) {} | ||
|
||
// Getter methods | ||
int getX() const { return x; } | ||
int getY() const { return y; } | ||
int getZ() const { return z; } | ||
int getFocus() const { return focus; } | ||
|
||
// Setter methods | ||
void setX(int newX) { | ||
newX = constrain(newX, 0, MAXX); | ||
x = newX; | ||
} | ||
void setY(int newY) { | ||
newY = constrain(newY, 0, MAXY); | ||
y = newY; | ||
} | ||
void setZ(int newZ) { | ||
newZ = constrain(newZ, 0, MAXZ); | ||
z = newZ; | ||
} | ||
void setFocus(int newFocus) { | ||
newFocus = constrain(newFocus, -1, MAXF); | ||
focus = newFocus; | ||
} | ||
|
||
private: | ||
int x; | ||
int y; | ||
int z; | ||
int focus; | ||
}; | ||
|
||
extern PTZCam cams[NUM_CAMS]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
#include <Arduino.h> | ||
#include <camera.h> | ||
#include <commands.h> | ||
|
||
PTZCam cams[NUM_CAMS]; | ||
|
||
|
||
VISCACommand makePackage(byte* payload, uint8_t length, uint8_t camNum) { | ||
VISCACommand cmd; | ||
uint8_t charCount = 0; | ||
cmd.payload[charCount++] = 0x81 + camNum; | ||
for (uint8_t i = 0; i < length; i++) { | ||
cmd.payload[charCount++] = payload[i]; | ||
} | ||
cmd.payload[charCount++] = 0xFF; | ||
cmd.len = charCount; | ||
return cmd; | ||
} | ||
VISCACommand blinkenlights(uint8_t led, uint8_t mode, uint8_t cam) { | ||
byte cmd[] = {0x01, 0x33, led, mode}; | ||
VISCACommand command = makePackage(cmd, sizeof(cmd), cam); | ||
return command; | ||
} | ||
|
||
VISCACommand flip(bool setting, uint8_t cam) { | ||
byte cmd[] = {0x01, 0x04, 0x66, (setting ? 0x02 : 0x03)}; | ||
VISCACommand command = makePackage(cmd, sizeof(cmd), cam); | ||
return command; | ||
} | ||
VISCACommand mirror(bool setting, uint8_t cam) { | ||
byte cmd[] = {0x01, 0x04, 0x61, (setting ? 0x02 : 0x03)}; | ||
VISCACommand command = makePackage(cmd, sizeof(cmd), cam); | ||
return command; | ||
} | ||
VISCACommand backlight(bool setting, uint8_t cam) { | ||
byte cmd[] = {0x01, 0x04, 0x33, 0x02, (setting ? 0x02 : 0x03)}; | ||
VISCACommand command = makePackage(cmd, sizeof(cmd), cam); | ||
return command; | ||
} | ||
VISCACommand mmdetect(bool setting, uint8_t cam) { | ||
byte cmd[] = {0x01, 0x50, 0x30, 0x01, setting}; | ||
VISCACommand command = makePackage(cmd, sizeof(cmd), cam); | ||
return command; | ||
} | ||
void convertValues(uint input, byte* output) { | ||
output[0] = (input >> 12) & 0x0f; | ||
output[1] = (input >> 8) & 0x0f; | ||
output[2] = (input >> 4) & 0x0f; | ||
output[3] = input & 0x0f; | ||
} | ||
VISCACommand wb(int setting, uint8_t cam) { | ||
byte wbValues[4]; | ||
convertValues(setting, wbValues); | ||
byte cmd[] = { | ||
0x01, 0x04, 0x35, (setting <= -1 ? 0x00 : 0x06), | ||
0xff, 0x81 + cam, 0x01, 0x04, | ||
0x75, wbValues[0], wbValues[1], wbValues[2], | ||
wbValues[3]}; | ||
VISCACommand command = makePackage(cmd, sizeof(cmd), cam); | ||
return command; | ||
} | ||
VISCACommand iris(int setting, uint8_t cam) { | ||
byte irisValues[4]; | ||
convertValues(setting, irisValues); | ||
byte cmd[] = {0x01, 0x04, | ||
0x39, (setting <= -1 ? 0x00 : 0x03), | ||
0xff, 0x81 + cam, | ||
0x01, 0x04, | ||
0x4b, irisValues[0], | ||
irisValues[1], irisValues[2], | ||
irisValues[3]}; | ||
VISCACommand command = makePackage(cmd, sizeof(cmd), cam); | ||
return command; | ||
} | ||
|
||
VISCACommand relativeMovement(int x, int y, uint8_t cam) { | ||
// 01 06 01 0p 0t 03 01 | ||
|
||
byte panDirection = 0x03; | ||
byte tiltDirection = 0x03; | ||
|
||
if (x > 0) { | ||
panDirection = 0x02; | ||
} | ||
if (x < 0) { | ||
panDirection = 0x01; | ||
} | ||
|
||
if (y > 0) { | ||
tiltDirection = 0x02; | ||
} | ||
if (y < 0) { | ||
tiltDirection = 0x01; | ||
} | ||
|
||
byte panSpeed = map(abs(x), 0, 100, 0x00, 0x1f); | ||
byte tiltSpeed = map(abs(y), 0, 100, 0x00, 0x1f); | ||
|
||
byte cmd[] = {0x01, 0x06, 0x01, 0x00, 0x00, 0x03, 0x03, 0xff, 0x81+cam, 0x01, 0x06, 0x01, panSpeed, | ||
tiltSpeed, panDirection, tiltDirection}; | ||
VISCACommand command = makePackage(cmd, sizeof(cmd), cam); | ||
return command; | ||
} | ||
VISCACommand movement(uint8_t cam) { | ||
Serial.println(cams[cam].getX()); | ||
const uint x = cams[cam].getX(); | ||
const uint y = cams[cam].getY(); | ||
const uint z = cams[cam].getZ(); | ||
const uint focus = cams[cam].getFocus(); | ||
|
||
byte xValues[4]; | ||
convertValues(x, xValues); | ||
|
||
byte yValues[4]; | ||
convertValues(y, yValues); | ||
|
||
byte zValues[4]; | ||
convertValues(z, zValues); | ||
|
||
byte focusValues[4]; | ||
convertValues(focus, focusValues); | ||
|
||
byte cmd[] = {0x01, 0x04, | ||
0x38, (focus == -1 ? 0x02 : 0x03), | ||
0xff, (0x81 + cam), | ||
0x01, 0x06, | ||
0x01, 0x03, | ||
0x03, 0x03, | ||
0x03, 0xff, | ||
(0x81 + cam), 0x01, | ||
0x06, 0x20, | ||
xValues[0], xValues[1], | ||
xValues[2], xValues[3], | ||
|
||
yValues[0], yValues[1], | ||
yValues[2], yValues[3], | ||
zValues[0], zValues[1], | ||
zValues[2], zValues[3], | ||
focusValues[0], focusValues[1], | ||
focusValues[2], focusValues[3]}; | ||
VISCACommand command = makePackage(cmd, sizeof(cmd), cam); | ||
|
||
return command; | ||
} | ||
|
||
void requestEverything() { | ||
// 8x 09 06 12 ff request PT | ||
// | ||
byte cmd[] = {0x81, 0x09, 0x06, 0x12, 0xFF}; | ||
for (uint8_t i = 0; i < NUM_CAMS; i++) { | ||
cmd[0] = 0x81 + i; | ||
Serial.write(cmd, sizeof(cmd)); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
#include <camera.h> | ||
#define VISCACOMMAND_MAX_LENGTH 128 | ||
|
||
struct VISCACommand { | ||
uint8_t len; | ||
uint8_t payload[VISCACOMMAND_MAX_LENGTH]; | ||
}; | ||
|
||
void convertValues(uint input, byte* output); | ||
void parseCommand(uint8_t* command, int length); | ||
void requestEverything(); | ||
void handleSerial(); | ||
|
||
VISCACommand makePackage(byte* payload, uint8_t length, uint8_t camNum); | ||
VISCACommand blinkenlights(uint8_t led = 0, uint8_t mode = 0, uint8_t cam = 0); | ||
VISCACommand flip(bool setting = 0, uint8_t cam = 0); | ||
VISCACommand mirror(bool setting = 0, uint8_t cam = 0); | ||
VISCACommand backlight(bool setting = 0, uint8_t cam = 0); | ||
VISCACommand mmdetect(bool setting = 0, uint8_t cam = 0); | ||
VISCACommand wb(int setting = 0, uint8_t cam = 0); | ||
VISCACommand iris(int setting = 0, uint8_t cam = 0); | ||
VISCACommand relativeMovement(int x, int y, uint8_t cam = 0); | ||
|
||
VISCACommand movement(uint8_t cam = 0); |
Oops, something went wrong.