|
|
@@ -1,66 +1,117 @@ |
|
|
|
|
|
|
|
///-------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
/// \file TactiloControllerPanda
|
|
|
|
/// \brief Classes of the Box Tactilo Controller.
|
|
|
|
/// \author Tobias Baumann (TH-Nürnberg).
|
|
|
|
/// \version 1.0.
|
|
|
|
/// \date Mon Feb 21 14:59:56 2022.
|
|
|
|
/// \copyright <a href="https://choosealicense.com/licenses/agpl-3.0/">GNU Affero General Public License v3.0</a>.
|
|
|
|
///
|
|
|
|
///-------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#define TAC1 7
|
|
|
|
#define TAC2 8
|
|
|
|
#define TAC3 9
|
|
|
|
#define TAC4 10
|
|
|
|
#define TAC5 11
|
|
|
|
#define TAC6 12
|
|
|
|
#define LED 13
|
|
|
|
|
|
|
|
void setup()
|
|
|
|
{
|
|
|
|
//init GPIOs
|
|
|
|
set_PinMode();
|
|
|
|
set_AllLow();
|
|
|
|
|
|
|
|
//init serial
|
|
|
|
Serial.begin(115200);
|
|
|
|
}
|
|
|
|
|
|
|
|
void loop()
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_PinMode()
|
|
|
|
{
|
|
|
|
//set all pins to OUTPUT
|
|
|
|
pinMode(TAC1, OUTPUT);
|
|
|
|
pinMode(TAC2, OUTPUT);
|
|
|
|
pinMode(TAC3, OUTPUT);
|
|
|
|
pinMode(TAC4, OUTPUT);
|
|
|
|
pinMode(TAC5, OUTPUT);
|
|
|
|
pinMode(TAC6, OUTPUT);
|
|
|
|
|
|
|
|
pinMode(LED, OUTPUT);
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_AllLow()
|
|
|
|
{
|
|
|
|
//set all pins to LOW
|
|
|
|
digitalWrite(TAC1, LOW);
|
|
|
|
digitalWrite(TAC2, LOW);
|
|
|
|
digitalWrite(TAC3, LOW);
|
|
|
|
digitalWrite(TAC4, LOW);
|
|
|
|
digitalWrite(TAC5, LOW);
|
|
|
|
digitalWrite(TAC6, LOW);
|
|
|
|
|
|
|
|
digitalWrite(LED, LOW);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ToggleTactilos()
|
|
|
|
{
|
|
|
|
switch(
|
|
|
|
}
|
|
|
|
|
|
|
|
///------------------------------------------------------------------------------------------------- |
|
|
|
/// |
|
|
|
/// \file TactiloControllerPanda.ino |
|
|
|
/// \brief Controlls the Tactilos on the Leonardos GPIOs, based on the messages from OpenVibes TactiloController Box Algorithm |
|
|
|
/// \author Tobias Baumann (TH-Nürnberg). |
|
|
|
/// \version 1.0. |
|
|
|
/// \date Mon Mar 7 14:02:56 2022. |
|
|
|
/// |
|
|
|
///------------------------------------------------------------------------------------------------- |
|
|
|
|
|
|
|
//define used GPIO pins |
|
|
|
#define TAC1 7 |
|
|
|
#define TAC2 8 |
|
|
|
#define TAC3 9 |
|
|
|
#define TAC4 10 |
|
|
|
#define TAC5 11 |
|
|
|
#define TAC6 12 |
|
|
|
|
|
|
|
#define LED 13 |
|
|
|
|
|
|
|
|
|
|
|
void setup() |
|
|
|
{ |
|
|
|
//init serial |
|
|
|
Serial.begin(115200); |
|
|
|
|
|
|
|
//init GPIOs |
|
|
|
Serial.println("...init GPIOs"); |
|
|
|
set_PinMode(); |
|
|
|
set_AllLow(); |
|
|
|
} |
|
|
|
|
|
|
|
void loop() |
|
|
|
{ |
|
|
|
char SerialData; |
|
|
|
|
|
|
|
if(Serial.available() > 0) |
|
|
|
{ |
|
|
|
SerialData = Serial.read(); |
|
|
|
Serial.print("...Received Data: "); |
|
|
|
Serial.println(SerialData, DEC); |
|
|
|
} |
|
|
|
|
|
|
|
processSerialData(SerialData); |
|
|
|
} |
|
|
|
|
|
|
|
void set_PinMode() |
|
|
|
{ |
|
|
|
//set all pins to OUTPUT |
|
|
|
pinMode(TAC1, OUTPUT); |
|
|
|
pinMode(TAC2, OUTPUT); |
|
|
|
pinMode(TAC3, OUTPUT); |
|
|
|
pinMode(TAC4, OUTPUT); |
|
|
|
pinMode(TAC5, OUTPUT); |
|
|
|
pinMode(TAC6, OUTPUT); |
|
|
|
|
|
|
|
pinMode(LED, OUTPUT); |
|
|
|
} |
|
|
|
|
|
|
|
void set_AllLow() |
|
|
|
{ |
|
|
|
//set all pins to LOW |
|
|
|
digitalWrite(TAC1, LOW); |
|
|
|
digitalWrite(TAC2, LOW); |
|
|
|
digitalWrite(TAC3, LOW); |
|
|
|
digitalWrite(TAC4, LOW); |
|
|
|
digitalWrite(TAC5, LOW); |
|
|
|
digitalWrite(TAC6, LOW); |
|
|
|
|
|
|
|
digitalWrite(LED, LOW); |
|
|
|
} |
|
|
|
|
|
|
|
void processSerialData(char SerialData) |
|
|
|
{ |
|
|
|
switch(SerialData) |
|
|
|
{ |
|
|
|
case '0': |
|
|
|
if(digitalRead(LED) == LOW) |
|
|
|
{ |
|
|
|
digitalWrite(LED, HIGH); |
|
|
|
Serial.println("...Start Tactile Session"); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
set_AllLow(); |
|
|
|
Serial.println("...End Tactile Session"); |
|
|
|
} |
|
|
|
break; |
|
|
|
case '1': |
|
|
|
digitalWrite(TAC1, !digitalRead(TAC1)); |
|
|
|
Serial.println("Tactilo 1"); |
|
|
|
break; |
|
|
|
case '2': |
|
|
|
digitalWrite(TAC2, !digitalRead(TAC2)); |
|
|
|
Serial.println("Tactilo 2"); |
|
|
|
break; |
|
|
|
case '3': |
|
|
|
digitalWrite(TAC3, !digitalRead(TAC3)); |
|
|
|
Serial.println("Tactilo 3"); |
|
|
|
break; |
|
|
|
case '4': |
|
|
|
digitalWrite(TAC4, !digitalRead(TAC4)); |
|
|
|
Serial.println("Tactilo 4"); |
|
|
|
break; |
|
|
|
case '5': |
|
|
|
digitalWrite(TAC5, !digitalRead(TAC5)); |
|
|
|
Serial.println("Tactilo 5"); |
|
|
|
break; |
|
|
|
case '6': |
|
|
|
digitalWrite(TAC6, !digitalRead(TAC6)); |
|
|
|
Serial.println("Tactilo 6"); |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
} |