Merge branch 'add_effect_engine' of https://github.com/tvdzwan/hyperion into add_effect_engine

Former-commit-id: 505461722259be6884e475a9a0783ba95280b8a6
This commit is contained in:
johan 2013-12-13 00:01:59 +01:00
commit de7f340123
16 changed files with 537 additions and 88 deletions

View File

@ -1 +1 @@
a63791e2794fa0c76a2a5da3d0ce7b3e4f4089ff ada8097cb71b680dd6fa48cf190ff66c8814ad0b

View File

@ -40,6 +40,7 @@ SET(Hyperion_HEADERS
${CURRENT_SOURCE_DIR}/device/LedDeviceLpd6803.h ${CURRENT_SOURCE_DIR}/device/LedDeviceLpd6803.h
${CURRENT_SOURCE_DIR}/device/LedDeviceLpd8806.h ${CURRENT_SOURCE_DIR}/device/LedDeviceLpd8806.h
${CURRENT_SOURCE_DIR}/device/LedDeviceLightpack.h ${CURRENT_SOURCE_DIR}/device/LedDeviceLightpack.h
${CURRENT_SOURCE_DIR}/device/LedDevicePaintpack.h
${CURRENT_SOURCE_DIR}/device/LedDeviceMultiLightpack.h ${CURRENT_SOURCE_DIR}/device/LedDeviceMultiLightpack.h
) )
@ -65,6 +66,7 @@ SET(Hyperion_SOURCES
${CURRENT_SOURCE_DIR}/device/LedDeviceLpd8806.cpp ${CURRENT_SOURCE_DIR}/device/LedDeviceLpd8806.cpp
${CURRENT_SOURCE_DIR}/device/LedDeviceAdalight.cpp ${CURRENT_SOURCE_DIR}/device/LedDeviceAdalight.cpp
${CURRENT_SOURCE_DIR}/device/LedDeviceLightpack.cpp ${CURRENT_SOURCE_DIR}/device/LedDeviceLightpack.cpp
${CURRENT_SOURCE_DIR}/device/LedDevicePaintpack.cpp
${CURRENT_SOURCE_DIR}/device/LedDeviceMultiLightpack.cpp ${CURRENT_SOURCE_DIR}/device/LedDeviceMultiLightpack.cpp
) )
@ -87,6 +89,7 @@ add_library(hyperion
target_link_libraries(hyperion target_link_libraries(hyperion
hyperion-utils hyperion-utils
effectengine effectengine
hidapi-libusb
serialport serialport
${LIBUSB_1_LIBRARIES} #apt-get install libusb-1.0-0-dev ${LIBUSB_1_LIBRARIES} #apt-get install libusb-1.0-0-dev
${CMAKE_THREAD_LIBS_INIT} ${CMAKE_THREAD_LIBS_INIT}

View File

@ -23,6 +23,7 @@
#include "device/LedDeviceTest.h" #include "device/LedDeviceTest.h"
#include "device/LedDeviceWs2801.h" #include "device/LedDeviceWs2801.h"
#include "device/LedDeviceAdalight.h" #include "device/LedDeviceAdalight.h"
#include "device/LedDevicePaintpack.h"
#include "device/LedDeviceLightpack.h" #include "device/LedDeviceLightpack.h"
#include "device/LedDeviceMultiLightpack.h" #include "device/LedDeviceMultiLightpack.h"
@ -40,7 +41,7 @@ LedDevice* Hyperion::createDevice(const Json::Value& deviceConfig)
std::transform(type.begin(), type.end(), type.begin(), ::tolower); std::transform(type.begin(), type.end(), type.begin(), ::tolower);
LedDevice* device = nullptr; LedDevice* device = nullptr;
if (type == "ws2801") if (type == "ws2801" || type == "lightberry")
{ {
const std::string output = deviceConfig["output"].asString(); const std::string output = deviceConfig["output"].asString();
const unsigned rate = deviceConfig["rate"].asInt(); const unsigned rate = deviceConfig["rate"].asInt();
@ -99,6 +100,13 @@ LedDevice* Hyperion::createDevice(const Json::Value& deviceConfig)
device = deviceLightpack; device = deviceLightpack;
} }
else if (type == "paintpack")
{
LedDevicePaintpack * devicePainLightpack = new LedDevicePaintpack();
devicePainLightpack->open();
device = devicePainLightpack;
}
else if (type == "multi-lightpack") else if (type == "multi-lightpack")
{ {
LedDeviceMultiLightpack* deviceLightpack = new LedDeviceMultiLightpack(); LedDeviceMultiLightpack* deviceLightpack = new LedDeviceMultiLightpack();

View File

@ -0,0 +1,77 @@
// Hyperion includes
#include "LedDevicePaintpack.h"
LedDevicePaintpack::LedDevicePaintpack() :
LedDevice(),
_deviceHandle(nullptr)
{
// empty
}
int LedDevicePaintpack::open()
{
// initialize the usb context
int error = hid_init();
if (error != 0)
{
std::cerr << "Error while initializing the hidapi context" << std::endl;
return -1;
}
std::cout << "Hidapi initialized" << std::endl;
// Initialise the paintpack device
const unsigned short Paintpack_VendorId = 0x0ebf;
const unsigned short Paintpack_ProductId = 0x0025;
_deviceHandle = hid_open(Paintpack_VendorId, Paintpack_ProductId, nullptr);
if (_deviceHandle == nullptr)
{
// Failed to open the device
std::cerr << "Failed to open HID Paintpakc device " << std::endl;
return -1;
}
return 0;
}
LedDevicePaintpack::~LedDevicePaintpack()
{
if (_deviceHandle != nullptr)
{
hid_close(_deviceHandle);
_deviceHandle = nullptr;
}
hid_exit();
}
int LedDevicePaintpack::write(const std::vector<ColorRgb>& ledValues)
{
if (_ledBuffer.size() < 3 + ledValues.size()*3)
{
_ledBuffer.resize(3 + ledValues.size()*3, uint8_t(0));
_ledBuffer[0] = 0;
_ledBuffer[1] = 3;
_ledBuffer[2] = 0;
}
auto bufIt = _ledBuffer.begin()+3;
for (const ColorRgb & ledValue : ledValues)
{
*bufIt = ledValue.red;
++bufIt;
*bufIt = ledValue.green;
++bufIt;
*bufIt = ledValue.blue;
++bufIt;
}
return hid_write(_deviceHandle, _ledBuffer.data(), _ledBuffer.size());
}
int LedDevicePaintpack::switchOff()
{
std::fill(_ledBuffer.begin()+3, _ledBuffer.end(), uint8_t(0));
return hid_write(_deviceHandle, _ledBuffer.data(), _ledBuffer.size());
}

View File

@ -0,0 +1,59 @@
#pragma once
// STL includes
#include <vector>
// libusb include
#include <hidapi/hidapi.h>
// Hyperion includes
#include <hyperion/LedDevice.h>
///
/// LedDevice implementation for a paintpack device ()
///
class LedDevicePaintpack : public LedDevice
{
public:
/**
* Constructs the paintpack device
*/
LedDevicePaintpack();
/**
* Destructs the paintpack device, closes USB connection if open
*/
virtual ~LedDevicePaintpack();
/**
* Opens the Paintpack device
*
* @return Zero on succes else negative
*/
int open();
///
/// Writes the RGB-Color values to the leds.
///
/// @param[in] ledValues The RGB-color per led
///
/// @return Zero on success else negative
///
virtual int write(const std::vector<ColorRgb>& ledValues);
///
/// Switch the leds off
///
/// @return Zero on success else negative
///
virtual int switchOff();
private:
/// libusb device handle
hid_device * _deviceHandle;
/// buffer for led data
std::vector<uint8_t> _ledBuffer;
};

View File

@ -104,12 +104,16 @@ public class JsonStringBuffer {
++mIndentLevel; ++mIndentLevel;
} }
public void stopArray() { public void stopArray(boolean lastValue) {
--mIndentLevel; --mIndentLevel;
startLine(); startLine();
if (lastValue) {
mStrBuf.append("]\n");
} else {
mStrBuf.append("],\n"); mStrBuf.append("],\n");
} }
}
public void addRawValue(String pKey, String pValue, boolean lastValue) { public void addRawValue(String pKey, String pValue, boolean lastValue) {

View File

@ -28,6 +28,8 @@ import org.hyperion.hypercon.spec.TransformConfig;
*/ */
public class ColorTransformPanel extends JPanel { public class ColorTransformPanel extends JPanel {
private final Dimension maxDim = new Dimension(1024, 20);
private final TransformConfig mColorConfig; private final TransformConfig mColorConfig;
private JPanel mIndexPanel; private JPanel mIndexPanel;
@ -131,45 +133,57 @@ public class ColorTransformPanel extends JPanel {
mRedTransformLabel = new JLabel("RED"); mRedTransformLabel = new JLabel("RED");
mRgbTransformPanel.add(mRedTransformLabel); mRgbTransformPanel.add(mRedTransformLabel);
mRedThresholdSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mRedThreshold, 0.0, 1.0, 0.1)); mRedThresholdSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mRedThreshold, 0.0, 1.0, 0.1));
mRedThresholdSpinner.setMaximumSize(maxDim);
mRedThresholdSpinner.addChangeListener(mChangeListener); mRedThresholdSpinner.addChangeListener(mChangeListener);
mRgbTransformPanel.add(mRedThresholdSpinner); mRgbTransformPanel.add(mRedThresholdSpinner);
mRedGammaSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mRedGamma, 0.0, 100.0, 0.1)); mRedGammaSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mRedGamma, 0.0, 100.0, 0.1));
mRedThresholdSpinner.addChangeListener(mChangeListener); mRedGammaSpinner.setMaximumSize(maxDim);
mRedGammaSpinner.addChangeListener(mChangeListener);
mRgbTransformPanel.add(mRedGammaSpinner); mRgbTransformPanel.add(mRedGammaSpinner);
mRedBlacklevelSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mRedBlacklevel, 0.0, 1.0, 0.1)); mRedBlacklevelSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mRedBlacklevel, 0.0, 1.0, 0.1));
mRedThresholdSpinner.addChangeListener(mChangeListener); mRedBlacklevelSpinner.setMaximumSize(maxDim);
mRedBlacklevelSpinner.addChangeListener(mChangeListener);
mRgbTransformPanel.add(mRedBlacklevelSpinner); mRgbTransformPanel.add(mRedBlacklevelSpinner);
mRedWhitelevelSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mRedWhitelevel, 0.0, 1.0, 0.1)); mRedWhitelevelSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mRedWhitelevel, 0.0, 1.0, 0.1));
mRedThresholdSpinner.addChangeListener(mChangeListener); mRedWhitelevelSpinner.setMaximumSize(maxDim);
mRedWhitelevelSpinner.addChangeListener(mChangeListener);
mRgbTransformPanel.add(mRedWhitelevelSpinner); mRgbTransformPanel.add(mRedWhitelevelSpinner);
mGreenTransformLabel = new JLabel("GREEN"); mGreenTransformLabel = new JLabel("GREEN");
mRgbTransformPanel.add(mGreenTransformLabel); mRgbTransformPanel.add(mGreenTransformLabel);
mGreenThresholdSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mGreenThreshold, 0.0, 1.0, 0.1)); mGreenThresholdSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mGreenThreshold, 0.0, 1.0, 0.1));
mGreenThresholdSpinner.setMaximumSize(maxDim);
mGreenThresholdSpinner.addChangeListener(mChangeListener); mGreenThresholdSpinner.addChangeListener(mChangeListener);
mRgbTransformPanel.add(mGreenThresholdSpinner); mRgbTransformPanel.add(mGreenThresholdSpinner);
mGreenGammaSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mGreenGamma, 0.0, 100.0, 0.1)); mGreenGammaSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mGreenGamma, 0.0, 100.0, 0.1));
mGreenGammaSpinner.setMaximumSize(maxDim);
mGreenGammaSpinner.addChangeListener(mChangeListener); mGreenGammaSpinner.addChangeListener(mChangeListener);
mRgbTransformPanel.add(mGreenGammaSpinner); mRgbTransformPanel.add(mGreenGammaSpinner);
mGreenBlacklevelSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mGreenBlacklevel, 0.0, 1.0, 0.1)); mGreenBlacklevelSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mGreenBlacklevel, 0.0, 1.0, 0.1));
mGreenBlacklevelSpinner.setMaximumSize(maxDim);
mGreenBlacklevelSpinner.addChangeListener(mChangeListener); mGreenBlacklevelSpinner.addChangeListener(mChangeListener);
mRgbTransformPanel.add(mGreenBlacklevelSpinner); mRgbTransformPanel.add(mGreenBlacklevelSpinner);
mGreenWhitelevelSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mGreenWhitelevel, 0.0, 1.0, 0.1)); mGreenWhitelevelSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mGreenWhitelevel, 0.0, 1.0, 0.1));
mGreenWhitelevelSpinner.setMaximumSize(maxDim);
mGreenWhitelevelSpinner.addChangeListener(mChangeListener); mGreenWhitelevelSpinner.addChangeListener(mChangeListener);
mRgbTransformPanel.add(mGreenWhitelevelSpinner); mRgbTransformPanel.add(mGreenWhitelevelSpinner);
mBlueTransformLabel = new JLabel("BLUE"); mBlueTransformLabel = new JLabel("BLUE");
mRgbTransformPanel.add(mBlueTransformLabel); mRgbTransformPanel.add(mBlueTransformLabel);
mBlueThresholdSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mBlueThreshold, 0.0, 1.0, 0.1)); mBlueThresholdSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mBlueThreshold, 0.0, 1.0, 0.1));
mBlueThresholdSpinner.setMaximumSize(maxDim);
mBlueThresholdSpinner.addChangeListener(mChangeListener); mBlueThresholdSpinner.addChangeListener(mChangeListener);
mRgbTransformPanel.add(mBlueThresholdSpinner); mRgbTransformPanel.add(mBlueThresholdSpinner);
mBlueGammaSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mBlueGamma, 0.0, 100.0, 0.1)); mBlueGammaSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mBlueGamma, 0.0, 100.0, 0.1));
mBlueGammaSpinner.setMaximumSize(maxDim);
mBlueGammaSpinner.addChangeListener(mChangeListener); mBlueGammaSpinner.addChangeListener(mChangeListener);
mRgbTransformPanel.add(mBlueGammaSpinner); mRgbTransformPanel.add(mBlueGammaSpinner);
mBlueBlacklevelSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mBlueBlacklevel, 0.0, 1.0, 0.1)); mBlueBlacklevelSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mBlueBlacklevel, 0.0, 1.0, 0.1));
mBlueBlacklevelSpinner.setMaximumSize(maxDim);
mBlueBlacklevelSpinner.addChangeListener(mChangeListener); mBlueBlacklevelSpinner.addChangeListener(mChangeListener);
mRgbTransformPanel.add(mBlueBlacklevelSpinner); mRgbTransformPanel.add(mBlueBlacklevelSpinner);
mBlueWhitelevelSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mBlueWhitelevel, 0.0, 1.0, 0.1)); mBlueWhitelevelSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mBlueWhitelevel, 0.0, 1.0, 0.1));
mBlueWhitelevelSpinner.setMaximumSize(maxDim);
mBlueWhitelevelSpinner.addChangeListener(mChangeListener); mBlueWhitelevelSpinner.addChangeListener(mChangeListener);
mRgbTransformPanel.add(mBlueWhitelevelSpinner); mRgbTransformPanel.add(mBlueWhitelevelSpinner);
} }
@ -187,6 +201,7 @@ public class ColorTransformPanel extends JPanel {
mHsvTransformPanel.add(mSaturationAdjustLabel); mHsvTransformPanel.add(mSaturationAdjustLabel);
mSaturationAdjustSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mSaturationGain, 0.0, 1024.0, 0.01)); mSaturationAdjustSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mSaturationGain, 0.0, 1024.0, 0.01));
mSaturationAdjustSpinner.setMaximumSize(maxDim);
mSaturationAdjustSpinner.addChangeListener(mChangeListener); mSaturationAdjustSpinner.addChangeListener(mChangeListener);
mHsvTransformPanel.add(mSaturationAdjustSpinner); mHsvTransformPanel.add(mSaturationAdjustSpinner);
@ -194,6 +209,7 @@ public class ColorTransformPanel extends JPanel {
mHsvTransformPanel.add(mValueAdjustLabel); mHsvTransformPanel.add(mValueAdjustLabel);
mValueAdjustSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mValueGain, 0.0, 1024.0, 0.01)); mValueAdjustSpinner = new JSpinner(new SpinnerNumberModel(mColorConfig.mValueGain, 0.0, 1024.0, 0.01));
mValueAdjustSpinner.setMaximumSize(maxDim);
mValueAdjustSpinner.addChangeListener(mChangeListener); mValueAdjustSpinner.addChangeListener(mChangeListener);
mHsvTransformPanel.add(mValueAdjustSpinner); mHsvTransformPanel.add(mValueAdjustSpinner);

View File

@ -0,0 +1,24 @@
package org.hyperion.hypercon.gui.device;
import java.awt.Dimension;
import javax.swing.JPanel;
import org.hyperion.hypercon.spec.DeviceConfig;
public abstract class DeviceTypePanel extends JPanel {
protected final Dimension firstColMinDim = new Dimension(80, 10);
protected final Dimension maxDim = new Dimension(1024, 20);
protected DeviceConfig mDeviceConfig = null;
public DeviceTypePanel() {
super();
}
public void setDeviceConfig(DeviceConfig pDeviceConfig) {
mDeviceConfig = pDeviceConfig;
}
}

View File

@ -0,0 +1,63 @@
package org.hyperion.hypercon.gui.device;
import javax.swing.GroupLayout;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import org.hyperion.hypercon.spec.DeviceConfig;
public class LightPackPanel extends DeviceTypePanel {
private JLabel mSerialNoLabel;
private JTextField mSerialNoField;
public LightPackPanel() {
super();
initialise();
}
@Override
public void setDeviceConfig(DeviceConfig pDeviceConfig) {
super.setDeviceConfig(pDeviceConfig);
mSerialNoField.setText(mDeviceConfig.mOutput);
}
private void initialise() {
mSerialNoLabel = new JLabel("Serial #: ");
mSerialNoLabel.setMinimumSize(firstColMinDim);
add(mSerialNoLabel);
mSerialNoField = new JTextField();
mSerialNoField.setMaximumSize(maxDim);
mSerialNoField.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void removeUpdate(DocumentEvent e) {
mDeviceConfig.mOutput = mSerialNoField.getText();
}
@Override
public void insertUpdate(DocumentEvent e) {
mDeviceConfig.mOutput = mSerialNoField.getText();
}
@Override
public void changedUpdate(DocumentEvent e) {
mDeviceConfig.mOutput = mSerialNoField.getText();
}
});
add(mSerialNoField);
GroupLayout layout = new GroupLayout(this);
setLayout(layout);
layout.setHorizontalGroup(layout.createSequentialGroup()
.addComponent(mSerialNoLabel)
.addComponent(mSerialNoField));
layout.setVerticalGroup(layout.createParallelGroup()
.addComponent(mSerialNoLabel)
.addComponent(mSerialNoField));
}
}

