More things for effects support

This commit is contained in:
Dmitry Isaenko 2019-10-15 04:31:19 +03:00
parent f20ac83c37
commit d4c138cf33
9 changed files with 200 additions and 93 deletions

3
.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
target
.idea
*.iml

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View file

@ -24,11 +24,11 @@ JRE/JDK 8u60 or higher.
1. Install JRE/JDK 8u60 or higher (openJDK is good. Oracle's one is also good). JavaFX not needed (it's embedded).
2. `root # java -jar /path/to/NS-USBloader.jar`
2. `root # java -jar /path/to/application.jar`
3. Optional. Add user to 'udev' rules to use NS not-from-root-account
```
root # vim /etc/udev/rules.d/99-NS.rules
root # vim /etc/udev/rules.d/99-G513.rules
SUBSYSTEM=="usb", ATTRS{idVendor}=="046D", ATTRS{idProduct}=="c33c", GROUP="plugdev"
root # udevadm control --reload-rules && udevadm trigger
```

View file

@ -1,20 +1,149 @@
package logiled.Controllers;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.ToggleGroup;
import javafx.scene.control.*;
import java.net.URL;
import java.util.HashMap;
import java.util.ResourceBundle;
public class EffectsController implements Initializable {
@FXML
private MenuButton effectsMenu;
@FXML
private ToggleGroup effectsToggleGrp;
@FXML
private RadioMenuItem disRMI,
constRMI,
breathRMI,
circlesOnPressRMI,
cycleRMI,
hWaveFrwRMI,
vWaveFrwRMI,
cntrToEdgWaveRMI,
hWaveBkwRMI,
vWaveBkwRMI,
edgToCntrWaveRMI;
@FXML
private ColorPicker mainClrPkr;
@FXML
private Slider mainSlide;
@FXML
private Label mainSlideInfoLbl;
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
mainSlide.valueProperty().addListener((observableValue, oldValue, newValue) -> mainSlideInfoLbl.setText(Long.toString(newValue.longValue())));
mainSlideInfoLbl.setText(String.format("%.0f", mainSlide.getValue()));
effectsMenu.setText(((RadioMenuItem) effectsToggleGrp.getSelectedToggle()).getText());
}
@FXML
private void selectEffect(ActionEvent event){
final RadioMenuItem item = (RadioMenuItem) event.getSource();
effectsMenu.setText(item.getText());
switch (item.getId()){
case "disRMI":
mainClrPkr.setVisible(false);
mainSlide.setVisible(false);
mainSlideInfoLbl.setVisible(false);
break;
case "constRMI":
case "breathRMI":
mainClrPkr.setVisible(true);
mainSlide.setVisible(false);
mainSlideInfoLbl.setVisible(false);
break;
case "cycleRMI":
mainClrPkr.setVisible(false);
mainSlide.setVisible(true);
mainSlideInfoLbl.setVisible(true);
mainSlide.setMin(20.0);
mainSlide.setMax(200.0);
mainSlide.setMajorTickUnit(10.0);
mainSlide.setBlockIncrement(10.0);
mainSlide.setValue(20.0);
break;
case "circlesOnPressRMI":
mainClrPkr.setVisible(true);
mainSlide.setVisible(true);
mainSlideInfoLbl.setVisible(true);
mainSlide.setMin(1000.0);
mainSlide.setMax(5000.0);
mainSlide.setMajorTickUnit(1000.0);
mainSlide.setBlockIncrement(100.0);
mainSlide.setValue(1000.0);
break;
case "hWaveFrwRMI":
case "vWaveFrwRMI":
case "cntrToEdgWaveRMI":
case "hWaveBkwRMI":
case "vWaveBkwRMI":
case "edgToCntrWaveRMI":
mainClrPkr.setVisible(false);
mainSlide.setVisible(true);
mainSlideInfoLbl.setVisible(true);
mainSlide.setMin(1000.0);
mainSlide.setMax(5000.0);
mainSlide.setMajorTickUnit(1000.0);
mainSlide.setBlockIncrement(100.0);
mainSlide.setValue(1000.0);
break;
}
}
public String getEffect(){
final RadioMenuItem item = (RadioMenuItem) effectsToggleGrp.getSelectedToggle();
/*
HashMap<LoEffects, byte[]> effectsSet = new HashMap<>();
byte[] meta;
switch (item.getId()){
case "disRMI":
effectsSet.put(LoEffects.DISABLE, null);
break;
case "constRMI":
effectsSet.put(LoEffects.CONSTANT_COLOR, );
break;
case "breathRMI":
effectsSet.put(LoEffects.BREATH, );
break;
case "cycleRMI":
effectsSet.put(LoEffects.CYCLE, );
break;
case "circlesOnPressRMI":
effectsSet.put(LoEffects.CIRCLES_ON_PRESS, );
break;
case "hWaveFrwRMI":
effectsSet.put(LoEffects.WAVE_HORIZONTAL_FRW, );
break;
case "vWaveFrwRMI":
effectsSet.put(LoEffects.WAVE_VERTICAL_FRW, );
break;
case "cntrToEdgWaveRMI":
effectsSet.put(LoEffects.WAVE_CENTER_TO_EDGE, );
break;
case "hWaveBkwRMI":
effectsSet.put(LoEffects.WAVE_HORIZONTAL_BKW, );
break;
case "vWaveBkwRMI":
effectsSet.put(LoEffects.WAVE_VERTICAL_BKW, );
break;
case "edgToCntrWaveRMI":
effectsSet.put(LoEffects.WAVE_EDGE_TO_CENTER, );
break;
}
*/
//System.out.println(LoEffects.DISABLE.getValue());
return item.getId();
}
}

View file

@ -1,5 +1,5 @@
package logiled.Controllers;
// TODO: rewrite to ENUM
class LoCodepage {
static byte getCode(String id){
switch (id){

View file

@ -0,0 +1,23 @@
package logiled.Controllers;
public enum LoEffects {
DISABLE ((byte) 0),
CONSTANT_COLOR ((byte) 1),
BREATH ((byte) 2),
CIRCLES_ON_PRESS ((byte) 3),
CYCLE ((byte) 4),
WAVE_HORIZONTAL_FRW ((byte) 5),
WAVE_VERTICAL_FRW ((byte) 6),
WAVE_CENTER_TO_EDGE ((byte) 7),
WAVE_HORIZONTAL_BKW ((byte) 8),
WAVE_VERTICAL_BKW ((byte) 9),
WAVE_EDGE_TO_CENTER ((byte) 10);
private final byte value;
private LoEffects(byte value){
this.value = value;
}
public byte getValue() { return value; }
}

View file

@ -51,7 +51,10 @@ public class MainController implements Initializable {
commThread.setDaemon(true);
commThread.start();
}
//else if (MainTabPane.getSelectionModel().getSelectedItem().getId().equals("EffectsTab")) { // todo }
else if (MainTabPane.getSelectionModel().getSelectedItem().getId().equals("EffectsTab")) {
// TODO
System.out.println(EffectsController.getEffect());
}
});
}
}

View file

@ -2,7 +2,9 @@
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.ColorPicker?>
<?import javafx.scene.control.RadioButton?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.MenuButton?>
<?import javafx.scene.control.RadioMenuItem?>
<?import javafx.scene.control.Separator?>
<?import javafx.scene.control.Slider?>
<?import javafx.scene.control.ToggleGroup?>
@ -14,84 +16,35 @@
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
</padding>
<children>
<HBox alignment="CENTER_LEFT" spacing="5.0">
<children>
<RadioButton mnemonicParsing="false" prefWidth="210.0" text="%effect_disable">
<MenuButton fx:id="effectsMenu" mnemonicParsing="false">
<items>
<RadioMenuItem fx:id="disRMI" mnemonicParsing="false" onAction="#selectEffect" text="%effect_disable">
<toggleGroup>
<ToggleGroup fx:id="effectsToggleGrp" />
</toggleGroup></RadioButton>
</children>
</HBox>
</toggleGroup></RadioMenuItem>
<RadioMenuItem fx:id="constRMI" mnemonicParsing="false" onAction="#selectEffect" selected="true" text="%effect_constant" toggleGroup="$effectsToggleGrp" />
<RadioMenuItem fx:id="breathRMI" mnemonicParsing="false" onAction="#selectEffect" text="%effect_breath" toggleGroup="$effectsToggleGrp" />
<RadioMenuItem fx:id="circlesOnPressRMI" mnemonicParsing="false" onAction="#selectEffect" text="%effect_cirles_on_press" toggleGroup="$effectsToggleGrp" />
<RadioMenuItem fx:id="cycleRMI" mnemonicParsing="false" onAction="#selectEffect" text="%effect_cycle" toggleGroup="$effectsToggleGrp" />
<RadioMenuItem fx:id="hWaveFrwRMI" mnemonicParsing="false" onAction="#selectEffect" text="%effect_wave_horizontal" toggleGroup="$effectsToggleGrp" />
<RadioMenuItem fx:id="vWaveFrwRMI" mnemonicParsing="false" onAction="#selectEffect" text="%effect_wave_vertical" toggleGroup="$effectsToggleGrp" />
<RadioMenuItem fx:id="cntrToEdgWaveRMI" mnemonicParsing="false" onAction="#selectEffect" text="%effect_wave_center_to_edge" toggleGroup="$effectsToggleGrp" />
<RadioMenuItem fx:id="hWaveBkwRMI" mnemonicParsing="false" onAction="#selectEffect" text="%effect_wave_horizontal_reverse" toggleGroup="$effectsToggleGrp" />
<RadioMenuItem fx:id="vWaveBkwRMI" mnemonicParsing="false" onAction="#selectEffect" text="%effect_wave_vertical_reverse" toggleGroup="$effectsToggleGrp" />
<RadioMenuItem fx:id="edgToCntrWaveRMI" mnemonicParsing="false" onAction="#selectEffect" text="%effect_wave_edge_to_center" toggleGroup="$effectsToggleGrp" />
</items>
</MenuButton>
<Separator prefWidth="200.0" />
<HBox alignment="CENTER_LEFT" spacing="5.0">
<HBox alignment="CENTER_LEFT" maxHeight="-Infinity" minHeight="-Infinity" prefHeight="35.0">
<children>
<RadioButton mnemonicParsing="false" prefWidth="210.0" selected="true" text="%effect_constant" toggleGroup="$effectsToggleGrp" />
<ColorPicker />
</children>
</HBox>
<Separator prefWidth="200.0" />
<HBox alignment="CENTER_LEFT" spacing="5.0">
<children>
<RadioButton mnemonicParsing="false" prefWidth="210.0" text="%effect_breath" toggleGroup="$effectsToggleGrp" />
<ColorPicker />
</children>
</HBox>
<Separator prefWidth="200.0" />
<HBox alignment="CENTER_LEFT" spacing="5.0">
<children>
<RadioButton mnemonicParsing="false" prefWidth="210.0" text="%effect_cirles_on_press" toggleGroup="$effectsToggleGrp" />
<Slider blockIncrement="100.0" majorTickUnit="5000.0" max="5000.0" min="1000.0" minorTickCount="1000" prefWidth="300.0" value="1000.0" />
<ColorPicker />
</children>
</HBox>
<Separator prefWidth="200.0" />
<HBox alignment="CENTER_LEFT" spacing="5.0">
<children>
<RadioButton mnemonicParsing="false" prefWidth="210.0" text="%effect_cycle" toggleGroup="$effectsToggleGrp" />
<Slider majorTickUnit="200.0" max="200.0" min="20.0" minorTickCount="20" prefWidth="300.0" value="20.0" />
</children>
</HBox>
<Separator prefWidth="200.0" />
<HBox alignment="CENTER_LEFT" spacing="5.0">
<children>
<RadioButton mnemonicParsing="false" prefWidth="210.0" text="%effect_wave_horizontal" toggleGroup="$effectsToggleGrp" />
<Slider blockIncrement="100.0" majorTickUnit="5000.0" max="5000.0" min="1000.0" minorTickCount="1000" prefWidth="300.0" value="1000.0" />
</children>
</HBox>
<Separator prefWidth="200.0" />
<HBox alignment="CENTER_LEFT" spacing="5.0">
<children>
<RadioButton mnemonicParsing="false" prefWidth="210.0" text="%effect_wave_vertical" toggleGroup="$effectsToggleGrp" />
<Slider blockIncrement="100.0" majorTickUnit="5000.0" max="5000.0" min="1000.0" minorTickCount="1000" prefWidth="300.0" value="1000.0" />
</children>
</HBox>
<Separator prefWidth="200.0" />
<HBox alignment="CENTER_LEFT" spacing="5.0">
<children>
<RadioButton mnemonicParsing="false" prefWidth="210.0" text="%effect_wave_center_to_edge" toggleGroup="$effectsToggleGrp" />
<Slider blockIncrement="100.0" majorTickUnit="5000.0" max="5000.0" min="1000.0" minorTickCount="1000" prefWidth="300.0" value="1000.0" />
</children>
</HBox>
<Separator prefWidth="200.0" />
<HBox alignment="CENTER_LEFT" spacing="5.0">
<children>
<RadioButton mnemonicParsing="false" prefWidth="210.0" text="%effect_wave_horizontal_reverse" toggleGroup="$effectsToggleGrp" />
<Slider blockIncrement="100.0" majorTickUnit="5000.0" max="5000.0" min="1000.0" minorTickCount="1000" prefWidth="300.0" value="1000.0" />
</children>
</HBox>
<Separator prefWidth="200.0" />
<HBox alignment="CENTER_LEFT" spacing="5.0">
<children>
<RadioButton mnemonicParsing="false" prefWidth="210.0" text="%effect_wave_vertical_reverse" toggleGroup="$effectsToggleGrp" />
<Slider blockIncrement="100.0" majorTickUnit="5000.0" max="5000.0" min="1000.0" minorTickCount="1000" prefWidth="300.0" value="1000.0" />
</children>
</HBox>
<Separator prefWidth="200.0" />
<HBox alignment="CENTER_LEFT" spacing="5.0">
<children>
<RadioButton mnemonicParsing="false" prefWidth="210.0" text="%effect_wave_edge_to_center" toggleGroup="$effectsToggleGrp" />
<Slider blockIncrement="100.0" majorTickUnit="5000.0" max="5000.0" min="1000.0" minorTickCount="1000" prefWidth="300.0" value="1000.0" />
<Slider fx:id="mainSlide" prefWidth="300.0" showTickLabels="true" showTickMarks="true" visible="false">
<HBox.margin>
<Insets left="10.0" right="10.0" />
</HBox.margin>
</Slider>
<Label fx:id="mainSlideInfoLbl" maxWidth="-Infinity" minWidth="-Infinity" prefWidth="40.0" textFill="DIMGRAY" visible="false" />
</children>
</HBox>
<ColorPicker fx:id="mainClrPkr" visible="false" />
</children>
</VBox>

