Skip to content

Commit 509ed98

Browse files
committed
now it's a bus!
1 parent 09b86ab commit 509ed98

7 files changed

Lines changed: 117 additions & 135 deletions

File tree

examples/get_position/get_position.ino

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,20 @@
11
#include "Arduino.h"
22
#include <Pelco_And_Arduino.h>
33

4-
5-
6-
PelcoCam MyPelcoCam(01, //Address of the camera
7-
PELCO_D9600,//Config
8-
6, //TX pin (Arduino to Cam)
9-
7, //RX pin (Cam to Arduino)
10-
false, //Enable logging?
11-
8); // RE pin for manual switching modules set to -1 if it is a auto module (like a groove one)
4+
PelcoCamBus MyPelcoBus(6, // TX pin (Arduino to Cam)
5+
7, // RX pin (Cam to Arduino)
6+
8); // RE pin for manual switching modules set to -1 if it is a auto module (like a groove one)
127

138
void setup() {
149

1510
Serial.begin(9600);
16-
11+
1712
// Begin the serial communication
18-
MyPelcoCam.begin();
13+
MyPelcoBus.begin(PELCO_D9600, true);
1914

20-
2115
// Send stop, send_command will return a bool that indicates if the cameras sended its ACK
2216
// It's a good way to see if the camera is plugged in
23-
while (!MyPelcoCam.send_command(STOP)) {
17+
while (!MyPelcoBus.send_command(1, STOP)) {
2418
Serial.println("Camera not plugged?");
2519
delay(1000);
2620
}
@@ -31,10 +25,10 @@ void loop() {
3125
// loops the camera increment angle of 1°; very fun because it shakes like hell
3226
int i = 0;
3327
for (i = 0; i < 35999; i = i + 100) {
34-
MyPelcoCam.send_command(SET_PAN, i); // Hundered of degrees, max is 35999 == 359,99°
28+
MyPelcoBus.send_command(1, SET_PAN, i); // Hundered of degrees, max is 35999 == 359,99°
3529
delay(1000);
3630

37-
int angle100 = MyPelcoCam.send_request(QUERY_PAN); // Get the current angle of the camera
31+
int angle100 = MyPelcoBus.send_request(1, QUERY_PAN); // Get the current angle of the camera
3832

3933
float angle = angle100 / 100.0; // Convert to float
4034

examples/send_raw/send_raw.ino

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
#include "Arduino.h"
22
#include <Pelco_And_Arduino.h>
33

4-
PelcoCam MyPelcoCam(01, //Address of the camera
5-
PELCO_D9600,//Config
6-
7, //RX pin (Cam to Arduino)
7-
6, //TX pin (Arduino to Cam)
8-
true, //Enable logging?
9-
8); // RE pin for manual switching modules set to -1 if it is a auto module (like a groove one)
4+
PelcoCamBus MyPelcoBus(6, // TX pin (Arduino to Cam)
5+
7, // RX pin (Cam to Arduino)
6+
8); // RE pin for manual switching modules set to -1 if it is a auto module (like a groove one)
107

118
void setup() {
9+
1210
Serial.begin(9600);
1311

14-
//Begin the serial communication
15-
MyPelcoCam.begin();
12+
// Begin the serial communication
13+
MyPelcoBus.begin(PELCO_D9600, true);
1614

17-
//Send stop, send_command will return a bool that indicates if the cameras sended its ACK
18-
//It's a good way to see if the camera is plugged in
19-
while (!MyPelcoCam.send_command(STOP)) {
15+
// Send stop, send_command will return a bool that indicates if the cameras sended its ACK
16+
// It's a good way to see if the camera is plugged in
17+
while (!MyPelcoBus.send_command(1, STOP)) {
2018
Serial.println("Camera not plugged?");
2119
delay(1000);
2220
}
@@ -26,8 +24,8 @@ void setup() {
2624
void loop() {
2725
while(Serial.available()) {
2826
String in = Serial.readString(); //Read from the serial
29-
MyPelcoCam.send_raw(in); //Send the raw command to the cameras (adress can be another than the one declared in the object because it's raw transmission)
27+
MyPelcoBus.send_raw(in); //Send the raw command to the cameras (adress can be another than the one declared in the object because it's raw transmission)
3028
delay(500);
31-
MyPelcoCam.send_command(STOP); //Stop it after a while
29+
MyPelcoBus.send_command(1, STOP); //Stop it after a while
3230
}
3331
}

examples/set_position/set_position.ino

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
#include "Arduino.h"
22
#include <Pelco_And_Arduino.h>
33

4-
PelcoCam MyPelcoCam(01, //Address of the camera
5-
PELCO_D9600,//Config
6-
7, //RX pin (Cam to Arduino)
7-
6, //TX pin (Arduino to Cam)
8-
true, //Enable logging?
9-
8); // RE pin for manual switching modules set to -1 if it is a auto module (like a groove one)
4+
PelcoCamBus MyPelcoBus(6, // TX pin (Arduino to Cam)
5+
7, // RX pin (Cam to Arduino)
6+
8); // RE pin for manual switching modules set to -1 if it is a auto module (like a groove one)
107

118
void setup() {
9+
1210
Serial.begin(9600);
1311

14-
//Begin the serial communication
15-
MyPelcoCam.begin();
12+
// Begin the serial communication
13+
MyPelcoBus.begin(PELCO_D9600, true);
1614

17-
//Send stop, send_command will return a bool that indicates if the cameras sended its ACK
18-
//It's a good way to see if the camera is plugged in
19-
while (!MyPelcoCam.send_command(STOP)) {
15+
// Send stop, send_command will return a bool that indicates if the cameras sended its ACK
16+
// It's a good way to see if the camera is plugged in
17+
while (!MyPelcoBus.send_command(1, STOP)) {
2018
Serial.println("Camera not plugged?");
2119
delay(1000);
2220
}
@@ -27,7 +25,7 @@ void loop() {
2725
//loops the camera increment angle of 1°; very fun because it shakes like hell
2826
int i=0;
2927
for(i=0; i<35999; i=i+100){
30-
MyPelcoCam.send_command(SET_PAN, i); //Hundered of degrees, max is 35999 == 359,99°
28+
MyPelcoBus.send_command(SET_PAN, i); //Hundered of degrees, max is 35999 == 359,99°
3129
delay(500);
3230
}
3331

examples/simple/simple.ino

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
#include "Arduino.h"
22
#include <Pelco_And_Arduino.h>
33

4-
PelcoCam MyPelcoCam(01, //Address of the camera
5-
PELCO_D9600,//Config
6-
7, //RX pin (Cam to Arduino)
7-
6, //TX pin (Arduino to Cam)
8-
true, //Enable logging?
9-
8); // RE pin for manual switching modules set to -1 if it is a auto module (like a groove one)
4+
PelcoCamBus MyPelcoBus(6, // TX pin (Arduino to Cam)
5+
7, // RX pin (Cam to Arduino)
6+
8); // RE pin for manual switching modules set to -1 if it is a auto module (like a groove one)
107

118
void setup() {
9+
1210
Serial.begin(9600);
1311

14-
//Begin the serial communication
15-
MyPelcoCam.begin();
12+
// Begin the serial communication
13+
MyPelcoBus.begin(PELCO_D9600, true);
1614

17-
//Send stop, send_command will return a bool that indicates if the cameras sended its ACK
18-
//It's a good way to see if the camera is plugged in
19-
while (!MyPelcoCam.send_command(STOP)) {
15+
// Send stop, send_command will return a bool that indicates if the cameras sended its ACK
16+
// It's a good way to see if the camera is plugged in
17+
while (!MyPelcoBus.send_command(1, STOP)) {
2018
Serial.println("Camera not plugged?");
2119
delay(1000);
2220
}
@@ -26,13 +24,13 @@ void setup() {
2624
void loop() {
2725

2826
//Pan to the left with max speed before turbo
29-
MyPelcoCam.send_command(PAN_L, 0x3F);
27+
MyPelcoBus.send_command(1, PAN_L, 0x3F);
3028
delay(1000);
31-
MyPelcoCam.send_command(STOP); //Stop the camera
29+
MyPelcoBus.send_command(1, STOP); //Stop the camera
3230
delay(1000);
3331
//Pan to the left with less speed than the tilt speed that goes up
34-
MyPelcoCam.send_command(PAN_L_TILT_U, 0x10, 0xFF);
32+
MyPelcoBus.send_command(1, PAN_L_TILT_U, 0x10, 0xFF);
3533
delay(1000);
36-
MyPelcoCam.send_command(STOP); //Stop the camera
34+
MyPelcoBus.send_command(1, STOP); //Stop the camera
3735
delay(1000);
3836
}

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Pelco_And_Arduino
2-
version=1.1.0
2+
version=2.0.0
33
author=Boris Hilkens <pixelbo21@gmail.com>
44
maintainer=Boris Hilkens <pixelbo21@gmail.com>
55
sentence=This library makes Pelco cameras moves!

0 commit comments

Comments
 (0)