From 01ee91e7622bbdf6a940b2d8ca9efc1f133cbe97 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tomas=20Wenstr=C3=B6m?= Date: Sat, 22 Apr 2017 17:34:42 +0200 Subject: [PATCH] Added an Ant build file and a small SPI test --- build.xml | 207 ++++++++++++++++++++++++++++++++++ config.properties | 2 + src/kaka/cakelight/CakeLight.java | 4 +- src/kaka/cakelight/GuiTest.java | 7 +- src/kaka/cakelight/LedController.java | 23 ++++ src/kaka/cakelight/Main.java | 2 +- 6 files changed, 236 insertions(+), 9 deletions(-) create mode 100644 build.xml diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..a0d21ec --- /dev/null +++ b/build.xml @@ -0,0 +1,207 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/config.properties b/config.properties index df7ee04..2e2934d 100644 --- a/config.properties +++ b/config.properties @@ -1,3 +1,5 @@ +jdk.home.1.8=/usr/lib/jvm/java-8-openjdk-amd64 + # Video info can be found with 'v4l2-ctl --get-fmt-video' # Supported formats: UYVY, YUYV, YVYU video.format=UYVY diff --git a/src/kaka/cakelight/CakeLight.java b/src/kaka/cakelight/CakeLight.java index 5401c0f..9b32c02 100644 --- a/src/kaka/cakelight/CakeLight.java +++ b/src/kaka/cakelight/CakeLight.java @@ -5,9 +5,9 @@ public class CakeLight { private Mode mode; private LedController ledController; - public CakeLight(Configuration config, LedController ledController) { + public CakeLight(Configuration config) { this.config = config; - this.ledController = ledController; + this.ledController = new LedController(config); } public void setMode(Mode mode) { diff --git a/src/kaka/cakelight/GuiTest.java b/src/kaka/cakelight/GuiTest.java index 6dbb5ff..b73d37f 100644 --- a/src/kaka/cakelight/GuiTest.java +++ b/src/kaka/cakelight/GuiTest.java @@ -56,12 +56,7 @@ public class GuiTest extends Application { private void setupCakeLight() { log("Running with config:\n" + config); - cakelight = new CakeLight(config, new LedController() { - @Override - public void onFrame(LedFrame ledFrame) { - if (!paused) drawLEDs(canvas.getGraphicsContext2D(), ledFrame); - } - }); + cakelight = new CakeLight(config); VideoMode mode = new VideoMode(); cakelight.setMode(mode); cakelight.startLoop(); diff --git a/src/kaka/cakelight/LedController.java b/src/kaka/cakelight/LedController.java index 201644d..9a23331 100644 --- a/src/kaka/cakelight/LedController.java +++ b/src/kaka/cakelight/LedController.java @@ -1,6 +1,29 @@ package kaka.cakelight; +import com.pi4j.io.spi.SpiChannel; +import com.pi4j.io.spi.SpiDevice; +import com.pi4j.io.spi.SpiFactory; + +import java.io.IOException; + public class LedController { + public static void main(String args[]) { + new LedController(null); + } + + public LedController(Configuration config) { + try { + SpiDevice spi = SpiFactory.getInstance(SpiChannel.CS0); + spi.write( + (byte)0xff, (byte)0x0, (byte)0x0, + (byte)0x00, (byte)0xff, (byte)0x0, + (byte)0x0, (byte)0x00, (byte)0xff + ); + } catch (IOException e) { + e.printStackTrace(); + } + } + public void onFrame(LedFrame ledFrame) { // TODO } diff --git a/src/kaka/cakelight/Main.java b/src/kaka/cakelight/Main.java index e071fec..9786aac 100644 --- a/src/kaka/cakelight/Main.java +++ b/src/kaka/cakelight/Main.java @@ -13,7 +13,7 @@ public class Main { Configuration config = Configuration.from("config.properties"); log("Running with config:\n" + config); - CakeLight cakelight = new CakeLight(config, new LedController()); + CakeLight cakelight = new CakeLight(config); cakelight.setMode(new VideoMode()); cakelight.startLoop(); // try { -- 2.11.0