Skip to content

Commit

Permalink
Merge branch 'master' of github.com:pushsnowboarding/Push-Snowboarding
Browse files Browse the repository at this point in the history
Conflicts:
	PushBurton2/PushBurton2.pro.user
  • Loading branch information
cpscotti committed Jun 14, 2011
2 parents 601417d + c35ef9d commit 6064c6e
Show file tree
Hide file tree
Showing 50 changed files with 2,443 additions and 1,714 deletions.
6 changes: 6 additions & 0 deletions Arduino/FootPressure/FootPressure.pde
Expand Up @@ -9,6 +9,12 @@
*
*/

/*
* Arduino responds to char 'A' from the serial port.
* Replies with:
* FOOT,<value heel>,<value toes>,END;
*/

//FOOT, arduino pro mini 3.3v connected to FSRs in divider with 1.5K resistor talking to bluetooth at 115200 Baud on a bluetooth mate.

void setup()
Expand Down
6 changes: 6 additions & 0 deletions Arduino/GSR/GSR.pde
Expand Up @@ -9,6 +9,12 @@
*
*/

/*
* Arduino responds to char 'A' from the serial port.
* Replies with:
* GSR,<value>,END;
*/

//GSR, arduino pro mini 3.3v connected to analog in port 3 with a 300K resistor tied to ground talking to bluetooth at 115200 Baud on a bluetooth mate.

void setup()
Expand Down
6 changes: 6 additions & 0 deletions Arduino/Heart/Heart.pde
Expand Up @@ -10,6 +10,12 @@
*
*/

/*
* Arduino responds to char 'A' from the serial port.
* Replies with:
* HRM,<average last 32 beats>,<average last 16 beats>,<average last beat>,END;
*/

