├── AmbilWarna ├── res │ ├── drawable │ │ ├── ambilwarna_hue.png │ │ ├── ambilwarna_cursor.png │ │ ├── ambilwarna_target.png │ │ ├── ambilwarna_arrow_down.png │ │ └── ambilwarna_arrow_right.png │ ├── drawable-hdpi │ │ ├── ambilwarna_cursor.png │ │ ├── ambilwarna_target.png │ │ ├── ambilwarna_arrow_down.png │ │ └── ambilwarna_arrow_right.png │ ├── drawable-ldpi │ │ ├── ambilwarna_cursor.png │ │ ├── ambilwarna_target.png │ │ ├── ambilwarna_arrow_down.png │ │ └── ambilwarna_arrow_right.png │ ├── drawable-xhdpi │ │ ├── ambilwarna_cursor.png │ │ ├── ambilwarna_target.png │ │ ├── ambilwarna_arrow_down.png │ │ └── ambilwarna_arrow_right.png │ ├── values-land │ │ └── dimen.xml │ ├── values-xlarge-land │ │ └── dimen.xml │ ├── values │ │ └── dimen.xml │ ├── layout │ │ ├── ambilwarna_pref_widget.xml │ │ └── ambilwarna_dialog.xml │ └── layout-land │ │ └── ambilwarna_dialog.xml ├── AndroidManifest.xml ├── project.properties └── src │ └── yuku │ └── ambilwarna │ ├── AmbilWarnaKotak.java │ └── AmbilWarnaDialog.java ├── ColorLightsController ├── ic_launcher-web.png ├── libs │ └── android-support-v4.jar ├── res │ ├── drawable-hdpi │ │ └── ic_launcher.png │ ├── drawable-ldpi │ │ └── ic_launcher.png │ ├── drawable-mdpi │ │ └── ic_launcher.png │ ├── drawable-xhdpi │ │ └── ic_launcher.png │ ├── values │ │ ├── strings.xml │ │ └── styles.xml │ ├── menu │ │ └── activity_main.xml │ ├── values-v11 │ │ └── styles.xml │ ├── values-v14 │ │ └── styles.xml │ └── layout │ │ └── activity_main.xml ├── project.properties ├── AndroidManifest.xml └── src │ └── tkjelectronics │ └── arduino │ └── colorlightscontroller │ └── MainActivity.java ├── OpenWrt ├── README.md └── www │ ├── cgi-bin │ └── color │ └── color │ ├── css │ └── farbtastic.css │ ├── index.html │ └── js │ └── farbtastic.js ├── .gitignore ├── EEPROMAnything.h ├── README.md └── AndroidControllableLights.ino /AmbilWarna/res/drawable/ambilwarna_hue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/probonopd/AndroidControllableLights/master/AmbilWarna/res/drawable/ambilwarna_hue.png -------------------------------------------------------------------------------- /ColorLightsController/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/probonopd/AndroidControllableLights/master/ColorLightsController/ic_launcher-web.png -------------------------------------------------------------------------------- /AmbilWarna/res/drawable/ambilwarna_cursor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/probonopd/AndroidControllableLights/master/AmbilWarna/res/drawable/ambilwarna_cursor.png -------------------------------------------------------------------------------- /AmbilWarna/res/drawable/ambilwarna_target.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/probonopd/AndroidControllableLights/master/AmbilWarna/res/drawable/ambilwarna_target.png -------------------------------------------------------------------------------- /AmbilWarna/res/drawable-hdpi/ambilwarna_cursor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/probonopd/AndroidControllableLights/master/AmbilWarna/res/drawable-hdpi/ambilwarna_cursor.png -------------------------------------------------------------------------------- /AmbilWarna/res/drawable-hdpi/ambilwarna_target.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/probonopd/AndroidControllableLights/master/AmbilWarna/res/drawable-hdpi/ambilwarna_target.png -------------------------------------------------------------------------------- /AmbilWarna/res/drawable-ldpi/ambilwarna_cursor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/probonopd/AndroidControllableLights/master/AmbilWarna/res/drawable-ldpi/ambilwarna_cursor.png -------------------------------------------------------------------------------- /AmbilWarna/res/drawable-ldpi/ambilwarna_target.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/probonopd/AndroidControllableLights/master/AmbilWarna/res/drawable-ldpi/ambilwarna_target.png -------------------------------------------------------------------------------- /AmbilWarna/res/drawable/ambilwarna_arrow_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/probonopd/AndroidControllableLights/master/AmbilWarna/res/drawable/ambilwarna_arrow_down.png -------------------------------------------------------------------------------- /AmbilWarna/res/drawable/ambilwarna_arrow_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/probonopd/AndroidControllableLights/master/AmbilWarna/res/drawable/ambilwarna_arrow_right.png -------------------------------------------------------------------------------- /ColorLightsController/libs/android-support-v4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/probonopd/AndroidControllableLights/master/ColorLightsController/libs/android-support-v4.jar -------------------------------------------------------------------------------- /AmbilWarna/res/drawable-xhdpi/ambilwarna_cursor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/probonopd/AndroidControllableLights/master/AmbilWarna/res/drawable-xhdpi/ambilwarna_cursor.png -------------------------------------------------------------------------------- /AmbilWarna/res/drawable-xhdpi/ambilwarna_target.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/probonopd/AndroidControllableLights/master/AmbilWarna/res/drawable-xhdpi/ambilwarna_target.png -------------------------------------------------------------------------------- /AmbilWarna/res/drawable-hdpi/ambilwarna_arrow_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/probonopd/AndroidControllableLights/master/AmbilWarna/res/drawable-hdpi/ambilwarna_arrow_down.png -------------------------------------------------------------------------------- /AmbilWarna/res/drawable-hdpi/ambilwarna_arrow_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/probonopd/AndroidControllableLights/master/AmbilWarna/res/drawable-hdpi/ambilwarna_arrow_right.png -------------------------------------------------------------------------------- /AmbilWarna/res/drawable-ldpi/ambilwarna_arrow_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/probonopd/AndroidControllableLights/master/AmbilWarna/res/drawable-ldpi/ambilwarna_arrow_down.png -------------------------------------------------------------------------------- /AmbilWarna/res/drawable-ldpi/ambilwarna_arrow_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/probonopd/AndroidControllableLights/master/AmbilWarna/res/drawable-ldpi/ambilwarna_arrow_right.png -------------------------------------------------------------------------------- /AmbilWarna/res/drawable-xhdpi/ambilwarna_arrow_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/probonopd/AndroidControllableLights/master/AmbilWarna/res/drawable-xhdpi/ambilwarna_arrow_down.png -------------------------------------------------------------------------------- /ColorLightsController/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/probonopd/AndroidControllableLights/master/ColorLightsController/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /ColorLightsController/res/drawable-ldpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/probonopd/AndroidControllableLights/master/ColorLightsController/res/drawable-ldpi/ic_launcher.png -------------------------------------------------------------------------------- /ColorLightsController/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/probonopd/AndroidControllableLights/master/ColorLightsController/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /AmbilWarna/res/drawable-xhdpi/ambilwarna_arrow_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/probonopd/AndroidControllableLights/master/AmbilWarna/res/drawable-xhdpi/ambilwarna_arrow_right.png -------------------------------------------------------------------------------- /ColorLightsController/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/probonopd/AndroidControllableLights/master/ColorLightsController/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /AmbilWarna/res/values-land/dimen.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 240dp 4 | 120dp 5 | -------------------------------------------------------------------------------- /AmbilWarna/res/values-xlarge-land/dimen.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 240dp 4 | 240dp 5 | -------------------------------------------------------------------------------- /ColorLightsController/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Color Lights Controller 5 | Hello world! 6 | Settings 7 | 8 | -------------------------------------------------------------------------------- /AmbilWarna/res/values/dimen.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 240dp 4 | 240dp 5 | 30dp 6 | 8dp 7 | 8 | -------------------------------------------------------------------------------- /ColorLightsController/res/menu/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /AmbilWarna/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 12 | 13 | -------------------------------------------------------------------------------- /OpenWrt/README.md: -------------------------------------------------------------------------------- 1 | ![bildschirmfoto 2014-07-12 um 20 02 28 1](https://cloud.githubusercontent.com/assets/2480569/3562386/c8008754-09ee-11e4-9881-d50cc3a5e4d7.png) 2 | 3 | Web interface running on an OpenWrt router using a serial converter on /dev/ttyUSB0 connected to an Arduino Pro Mini running the AndroidControllableLights.ino sketch. So now we can operate the lights from any web enabled device, Android or otherwise. 4 | -------------------------------------------------------------------------------- /ColorLightsController/res/values-v11/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /ColorLightsController/res/values-v14/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 11 | 12 | -------------------------------------------------------------------------------- /AmbilWarna/res/layout/ambilwarna_pref_widget.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Links 2 | 3 | # built application files 4 | *.ap_ 5 | 6 | # files for the dex VM 7 | *.dex 8 | 9 | # Java class files 10 | *.class 11 | 12 | # generated files 13 | bin/ 14 | gen/ 15 | lint.xml 16 | 17 | # Local configuration file (sdk path, etc) 18 | local.properties 19 | 20 | # Eclipse project files 21 | .classpath 22 | .project 23 | .settings 24 | .checkstyle 25 | 26 | #Ant 27 | build.xml 28 | ant.properties 29 | local.properties 30 | proguard.cfg 31 | proguard-project.txt -------------------------------------------------------------------------------- /AmbilWarna/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system use, 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | 10 | android.library=true 11 | # Indicates whether an apk should be generated for each density. 12 | split.density=false 13 | # Project target. 14 | target=android-17 15 | -------------------------------------------------------------------------------- /OpenWrt/www/cgi-bin/color: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # It is not necessary to use lua/luci for very simple web interfaces 5 | # See http://wiki.openwrt.org/doc/howto/http.httpd 6 | # 7 | 8 | # Always need to send this header 9 | echo "Content-type: text/html" 10 | echo "" 11 | 12 | # Send command to serial port 13 | # NOTE: For me this works only if we do "cat /dev/ttyUSB0" somewhere 14 | COMMAND=$(echo "$QUERY_STRING" | cut -d "=" -f 2) 15 | replaced=$(echo $COMMAND | sed -e 's|0x|\\x|g' | sed -e 's|%3B|;|g') 16 | # echo "$replaced" 17 | echo -en "$replaced" > /dev/ttyUSB0 18 | 19 | ### 20 | # Note that this could be INSECURE - only use this in trusted internal networks 21 | ### 22 | -------------------------------------------------------------------------------- /ColorLightsController/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-17 15 | android.library.reference.1=../AmbilWarna 16 | -------------------------------------------------------------------------------- /ColorLightsController/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 14 | 15 | 16 | 19 | 20 | -------------------------------------------------------------------------------- /ColorLightsController/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 12 | 13 | 18 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /EEPROMAnything.h: -------------------------------------------------------------------------------- 1 | #ifndef _eepromanything_h_ 2 | #define _eepromanything_h_ 3 | 4 | #include 5 | 6 | // Source: http://playground.arduino.cc/Code/EEPROMWriteAnything 7 | // Modified to use the standard eeprom library and added 'eeprom_busy_wait()' 8 | // Also added EEPROM_updateAnything to limit number of write/erase cycles 9 | // By: Krisitan Lauszus, TKJ Electronics 10 | 11 | template uint16_t EEPROM_writeAnything(uint16_t addr, const T& value) { 12 | eeprom_busy_wait(); // Wait until the eeprom is ready 13 | const uint8_t *p = (const uint8_t*)(const void*)&value; 14 | uint16_t i; 15 | for (i = 0; i < sizeof(value); i++) 16 | eeprom_write_byte((uint8_t*)addr++, *p++); 17 | return i; 18 | } 19 | template uint16_t EEPROM_updateAnything(uint16_t addr, const T& value) { 20 | eeprom_busy_wait(); // Wait until the eeprom is ready 21 | const uint8_t *p = (const uint8_t*)(const void*)&value; 22 | uint16_t i; 23 | for (i = 0; i < sizeof(value); i++) { 24 | if (eeprom_read_byte((uint8_t*)addr) != *p) // Limits number of write/erase cycles 25 | eeprom_write_byte((uint8_t*)addr, *p); 26 | addr++; 27 | p++; 28 | } 29 | return i; 30 | } 31 | template uint16_t EEPROM_readAnything(uint16_t addr, T& value) { 32 | eeprom_busy_wait(); // Wait until the eeprom is ready 33 | uint8_t *p = (uint8_t*)(void*)&value; 34 | uint16_t i; 35 | for (i = 0; i < sizeof(value); i++) 36 | *p++ = eeprom_read_byte((uint8_t*)addr++); 37 | return i; 38 | } 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /AmbilWarna/src/yuku/ambilwarna/AmbilWarnaKotak.java: -------------------------------------------------------------------------------- 1 | package yuku.ambilwarna; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.content.Context; 5 | import android.graphics.Canvas; 6 | import android.graphics.Color; 7 | import android.graphics.ComposeShader; 8 | import android.graphics.LinearGradient; 9 | import android.graphics.Paint; 10 | import android.graphics.PorterDuff; 11 | import android.graphics.Shader; 12 | import android.graphics.Shader.TileMode; 13 | import android.util.AttributeSet; 14 | import android.view.View; 15 | 16 | public class AmbilWarnaKotak extends View { 17 | Paint paint; 18 | Shader luar; 19 | final float[] color = { 1.f, 1.f, 1.f }; 20 | 21 | public AmbilWarnaKotak(Context context, AttributeSet attrs) { 22 | super(context, attrs); 23 | } 24 | 25 | public AmbilWarnaKotak(Context context, AttributeSet attrs, int defStyle) { 26 | super(context, attrs, defStyle); 27 | } 28 | 29 | @SuppressLint("DrawAllocation") @Override protected void onDraw(Canvas canvas) { 30 | super.onDraw(canvas); 31 | if (paint == null) { 32 | paint = new Paint(); 33 | luar = new LinearGradient(0.f, 0.f, 0.f, this.getMeasuredHeight(), 0xffffffff, 0xff000000, TileMode.CLAMP); 34 | } 35 | int rgb = Color.HSVToColor(color); 36 | Shader dalam = new LinearGradient(0.f, 0.f, this.getMeasuredWidth(), 0.f, 0xffffffff, rgb, TileMode.CLAMP); 37 | ComposeShader shader = new ComposeShader(luar, dalam, PorterDuff.Mode.MULTIPLY); 38 | paint.setShader(shader); 39 | canvas.drawRect(0.f, 0.f, this.getMeasuredWidth(), this.getMeasuredHeight(), paint); 40 | } 41 | 42 | void setHue(float hue) { 43 | color[0] = hue; 44 | invalidate(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /OpenWrt/www/color/css/farbtastic.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Farbtastic Color Picker 1.2 3 | * © 2008 Steven Wittens 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | .farbtastic { 20 | position: relative; 21 | } 22 | .farbtastic * { 23 | position: absolute; 24 | cursor: crosshair; 25 | } 26 | .farbtastic, .farbtastic .wheel { 27 | width: 195px; 28 | height: 195px; 29 | } 30 | .farbtastic .color, .farbtastic .overlay { 31 | top: 47px; 32 | left: 47px; 33 | width: 101px; 34 | height: 101px; 35 | } 36 | .farbtastic .wheel { 37 | background: url('https://farbtastic.googlecode.com/svn/branches/farbtastic-1/wheel.png') no-repeat; 38 | width: 195px; 39 | height: 195px; 40 | } 41 | .farbtastic .overlay { 42 | background: url('https://farbtastic.googlecode.com/svn/branches/farbtastic-1/mask.png') no-repeat; 43 | } 44 | .farbtastic .marker { 45 | width: 17px; 46 | height: 17px; 47 | margin: -8px 0 0 -8px; 48 | overflow: hidden; 49 | background: url('https://farbtastic.googlecode.com/svn/branches/farbtastic-1/marker.png') no-repeat; 50 | } 51 | -------------------------------------------------------------------------------- /AmbilWarna/res/layout-land/ambilwarna_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 15 | 24 | 30 | 37 | 43 | 44 | 51 | 53 | 58 | 67 | 68 | 75 | 76 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /AmbilWarna/res/layout/ambilwarna_dialog.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 17 | 18 | 23 | 24 | 32 | 33 | 39 | 40 | 46 | 47 | 56 | 57 | 62 | 63 | 69 | 70 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Android Controllable Lights 2 | 3 | Developed by Thomas Jespersen, TKJ Electronics 2013 4 | Modified for simple RGB strips by probono 2013 5 | 6 | The code is released under the GNU General Public License. 7 | 8 | This is the code is for controlling a simple RGB LED strip (not WS2801 based) with your Arduino using your Android phone with Bluetooth as remote control. 9 | 10 | You can check out a video demonstration of the project here: but please note that a simple RGB strip you can only modify the entire LED strip at once, so not all effects are available. 11 | 12 | For more information see the blog post at . 13 | 14 | ## Commands 15 | 16 | The first byte of a command package is the command byte, descriping the command of the package. The next bytes are all parameters as described below. Each parameter is terminated with a ‘;’ character, also when only one parameter is needed. 17 | 18 | * 0x0F = Color command [Parameters: 3 bytes of 3 char each] 19 | * 0x01 = Add fade color [Parameters: 3 bytes of 3 char each] 20 | * 0x02 = Reset fade colors [Parameters: None] 21 | * 0x03 = Set speed delay [Parameters: 1 integer of 5 chars] 22 | * 0x04 = Enable Fade effect [Parameters: None] 23 | * 0x05 = Add Snap color [Parameters: 3 bytes of 3 char each] 24 | * 0x06 = Reset snap colors [Parameters: None] 25 | * 0x07 = Enable Snap effect [Parameters: None] 26 | * 0x08 = Add Running color (requires WS2801, hence disabled here) [Parameters: 3 bytes of 3 char each] 27 | * 0x09 = Reset Running colors (requires WS2801, hence disabled here) [Parameters: None] 28 | * 0x0A = Enable Running effect (requires WS2801, hence disabled here) [Parameters: None] 29 | * 0x0B = Add Running Fade color (requires WS2801, hence disabled here) [Parameters: 3 bytes of 3 char each] 30 | * 0x0C = Reset Running Fade colors (requires WS2801, hence disabled here) [Parameters: None] 31 | * 0x0D = Enable Running Fade effect (requires WS2801, hence disabled here) [Parameters: None] 32 | * 0x0E = Disable any effect [Parameters: None] 33 | * 0x1A = Invalidate EEProm 34 | 35 | I can successfully send commands using 36 | ``` 37 | stty -F /dev/ttyUSB0 speed 57600 cs8 -cstopb -parenb -echo # Configure serial connection 38 | cat /dev/ttyUSB0 & # Otherwise sending does NOT work! 39 | echo -en '0 ' > /dev/ttyUSB0 # Reset the Arduino 40 | sleep 2 41 | echo -en '\x0f255;255;255;' > /dev/ttyUSB0 # Set all white 42 | sleep 1 43 | echo -en '\x0f255;000;000;' > /dev/ttyUSB0 # Set all red 44 | sleep 1 45 | echo -en '\x0f000;255;000;' > /dev/ttyUSB0 # Set all green 46 | sleep 1 47 | echo -en '\x0f000;000;255;' > /dev/ttyUSB0 # Set all blue 48 | killall cat # Do not forget this 49 | 50 | # 51 | # Set warm white color after and save to EEPROM 52 | # 53 | 54 | cat /dev/ttyUSB0 & # Otherwise sending does NOT work! 55 | echo -en '\x02' > /dev/ttyUSB0 # Reset fade colors 56 | echo -en '\x01255;180;100;' > /dev/ttyUSB0 # Add warm white fade color 57 | echo -en '\x04' > /dev/ttyUSB0 # Enable fade effect 58 | echo -en '0 ' > /dev/ttyUSB0 # Reset 59 | killall cat # Do not forget this 60 | 61 | # 62 | # Do the same in 1 line 63 | # 64 | 65 | cat /dev/ttyUSB0 & # Otherwise sending does NOT work! 66 | echo -en '\x02\x01255;180;100;\x040 ' > /dev/ttyUSB0 67 | killall cat # Do not forget this 68 | 69 | # 70 | # More examples 71 | # 72 | 73 | When the app sends the 0x0f "white" command it looks like this: 74 | 00000220 32 3b 0f 32 35 32 3b 32 35 32 3b 32 35 32 3b 0f |2;.252;252;252;.| 75 | 00000230 32 35 32 3b 32 35 32 3b 32 35 32 3b 0f 32 35 32 |252;252;252;.252| 76 | 00000240 3b 32 35 32 3b 32 35 32 3b 0f 32 35 32 3b 32 35 |;252;252;.252;25| 77 | 00000250 32 3b 32 35 32 3b 0f 32 35 32 3b 32 35 32 3b 32 |2;252;.252;252;2| 78 | 00000260 35 32 3b 0f 32 35 32 3b 32 35 32 3b 32 35 32 3b |52;.252;252;252;| 79 | 00000270 0f 32 35 32 3b 32 35 32 3b 32 35 32 3b 0f 32 35 |.252;252;252;.25| 80 | 81 | When the app sends the 0x0f "black" command it looks like this: 82 | 00000310 3b 30 30 30 3b 30 30 30 3b 0f 30 30 30 3b 30 30 |;000;000;.000;00| 83 | 00000320 30 3b 30 30 30 3b 0f 30 30 30 3b 30 30 30 3b 30 |0;000;.000;000;0| 84 | 00000330 30 30 3b 0f 30 30 30 3b 30 30 30 3b 30 30 30 3b |00;.000;000;000;| 85 | 00000340 0f 30 30 30 3b 30 30 30 3b 30 30 30 3b 0f 30 30 |.000;000;000;.00| 86 | 00000350 30 3b 30 30 30 3b 30 30 30 3b 0f 30 30 30 3b 30 |0;000;000;.000;0| 87 | 00000360 30 30 3b 30 30 30 3b 0f 30 30 30 3b 30 30 30 3b |00;000;.000;000;| 88 | 89 | When the app sends the 0x03 "set speed delay" command to 100 it looks like this: 90 | 00000000 03 30 30 31 30 30 3b 03 30 30 31 30 30 3b 03 30 |.00100;.00100;.0| 91 | 92 | ``` 93 | -------------------------------------------------------------------------------- /OpenWrt/www/color/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 46 | 145 | 146 | 147 |
148 |
149 |
150 |
000;000;000;
151 |
152 |
153 |
154 |
155 |
156 |
157 | 158 | 159 |
160 | 161 |
162 | 163 | 164 | 0
165 | 166 | 167 | 0
168 | 169 | 170 |
171 | 172 | 173 |
174 | 175 | 176 | -------------------------------------------------------------------------------- /AmbilWarna/src/yuku/ambilwarna/AmbilWarnaDialog.java: -------------------------------------------------------------------------------- 1 | package yuku.ambilwarna; 2 | 3 | import android.app.*; 4 | import android.content.*; 5 | import android.content.DialogInterface.OnCancelListener; 6 | import android.graphics.*; 7 | import android.view.*; 8 | import android.widget.*; 9 | 10 | public class AmbilWarnaDialog { 11 | public interface OnAmbilWarnaListener { 12 | void onCancel(AmbilWarnaDialog dialog); 13 | void onOk(AmbilWarnaDialog dialog, int color); 14 | void onChange(AmbilWarnaDialog dialog, int color); 15 | } 16 | 17 | final AlertDialog dialog; 18 | final OnAmbilWarnaListener listener; 19 | final View viewHue; 20 | final AmbilWarnaKotak viewSatVal; 21 | final ImageView viewCursor; 22 | final View viewOldColor; 23 | final View viewNewColor; 24 | final ImageView viewTarget; 25 | final ViewGroup viewContainer; 26 | final float[] currentColorHsv = new float[3]; 27 | 28 | /** 29 | * create an AmbilWarnaDialog. call this only from OnCreateDialog() or from a background thread. 30 | * 31 | * @param context 32 | * current context 33 | * @param color 34 | * current color 35 | * @param listener 36 | * an OnAmbilWarnaListener, allowing you to get back error or 37 | */ 38 | public AmbilWarnaDialog(final Context context, int color, OnAmbilWarnaListener listener) { 39 | this.listener = listener; 40 | Color.colorToHSV(color, currentColorHsv); 41 | 42 | final View view = LayoutInflater.from(context).inflate(R.layout.ambilwarna_dialog, null); 43 | viewHue = view.findViewById(R.id.ambilwarna_viewHue); 44 | viewSatVal = (AmbilWarnaKotak) view.findViewById(R.id.ambilwarna_viewSatBri); 45 | viewCursor = (ImageView) view.findViewById(R.id.ambilwarna_cursor); 46 | viewOldColor = view.findViewById(R.id.ambilwarna_warnaLama); 47 | viewNewColor = view.findViewById(R.id.ambilwarna_warnaBaru); 48 | viewTarget = (ImageView) view.findViewById(R.id.ambilwarna_target); 49 | viewContainer = (ViewGroup) view.findViewById(R.id.ambilwarna_viewContainer); 50 | 51 | viewSatVal.setHue(getHue()); 52 | viewOldColor.setBackgroundColor(color); 53 | viewNewColor.setBackgroundColor(color); 54 | 55 | viewHue.setOnTouchListener(new View.OnTouchListener() { 56 | @Override public boolean onTouch(View v, MotionEvent event) { 57 | if (event.getAction() == MotionEvent.ACTION_MOVE 58 | || event.getAction() == MotionEvent.ACTION_DOWN 59 | || event.getAction() == MotionEvent.ACTION_UP) { 60 | 61 | float y = event.getY(); 62 | if (y < 0.f) y = 0.f; 63 | if (y > viewHue.getMeasuredHeight()) y = viewHue.getMeasuredHeight() - 0.001f; // to avoid looping from end to start. 64 | float hue = 360.f - 360.f / viewHue.getMeasuredHeight() * y; 65 | if (hue == 360.f) hue = 0.f; 66 | setHue(hue); 67 | 68 | // update view 69 | viewSatVal.setHue(getHue()); 70 | moveCursor(); 71 | viewNewColor.setBackgroundColor(getColor()); 72 | if (AmbilWarnaDialog.this.listener != null) { 73 | AmbilWarnaDialog.this.listener.onChange(AmbilWarnaDialog.this, getColor()); 74 | } 75 | 76 | return true; 77 | } 78 | return false; 79 | } 80 | }); 81 | viewSatVal.setOnTouchListener(new View.OnTouchListener() { 82 | @Override public boolean onTouch(View v, MotionEvent event) { 83 | if (event.getAction() == MotionEvent.ACTION_MOVE 84 | || event.getAction() == MotionEvent.ACTION_DOWN 85 | || event.getAction() == MotionEvent.ACTION_UP) { 86 | 87 | float x = event.getX(); // touch event are in dp units. 88 | float y = event.getY(); 89 | 90 | if (x < 0.f) x = 0.f; 91 | if (x > viewSatVal.getMeasuredWidth()) x = viewSatVal.getMeasuredWidth(); 92 | if (y < 0.f) y = 0.f; 93 | if (y > viewSatVal.getMeasuredHeight()) y = viewSatVal.getMeasuredHeight(); 94 | 95 | setSat(1.f / viewSatVal.getMeasuredWidth() * x); 96 | setVal(1.f - (1.f / viewSatVal.getMeasuredHeight() * y)); 97 | 98 | // update view 99 | moveTarget(); 100 | viewNewColor.setBackgroundColor(getColor()); 101 | if (AmbilWarnaDialog.this.listener != null) { 102 | AmbilWarnaDialog.this.listener.onChange(AmbilWarnaDialog.this, getColor()); 103 | } 104 | 105 | return true; 106 | } 107 | return false; 108 | } 109 | }); 110 | 111 | dialog = new AlertDialog.Builder(context) 112 | .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { 113 | @Override public void onClick(DialogInterface dialog, int which) { 114 | if (AmbilWarnaDialog.this.listener != null) { 115 | AmbilWarnaDialog.this.listener.onOk(AmbilWarnaDialog.this, getColor()); 116 | } 117 | } 118 | }) 119 | .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { 120 | @Override public void onClick(DialogInterface dialog, int which) { 121 | if (AmbilWarnaDialog.this.listener != null) { 122 | AmbilWarnaDialog.this.listener.onCancel(AmbilWarnaDialog.this); 123 | } 124 | } 125 | }) 126 | .setOnCancelListener(new OnCancelListener() { 127 | // if back button is used, call back our listener. 128 | @Override public void onCancel(DialogInterface paramDialogInterface) { 129 | if (AmbilWarnaDialog.this.listener != null) { 130 | AmbilWarnaDialog.this.listener.onCancel(AmbilWarnaDialog.this); 131 | } 132 | 133 | } 134 | }) 135 | .create(); 136 | // kill all padding from the dialog window 137 | dialog.setView(view, 0, 0, 0, 0); 138 | 139 | // move cursor & target on first draw 140 | ViewTreeObserver vto = view.getViewTreeObserver(); 141 | vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { 142 | @Override public void onGlobalLayout() { 143 | moveCursor(); 144 | moveTarget(); 145 | view.getViewTreeObserver().removeGlobalOnLayoutListener(this); 146 | } 147 | }); 148 | } 149 | 150 | protected void moveCursor() { 151 | float y = viewHue.getMeasuredHeight() - (getHue() * viewHue.getMeasuredHeight() / 360.f); 152 | if (y == viewHue.getMeasuredHeight()) y = 0.f; 153 | RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) viewCursor.getLayoutParams(); 154 | layoutParams.leftMargin = (int) (viewHue.getLeft() - Math.floor(viewCursor.getMeasuredWidth() / 2) - viewContainer.getPaddingLeft()); 155 | ; 156 | layoutParams.topMargin = (int) (viewHue.getTop() + y - Math.floor(viewCursor.getMeasuredHeight() / 2) - viewContainer.getPaddingTop()); 157 | ; 158 | viewCursor.setLayoutParams(layoutParams); 159 | } 160 | 161 | protected void moveTarget() { 162 | float x = getSat() * viewSatVal.getMeasuredWidth(); 163 | float y = (1.f - getVal()) * viewSatVal.getMeasuredHeight(); 164 | RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) viewTarget.getLayoutParams(); 165 | layoutParams.leftMargin = (int) (viewSatVal.getLeft() + x - Math.floor(viewTarget.getMeasuredWidth() / 2) - viewContainer.getPaddingLeft()); 166 | layoutParams.topMargin = (int) (viewSatVal.getTop() + y - Math.floor(viewTarget.getMeasuredHeight() / 2) - viewContainer.getPaddingTop()); 167 | viewTarget.setLayoutParams(layoutParams); 168 | } 169 | 170 | private int getColor() { 171 | return Color.HSVToColor(currentColorHsv); 172 | } 173 | 174 | private float getHue() { 175 | return currentColorHsv[0]; 176 | } 177 | 178 | private float getSat() { 179 | return currentColorHsv[1]; 180 | } 181 | 182 | private float getVal() { 183 | return currentColorHsv[2]; 184 | } 185 | 186 | private void setHue(float hue) { 187 | currentColorHsv[0] = hue; 188 | } 189 | 190 | private void setSat(float sat) { 191 | currentColorHsv[1] = sat; 192 | } 193 | 194 | private void setVal(float val) { 195 | currentColorHsv[2] = val; 196 | } 197 | 198 | public void show() { 199 | dialog.show(); 200 | } 201 | 202 | public AlertDialog getDialog() { 203 | return dialog; 204 | } 205 | } 206 | -------------------------------------------------------------------------------- /ColorLightsController/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 16 | 17 |