From f547bf09dc2a29d49016e2ec372524e31ab7b282 Mon Sep 17 00:00:00 2001 From: witnessmenow Date: Sun, 1 Oct 2017 16:44:03 +0100 Subject: [PATCH] Forgot to add examples to last commit --- examples/HID_MOUSE/HID_MOUSE.ino | 12 ++++---- examples/HID_MOUSE_WHEEL/HID_MOUSE_WHEEL.ino | 8 +++-- .../SPP_SEND_REC_MSG/SPP_SEND_REC_MSG.ino | 29 ++++++++++++------- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/examples/HID_MOUSE/HID_MOUSE.ino b/examples/HID_MOUSE/HID_MOUSE.ino index 531ed81..a3f056d 100644 --- a/examples/HID_MOUSE/HID_MOUSE.ino +++ b/examples/HID_MOUSE/HID_MOUSE.ino @@ -7,17 +7,19 @@ This example illustrated how the library can be used to make mouse movements and #include -BPLib BPMod; +BPLib *BPMod; void setup(){ -BPMod.begin(BP_MODE_HID,BP_HID_MOUSE); - + Serial.begin(115200); + BPMod = new BPLib(swSer); + BPMod->begin(BP_MODE_HID,BP_HID_MOUSE); + } void loop(){ delay(1000); for(signed int i=-127;i<127;i++){ - BPMod.mouseMove(i,i); + BPMod->mouseMove(i,i); delay(100); } - BPMod.mouseClick(BP_MOUSE_BTN_LEFT); + BPMod->mouseClick(BP_MOUSE_BTN_LEFT); } diff --git a/examples/HID_MOUSE_WHEEL/HID_MOUSE_WHEEL.ino b/examples/HID_MOUSE_WHEEL/HID_MOUSE_WHEEL.ino index 485276c..256e9e2 100644 --- a/examples/HID_MOUSE_WHEEL/HID_MOUSE_WHEEL.ino +++ b/examples/HID_MOUSE_WHEEL/HID_MOUSE_WHEEL.ino @@ -7,15 +7,17 @@ This example illustrated the use of the Bluetooth Mouse Wheel (Scrolling). #include -BPLib BPMod; +BPLib *BPMod; void setup(){ -BPMod.begin(BP_MODE_HID,BP_HID_MOUSE); + Serial.begin(115200); + BPMod = new BPLib(swSer); + BPMod->begin(BP_MODE_HID,BP_HID_MOUSE); } void loop(){ delay(5000); for(signed int i=-5;i<5;i++){ - BPMod.mouseWheel(i); + BPMod->mouseWheel(i); delay(100); } } diff --git a/examples/SPP_SEND_REC_MSG/SPP_SEND_REC_MSG.ino b/examples/SPP_SEND_REC_MSG/SPP_SEND_REC_MSG.ino index b1517a5..c35f0ca 100644 --- a/examples/SPP_SEND_REC_MSG/SPP_SEND_REC_MSG.ino +++ b/examples/SPP_SEND_REC_MSG/SPP_SEND_REC_MSG.ino @@ -8,25 +8,32 @@ This example illustrates the use of the bluetooth serial protocol. #include -BPLib BPMod; +BPLib *BPMod; int count = 0; void setup(){ - BPMod.begin(BP_MODE_SPP,BP_SPP_SPP); //Bluetooth Serial Mode - BPMod.changeName("BlueNar_One"); //Change bluetooth name (appears on devices searching for BT) - while(!BPMod.connected()){}; //BlueNar One only! Check if a connection is made + Serial.begin(115200); + + // The 7 pin was something that was previously hard coded into the library, its state gets read by the connected method + // I'm not really sure what it does :) + // I guess it has something to do with "BlueNar One only" comments + pinMode(7, INPUT); + BPMod = new BPLib(swSer, 7); + BPMod->begin(BP_MODE_SPP,BP_SPP_SPP); //Bluetooth Serial Mode + BPMod->changeName("BlueNar_One"); //Change bluetooth name (appears on devices searching for BT) + while(!BPMod->connected()){}; //BlueNar One only! Check if a connection is made } void loop(){ - if(BPMod.connected()){ //BlueNar One only! if connected then proceed - if(BPMod.available()>0){ //Check if data is available - BPMod.readRaw(); //Read the data (just to empty the buffer) + if(BPMod->connected()){ //BlueNar One only! if connected then proceed + if(BPMod->available()>0){ //Check if data is available + BPMod->readRaw(); //Read the data (just to empty the buffer) count++; - BPMod.sendString("Count: "); //Send a string - BPMod.sendInt(count); //Send a integer - BPMod.sendChar('\n'); //Send character + BPMod->sendString("Count: "); //Send a string + BPMod->sendInt(count); //Send a integer + BPMod->sendChar('\n'); //Send character } } else{ - while(!BPMod.connected()){}; //BlueNar One only! - If disconnected wait for a new connection + while(!BPMod->connected()){}; //BlueNar One only! - If disconnected wait for a new connection } }