Skip to content

Commit

Permalink
Merge pull request #59 from jetty840/dcnewman-merge
Browse files Browse the repository at this point in the history
Add RGB LED settings to machine > onboard parameters
  • Loading branch information
dcnewman committed May 3, 2014
2 parents 4e3d647 + 634993d commit 24a66a0
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 23 deletions.
2 changes: 1 addition & 1 deletion changelog.txt
@@ -1,4 +1,4 @@
0040r24-Sailfish ReplicatorG
0040r25-Sailfish ReplicatorG
* Replicator 2 profile now more robust
* support for selecting between s3g, x3g file formats (future bots)
* minor profile updates
Expand Down
4 changes: 2 additions & 2 deletions examples/dual/replicator_calibration_check.gcode
Expand Up @@ -13,10 +13,10 @@ G92 Z-5 (set Z to -5)
G1 Z0.0 (move Z to "0")
G161 Z F100 (home Z axis minimum)
M132 X Y Z A B (Recall stored home offsets for XYZAB axis)
(**** end homing ****)
(**** end homing *** *)
G1 X112 Y-73 Z150 F3300.0 (move to waiting position)
G130 X0 Y0 A0 B0 (Lower stepper Vrefs while heating)
M109 S110 T0 (set HBP temperature)
M109 S100 T0 (set HBP temperature)
M6 T0 (wait for toolhead, and HBP to reach temperature)
M104 S220 T0 (set extruder temperature)
M104 S220 T1 (set extruder temperature)
Expand Down
2 changes: 1 addition & 1 deletion machines/replicator2-sailfish.xml
Expand Up @@ -60,7 +60,7 @@ M18 (Turn off steppers after a build.)
<cooldown>
M18 (Turn off steppers after a build.)
</cooldown>
<bookend start="machines/replicator2/Dual_Head_start.gcode" end="machines/replicator2/Single_Head_HBP_end.gcode"/>
<bookend start="machines/replicator2/Single_Head_HBP_start.gcode" end="machines/replicator2/Single_Head_HBP_end.gcode"/>
</machine>
<machine experimental="0">
<name>Replicator 2X (Sailfish)</name>
Expand Down
2 changes: 1 addition & 1 deletion machines/replicator2/Dual_Head_start.gcode
@@ -1,4 +1,4 @@
(**** start.gcode for Replicator 2 w/HBP, Replicator 2X, single head ****)
(**** start.gcode for Replicator 2X ****)
M103 (disable RPM)
M73 P0 (enable build progress)
G21 (set units to mm)
Expand Down
2 changes: 1 addition & 1 deletion src/replicatorg/app/Base.java
Expand Up @@ -103,7 +103,7 @@ public enum InitialOpenBehavior {
* The version number of this edition of replicatorG.
*/
public static final int VERSION = 40;
public static final int REVISION = 24;
public static final int REVISION = 25;

/**
* The textual representation of this version (4 digits, zero padded).
Expand Down
135 changes: 123 additions & 12 deletions src/replicatorg/app/ui/onboard/MachineOnboardParameters.java
Expand Up @@ -876,8 +876,8 @@ private class JettyMightyBoardMachineOnboardAccelerationParameters extends Machi

// Bitmask bits indicating which tabs to set
// We worry about this aspect as part of supporting the "draft" and "quality" buttons
final int UI_TAB_1 = 0x01;
final int UI_TAB_2 = 0x02;
final int UI_TAB_1 = 0x01;
final int UI_TAB_2 = 0x02;

// Accel Parameters of Tab 1
class AccelParamsTab1 {
Expand Down Expand Up @@ -1339,8 +1339,44 @@ private class MightySailfishMachineOnboardAccelerationParameters extends Machine

// Bitmask bits indicating which tabs to set
// We worry about this aspect as part of supporting the "draft" and "quality" buttons
final int UI_TAB_1 = 0x01;
final int UI_TAB_2 = 0x02;
final int UI_TAB_1 = 0x01;
final int UI_TAB_2 = 0x02;
final int UI_TAB_LED = 0x04;

// RGB LED params
class LEDParamsTab {
int colorChoice;
boolean showHeating;
int red;
int green;
int blue;

LEDParamsTab(int colorChoice,
boolean showHeating,
int red,
int green,
int blue)
{
if (colorChoice < 0 || colorChoice > 8)
colorChoice = 0;
this.colorChoice = colorChoice;
this.showHeating = showHeating;
this.red = red & 0xff;
this.green = green & 0xff;
this.blue = blue & 0xff;
}

boolean isEqual(LEDParamsTab params)
{
if (this == params)
return true;
return(colorChoice == params.colorChoice &&
showHeating == params.showHeating &&
red == params.red &&
green == params.green &&
blue == params.blue);
}
}

// Accel Parameters of Tab 1
class AccelParamsTab1 {
Expand Down Expand Up @@ -1406,10 +1442,12 @@ class AccelParamsTab2 {
private class AccelParams {
public AccelParamsTab1 tab1;
public AccelParamsTab2 tab2;
public LEDParamsTab tabLED;

AccelParams(AccelParamsTab1 params1, AccelParamsTab2 params2) {
this.tab1 = params1;
this.tab2 = params2;
AccelParams(AccelParamsTab1 params1, AccelParamsTab2 params2, LEDParamsTab paramsLED) {
this.tab1 = params1;
this.tab2 = params2;
this.tabLED = paramsLED;
}
}

Expand Down Expand Up @@ -1600,6 +1638,34 @@ private class AccelParams {
"The reduction in printing speed then gives the planner a chance to catch up."));
}

private JCheckBox moodLightShowHeatingBox = new JCheckBox();

public final String[] moodLightChoices = {
"White",
"Red",
"Orange",
"Pink",
"Green",
"Blue",
"Purple",
"Off",
"Custom Color"
};

private JColorChooser moodLightCustomColor = new JColorChooser();
{
moodLightCustomColor.setToolTipText(wrap2HTML(width,
"Select the color to use when the \"Custom Color\" lighting choice " +
"is selected."));
}

private JComboBox moodLightScript = new JComboBox(moodLightChoices);
{
moodLightScript.setToolTipText(wrap2HTML(width,
"Select the LED lighting color. To use a custom color, select \"Custom Color\" " +
"and then pick the color with the color selection tool below."));
}

private MightySailfishMachineOnboardAccelerationParameters(OnboardParameters target,
Driver driver,
JTabbedPane subtabs) {
Expand All @@ -1623,6 +1689,7 @@ public void actionPerformed(ActionEvent arg0) {
}

AccelParams getAccelParamsFromUI() {
Color c = moodLightCustomColor.getColor();
return new AccelParams(new AccelParamsTab1(accelerationBox.isSelected(),
new int[] {((Number)normalMoveAcceleration.getValue()).intValue(),
((Number)extruderMoveAcceleration.getValue()).intValue()},
Expand All @@ -1645,7 +1712,12 @@ AccelParams getAccelParamsFromUI() {
new int[] {((Number)extruderDeprimeA.getValue()).intValue(),
((Number)extruderDeprimeB.getValue()).intValue()},
new double[] {((Number)JKNAdvance1.getValue()).doubleValue(),
((Number)JKNAdvance2.getValue()).doubleValue()}));
((Number)JKNAdvance2.getValue()).doubleValue()}),
new LEDParamsTab(moodLightScript.getSelectedIndex(),
moodLightShowHeatingBox.isSelected(),
c.getRed(),
c.getGreen(),
c.getBlue()));
}

@Override
Expand Down Expand Up @@ -1682,6 +1754,12 @@ private void setEEPROMFromUI(AccelParams params) {

target.setEEPROMParam(OnboardParameters.EEPROMParams.ACCEL_EXTRUDER_DEPRIME_A, params.tab2.deprime[0]);
target.setEEPROMParam(OnboardParameters.EEPROMParams.ACCEL_EXTRUDER_DEPRIME_B, params.tab2.deprime[1]);

target.setEEPROMParam(OnboardParameters.EEPROMParams.MOOD_LIGHT_SCRIPT, params.tabLED.colorChoice);
target.setEEPROMParam(OnboardParameters.EEPROMParams.MOOD_LIGHT_SHOW_HEATING, params.tabLED.showHeating ? 1 : 0);
target.setEEPROMParam(OnboardParameters.EEPROMParams.MOOD_LIGHT_CUSTOM_RED, params.tabLED.red);
target.setEEPROMParam(OnboardParameters.EEPROMParams.MOOD_LIGHT_CUSTOM_GREEN, params.tabLED.green);
target.setEEPROMParam(OnboardParameters.EEPROMParams.MOOD_LIGHT_CUSTOM_BLUE, params.tabLED.blue);
}

@Override
Expand All @@ -1702,7 +1780,12 @@ private void setUIFields(AccelParamsTab1 params) {
params.maxAccelerations,
params.maxSpeedChanges,
null,
null);
null,
0,
false,
0x00,
0x00,
0x00);
}

private void setUIFields(int tabs,
Expand All @@ -1717,7 +1800,12 @@ private void setUIFields(int tabs,
int[] maxAccelerations,
int[] maxSpeedChanges,
double[] JKNadvance,
int[] deprime) {
int[] deprime,
int colorChoice,
boolean showHeating,
int red,
int green,
int blue) {

if ((tabs & UI_TAB_1) != 0) {
accelerationBox.setSelected(accelerationEnabled);
Expand Down Expand Up @@ -1763,6 +1851,14 @@ private void setUIFields(int tabs,
}
}

if ((tabs & UI_TAB_LED) != 0) {
if (colorChoice < 0 || colorChoice > 8)
colorChoice = 0;
moodLightScript.setSelectedIndex(colorChoice);
moodLightShowHeatingBox.setSelected(showHeating);
moodLightCustomColor.setColor(red & 0xff, green & 0xff, blue & 0xff);
}

// Enable/disable the draft & quality buttons based upon the UI field values
// propertyChange(null);
}
Expand Down Expand Up @@ -1802,9 +1898,16 @@ public void setUIFromEEPROM() {
target.getEEPROMParamInt(OnboardParameters.EEPROMParams.ACCEL_EXTRUDER_DEPRIME_A),
target.getEEPROMParamInt(OnboardParameters.EEPROMParams.ACCEL_EXTRUDER_DEPRIME_B) };

setUIFields(UI_TAB_1 | UI_TAB_2, accelerationEnabled, slowdownEnabled, overrideGCodeTempEnabled,
int colorChoice = target.getEEPROMParamInt(OnboardParameters.EEPROMParams.MOOD_LIGHT_SCRIPT);
boolean showHeating = target.getEEPROMParamInt(OnboardParameters.EEPROMParams.MOOD_LIGHT_SHOW_HEATING) != 0;
int red = target.getEEPROMParamInt(OnboardParameters.EEPROMParams.MOOD_LIGHT_CUSTOM_RED);
int green = target.getEEPROMParamInt(OnboardParameters.EEPROMParams.MOOD_LIGHT_CUSTOM_GREEN);
int blue = target.getEEPROMParamInt(OnboardParameters.EEPROMParams.MOOD_LIGHT_CUSTOM_BLUE);

setUIFields(UI_TAB_1 | UI_TAB_2 | UI_TAB_LED, accelerationEnabled, slowdownEnabled, overrideGCodeTempEnabled,
preheatDuringPauseEnabled, extruderHoldEnabled, newToolheadOffsetSystem, checkCRC,
accelerations, maxAccelerations, maxSpeedChanges, JKNadvance, deprime);
accelerations, maxAccelerations, maxSpeedChanges, JKNadvance, deprime,
colorChoice, showHeating, red, green, blue);
}

@Override
Expand All @@ -1815,6 +1918,9 @@ public void buildUI() {
JPanel accelerationMiscTab = new JPanel(new MigLayout("fill", "[r][l]"));
subTabs.addTab("Acceleration (Misc)", accelerationMiscTab);

JPanel LEDTab = new JPanel(new MigLayout("fill", "[r][l]"));
subTabs.addTab("Lighting", LEDTab);

normalMoveAcceleration.setColumns(8);
extruderMoveAcceleration.setColumns(8);

Expand Down Expand Up @@ -1889,6 +1995,11 @@ public void buildUI() {
addWithSharedToolTips(accelerationMiscTab, "JKN Advance K2", JKNAdvance2, "wrap");
addWithSharedToolTips(accelerationMiscTab, "Right extruder deprime (steps)", extruderDeprimeA, "wrap");
addWithSharedToolTips(accelerationMiscTab, "Left extruder deprime (steps)", extruderDeprimeB, "wrap");

// LED Lighting
addWithSharedToolTips(LEDTab, "Show heating progress by changing the lighting color", moodLightShowHeatingBox, "wrap");
addWithSharedToolTips(LEDTab, "Lighting color when idle or during printing", moodLightScript, "wrap");
addWithSharedToolTips(LEDTab, "Custom color choice", moodLightCustomColor, "span 2, wrap, gapbottom push, gapright push");
}
}

Expand Down
1 change: 1 addition & 0 deletions src/replicatorg/drivers/OnboardParameters.java
Expand Up @@ -75,6 +75,7 @@ public enum EEPROMParams {
MOOD_LIGHT_CUSTOM_GREEN, //
MOOD_LIGHT_CUSTOM_RED, //
MOOD_LIGHT_SCRIPT, //
MOOD_LIGHT_SHOW_HEATING, //
OVERRIDE_GCODE_TEMP, // Override gcode temp settings with preheat temps
PLATFORM_TEMP, // Preheat & Override build platform temperature (C)
PSTOP_ENABLE, // Enable/disable the firmware Pause Stop (P-Stop)
Expand Down
21 changes: 19 additions & 2 deletions src/replicatorg/drivers/gen3/MightySailfish.java
Expand Up @@ -157,7 +157,7 @@ final static class AccelerationOffsets {
/// Boolean if HBP exists
// two bytes
final public static int HBP_PRESENT = 0X004C;
/// 38 bytes padding
/// 38 bytes padding
/// Thermistor table 0: 128 bytes
final public static int THERM_TABLE = 0x0074;
/// Padding: 8 bytes
Expand All @@ -168,6 +168,8 @@ final static class AccelerationOffsets {
/// 2 bytes padding
/// Light Effect table. 3 Bytes x 3 entries
final public static int LED_STRIP_SETTINGS = 0x0140;
final public static int BASIC_COLOR = 0x0140;
final public static int LED_HEAT = 0x0142;
final public static int CUSTOM_COLOR_OFFSET = 0x0144;
/// Buzz Effect table. 4 Bytes x 3 entries
/// 1 byte padding for offsets
Expand Down Expand Up @@ -1555,7 +1557,12 @@ public boolean verifyMachineId()
if ( this.machineId == VidPid.UNKNOWN ) {
readMachineVidPid();
}
return this.machineId.equals(VidPid.THE_REPLICATOR) || this.machineId.equals(VidPid.REPLICATOR_2);
return
this.machineId.equals(VidPid.MIGHTY_BOARD) ||
this.machineId.equals(VidPid.THE_REPLICATOR) ||
this.machineId.equals(VidPid.REPLICATOR_2) ||
this.machineId.equals(VidPid.REPLICATOR_2h) ||
this.machineId.equals(VidPid.REPLICATOR_2X);
}

@Override
Expand Down Expand Up @@ -2294,6 +2301,11 @@ public int getEEPROMParamInt(EEPROMParams param) {
case SD_USE_CRC : return getUInt8EEPROM(JettyMBEEPROM.SD_USE_CRC);
case PSTOP_ENABLE : return getUInt8EEPROM(JettyMBEEPROM.PSTOP_ENABLE);
case HBP_PRESENT : return getUInt8EEPROM(JettyMBEEPROM.HBP_PRESENT);
case MOOD_LIGHT_SCRIPT : return getUInt8EEPROM(MightySailfish5XEEPROM.BASIC_COLOR);
case MOOD_LIGHT_SHOW_HEATING : return getUInt8EEPROM(MightySailfish5XEEPROM.LED_HEAT);
case MOOD_LIGHT_CUSTOM_RED : return getUInt8EEPROM(MightySailfish5XEEPROM.CUSTOM_COLOR_OFFSET + 0x00);
case MOOD_LIGHT_CUSTOM_GREEN : return getUInt8EEPROM(MightySailfish5XEEPROM.CUSTOM_COLOR_OFFSET + 0x01);
case MOOD_LIGHT_CUSTOM_BLUE : return getUInt8EEPROM(MightySailfish5XEEPROM.CUSTOM_COLOR_OFFSET + 0x02);
default :
Base.logger.log(Level.WARNING, "getEEPROMParamInt(" + param + ") call failed");
return 0;
Expand Down Expand Up @@ -2347,6 +2359,11 @@ public void setEEPROMParam(EEPROMParams param, int val) {
case SD_USE_CRC : setUInt8EEPROM(JettyMBEEPROM.SD_USE_CRC, (val != 0) ? 1 : 0); break;
case PSTOP_ENABLE : setUInt8EEPROM(JettyMBEEPROM.PSTOP_ENABLE, (val != 0) ? 1 : 0); break;
case HBP_PRESENT : setUInt8EEPROM(JettyMBEEPROM.HBP_PRESENT, (val != 0) ? 1 : 0); break;
case MOOD_LIGHT_SCRIPT : setUInt8EEPROM(MightySailfish5XEEPROM.BASIC_COLOR, val); break;
case MOOD_LIGHT_SHOW_HEATING : setUInt8EEPROM(MightySailfish5XEEPROM.LED_HEAT, (val != 0) ? 1 : 0); break;
case MOOD_LIGHT_CUSTOM_RED : setUInt8EEPROM(MightySailfish5XEEPROM.CUSTOM_COLOR_OFFSET + 0x00, val); break;
case MOOD_LIGHT_CUSTOM_GREEN : setUInt8EEPROM(MightySailfish5XEEPROM.CUSTOM_COLOR_OFFSET + 0x01, val); break;
case MOOD_LIGHT_CUSTOM_BLUE : setUInt8EEPROM(MightySailfish5XEEPROM.CUSTOM_COLOR_OFFSET + 0x02, val); break;
default : Base.logger.log(Level.WARNING, "setEEPROMParam(" + param + ", " + val + ") call failed"); break;
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/replicatorg/drivers/gen3/VidPid.java
Expand Up @@ -9,9 +9,11 @@
public enum VidPid {
UNKNOWN (0X0000, 0X000),
MIGHTY_BOARD (0x23C1, 0xB404), //Board 404!
THE_REPLICATOR(0x23C1, 0xD314), //Dean 314
REPLICATOR_2(0x23C1, 0xB015), // BOTS as leet
SAILFISH_G34(0x23C1, 0xACDC); // Sailfish Gen 3 and Gen 4 Motherboard (Cupcake/Thingomatic)
THE_REPLICATOR (0x23C1, 0xD314), //Dean 314
REPLICATOR_2 (0x23C1, 0xB015), // BOTS as leet
REPLICATOR_2h (0x23C1, 0xB016), // Rev H board?
REPLICATOR_2X (0x23C1, 0xB017), //
SAILFISH_G34 (0x23C1, 0xACDC); // Sailfish Gen 3 and Gen 4 Motherboard (Cupcake/Thingomatic)

final int pid; //productId (same as USB product id)
final int vid; //vendorId (same as USB vendor id)
Expand Down

0 comments on commit 24a66a0

Please sign in to comment.