View File

@ -0,0 +1,104 @@
package org.hyperion.hypercon.gui.device;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.GroupLayout;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.hyperion.hypercon.spec.DeviceConfig;
/**
* Panel for configuring Ws2801 specific settings
*/
public class SerialPanel extends DeviceTypePanel {
public static final String[] KnownOutputs = { "/dev/ttyS0", "/dev/ttyUSB0", "/dev/ttyAMA0", "/dev/null"};
private JLabel mOutputLabel;
private JComboBox<String> mOutputCombo;
private JLabel mBaudrateLabel;
private JSpinner mBaudrateSpinner;
public SerialPanel() {
super();
initialise();
}
@Override
public void setDeviceConfig(DeviceConfig pDeviceConfig) {
super.setDeviceConfig(pDeviceConfig);
mOutputCombo.setSelectedItem(mDeviceConfig.mOutput);
((SpinnerNumberModel)mBaudrateSpinner.getModel()).setValue(mDeviceConfig.mBaudrate);
}
private void initialise() {
mOutputLabel = new JLabel("Output: ");
mOutputLabel.setMinimumSize(firstColMinDim);
add(mOutputLabel);
mOutputCombo = new JComboBox<>(KnownOutputs);
mOutputCombo.setMaximumSize(maxDim);
mOutputCombo.setEditable(true);
mOutputCombo.addActionListener(mActionListener);
add(mOutputCombo);
mBaudrateLabel = new JLabel("Baudrate: ");
mBaudrateLabel.setMinimumSize(firstColMinDim);
add(mBaudrateLabel);
mBaudrateSpinner = new JSpinner(new SpinnerNumberModel(1, 1, 1000000, 128));
mBaudrateSpinner .setMaximumSize(maxDim);
mBaudrateSpinner.addChangeListener(mChangeListener);
add(mBaudrateSpinner);
GroupLayout layout = new GroupLayout(this);
layout.setAutoCreateGaps(true);
setLayout(layout);
layout.setHorizontalGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup()
.addComponent(mOutputLabel)
.addComponent(mBaudrateLabel))
.addGroup(layout.createParallelGroup()
.addComponent(mOutputCombo)
.addComponent(mBaudrateSpinner))
);
layout.setVerticalGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup()
.addComponent(mOutputLabel)
.addComponent(mOutputCombo))
.addGroup(layout.createParallelGroup()
.addComponent(mBaudrateLabel)
.addComponent(mBaudrateSpinner))
);
}
private ActionListener mActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == mOutputCombo) {
mDeviceConfig.mOutput = (String)mOutputCombo.getSelectedItem();
} else if (e.getSource() == mBaudrateSpinner) {
mDeviceConfig.mBaudrate = (Integer)mBaudrateSpinner.getValue();
}
}
};
private ChangeListener mChangeListener = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
mDeviceConfig.mBaudrate = (Integer)mBaudrateSpinner.getValue();
}
};
}

