Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b6ec9d
commit c52ffab
Showing
5 changed files
with
198 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.pioenvs |
6 changes: 6 additions & 0 deletions
6
Arduino/Edt_2000_OSC_Test3Pong/Edt_2000_OSC_Test3Pong.vcxproj.user
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<ShowAllFiles>false</ShowAllFiles> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
This directory is intended for the project specific (private) libraries. | ||
PlatformIO will compile them to static libraries and link to executable file. | ||
|
||
The source code of each library should be placed in separate directory, like | ||
"lib/private_lib/[here are source files]". | ||
|
||
For example, see how can be organized `Foo` and `Bar` libraries: | ||
|
||
|--lib | ||
| |--Bar | ||
| | |--docs | ||
| | |--examples | ||
| | |--src | ||
| | |- Bar.c | ||
| | |- Bar.h | ||
| |--Foo | ||
| | |- Foo.c | ||
| | |- Foo.h | ||
| |- readme.txt --> THIS FILE | ||
|- platformio.ini | ||
|--src | ||
|- main.c | ||
|
||
Then in `src/main.c` you should use: | ||
|
||
#include <Foo.h> | ||
#include <Bar.h> | ||
|
||
// rest H/C/CPP code | ||
|
||
PlatformIO will find your libraries automatically, configure preprocessor's | ||
include paths and build them. | ||
|
||
See additional options for PlatformIO Library Dependency Finder `lib_*`: | ||
|
||
http://docs.platformio.org/en/latest/projectconf.html#lib-install | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[env:uno] | ||
platform = atmelavr | ||
framework = arduino | ||
board = leonardoeth | ||
upload_port = COM8 | ||
|
||
[platformio] | ||
lib_dir = D:\Edt-2000\Arduino\libraries |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
/* | ||
Edt-2000 Test Ping | ||
*/ | ||
#define DEBUG | ||
|
||
#define STARTIO 5 | ||
#define FINISHIO 6 | ||
|
||
#define SYS 0 | ||
#define STEP 1 | ||
#define FULL 2 | ||
|
||
#include "Definitions.h" | ||
|
||
#include "Arduino.h" | ||
#include "Ethernet.h" | ||
#include "EthernetUdp.h" | ||
#include "OSC.h" | ||
#include "Statemachine.h" | ||
#include "Preset.h" | ||
#include "Trak.h" | ||
#include "Time.h" | ||
#include "Memory.h" | ||
|
||
EthernetUDP Udp; | ||
EdtOSC OSC; | ||
|
||
enum class states { init, waitingForStart, waitingForFinish, waitingForReset }; | ||
states state = states::init; | ||
|
||
class OSCMessageWriter : public EdtOSCSourceObject | ||
{ | ||
public: | ||
OSCMessageWriter() { | ||
message.reserve(1); | ||
message.setAddress("/M"); | ||
} | ||
OSCMessage * generateMessage() { | ||
if (enabled) { | ||
|
||
message.add(++messages); | ||
|
||
enabled = false; | ||
|
||
return &message; | ||
} | ||
|
||
return nullptr; | ||
} | ||
void enable() { | ||
enabled = true; | ||
} | ||
private: | ||
OSCMessage message = OSCMessage(); | ||
float messages = 0; | ||
bool enabled = false; | ||
} OSCWriter; | ||
|
||
void setup() { | ||
Statemachine.begin(13, LOW); | ||
|
||
pinMode(STARTIO, INPUT_PULLUP); | ||
pinMode(FINISHIO, INPUT_PULLUP); | ||
} | ||
|
||
void loop() { | ||
Statemachine.loop(); | ||
|
||
if (Statemachine.isBegin()) { | ||
Time.begin(); | ||
|
||
Time.startTiming(SYS); | ||
Time.startTiming(STEP); | ||
Time.startTiming(FULL); | ||
|
||
Serial.begin(9600); | ||
|
||
// Pong code | ||
Time.addTimeEvent(SYS, "Edt-Trak Ping"); | ||
|
||
Time.addTimeEvent(SYS, "Starting Ethernet.."); | ||
|
||
Ethernet.begin(MAC_PONG); | ||
|
||
Time.addTimeEvent(SYS, "Started Ethernet."); | ||
|
||
Serial.print("IP: "); | ||
for (byte thisByte = 0; thisByte < 4; thisByte++) { | ||
Serial.print(Ethernet.localIP()[thisByte], DEC); | ||
Serial.print("."); | ||
} | ||
Serial.println(); | ||
|
||
Time.addTimeEvent(SYS, "Starting UDP.."); | ||
|
||
Udp.begin(PORT_BROADCAST); | ||
|
||
Time.addTimeEvent(SYS, "Started UDP."); | ||
Time.addTimeEvent(SYS, "Starting code.."); | ||
|
||
OSC = EdtOSC(1, 0); | ||
OSC.bindUDP(&Udp, IP_BROADCAST, PORT_BROADCAST); | ||
OSC.addSource(&OSCWriter); | ||
|
||
Time.addTimeEvent(SYS, "Started code."); | ||
// /Pong code | ||
|
||
Statemachine.ready(); | ||
} | ||
else { | ||
while (Statemachine.isRun()) { | ||
Time.loop(); | ||
OSC.loop(); | ||
|
||
switch (state) { | ||
case states::init: | ||
Time.addTimeEvent(FULL, "Start cycle."); | ||
state = states::waitingForStart; | ||
break; | ||
|
||
case states::waitingForStart: | ||
if (digitalRead(STARTIO) == HIGH) { | ||
Time.addTimeEvent(FULL, "Received start."); | ||
state = states::waitingForFinish; | ||
OSCWriter.enable(); | ||
} | ||
break; | ||
|
||
case states::waitingForFinish: | ||
if (digitalRead(FINISHIO) == HIGH) { | ||
Time.addTimeEvent(FULL, "Received finish."); | ||
state = states::waitingForReset; | ||
} | ||
break; | ||
|
||
case states::waitingForReset: | ||
if (digitalRead(STARTIO) == LOW && digitalRead(FINISHIO) == LOW) { | ||
Time.addTimeEvent(FULL, "Received reset."); | ||
state = states::init; | ||
} | ||
break; | ||
} | ||
} | ||
} | ||
} |