Snapshot of project to connect drivers for lirc (https://github.com/Boukefalos/jliblirc) and ibuddy (https://github.com/Boukefalos/jlibibuddy) towards pluggable successor of mimis (https://github.com/Boukefalos/mimis)

This commit is contained in:
2015-06-11 23:10:08 +01:00
commit 4cb0910910
10 changed files with 472 additions and 0 deletions

6
.gitignore vendored Normal file
View File

@@ -0,0 +1,6 @@
/.gradle
/.settings
/.classpath
/.project
/bin
/build

14
build.gradle Normal file
View File

@@ -0,0 +1,14 @@
apply plugin: 'java'
apply plugin: 'eclipse'
task wrapper(type: Wrapper) {
gradleVersion = '2.2'
}
repositories {
mavenCentral()
}
dependencies {
}

View File

@@ -0,0 +1,68 @@
package connected;
import java.util.HashMap;
import lirc.Lirc;
import base.work.Listen;
import com.github.boukefalos.lirc.LircButton;
import com.github.boukefalos.lirc.implementation.LocalImplementation;
import com.github.boukefalos.lirc.util.SignalObject;
public class TestParsing extends Listen<SignalObject<LircButton>> {
public static void main(String[] args) {
new TestParsing().start();
}
protected HashMap<String, LircButton[]> buttonMap;
//protected LircTaskMapCycle taskMapCycle;
//buttonMap = new HashMap<String, LircButton[]>();
public void start() {
LocalImplementation lirc = new LocalImplementation();
/*public void put(String name, LircButton[] LircButtonArray) {
buttonMap.put(name, LircButtonArray);
}*/
/*public LircButton parseButton(Scanner scanner) throws UnknownButtonException {
try {
LircButton[] buttonArray = buttonMap.get(remote);
f (buttonArray != null) {
for (LircButton button : buttonArray) {
if (button.getCode().equals(code)) {
return button;
}
}
}
} catch (InputMismatchException e) {
logger.error("", e);
} catch (NoSuchElementException e) {
logger.error("", e);
}
throw new UnknownButtonException();
}*/
/*put(PhiliphsRCLE011Button.NAME, PhiliphsRCLE011Button.values());
put(DenonRC176Button.NAME, DenonRC176Button.values());
put(SamsungBN5901015AButton.NAME, SamsungBN5901015AButton.values());*/
lirc.Lirc.Signal x = Lirc.Signal.BEGIN;
//lirc.put(PhiliphsRCLE011Button.NAME, PhiliphsRCLE011Button.values());
lirc.start();
super.start();
try {
Thread.sleep(100000000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void put(String name, LircButton[] LircButtonArray) {
buttonMap.put(name, LircButtonArray);
}
}

View File

@@ -0,0 +1,54 @@
package connected;
import java.util.Properties;
import base.work.Work;
import com.github.boukefalos.ibuddy.iBuddy;
import com.github.boukefalos.lirc.Lirc;
import com.github.boukefalos.lirc.Loader;
import dummy.Dummy;
public class TestTcpCommunication {
public static void main(String[] args) {
try {
Properties localProperties = new Properties();
localProperties.setProperty("implementation", "local");
localProperties.setProperty("server", "true");
localProperties.setProperty("server.port", "8883");
localProperties.setProperty("server.protocol", "tcp");
Properties remoteProperties = new Properties();
remoteProperties.setProperty("implementation", "remote");
remoteProperties.setProperty("protocol", "tcp");
remoteProperties.setProperty("remote.host", "localhost");
remoteProperties.setProperty("remote.port", "8883");
Loader localLoader = new Loader(localProperties);
Loader remoteLoader = new Loader(remoteProperties);
//Lirc localLirc = localLoader.getLirc();
Lirc remoteLirc = remoteLoader.getLirc();
Properties iBuddyProperties = new Properties();
iBuddyProperties.setProperty("implementation", "local");
iBuddy iBuddy = new com.github.boukefalos.ibuddy.Loader(iBuddyProperties).getiBuddy();
Dummy dummy = new Dummy(remoteLirc, iBuddy);
Work server = localLoader.getServer();
// Can we reuse the same Thread for all Listens?
//localLirc.start();
remoteLirc.start();
server.start();
dummy.start();
Thread.sleep(10000);
//server.exit();
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,97 @@
package dummy;
import lirc.Lirc.Color;
import lirc.Lirc.Direction;
import lirc.Lirc.Number;
import lirc.Lirc.Signal;
import base.work.Listen;
import com.github.boukefalos.ibuddy.iBuddy;
import com.github.boukefalos.lirc.Lirc;
import com.github.boukefalos.lirc.LircButton;
import com.github.boukefalos.lirc.util.SignalObject;
public class Dummy extends Listen<Object> {
protected Lirc lirc;
protected iBuddy iBuddy;
public Dummy(Lirc lirc, iBuddy iBuddy) {
this.lirc = lirc;
this.iBuddy = iBuddy;
lirc.register(this);
}
public void start() {
lirc.start();
super.start();
}
public void input(SignalObject<Object> signalObject) {
Signal signal = signalObject.signal;
Object object = signalObject.object;
System.out.println(object);
try {
// Move these mappings to config file?
if (object instanceof LircButton) {
LircButton lircButton = (LircButton) object;
String code = lircButton.code;
logger.error(signal.name() + " : " + code + " @ " + lircButton.remote);
} else if (object instanceof Color) {
Color color = (Color) object;
System.err.println("Color: " + color);
try {
switch (color) {
case RED:
iBuddy.setHeadRed(signal.equals(Signal.BEGIN));
break;
case GREEN:
iBuddy.setHeadGreen(signal.equals(Signal.BEGIN));
break;
case YELLOW:
if (signal.equals(Signal.BEGIN)) {
iBuddy.setHead(proto.Ibuddy.Color.YELLOW);
} else {
iBuddy.setHead(proto.Ibuddy.Color.NONE);
}
break;
case BLUE:
iBuddy.setHeadBlue(signal.equals(Signal.BEGIN));
break;
default:
break;
}
} catch (Exception e) {}
} else if (object instanceof Number) {
Number number = (Number) object;
// Find way to reuse enum?
proto.Ibuddy.Color color = proto.Ibuddy.Color.valueOf(number.getNumber());
if (signal.equals(Signal.BEGIN)) {
System.err.println("Number: " + number + " Color: " + color);
iBuddy.setHead(color);
} else {
iBuddy.setHead(proto.Ibuddy.Color.NONE);
}
} else if (object instanceof Direction && signal.equals(Signal.BEGIN)) {
Direction direction = (Direction) object;
System.err.println("Direction: " + direction);
switch (direction) {
case LEFT:
iBuddy.setRotateLeft();
break;
case RIGHT:
iBuddy.setRotateRight();
break;
case UP:
iBuddy.setWingsUp();
break;
case DOWN:
iBuddy.setWingsDown();
default:
iBuddy.setRotateCenter();
iBuddy.setWingsCenter();
break;
}
}
} catch (Exception e) {}
}
}

View File

@@ -0,0 +1,36 @@
/**
* Copyright (C) 2015 Rik Veenboer <rik.veenboer@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package extra;
import map.DenonRC176EventMap;
import map.PhiliphsRCLE011EventMap;
import map.SamsungBN5901015AEventMap;
import com.github.boukefalos.lirc.state.TaskMap;
import com.github.boukefalos.lirc.state.TaskMapCycle;
public class LircTaskMapCycle extends TaskMapCycle {
protected static final long serialVersionUID = 1L;
public TaskMap denonRC176, philiphsRCLE011, samsungBN5901015A;
public LircTaskMapCycle() {
register(denonRC176 = new DenonRC176EventMap());
register(philiphsRCLE011 = new PhiliphsRCLE011EventMap());
register(samsungBN5901015A = new SamsungBN5901015AEventMap());
}
}

View File

@@ -0,0 +1,65 @@
/**
* Copyright (C) 2015 Rik Veenboer <rik.veenboer@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package extra;
import com.github.boukefalos.lirc.input.Input;
import com.github.boukefalos.lirc.util.Signal;
import com.github.boukefalos.lirc.value.Action;
import com.github.boukefalos.lirc.value.Target;
import extra.Task;
public class Task implements Input {
protected static final long serialVersionUID = 1L;
public static final Target TARGET = Target.ALL;
public static final Signal SIGNAL = Signal.NONE;
protected Target target;
protected Action action;
protected Signal signal;
public Task(Action action) {
this(action, TARGET);
}
public Task(Action action, Target target) {
this(action, target, SIGNAL);
}
public Task(Action action, Target target, Signal signal) {
this.target = target;
this.action = action;
this.signal = signal;
}
public Target getTarget() {
return target;
}
public Action getAction() {
return action;
}
public Signal getSignal() {
return signal;
}
public Task setSignal(Signal signal) {
return new Task(action, target, signal);
}
}

View File

@@ -0,0 +1,50 @@
/**
* Copyright (C) 2015 Rik Veenboer <rik.veenboer@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package map;
import com.github.boukefalos.lirc.button.remote.DenonRC176Button;
import com.github.boukefalos.lirc.state.TaskMap;
import com.github.boukefalos.lirc.value.Action;
import com.github.boukefalos.lirc.value.Target;
import extra.Task;
public class DenonRC176EventMap extends TaskMap {
protected static final long serialVersionUID = 1L;
public DenonRC176EventMap() {
/* Mimis */
receive(DenonRC176Button.TUNER_UP, new Task(Action.NEXT, Target.MAIN));
receive(DenonRC176Button.TUNER_DOWN, new Task(Action.PREVIOUS, Target.MAIN));
/* Application */
receive(DenonRC176Button.AMP_POWER, new Task(Action.START, Target.CURRENT));
receive(DenonRC176Button.CD_NEXT, new Task(Action.NEXT, Target.CURRENT));
receive(DenonRC176Button.CD_PREVIOUS, new Task(Action.PREVIOUS, Target.CURRENT));
receive(DenonRC176Button.TAPE_REWIND, new Task(Action.REWIND, Target.CURRENT));
receive(DenonRC176Button.CD_PLAY, new Task(Action.PLAY, Target.CURRENT));
receive(DenonRC176Button.CD_PAUSE, new Task(Action.PLAY, Target.CURRENT));
receive(DenonRC176Button.TAPE_FORWARD, new Task(Action.FORWARD, Target.CURRENT));
receive(DenonRC176Button.AMP_MUTE, new Task(Action.MUTE, Target.CURRENT));
receive(DenonRC176Button.AMP_VOLUME_UP, new Task(Action.VOLUME_UP, Target.CURRENT));
receive(DenonRC176Button.AMP_VOLUME_DOWN, new Task(Action.VOLUME_DOWN, Target.CURRENT));
receive(DenonRC176Button.CD_REPEAT, new Task(Action.REPEAT, Target.CURRENT));
receive(DenonRC176Button.CD_SHUFFLE, new Task(Action.SHUFFLE, Target.CURRENT));
receive(DenonRC176Button.TAPE_AB, new Task(Action.LIKE, Target.CURRENT));
receive(DenonRC176Button.TAPE_REC, new Task(Action.DISLIKE, Target.CURRENT));
}
}

View File

@@ -0,0 +1,50 @@
/**
* Copyright (C) 2015 Rik Veenboer <rik.veenboer@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package map;
import com.github.boukefalos.lirc.button.remote.PhiliphsRCLE011Button;
import com.github.boukefalos.lirc.state.TaskMap;
import com.github.boukefalos.lirc.value.Action;
import com.github.boukefalos.lirc.value.Target;
import extra.Task;
public class PhiliphsRCLE011EventMap extends TaskMap {
protected static final long serialVersionUID = 1L;
public PhiliphsRCLE011EventMap() {
/* Mimis */
receive(PhiliphsRCLE011Button.UP, new Task(Action.NEXT, Target.MAIN));
receive(PhiliphsRCLE011Button.DOWN, new Task(Action.PREVIOUS, Target.MAIN));
/* Application */
receive(PhiliphsRCLE011Button.POWER, new Task(Action.START, Target.CURRENT));
receive(PhiliphsRCLE011Button.PROGRAM_UP, new Task(Action.NEXT, Target.CURRENT));
receive(PhiliphsRCLE011Button.PROGRAM_DOWN, new Task(Action.PREVIOUS, Target.CURRENT));
receive(PhiliphsRCLE011Button.LEFT, new Task(Action.REWIND, Target.CURRENT));
receive(PhiliphsRCLE011Button.TUNE, new Task(Action.PLAY, Target.CURRENT));
receive(PhiliphsRCLE011Button.RIGHT, new Task(Action.FORWARD, Target.CURRENT));
receive(PhiliphsRCLE011Button.VOLUME_DOWN, new Task(Action.VOLUME_DOWN, Target.CURRENT));
receive(PhiliphsRCLE011Button.MUTE, new Task(Action.MUTE, Target.CURRENT));
receive(PhiliphsRCLE011Button.VOLUME_UP, new Task(Action.VOLUME_UP, Target.CURRENT));
receive(PhiliphsRCLE011Button.CLOCK, new Task(Action.REPEAT, Target.CURRENT));
receive(PhiliphsRCLE011Button.OUT, new Task(Action.SHUFFLE, Target.CURRENT));
receive(PhiliphsRCLE011Button.SQUARE, new Task(Action.FULLSCREEN, Target.CURRENT));
receive(PhiliphsRCLE011Button.RED, new Task(Action.DISLIKE, Target.CURRENT));
receive(PhiliphsRCLE011Button.GREEN, new Task(Action.LIKE, Target.CURRENT));
}
}

View File

@@ -0,0 +1,32 @@
/**
* Copyright (C) 2015 Rik Veenboer <rik.veenboer@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package map;
import com.github.boukefalos.lirc.button.remote.SamsungBN5901015AButton;
import com.github.boukefalos.lirc.state.TaskMap;
import com.github.boukefalos.lirc.value.Action;
import com.github.boukefalos.lirc.value.Target;
import extra.Task;
public class SamsungBN5901015AEventMap extends TaskMap {
protected static final long serialVersionUID = 1L;
public SamsungBN5901015AEventMap() {
receive(SamsungBN5901015AButton.VOLUME_UP, new Task(Action.VOLUME_UP, Target.CURRENT));
}
}