Skip to content

Commit 5c4c436

Browse files
authored
Merge pull request #2 from Pixelbo/test-class
Merge test-class for main release
2 parents 0bfa197 + dddb97a commit 5c4c436

17 files changed

Lines changed: 534 additions & 291 deletions

File tree

Protocol and errors.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ The acknoledge data that you received isn't right, the address byte isn't the on
5555

5656
The acknoledge data that you received isn't right, the null byte (the third one) isn't detected by the program
5757

58-
"Cam %i: ERROR Could not verify camera ACK: bad checksum (is camera well plugged in?)\n",
58+
"Cam 1: ERROR Could not verify camera ACK: bad checksum (is camera well plugged in?)\n",
5959

6060
The acknoledge data that you received isn't right, the checksum byte isn't good
6161

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

4-
PelcoBus 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)
4+
PelcoBus MyPelcoBus(6, // RX pin (Cam to Arduino)
5+
7, // TX pin (Arduino to Cam)
6+
8); // RE pin for manual switching modules set to -1 or nothing if it is a auto module (like a groove one)
77

8-
PelcoBus::PelcoCam Camera1; //Declare a camera
8+
9+
PelcoCam Camera1(&MyPelcoBus, //The pointer to the bus
10+
1, //Address of the camera
11+
false); //We are getting a response
912

1013
void setup() {
1114
Serial.begin(9600);
1215

13-
// Begin the serial communication
14-
MyPelcoBus.begin(PELCO_D9600, true);
16+
// Begin the bus communication at 9600 and disable logging
17+
MyPelcoBus.begin(PELCO_D9600, false);
1518

16-
// Set camera settings
17-
Camera1.address = 1; //Address of the camera
18-
Camera1.disable_ack = false; //For this exemple, this must set to false!
19-
20-
21-
// Send stop, send_command will return a bool that indicates if the cameras sended its ACK
22-
// It's a good way to see if the camera is plugged in
23-
while (!MyPelcoBus.send_command(Camera1, STOP)) {
19+
//Is the camera online?
20+
while (!Camera1.available()) {
2421
Serial.println("Camera not plugged?");
2522
delay(1000);
2623
}
2724
Serial.println("Init Finished!");
2825
}
2926

3027
void loop() {
31-
MyPelcoBus.send_command(Camera1, PAN_L, 0x3F); // Spin for a random time
32-
delay(random(1000, 2000));
28+
Camera1.send_command(SET_PAN, random(0, 35999)); // set pan to a random angle
3329

34-
int angle100 = MyPelcoBus.send_request(Camera1, QUERY_PAN); // Get the current angle of the camera
30+
int angle100 = Camera1.send_request(QUERY_PAN); // Get the current angle of the camera
3531

3632
float angle = angle100 / 100.0; // Convert to float
3733

3834
Serial.println("Angle detected: " + String(angle));
35+
delay(200);
3936
}

examples/old_model/old_model.ino

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

4-
PelcoBus 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)
4+
PelcoBus MyPelcoBus(6, // RX pin (Cam to Arduino)
5+
7, // TX pin (Arduino to Cam)
6+
8); // RE pin for manual switching modules set to -1 or nothing if it is a auto module (like a groove one)
77

8-
PelcoBus::PelcoCam Camera1; //Declare a camera
8+
////IMPORTANT: Even if it is an old model without returning a response capabilities you need to specify a RX pin and a RE pin
9+
10+
PelcoCam Camera1(&MyPelcoBus, //The pointer to the bus
11+
1, //Address of the camera
12+
true); //We are NOT getting a response
913

