improvements to several effects

This commit is contained in:
Felix Klenner 2022-07-01 04:39:20 +02:00
parent 846959f313
commit 95e31a9e13
5 changed files with 20 additions and 25 deletions

View file

@ -12,7 +12,7 @@ public class EffectManager {
private boolean sweep = false; private boolean sweep = false;
private final LEDEffect[] effects = new LEDEffect[]{new ClockEffect(), new AnalogClockEffect(), new NetworkSpeedEffect(), new AudioVolumeEffect(), new SineEffect(), new AudioFFTEffect(), new ColorSweepEffect()}; private final LEDEffect[] effects = new LEDEffect[]{new ClockEffect(), new AnalogClockEffect(), new NetworkSpeedEffect(), new AudioVolumeEffect(), new AudioFFTEffect(), new SineEffect(), new ColorSweepEffect()};
private int activeId = 0; private int activeId = 0;
private final TrayIcon trayIcon; private final TrayIcon trayIcon;
@ -25,15 +25,12 @@ public class EffectManager {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
switch (e.getButton()) { switch (e.getButton()) {
case MouseEvent.BUTTON1: case MouseEvent.BUTTON1 -> loadNext();
loadNext(); case MouseEvent.BUTTON2 -> {
break;
case MouseEvent.BUTTON2:
sweep = !sweep; sweep = !sweep;
loadNext(); loadNext();
break; }
case MouseEvent.BUTTON3: case MouseEvent.BUTTON3 -> System.exit(0);
System.exit(0);
} }
} }

View file

@ -17,7 +17,7 @@ public class AnalogClockEffect implements LEDEffect {
return "Analog Clock"; return "Analog Clock";
} }
//private int WIDTH = HEIGHT; private int WIDTH = HEIGHT; //make square area for clock
long ns = 0; long ns = 0;
boolean upperPart = false; boolean upperPart = false;

View file

@ -27,7 +27,7 @@ public abstract class AudioEffect implements LEDEffect {
Mixer m = AudioSystem.getMixer(mixerInfo); Mixer m = AudioSystem.getMixer(mixerInfo);
Line.Info[] lines = m.getTargetLineInfo(); Line.Info[] lines = m.getTargetLineInfo();
//System.out.println(mixerInfo); System.out.println(mixerInfo);
for (Line.Info li : lines) { for (Line.Info li : lines) {
try { try {
@ -49,7 +49,7 @@ public abstract class AudioEffect implements LEDEffect {
//System.out.println("SUPPORTED TARGET FORMATS: "); //System.out.println("SUPPORTED TARGET FORMATS: ");
AudioFormat[] formats = (targetLineInfo).getFormats(); AudioFormat[] formats = (targetLineInfo).getFormats();
for (int i = 0; i < formats.length; i++) { for (int i = 0; i < formats.length; i++) {
//System.out.println("(" + i + ")" + formats[i]); System.out.println("(" + i + ")" + formats[i]);
} }
AudioFormat format = formats[formats.length > 10 ? 64 : 2]; AudioFormat format = formats[formats.length > 10 ? 64 : 2];

View file

@ -5,7 +5,6 @@ import de.zuim.ledcontrol.LEDEffect;
import java.awt.*; import java.awt.*;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date;
import static de.zuim.ledcontrol.LEDControl.HEIGHT; import static de.zuim.ledcontrol.LEDControl.HEIGHT;
@ -36,14 +35,14 @@ public class ClockEffect implements LEDEffect {
String text2 = new SimpleDateFormat("ss").format(time.getTime()); String text2 = new SimpleDateFormat("ss").format(time.getTime());
g.setFont(font); g.setFont(font);
g.setColor(Color.getHSBColor((time.get(Calendar.MINUTE)+time.get(Calendar.SECOND)/60f)/60f, 1f, 15f / 255f)); g.setColor(Color.getHSBColor((time.get(Calendar.MINUTE)+time.get(Calendar.SECOND)/60f)/60f, 1f, 4f / 255f));
//g.setColor(new Color(0, 10 - date.getMinutes() / 6, date.getMinutes() / 6)); //g.setColor(new Color(0, 10 - date.getMinutes() / 6, date.getMinutes() / 6));
//posOffset-=(4*getScale()*timeDelta)/1000000000.0; //posOffset-=(4*getScale()*timeDelta)/1000000000.0;
g.drawString(text, (int) posOffset, HEIGHT / 2 * getScale()); g.drawString(text, (int) posOffset, HEIGHT / 2 * getScale());
//g.setColor(new Color(10 - date.getSeconds() / 6, date.getSeconds() / 6, 0)); //g.setColor(new Color(10 - date.getSeconds() / 6, date.getSeconds() / 6, 0));
g.setColor(Color.getHSBColor((time.get(Calendar.SECOND)+time.get(Calendar.MILLISECOND)/1000f)/60f, 1f, 15f / 255f)); g.setColor(Color.getHSBColor((time.get(Calendar.SECOND)+time.get(Calendar.MILLISECOND)/1000f)/60f, 1f, 4f / 255f));
g.drawString(text2, 5, HEIGHT * getScale()); g.drawString(text2, 5, HEIGHT * getScale());
if (posOffset < -g.getFontMetrics().stringWidth(text)) if (posOffset < -g.getFontMetrics().stringWidth(text))
posOffset = 0; posOffset = 0;
} }
} }

View file

@ -14,8 +14,8 @@ import static de.zuim.ledcontrol.LEDControl.WIDTH;
public class NetworkSpeedEffect implements LEDEffect { public class NetworkSpeedEffect implements LEDEffect {
private static final int MAX_UPLOAD_MBIT_S = 290; private static final int MAX_UPLOAD_MBIT_S = 60;
private static final int MAX_DOWNLOAD_MBIT_S = 500; private static final int MAX_DOWNLOAD_MBIT_S = 1000;
private static final long NANOS_PER_PIXEL = 1000000000; private static final long NANOS_PER_PIXEL = 1000000000;
private static final String NETWORK_NAME = "Realtek"; private static final String NETWORK_NAME = "Realtek";
@ -77,19 +77,18 @@ public class NetworkSpeedEffect implements LEDEffect {
} }
if (history.size() > 1) { if (history.size() > 1) {
g.setFont(font);
g.setColor(new Color(1, 0, 0));
g.drawString(downloadText, WIDTH - g.getFontMetrics().stringWidth(downloadText), HEIGHT * getScale() - 3);
g.setColor(new Color(0, 1, 0));
g.drawString(uploadText, WIDTH - g.getFontMetrics().stringWidth(uploadText), HEIGHT / 2 * getScale() - 2);
for (int x = 0; x < WIDTH && x < history.size(); x++) { for (int x = 0; x < WIDTH && x < history.size(); x++) {
boolean firstUp = history.get(x).upY > history.get(x).downY; boolean firstUp = history.get(x).upY > history.get(x).downY;
drawMeasurement(g, x, firstUp); drawMeasurement(g, x, firstUp);
drawMeasurement(g, x, !firstUp); drawMeasurement(g, x, !firstUp);
} }
g.setFont(font);
g.setColor(new Color(2, 0, 2));
g.drawString(downloadText, WIDTH - g.getFontMetrics().stringWidth(downloadText), HEIGHT * getScale() - 3);
g.setColor(new Color(0, 2, 2));
g.drawString(uploadText, WIDTH - g.getFontMetrics().stringWidth(uploadText), HEIGHT / 2 * getScale() - 2);
} }
} }