perturh room legacy

Dependencies:   SMARTWAV USBDevice mbed stateScript

Fork of stateScript by Mattias Karlsson

Revision:
5:e62cd80aa22f
Parent:
4:34aca2142df9
--- a/behave.h	Thu Sep 25 23:42:30 2014 +0000
+++ b/behave.h	Sat May 16 23:41:46 2015 +0000
@@ -7,6 +7,7 @@
 #include <deque>
 #include <queue>
 #include "soundControl.h"
+#include "USBSerial.h"
 
 
 #define NUMEVENTS 50
@@ -21,10 +22,9 @@
 #define OR_CONDITION    1
 #define AND_CONDITION    2
 
-#define NUMPORTS 8
+#define NUMPORTS 5
 
-#define INPUTCHARBUFFERSIZE 3072
-
+extern "C" void mbed_reset();//MAX and ANDY
 class event; //we foreward declare this because of class interdependencies
 
 //used in the digital port class to organize digital change events
@@ -38,6 +38,7 @@
 class digitalPort {
 public:
     digitalPort(DigitalOut* DOP, DigitalIn* DIP);
+    digitalPort(DigitalOut* DOP);
     void setDigitalOut(int outVal);
     //int  getDigitalOut();
     int  getDigitalIn();
@@ -96,10 +97,10 @@
 
 public:
     displayAction();
-    displayAction(int* variable, string varNameInput, Serial* pcPtrInput);
-    displayAction(string text, Serial* pcPtrInput);
-    void set(int* variable, string varNameInput, Serial* pcPtrInput);
-    void set(string text, Serial* pcPtrInput);
+    displayAction(int* variable, string varNameInput, USBSerial* pcPtrInput);
+    displayAction(string text, USBSerial* pcPtrInput);
+    void set(int* variable, string varNameInput, USBSerial* pcPtrInput);
+    void set(string text, USBSerial* pcPtrInput);
     bool isUsed;
     void execute();
     void release();
@@ -107,7 +108,7 @@
 private:
     int* dVariable;
     string dText;
-    Serial* pcPtr;
+    USBSerial* pcPtr;
 };
 
 //intOpertaion is an action that does addition or subtraction of integers and returns/stores the result
@@ -386,30 +387,11 @@
     action* actionPtr;
 };
 
-class blockBuffer {
-    
-public:
-    blockBuffer();
-    bool addLine(char* input, int numChars);
-    string getNextLine();
-    int16_t linesAvailable();
-    bool empty();
-    void resetBuffer();
-    
-private:
-    //__attribute((section("AHBSRAM1"),aligned)) char charBuffer[INPUTCHARBUFFERSIZE];
-    char charBuffer[INPUTCHARBUFFERSIZE];       
-    int16_t bufferWritePos;
-    int16_t bufferReadPos;
-    int16_t _linesAvailable;
-    
-};
-
 //Parser for the incoming text.  The parser is called when a line terminates with a semicolon (;).
 //Only the final line in a callback block should have a semicolon.  
 class scriptStream {
 public:
-    scriptStream(Serial* serialInput, digitalPort** portVectorInput, int numPortsInput, eventQueue* queueInput);
+    scriptStream(USBSerial* serialInput, digitalPort** portVectorInput, int numPortsInput, eventQueue* queueInput);
     void parseBlock();
     void addLineToCurrentBlock(char* lineInput); // if the line did not end with a semicolon, add it to the current block
     int* findIntVariable(string nameInput); //used to retrieve the pointer to the designated variable if it exists
@@ -423,15 +405,13 @@
     
     int getRandomParam(string expression);
     
-    
-    
 private:
 
     int currentTriggerPort;
     int currentTriggerDir;
     int currentPort;
     int currentFunction;
-        
+    
     string tmpLine; 
     vector<string> tokens;
     
@@ -448,13 +428,12 @@
     vector<intVariable*> globalVariables;
     vector<event*> tmpEventPtrArray;
     vector<functionItem*> functionArray; //any blocks declared outsite callback blocks are stored here
-    //list<string> currentBlock;
-    blockBuffer currentBlock;
+    list<string> currentBlock;
     digitalPort** portVector;
     
     
     int numPorts;
-    Serial* pcPtr;
+    USBSerial* pcPtr;
     eventQueue* queuePtr;
 
 };