From 386bc35abb923a0cd1f6077a48b06f507c1406fe Mon Sep 17 00:00:00 2001
From: manzerbredes <loic.guegan_secondary@yahoo.fr>
Date: Wed, 30 Mar 2016 17:59:50 +0200
Subject: [PATCH] Add args parser

---
 src/app/App.java                  | 26 +++++++++++++++++++-------
 src/args/ArgsTypeA.java           |  6 ++++++
 src/drivers/Driver_1770_ff00.java |  7 ++++++-
 3 files changed, 31 insertions(+), 8 deletions(-)
 create mode 100644 src/args/ArgsTypeA.java

diff --git a/src/app/App.java b/src/app/App.java
index fd10967..25d8d7a 100644
--- a/src/app/App.java
+++ b/src/app/App.java
@@ -1,5 +1,15 @@
 package org.manzerbredes.open_klm.app;
 
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import javax.sound.sampled.AudioFormat;
+import javax.sound.sampled.AudioSystem;
+import javax.sound.sampled.DataLine;
+import javax.sound.sampled.LineUnavailableException;
+import javax.sound.sampled.SourceDataLine;
+import javax.sound.sampled.TargetDataLine;
+
 import org.kohsuke.args4j.CmdLineException;
 import org.kohsuke.args4j.CmdLineParser;
 import org.kohsuke.args4j.Option;
@@ -44,21 +54,23 @@ public class App
 		
 	}
 	
-    public static void main( String[] args ) throws InstantiationException, CmdLineException
+    public static void main( String[] args ) throws InstantiationException, CmdLineException, LineUnavailableException, IOException
     {
     	 App app =new App();
     	 CmdLineParser parser = new CmdLineParser(app);
     	 parser.parseArgument(args);
-    	 app.parseArguments();
-    	new MainWindow();
-		/*DriverTypeA device=new Driver_1770_ff00();
+    	//app.parseArguments();
+    //	new MainWindow();
+		DriverTypeA device=new Driver_1770_ff00();
 		Driver a=(Driver) device;
 		a.initDriver();
 		device.setRegionColor(Region.LEFT, Color.RED, Intensity.HIGH);
 		device.setRegionColor(Region.MIDDLE, Color.ORANGE, Intensity.HIGH);
 		device.setRegionColor(Region.RIGHT, Color.PURPLE, Intensity.HIGH);
-
-		device.setMode(Mode.BREATHE);*/
-
+		device.setMode(Mode.NORMAL);
+	
+		
+		
     }
 }
+
diff --git a/src/args/ArgsTypeA.java b/src/args/ArgsTypeA.java
new file mode 100644
index 0000000..eb172ef
--- /dev/null
+++ b/src/args/ArgsTypeA.java
@@ -0,0 +1,6 @@
+package org.manzerbredes.open_klm.args;
+
+
+public class ArgsTypeA{
+	
+}
\ No newline at end of file
diff --git a/src/drivers/Driver_1770_ff00.java b/src/drivers/Driver_1770_ff00.java
index 01e9f59..c0f450b 100644
--- a/src/drivers/Driver_1770_ff00.java
+++ b/src/drivers/Driver_1770_ff00.java
@@ -102,8 +102,10 @@ public class Driver_1770_ff00 implements Driver, DriverTypeA{
 	@Override
 	public void setRegionColor(Region region, Color color, Intensity intensity) {
 		try {
+			// Set the color of the region
 			this.device.sendFeatureReport(this.getReport(1,2,66,region.intValue(),color.intValue(),intensity.intValue(),0,236));
 			this.commit();
+			// Save the color of the region
 			this.primaryColorsState.put(region, new Pair<DriverTypeA.Color, DriverTypeA.Intensity>(color, intensity));
 		} catch (IOException e) {
 			e.printStackTrace();
@@ -116,10 +118,12 @@ public class Driver_1770_ff00 implements Driver, DriverTypeA{
 	@Override
 	public void setColor(Color color, Intensity intensity) {
 		try {
+			// Apply color to all region
 			this.device.sendFeatureReport(this.getReport(1,2,66,Region.LEFT.intValue(),color.intValue(),intensity.intValue(),0,236));
 			this.device.sendFeatureReport(this.getReport(1,2,66,Region.MIDDLE.intValue(),color.intValue(),intensity.intValue(),0,236));
 			this.device.sendFeatureReport(this.getReport(1,2,66,Region.RIGHT.intValue(),color.intValue(),intensity.intValue(),0,236));
 			this.commit();
+			// Save the color of all region
 			this.primaryColorsState.put(Region.LEFT, new Pair<DriverTypeA.Color, DriverTypeA.Intensity>(color, intensity));
 			this.primaryColorsState.put(Region.MIDDLE, new Pair<DriverTypeA.Color, DriverTypeA.Intensity>(color, intensity));
 			this.primaryColorsState.put(Region.RIGHT, new Pair<DriverTypeA.Color, DriverTypeA.Intensity>(color, intensity));
@@ -155,7 +159,6 @@ public class Driver_1770_ff00 implements Driver, DriverTypeA{
 
 			}
 		}
-		
 		// Apply mode
 		this.commit();
 	}
@@ -169,6 +172,7 @@ public class Driver_1770_ff00 implements Driver, DriverTypeA{
 
 	@Override
 	public void setSecondaryColor(Color color, Intensity intensity) {
+		// Set the secondary color of al regions
 		this.secondaryColorsState.put(Region.LEFT, new Pair<DriverTypeA.Color, DriverTypeA.Intensity>(color, intensity));
 		this.secondaryColorsState.put(Region.MIDDLE, new Pair<DriverTypeA.Color, DriverTypeA.Intensity>(color, intensity));
 		this.secondaryColorsState.put(Region.RIGHT, new Pair<DriverTypeA.Color, DriverTypeA.Intensity>(color, intensity));
@@ -177,6 +181,7 @@ public class Driver_1770_ff00 implements Driver, DriverTypeA{
 
 	@Override
 	public void setSecondaryRegionColor(Region region, Color color, Intensity intensity) {
+		// Set the secondary color of the region
 		this.secondaryColorsState.put(region, new Pair<DriverTypeA.Color, DriverTypeA.Intensity>(color, intensity));
 	}