Skip to content

Commit

Permalink
Merge pull request #8 from TFyre/controls
Browse files Browse the repository at this point in the history
Various Changes
  • Loading branch information
TFyre authored Jan 26, 2024
2 parents 4546dd8 + c5cf5c5 commit 12e980e
Show file tree
Hide file tree
Showing 15 changed files with 468 additions and 106 deletions.
108 changes: 96 additions & 12 deletions bambu/frontend/themes/bambu-theme/bambu.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,33 @@
@media screen and (min-width: 0px) and (max-width:1110px) {
:root {
--bambu-columns: calc(var(--bambu-default-columns,4) - 3);
}
}
@media screen and (min-width: 1111px) and (max-width:1650px) {
:root {
--bambu-columns: calc(var(--bambu-default-columns,4) - 2);
}
}
@media screen and (min-width: 1651px) and (max-width:2200px) {
:root {
--bambu-columns: calc(var(--bambu-default-columns,4) - 1);
}
}
@media screen and (min-width: 2201px) and (max-width:2750px) {
:root {
--bambu-columns: var(--bambu-default-columns,4);
}
}
@media screen and (min-width: 2751px){
:root {
--bambu-columns: calc(var(--bambu-default-columns,4) + 1);
}
}

.dashboard-view {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
grid-template-columns: repeat(var(--bambu-columns), minmax(0, 1fr));

/*LumoUtility.Gap.MEDIUM*/
gap: var(--lumo-space-m);

Expand All @@ -14,6 +40,11 @@
width: 100%;
font-size: 2em;
text-align: center;
padding-bottom: 10px;
}

.dashboard-printer .name vaadin-button {
margin: 0.1rem;
}

.dashboard-printer .image {
Expand All @@ -36,6 +67,7 @@
}

.dashboard-printer .image img {
flex-grow: 1;
height: 95%;
width: 95%;
max-height: 720px;
Expand All @@ -52,13 +84,13 @@
font-weight: bolder;
align-items: center;
min-width: 50px;

/*LumoUtility.Padding.SMALL*/
padding: var(--lumo-space-s);

/*LumoUtility.Margin.SMALL*/
margin: var(--lumo-space-s);

/*LumoUtility.Flex.GROW*/
flex-grow: 1;

Expand Down Expand Up @@ -87,15 +119,15 @@
flex-wrap: wrap;
}

