Browse Source

Implement 6 Tactilos and rename

master
Igor Beloschapkin 4 years ago
parent
commit
69f107c9cc

tactile_eeg_v1.1/tactile_eeg_v1.1.ino → tactile_eeg_local/tactile_eeg_local.ino View File

@@ -14,12 +14,12 @@
#define PASSWORD "featherNetwork" // network password

#define PIN_LED 13
#define PIN_Z 14
#define PIN_V 32
#define PIN_R 15
#define PIN_L 33
#define PIN_27 27
#define PIN_12 12
#define PIN_TAC6 12
#define PIN_TAC5 27
#define PIN_TAC4 33
#define PIN_TAC3 15
#define PIN_TAC2 32
#define PIN_TAC1 14
#define PIN_13 13
#define PIN_A5 4
#define PIN_A1 25
@@ -101,14 +101,14 @@ void setInitGPIO()
{
// Set all as OUTPUT
pinMode(PIN_LED, OUTPUT);
pinMode(PIN_Z, OUTPUT);
pinMode(PIN_V, OUTPUT);
pinMode(PIN_R, OUTPUT);
pinMode(PIN_L, OUTPUT);
pinMode(PIN_TAC6, OUTPUT);
pinMode(PIN_TAC5, OUTPUT);
pinMode(PIN_TAC4, OUTPUT);
pinMode(PIN_TAC3, OUTPUT);
pinMode(PIN_TAC2, OUTPUT);
pinMode(PIN_TAC1, OUTPUT);
// Bisher ungenutzte Pins
pinMode(PIN_27, OUTPUT);
pinMode(PIN_12, OUTPUT);
pinMode(PIN_13, OUTPUT);
pinMode(PIN_A5, OUTPUT);
pinMode(PIN_A1, OUTPUT);
@@ -121,14 +121,14 @@ void allLow()
{
// Set all LOW
digitalWrite(PIN_LED, LOW);
digitalWrite(PIN_Z, LOW);
digitalWrite(PIN_V, LOW);
digitalWrite(PIN_R, LOW);
digitalWrite(PIN_L, LOW);
digitalWrite(PIN_TAC6, LOW);
digitalWrite(PIN_TAC5, LOW);
digitalWrite(PIN_TAC4, LOW);
digitalWrite(PIN_TAC3, LOW);
digitalWrite(PIN_TAC2, LOW);
digitalWrite(PIN_TAC1, LOW);
// Bisher ungenutzte Pins
digitalWrite(PIN_27, LOW);
digitalWrite(PIN_12, LOW);
digitalWrite(PIN_13, LOW);
digitalWrite(PIN_A5, LOW);
digitalWrite(PIN_A1, LOW);
@@ -167,10 +167,12 @@ void vibrate(const char signr)
{
switch(signr)
{
case '4': digitalWrite(PIN_Z, HIGH); break;
case '3': digitalWrite(PIN_V, HIGH); break;
case '2': digitalWrite(PIN_R, HIGH); break;
case '1': digitalWrite(PIN_L, HIGH); break;
case '6': digitalWrite(PIN_TAC6, HIGH); break;
case '5': digitalWrite(PIN_TAC5, HIGH); break;
case '4': digitalWrite(PIN_TAC4, HIGH); break;
case '3': digitalWrite(PIN_TAC3, HIGH); break;
case '2': digitalWrite(PIN_TAC2, HIGH); break;
case '1': digitalWrite(PIN_TAC1, HIGH); break;
case '0': allLow(); break;
}
}

tactile_eeg_v1.3/tactile_eeg_v1.3.ino → tactile_eeg_router/tactile_eeg_router.ino View File


+ 0
- 236
tactile_eeg_v1.2/tactile_eeg_v1.2.ino View File

@@ -1,236 +0,0 @@
// Arduino -> Adafruit ESP32 Feather auswählen

#include <WiFi.h>
#include <WiFiUDP.h>
#include <stdio.h>
#include <ctype.h>

/* Firmware v1.1 04.04.2019
* Christian Schuster
* cchschuster@gmail.com
*
* Firmware v1.2 03.08.2020
* Igor Beloschapkin
* beloschapkin@protonmail.com
*/

#define PIN_LED 13
#define PIN_Z 14
#define PIN_V 32
#define PIN_R 15
#define PIN_L 33
#define PIN_27 27
#define PIN_12 12
#define PIN_13 13
#define PIN_A5 4
#define PIN_A1 25
#define PIN_A0 26

#define SCRIPTMODE 1 // 0 = local filtering, 1 = laptop script filtering

char ssid[] = "ssid";
char pass[] = "pass";

char packetBuffer[255]; // buffer to hold incoming packet
unsigned int localPort = 8888;

char sig_nr;
int i_sig_nr;

WiFiUDP udp;

void setup()
{
setInitGPIO();

// Initialize serial
Serial.begin(115200);
Serial.println();
Serial.print("Connecting to WIFI at SSID: ");
Serial.print(ssid);

// Connect to WPA/WPA2 network:
bool result = WiFi.begin(ssid, pass);

// Wait 10 seconds for connection:
delay(10000);

//result = false; // for error testing
if(result)
{
successWiFi();
udp.begin(localPort);
} else {
errorWiFi();
}
}

void printWifiData() {
// print your WiFi shield's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
Serial.println(ip);

// print your MAC address:
byte mac[6];
WiFi.macAddress(mac);
Serial.print("MAC address: ");
Serial.print(mac[5], HEX);
Serial.print(":");
Serial.print(mac[4], HEX);
Serial.print(":");
Serial.print(mac[3], HEX);
Serial.print(":");
Serial.print(mac[2], HEX);
Serial.print(":");
Serial.print(mac[1], HEX);
Serial.print(":");
Serial.println(mac[0], HEX);

}

void printCurrentNet() {
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());

// print the MAC address of the router you're attached to:
// byte bssid[6];
// WiFi.BSSID(bssid);
// Serial.print("BSSID: ");
// Serial.print(bssid[5], HEX);
// Serial.print(":");
// Serial.print(bssid[4], HEX);
// Serial.print(":");
// Serial.print(bssid[3], HEX);
// Serial.print(":");
// Serial.print(bssid[2], HEX);
// Serial.print(":");
// Serial.print(bssid[1], HEX);
// Serial.print(":");
// Serial.println(bssid[0], HEX);

// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.println(rssi);

// print the encryption type:
// byte encryption = WiFi.encryptionType();
// Serial.print("Encryption Type:");
// Serial.println(encryption, HEX);
// Serial.println();
}

void loop()
{
int packetSize = udp.parsePacket();
if(packetSize)
{
int len = udp.read(packetBuffer, 255);
if(len)
{
packetBuffer[len] = 0;
}

if(SCRIPTMODE) // == 1
{
// laptop script filtering
sig_nr = packetBuffer[0];
Serial.println(sig_nr);
vibrate(sig_nr);
} else {
// local filtering
if(strstr(packetBuffer,"usCode "))
{
sig_nr = packetBuffer[13];
Serial.println(sig_nr);
vibrate(sig_nr);
}
}
}
}

void setInitGPIO()
{
// Set all as OUTPUT
pinMode(PIN_LED, OUTPUT);
pinMode(PIN_Z, OUTPUT);
pinMode(PIN_V, OUTPUT);
pinMode(PIN_R, OUTPUT);
pinMode(PIN_L, OUTPUT);
// Bisher ungenutzte Pins
pinMode(PIN_27, OUTPUT);
pinMode(PIN_12, OUTPUT);
pinMode(PIN_13, OUTPUT);
pinMode(PIN_A5, OUTPUT);
pinMode(PIN_A1, OUTPUT);
pinMode(PIN_A0, OUTPUT);
allLow();
}

void allLow()
{
// Set all LOW
digitalWrite(PIN_LED, LOW);
digitalWrite(PIN_Z, LOW);
digitalWrite(PIN_V, LOW);
digitalWrite(PIN_R, LOW);
digitalWrite(PIN_L, LOW);
// Bisher ungenutzte Pins
digitalWrite(PIN_27, LOW);
digitalWrite(PIN_12, LOW);
digitalWrite(PIN_13, LOW);
digitalWrite(PIN_A5, LOW);
digitalWrite(PIN_A1, LOW);
digitalWrite(PIN_A0, LOW);
}

void errorWiFi()
{
Serial.println("...Failed while connecting to Network");
delay(2000);
while(true)
{
digitalWrite(PIN_LED, HIGH);
delay(100);
digitalWrite(PIN_LED, LOW);
delay(100);
digitalWrite(PIN_LED, HIGH);
delay(100);
digitalWrite(PIN_LED, LOW);
delay(1000);
}
}

void successWiFi()
{
Serial.print("You're connected to the network");
// Print out data
printCurrentNet();
printWifiData();
delay(2000);
for(int i = 0; i < 5; i++)
{
digitalWrite(PIN_LED, HIGH);
delay(1000);
digitalWrite(PIN_LED, LOW);
delay(200);
}
}

void vibrate(const char signr)
{
switch(signr)
{
case '4': digitalWrite(PIN_Z, HIGH); break;
case '3': digitalWrite(PIN_V, HIGH); break;
case '2': digitalWrite(PIN_R, HIGH); break;
case '1': digitalWrite(PIN_L, HIGH); break;
case '0': allLow(); break;
}
}

Loading…
Cancel
Save