Skip to content

Commit

Permalink
Forgot to add examples to last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
witnessmenow committed Oct 1, 2017
1 parent 06f624a commit f547bf0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 19 deletions.
12 changes: 7 additions & 5 deletions examples/HID_MOUSE/HID_MOUSE.ino
Expand Up @@ -7,17 +7,19 @@ This example illustrated how the library can be used to make mouse movements and

#include <BPLib.h>

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);
}
8 changes: 5 additions & 3 deletions examples/HID_MOUSE_WHEEL/HID_MOUSE_WHEEL.ino
Expand Up @@ -7,15 +7,17 @@ This example illustrated the use of the Bluetooth Mouse Wheel (Scrolling).

#include <BPLib.h>

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);
}
}
29 changes: 18 additions & 11 deletions examples/SPP_SEND_REC_MSG/SPP_SEND_REC_MSG.ino
Expand Up @@ -8,25 +8,32 @@ This example illustrates the use of the bluetooth serial protocol.

#include <BPLib.h>

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
}
}

0 comments on commit f547bf0

Please sign in to comment.