1313#include < SoftwareSerial.h>
1414
1515#include " Arduino.h"
16- #include " constants.h"
1716
17+ #include " constants.h"
1818#include " PelcoCam.h"
1919
20+
2021// Only serves as a wrapper for the PelcoBus class
2122
22- PelcoCam::PelcoCam (uint8_t address, bool disable_ack): PelcoBus(PelcoBus::rxPin_, PelcoBus::txPin_, PelcoBus::rePin_){
23+ PelcoCam::PelcoCam (PelcoBus *bus, uint8_t address, bool disable_ack = false ){
24+ bus_ = bus; // Get the address (pointer) of the PelcoBus class
2325 address_ = address;
2426 disable_ack_ = disable_ack;
2527}
@@ -34,17 +36,12 @@ bool PelcoCam::available() { // Returns true if there's a ACK
3436 }
3537 return false ;
3638 }
37- return PelcoBus:: command (address_, disable_ack_, DUMMY);
39+ return bus_-> command (address_, disable_ack_, DUMMY);
3840
3941}
4042
41- bool PelcoCam::send_command (uint8_t command, uint16_t data1 = 0x00 , uint8_t data2 = 0x00 ) {
42- Serial.print (" ah" );
43- Serial.print (log_buffer);
44- delay (1000 );
45- Serial.println (" bbbb" );
46- bool test = PelcoBus::command (address_, disable_ack_, command, data1, data2);
47- return test;
43+ bool PelcoCam::send_command (uint8_t command=STOP, uint16_t data1 = 0x00 , uint8_t data2 = 0x00 ) {
44+ return bus_->command (address_, disable_ack_, command, data1, data2);
4845}
4946
5047uint16_t PelcoCam::send_request (uint8_t request, uint16_t timeout = 1000 ) {
@@ -58,5 +55,5 @@ uint16_t PelcoCam::send_request(uint8_t request, uint16_t timeout = 1000) {
5855 return 0 ;
5956 }
6057
61- return PelcoBus:: request (address_, request, timeout);
58+ return bus_-> request (address_, request, timeout);
6259}
0 commit comments