Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: aguegu/DotMatrixJava
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: tomazas/DotMatrixJava
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 12 commits
  • 24 files changed
  • 1 contributor

Commits on Apr 25, 2015

  1. Copy the full SHA
    2d3afbb View commit details

Commits on Apr 26, 2015

  1. Removed redundant examples.

    tomazas committed Apr 26, 2015
    Copy the full SHA
    dc0876e View commit details
  2. Help files for github.

    tomazas committed Apr 26, 2015
    Copy the full SHA
    51193b1 View commit details
  3. Create LICENSE

    tomazas committed Apr 26, 2015
    Copy the full SHA
    0a19ad9 View commit details
  4. Update README.md

    tomazas committed Apr 26, 2015
    Copy the full SHA
    a981847 View commit details
  5. Update README.md

    tomazas committed Apr 26, 2015
    Copy the full SHA
    e0bb864 View commit details
  6. Update README.md

    tomazas committed Apr 26, 2015
    Copy the full SHA
    ba0ed86 View commit details
  7. Update README.md

    tomazas committed Apr 26, 2015
    Copy the full SHA
    8ebead2 View commit details
  8. Remove unnecessary code

    tomazas committed Apr 26, 2015
    Copy the full SHA
    a92ab88 View commit details

Commits on Apr 27, 2015

  1. Update SDAnimation.ino

    tomazas committed Apr 27, 2015
    Copy the full SHA
    6cbd150 View commit details

Commits on May 8, 2015

  1. Copy the full SHA
    06a3337 View commit details

Commits on Jul 20, 2015

  1. Update LICENSE

    tomazas committed Jul 20, 2015
    Copy the full SHA
    259d363 View commit details
1 change: 1 addition & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="libs/RXTXcomm.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright Tomas Uktveris (c) 2015

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
48 changes: 45 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,46 @@
DotMatrixJava
=============
8x8x8 Led Cube control program
---------

Java PC animation generator for 3D8S 8x8x8 Led charlieplexed
PC control program for generic 8x8x8 3D LED Cube found on eBay
(e.g. 3D LightSquared 8x8x8 LED Cube DIY kit, ideasoft, etc.)

![Program view](/help/program_view.png)

