forked from robvanderleek/JLifx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added brightness flag to color command, working on absolute dim command.
- Loading branch information
1 parent
a4d086a
commit f126738
Showing
13 changed files
with
154 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package jlifx.commandline.command; | ||
|
||
import java.io.IOException; | ||
import java.io.PrintStream; | ||
import java.util.Collection; | ||
|
||
import jlifx.bulb.IBulb; | ||
import jlifx.commandline.AbstractBulbCommand; | ||
import jlifx.commandline.Utils; | ||
|
||
public class DimCommand extends AbstractBulbCommand { | ||
|
||
@Override | ||
public boolean execute(Collection<IBulb> bulbs, String[] commandArgs, PrintStream out) throws Exception { | ||
if (commandArgs.length != 2 || !Utils.isFloatValue(commandArgs[1])) { | ||
return false; | ||
} else { | ||
dimBulbs(bulbs, Float.parseFloat(commandArgs[1])); | ||
return true; | ||
} | ||
} | ||
|
||
private void dimBulbs(Collection<IBulb> bulbs, float brightness) throws IOException { | ||
for (IBulb bulb : bulbs) { | ||
bulb.setDim(brightness); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package jlifx.packet; | ||
|
||
public class SetDimAbsolutePacket extends Packet { | ||
|
||
public SetDimAbsolutePacket(float brightness) { | ||
setType((byte)0x68); | ||
int value; | ||
if (Math.floor(brightness) >= 1) { | ||
value = 0xFFFF; | ||
} else { | ||
value = (int)(0xFFFF * brightness); | ||
} | ||
byte[] payload = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; | ||
payload[0] = (byte)(value >> 8); | ||
payload[1] = (byte)value; | ||
payload[2] = 0x10; | ||
setPayload(payload); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters