Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

Commit

Permalink
Prep for Release v1.1 (#10)
Browse files Browse the repository at this point in the history
Merged Commits from Dev-Branch:
* Created more effects (#7)
* Refactoring, Debug, and Logging Overhaul (#8)
* Changed Step4 example picture
  • Loading branch information
jaxcksn authored Jan 2, 2021
1 parent 9eb56c5 commit 1da95f9
Show file tree
Hide file tree
Showing 18 changed files with 470 additions and 163 deletions.
25 changes: 12 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ The effect has two different ways to set the colors, **album art** and **color p

To add a color to the palette, use the color selection dropdown, and then press the _Add Color_ button to add it to the list. To remove a color from the palette, select the color in the list, then press the remove button. Finally, press the save button to apply your changes and update the colors. To go back to album art mode, open the settings drop down and enable it again. When you exit the program, both your color palette and color made will be saved for next time.

##### Switching the Effect
<p align="center">
<img align="center" width="440" src="./assets/step4.png"/>
</p>

To change the effect, open the setting drop down, and move your mouse over the 'Choose Effect' option and another menu, with the [available effects](#available-effects) should appear. Your current effect will appear above the 'Now Playing' label in the playback view.


## Troubleshooting

Expand All @@ -87,22 +94,14 @@ To add a color to the palette, use the color selection dropdown, and then press
* It can take a moment for the program to notice the song has changed, but once you see it change on the program, it should be reflected on the device.
* If it still doesn't respond, in the settings menu there is a _reload effect_ button. Press that to restart the effect. If it doesn't work, I recommend restarting the program.


## Available Effects:
- Pulse Beat: The classic and original effect. Creates a ripple that pulses out from a random panel on every beat.
- Fireworks: Lights up a random group of panels on every beat, like distant fireworks.
- Vibe: More minimal and bright, on every beat the color of a random panel gets brighter, and every bar the color changes.

## Future Goals

For future releases, here is my list of some of my goals ordered by priority:

#### v1.0:
- [X] Refactoring and Improving Performance
- [X] Redo of the Color Palette UI
- [X] UI Overhaul

#### v1.5:
- [ ] Adding Java Documentation to Source Code
- [ ] Adding a Firework Effect
- [ ] Adding Player Controls to UI

All of my future goals for releases are in the project section of this repository, and you can keep track of the progress of them. If you have any suggestions for features, you can open an issue and I'll look into it.

## Credits

Expand Down
Binary file added assets/step4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 20 additions & 10 deletions src/main/java/dev/jaxcksn/nanoleafMusic/DataManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@

package dev.jaxcksn.nanoleafMusic;

import ch.qos.logback.classic.Logger;
import com.github.kevinsawicki.http.HttpRequest;
import dev.jaxcksn.nanoleafMusic.effects.EffectType;
import dev.jaxcksn.nanoleafMusic.utility.DataManagerException;
import dev.jaxcksn.nanoleafMusic.utility.Settings;
import dev.jaxcksn.nanoleafMusic.utility.dMEC;
import io.github.rowak.nanoleafapi.Aurora;
import io.github.rowak.nanoleafapi.StatusCodeException;
import org.slf4j.LoggerFactory;

import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
Expand All @@ -25,9 +27,11 @@
public class DataManager {
private static final Preferences preferences = Preferences.userNodeForPackage(Main.class);
public boolean hasSaved;
private static final Logger logger
= (Logger) LoggerFactory.getLogger("nanoleafMusic.DataManager");

public DataManager() {
String testForSaved = preferences.get("savedDevice",null);
String testForSaved = preferences.get("savedDevice", null);
hasSaved = testForSaved != null && !testForSaved.isEmpty();
}

Expand All @@ -39,6 +43,7 @@ public void saveDevice(Aurora device) {
";" +
device.getAccessToken();
preferences.put("savedDevice", str);
logger.info("Saved {} to preferences", device.getName());
try {
preferences.flush();
} catch (BackingStoreException e) {
Expand All @@ -49,6 +54,7 @@ public void saveDevice(Aurora device) {
public Aurora loadDevice() {
String saved = preferences.get("savedDevice",null);
if (saved == null || saved.isEmpty() || !hasSaved) {
logger.error("Could not load from preferences, key is null or empty.");
throw new DataManagerException("Could not load from preferences, key is null or empty.", dMEC.NDS);
} else {
try {
Expand All @@ -57,30 +63,28 @@ public Aurora loadDevice() {
int port = Integer.parseInt(deviceData[1]);
String accessToken = deviceData[2];
try {
logger.info("Loading device at {} from preferences", hostName);
return new Aurora(hostName,port,"v1",accessToken);
} catch (StatusCodeException | HttpRequest.HttpRequestException e) {
logger.error("Error creating device object from saved data.", e);
throw new DataManagerException("Error creating device object from saved data.",dMEC.ISD);
}

} catch (Exception e) {
logger.error("Could not process saved device data, string may be malformed.", e);
throw new DataManagerException("Could not process saved device data, string may be malformed.", dMEC.MDS);
}
}
}

public void removeDevice() {
preferences.remove("savedDevice");
logger.info("Removed saved device from preferences");
hasSaved = false;
}

public static Settings loadSettings() {
boolean albumColors = preferences.getBoolean("useAlbumColors",true);
int albumPaletteLength = preferences.getInt("numberOfAlbumColors",6);
if(albumPaletteLength > 12) {
albumPaletteLength = 12;
} else if (albumPaletteLength < 3) {
albumPaletteLength = 3;
}
boolean albumColors = preferences.getBoolean("useAlbumColors", true);
String colorPalette = preferences.get("colorPalette", "#FF0000,#00FF00,#0000FF");
if (colorPalette.length() > 95) {
colorPalette = colorPalette.substring(0, 95);
Expand All @@ -89,27 +93,33 @@ public static Settings loadSettings() {
}
String effectString = preferences.get("selectedEffect", "PULSEBEAT");
EffectType activeEffectType = EffectType.valueOf(effectString);
return new Settings(albumColors, albumPaletteLength, colorPalette, activeEffectType);
logger.info("Loaded settings from preferences");
return new Settings(albumColors, colorPalette, activeEffectType);
}

public static void updateSettings(Settings settings) {
preferences.putBoolean("useAlbumColors", settings.albumColors);
preferences.put("colorPalette", settings.colorPalette);
preferences.put("savedEffect", settings.activeEffectType.toString());
logger.info("Updated settings in preferences");
}

public static void changeAlbumMode(boolean b) {
preferences.putBoolean("useAlbumColors", b);
logger.info("Changed album mode to {} in preferences", b);
}

public static void changeEffectType(EffectType effectType) {
preferences.put("selectedEffect", effectType.toString());
logger.info("Changed saved effect type to {} in preferences", effectType);
}

public static void clearSavedData() {
try {
preferences.clear();
logger.info("Cleared all data from preferences");
} catch (BackingStoreException e) {
e.printStackTrace();
Main.showException(e);
}
}

Expand Down
Loading

0 comments on commit 1da95f9

Please sign in to comment.