Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sker65 committed Jan 30, 2015
0 parents commit 74164a1
Show file tree
Hide file tree
Showing 41 changed files with 1,806 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# go-dmd-clock

Ein Projekt zum Bau einer Uhr mit Hilfe von LED-Modulen
19 changes: 19 additions & 0 deletions dmdf.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
DMDF Format:
ints sind little endian (low byte first)
Header:
8 Byte magic: FPDMDFNT
2 Byte: xres
2 Byte: yres
2 Byte: Anzahl Frames

dann per Frame:
2 Byte: xres
for 0<y<height
for 0<x<width
1 Byte per Pixel: werte 0,1,2,4 je nach helligkeit

d.h. bei 128*32 Frames 4096 Byte

Gesamtgrösse in Byte bei 95 Frames: 389324


Binary file added foo.ani
Binary file not shown.
47 changes: 47 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.rinke.solutions.pinball</groupId>
<artifactId>go-dmd-clock</artifactId>
<version>0.0.1-SNAPSHOT</version>
<repositories>
<repository>
<id>swt-repo</id>
<url>https://swt-repo.googlecode.com/svn/repo/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.typesafe</groupId>
<artifactId>config</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.9</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<version>1.7.9</version>
</dependency>

<dependency>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt.gtk.linux.x86_64</artifactId>
<version>4.4</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
</dependency>
<dependency>
<groupId>ar.com.hjg</groupId>
<artifactId>pngj</artifactId>
<version>2.1.0</version>
</dependency>
</dependencies>
</project>
Binary file added redlight-ani.zip
Binary file not shown.
197 changes: 197 additions & 0 deletions src/main/java/com/rinke/solutions/pinball/Animation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
package com.rinke.solutions.pinball;

import com.rinke.solutions.pinball.renderer.AnimatedGIFRenderer;
import com.rinke.solutions.pinball.renderer.DMDFRenderer;
import com.rinke.solutions.pinball.renderer.FrameSet;
import com.rinke.solutions.pinball.renderer.PngRenderer;
import com.rinke.solutions.pinball.renderer.Renderer;


public class Animation {

// teil der zum einlesen gebraucht wird
protected int start = 0;
protected int end = 0;
private int skip = 2;
private String pattern = "Image-0x%04X";
private boolean autoMerge;

// meta daten
private int cycles = 1;
private String name;
private int holdCycles;
private AnimationType type;
private int refreshDelay = 100;
// defines at which frame clock should reappear
private int clockFrom;
// should we use small clock in animation
private boolean clockSmall = false;
private int clockXOffset = 24;
private int clockYOffset = 3;

// runtime daten
int act;
boolean ended = false;
private int actCycle;
int holdCount = 0;

public int getFrameSetCount() {
return (end-start)/skip;
}

public int getCycles() {
return cycles;
}

public void setCycles(int cycles) {
this.cycles = cycles;
}

public int getHoldCycles() {
return holdCycles;
}

public void setHoldCycles(int holdCycles) {
this.holdCycles = holdCycles;
}

public AnimationType getType() {
return type;
}

public void setType(AnimationType type) {
this.type = type;
}

public int getClockFrom() {
return clockFrom;
}

public void setName(String name) {
this.name = name;
}

public void setClockFrom(int clockFrom) {
this.clockFrom = clockFrom;
}

public String getName() {
return name;
}

public void setPattern(String pattern) {
this.pattern = pattern;
}

public int getRefreshDelay() {
return refreshDelay;
}

public void setRefreshDelay(int refreshDelay) {
this.refreshDelay = refreshDelay;
}

public Animation(AnimationType type, String name, int start, int end, int skip,
int cycles, int holdCycles) {
super();
this.start = start;
this.act = start;
this.end = end;
this.skip = skip;
this.cycles = cycles;
actCycle = 0;
this.name = name;
this.holdCycles = holdCycles;
this.type = type;
this.clockFrom = 20000;
}

String basePath = "/home/sr/Downloads/Pinball/";
Renderer r = null;
FrameSet last;

protected FrameSet renderFrameSet(String name,DMD dmd, int act) {
return r.convert(name, dmd, act);
}

public Renderer getRenderer() {
if( r == null ) init();
return r;
}

public FrameSet render(DMD dmd) {
if( r == null ) init();
if (act <= end) {
ended = false;
last = renderFrameSet(basePath+name, dmd, act);
act += skip;
return last;
} else if (++actCycle < cycles) {
act = start;
} else {
if (holdCount++ >= holdCycles)
ended = true;
actCycle = 0;
}
return last;
}

public boolean addClock() {
return act>clockFrom;
}

private void init() {
switch (type) {
case PNG_SEQ:
r = new PngRenderer(pattern,autoMerge);
break;
case DMDF:
r = new DMDFRenderer();
break;
case GIF:
r = new AnimatedGIFRenderer();
default:
break;
}
}

public boolean hasEnded() {
return ended;
}

public void restart() {
ended = false;
actCycle = 0;
act = start;
holdCount = 0;
}

public void setAutoMerge(boolean b) {
this.autoMerge = b;
}

public void setClockSmall(boolean clockSmall) {
this.clockSmall = clockSmall;
}

public void setClockXOffset(int clockXOffset) {
this.clockXOffset = clockXOffset;
}

public void setClockYOffset(int clockYOffset) {
this.clockYOffset = clockYOffset;
}

public boolean isClockSmall() {
return clockSmall;
}

public int getClockXOffset() {
return clockXOffset;
}

public int getClockYOffset() {
return clockYOffset;
}

}
Loading

0 comments on commit 74164a1

Please sign in to comment.