View File

@ -0,0 +1,63 @@
package org.hyperion.hypercon.gui.device;
import javax.swing.GroupLayout;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import org.hyperion.hypercon.spec.DeviceConfig;
public class TestDevicePanel extends DeviceTypePanel {
private JLabel mFilenameLabel;
private JTextField mFilenameField;
public TestDevicePanel() {
super();
initialise();
}
@Override
public void setDeviceConfig(DeviceConfig pDeviceConfig) {
super.setDeviceConfig(pDeviceConfig);
mFilenameField.setText(mDeviceConfig.mOutput);
}
private void initialise() {
mFilenameLabel = new JLabel("Filename: ");
mFilenameLabel.setMinimumSize(firstColMinDim);
add(mFilenameLabel);
mFilenameField = new JTextField();
mFilenameField.setMaximumSize(maxDim);
mFilenameField.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void removeUpdate(DocumentEvent e) {
mDeviceConfig.mOutput = mFilenameField.getText();
}
@Override
public void insertUpdate(DocumentEvent e) {
mDeviceConfig.mOutput = mFilenameField.getText();
}
@Override
public void changedUpdate(DocumentEvent e) {
mDeviceConfig.mOutput = mFilenameField.getText();
}
});
add(mFilenameField);
GroupLayout layout = new GroupLayout(this);
setLayout(layout);
layout.setHorizontalGroup(layout.createSequentialGroup()
.addComponent(mFilenameLabel)
.addComponent(mFilenameField));
layout.setVerticalGroup(layout.createParallelGroup()
.addComponent(mFilenameLabel)
.addComponent(mFilenameField));
}
}

View File

@ -0,0 +1,104 @@
package org.hyperion.hypercon.gui.device;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.GroupLayout;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.hyperion.hypercon.spec.DeviceConfig;
/**
* Panel for configuring Ws2801 specific settings
*/
public class Ws2801Panel extends DeviceTypePanel {
public static final String[] KnownOutputs = {"/dev/spidev0.0", "/dev/spidev0.1", "/dev/null"};
private JLabel mOutputLabel;
private JComboBox<String> mOutputCombo;
private JLabel mBaudrateLabel;
private JSpinner mBaudrateSpinner;
public Ws2801Panel() {
super();
initialise();
}
@Override
public void setDeviceConfig(DeviceConfig pDeviceConfig) {
super.setDeviceConfig(pDeviceConfig);
mOutputCombo.setSelectedItem(mDeviceConfig.mOutput);
((SpinnerNumberModel)mBaudrateSpinner.getModel()).setValue(mDeviceConfig.mBaudrate);
}
private void initialise() {
mOutputLabel = new JLabel("Output: ");
mOutputLabel.setMinimumSize(firstColMinDim);
add(mOutputLabel);
mOutputCombo = new JComboBox<>(KnownOutputs);
mOutputCombo.setMaximumSize(maxDim);
mOutputCombo.setEditable(true);
mOutputCombo.addActionListener(mActionListener);
add(mOutputCombo);
mBaudrateLabel = new JLabel("Baudrate: ");
mBaudrateLabel.setMinimumSize(firstColMinDim);
add(mBaudrateLabel);
mBaudrateSpinner = new JSpinner(new SpinnerNumberModel(1, 1, 1000000, 128));
mBaudrateSpinner.setMaximumSize(maxDim);
mBaudrateSpinner.addChangeListener(mChangeListener);
add(mBaudrateSpinner);
GroupLayout layout = new GroupLayout(this);
layout.setAutoCreateGaps(true);
setLayout(layout);
layout.setHorizontalGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup()
.addComponent(mOutputLabel)
.addComponent(mBaudrateLabel))
.addGroup(layout.createParallelGroup()
.addComponent(mOutputCombo)
.addComponent(mBaudrateSpinner))
);
layout.setVerticalGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup()
.addComponent(mOutputLabel)
.addComponent(mOutputCombo))
.addGroup(layout.createParallelGroup()
.addComponent(mBaudrateLabel)
.addComponent(mBaudrateSpinner))
);
}
private ActionListener mActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == mOutputCombo) {
mDeviceConfig.mOutput = (String)mOutputCombo.getSelectedItem();
} else if (e.getSource() == mBaudrateSpinner) {
mDeviceConfig.mBaudrate = (Integer)mBaudrateSpinner.getValue();
}
}
};
private ChangeListener mChangeListener = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
mDeviceConfig.mBaudrate = (Integer)mBaudrateSpinner.getValue();
}
};
}

