diff --git a/.classpath b/.classpath index e1bc20c..4e9fdd0 100644 --- a/.classpath +++ b/.classpath @@ -1,14 +1,10 @@ - - - - - + - + diff --git a/.gitignore b/.gitignore index f7df38e..e65ee4d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ /LampDemo.class +/Test.class +/LEDDemo.class diff --git a/.project b/.project index da80612..dd45e83 100644 --- a/.project +++ b/.project @@ -1,6 +1,6 @@ - ArduinoOSX + EmoJArduino diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 8000cd6..a698e59 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,11 +1,12 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/LampDemo.java b/LEDDemo.java similarity index 78% rename from LampDemo.java rename to LEDDemo.java index c0f538e..40d3da0 100644 --- a/LampDemo.java +++ b/LEDDemo.java @@ -7,16 +7,16 @@ import java.net.UnknownHostException; import org.json.*; import arduino.Arduino; -public class LampDemo { - private static boolean LAMP_ON = false; +public class LEDDemo { + private static boolean LED_ON = false; public static void main(String[] args) throws UnknownHostException, IOException, JSONException { double threshold = 0.5; - Arduino ard = new Arduino("/dev/cu.usbserial-AD01VFL0"); + Arduino ard = new Arduino("/dev/cu.usbserial-AD01VFL0"); //change this //connect the Arduino ard.connect(); String params; String JSONResponse; - BufferedReader inFromUser = new BufferedReader( new InputStreamReader(System.in)); + BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in)); //run API_Main for the EPOC server socket try { @@ -27,8 +27,8 @@ public class LampDemo { Socket clientSocket = new Socket("localhost", 2222); DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream()); - //get user param and use that to turn on the lamp and send to server - System.out.println("Enter 2 EEG events to control lamp (separated by commas): "); + //get user param and use that to turn on the LED and send to server + System.out.println("Enter 2 EEG events to control LED (separated by commas): "); BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream())); params = inFromUser.readLine(); outToServer.writeBytes(params + '\n'); @@ -48,12 +48,12 @@ public class LampDemo { for (int i = 0; i < array.length(); i++) { double param_val = array.getJSONObject(i).getDouble(token); if (param_val > threshold && token == tokens[0]) { - //turn on lamp - lampSwitch(ard, LAMP_ON); + //turn on LED + LEDSwitch(ard); } else if (param_val > threshold && token == tokens[1]) { - //turn off lamp - lampSwitch(ard, LAMP_ON); + //turn off LED + LEDSwitch(ard); } } } @@ -63,12 +63,12 @@ public class LampDemo { if (cog_action.equals(token)) { double param_val = obj.getJSONObject("EmoStateData").getDouble("Cognitiv"); if (param_val > threshold && token == tokens[0]) { - //turn on lamp - lampSwitch(ard, LAMP_ON); + //turn on LED + LEDSwitch(ard); } else if (param_val > threshold && token == tokens[1]) { - //turn off lamp - lampSwitch(ard, LAMP_ON); + //turn off LED + LEDSwitch(ard); } } } @@ -91,16 +91,15 @@ public class LampDemo { } } - public static void lampSwitch(Arduino ard, boolean lampON) { - if (lampON) { - System.out.println("Shutting off lamp..."); + public static void LEDSwitch(Arduino ard) { + if (LED_ON) { + System.out.println("Shutting off LED..."); ard.digitalWrite(13, false); - LAMP_ON = !LAMP_ON; } else { - System.out.println("Turning on lamp..."); + System.out.println("Turning on LED..."); ard.digitalWrite(13, true); - LAMP_ON = !LAMP_ON; } + LED_ON = !LED_ON; } } diff --git a/Test.class b/Test.class index c2403f6..4bab284 100644 Binary files a/Test.class and b/Test.class differ