View file

@ -35,7 +35,7 @@
-fx-text-fill: #2c2c2c;
-fx-effect: dropshadow(three-pass-box, #e82382, 2, 0, 0, 0);
}
// -========================+ TextArea =====================-
/* -========================+ TextArea =====================- */
.text-area{
-fx-background-color: transparent;
-fx-control-inner-background: #fefefe;
@ -71,11 +71,13 @@
-fx-padding: 10 5 10 5;
}
/* -======================== ToolBar =========================- */
/*
.tool-bar{
-fx-background-color: transparent;
}
// -======================== Choice box =========================-
*/
/* -======================== Choice box =========================- */
.choice-box {
-fx-background-color: #fefefe;
-fx-border-color: #fefefe;
@ -111,7 +113,7 @@
-fx-text-fill: #2c2c2c;
}
// -======================== TAB PANE =========================-
/* -======================== TAB PANE =========================- */
.tab-pane .tab SVGPath{
-fx-fill: #2c2c2c;
}
@ -152,7 +154,7 @@
.tab-pane > .tab-header-area > .headers-region > .tab {
-fx-padding: 10;
}
// -=========================== TABLE ======================-
/* -=========================== TABLE ======================- */
.table-view {
-fx-background-color: #fefefe;
-fx-background-image: url(app_logo.png);
@ -201,7 +203,7 @@
-fx-padding: 0.0em; /* 0 */
-fx-table-cell-border-color: #b0b0b0;
}
// -========================== Context menu =====================-
/* -========================== Context menu =====================- */
.context-menu {
-fx-background-color: #fefefe;
-fx-cursor: hand;
@ -212,7 +214,7 @@
.context-menu .menu-item:focused .label {
-fx-text-fill: white;
}
// -========================== Text Field =====================-
/* -========================== Text Field =====================- */
.text-field {
-fx-border-color: #289de8;
-fx-border-width: 0 0 1 0;
@ -225,7 +227,7 @@
-fx-background-color: transparent;
-fx-text-fill: #e82382;
}
// -========================== footer pane =====================-
/* -========================== footer pane =====================- */
.footer{
-fx-background-color: #ffffff;
}