Skip to content

Commit

Permalink
Clean up examples, move OSC examples to ofxOscSerial.
Browse files Browse the repository at this point in the history
  • Loading branch information
bakercp committed Apr 6, 2019
1 parent 77407e8 commit e764c57
Show file tree
Hide file tree
Showing 43 changed files with 134 additions and 1,059 deletions.
24 changes: 3 additions & 21 deletions examples/basic/echo/Arduino/Echo/Echo.ino
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
// =============================================================================
//
// Copyright (c) 2013 Christopher Baker <http://christopherbaker.net>
// Copyright (c) 2014 Christopher Baker <https://christopherbaker.net>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// SPDX-License-Identifier: MIT
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// =============================================================================


void setup()
{
Expand All @@ -37,4 +20,3 @@ void loop()

delay(10);
}

13 changes: 13 additions & 0 deletions examples/basic/echo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Echo

## Description

This example sets up a simple echo connection with an Arduino.

## Instructions

1. Upload the `Echo.ino` sketch (in this example's `Arduino/` folder) to an Arduino-compatible board.

2. Check the "listDevices" call in the `ofApp::setup()` function to make sure the correct serial device is connected.

3. Run this app.
2 changes: 1 addition & 1 deletion examples/basic/echo/addons.make
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ofxIO
ofxPoco
ofxSerial
ofxPoco
17 changes: 9 additions & 8 deletions examples/basic/echo/src/ofApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@

void ofApp::setup()
{
// 1. Upload the Echo.ino sketch (in this example's Arduino/ folder) to
// an Arduino board.
// 2. Check the "listDevices" call below to make sure the correct serial
// device is connected. This works with OSX but may require a different
// port name for Linux or Windows.
// 1. Upload the `Echo.ino` sketch (in this example's `Arduino/` folder) to
// an Arduino-compatible board.
//
// 2. Check the "listDevices" call in the `ofApp::setup()` function to make
// sure the correct serial device is connected.
//
// 3. Run this app.

std::vector<ofx::IO::SerialDeviceInfo> devicesInfo = ofx::IO::SerialDeviceUtils::listDevices();
Expand All @@ -31,7 +32,7 @@ void ofApp::setup()
// Connect to the first matching device.
bool success = device.setup(devicesInfo[0], 115200);

if(success)
if (success)
{
ofLogNotice("ofApp::setup") << "Successfully setup " << devicesInfo[0];
}
Expand Down Expand Up @@ -83,6 +84,6 @@ void ofApp::update()
void ofApp::draw()
{
ofBackgroundGradient(ofColor::white, ofColor::black);
ofDrawBitmapStringHighlight("Connected to " + device.getPortName(), ofVec2f(20, 20));
ofDrawBitmapStringHighlight("See Console.", ofVec2f(20, 45));
ofDrawBitmapStringHighlight("Connected to " + device.port(), 20, 20);
ofDrawBitmapStringHighlight("See Console.", 20, 45);
}
9 changes: 9 additions & 0 deletions examples/basic/list_devices/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Echo

## Description

This example shows how to list all connected serial devices.

## Instructions

1. Run this app.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// Copyright (c) 2014 Christopher Baker <https://christopherbaker.net>
//
// SPDX-License-Identifier: MIT
//


const int numLines = 3;

String haiku[] = {
"at the age old pond",
"a frog leaps into water",
"a deep resonance"
};

byte currentLine = 0;
byte currentChar = 0;

void setup()
{
Serial.begin(115200);
}


void loop()
{
if (currentChar < haiku[currentLine].length())
{
Serial.print(haiku[currentLine][currentChar]);
currentChar++;
}
else
{
Serial.println("");
currentChar = 0;
currentLine = random(0, numLines);
}

delay(random(250));
}
13 changes: 13 additions & 0 deletions examples/intermediate/buffered_serial_device/line_buffer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Buffered Serial Device / Basic

## Description

This example sets up a simple echo connection with an Arduino using a buffered serial device.

## Instructions

1. Upload the `HaikuGenerator.ino` sketch (in this example's `Arduino/` folder) to an Arduino-compatible board.

2. Check the "listDevices" call in the `ofApp::setup()` function to make sure the correct serial device is connected.

3. Run this app.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// SPDX-License-Identifier: MIT
//


#include "ofApp.h"


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
// SPDX-License-Identifier: MIT
//


#include "ofApp.h"


void ofApp::setup()
{
// 1. Upload the HaikuGenerator.ino sketch (in this example's Arduino/
// folder) to an Arduino board.
// 2. Check the "getDevices" call below to make sure the correct serial
// device is connected. This works with OSX but may require a different
// port name for Linux or Windows.
// 3. Run this app.
// 1. Upload the `HaikuGenerator.ino` sketch (in this example's
// `Arduino/` folder) to an Arduino-compatible board.
// 2. Check the "listDevices" call in the `ofApp::setup()` function to
// make sure the correct serial device is connected.
// 3. Run this app.

ofEnableAlphaBlending();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// SPDX-License-Identifier: MIT
//


#pragma once


Expand Down
11 changes: 11 additions & 0 deletions examples/intermediate/packet_serial_device/cobs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Packet Serial Device / Basic

## Description

This example sets up a simple connection with an Arduino using a packet serial device.

## Instructions

1. Upload the `PacketSerialReverseEcho.ino` sketch to an Arduino board. This sketch requires the Arduino [PacketSerial library](https://github.com/bakercp/PacketSerial) and the example Arduino code can be found in that package.
2. Check the "listDevices" call below to make sure the correct serial device is connected.
3. Run this app.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@

void ofApp::setup()
{
// 1. Upload the SLIPPacketSerialReverseEcho.ino sketch (in this example's
// Arduino/ folder) to an Arduino board. This sketch requires
// the Arduino PacketSerial library https://github.com/bakercp/PacketSerial.
// 1. Upload the `PacketSerialReverseEcho.ino` sketch to an Arduino board.
// This sketch requires the Arduino
// [PacketSerial library](https://github.com/bakercp/PacketSerial)
// and the example Arduino code can be found in that package.
// 2. Check the "listDevices" call below to make sure the correct serial
// device is connected.
// 3. Run this app.
Expand Down

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions examples/intermediate/packet_serial_device/osc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Please see the [ofxOscSerial](https://github.com/bakercp/ofxOscSerial) addon for communicating via OSC over SLIP.
4 changes: 0 additions & 4 deletions examples/intermediate/packet_serial_device/osc/addons.make

This file was deleted.

15 changes: 0 additions & 15 deletions examples/intermediate/packet_serial_device/osc/src/main.cpp

This file was deleted.

Loading

0 comments on commit e764c57

Please sign in to comment.