Skip to content

Commit

Permalink
adding IO wrappers to the BowlerCOm object
Browse files Browse the repository at this point in the history
  • Loading branch information
madhephaestus committed Jul 25, 2016
1 parent 86a6e00 commit 39df214
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 17 deletions.
13 changes: 8 additions & 5 deletions examples/BowlerCom/BowlerCom.ino
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
*/
int baudrate = 9600;
#include <BowlerCom.h>

int txPin =11;
int rxPin =10;
BowlerCom com;
SoftwareSerial mySerial(10,11); // RX, TX
SoftwareSerial mySerial(rxPin,txPin); // RX, TX

boolean on=false;

Expand All @@ -29,6 +30,10 @@ void setup() {
setPrintLevelInfoPrint();

println_E("Adding namespaces");
// ensure DyIO leaves these pins alone
_EEWriteMode(txPin, IS_DEBUG_TX);
_EEWriteMode(rxPin, IS_DEBUG_RX);
// start dyio framework and load DyIO namespace
com.addDyIO();
//setMode(11,IS_DEBUG_TX);
setMode(13,IS_DO);
Expand All @@ -40,10 +45,8 @@ void setup() {

void loop() {
com.server();
SetChanVal(13, on?1:0, 0);
SetChanVal(13, (on=!on)?1:0, 0);

//on=!on;
//println_I("Bowlewr Server");
}


8 changes: 7 additions & 1 deletion kewords.txt
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
BowlerCom KEYWORD1 BowlerCom
BowlerCom KEYWORD1 BowlerCom

SetChanVal KEYWORD2 SetChanVal
GetChanVal KEYWORD2 GetChanVal
setMode KEYWORD2 setMode

startDebugPint KEYWORD3 startDebugPint
18 changes: 18 additions & 0 deletions src/BowlerCom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,24 @@ BowlerCom::BowlerCom()
comPort=NULL;
Bowler_Init();
}
/**
* This Function is used to alter the mode of the pin (See DYIO_def.h for modes)
* Setting the higest bit (|=0x80) will enable the mode as async
*
* @param pin The pin refers to the dyio channel to be altered
* @param mode the mode to set the pin to
* @return If the mode change was successfull
*/
boolean BowlerCom::setMode(uint8_t pin,uint8_t mode){
return setMode(pin,mode);
}

boolean BowlerCom::SetChanVal(uint8_t pin, int32_t bval, float time){
return SetChanVal(pin,bval,time);
}
int32_t BowlerCom::GetChanVal(uint8_t pin){
return GetChanVal(pin);
}

/* begin method for overriding default serial bitrate */
void BowlerCom::begin(Stream * port) {
Expand Down
11 changes: 11 additions & 0 deletions src/BowlerCom.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ void startDebugPint(Stream * port);
byte privateRXCom[comBuffSize];
BYTE_FIFO_STORAGE store;
BowlerPacket Packet;
boolean SetChanVal(uint8_t pin, int32_t bval, float time);
int32_t GetChanVal(uint8_t pin);
/**
* This Function is used to alter the mode of the pin (See DYIO_def.h for modes)
* Setting the higest bit (|=0x80) will enable the mode as async
*
* @param pin The pin refers to the dyio channel to be altered
* @param mode the mode to set the pin to
* @return If the mode change was successfull
*/
boolean setMode(uint8_t pin,uint8_t mode);
private:
boolean addedDyIO;
boolean addedPID;
Expand Down
22 changes: 11 additions & 11 deletions src/PinFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ boolean setMode(uint8_t pin, uint8_t mode) {

switch (GetChannelMode(pin)) {
case IS_DI:
//pinMode(PIN_TO_DIGITAL(pin), INPUT);
pinMode(PIN_TO_DIGITAL(pin), INPUT);
digitalWrite(pin, HIGH); // turn on pullup resistors
break;
case IS_DO:
//pinMode(PIN_TO_DIGITAL(pin), OUTPUT);
pinMode(PIN_TO_DIGITAL(pin), OUTPUT);
break;
case IS_ANALOG_IN:
// arduino analogs are not changable
break;
case IS_SERVO:
//myservo[PIN_TO_SERVO(pin)].attach(PIN_TO_SERVO(pin));
myservo[PIN_TO_SERVO(pin)].attach(PIN_TO_SERVO(pin));
break;
case IS_DEBUG_TX:
// pinMode(PIN_TO_DIGITAL(pin), OUTPUT);
Expand All @@ -73,10 +73,10 @@ boolean setMode(uint8_t pin, uint8_t mode) {

return true;
}
println_E("CAN NOT BE MODE Pin ");
p_int_E(pin);
print_E(" to New Mode ");
printMode(pin, mode, ERROR_PRINT);
println_I("CAN NOT BE MODE Pin ");
p_int_I(pin);
print_I(" to New Mode ");
printMode(pin, mode, INFO_PRINT);
return false;
}

Expand Down Expand Up @@ -183,10 +183,10 @@ boolean SetChanVal(uint8_t pin, int32_t bval, float time) {
if (pin < 2) {
return true;
}
print_W("\r\n");
p_int_E(pin);
print_W(" Set value of pin to ");
p_int_W(bval);
// print_W("\r\n");
// p_int_E(pin);
// print_W(" Set value of pin to ");
// p_int_W(bval);
switch (GetChannelMode(pin)) {

case IS_DO:
Expand Down

0 comments on commit 39df214

Please sign in to comment.