Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux Port #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Linux cruft
proj/cmake/build/

# Mac OS X cruft
*.pbxuser
*.mode1v3
Expand Down Expand Up @@ -37,4 +40,4 @@ docs/html
docs/xml
docs/doxygen/cinder.tag
docs/*/node_modules
*.pyc
*.pyc
43 changes: 42 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ In the event of a crash, a log file will be created in a folder called "logs" in
Please attach this file when asking for support along with any other relevant information.

## Code Setup
### Windows
1. Clone Cinder 0.9.0 or download via zipped archive. [[Cinder Github](https://github.com/cinder/Cinder)]
2. SilverSprint wants to be in a directory one above the Cinder root. For example:

Expand All @@ -53,8 +54,48 @@ Please attach this file when asking for support along with any other relevant in
- lib
- ...
```
3. Open the project file for your platform. It will be in `SilverSprint/xcode/SilverSprint.xcodeproj` for mac, and `SilverSprint/vs2013` for PC.
3. Open the project file for your platform. It will be in `SilverSprint/vs2013` for PC.
4. Build and enjoy. There are no external dependencies aside from Cinder itself.
### OSX
1. Clone Cinder 0.9.0 or download via zipped archive. [[Cinder Github](https://github.com/cinder/Cinder)]
2. SilverSprint wants to be in a directory one above the Cinder root. For example:

```
- Cinder
- apps
- SilverSprint
- blocks
- docs
- include
- lib
- ...
```
3. Open the project file for your platform. It will be in `SilverSprint/xcode/SilverSprint.xcodeproj`.
4. Build and enjoy. There are no external dependencies aside from Cinder itself.
### Ubuntu
1. [Install Cinder](https://libcinder.org/docs/branch/master/guides/linux-notes/ubuntu.html) NOTE: There might be other dependencies, just read the errors.
2. Clone SilverSprint into a directory one above the Cinder root. Either use 'samples' or create 'apps' like Windows and OSX.

```
- Cinder
- examples
- SilverSprint
- blocks
- docs
- include
- lib
- ...
```
3. Build
```
$ cd Cinder/examples/SilverSprint/proj/cmake/
$ mkdir build && cd build && cmake .. && make
```
4. Execute
```
$ cd Debug/SilverSprintApp
$ ./SilverSprintApp
```

## Credits

Expand Down
9 changes: 8 additions & 1 deletion blocks/Serial/include/SerialDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@
#include <vector>
#include <regex>

#include "serial.h"
#ifdef __linux
//linux
#include "../lib/serial/include/serial/serial.h"
#else
// Windows & OSX
#include "serial.h"
#endif


namespace Cinder { namespace Serial {

Expand Down
10 changes: 8 additions & 2 deletions blocks/Serial/lib/serial/include/serial/impl/unix.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@
#ifndef SERIAL_IMPL_UNIX_H
#define SERIAL_IMPL_UNIX_H

#include "serial/serial.h"
#ifdef __linux
// linux
#include "../serial.h"
#else
// Windows & OSX
#include "serial/serial.h"
#endif

#include <pthread.h>

Expand All @@ -55,7 +61,7 @@ using serial::IOException;

class MillisecondTimer {
public:
MillisecondTimer(const uint32_t millis);
MillisecondTimer(const uint32_t millis);
int64_t remaining();

private:
Expand Down
9 changes: 8 additions & 1 deletion blocks/Serial/lib/serial/include/serial/serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,14 @@
#include <sstream>
#include <exception>
#include <stdexcept>
#include <serial/v8stdint.h>

#ifdef __linux
//linux
#include "v8stdint.h"
#else
// Windows & OSX
#include <serial/v8stdint.h>
#endif

#define THROW(exceptionClass, message) throw exceptionClass(__FILE__, \
__LINE__, (message) )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <sys/stat.h>
#include <unistd.h>

#include "serial/serial.h"
#include "../../../include/serial/serial.h"

using serial::PortInfo;
using std::istringstream;
Expand Down
8 changes: 7 additions & 1 deletion blocks/Serial/lib/serial/src/impl/unix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@
#include <mach/mach.h>
#endif

#include "serial/impl/unix.h"
#ifdef __linux
// linux
#include "../../include/serial/impl/unix.h"
#else
// OSX
#include "serial/impl/unix.h"
#endif

#ifndef TIOCINQ
#ifdef FIONREAD
Expand Down
14 changes: 10 additions & 4 deletions blocks/Serial/lib/serial/src/serial.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,18 @@
# define alloca __builtin_alloca
#endif

#include "serial/serial.h"

#ifdef _WIN32
#include "serial/impl/win.h"
// Windows
#include "serial/serial.h"
#include "serial/impl/win.h"
#elif __linux
// linux
#include "../include/serial/serial.h"
#include "../include/serial/impl/unix.h"
#else
#include "serial/impl/unix.h"
// OSX
#include "serial/serial.h"
#include "serial/impl/unix.h"
#endif

using std::invalid_argument;
Expand Down
9 changes: 8 additions & 1 deletion blocks/Serial/src/SerialDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@
// Copyright 2015 Chorded Constructions. All rights reserved.
//

#include "SerialDevice.h"
#ifdef __linux
// linux
#include "../include/SerialDevice.h"
#else
// Windows & OSX
#include "SerialDevice.h"
#endif


namespace Cinder { namespace Serial {

Expand Down
48 changes: 31 additions & 17 deletions include/app/GFXMain.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,32 @@
#include "cinder/app/App.h"
#include "cinder/app/KeyEvent.h"

#include "data/Model.h"
#include "data/GFXGlobal.h"
#include "data/SerialReader.h"
#include "data/StateManager.h"
#ifdef __linux
//linux
#include "../data/Model.h"
#include "../data/GFXGlobal.h"
#include "../data/SerialReader.h"
#include "../data/StateManager.h"

#include "views/NavBarView.h"
#include "views/RaceView.h"
#include "views/RosterView.h"
#include "views/SettingsView.h"
#include "../views/NavBarView.h"
#include "../views/RaceView.h"
#include "../views/RosterView.h"
#include "../views/SettingsView.h"
#else
// Windows & OSX
#include "data/Model.h"
#include "data/GFXGlobal.h"
#include "data/SerialReader.h"
#include "data/StateManager.h"

#include "views/NavBarView.h"
#include "views/RaceView.h"
#include "views/RosterView.h"
#include "views/SettingsView.h"
#endif

namespace gfx{

using GFXMainRef = std::shared_ptr<class GFXMain>;

class GFXMain
Expand All @@ -33,27 +47,27 @@ namespace gfx{
void setup();
void update();
void draw( const ci::Rectf &drawRect );

void resetPlayerData();

private:
void onAppStateChaged( APP_STATE as );
void onRaceStateChanged( RACE_STATE rc );

void onRaceFinished();

GFXGlobal *mGlobal;

NavBarViewRef mNav;
RaceViewRef mRaceView;
RosterViewRef mRosterView;
SettingsViewRef mSettingsView;

Model *mModel;
SerialReaderRef mSerialReader;
StateManager *mStateManager;

void onKeyDown( ci::app::KeyEvent event );
};

}
}
41 changes: 25 additions & 16 deletions include/data/SerialReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,22 @@
#include "cinder/ConcurrentCircularBuffer.h"
#include <boost/algorithm/string.hpp>

#include "data/StateManager.h"
#include "data/Model.h"
#ifdef __linux
//linux
#include "StateManager.h"
#include "Model.h"

#include "Cinder-Serial.h"
#include "../../blocks/Serial/include/Cinder-Serial.h"
#else
// Windows & OSX
#include "data/StateManager.h"
#include "data/Model.h"

#include "Cinder-Serial.h"
#endif

namespace gfx
{
{
using SerialReaderRef = std::shared_ptr<class SerialReader>;
class SerialReader
{
Expand All @@ -31,45 +40,45 @@ namespace gfx
~SerialReader();
void setup();
void update();

void startRace();
void stopRace();

void setRaceDuration( int );
void setRaceLengthTicks( int numTicks );
void setMockMode( bool enabled=true );
void getVersion();

private:
void updateSerialThread();

void onConnect();
void onDisconnect();

void parseCommandToBuffer( std::string command );
void parseFromBuffer();

bool isRaceFinished();

StateManager *mStateManager;
Model *mModel;

void readSerial();
void sendSerialMessage( std::string msg );

int BAUD_RATE = 115200;
//ci::SerialRef mSerial;
Cinder::Serial::SerialDeviceRef mSerial;
bool bSerialConnected = false, bLastConnection = false;
bool bThreadShouldQuit = false;
bool bMockEnabled = false;

std::string mStringBuffer;

std::string mFirmwareVersion;
std::string mProtoculVersion;
std::string mHardwareVersion; // currently unimplemented in arduino software

// threading
std::shared_ptr<std::thread> mSerialThread;
std::mutex mSerialMutex;
Expand Down
18 changes: 12 additions & 6 deletions include/ui/BaseButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,32 @@

#include "cinder/app/App.h"

#include "data/GFXGlobal.h"
#ifdef __linux
//linux
#include "../data/GFXGlobal.h"
#else
// Windows & OSX
#include "data/GFXGlobal.h"
#endif

class BaseButton {
public:
BaseButton();

// virtual void setup();
// virtual void update();
// virtual void draw();

void onMouseMove( cinder::app::MouseEvent event );
void onMouseUp( cinder::app::MouseEvent event );

virtual void onMouseOver() = 0;
virtual void onMouseOut() = 0;
virtual void onClick() = 0;

protected:
ci::Rectf mBounds;
bool bEnabled;
bool bHover;
bool bActive;
};
};
Loading