volatile boolean inService = false;
long timeArray[] ={
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
Expand Down
18 changes: 18 additions & 0 deletions Arduino/IMU/IMU.pde
@@ -1,4 +1,22 @@


/*
* Copyright (c) 2011 Nokia Corporation
*
* This file is part of the Push Snowboarding Project, More info at:
* http://pushsnowboarding.com/tech/developer-centre/
*
* This file is under the GPLv3 License, more details at:
* http://www.gnu.org/licenses/
*
*/

/*
* Arduino responds to char 'A' from the serial port.
* Replies with:
* IMU,<gyro's x>,<gyro's y>,<gyro's z>,<acc's x>,<acc's y>,<acc's z>,<mag's x>,<mag's y>,<mag's z>,END;
*/

#include <Wire.h>

int XGyro, YGyro, ZGyro;
Expand Down
19 changes: 15 additions & 4 deletions PushBurton2/PushBurton2.pro
Expand Up @@ -26,8 +26,7 @@
#-------------------------------------------------


QT += core gui
QT += xml
QT += core gui xml phonon network

TARGET = PushBurton2
TEMPLATE = app
Expand Down Expand Up @@ -76,7 +75,11 @@ SOURCES += main.cpp\
graphicsreportview.cpp \
graphicslidingdownbts.cpp \
liveview.cpp \
graphicssettings.cpp
graphicssettings.cpp \
virtualbrosdevice.cpp \
rotationcounter.cpp \
npushrotationstick.cpp \
broadcasterdevice.cpp

HEADERS += mainwindow.h \
graphicpixmapbt.h \
Expand Down Expand Up @@ -122,7 +125,11 @@ HEADERS += mainwindow.h \
graphicslidingdownbts.h \
liveview.h \
graphicssettings.h \
FilesystemConventions.h
FilesystemConventions.h \
virtualbrosdevice.h \
rotationcounter.h \
npushrotationstick.h \
broadcasterdevice.h

FORMS += mainwindow.ui \
liveview.ui
Expand All @@ -131,6 +138,9 @@ CONFIG += mobility
MOBILITY = location sensors

#LIBS += -lQBluetooth
soundFiles.sources = sounds/*.mp3
DEPLOYMENT += soundFiles


symbian {
TARGET.UID3 = 0xece639d4
Expand Down Expand Up @@ -172,6 +182,7 @@ symbian {

addFiles.sources = $(EPOCROOT)Epoc32/release/$(PLATFORM)/$(CFG)/QBluetooth.dll
addFiles.path = /sys/bin

DEPLOYMENT += addFiles

isEmpty(ICON):ICON = images/burton_logo.svg
Expand Down
301 changes: 24 additions & 277 deletions PushBurton2/PushBurton2.pro.user

Large diffs are not rendered by default.

137 changes: 137 additions & 0 deletions PushBurton2/broadcasterdevice.cpp
@@ -0,0 +1,137 @@
#include "broadcasterdevice.h"

BroadcasterDevice::BroadcasterDevice(QObject *parent) :
PushBurtonGenericDevice(parent)
{

running = false;


xmlWriter = 0;

currConnection = 0;



serverAddress = QHostAddress("192.168.0.3");

serverPort = 45454;

}


BroadcasterDevice::~BroadcasterDevice()
{
if(currConnection)
currConnection->disconnectFromHost();
}


QString BroadcasterDevice::getName()
{

return QString("push.network.broadcaster");
}


bool BroadcasterDevice::start_run()
{
if(!running) {
running = true;
return true;
}
return false;
}

bool BroadcasterDevice::end_run()
{
if(running) {
running = false;

return true;
}
return false;
}

void BroadcasterDevice::incoming_reading(NPushLogTick * tick)
{
if(running) {
if(xmlWriter && currConnection->isWritable()) {
tick->dump_to_xml(*xmlWriter);
currConnection->flush();
}
}
}

void BroadcasterDevice::connected()
{
qDebug() << "Connected";
xmlWriter = new QXmlStreamWriter(currConnection);
qDebug() << "coupled with xml writer";

emit connectionUpdate(true);
}

void BroadcasterDevice::disconnected()
{
if(xmlWriter) {
delete xmlWriter;
xmlWriter = 0;
}
if(currConnection) {
currConnection->close();
currConnection->deleteLater();
currConnection = 0;
}
emit connectionUpdate(false);
}

void BroadcasterDevice::tryToConnect()
{
if(currConnection) {
qDebug() << "Cleaning up old connection";
currConnection->close();
currConnection->deleteLater();
currConnection = 0;
}

qDebug() << "Trying to establish new connection";

currConnection = new QTcpSocket(this);

currConnection->connectToHost(serverAddress, serverPort, QIODevice::WriteOnly);

connect(currConnection, SIGNAL(connected()),
this, SLOT(connected()));

connect(currConnection, SIGNAL(disconnected()),
this, SLOT(disconnected()));
}

void BroadcasterDevice::setServerAddress(const QString &addr)
{
serverAddress.setAddress(addr);
qDebug() << "Address set to " << serverAddress.toString();
}

void BroadcasterDevice::setServerPort(quint16 port)
{
serverPort = port;
qDebug() << "Port set to " << serverPort;
}

void BroadcasterDevice::tryToDisconnect()
{
if(xmlWriter) {
delete xmlWriter;
xmlWriter = 0;
}

if(currConnection) {
currConnection->close();
currConnection->deleteLater();
currConnection = 0;
}

emit connectionUpdate(false);
}
68 changes: 68 additions & 0 deletions PushBurton2/broadcasterdevice.h
@@ -0,0 +1,68 @@
#ifndef BROADCASTERDEVICE_H
#define BROADCASTERDEVICE_H

#include "npushlogtick.h"
#include "pushburtongenericdevice.h"

#include <QtNetwork>
#include <QHostAddress>
#include <QXmlStreamWriter>
#include <QIODevice>

#include <QDebug>

class BroadcasterDevice : public PushBurtonGenericDevice
{
Q_OBJECT
public:
explicit BroadcasterDevice(QObject *parent = 0);

~BroadcasterDevice();


QString getName();
bool is_online() {
return true;
}

//Our device subscribes to other devices so we need to reimplement these 2 functions
//accordingly. One can argue that subscribesToAny wouldn't be necessary but it SURE
//prevents doing a huge amount of unnecessary checks.
bool subscribesToAny() { return true; }

//This function will return true when the given device is a AirTimeDetector
bool subscribesTo(PushBurtonGenericDevice*) { return true; }

bool start_run();
bool end_run();

signals:
void connectionUpdate(bool connState);

public slots:

void tryToConnect();
void tryToDisconnect();

void setServerAddress(const QString& addr);
void setServerPort(quint16 port);

void connected();
void disconnected();
void incoming_reading(NPushLogTick *);

private:
bool running;

QHostAddress serverAddress;
quint16 serverPort;


QTcpSocket *currConnection;

QXmlStreamWriter *xmlWriter;


};

#endif // BROADCASTERDEVICE_H
23 changes: 13 additions & 10 deletions PushBurton2/devicesmanager.cpp
Expand Up @@ -209,13 +209,13 @@ void DevicesManager::stop_bt_search()
#endif
}

void DevicesManager::switch_to_simulation_device()
void DevicesManager::switch_to_simulation_device(const QString& fname)
{
//TODO
qDebug() << "Switched to simulation device!";
configuredDevices->deleteAllAndClear();

PushN8SimulationDevice * simulationDevice = new PushN8SimulationDevice();
PushN8SimulationDevice * simulationDevice = new PushN8SimulationDevice(fname);
configuredDevices->push_back(simulationDevice);

SetupAbstractDevices();
Expand All @@ -227,12 +227,8 @@ void DevicesManager::switch_to_simulation_device()
emit device_connected(QString("Location"));
emit device_connected(QString("Heart"));

// emit foot_l_connected();
// emit foot_r_connected();
// emit motion_box_connected();
// emit heart_connected();
// emit gsr_connected();
// emit phone_gps_connected();
emit request_run_start();
connect(simulationDevice, SIGNAL(simulationEnded()), this, SIGNAL(request_run_end()));

}

Expand Down Expand Up @@ -286,8 +282,6 @@ void DevicesManager::SetupPhoneDevices()
connect(phoneGPS, SIGNAL(disconnected()), &disconnectedMapper, SLOT(map()));
disconnectedMapper.setMapping(phoneGPS, "Location");

// emit phone_gps_connecting();
// connect(phoneGPS, SIGNAL(connected()), this, SIGNAL(phone_gps_connected()));
}

void DevicesManager::SetupAbstractDevices()
Expand All @@ -300,4 +294,13 @@ void DevicesManager::SetupAbstractDevices()

PushN8SimpleReportsGenerator * reportGenerator = new PushN8SimpleReportsGenerator();
configuredDevices->push_back(reportGenerator);

RotationCounter * spin2WinKid = new RotationCounter();
configuredDevices->push_back(spin2WinKid);

VirtualBrosDevice * virtualBros = new VirtualBrosDevice();
configuredDevices->push_back(virtualBros);

BroadcasterDevice * brodDevice = new BroadcasterDevice();
configuredDevices->push_back(brodDevice);
}

0 comments on commit 6064c6e

Please sign in to comment.