View File

@ -47,8 +47,8 @@ public class ColorConfig {
strBuf.append("\t/// - 'gamma' The gamma-curve correction factor\n"); strBuf.append("\t/// - 'gamma' The gamma-curve correction factor\n");
strBuf.append("\t/// - 'blacklevel' The lowest possible value (when the channel is black)\n"); strBuf.append("\t/// - 'blacklevel' The lowest possible value (when the channel is black)\n");
strBuf.append("\t/// - 'whitelevel' The highest possible value (when the channel is white)\n"); strBuf.append("\t/// - 'whitelevel' The highest possible value (when the channel is white)\n");
strBuf.append("\t///"); strBuf.append("\t///\n");
strBuf.append("\t/// Next to the list with color transforms there is also a smoothing option."); strBuf.append("\t/// Next to the list with color transforms there is also a smoothing option.\n");
strBuf.append("\t/// * 'smoothing' : Smoothing of the colors in the time-domain with the following tuning \n"); strBuf.append("\t/// * 'smoothing' : Smoothing of the colors in the time-domain with the following tuning \n");
strBuf.append("\t/// parameters:\n"); strBuf.append("\t/// parameters:\n");
strBuf.append("\t/// - 'type' The type of smoothing algorithm ('linear' or 'none')\n"); strBuf.append("\t/// - 'type' The type of smoothing algorithm ('linear' or 'none')\n");

View File

@ -12,7 +12,7 @@ public class DeviceConfig {
/** The device 'file' name */ /** The device 'file' name */
public String mOutput = "/dev/spidev0.0"; public String mOutput = "/dev/spidev0.0";
/** The baudrate of the device */ /** The baudrate of the device */
public int mBaudrate = 1000000; public int mBaudrate = 250000;
/** The order of the color bytes */ /** The order of the color bytes */
public ColorByteOrder mColorByteOrder = ColorByteOrder.RGB; public ColorByteOrder mColorByteOrder = ColorByteOrder.RGB;

View File

@ -1,76 +0,0 @@
package org.hyperion.hypercon.spec;
import java.util.Vector;
import org.hyperion.hypercon.JsonStringBuffer;
/**
* The configuration structure for a single 'effect'.
*/
public class EffectConfig {
/** The identifier of the effect */
public String mId;
/** The python-script used to generate the effect */
public String mScript;
/** The arguments (key-value) of the python-script */
public final Vector<EffectArg> mArgs = new Vector<>();
/**
* The effect argument contains a key-value combination that holds a single argument of an
* effect
*/
static public class EffectArg {
/** The key of the effect argument */
public String key;
/** The value of the effect argument */
public Object value;
/**
* Constructs an new effect argument with empty key and value
*/
public EffectArg() {
this("", "");
}
/**
* Constructs an effect argument with the given key and value
*
* @param pKey The key of the new argument
* @param pValue The value of the new argument
*/
public EffectArg(String pKey, Object pValue) {
key = pKey;
value = pValue;
}
}
public void append(JsonStringBuffer pJsonBuf, boolean endOfEffects) {
pJsonBuf.startObject(mId);
pJsonBuf.addValue("script", mScript, false);
//pJsonBuf.addRawValue("args", String.format(Locale.ENGLISH, "{\n%s\n}", mArgs), true);
pJsonBuf.stopObject(endOfEffects);
}
@Override
public String toString() {
return mId;
}
@Override
public EffectConfig clone() {
EffectConfig thisClone = new EffectConfig();
thisClone.mId = mId;
thisClone.mScript = mScript;
for (EffectArg arg : mArgs) {
thisClone.mArgs.add(new EffectArg(arg.key, arg.value));
}
return thisClone;
}
}

View File

@ -13,7 +13,7 @@ public class MiscConfig {
/** Flag indicating that the boot sequence is enabled(true) or not(false) */ /** Flag indicating that the boot sequence is enabled(true) or not(false) */
public boolean mBootSequenceEnabled = true; public boolean mBootSequenceEnabled = true;
/** The effect selected for the boot sequence */ /** The effect selected for the boot sequence */
public String mBootSequenceEffect = "Rainbow Swirl (fast)"; public String mBootSequenceEffect = "Rainbow swirl fast";
/** Flag indicating that the Frame Grabber is enabled */ /** Flag indicating that the Frame Grabber is enabled */
public boolean mFrameGrabberEnabled = true; public boolean mFrameGrabberEnabled = true;
@ -68,7 +68,7 @@ public class MiscConfig {
for (String effectPath : effectPaths) { for (String effectPath : effectPaths) {
strBuf.addArrayElement(effectPath, effectPath == effectPaths[effectPaths.length-1]); strBuf.addArrayElement(effectPath, effectPath == effectPaths[effectPaths.length-1]);
} }
strBuf.stopArray(); strBuf.stopArray(!mBootSequenceEnabled);
strBuf.toggleComment(!mBootSequenceEnabled); strBuf.toggleComment(!mBootSequenceEnabled);
strBuf.addValue("bootsequence", mBootSequenceEffect, true); strBuf.addValue("bootsequence", mBootSequenceEffect, true);
strBuf.toggleComment(false); strBuf.toggleComment(false);