Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
PedroLopes committed Feb 1, 2017
2 parents bc1994b + 8bc4381 commit fde5150
Show file tree
Hide file tree
Showing 37 changed files with 24 additions and 22 deletions.
4 changes: 2 additions & 2 deletions apps/python/send_single_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from pyEMS import openEMSstim
from pyEMS.EMSCommand import ems_command

my_ems_board = openEMSstim.openEMSstim("/dev/tty.wchusbserial14220",19200)
my_ems_board = openEMSstim.openEMSstim("/dev/tty.usbserial-A98VFLTL",19200)
while 1:
choice = int(raw_input("1 or 2? EMS with full intensity on that channel for 2 seconds"))
my_ems_board.send(ems_command(choice,100,2000))
my_ems_board.send(ems_command(choice,100,9000))


9 changes: 0 additions & 9 deletions apps/unity/EMS_Pong/Assets/Plugins.meta

This file was deleted.

Binary file modified apps/unity/EMS_Pong/library/ScriptAssemblies/Assembly-CSharp.dll
Binary file not shown.
Binary file not shown.
Binary file modified apps/unity/EMS_Pong/library/assetDatabase3
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion arduino-openEMSstim/Rn4020BTLe.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void Rn4020BTLe::init(String bluetoothName) {
Serial.println();
delay(2000);
if ( notification.length()>0){
serial->begin(2400);
serial->begin(2400);
}else{
serial->begin(19200);
}
Expand Down
31 changes: 21 additions & 10 deletions arduino-openEMSstim/arduino-openEMSstim.ino
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ const char* const string_table_outputs[] PROGMEM = {ems_channel_1_active, ems_ch

char buffer[32];


//process a command message (according to protocol, check https://bitbucket.org/MaxPfeiffer/letyourbodymove/)
//process a command message (according to protocol, check github for that)
void processMessage(String message) {
if (message.charAt(0) == 'W' && message.charAt(1) == 'V') {
int lastIndexOfComma = message.lastIndexOf(',');
Expand All @@ -162,16 +161,27 @@ void processMessage(String message) {
else {
printer("\tCommand NON HEX:");
printer(message);
//doCommand(&message);
//printer("\tERROR: HEX Command Unknown");
doCommand(message[0]);
}
}



//For testing
// TESTING COMMANDS
// For quick testing (e.g., opening the optocoupler ports, etc) you can use these single-char commands (one command = one char).
// The cavailable commands are:
// "1": toggles the channel 1 between open/closed state (when the channel is closed, the potenciometer position is reset to minimum, i.e., 255)
// "2": toggles the channel 1 between open/closed state (when the channel is closed, the potenciometer position is reset to minimum, i.e., 255)
// "q": increases EMS signal on channel 1 by decreasing the digital potenciometer wiper position (i.e., resistance lowers and more EMS is passing)
// -> note that you have full EMS signal when the potentiometer wiper is at 0 (0 is the maximum)
// "a": decreases EMS signal on channel 1 by increasing the digital potenciometer wiper position (i.e., resistance lowers and more EMS is passing)
// -> note that you have no EMS signal when the potentiometer wiper is at 255 (255 is the maximum resistance of the potentiometer)
// "w": increases EMS signal on channel 2 by decreasing the digital potenciometer wiper position (i.e., resistance lowers and more EMS is passing)
// -> note that you have full EMS signal when the potentiometer wiper is at 0 (0 is the maximum)
// "s": decreases EMS signal on channel 2 by increasing the digital potenciometer wiper position (i.e., resistance lowers and more EMS is passing)
// -> note that you have no EMS signal when the potentiometer wiper is at 255 (255 is the maximum resistance of the potentiometer)
void doCommand(char c) {
if (c == '1') {
if (c == '1') {
if (emsChannel1.isActivated()) {
emsChannel1.deactivate();
strcpy_P(buffer, (char*)pgm_read_word(&(string_table_outputs[1])));
Expand All @@ -191,27 +201,28 @@ void doCommand(char c) {
strcpy_P(buffer, (char*)pgm_read_word(&(string_table_outputs[2])));
printer(buffer); //"\tEMS: Channel 2 inactive"
}
} else if (c == 'q') {
} else if (c == 'a') {
digitalPot.setPosition(1, digitalPot.getPosition(1) + 1);
strcpy_P(buffer, (char*)pgm_read_word(&(string_table_outputs[4])));
printer(
buffer + String(digitalPot.getPosition(1))); //"\tEMS: Intensity Channel 1: "
} else if (c == 'w') {
} else if (c == 'q') {
strcpy_P(buffer, (char*)pgm_read_word(&(string_table_outputs[4])));
digitalPot.setPosition(1, digitalPot.getPosition(1) - 1);
printer(
buffer + String(digitalPot.getPosition(1))); //"\tEMS: Intensity Channel 1: "
} else if (c == 'e') {
} else if (c == 's') {
//Note that this is channel 3 on Digipot but EMS channel 2
digitalPot.setPosition(3, digitalPot.getPosition(3) + 1);
strcpy_P(buffer, (char*)pgm_read_word(&(string_table_outputs[5])));
printer(
buffer + String(digitalPot.getPosition(3))); //"\tEMS: Intensity Channel 2: "
} else if (c == 'r') {
} else if (c == 'w') {
//Note that this is channel 3 on Digipot but EMS channel 2
digitalPot.setPosition(3, digitalPot.getPosition(3) - 1);
strcpy_P(buffer, (char*)pgm_read_word(&(string_table_outputs[5])));
printer(
buffer + String(digitalPot.getPosition(3))); //"\tEMS: Intensity Channel 2: "
}
else printer("\tERROR: SINGLE-CHAR Command Unknown");
}

0 comments on commit fde5150

Please sign in to comment.