Skip to content

Instantly share code, notes, and snippets.

@bilderbuchi
Created February 2, 2013 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bilderbuchi/4698218 to your computer and use it in GitHub Desktop.
Save bilderbuchi/4698218 to your computer and use it in GitHub Desktop.
My first gist
## Code style Gist for [PR 1](https://github.com/bilderbuchi/openFrameworks/pull/1)
The `.patch` file below contains the necessary changes for making sure your PR conforms to the [OF code style](https://github.com/openframeworks/openFrameworks/wiki/oF-code-style).
### Usage
Download the patch file via the Download button on the left (to make sure all formatting is preserved). Apply the patch to the clean tip of your PR branch with `git apply --index --whitespace=nowarn <patchfile>`. The changes will land in your git staging area, ready to commit.
Before that, you can test if the patch succeeds with `git apply --index --whitespace=nowarn --check <patchfile>`
If you have problems, comment in the PR.
diff --git a/examples/communication/serialExample/src/testApp.cpp b/examples/communication/serialExample/src/testApp.cpp
index 7aff852..07f6039 100644
--- a/examples/communication/serialExample/src/testApp.cpp
+++ b/examples/communication/serialExample/src/testApp.cpp
@@ -3,16 +3,16 @@
//--------------------------------------------------------------
void testApp::setup(){
ofSetVerticalSync(true);
-
+
bSendSerialMessage = false;
- ofBackground(255);
+ ofBackground(255);
ofSetLogLevel(OF_LOG_VERBOSE);
-
+
font.loadFont("DIN.otf", 64);
-
+
serial.listDevices();
vector <ofSerialDeviceInfo> deviceList = serial.getDeviceList();
-
+
// this should be set to whatever com port your serial device is connected to.
// (ie, COM4 on a pc, /dev/tty.... on linux, /dev/tty... on a mac)
// arduino users check in arduino app....
@@ -21,45 +21,45 @@ void testApp::setup(){
//serial.setup("COM4", baud); // windows example
//serial.setup("/dev/tty.usbserial-A4001JEC", baud); // mac osx example
//serial.setup("/dev/ttyUSB0", baud); //linux example
-
+
nTimesRead = 0;
- nBytesRead = 0;
- readTime=0;
+ nBytesRead = 0;
+ readTime = 0;
memset(bytesReadString, 0, 4);
}
//--------------------------------------------------------------
void testApp::update(){
-
- if (bSendSerialMessage){
-
+
+ if(bSendSerialMessage){
+
// (1) write the letter "a" to serial:
serial.writeByte('a');
-
+
// (2) read
// now we try to read 3 bytes
// since we might not get them all the time 3 - but sometimes 0, 6, or something else,
// we will try to read three bytes, as much as we can
// otherwise, we may have a "lag" if we don't read fast enough
- // or just read three every time. now, we will be sure to
+ // or just read three every time. now, we will be sure to
// read as much as we can in groups of three...
-
+
nTimesRead = 0;
nBytesRead = 0;
- int nRead = 0; // a temp variable to keep count per read
-
+ int nRead = 0; // a temp variable to keep count per read
+
unsigned char bytesReturned[3];
-
+
memset(bytesReadString, 0, 4);
memset(bytesReturned, 0, 3);
-
- while( (nRead = serial.readBytes( bytesReturned, 3)) > 0){
- nTimesRead++;
+
+ while((nRead = serial.readBytes(bytesReturned, 3)) > 0){
+ nTimesRead++;
nBytesRead = nRead;
- };
-
+ }
+
memcpy(bytesReadString, bytesReturned, 3);
-
+
bSendSerialMessage = false;
readTime = ofGetElapsedTimef();
}
@@ -67,9 +67,10 @@ void testApp::update(){
//--------------------------------------------------------------
void testApp::draw(){
- if (nBytesRead > 0 && ((ofGetElapsedTimef() - readTime) < 0.5f)){
+ if(nBytesRead > 0 && ((ofGetElapsedTimef() - readTime) < 0.5f)){
ofSetColor(0);
- } else {
+ }
+ else{
ofSetColor(220);
}
string msg;
@@ -82,23 +83,23 @@ void testApp::draw(){
}
//--------------------------------------------------------------
-void testApp::keyPressed (int key){
-
+void testApp::keyPressed(int key){
+
}
//--------------------------------------------------------------
-void testApp::keyReleased(int key){
-
+void testApp::keyReleased(int key){
+
}
//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y){
-
+
}
//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){
-
+
}
//--------------------------------------------------------------
@@ -108,21 +109,21 @@ void testApp::mousePressed(int x, int y, int button){
//--------------------------------------------------------------
void testApp::mouseReleased(int x, int y, int button){
-
+
}
//--------------------------------------------------------------
void testApp::windowResized(int w, int h){
-
+
}
//--------------------------------------------------------------
void testApp::gotMessage(ofMessage msg){
-
+
}
//--------------------------------------------------------------
-void testApp::dragEvent(ofDragInfo dragInfo){
-
+void testApp::dragEvent(ofDragInfo dragInfo){
+
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment