diff --git a/Light_Controller/application.macosx/Light_Controller.app/Contents/Info.plist b/Light_Controller/application.macosx/Light_Controller.app/Contents/Info.plist deleted file mode 100644 index ade89f7..0000000 --- a/Light_Controller/application.macosx/Light_Controller.app/Contents/Info.plist +++ /dev/null @@ -1,78 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - Light_Controller - CFBundleIconFile - sketch.icns - CFBundleIdentifier - Light_Controller - CFBundleDisplayName - Light_Controller - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - Light_Controller - CFBundlePackageType - APPL - - - CFBundleShortVersionString - 1 - CFBundleVersion - 1 - CFBundleSignature - ???? - NSHumanReadableCopyright - Your copyright here - CFBundleGetInfoString - Created with Processing - - - - - JVMMainClassName - Light_Controller - - LSMinimumSystemVersion - 10.7.3 - - NSHighResolutionCapable - - - LSArchitecturePriority - - x86_64 - - - LSEnvironment - - LC_CTYPE - UTF-8 - - - LSUIPresentationMode - 0 - - LSUIElement - - - JVMOptions - - -Djna.nosys=true - - -Xdock:icon=Contents/Resources/sketch.icns - -Dapple.laf.useScreenMenuBar=true - -Dcom.apple.macos.use-file-dialog-packages=true - -Dcom.apple.macos.useScreenMenuBar=true - -Dcom.apple.mrj.application.apple.menu.about.name=Light_Controller - -Dcom.apple.smallTabs=true - - JVMArguments - - - - diff --git a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/Light_Controller.jar b/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/Light_Controller.jar deleted file mode 100644 index 5e9a89a..0000000 Binary files a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/Light_Controller.jar and /dev/null differ diff --git a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/core.jar b/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/core.jar deleted file mode 100644 index 115971a..0000000 Binary files a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/core.jar and /dev/null differ diff --git a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/gluegen-rt-natives-macosx-universal.jar b/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/gluegen-rt-natives-macosx-universal.jar deleted file mode 100644 index 1307317..0000000 Binary files a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/gluegen-rt-natives-macosx-universal.jar and /dev/null differ diff --git a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/gluegen-rt.jar b/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/gluegen-rt.jar deleted file mode 100644 index c20455e..0000000 Binary files a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/gluegen-rt.jar and /dev/null differ diff --git a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/jl1.0.jar b/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/jl1.0.jar deleted file mode 100644 index 17f7c0a..0000000 Binary files a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/jl1.0.jar and /dev/null differ diff --git a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/jogl-all-natives-macosx-universal.jar b/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/jogl-all-natives-macosx-universal.jar deleted file mode 100644 index 35f72f5..0000000 Binary files a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/jogl-all-natives-macosx-universal.jar and /dev/null differ diff --git a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/jogl-all.jar b/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/jogl-all.jar deleted file mode 100644 index 1d048da..0000000 Binary files a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/jogl-all.jar and /dev/null differ diff --git a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/jsminim.jar b/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/jsminim.jar deleted file mode 100644 index 0b61d9b..0000000 Binary files a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/jsminim.jar and /dev/null differ diff --git a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/jssc.backup.txt b/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/jssc.backup.txt deleted file mode 100644 index 7174ece..0000000 --- a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/jssc.backup.txt +++ /dev/null @@ -1,4 +0,0 @@ -This is using a modified version of Java Simple Serial Connector by Alexey Sokolov. See https://github.com/gohai/java-simple-serial-connector for details on the modifications. - -To compile the C++ portion of the library on OS X: -g++ -shared [or: -dynamiclib?] -arch i386 -arch x86_64 -I/System/Library/Frameworks/IOKit.framework/Versions/A/Headers -I$JAVA_HOME/include -I$JAVA_HOME/include/darwin -framework IOKit -framework CoreFoundation -o libjSSC-2.6.jnilib jssc.cpp diff --git a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/jssc.jar b/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/jssc.jar deleted file mode 100644 index 93269cf..0000000 Binary files a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/jssc.jar and /dev/null differ diff --git a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/jssc.txt b/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/jssc.txt deleted file mode 100644 index 63d9c89..0000000 Binary files a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/jssc.txt and /dev/null differ diff --git a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/libjSSC-2.8.jnilib b/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/libjSSC-2.8.jnilib deleted file mode 100644 index 012a168..0000000 Binary files a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/libjSSC-2.8.jnilib and /dev/null differ diff --git a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/minim.jar b/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/minim.jar deleted file mode 100644 index 35da1d5..0000000 Binary files a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/minim.jar and /dev/null differ diff --git a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/mp3spi1.9.4.jar b/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/mp3spi1.9.4.jar deleted file mode 100644 index 019b86c..0000000 Binary files a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/mp3spi1.9.4.jar and /dev/null differ diff --git a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/serial.jar b/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/serial.jar deleted file mode 100644 index cedeeb8..0000000 Binary files a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/serial.jar and /dev/null differ diff --git a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/tritonus_aos.jar b/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/tritonus_aos.jar deleted file mode 100644 index 4a02386..0000000 Binary files a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/tritonus_aos.jar and /dev/null differ diff --git a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/tritonus_share.jar b/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/tritonus_share.jar deleted file mode 100644 index bb367d1..0000000 Binary files a/Light_Controller/application.macosx/Light_Controller.app/Contents/Java/tritonus_share.jar and /dev/null differ diff --git a/Light_Controller/application.macosx/Light_Controller.app/Contents/MacOS/Light_Controller b/Light_Controller/application.macosx/Light_Controller.app/Contents/MacOS/Light_Controller deleted file mode 100755 index 48de106..0000000 Binary files a/Light_Controller/application.macosx/Light_Controller.app/Contents/MacOS/Light_Controller and /dev/null differ diff --git a/Light_Controller/application.macosx/Light_Controller.app/Contents/PkgInfo b/Light_Controller/application.macosx/Light_Controller.app/Contents/PkgInfo deleted file mode 100644 index 6f749b0..0000000 --- a/Light_Controller/application.macosx/Light_Controller.app/Contents/PkgInfo +++ /dev/null @@ -1 +0,0 @@ -APPL???? diff --git a/Light_Controller/application.macosx/Light_Controller.app/Contents/Resources/en.lproj/Localizable.strings b/Light_Controller/application.macosx/Light_Controller.app/Contents/Resources/en.lproj/Localizable.strings deleted file mode 100644 index 0d306aa..0000000 --- a/Light_Controller/application.macosx/Light_Controller.app/Contents/Resources/en.lproj/Localizable.strings +++ /dev/null @@ -1,3 +0,0 @@ -"JRELoadError" = "Unable to load Java Runtime Environment."; -"MainClassNameRequired" = "Main class name is required."; -"JavaDirectoryNotFound" = "Unable to enumerate Java directory contents."; diff --git a/Light_Controller/application.macosx/Light_Controller.app/Contents/Resources/sketch.icns b/Light_Controller/application.macosx/Light_Controller.app/Contents/Resources/sketch.icns deleted file mode 100644 index 2bdb4df..0000000 Binary files a/Light_Controller/application.macosx/Light_Controller.app/Contents/Resources/sketch.icns and /dev/null differ diff --git a/Light_Controller/application.macosx/Light_Controller.app/Contents/_CodeSignature/CodeResources b/Light_Controller/application.macosx/Light_Controller.app/Contents/_CodeSignature/CodeResources deleted file mode 100644 index eeffa92..0000000 --- a/Light_Controller/application.macosx/Light_Controller.app/Contents/_CodeSignature/CodeResources +++ /dev/null @@ -1,201 +0,0 @@ - - - - - files - - Resources/en.lproj/Localizable.strings - - hash - - 1x7GcvnGdR/b251TU0nrD14zM/c= - - optional - - - Resources/sketch.icns - - V0eScs9jH/kx46PDDKFKW0jiUlA= - - - files2 - - Java/Light_Controller.jar - - w0qu8TMwkCm2VeznGYwL0AKsOtQ= - - Java/core.jar - - 9yAhryCrC0UVAs0jLxdifhNloyE= - - Java/gluegen-rt-natives-macosx-universal.jar - - 11uvp9PE8pshoC2Ui3fprr9Rlyk= - - Java/gluegen-rt.jar - - APjYBlK7KesrkBL7r+HBYLqAd1w= - - Java/jl1.0.jar - - ICDVRWV1CL2CvqsANZ3MUJlrh14= - - Java/jogl-all-natives-macosx-universal.jar - - vfFs1wrGn5GXlnQXxB6q14dTj7k= - - Java/jogl-all.jar - - +x0SaYucrNLvSRtPISbciy2yp4E= - - Java/jsminim.jar - - sqOg49tOG8G2BNaKXtoq9av318Y= - - Java/jssc.backup.txt - - oNMgccwbKmCFTlmq4LOmgufSvZk= - - Java/jssc.jar - - +2l8Vvq2Gt4LSm5tKTdyWYaj+Q4= - - Java/jssc.txt - - SwiuX6rcaizr4Zu7OOeoZl6Hjus= - - Java/libjSSC-2.8.jnilib - - e62Pi7yGa2wCqoFf4HOBIsgRH40= - - Java/minim.jar - - PJw/Dsv3rpptpOqmw0BIx7bGxQg= - - Java/mp3spi1.9.4.jar - - vsyxo+dm0L14KhdNfMoKR7o7idg= - - Java/serial.jar - - 3+xMXyqSnh0pgELHQF2ripYQ4p8= - - Java/tritonus_aos.jar - - +CO4n2N7Zc7VSnfrfPAM9i5oFH4= - - Java/tritonus_share.jar - - 5WRtooC+nx4HMBs1M5o3asZA358= - - Resources/en.lproj/Localizable.strings - - hash - - 1x7GcvnGdR/b251TU0nrD14zM/c= - - optional - - - Resources/sketch.icns - - V0eScs9jH/kx46PDDKFKW0jiUlA= - - - rules - - ^Resources/ - - ^Resources/.*\.lproj/ - - optional - - weight - 1000 - - ^Resources/.*\.lproj/locversion.plist$ - - omit - - weight - 1100 - - ^version.plist$ - - - rules2 - - .*\.dSYM($|/) - - weight - 11 - - ^(.*/)?\.DS_Store$ - - omit - - weight - 2000 - - ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/ - - nested - - weight - 10 - - ^.* - - ^Info\.plist$ - - omit - - weight - 20 - - ^PkgInfo$ - - omit - - weight - 20 - - ^Resources/ - - weight - 20 - - ^Resources/.*\.lproj/ - - optional - - weight - 1000 - - ^Resources/.*\.lproj/locversion.plist$ - - omit - - weight - 1100 - - ^[^/]+$ - - nested - - weight - 10 - - ^embedded\.provisionprofile$ - - weight - 20 - - ^version\.plist$ - - weight - 20 - - - - diff --git a/Light_Controller/application.macosx/source/BeatListener.java b/Light_Controller/application.macosx/source/BeatListener.java deleted file mode 100644 index 6b1f5a3..0000000 --- a/Light_Controller/application.macosx/source/BeatListener.java +++ /dev/null @@ -1,31 +0,0 @@ -import ddf.minim.analysis.BeatDetect; -import ddf.minim.AudioInput; -import ddf.minim.AudioListener; - -// This class adds a listener to Minim's BeatDetect class so that -// BeatDetect.detect() is automatically called whenever a new audio buffer -// arrives. -public class BeatListener implements AudioListener -{ - private BeatDetect beat; - private AudioInput source; - - public BeatListener( BeatDetect beat, AudioInput source ) - { - this.source = source; - this.source.addListener( this ); - this.beat = beat; - } - - // Whenever the AudioInput has buffers, this will be called - public void samples( float[] samples ) - { - beat.detect( source.mix ); - } - - // or this one. Depending on the channel. - public void samples( float[] samples_left, float[] samples_right ) - { - beat.detect( source.mix ); - } -} diff --git a/Light_Controller/application.macosx/source/Demos.java b/Light_Controller/application.macosx/source/Demos.java deleted file mode 100644 index a5f7070..0000000 --- a/Light_Controller/application.macosx/source/Demos.java +++ /dev/null @@ -1,330 +0,0 @@ -public class Demos -{ - private Demos() {} - - // To convert these js fles to strings: - // 1. Replace " with \\" - - // Some compilers don't like you splitting lines without closing a string. - // to take care of that: - // 2. Replace \n with \\n"+\n" - - // 3. Paste the contents in between two double quotes. ("") - - // Note: You need to use a find and replace that supports regex. I recommend - // Sublime Text for this. Atom doesn't work for some reason. - - public static final String kick_detect_color = - "/* This is a plugin example. Plugins are written in JavaScript.\n"+ - " Plugins placed in this folder will automatically show up in\n"+ - " the taskbar (Windows)/menubar (Mac)/nowhere (Linux) (help wanted). */\n"+ - "\n"+ - "\n"+ - "/* The following variables along with all of their methods\n"+ - " are available to you in this scirpt. Hint: leds.length\n"+ - " is the number of LED segments the user has set.*/\n"+ - "\n"+ - "/*//////// AVAILABLE VARIABLES ////////////\n"+ - "// Java Class JavaScript var name //\n"+ - "// ________________ ____________________ //\n"+ - "// int[NUM_LEDS][3] leds //\n"+ - "// FFT FFT //\n"+ - "// BeatDetect BeatDetect //\n"+ - "/////////////////////////////////////////*/\n"+ - "\n"+ - "/* Below are the JavaDocs for these classes:\n"+ - " FFT:\n"+ - " http://code.compartmental.net/minim/javadoc/ddf/minim/analysis/FFT.html\n"+ - " BeatDetect:\n"+ - " http://code.compartmental.net/minim/javadoc/ddf/minim/analysis/BeatDetect.html\n"+ - "*/\n"+ - "\n"+ - "/* The update function will automatically be called\n"+ - " 30 times per second. After update finishes, the\n"+ - " leds[][] array will be sent to the Arduino. */\n"+ - "\n"+ - "\n"+ - "// This example will pulse when a kick drum sound is detected from the\n"+ - "// audio input. (Soundflower (2ch) by default)\n"+ - "var brightness = 0;\n"+ - "function update()\n"+ - "{\n"+ - " if ( BeatDetect.isKick() )\n"+ - " {\n"+ - " brightness = 255;\n"+ - " }\n"+ - " else\n"+ - " brightness *= 0.65;\n"+ - "\n"+ - " for(var i = 0; i < leds.length; i++)\n"+ - " {\n"+ - " leds[i][0] = brightness;\n"+ - " leds[i][1] = brightness;\n"+ - " leds[i][2] = brightness;\n"+ - " }\n"+ - "}\n"+ - ""; - - public static final String kick_detect = - "/* This is a plugin example. Plugins are written in JavaScript.\n"+ -" Plugins placed in this folder will automatically show up in\n"+ -" the taskbar (Windows)/menubar (Mac)/nowhere (Linux) (help wanted). */\n"+ -"\n"+ -"\n"+ -"/* The following variables along with all of their methods\n"+ -" are available to you in this scirpt. Hint: leds.length\n"+ -" is the number of LED segments the user has set.*/\n"+ -"\n"+ -"/*//////// AVAILABLE VARIABLES ////////////\n"+ -"// Java Class JavaScript var name //\n"+ -"// ________________ ____________________ //\n"+ -"// int[NUM_LEDS][3] leds //\n"+ -"// FFT FFT //\n"+ -"// BeatDetect BeatDetect //\n"+ -"/////////////////////////////////////////*/\n"+ -"\n"+ -"/* Below are the JavaDocs for these classes:\n"+ -" FFT:\n"+ -" http://code.compartmental.net/minim/javadoc/ddf/minim/analysis/FFT.html\n"+ -" BeatDetect:\n"+ -" http://code.compartmental.net/minim/javadoc/ddf/minim/analysis/BeatDetect.html\n"+ -"*/\n"+ -"\n"+ -"/* The update function will automatically be called\n"+ -" 30 times per second. After update finishes, the\n"+ -" leds[][] array will be sent to the Arduino. */\n"+ -"\n"+ -"\n"+ -"// This example will pulse when a kick drum sound is detected from the\n"+ -"// audio input. (Soundflower (2ch) by default)\n"+ -"var brightness = 0;\n"+ -"function update()\n"+ -"{\n"+ -" if ( BeatDetect.isKick() )\n"+ -" {\n"+ -" brightness = 255;\n"+ -" }\n"+ -" else\n"+ -" brightness *= 0.65;\n"+ -"\n"+ -" for(var i = 0; i < leds.length; i++)\n"+ -" {\n"+ -" leds[i][0] = brightness;\n"+ -" leds[i][1] = brightness;\n"+ -" leds[i][2] = brightness;\n"+ -" }\n"+ -"}\n"+ -""; - - public static final String pulse = - "/* This is a plugin example. Plugins are written in JavaScript.\n"+ -" Plugins placed in this folder will automatically show up in\n"+ -" the taskbar (Windows)/menubar (Mac)/nowhere (Linux) (help wanted). */\n"+ -"\n"+ -"\n"+ -"/* The following variables along with all of their methods\n"+ -" are available to you in this scirpt. Hint: leds.length\n"+ -" is the number of LED segments the user has set.*/\n"+ -"\n"+ -"/*//////// AVAILABLE VARIABLES ////////////\n"+ -"// Java Class JavaScript var name //\n"+ -"// ________________ ____________________ //\n"+ -"// int[NUM_LEDS][3] leds //\n"+ -"// FFT FFT //\n"+ -"// BeatDetect BeatDetect //\n"+ -"/////////////////////////////////////////*/\n"+ -"\n"+ -"/* Below are the JavaDocs for these classes:\n"+ -" FFT:\n"+ -" http://code.compartmental.net/minim/javadoc/ddf/minim/analysis/FFT.html\n"+ -" BeatDetect:\n"+ -" http://code.compartmental.net/minim/javadoc/ddf/minim/analysis/BeatDetect.html\n"+ -"*/\n"+ -"\n"+ -"/* The update function will automatically be called\n"+ -" 30 times per second. After update finishes, the\n"+ -" leds[][] array will be sent to the Arduino. */\n"+ -"\n"+ -"\n"+ -"// This example will pulse white\n"+ -"var c = 0;\n"+ -"function update()\n"+ -"{\n"+ -" for(var i = 0; i < leds.length; i++)\n"+ -" {\n"+ -" leds[i][0] = Math.sin(c)*127+127;\n"+ -" leds[i][1] = leds[i][0];\n"+ -" leds[i][2] = leds[i][1];\n"+ -" }\n"+ -" c += 0.1;\n"+ -"}\n"+ -""; - - public static final String rainbow = - "/* This is a plugin example. Plugins are written in JavaScript.\n"+ -" Plugins placed in this folder will automatically show up in\n"+ -" the taskbar (Windows)/menubar (Mac)/nowhere (Linux) (help wanted). */\n"+ -"\n"+ -"\n"+ -"/* The following variables along with all of their methods\n"+ -" are available to you in this scirpt. Hint: leds.length\n"+ -" is the number of LED segments the user has set.*/\n"+ -"\n"+ -"/*//////// AVAILABLE VARIABLES ////////////\n"+ -"// Java Class JavaScript var name //\n"+ -"// ________________ ____________________ //\n"+ -"// int[NUM_LEDS][3] leds //\n"+ -"// FFT FFT //\n"+ -"// BeatDetect BeatDetect //\n"+ -"/////////////////////////////////////////*/\n"+ -"\n"+ -"/* Below are the JavaDocs for these classes:\n"+ -" FFT:\n"+ -" http://code.compartmental.net/minim/javadoc/ddf/minim/analysis/FFT.html\n"+ -" BeatDetect:\n"+ -" http://code.compartmental.net/minim/javadoc/ddf/minim/analysis/BeatDetect.html\n"+ -"*/\n"+ -"\n"+ -"/* The update function will automatically be called\n"+ -" 30 times per second. After update finishes, the\n"+ -" leds[][] array will be sent to the Arduino. */\n"+ -"\n"+ -"\n"+ -"// This example will fade through a rainbow of colors\n"+ -"var value = 0;\n"+ -"function update()\n"+ -"{\n"+ -" value += 0.01;\n"+ -"\n"+ -" for(var i = 0; i < leds.length; i++)\n"+ -" {\n"+ -" var rgb = HSVtoRGB(value%1, 1, 1);\n"+ -" leds[i][0] = rgb.r;\n"+ -" leds[i][1] = rgb.g;\n"+ -" leds[i][2] = rgb.b;\n"+ -" }\n"+ -"}\n"+ -"\n"+ -"// Taken from here: http://stackoverflow.com/questions/17242144/javascript-convert-hsb-hsv-color-to-rgb-accurately\n"+ -"function HSVtoRGB(h, s, v) {\n"+ -" var r, g, b, i, f, p, q, t;\n"+ -" if (arguments.length === 1) {\n"+ -" s = h.s, v = h.v, h = h.h;\n"+ -" }\n"+ -" i = Math.floor(h * 6);\n"+ -" f = h * 6 - i;\n"+ -" p = v * (1 - s);\n"+ -" q = v * (1 - f * s);\n"+ -" t = v * (1 - (1 - f) * s);\n"+ -" switch (i % 6) {\n"+ -" case 0: r = v, g = t, b = p; break;\n"+ -" case 1: r = q, g = v, b = p; break;\n"+ -" case 2: r = p, g = v, b = t; break;\n"+ -" case 3: r = p, g = q, b = v; break;\n"+ -" case 4: r = t, g = p, b = v; break;\n"+ -" case 5: r = v, g = p, b = q; break;\n"+ -" }\n"+ -" return {\n"+ -" r: Math.round(r * 255),\n"+ -" g: Math.round(g * 255),\n"+ -" b: Math.round(b * 255)\n"+ -" };\n"+ -"}\n"+ -""; - - public static final String pink = - "/* This is a plugin example. Plugins are written in JavaScript.\n"+ -" Plugins placed in this folder will automatically show up in\n"+ -" the taskbar (Windows)/menubar (Mac)/nowhere (Linux) (help wanted). */\n"+ -"\n"+ -"\n"+ -"/* The following variables along with all of their methods\n"+ -" are available to you in this scirpt. Hint: leds.length\n"+ -" is the number of LED segments the user has set.*/\n"+ -"\n"+ -"/*//////// AVAILABLE VARIABLES ////////////\n"+ -"// Java Class JavaScript var name //\n"+ -"// ________________ ____________________ //\n"+ -"// int[NUM_LEDS][3] leds //\n"+ -"// FFT FFT //\n"+ -"// BeatDetect BeatDetect //\n"+ -"/////////////////////////////////////////*/\n"+ -"\n"+ -"/* Below are the JavaDocs for these classes:\n"+ -" FFT:\n"+ -" http://code.compartmental.net/minim/javadoc/ddf/minim/analysis/FFT.html\n"+ -" BeatDetect:\n"+ -" http://code.compartmental.net/minim/javadoc/ddf/minim/analysis/BeatDetect.html\n"+ -"*/\n"+ -"\n"+ -"/* The update function will automatically be called\n"+ -" 30 times per second. After update finishes, the\n"+ -" leds[][] array will be sent to the Arduino. */\n"+ -"\n"+ -"\n"+ -"// This example will set the LEDs to deeppink\n"+ -"\n"+ -"// We're never changing the color from deeppink, so we only need to execute this\n"+ -"// code once. Therefore, we will put it outside the update function so that\n"+ -"// it's not run every time update is called.\n"+ -"for(var i = 0; i < leds.length; i++)\n"+ -"{\n"+ -" leds[i][0] = 255;\n"+ -" leds[i][1] = 20;\n"+ -" leds[i][2] = 147;\n"+ -"}\n"+ -"\n"+ -"function update()\n"+ -"{\n"+ -"\n"+ -"}\n"+ -""; - - public static final String red = - "/* This is a plugin example. Plugins are written in JavaScript.\n"+ -" Plugins placed in this folder will automatically show up in\n"+ -" the taskbar (Windows)/menubar (Mac)/nowhere (Linux) (help wanted). */\n"+ -"\n"+ -"\n"+ -"/* The following variables along with all of their methods\n"+ -" are available to you in this scirpt. Hint: leds.length\n"+ -" is the number of LED segments the user has set.*/\n"+ -"\n"+ -"/*//////// AVAILABLE VARIABLES ////////////\n"+ -"// Java Class JavaScript var name //\n"+ -"// ________________ ____________________ //\n"+ -"// int[NUM_LEDS][3] leds //\n"+ -"// FFT FFT //\n"+ -"// BeatDetect BeatDetect //\n"+ -"/////////////////////////////////////////*/\n"+ -"\n"+ -"/* Below are the JavaDocs for these classes:\n"+ -" FFT:\n"+ -" http://code.compartmental.net/minim/javadoc/ddf/minim/analysis/FFT.html\n"+ -" BeatDetect:\n"+ -" http://code.compartmental.net/minim/javadoc/ddf/minim/analysis/BeatDetect.html\n"+ -"*/\n"+ -"\n"+ -"/* The update function will automatically be called\n"+ -" 30 times per second. After update finishes, the\n"+ -" leds[][] array will be sent to the Arduino. */\n"+ -"\n"+ -"\n"+ -"// This example will set the LEDs to red\n"+ -"\n"+ -"// We're never changing the color from red, so we only need to execute this\n"+ -"// code once. Therefore, we will put it outside the update function so that\n"+ -"// it's not run every time update is called.\n"+ -"for(var i = 0; i < leds.length; i++)\n"+ -"{\n"+ -" leds[i][0] = 255;\n"+ -"}\n"+ -"\n"+ -"function update()\n"+ -"{\n"+ -"\n"+ -"}\n"+ -""; - - -} diff --git a/Light_Controller/application.macosx/source/FFTListener.java b/Light_Controller/application.macosx/source/FFTListener.java deleted file mode 100644 index 9fb4169..0000000 --- a/Light_Controller/application.macosx/source/FFTListener.java +++ /dev/null @@ -1,30 +0,0 @@ -import ddf.minim.analysis.FFT; -import ddf.minim.AudioInput; -import ddf.minim.AudioListener; - -// This class adds a listener to Minim's FFT class so that FFT.forward() -// is automatically called whenever a new audio buffer arrives. -public class FFTListener implements AudioListener -{ - private FFT fft; - private AudioInput source; - - public FFTListener( FFT fft, AudioInput source ) - { - this.source = source; - this.source.addListener( this ); - this.fft = fft; - } - - // Whenever the AudioInput has buffers, this will be called - public void samples( float[] samples ) - { - fft.forward( source.mix ); - } - - // or this one. Depending on the channel. - public void samples( float[] samples_left, float[] samples_right ) - { - fft.forward( source.mix ); - } -} diff --git a/Light_Controller/application.macosx/source/FileHandler.java b/Light_Controller/application.macosx/source/FileHandler.java deleted file mode 100644 index b0f03e5..0000000 --- a/Light_Controller/application.macosx/source/FileHandler.java +++ /dev/null @@ -1,141 +0,0 @@ -import java.io.File; -import java.io.FileNotFoundException; -import java.io.PrintWriter; -import javax.swing.JFileChooser; - -public class FileHandler -{ - private FileHandler() {} - - public static void startupChecks() - { - - // If the plugins path is not set, we will set it - if ( Settings.PLUGINS_PATH.equals("") ) - { - // This method doesn't work perfectly. In unix it will return - // only the user's home directory. So we add /Documents/ to it. - // Also has a lot of potential for failure in Windows since - // Windows seems to have an ever-shifting idea of what the - // Documents folder should be. - String os = System.getProperty( "os.name" ).toLowerCase(); - String docs = new JFileChooser().getFileSystemView() - .getDefaultDirectory().toString(); - if ( !( os.indexOf( "win" ) >= 0 ) ) - { - docs += File.separator + "Documents" + File.separator; - } - - Settings.savePLUGINS_PATH( docs + "Light Controller" + File.separator + "Plugins" + File.separator ); - } - - - // Initialize files if they don't exist - File plugins = new File ( Settings.PLUGINS_PATH ); - - // We want to check if this directory has been created - if ( !plugins.exists() ) - { - // This will attempt to create the directory - plugins = getFile( Settings.PLUGINS_PATH ); - - // Lets check again if it exists - if ( !plugins.exists() ) - { - // Something went wrong and we can't load the path - System.exit(1); - } - - writeDemos( Settings.PLUGINS_PATH ); - } - - } - - - public static void writeDemos( String plugins ) - { - if ( getFile( plugins ).exists() ) - { - writeDemo( plugins, "Kick Detect Color.js", Demos.kick_detect_color ); - writeDemo( plugins, "Kick Detect.js", Demos.kick_detect ); - writeDemo( plugins, "Pulse.js", Demos.pulse ); - writeDemo( plugins, "Rainbow.js", Demos.rainbow ); - - if ( getFile( plugins + "Solid Colors/" ).exists() ) - { - writeDemo( plugins + "Solid Colors/", "Pink.js", Demos.pink ); - writeDemo( plugins + "Solid Colors/", "Red.js", Demos.red ); - } - } - } - - private static boolean suppress = false; - private static void writeDemo( String path, String demo_name, String contents ) - { - PrintWriter writer = null; - try - { - writer = new PrintWriter( path + demo_name ); - writer.print( contents ); - } - catch ( FileNotFoundException e ) - { - if ( !suppress ) - { - // We're only going to show this error once, because chances are - // if it failed once, it's going to fail over and over again. - suppress = true; - Message.showWarning( -"We couldn't create the demo " + demo_name + " It's okay!
"+ -"You can grab all of the demos here " + -"and place
them in your Documents/Light Controller/Plugins/ folder.

"+ -"Below is the stack trace for this error.
", - "FileNotFoundException_CANT_MAKE_DEMO_FILES", e ); - } - } - finally - { - if ( writer != null ) - { - writer.close(); - } - } - } - - // Returns a file based on the given input, and if the pramater is a - // directory, it will try to create it. Giving a warning if it cant. - public static File getFile( String folder_name ) - { - // Convert string path to file - File file = new File( folder_name ); - - // If the file doesn't exist - if ( !file.exists() ) - { - // Check if the parent exists, because we can't create a directory - // inside a null directory - if ( !file.getParentFile().exists() ) - { - // Recursively make directories up the chain until we hit one - // that already exists - getFile( file.getParent() ); - } - try - { - file.mkdir(); - } - catch ( SecurityException e ) - { - Message.showWarning( -"Well this is odd... Somehow we couldn't create
" + -folder_name + -"
The program may or may not crash now.
" + -"Below you will find the stack trace for this error.
", - "SecurityException_CREATE_FOLDER", e ); - } - } - return file; - } - -} diff --git a/Light_Controller/application.macosx/source/Light_Controller.java b/Light_Controller/application.macosx/source/Light_Controller.java deleted file mode 100644 index 579730b..0000000 --- a/Light_Controller/application.macosx/source/Light_Controller.java +++ /dev/null @@ -1,144 +0,0 @@ -import processing.core.*; -import processing.data.*; -import processing.event.*; -import processing.opengl.*; - -import ddf.minim.AudioInput; -import ddf.minim.Minim; -import ddf.minim.analysis.BeatDetect; -import ddf.minim.analysis.FFT; -import processing.serial.Serial; - -import java.util.HashMap; -import java.util.ArrayList; -import java.io.File; -import java.io.BufferedReader; -import java.io.PrintWriter; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.IOException; - -public class Light_Controller extends PApplet { - - - - - - -// This is needed because Processing throws a fit if it's not here. - - -// TODO: BUG: -// When minim.setInputMixer() is called, it seems that the AudioInput only -// generates buffers SOMETIMES. Generally, if it starts generating buffers at -// the beginning, it will continue for the rest of the operation. But if it -// doesn't, it's not going to randomly start. I've spent way too much time -// on trying to fix this, so for now I'm removing this feature (ability to -// select the input device.) -// A user-workaround for this is to set the default input to whatever you want -// it to be, start the program, and then change it back to whatever it was -// before. -private static final boolean MIXER_BUG = true; - -// In order for there to be no dock icon in Mac, I had to add these lines to -// /Applications/Processing.app/Contents/Java/modes/java/application/Info.plist.tmpl -// LSUIElement -// - -Minim minim; // Needs global for stop() and setup() -AudioInput in; // Needs global for stop() and setup() -SerialHandler serial; // Needs global for draw() and setup() -PluginHandler plugin; // Needs global for draw() and setup() - -public void setup() -{ - Settings.init(); - FileHandler.startupChecks(); - - // Set up minim / audio input - minim = new Minim( this ); - if(!MIXER_BUG) in = SelectInput.getInstance().setInput( "Soundflower (2ch)" ); - if (MIXER_BUG) in = minim.getLineIn( Minim.STEREO, - Settings.BUFFER_SIZE ); - - // Set up BeatDetect - BeatDetect beat = new BeatDetect( in.bufferSize(), in.sampleRate() ); - new BeatListener( beat, in ); - - // Set up FFT - FFT fft = new FFT( in.bufferSize(), in.sampleRate() ); - new FFTListener( fft, in ); - - // Import a custom pattern plugin - plugin = new PluginHandler( beat, fft ); - - // In Java this is the code we would use for the working_directory, but - // in Processing this does not work - // String working_directory = MyClassName.class.getResource("").getPath(); - // So we have to use this instead: - // TODO: This folder isn't here when you export the program. - String working_directory = sketchPath(""); - - // Load the system tray - new SystemTrayHandler( plugin, working_directory, in ); - - // Set up Serial - serial = new SerialHandler(); - - // Set frame rate of draw() - frameRate( Settings.FRAME_RATE ); - -} - -public void draw() -{ - // We will let the plugin update the leds array - if ( plugin.update() ) - { - // TODO: Should this be here? - // beat.detect(in.mix); - - // After that we will send the array to the Arduino - // The format of the expected data is as follows: - //[red0, green0, blue0, red1, green1, blue1, (...), redN, greenN, blueN] - serial.sendLEDs( plugin.leds ); - } -} - -public void stop() { - // always close Minim audio classes when you are done with them - in.close(); - minim.stop(); - // Close serial port so others can use it - serial.stop(); - super.stop(); -} - -public boolean displayable() { - return Settings.VISIBLE; -} - -// For debug stuff only. -public void keyPressed() -{ - switch( key ) - { - case '2': - SelectInput.getInstance().refresh(); - in.close(); - in = SelectInput.getInstance().setInput( "Soundflower (2ch)" ); - System.out.println("\nREFRESHED AND RELOADED"); - break; - - default: break; - } -} - static public void main(String[] passedArgs) { - String[] appletArgs = new String[] { "Light_Controller" }; - if (passedArgs != null) { - PApplet.main(concat(appletArgs, passedArgs)); - } else { - PApplet.main(appletArgs); - } - } -} diff --git a/Light_Controller/application.macosx/source/Light_Controller.pde b/Light_Controller/application.macosx/source/Light_Controller.pde deleted file mode 100644 index 08d4503..0000000 --- a/Light_Controller/application.macosx/source/Light_Controller.pde +++ /dev/null @@ -1,113 +0,0 @@ -import ddf.minim.AudioInput; -import ddf.minim.Minim; -import ddf.minim.analysis.BeatDetect; -import ddf.minim.analysis.FFT; - -// This is needed because Processing throws a fit if it's not here. -import processing.serial.Serial; - -// TODO: BUG: -// When minim.setInputMixer() is called, it seems that the AudioInput only -// generates buffers SOMETIMES. Generally, if it starts generating buffers at -// the beginning, it will continue for the rest of the operation. But if it -// doesn't, it's not going to randomly start. I've spent way too much time -// on trying to fix this, so for now I'm removing this feature (ability to -// select the input device.) -// A user-workaround for this is to set the default input to whatever you want -// it to be, start the program, and then change it back to whatever it was -// before. -private static final boolean MIXER_BUG = true; - -// In order for there to be no dock icon in Mac, I had to add these lines to -// /Applications/Processing.app/Contents/Java/modes/java/application/Info.plist.tmpl -// LSUIElement -// - -Minim minim; // Needs global for stop() and setup() -AudioInput in; // Needs global for stop() and setup() -SerialHandler serial; // Needs global for draw() and setup() -PluginHandler plugin; // Needs global for draw() and setup() - -void setup() -{ - Settings.init(); - FileHandler.startupChecks(); - - // Set up minim / audio input - minim = new Minim( this ); - if(!MIXER_BUG) in = SelectInput.getInstance().setInput( "Soundflower (2ch)" ); - if (MIXER_BUG) in = minim.getLineIn( Minim.STEREO, - Settings.BUFFER_SIZE ); - - // Set up BeatDetect - BeatDetect beat = new BeatDetect( in.bufferSize(), in.sampleRate() ); - new BeatListener( beat, in ); - - // Set up FFT - FFT fft = new FFT( in.bufferSize(), in.sampleRate() ); - new FFTListener( fft, in ); - - // Import a custom pattern plugin - plugin = new PluginHandler( beat, fft ); - - // In Java this is the code we would use for the working_directory, but - // in Processing this does not work - // String working_directory = MyClassName.class.getResource("").getPath(); - // So we have to use this instead: - // TODO: This folder isn't here when you export the program. - String working_directory = sketchPath(""); - - // Load the system tray - new SystemTrayHandler( plugin, working_directory, in ); - - // Set up Serial - serial = new SerialHandler(); - - // Set frame rate of draw() - frameRate( Settings.FRAME_RATE ); - -} - -void draw() -{ - // We will let the plugin update the leds array - if ( plugin.update() ) - { - // TODO: Should this be here? - // beat.detect(in.mix); - - // After that we will send the array to the Arduino - // The format of the expected data is as follows: - //[red0, green0, blue0, red1, green1, blue1, (...), redN, greenN, blueN] - serial.sendLEDs( plugin.leds ); - } -} - -public void stop() { - // always close Minim audio classes when you are done with them - in.close(); - minim.stop(); - // Close serial port so others can use it - serial.stop(); - super.stop(); -} - -boolean displayable() { - return Settings.VISIBLE; -} - -// For debug stuff only. -void keyPressed() -{ - switch( key ) - { - case '2': - SelectInput.getInstance().refresh(); - in.close(); - in = SelectInput.getInstance().setInput( "Soundflower (2ch)" ); - System.out.println("\nREFRESHED AND RELOADED"); - break; - - default: break; - } -} diff --git a/Light_Controller/application.macosx/source/Message.java b/Light_Controller/application.macosx/source/Message.java deleted file mode 100644 index 9d5595d..0000000 --- a/Light_Controller/application.macosx/source/Message.java +++ /dev/null @@ -1,161 +0,0 @@ -import javax.swing.JOptionPane; -import java.io.StringWriter; -import java.io.PrintWriter; - -import javax.swing.JLabel; -import javax.swing.JEditorPane; -import javax.swing.event.HyperlinkListener; -import javax.swing.event.HyperlinkEvent; -import java.io.IOException; -import java.awt.Desktop; -import java.net.URISyntaxException; -import java.awt.Font; - -public class Message -{ - // Icon guidelines - // JOptionPane.WARNING_MESSAGE - Usually recoverable - // JOptionPane.ERROR_MESSAGE - Usually not recoverable - // JOptionPane.QUESTION_MESSAGE - Asking for input - // JOptionPane.PLAIN_MESSAGE - No use yet - // JOptionPane.INFORMATION_MESSAGE - Giving information - - public Message( String message ) - { - showInfo( message ); - } - - public static int getPositiveInt( String message, String filled_in ) - { - boolean first_fail = false; - while ( true ) - { - String input = JOptionPane.showInputDialog( message, filled_in ); - if ( input == null ) - { - return -1; - } - try - { - int number = Integer.parseInt( input ); - if ( number < 0 ) throw new NumberFormatException(); - return number; - } - catch ( NumberFormatException e ) - { - if ( !first_fail ) - { - first_fail = true; - message = "ERROR: Input must be a positive integer.
" + message; - } - } - } - } - - // Displays an informational dialog with the specified message. The message - // can contain HTML including links and will be wrapped in an html and body - // tag. - public static void showInfo( String message ) - { - String issue_link = "https://github.com/uPaymeiFixit/Processing-Ardui" + - "no-Light-Controller/issues/new?title=Unexpected%" + - "20Message&body=%23%23%23%23+What+" + - "error+message+did+you+get%3F%0D" + - "%0D%0A%0D%0A%23%23%23%23+Can+you+reproduce+this+" + - "error%3F+If+so%2C+how%3F%0D%0A%0D%0A%0D%0A%23%23" + - "%23%23+Any+other+information%3F"; - - String html = message+"

If you think this may be a " + - "bug, report it here or " + - "contact J@Gibbs.tk"; - - showDialog( html, "Light Controller Message", JOptionPane.INFORMATION_MESSAGE ); - } - - // Shows a warning with the given message, error name, and exception trace - public static void showWarning( String message, String error_name, Exception e ) - { - StringWriter sw = new StringWriter(); - e.printStackTrace( new PrintWriter( sw ) ); - showWarning( message + '\n' + sw.toString(), error_name ); - } - - // Shows a warning with the given message and error name - public static void showWarning( String message, String error_name ) - { - String issue_link = "https://github.com/uPaymeiFixit/Processing-Ardui" + - "no-Light-Controller/issues/new?title=Unexpected%" + - "20"+error_name+"%20Warning&body=%23%23%23%23+What+" + - "error+message+did+you+get%3F%0D"+error_name + - "%0D%0A%0D%0A%23%23%23%23+Can+you+reproduce+this+" + - "error%3F+If+so%2C+how%3F%0D%0A%0D%0A%0D%0A%23%23" + - "%23%23+Any+other+information%3F"; - - String html = message+"

If you think this may be a " + - "bug, report it here or " + - "contact J@Gibbs.tk"; - - showDialog( html, "Light Controller Warning: " + error_name, JOptionPane.WARNING_MESSAGE ); - } - - // Shows a warning with the given message, error name, and exception trace - public static void showError( String message, String error_name, Exception e ) - { - StringWriter sw = new StringWriter(); - e.printStackTrace( new PrintWriter( sw ) ); - showError( message + '\n' + sw.toString(), error_name ); - } - - // Shows an error dialog with the given message and error name - public static void showError( String message, String error_name ) - { - String issue_link = "https://github.com/uPaymeiFixit/Processing-Ardui" + - "no-Light-Controller/issues/new?title=Unexpected%" + - "20"+error_name+"%20Error&body=%23%23%23%23+What+" + - "error+message+did+you+get%3F%0D"+error_name+"%0A" + - "%0D%0A%0D%0A%23%23%23%23+Can+you+reproduce+this+" + - "error%3F+If+so%2C+how%3F%0D%0A%0D%0A%0D%0A%23%23" + - "%23%23+Any+other+information%3F"; - - String html = message+"

If you think this may be a " + - "bug, report it here or " + - "contact J@Gibbs.tk"; - - showDialog( html, "Light Controller Error: " + error_name, JOptionPane.ERROR_MESSAGE ); - } - - // Shows a dialog with the given HTML, and handles clickable links - public static void showDialog( String html, String title, int icon ) - { - // for copying style - JLabel label = new JLabel(); - Font font = label.getFont(); - - // create some css from the label's font - StringBuffer style = new StringBuffer("font-family:" + font.getFamily() + ";"); - style.append("font-weight:" + (font.isBold() ? "bold" : "normal") + ";"); - style.append("font-size:" + font.getSize() + "pt;"); - html = html.replaceAll("(\r\n|\n)", "
"); - JEditorPane ep = new JEditorPane( "text/html", "" + html + "" ); - ep.addHyperlinkListener( new HyperlinkListener() - { - @Override - public void hyperlinkUpdate( HyperlinkEvent e ) - { - if ( e.getEventType().equals( HyperlinkEvent.EventType.ACTIVATED ) ) - { - try - { - Desktop.getDesktop().browse(e.getURL().toURI()); - } - catch ( URISyntaxException e2 ) { System.out.println(e); } - catch ( IOException e2 ) { System.out.println(e); } - } - } - }); - ep.setEditable( false ); - ep.setBackground( label.getBackground() ); - JOptionPane.showMessageDialog( null, ep, title, icon ); - } -} diff --git a/Light_Controller/application.macosx/source/PluginHandler.java b/Light_Controller/application.macosx/source/PluginHandler.java deleted file mode 100644 index 02b4a67..0000000 --- a/Light_Controller/application.macosx/source/PluginHandler.java +++ /dev/null @@ -1,142 +0,0 @@ -import ddf.minim.analysis.BeatDetect; -import ddf.minim.analysis.FFT; -import java.io.FileNotFoundException; -import java.io.FileReader; -import javax.script.Invocable; -import javax.script.ScriptEngine; -import javax.script.ScriptEngineManager; -import javax.script.ScriptException; - -public class PluginHandler -{ - // There is a lot of mixing bytes and ints because Processing 2.2.1 crashes - // when trying to convert ints from JavaScript to bytes in Java. - public int[][] leds; - private Invocable invocable_engine; - private BeatDetect beat; - private FFT fft; - - public PluginHandler( BeatDetect beat, FFT fft ) - { - this.beat = beat; - this.fft = fft; - - instantiateLEDs( Settings.NUM_LEDS ); - } - - public void instantiateLEDs( int num_leds ) - { - Settings.saveNUM_LEDS( num_leds ); - - // Unload the script - unload(); - - // Initialize the leds array - leds = new int[num_leds][3]; - - // Reload the script - if ( !Settings.ACTIVE_PLUGIN.equals("") ) - { - System.out.println(Settings.ACTIVE_PLUGIN); - load( Settings.ACTIVE_PLUGIN ); - } - } - - public boolean update() - { - if ( invocable_engine != null ) - { - try - { - // invoke the global function named "update" - invocable_engine.invokeFunction( "update" ); - } - catch ( ScriptException e ) - { - Message.showWarning( -"It appears as though there may be an error in your script.
" + -"Here is the stack trace:
", - "ScriptException_DURING_UPDATE", e ); - } - catch ( NoSuchMethodException e ) - { - Message.showWarning( -"We can't find the \"update()\" function in yourscript.
" + -"Are you sure it's there?
" + -"Here is the stack trace:
", - "NoSuchMethodException", e ); - } - - return true; - } - return false; - } - - public void resetLeds() - { - if ( leds != null ) - { - for ( int i = 0; i < leds.length; i++ ) - { - leds[i][0] = 0; - leds[i][1] = 0; - leds[i][2] = 0; - } - - // the main update loop won't send this since this class's update method - // returs false, so we have to manually send the black leds. - SerialHandler.sendLEDs( leds ); - } - } - - public void unload() - { - invocable_engine = null; - resetLeds(); - } - - public void load( String file_location ) - { - // This keeps previous scripts from interfering - unload(); - - // create a script engine manager - ScriptEngineManager factory = new ScriptEngineManager(); - - // create a script engine - ScriptEngine engine = factory.getEngineByName( "JavaScript" ); - - // expose leds array, beat, and fft as variables to script to be used - engine.put( "leds", leds ); - engine.put( "FFT", fft ); - engine.put( "BeatDetect", beat ); - - try - { - // evaluate JavaScript code from given file - engine.eval( new FileReader( file_location ) ); - } - catch (ScriptException e) - { - Message.showWarning( -"It appears as though there may be an error in your script.
"+ -"Here is the stack trace:
", - "ScriptException_DURING_INIT", e ); - return; - } - catch (FileNotFoundException e) - { - Message.showWarning( -"We couldn't load the plugin! Are you sure the file is still there?
"+ -"Below is the stack trace for this error.\n", - "FileNotFoundException_SCRIPT_FILE", e ); - return; - } - - // cast the engine to an invocable object for use later - invocable_engine = (Invocable) engine; - - Settings.saveACTIVE_PLUGIN( file_location ); - } - -} diff --git a/Light_Controller/application.macosx/source/RadioMenuItem.java b/Light_Controller/application.macosx/source/RadioMenuItem.java deleted file mode 100644 index 3d1270e..0000000 --- a/Light_Controller/application.macosx/source/RadioMenuItem.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * java.awt does not have a RadioMenuItem which can be used with the System - * Tray, so I made one. This class extends java.awt.CheckboxMenuItem, and - * therefore acts very similar. The difference is that only one radio menu - * item can be checked per group. This is meant to be used with - * the RadioMenuItemGroup class you should have received with this file. - * - * @title RadioMenuItem.java - * @author uPaymeiFixit - * @version 1.2 - * @since 2015-08-17 - */ - -import java.awt.CheckboxMenuItem; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; - -public class RadioMenuItem extends CheckboxMenuItem -{ - private ItemListener listener; - private RadioMenuItemGroup group; - - // I don't know what this is but I needed it apparently. - public static final long serialVersionUID = 42L; - - public RadioMenuItem() - { - super(); - } - public RadioMenuItem( String label ) - { - super( label ); - } - public RadioMenuItem( String label, RadioMenuItemGroup group ) - { - super( label ); - setRadioMenuItemGroup( group ); - } - public RadioMenuItem( String label, boolean state ) - { - super( label, state ); - } - public RadioMenuItem( String label, RadioMenuItemGroup group, boolean state ) - { - super( label, state ); - setRadioMenuItemGroup( group ); - } - - public RadioMenuItemGroup getRadioMenuItemGroup() - { - return group; - } - - public void setRadioMenuItemGroup( RadioMenuItemGroup group ) - { - this.group = group; - this.removeItemListener( listener ); - if ( group != null ) - { - // We need to make sure "this" is final so that we can refer to it - // in the scope below. Some compilers make you do this. - final RadioMenuItem me = this; - listener = new ItemListener() - { - @Override - public void itemStateChanged( ItemEvent e ) - { - if ( e.getStateChange() == ItemEvent.SELECTED ) - { - me.group.setSelectedRadioMenuItem( me ); - } - } - }; - this.addItemListener( listener ); - group.addRadioMenuItem( this ); - } - } -} diff --git a/Light_Controller/application.macosx/source/RadioMenuItemGroup.java b/Light_Controller/application.macosx/source/RadioMenuItemGroup.java deleted file mode 100644 index 51eaa3a..0000000 --- a/Light_Controller/application.macosx/source/RadioMenuItemGroup.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * java.awt does not have a RadioMenuItem which can be used with the System - * Tray, so I made one. This class extends allows you to make full use of the - * RadioMenuItem class you should have received with this file by grouping - * them together in one object so only one can be set “on” at a time. - * - * @title RadioMenuItemGroup.java - * @author uPaymeiFixit - * @version 1.2 - * @since 2015-08-17 - */ - -import java.util.ArrayList; - -public class RadioMenuItemGroup -{ - ArrayList radios; - - // Default methods from java.awt.CheckboxGroup - public RadioMenuItemGroup() - { - radios = new ArrayList(); - } - - // Gets the current choice from this radio menu item group. The current - // choice is the radio menu item in this group that is currently in the "on" - // state, or null if all radio menu itemes in the group are off. - public RadioMenuItem getSelectedRadioMenuItem() - { - for ( RadioMenuItem radio : radios ) - if ( radio.getState() ) - return radio; - return null; - } - - // Sets the currently selected radio menu item in this group to be the - // specified radio menu item. This method sets the state of that radio menu - // item to "on" and sets all other radio menu itemes in the group to be off. - // If the radio menu item argument is null, all radio menu itemes in this - // radio menu item group are deselected. If the radio menu item argument - // belongs to a different radio menu item group, this method does nothing. - public void setSelectedRadioMenuItem( RadioMenuItem radio ) - { - // If the user gave us a random RadioMenuItem not in this group, add it - if ( radio.getRadioMenuItemGroup() != this ) - radio.setRadioMenuItemGroup( this ); - - // Set all of the radios to off - for ( RadioMenuItem local_radio : radios ) - local_radio.setState( false ); - - // Turn our radio on - radio.setState( true ); - } - - // Returns a string representation of this radio menu item group, including - // the value of its current selection. - public String toString() - { - // I don't know exactly how CheckboxGroup's toString works - String output = "["; - for ( RadioMenuItem radio : radios ) - output += radio.getLabel() + ": " + radio.getState() + ", "; - return output.substring( 0, output.length() - 2 )+"]"; - } - - // Custom methods - public void addRadioMenuItem( RadioMenuItem radio ) - { - // If the user gave us a random RadioMenuItem not in this group, add it - if ( radio.getRadioMenuItemGroup() != this ) - { - radio.setRadioMenuItemGroup( this ); - } - else - { - radios.add( radio ); - - if ( radio.getState() ) - { - setSelectedRadioMenuItem( radio ); - } - } - } -} diff --git a/Light_Controller/application.macosx/source/SelectInput.java b/Light_Controller/application.macosx/source/SelectInput.java deleted file mode 100644 index dc29613..0000000 --- a/Light_Controller/application.macosx/source/SelectInput.java +++ /dev/null @@ -1,113 +0,0 @@ -import ddf.minim.AudioInput; -import ddf.minim.Minim; -import javax.sound.sampled.AudioSystem; -import javax.sound.sampled.Mixer; - -// Singleton class -// This class takes the same parameters as Minim's getLineIn method -// and tries all of the inputs to see if they are usable. -public class SelectInput -{ - private Minim minim; - private Mixer mixer; - - private static final int CHANNEL = Minim.STEREO; - - private Mixer.Info[] mixer_info; - private Mixer.Info[] usable_inputs; - private int usable_inputs_size; - - private SelectInput() - { - minim = new Minim( this ); - refresh(); - } - - private static SelectInput firstInstance = null; - public static SelectInput getInstance() - { - if ( firstInstance == null ) - { - synchronized ( SelectInput.class ) - { - if ( firstInstance == null ) - { - firstInstance = new SelectInput(); - } - } - } - return firstInstance; - } - - public void refresh() - { - usable_inputs_size = 0; - mixer_info = AudioSystem.getMixerInfo(); - Mixer.Info[] usable_inputs_temp = new Mixer.Info[mixer_info.length]; - - for( int i = mixer_info.length; i-- > 0; ) - { - // Set the i-th input and try getting data from it. - mixer = AudioSystem.getMixer( mixer_info[i] ); - minim.setInputMixer( mixer ); - // If it's null, we cannot use it - if ( minim.getLineIn( CHANNEL, Settings.BUFFER_SIZE ) != null ) - { - // Otherwise we can - usable_inputs_temp[usable_inputs_size++] = mixer_info[i]; - } - } - - usable_inputs = new Mixer.Info[usable_inputs_size]; - System.arraycopy( usable_inputs_temp, 0, usable_inputs, 0, usable_inputs_size ); - } - - // Returns an array of the inputs that can actually have sound data - // pulled from them. - public Mixer.Info[] getInputs() - { - return usable_inputs; - } - - public String toString() - { - String output = "["; - for ( int i = 0; i < usable_inputs.length; i++ ) - output += usable_inputs[i].getName() + ", "; - return output.substring( 0, output.length() - 2 )+"]"; - } - - // Returns an AudioInput device based on the mixers - public AudioInput setInput( Mixer.Info mixer_info_element ) - { - mixer = AudioSystem.getMixer( mixer_info_element ); - minim.setInputMixer( mixer ); - return minim.getLineIn( CHANNEL, Settings.BUFFER_SIZE ); - } - - // Returns an AudioInput based on the String name - // If none of that name are found, the default will be returned - public AudioInput setInput( String name ) - { - for ( int i = 0; i < usable_inputs.length; i++ ) - { - if ( usable_inputs[i].getName().equals( name ) ) - { - return setInput( usable_inputs[i] ); - } - } - return setInput(); - } - - // Returns an AudioInput based on the specified index - public AudioInput setInput( int index ) - { - return setInput( usable_inputs[index] ); - } - - // Returns the first (usually default) audio input - public AudioInput setInput() - { - return setInput(0); - } -} diff --git a/Light_Controller/application.macosx/source/SerialHandler.java b/Light_Controller/application.macosx/source/SerialHandler.java deleted file mode 100644 index 0c00a27..0000000 --- a/Light_Controller/application.macosx/source/SerialHandler.java +++ /dev/null @@ -1,203 +0,0 @@ -import processing.core.PApplet; -import processing.serial.Serial; - -public class SerialHandler -{ - public static final byte NAME = 0; - public static final byte INDEX = 1; - public static final byte AUTO = 2; - - private static Serial serial_port; - private static PApplet applet; - private static byte MODE; - private static String name; - private static int index; - - - public SerialHandler() - { - MODE = AUTO; - this.applet = new PApplet(); - detectArduino(); - } - - public static void setBaudRate( int baud_rate ) - { - Settings.saveBAUD_RATE( baud_rate ); - refresh(); - } - - public static void refresh() - { - if ( MODE == INDEX ) - { - setSerial( index ); - } - else if ( MODE == NAME ) - { - setSerial( name ); - } - else if ( MODE == AUTO ) - { - detectArduino(); - } - } - - // Returns a list of all serial devices - public static String[] list() - { - return Serial.list(); - } - - public static Serial getSerial() - { - return serial_port; - } - - public static Serial getSerial( int index ) - { - return new Serial( applet, Serial.list()[index], Settings.BAUD_RATE ); - } - - public static Serial getSerial( String name ) - { - return new Serial( applet, name, Settings.BAUD_RATE ); - } - - public static void setSerial( int _index ) - { - MODE = INDEX; - index = _index; - // Close the serial port before we change it. - stop(); - serial_port = getSerial( index ); - } - - public static void setSerial( String _name ) - { - MODE = NAME; - name = _name; - // Close the serial port before we change it. - stop(); - serial_port = getSerial( name ); - } - - // Connects to each serial device and waits for a beacon - public static void detectArduino() - { - MODE = AUTO; - // Close the serial port before we change it. - stop(); - Serial serial = null; - boolean suppress = false; - - while (true) - { - - // Run through each Serial device - for (int i = 0; i < Serial.list().length; i++) - { - try - { - System.out.println( "Trying serial port " + Serial.list()[i] ); - // This throws the exceptin if it can't run - serial = new Serial( applet, Serial.list()[i], Settings.BAUD_RATE ); - - System.out.println( " Connected.\n Listening for Arduin" + - "o beacon..." ); - // We will wait for the device to send us information - try - { - Thread.sleep( Settings.BEACON_PERIOD+1 ); - } - catch ( InterruptedException e ) - { - e.printStackTrace(); - Thread.currentThread().interrupt(); - } - // If the device sends us a matching byte, we found it - if ( serial.read() == Settings.BEACON_KEY ) - { - System.out.println( " \nArduino found on " + - Serial.list()[i] + '\n' ); - serial_port = serial; - - // If we've told the user we would notify them when we - // found the Arduino: - if ( suppress ) - { - new Message( - "Whatever you did worked! ;)
"+ - "We found the Arduino on
"+ - Serial.list()[i] ); - } - - return; - } - System.out.println( " We didn't receive the Arduino beacon.\n" ); - serial.stop(); - } - catch ( RuntimeException e ) - { - System.out.println( " Could not connect. Maybe it was busy.\n" ); - } - serial = null; - } - - // we only want to show this error once - if ( !suppress ) - { - suppress = true; - // If we've gotten this far, there are no more devices left - Message.showWarning( -"We couldn't find the Arduino!

"+ -"We'll keep searching for it and let you know if we find it.
"+ -"In the meantime, here are some things to try:
"+ -" - Are you sure it's plugged in?
"+ -" - Are any programs such as the Arduino IDE using it?
"+ -" - Try changing the baud rate in Arduino.ino and the settings
"+ -" to 9600

"+ -"Make sure you let at least a minute pass before trying something new
"+ -"If you still need help take a look at this.", - "NO_ARDUINO" ); - } - - } - - } - - public static void sendLEDs( int[][] leds ) - { - // This happens when we are setting the baud rate - if ( serial_port != null ) - { - for ( int i = 0; i < leds.length; i++ ) - { - serial_port.write( leds[i][0] ); - serial_port.write( leds[i][1] ); - serial_port.write( leds[i][2] ); - } - } - } - - public String toString() - { - String output = ""; - for ( int i = 0; i < Serial.list().length; i++ ) - { - output += i + ": " + Serial.list()[i] + "\n"; - } - return output; - } - - public static void stop() - { - // Close the serial port before we change it. - if ( serial_port != null ) - { - serial_port.stop(); - serial_port = null; - } - } -} diff --git a/Light_Controller/application.macosx/source/Settings.java b/Light_Controller/application.macosx/source/Settings.java deleted file mode 100644 index 4c1a92a..0000000 --- a/Light_Controller/application.macosx/source/Settings.java +++ /dev/null @@ -1,156 +0,0 @@ -import java.util.prefs.Preferences; - -public class Settings -{ - // Created to keep users from instantiation - private Settings() {} - - private static String PACKAGE_NAME = "tk.gibbs.ColorOrgan"; - private static Preferences prefs; - - - // These preferences can be found in - // ~/Library/Preferences/com.apple.java.util.prefs.plist - - - // This should only be true if this is the first time this program has run - public static boolean FIRST_RUN = true; - - // Sets the GUI to show/not show - // In order for this to work, we have to compile using Processing 2.2.1 - // newer versions seem to ignore this. - public static boolean VISIBLE = false; - - // Size of the audio input buffer - public static int BUFFER_SIZE = 2048; - - // Speed of draw() function (units: per second) - public static int FRAME_RATE = 30; - - // Serial baud rate. Should match desktop program. - public static int BAUD_RATE = 115200; - - // Number of controllable LED segments on the strip (note, this needs to - // match NUM_LEDS in Arduino.ino); - public static int NUM_LEDS = 17; - - // Time in between beacons (units: milliseconds) - public static int BEACON_PERIOD = 500; - - // Unique byte that the desktop program should recognize - public static byte BEACON_KEY = 42; - - // Default path for the plugins (Documens/Light_Controller/Plugins) - public static String PLUGINS_PATH = ""; - - // This is the location of the last active plugin - public static String ACTIVE_PLUGIN = ""; - - - public static void init() - { - // This will define a node in which the preferences can be stored - prefs = Preferences.userRoot().node( PACKAGE_NAME ); - - // This will try to read constants from the preferences file, and return - // defaults if it could not find them. - FIRST_RUN = prefs.getBoolean( "FIRST_RUN ", FIRST_RUN ); - VISIBLE = prefs.getBoolean( "VISIBLE ", VISIBLE ); - BUFFER_SIZE = prefs.getInt ( "BUFFER_SIZE ", BUFFER_SIZE ); - FRAME_RATE = prefs.getInt ( "FRAME_RATE ", FRAME_RATE ); - BAUD_RATE = prefs.getInt ( "BAUD_RATE ", BAUD_RATE ); - NUM_LEDS = prefs.getInt ( "NUM_LEDS ", NUM_LEDS ); - BEACON_PERIOD = prefs.getInt ( "BEACON_PERIOD", BEACON_PERIOD ); - BEACON_KEY = (byte) prefs.getInt ( "BEACON_KEY ", BEACON_KEY ); - PLUGINS_PATH = prefs.get ( "PLUGINS_PATH ", PLUGINS_PATH ); - ACTIVE_PLUGIN = prefs.get ( "ACTIVE_PLUGIN", ACTIVE_PLUGIN ); - - // This will save all of the constants to the preferences file (just in - // case they were not there to begin with). - // saveFIRST_RUN ( FIRST_RUN ); - saveVISIBLE ( VISIBLE ); - saveBUFFER_SIZE ( BUFFER_SIZE ); - saveFRAME_RATE ( FRAME_RATE ); - saveBAUD_RATE ( BAUD_RATE ); - saveNUM_LEDS ( NUM_LEDS ); - saveBEACON_PERIOD( BEACON_PERIOD ); - saveBEACON_KEY ( BEACON_KEY ); - // savePLUGINS_PATH ( PLUGINS_PATH ); - saveACTIVE_PLUGIN( ACTIVE_PLUGIN ); - - - printSettings(); - - if ( FIRST_RUN ) - { - Settings.saveFIRST_RUN( false ); - - String readme = "README"; - String here = "here"; - - new Message( - "Welcome to Light Controller!
"+ - "
"+ - "This application will let you control your light RGB light strip.
"+ - "An icon should be present in your system tray’s notification area.
"+ - "(The menu bar for Mac, and the taskbar for Windows)
"+ - "
"+ - "From there you can select a pattern to display on your Arduino.
"+ - "
"+ - "This program should try to Automatically connect to the Arduino.
"+ - "If it cannot:
"+ - " - check to make sure than no other programs are using it
"+ - " (such as the Arduino IDE)
"+ - " - you have uploaded the Arduino.ino file
"+ - " - and your Arduino supports the current baud rate
"+ - " (115200 by default)
"+ - "
"+ - "To view more information about this program, view the "+readme+".
"+ - "
"+ - "To submit a feature request or a bug, let me know "+here+".
"+ - "
"+ - "To submit a bug, let me know here.
"+ - "
"+ - "v1.5b
"+ - "© 2015 uPaymeiFixit (Josh Gibbs)"); - } - } - - public static void printSettings() - { - System.out.println( - "\n************* PREFS **************\n" + - "FIRST_RUN: " + FIRST_RUN + "\n" + - "VISIBLE: " + VISIBLE + "\n" + - "BUFFER_SIZE: " + BUFFER_SIZE + "\n" + - "FRAME_RATE: " + FRAME_RATE + "\n" + - "BAUD_RATE: " + BAUD_RATE + "\n" + - "NUM_LEDS: " + NUM_LEDS + "\n" + - "BEACON_PERIOD: " + BEACON_PERIOD + "\n" + - "BEACON_KEY: " + BEACON_KEY + "\n" + - "PLUGINS_PATH: " + PLUGINS_PATH + "\n" + - "ACTIVE_PLUGIN: " + ACTIVE_PLUGIN + "\n" + - "**********************************\n" - ); - } - - public static void saveFIRST_RUN ( boolean _FIRST_RUN ) { FIRST_RUN = _FIRST_RUN ; prefs.putBoolean( "FIRST_RUN ", FIRST_RUN ); } - public static void saveVISIBLE ( boolean _VISIBLE ) { VISIBLE = _VISIBLE ; prefs.putBoolean( "VISIBLE ", VISIBLE ); } - public static void saveBUFFER_SIZE ( int _BUFFER_SIZE ) { BUFFER_SIZE = _BUFFER_SIZE ; prefs.putInt ( "BUFFER_SIZE ", BUFFER_SIZE ); } - public static void saveFRAME_RATE ( int _FRAME_RATE ) { FRAME_RATE = _FRAME_RATE ; prefs.putInt ( "FRAME_RATE ", FRAME_RATE ); } - public static void saveBAUD_RATE ( int _BAUD_RATE ) { BAUD_RATE = _BAUD_RATE ; prefs.putInt ( "BAUD_RATE ", BAUD_RATE ); } - public static void saveNUM_LEDS ( int _NUM_LEDS ) { NUM_LEDS = _NUM_LEDS ; prefs.putInt ( "NUM_LEDS ", NUM_LEDS ); } - public static void saveBEACON_PERIOD( int _BEACON_PERIOD ) { BEACON_PERIOD = _BEACON_PERIOD; prefs.putInt ( "BEACON_PERIOD", BEACON_PERIOD ); } - public static void saveBEACON_KEY ( byte _BEACON_KEY ) { BEACON_KEY = _BEACON_KEY ; prefs.putInt ( "BEACON_KEY ", BEACON_KEY ); } - public static void savePLUGINS_PATH ( String _PLUGINS_PATH ) { PLUGINS_PATH = _PLUGINS_PATH ; prefs.put ( "PLUGINS_PATH ", PLUGINS_PATH ); } - public static void saveACTIVE_PLUGIN( String _ACTIVE_PLUGIN ) { ACTIVE_PLUGIN = _ACTIVE_PLUGIN; prefs.put ( "ACTIVE_PLUGIN", ACTIVE_PLUGIN ); } - -} diff --git a/Light_Controller/application.macosx/source/SystemTrayHandler.java b/Light_Controller/application.macosx/source/SystemTrayHandler.java deleted file mode 100644 index d2310c3..0000000 --- a/Light_Controller/application.macosx/source/SystemTrayHandler.java +++ /dev/null @@ -1,340 +0,0 @@ -import ddf.minim.AudioInput; -import java.awt.AWTException; -import java.awt.Desktop; -import java.awt.Image; -import java.awt.Menu; -import java.awt.MenuItem; -import java.awt.PopupMenu; -import java.awt.SystemTray; -import java.awt.Toolkit; -import java.awt.TrayIcon; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.io.File; -import java.io.IOException; -import java.lang.NumberFormatException; -import javax.swing.JOptionPane; - -public class SystemTrayHandler -{ - // TODO: See Processing.pde for explanation - private static final boolean MIXER_BUG = true; - private static final boolean FEAT_CHIPSET = false; - - private PluginHandler plugin; - private AudioInput in; - private String plugins_directory; - - public SystemTrayHandler(PluginHandler plugin, String working_directory, AudioInput in) - { - this.plugin = plugin; - this.in = in; - this.plugins_directory = working_directory + "Plugins/"; - - // Okay, this one was stupid hacky. I couldn't figure out how to export - // images with processing, but I noticed that in - // Processing.app/Contents/Java/ there was a file named jssc.txt. - // I'm almost 100% certain that Processing isn't using this. So I found - // the file in /Applications/Processing.app/Contents/Java/modes/java/libraries/serial/library/jssc.txt - // I took my icon.gif and renamed it to jssc.txt, and it appears to work. - String icon = SystemTrayHandler.class.getResource("").getPath() + "jssc.txt"; - - if ( SystemTray.isSupported() ) - { - if ( !( new File( icon ) ).exists() ) - { - String local_icon = working_directory + "icon.gif"; - if ( !( new File( local_icon ) ).exists() ) - { - Message.showError( -"Could not find icon.gif to put in the System Tray. We looked in
"+ -icon + -"
and
" + -local_icon + -"

The program will now exit.", - "ICON_NOT_FOUND" ); - System.exit(1); - } - icon = local_icon; - } - - final PopupMenu popup = new PopupMenu(); - final Image image = Toolkit.getDefaultToolkit() - .getImage( icon ); - final TrayIcon trayIcon = new TrayIcon( image, "Light Controller" ); - final SystemTray tray = SystemTray.getSystemTray(); - - addPluginsMenu( popup ); - - popup.addSeparator(); - - if(!MIXER_BUG) addAudioMenu( popup ); - addSettingsMenu( popup ); - - popup.addSeparator(); - - addExitItem( popup ); - - trayIcon.setPopupMenu( popup ); - - try - { - tray.add( trayIcon ); - } - catch ( AWTException e ) - { - Message.showError( -"There was a problem creating an icon on the system tray.
"+ -"The program will now exit.
"+ -"Below you will find the stack trace for this error.\n", - "AWTException_CREATING_ICON", e ); - System.exit(1); - } - - } - else - { - Message.showError( -"Light Controller is not supported on this machine
"+ -"due to system tray being unsupported.
"+ -"The program will now exit.", "NO_SYS_TRAY" ); - - System.exit(1); - } - } - - void addPluginsMenu( PopupMenu popup ) - { - Menu plugins_menu = new Menu( "Plugins" ); - popup.add( plugins_menu ); - addPlugins( plugins_menu ); - } - - void addPlugins( Menu menu ) - { - MenuItem open_plugins_folder = new MenuItem( "Open Plugins Folder..." ); - open_plugins_folder.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent event ) - { - try - { - Desktop.getDesktop().open( FileHandler.getFile( Settings.PLUGINS_PATH ) ); - } - catch ( IOException e ) - { - Message.showWarning( "We could not automatically open the plugins folder. Below is the stack trace for this error.\n", "COULD_NOT_OPEN_PLUGINS", e ); - } - } - }); - menu.add( open_plugins_folder ); - - menu.addSeparator(); - - // Set up a group for all of the radio items to go in - RadioMenuItemGroup plugin_group = new RadioMenuItemGroup(); - - // Recursively search for and add plugins - searchForPlugins( menu, - new File( Settings.PLUGINS_PATH ), plugin_group ); - } - - // Recursively searches for files and directorys and places them in the menu - void searchForPlugins( Menu menu, File directory, RadioMenuItemGroup group ) - { - File[] files = directory.listFiles(); - for ( int i = 0; i < files.length; i++ ) - { - String file = files[i].getName(); - // If the "file" name is less than 3, it cannot be a .js file. - if ( files[i].isFile() && file.length() >= 3 ) - { - // If the "file" is a file and it's name ends with .js, load it - if ( file.substring( file.length()-3).equals( ".js" ) ) - { - // Gets the name of the file and takes the extension off the end - String file_name = file.split( "\\.", 2 )[0]; - final String file_location = files[i].getPath(); - boolean state = false; - if ( file_location.equals( Settings.ACTIVE_PLUGIN ) ) - { - state = true; - } - // Create a radio item based on this name and set the group - final RadioMenuItem radio = new RadioMenuItem( file_name, group, state ); - - // When this item is clicked, we will load that plugin - radio.addItemListener( new ItemListener() - { - @Override - public void itemStateChanged( ItemEvent e ) - { - if ( e.getStateChange() == ItemEvent.SELECTED ) - { - // Normally we would pass plugin in as a parameter - // but then we would be referring to a non-final - // variable inside an inner class defined in a - // different method. Throws errors and stuff. - plugin.load( file_location ); - } - else if ( radio.getRadioMenuItemGroup() - .getSelectedRadioMenuItem() == null ) - { - plugin.unload(); - Settings.saveACTIVE_PLUGIN(""); - } - } - }); - menu.add( radio ); - } - } - else if ( files[i].isDirectory() ) - { - // Makes a menu out of the directory name - Menu new_menu = new Menu( files[i].getName()+"..." ); - menu.add( new_menu ); - searchForPlugins( new_menu, files[i], group ); - } - } - } - - void addAudioMenu( PopupMenu popup ) - { - Menu audio_input_menu = new Menu( "Audio Input" ); - popup.add( audio_input_menu ); - addAudioInputs( audio_input_menu ); - } - - void addAudioInputs( Menu menu ) - { - SelectInput select_input = SelectInput.getInstance(); - RadioMenuItemGroup input_group = new RadioMenuItemGroup(); - for ( int i = 0; i < select_input.getInputs().length; i++ ) - { - boolean state = false; - if ( select_input.getInputs()[i].getName().equals( "Soundflower (2ch)" ) ) - { - state = true; - } - - final int index = i; - RadioMenuItem audio_option = new RadioMenuItem( - select_input.getInputs()[i].getName(), input_group, state ); - audio_option.addItemListener( new ItemListener() - { - @Override - public void itemStateChanged( ItemEvent e ) - { - if ( e.getStateChange() == ItemEvent.SELECTED ) - { - new Message( "Switching inputs to " + SelectInput - .getInstance().getInputs()[index].getName() + - "\nThis is an experimental feature." ); - SelectInput.getInstance().refresh(); - in.close(); - in = SelectInput.getInstance().setInput( - SelectInput.getInstance().getInputs()[index] ); - } - } - }); - - menu.add( audio_option ); - } - } - - void addSettingsMenu( PopupMenu popup ) - { - Menu settings = new Menu( "Settings " ); - popup.add( settings ); - addSettings( settings ); - } - - void addSettings( Menu menu ) - { - MenuItem set_led_count = new MenuItem( "Set LED Count..." ); - set_led_count.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - int input = Message.getPositiveInt( -"Enter the number of controllable LED segments on your light strip.\n"+ -"(You will need to change NUM_LEDS in Arduino.ino for this to work.)", - Integer.toString( Settings.NUM_LEDS ) ); - - // This happens when the user hits cancel - if ( input != -1 ) - { - plugin.instantiateLEDs( input ); - } - } - }); - menu.add( set_led_count ); - - Menu set_chipset = new Menu( "LED Chipset" ); - if(FEAT_CHIPSET) menu.add( set_chipset ); - if(FEAT_CHIPSET) addChipsets( set_chipset ); - - MenuItem set_baud = new MenuItem( "Set Baud Rate..." ); - set_baud.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - int input = Message.getPositiveInt( -"Enter the desired baud rate used to communicate with the Arduino.\n"+ -"If you are having problems finding the Arduino, it is recommended\n"+ -"that you change the baud rate to 9600. The default bad raute is 115200.\n"+ -"(You will need to change BAUD_RATE in Arduino.ino for this to work.)", - Integer.toString( Settings.BAUD_RATE ) ); - - // This happens when the user hits cancel - if ( input != -1 ) - { - SerialHandler.setBaudRate( input ); - } - } - }); - menu.add( set_baud ); - } - - // TODO: Make chipsets work - void addChipsets( Menu menu ) - { - RadioMenuItemGroup chipset_group = new RadioMenuItemGroup(); - RadioMenuItem spi_595 = new RadioMenuItem( "595", chipset_group ); - menu.add( spi_595 ); - RadioMenuItem spi_HL1606 = new RadioMenuItem( "HL1606", chipset_group ); - menu.add( spi_HL1606 ); - RadioMenuItem spi_LPD6803 = new RadioMenuItem( "LPD6803", chipset_group ); - menu.add( spi_LPD6803 ); - RadioMenuItem spi_WS2801 = new RadioMenuItem( "WS2801", chipset_group ); - menu.add( spi_WS2801 ); - RadioMenuItem spi_TM1809 = new RadioMenuItem( "TM1809", chipset_group ); - menu.add( spi_TM1809 ); - } - - void addExitItem( PopupMenu popup ) - { - MenuItem exit = new MenuItem( "Exit" ); - exit.addActionListener( new ActionListener() - { - @Override - public void actionPerformed( ActionEvent e ) - { - // Exits the program - // plugin.resetLeds(); - // TODO: Decide whether or not LEDS should turn off when - // program exits. - // Pros: You can set a color and then quit the program - // Cons: For LEDS to turn off, user has to unload plugins - System.exit(0); - } - }); - popup.add( exit ); - } - -}