Skip to content

Commit

Permalink
Device-Settings, Exit-Dialog, refs #5
Browse files Browse the repository at this point in the history
  • Loading branch information
SnowballThrower committed Apr 19, 2017
1 parent 84cb7f7 commit 4fbf946
Show file tree
Hide file tree
Showing 5 changed files with 291 additions and 40 deletions.
91 changes: 63 additions & 28 deletions Controller/DMXControl/DMXControl.ino
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,13 @@ void setup() {
for (i = 0; i < ChN + xCh; i++) {
values[i] = 0;
}
//Display
values[ChN + 0] = 255;
values[ChN + 1] = 255;
values[ChN + 2] = 0;
values[ChN + 3] = 255;
values[ChN + 4] = 60;
//Fader
for (i = 0; i < 8; i++) {
active[i] = false;
ofs[i] = i;
Expand Down Expand Up @@ -267,36 +269,12 @@ void encoder() {
if (turn) {
deactivateFaders();
if (turnRnL) {
if (mode == 3) {
midiButtonSend(true, true, 8);
}
if (DevChn) {
dev = calc(dev, 1, noD);
Ch = deviceStart[dev];
} else {
Ch = calc(Ch, 1, ChN + xCh);
}
right();
} else {
if (mode == 3) {
midiButtonSend(true, true, 9);
}
if (DevChn) {
dev = calc(dev, -1, noD);
Ch = deviceStart[dev];
} else {
Ch = calc(Ch, -1, ChN + xCh);
}
left();
}
turn = false;
if (mode != 3) {
lcd.clear();
lcd.print(String(Ch + 1));
lcd.setCursor(0, 1);
int p;
for (p = 0; p < 8; p++) {
printChannelName(p);
}
}
actDispAfterTurn();
}
}

Expand All @@ -323,7 +301,17 @@ void displayAnalog2() {
analogWrite(C, dispCont);
}


void actDispAfterTurn() {
if (mode != 3) {
lcd.clear();
lcd.print(String(Ch + 1));
lcd.setCursor(0, 1);
int p;
for (p = 0; p < 8; p++) {
printChannelName(p);
}
}
}

void rotLeft() {
if (lower && digitalRead(l) == HIGH && digitalRead(r) == LOW) {
Expand Down Expand Up @@ -434,3 +422,50 @@ void simpleInit() {
}
}

void onPressSel(int number) {
switch (mode) {
case 1: break;
}
}

void onReleaseSel(int number) {


}

//8 = Power
void onPressFkt(int number) {


}

//8 = Power
void onReleaseFkt(int number) {


}

void right() {
if (mode == 3) {
midiButtonSend(true, true, 8);
}
if (DevChn) {
dev = calc(dev, 1, noD);
Ch = deviceStart[dev];
} else {
Ch = calc(Ch, 1, ChN + xCh);
}
}

void left() {
if (mode == 3) {
midiButtonSend(true, true, 9);
}
if (DevChn) {
dev = calc(dev, -1, noD);
Ch = deviceStart[dev];
} else {
Ch = calc(Ch, -1, ChN + xCh);
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,8 @@ public TypeChannel[] getChannels() {
return channels;
}

public String getPicturePath() {
return picturePath;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,91 @@
import SnowballThrower.dmxsoftware.Processing.Manage;
import SnowballThrower.dmxsoftware.Surface.ControlSurface;
import SnowballThrower.dmxsoftware.Surface.MixerSurface;
import SnowballThrower.dmxsoftware.Surface.SettingSurface;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;

/**
* @author Sven
*/
public class HelloWorldMain extends Application {

@Override
public void start(Stage primaryStage) {
Manage mng = new Manage();
Button btn = new Button();
Button btn1 = new Button();
Button btn2 = new Button();
btn2.setTranslateY(30);
Devices devices = new Devices(mng);
btn.setText("Say 'Hello World'");
btn.setOnAction(new EventHandler<ActionEvent>() {

btn1.setText("ControlSurface");
btn1.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println("Hello World!");
mng.startMidi();
//MixerSurface ms = new MixerSurface(new Stage());
ControlSurface cs = new ControlSurface(mng, devices.getDevices(), devices.getChannels());
}
});

StackPane root = new StackPane();
root.getChildren().add(btn);

btn2.setText("Settings");
btn2.setOnAction(new EventHandler<ActionEvent>() {

@Override
public void handle(ActionEvent event) {
SettingSurface ss = new SettingSurface(new Stage(), devices.getDevices(), devices.getTypes());
}
});

StackPane root = new StackPane(btn1,btn2);
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("Hello World!");
Platform.setImplicitExit(false);
primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {

@Override
public void handle(WindowEvent event) {
Stage dialog = new Stage();
Text text = new Text("Are You sure, You want to exit the Application?");
Button ok = new Button("OK");
ok.setOnAction(new EventHandler<ActionEvent>() {

@Override
public void handle(ActionEvent t) {
dialog.close();
System.exit(1);
}
});
Button cancel = new Button("Cancel");
cancel.setOnAction(new EventHandler<ActionEvent>() {

@Override
public void handle(ActionEvent t) {
dialog.close();
}
});
text.setTranslateX(20);
text.setTranslateY(20);
ok.setTranslateX(150);
ok.setTranslateY(50);
cancel.setTranslateX(80);
cancel.setTranslateY(50);
Group menu = new Group(text, ok, cancel);
Scene closing = new Scene(menu);
dialog.setScene(closing);
dialog.setTitle("Shutdown?");
dialog.show();
event.consume();
}
});
primaryStage.setScene(scene);
primaryStage.show();
}
Expand All @@ -53,5 +104,5 @@ public void handle(ActionEvent event) {
public static void main(String[] args) {
launch(args);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,10 @@ public List<Device> getDevices() {
public Channels getChannels() {
return channels;
}

public List<DeviceType> getTypes() {
return types;
}


}
Loading

0 comments on commit 4fbf946

Please sign in to comment.