.dashboard-printer .amsheader > span {
.dashboard-printer .amsheader span {
flex-grow: 1;
}

.dashboard-printer .amsheader > span.filler {
.dashboard-printer .amsheader span.filler {
flex-grow: 10;
}

.dashboard-printer .amsheader > img {
.dashboard-printer .amsheader img {
flex-grow: 1;
max-height: 30px;
}
Expand All @@ -111,16 +143,16 @@
flex-direction: column;
font-weight: bolder;
align-items: center;

/*LumoUtility.Padding.SMALL*/
padding: var(--lumo-space-s);

/*LumoUtility.Margin.SMALL*/
margin: var(--lumo-space-s);

/*LumoUtility.Flex.GROW*/
flex-grow: 1;

/*LumoUtility.Background.BASE*/
background-color: var(--lumo-base-color);

Expand All @@ -131,9 +163,14 @@
border-radius: var(--lumo-border-radius-l);
}

.dashboard-printer .amstray .active {
--lumo-utility-border-color: var(--lumo-success-color);
border: 2px var(--lumo-utility-border-style, solid) var(--lumo-utility-border-color, var(--lumo-contrast-10pct));
}

.dashboard-printer .amstray .filament .color {
width: 50px;
height: 50px;
min-height: 50px;
border: 1px solid;

/*LumoUtility.BoxShadow.SMALL*/
Expand Down Expand Up @@ -164,4 +201,51 @@

.printer-view .content {
width: 100%;
}

.dashboard-printer .image .controlsbox {
display: flex;
}

.controlsbox .controls {
margin-top: auto;
margin-bottom: auto;
}

.controlsbox .controlheader {
display: flex;
justify-content: center;
}

.controlsbox .controlbody {
display: flex;
}

.controlxy {
margin-top: auto;
margin-bottom: auto;
}

.controlxy div.updown {
display: flex;
align-items: center;
flex-direction: column;
}

.controlxy div.leftright {
display: flex;
}

.controlxy vaadin-button,
.controlz vaadin-button {
margin: 0.1rem;
}

.controlz {
margin-top: auto;
margin-bottom: auto;
display: flex;
align-items: center;
flex-direction: column;
width: 150px;
}
4 changes: 2 additions & 2 deletions bambu/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.tfyre.bambu</groupId>
<artifactId>bambu-parent</artifactId>
<version>1.0.4</version>
<version>1.0.5</version>
</parent>
<artifactId>bambu-web</artifactId>
<packaging>jar</packaging>
Expand Down Expand Up @@ -153,4 +153,4 @@
</profile>
</profiles>

</project>
</project>
9 changes: 9 additions & 0 deletions bambu/src/main/java/com/tfyre/bambu/BambuConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,18 @@ public interface BambuConfig {
@WithDefault("false")
boolean useBouncyCastle();

@WithDefault("true")
boolean menuLeftClick();

@WithDefault("false")
boolean darkMode();

@WithDefault("5000")
int moveXy();

@WithDefault("3000")
int moveZ();

Map<String, Printer> printers();

Map<String, User> users();
Expand Down
99 changes: 99 additions & 0 deletions bambu/src/main/java/com/tfyre/bambu/printer/BambuConst.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.tfyre.bambu.printer;

import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
Expand Down Expand Up @@ -86,9 +87,107 @@ public static String gcodeTargetTemperatureNozzle(final int temperature) {
return "M104 S%d".formatted(Math.max(Math.min(temperature, TEMPERATURE_MAX_NOZZLE), 0));
}

public static String gcodeDisableSteppers() {
return "M18";
}

public static String gcodeFanSpeed(final Fan fan, final FanSpeed speed) {
return "M106 P%d S%d".formatted(fan.getValue(), speed.getValue());

}

public static List<String> gcodeMoveXYZ(final Move move, final int value, final int speed) {
return List.of(
"M211 S",
"M211 X1 Y1 Z1",
"M1002 push_ref_mode",
"G91",
"G1 %s%d F%d".formatted(move.getValue(), value, speed),
"M1002 pop_ref_mode",
"M211 R"
);
}

public static String gcodeHomeAll() {
return "G28";
}

public static String gcodeHomeXY() {
return "G28 X Y";
}

public static String gcodeHomeZ() {
return "G28 Z";
}

private BambuConst() {
}

public enum Move {
X("X"),
Y("Y"),
Z("Z");

private final String value;

private Move(final String value) {
this.value = value;
}

public String getValue() {
return value;
}

}

public enum Fan {
PART("Part", 1),
AUX("AUX", 2),
CHAMBER("Chamber", 3);

private final String name;
private final int value;

private Fan(final String name, final int value) {
this.name = name;
this.value = value;
}

public String getName() {
return name;
}

public int getValue() {
return value;
}

}

public enum FanSpeed {
OFF("Off", 0),
P25("25%", (int) (0.25 * 255)),
P50("50%", (int) (0.50 * 255)),
P75("75%", (int) (0.75 * 255)),
FULL("Full", (int) (1.0 * 255));

private final String name;
private final int value;

private FanSpeed(final String name, final int value) {
this.name = name;
this.value = value;
}

public String getName() {
return name;
}

public int getValue() {
return value;
}

}

public enum LightMode {
ON("on"),
OFF("off");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,21 +325,22 @@ private String stripSlash(final String fileName) {

@Override
public void commandPrintGCodeLine(final String lines) {
logUser("%s: commandPrintGCodeLine: %s".formatted(name, lines));
logUser("%s: commandPrintGCodeLine: [%s]".formatted(name, lines));
final BambuMessage message = BambuMessage.newBuilder()
.setPrint(
Print.newBuilder()
.setSequenceId("%d".formatted(counter.incrementAndGet()))
.setCommand("gcode_line")
.setParam(lines)
.setParam(lines.concat("\n"))
)
.build();

toJson(message).ifPresent(this::sendData);
}

@Override
public void commandPrintGCodeLine(final List<String> lines) {
commandPrintGCodeLine(String.join("\n", lines).concat("\n"));
commandPrintGCodeLine(String.join("\n", lines));
}

@Override
Expand Down
36 changes: 36 additions & 0 deletions bambu/src/main/java/com/tfyre/bambu/view/GCodeDialog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.tfyre.bambu.view;

import com.tfyre.bambu.printer.BambuPrinter;
import com.vaadin.flow.component.Unit;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.button.ButtonVariant;
import com.vaadin.flow.component.dialog.Dialog;
import com.vaadin.flow.component.textfield.TextArea;

/**
*
* @author Francois Steyn - ([email protected])
*/
public class GCodeDialog {

public static void show(final BambuPrinter printer) {
final Dialog d = new Dialog();
d.setHeaderTitle("Send GCode (No Validation!!)");
final TextArea text = new TextArea();
text.setWidthFull();
text.setHeight(95, Unit.PERCENTAGE);
d.add(text);
final Button cancel = new Button("Cancel", e -> d.close());
cancel.addThemeVariants(ButtonVariant.LUMO_ERROR);
final Button ok = new Button("OK", e -> {
d.close();
printer.commandPrintGCodeLine(text.getValue().trim().replaceAll("\n", "\\\n"));
});
ok.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
d.getFooter().add(cancel, ok);
d.setWidth(80, Unit.PERCENTAGE);
d.setHeight(80, Unit.PERCENTAGE);
d.open();
}

}
Loading

0 comments on commit 12e980e

Please sign in to comment.