1014
void setup() {
1115
Serial.begin(9600);
1216

13-
// Begin the serial communication
17+
// Begin the bus communication at 9600 and enable logging
1418
MyPelcoBus.begin(PELCO_D9600, true);
1519

16-
// Set camera settings
17-
Camera1.address = 1; //Address of the camera
18-
Camera1.disable_ack = true; //Old models function one 2 pair of wires and only one is usable, the TX one, so it's impossible that it can send back a reqponse
19-
20-
21-
// Send stop, send_command will return a bool that indicates if the cameras sended its ACK
22-
// It's a good way to see if the camera is plugged in
23-
while (!MyPelcoBus.send_command(Camera1, STOP)) {
20+
//Is the camera online? this will fail because it is an old models
21+
while (!Camera1.available()/* <---- will fail! */) {
2422
Serial.println("Camera not plugged?");
2523
delay(1000);
2624
}
@@ -30,13 +28,13 @@ void setup() {
3028
void loop() {
3129

3230
//Pan to the left with max speed before turbo
33-
MyPelcoBus.send_command(Camera1, PAN_L, 0x3F);
31+
Camera1.send_command(PAN_L, 0x3F);
3432
delay(1000);
35-
MyPelcoBus.send_command(Camera1, STOP); //Stop the camera
33+
Camera1.send_command(STOP); //Stop the camera
3634
delay(1000);
3735
//Pan to the left with less speed than the tilt speed that goes up
38-
MyPelcoBus.send_command(Camera1, PAN_R, 0x3F);
36+
Camera1.send_command(PAN_R, 0x3F);
3937
delay(1000);
40-
MyPelcoBus.send_command(Camera1, STOP); //Stop the camera
38+
Camera1.send_command(STOP); //Stop the camera
4139
delay(1000);
4240
}

examples/send_raw/send_raw.ino

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

4-
PelcoBus 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)
4+
PelcoBus MyPelcoBus(6, // RX pin (Cam to Arduino)
5+
7, // TX pin (Arduino to Cam)
6+
8); // RE pin for manual switching modules set to -1 or nothing if it is a auto module (like a groove one)
77

8-
void setup() {
9-
//Here we don't need to declare a camera because all we send is raw
108

9+
//No need to declare a camera here
10+
11+
void setup() {
1112
Serial.begin(9600);
1213

13-
// Begin the serial communication
14+
// Begin the bus communication at 9600 and enable logging
1415
MyPelcoBus.begin(PELCO_D9600, true);
1516

1617
Serial.println("Init Finished!");

examples/set_position/set_position.ino

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

4-
PelcoBus 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)
4+
PelcoBus MyPelcoBus(6, // RX pin (Cam to Arduino)
5+
7, // TX pin (Arduino to Cam)
6+
8); // RE pin for manual switching modules set to -1 or nothing if it is a auto module (like a groove one)
77

8-
PelcoBus::PelcoCam Camera1; //Declare a camera
8+
9+
PelcoCam Camera1(&MyPelcoBus, //The pointer to the bus
10+
1, //Address of the camera
11+
false); //We are getting a response
912

1013
void setup() {
1114
Serial.begin(9600);
1215

13-
// Begin the serial communication
16+
// Begin the bus communication at 9600 and enable logging
1417
MyPelcoBus.begin(PELCO_D9600, true);
1518

16-
// Set camera settings
17-
Camera1.address = 1; //Address of the camera
18-
Camera1.disable_ack = false; //If you want to disable the ACK, set it to true
19-
20-
21-
// Send stop, send_command will return a bool that indicates if the cameras sended its ACK
22-
// It's a good way to see if the camera is plugged in
23-
while (!MyPelcoBus.send_command(Camera1, STOP)) {
19+
//Is the camera online?
20+
while (!Camera1.available()) {
2421
Serial.println("Camera not plugged?");
2522
delay(1000);
2623
}
@@ -30,7 +27,7 @@ void setup() {
3027
void loop() {
3128
//loops the camera increment angle of 1°; very fun because it shakes like hell
3229
for(int i=0; i<35999; i=i+100){
33-
MyPelcoBus.send_command(Camera1, SET_PAN, i); //Hundered of degrees, max is 35999 == 359,99°
30+
Camera1.send_command(SET_PAN, i); //Hundered of degrees, max is 35999 == 359,99°
3431
delay(500);
3532
}
3633

examples/simple/simple.ino

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

4-
PelcoBus 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)
4+
PelcoBus MyPelcoBus(6, // RX pin (Cam to Arduino)
5+
7, // TX pin (Arduino to Cam)
6+
8); // RE pin for manual switching modules set to -1 or nothing if it is a auto module (like a groove one)
77

8-
PelcoBus::PelcoCam Camera1; //Declare a camera
8+
9+
PelcoCam Camera1(&MyPelcoBus, //The pointer to the bus
10+
1, //Address of the camera
11+
false); //We are getting a response
912

1013
void setup() {
1114
Serial.begin(9600);
1215

13-
// Begin the serial communication
16+
// Begin the bus communication at 9600 and enable logging
1417
MyPelcoBus.begin(PELCO_D9600, true);
1518

16-
// Set camera settings
17-
Camera1.address = 1; //Address of the camera
18-
Camera1.disable_ack = false; //If you want to disable the ACK, set it to true
19-
20-
21-
// Send stop, send_command will return a bool that indicates if the cameras sended its ACK
22-
// It's a good way to see if the camera is plugged in
23-
while (!MyPelcoBus.send_command(Camera1, STOP)) {
19+
//Is the camera online?
20+
while (!Camera1.available()) {
2421
Serial.println("Camera not plugged?");
2522
delay(1000);
2623
}
@@ -29,13 +26,13 @@ void setup() {
2926

3027
void loop() {
3128
//Pan to the left with max speed before turbo
32-
MyPelcoBus.send_command(Camera1, PAN_L, 0x3F);
29+
Camera1.send_command(PAN_L, 0x3F);
3330
delay(1000);
34-
MyPelcoBus.send_command(Camera1, STOP); //Stop the camera
31+
Camera1.send_command(STOP); //Stop the camera
3532
delay(1000);
3633
//Pan to the left with less speed than the tilt speed that goes up
37-
MyPelcoBus.send_command(Camera1, PAN_R, 0x3F);
34+
Camera1.send_command(PAN_R, 0x3F);
3835
delay(1000);
39-
MyPelcoBus.send_command(Camera1, STOP); //Stop the camera
36+
Camera1.send_command(STOP); //Stop the camera
4037
delay(1000);
4138
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include "Arduino.h"
2+
#include <Pelco_And_Arduino.h>
3+
4+
PelcoBus MyPelcoBus(6, // RX pin (Cam to Arduino)
5+
7); // TX pin (Arduino to Cam)
6+
7+
8+
PelcoCam Camera1(&MyPelcoBus, //The pointer to the bus
9+
1, //Address of the camera
10+
false); //We are getting a response
11+
12+
void setup() {
13+
Serial.begin(9600);
14+
15+
// Begin the bus communication at 9600 and enable logging
16+
MyPelcoBus.begin(PELCO_D9600, true);
17+
18+
//Is the camera online?
19+
while (!Camera1.available()) {
20+
Serial.println("Camera not plugged?");
21+
delay(1000);
22+
}
23+
Serial.println("Init Finished!");
24+
}
25+
26+
void loop() {
27+
//Pan to the left with max speed before turbo
28+
Camera1.send_command(PAN_L, 0x3F);
29+
delay(1000);
30+
Camera1.send_command(STOP); //Stop the camera
31+
delay(1000);
32+
//Pan to the left with less speed than the tilt speed that goes up
33+
Camera1.send_command(PAN_R, 0x3F);
34+
delay(1000);
35+
Camera1.send_command(STOP); //Stop the camera
36+
delay(1000);
37+
}

keywords.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#######################################
2-
# Syntax Coloring Map Servo
2+
# Syntax Coloring
33
#######################################
44

55
#######################################

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=2.1.0
2+
version=2.2.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)