* Written in Java (requires Java RE, download here: http://java.com)
* Supports direct animation playback through Serial/UART interface (rxtx library)
* Various GUI usability enhancements

##### Firmware
This program can control any packet format compatible LED cube (see below).
Example firmware of a compatible LED cube with an STC12C5A60S2 MCU can be found here: [Source Code](https://github.com/tomazas/ledcube8x8x8)

##### Using the program
* Run run_x32.bat for 32-bit Windows
* Run run_x64.bat for 64-bit Windows

Check this YouTube video for example: https://youtu.be/UplJi7pdV_Y
[![Using program](http://img.youtube.com/vi/UplJi7pdV_Y/0.jpg)](https://youtu.be/UplJi7pdV_Y)

##### LED Cube control packet format

8x8x8 LED Cubes that support below packet format can be controlled with the program via Serial console or other MCU such as an Atmega/Arduino.
Example UART/Serial packet (in hex):
```
F2
00 00 00 00 00 00 00 FF
00 00 00 00 00 00 00 FF
00 00 00 00 00 00 00 FF
00 00 00 00 00 00 00 FF
00 00 00 00 00 00 00 FF
00 00 00 00 00 00 00 FF
00 00 00 00 00 00 00 FF
00 00 00 00 00 00 00 FF
```

* F2 - denotes packet header (aka. batch update)
* next 64 bytes - (8x8x8 bits) of LED light states
* one byte - controls a LED row (8 LEDs)
* can be any value in range: 00-FF (i.e. 00 - all 8 LEDs in row are off, FF - all 8 LEDs are on)
* a single line (e.g. 00 00 00 00 00 00 00 FF) denotes a 64 LED layer

`Implementation note:` to save energy/current consumption only a single layer (64 LEDs) in a LED cube is ON at one time. This is done for all layers and so fast (using a hardware timer), that the human eye does not recognize this. This hack allows to view the cube (all layers) as fully lit.
24 changes: 6 additions & 18 deletions arduino-controller/SDAnimation.ino
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
#include "SD.h"
#include "string.h"

Sd2Card card;
SdVolume volume;
const int chipSelect = 4;
File root;

void setup()
{
Serial.begin(57600);
Serial.begin(9600);

pinMode(10, OUTPUT); // change this to 53 on a mega
pinMode(10, OUTPUT); // SS pin must be output, change this to 53 on a mega

bool sd_ok = SD.begin(9);
bool sd_ok = SD.begin(9); // chip select pin

if (!sd_ok)
{
@@ -25,22 +22,13 @@ void setup()

void sendAnimation(byte *data)
{
Serial.write(0xf3);
Serial.write(data[1]);

Serial.write(0xf4);
Serial.write(data[2]);

Serial.write(0xf5);
Serial.write(data[3]);

Serial.write(0xf2);
Serial.write(0xf2); // batch update supported
for (byte i = 8; i < 72; i++)
{
Serial.write(data[i]);
}

delay(makeWord(data[6], data[7]));
delay(20);
}

void readAnimation(File & file)
@@ -61,7 +49,7 @@ void loop(void)
char *p = file.name();
char *p_dot = strchr(p, '.');

if (p_dot != NULL && strcmp(p_dot, ".DAT") == 0)
if (p_dot != NULL && strcmp(p_dot, ".dat") == 0)
{
readAnimation(file);
}
Binary file modified dotmatrixjava.jar
Binary file not shown.
Binary file removed examples.zip
Binary file not shown.
Binary file added help/program_view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added libs/RXTXcomm.jar
Binary file not shown.
Binary file removed record.dat
Binary file not shown.
Binary file removed record2.dat
Binary file not shown.
Binary file removed record3.dat
Binary file not shown.
1 change: 1 addition & 0 deletions run_x32.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java -Djava.library.path=./runtime/x32 -jar dotmatrixjava.jar
1 change: 1 addition & 0 deletions run_x64.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java -Djava.library.path=./runtime/x64 -jar dotmatrixjava.jar
Binary file added runtime/x32/rxtxParallel.dll
Binary file not shown.
Binary file added runtime/x32/rxtxSerial.dll
Binary file not shown.
Binary file added runtime/x64/rxtxParallel.dll
Binary file not shown.
Binary file added runtime/x64/rxtxSerial.dll
Binary file not shown.
9 changes: 9 additions & 0 deletions src/aguegu/dotmatrix/DMRecordFrame.java
Original file line number Diff line number Diff line change
@@ -85,6 +85,15 @@ public byte[] getData() {

return data;
}

public byte[] getSimpleData() {
byte[] data = new byte[65];

data[0] = (byte) 0xf2;
System.arraycopy(dm.getCache(), 0, data, 1, DotMatrix.CACHE_LENGTH);

return data;
}

public String getCacheString() {
return DotMatrix.cacheString(getData());
362 changes: 256 additions & 106 deletions src/aguegu/dotmatrix/DMRecordHeaderPanel.java

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/aguegu/dotmatrix/DMRecordList.java
Original file line number Diff line number Diff line change
@@ -32,6 +32,10 @@ public void syncToReocrd() {
lm.addElement(dmrf);
}
}

public int getNumFrames() {
return lm.getSize();
}

class DotMatrixRecordCellRender extends JLabel implements
ListCellRenderer<DMRecordFrame> {
34 changes: 20 additions & 14 deletions src/aguegu/dotmatrix/DMRecordPanel.java
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@ public class DMRecordPanel extends JPanel {

private static final String[] FRAME_OPERATION_COMMANDS = new String[] {
"on", "off", "x+", "x-", "y+", "y-", "z+", "z-", "3c", "3a", "2c",
"2a", "1c", "1a", "0c", "0a", "xf", "yf", "zf", "r" };
"2a", "1c", "1a", "0c", "0a", "r" };

private boolean inLoop = true;
private static Font monoFont;
@@ -58,9 +58,11 @@ public class DMRecordPanel extends JPanel {
private JPanel panelFrameOperation;

private ResourceBundle res;
private DotMatrixTest parent;

public DMRecordPanel(ResourceBundle res) {
public DMRecordPanel(DotMatrixTest parent, DMRecordPanel prev, ResourceBundle res) {
this.res = res;
this.parent = parent;
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

panelController = new JPanel();
@@ -84,8 +86,9 @@ public DMRecordPanel(ResourceBundle res) {
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

panelController.add(textAreaPane);
panelHeader = new DMRecordHeaderPanel(this, res);


panelHeader = (prev != null) ? prev.getHeader() : new DMRecordHeaderPanel(this, res);
panelHeader.updateParent(this);
panelController.add(panelHeader);

this.add(panelController);
@@ -96,6 +99,18 @@ public DMRecordPanel(ResourceBundle res) {
initMenu();
initFrameOperationPanel();
}

public DMRecordHeaderPanel getHeader() {
return panelHeader;
}

public void setFrame(int index) {
parent.setActiveFrame(index);
}

public int getNumFrames() {
return parent.getNumFrames();
}

public void setFrame(DMRecordFrame dmrf) {
this.dmrf = new DMRecordFrame(dmrf.getIndex());
@@ -250,7 +265,7 @@ public void initFrameOperationPanel() {
panelFrameOperation.add(button);
}

checkboxInLoop = new JCheckBox("", inLoop);
checkboxInLoop = new JCheckBox(res.getString("loop"), inLoop);
checkboxInLoop.addActionListener(new ActionListenerInLoop());
checkboxInLoop.setToolTipText(res.getString("loop"));
panelFrameOperation.add(checkboxInLoop);
@@ -319,15 +334,6 @@ public void actionPerformed(ActionEvent e) {
case "0a":
dm.rotate(0, false, recycle);
break;
case "xf":
dm.flip(DotMatrix.Direction.X_POSI);
break;
case "yf":
dm.flip(DotMatrix.Direction.Y_POSI);
break;
case "zf":
dm.flip(DotMatrix.Direction.Z_POSI);
break;
}
refresh(true);
}
2 changes: 2 additions & 0 deletions src/aguegu/dotmatrix/DotMatrix.java
Original file line number Diff line number Diff line change
@@ -76,6 +76,8 @@ static public String cacheString(byte[] cache) {
String s = new String();

for (int i = 0; i < cache.length; i++) {
if (i > 0 && i < 8) continue; // skip irrelevant parameters that we don't use (brightness etc.);

if (i % 8 == 0 && i > 0)
s = s.concat("\n");
s = s.concat(String.format("0x%02x, ", cache[i]));
59 changes: 34 additions & 25 deletions src/aguegu/dotmatrix/DotMatrixTest.java
Original file line number Diff line number Diff line change
@@ -7,7 +7,6 @@
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.io.File;

import java.util.Arrays;
import java.util.Locale;
import java.util.ResourceBundle;
@@ -26,7 +25,6 @@
import javax.swing.JScrollPane;
import javax.swing.JToolBar;
import javax.swing.ScrollPaneConstants;

import javax.swing.border.BevelBorder;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
@@ -54,12 +52,14 @@ public class DotMatrixTest extends JFrame {
private static final String PROGRAME_NAME = new String(
"3D8 TF Animation Editor");

private Locale locale = Locale.CHINESE;
private Locale locale = Locale.ENGLISH;
private ResourceBundle res;

private File fileRecord = null;
private String message;
private boolean isSaved = true;
private boolean firstInit = true;
private JFileChooser fs = new JFileChooser();

public static void main(String[] args) {
DotMatrixTest dmt = new DotMatrixTest();
@@ -74,10 +74,9 @@ public void init() {

this.getContentPane().removeAll();

if (dmrf == null)
dmrf = new DMRecordFrame(0);
dmrf = new DMRecordFrame(0);

panelRecord = new DMRecordPanel(res);
panelRecord = new DMRecordPanel(this, panelRecord, res);
panelRecord.setFrame(dmrf);

panelToolbar = panelToolBar();
@@ -91,14 +90,10 @@ public void init() {
.createBevelBorder(BevelBorder.LOWERED));
this.getContentPane().add(BorderLayout.SOUTH, labelStatus);

if (dmr == null)
dmr = new DMRecord();
dmr = new DMRecord();

if (listFrame == null) {
listFrame = new DMRecordList(dmr);
listFrame
.addListSelectionListener(new ListSelectionListenerListFrame());
}
listFrame = new DMRecordList(dmr);
listFrame.addListSelectionListener(new ListSelectionListenerListFrame());

JScrollPane listFramePane = new JScrollPane(listFrame,
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
@@ -114,7 +109,10 @@ public void init() {
begin();
refreshFrame();

this.setLocation(100, 100);
if (firstInit) {
firstInit = false;
this.setLocation(100, 100);
}
this.pack();
this.setResizable(false);

@@ -124,7 +122,6 @@ public void init() {
private class ActionListenerFileOperation implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser fs = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter(
"3D8 animation record (*.dat)", "dat");
fs.setFileFilter(filter);
@@ -141,13 +138,16 @@ public void actionPerformed(ActionEvent e) {
if (result == JOptionPane.YES_OPTION)
save();
}
begin();
init(); //begin
break;
case "open":
result = fs.showOpenDialog(null);
file = fs.getSelectedFile();

if (file == null || result != JFileChooser.APPROVE_OPTION)
break;

fs.setCurrentDirectory(file); // save old directory

fileRecord = file;
dmr.readRecord(fileRecord);
@@ -192,7 +192,7 @@ public void actionPerformed(ActionEvent e) {
}
}

private class ActionListenerRecordOperation implements ActionListener {
private class ActionListenerRocordOperation implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
int index = listFrame.getSelectedIndex();
@@ -242,7 +242,8 @@ public void actionPerformed(ActionEvent e) {
String sSpan = JOptionPane.showInputDialog(
res.getString("span_prompt"), "0x0080");

if (sSpan != null && sSpan.matches("0[x|X][\\p{XDigit}]{4}")) {
if (sSpan != null
&& sSpan.matches("0[x|X][\\p{XDigit}]{4}")) {
int span = Integer.decode(sSpan);
dmr.setSpan(span);
}
@@ -266,12 +267,20 @@ public void valueChanged(ListSelectionEvent e) {
if (index == -1)
return;

dmrf = dmr.getFrame(index);
panelRecord.setFrame(dmrf);
panelRecord.refresh(true);
refreshFrame();
setActiveFrame(index);
}
}

public void setActiveFrame(int index) {
dmrf = dmr.getFrame(index);
panelRecord.setFrame(dmrf);
panelRecord.refresh(true);
refreshFrame();
}

public int getNumFrames() {
return listFrame.getNumFrames();
}

private class DotMatrixTestMenuBar extends JMenuBar implements
ActionListener {
@@ -302,7 +311,7 @@ public DotMatrixTestMenuBar() {
JMenuItem button = new JMenuItem(res.getString(s));

button.setActionCommand(s);
button.addActionListener(new ActionListenerRecordOperation());
button.addActionListener(new ActionListenerRocordOperation());
mnRecord.add(button);
}

@@ -338,7 +347,7 @@ public void actionPerformed(ActionEvent e) {
switch (e.getActionCommand()) {
case "about":
JOptionPane.showMessageDialog(this,
"For more info, check\nhttp://aguegu.net",
"For more info, check\nhttp://aguegu.net\nhttp://www.wzona.info",
res.getString("about"), JOptionPane.OK_OPTION
| JOptionPane.INFORMATION_MESSAGE);
break;
@@ -431,7 +440,7 @@ private JPanel panelToolBar() {
JButton button = new JButton(new ImageIcon(getClass().getResource(
"/image/" + s + ".png")));
button.setActionCommand(s);
button.addActionListener(new ActionListenerRecordOperation());
button.addActionListener(new ActionListenerRocordOperation());
button.setToolTipText(res.getString(s));
toolbarReord.add(button);
}
48 changes: 30 additions & 18 deletions src/aguegu/dotmatrix/DotMatrixTest.properties
Original file line number Diff line number Diff line change
@@ -9,10 +9,10 @@ frame=Frame
record=Record
help=Help

append=Append
insert=Insert
update=Update
delete=Delete
append=Append Frame to End
insert=Insert Frame Above Current
update=Update current frame
delete=Delete Current Frame

language=Language
english=English
@@ -25,23 +25,23 @@ span=Span
mode_prompt=Mode\ for\ All\ Frames:\ (0-2)
brightness_prompt=Brightness\ for\ All\ Frames:\ (0x00-0xff)"
span_prompt=Span\ for\ All\ Frames:\ (0x0000-0xffff)
message=Developed\ by\ http://aGuegu.net
message=Developed\ by\ http://aGuegu.net | Updates by http://www.wzona.info
time_span=Time\ Span
upper_led=Upper\ Led
bottom_led=Bottom\ Led
about=About
loop=Loop
on=All\ On
off=All\ Off
x+=X\ +
x-=X\ -
y+=Y\ +
y-=Y\ -
z+=Z\ +
z-=Z\ -
loop=Wrap
on=All LEDs On
off=All LEDs Off
x+=Shift X forward
x-=Shift X backwards
y+=Shift Y forward
y-=Shift X backwards
z+=Shift Z forward
z-=Shift Z backwards
3c=R3\ Clockwise
3a=R3\ Anticlockwise
2c=R2\ Clockwise
@@ -50,7 +50,19 @@ z-=Z\ -
1a=R1\ Anticlockwise
0c=R0\ Clockwise
0a=R0\ Anticlockwise
xf=flip\ X
yf=flip\ Y
zf=flip\ Z
r=Reverse
xf=Flip X
yf=Flip Y
zf=Flip Z
r=Invert All LEDs
baud=Baud
play=Play
stop=Stop
comport=Serial port
open_serial=Open
close_serial=Close
delay=Update delay(ms)
delay_ms=20
refresh=Refresh
anim_loop=Loop animation