Skip to content
Browse files

Moved the EEPROM settings for the new Mightyboard firmware.

WARNING: Probably broke Gen3/4 EEPROM settings. I need to revise that firmware to catch up.
  • Loading branch information...
1 parent 4bb442b commit c6cfc17c0f820cfef5a4ef1dd45efe7e3ed7004e @giseburt committed May 21, 2012
View
4 ...application/prefs/Replicator slicing defaults/profiles/extrusion/ABS/skeinforge_craft.csv
@@ -12,7 +12,7 @@ clip False
coil False
comb False
cool False
-dimension False
+dimension True
drill False
export False
feed False
@@ -31,7 +31,7 @@ multiply False
oozebane False
outset False
preface False
-raft True
+raft False
scale False
skin False
skirt False
View
40 src/replicatorg/app/ui/onboard/MachineOnboardParameters.java
@@ -83,14 +83,14 @@
private JFormattedTextField vref2 = new JFormattedTextField(threePlaces);
private JFormattedTextField vref3 = new JFormattedTextField(threePlaces);
private JFormattedTextField vref4 = new JFormattedTextField(threePlaces);
-
- private JFormattedTextField xToolheadOffsetField = new JFormattedTextField(threePlaces);
- private JFormattedTextField yToolheadOffsetField = new JFormattedTextField(threePlaces);
- private JFormattedTextField zToolheadOffsetField = new JFormattedTextField(threePlaces);
+
+ private JFormattedTextField xToolheadOffsetField = new JFormattedTextField(threePlaces);
+ private JFormattedTextField yToolheadOffsetField = new JFormattedTextField(threePlaces);
+ private JFormattedTextField zToolheadOffsetField = new JFormattedTextField(threePlaces);
+
+ private JCheckBox accelerationBox = new JCheckBox();
private JFormattedTextField masterAcceleration = new JFormattedTextField(threePlaces);
-
- private JFormattedTextField minimumPlannerSpeed = new JFormattedTextField(threePlaces);
private JFormattedTextField xAxisAcceleration = new JFormattedTextField(threePlaces);
private JFormattedTextField yAxisAcceleration = new JFormattedTextField(threePlaces);
@@ -175,17 +175,17 @@ private void commit() {
target.setStoredStepperVoltage(3, ((Number)vref3.getValue()).intValue());
target.setStoredStepperVoltage(4, ((Number)vref4.getValue()).intValue());
}
-
- target.eepromStoreToolDelta(0, ((Number)xToolheadOffsetField.getValue()).doubleValue());
- target.eepromStoreToolDelta(1, ((Number)yToolheadOffsetField.getValue()).doubleValue());
- target.eepromStoreToolDelta(2, ((Number)zToolheadOffsetField.getValue()).doubleValue());
- requestResetFromUser();
+ target.eepromStoreToolDelta(0, ((Number)xToolheadOffsetField.getValue()).doubleValue());
+ target.eepromStoreToolDelta(1, ((Number)yToolheadOffsetField.getValue()).doubleValue());
+ target.eepromStoreToolDelta(2, ((Number)zToolheadOffsetField.getValue()).doubleValue());
- if(target.hasAccelerationSupport())
+ if(target.hasAcceleration())
{
+ byte status = accelerationBox.isSelected() ? (byte)1: (byte)0;
+ target.setAccelerationStatus(status);
+
target.setMasterAccelerationRate(((Number)masterAcceleration.getValue()).intValue());
- target.setMinimumPlannerSpeed(((Number)minimumPlannerSpeed.getValue()).doubleValue());
Point5d accelerationRates = new Point5d();
accelerationRates.set(0, ((Number)xAxisAcceleration.getValue()).doubleValue());
@@ -284,11 +284,10 @@ private void loadParameters() {
}
- if(target.hasAccelerationSupport())
+ if(target.hasAcceleration())
{
+ accelerationBox.setSelected(this.target.getAccelerationStatus());
masterAcceleration.setValue(target.getMasterAccelerationRate());
-
- minimumPlannerSpeed.setValue(target.getMinimumPlannerSpeed());
Point5d accelerationRates = target.getAxisAccelerationRates();
xAxisAcceleration.setValue(accelerationRates.x());
@@ -437,13 +436,12 @@ public MachineOnboardParameters(OnboardParameters target, Driver driver, JFrame
homeVrefsTab.add(zToolheadOffsetField, "spanx, wrap");
}
- if(target.hasAccelerationSupport())
+ if(target.hasAcceleration())
{
JPanel accelerationTab = new JPanel(new MigLayout("fill", "[r][l][r][l]"));
subTabs.addTab("Acceleration", accelerationTab);
masterAcceleration.setColumns(4);
- minimumPlannerSpeed.setColumns(4);
xAxisAcceleration.setColumns(8);
xyJunctionJerk.setColumns(4);
@@ -459,11 +457,11 @@ public MachineOnboardParameters(OnboardParameters target, Driver driver, JFrame
bAxisAcceleration.setColumns(8);
bJunctionJerk.setColumns(4);
+ accelerationTab.add(new JLabel("Acceleration On"));
+ accelerationTab.add(accelerationBox, "spanx, wrap");
+
accelerationTab.add(new JLabel("Master acceleration rate (mm/s/s)"));
accelerationTab.add(masterAcceleration, "spanx, wrap");
-
- accelerationTab.add(new JLabel("Deceleration minimum speed (mm/s)"));
- accelerationTab.add(minimumPlannerSpeed, "spanx, wrap");
accelerationTab.add(new JLabel("X acceleration rate (mm/s/s)"));
accelerationTab.add(xAxisAcceleration);
View
7 src/replicatorg/drivers/DriverBaseImplementation.java
@@ -219,9 +219,10 @@ public Version getVersion() {
public Version getMinimumVersion() {
return minimumVersion;
}
- public Version getMinimumAccelerationVersion(){
- return minimumAccelerationVersion;
- }
+
+ public Version getMinimumAccelerationVersion(){
+ return minimumAccelerationVersion;
+ }
public Version getPreferredVersion() {
return preferredVersion;
View
22 src/replicatorg/drivers/OnboardParameters.java
@@ -42,17 +42,7 @@
double getAxisHomeOffset(int axis);
void setAxisHomeOffset(int axis, double d);
-
- /// returns true if the target machine stores toolhead offsets
- boolean hasAcceleration();
- /// Store acceleration settings to eeprom
- void setAccelerationStatus(byte status);
- void setAccelerationRate(int rate);
- /// Read acceleration settings from eeprom
- boolean getAccelerationStatus();
- int getAccelerationRate();
-
/// returns true if the target machine stores toolhead offsets
boolean hasToolheadsOffset();
@@ -182,13 +172,19 @@ public static EstopType estopTypeForValue(byte value) {
int getStoredStepperVoltage(int stepperId);
- boolean hasAccelerationSupport();
+ /// returns true if the target machine stores toolhead offsets
+ boolean hasAcceleration();
+ /// Store acceleration settings to eeprom
+ void setAccelerationStatus(byte status);
+ /// Read acceleration settings from eeprom
+ boolean getAccelerationStatus();
+
Point5d getAxisAccelerationRates();
void setAxisAccelerationRates(Point5d acceleration);
int getMasterAccelerationRate();
void setMasterAccelerationRate(int acceleration);
- boolean checkEepromStepsPerMM();
- void setEepromStepsPerMM();
+ // boolean checkEepromStepsPerMM();
+ // void setEepromStepsPerMM();
Point5d getAxisJunctionJerks();
void setAxisJunctionJerks(Point5d jerks);
double getMinimumPlannerSpeed();
View
226 src/replicatorg/drivers/gen3/MightyBoard.java
@@ -161,14 +161,16 @@
// 50 bytes of free space for expansion
- final public static int EEPROM_STEPS_PER_MM_OFFSET = 0x0194;
- final public static int EEPROM_ACCELERATION_RATE_OFFSET = 0x01A8;
- final public static int EEPROM_AXIS_ACC_RATE_OFFSET = 0x01AC;
- final public static int EEPROM_AXIS_JUNCTION_JERK_OFFSET = 0x01C0;
- final public static int EEPROM_MINIMUM_PLANNER_SPEED_OFFSET = 0x01D0;
+ final public static int ACCELERATION_SETTINGS = 0x016E;
+
+ final public static int EEPROM_ACCELERATION_ACTIVE = ACCELERATION_SETTINGS + 0x000;
+ // final public static int EEPROM_STEPS_PER_MM_OFFSET = ACCELERATION_SETTINGS + ???;
+ final public static int EEPROM_ACCELERATION_RATE_OFFSET = ACCELERATION_SETTINGS + 0x002;
+ final public static int EEPROM_AXIS_ACC_RATE_OFFSET = ACCELERATION_SETTINGS + 0x004;
+ final public static int EEPROM_AXIS_JUNCTION_JERK_OFFSET = ACCELERATION_SETTINGS + 0x00E;
/// start of free space
- final public static int FREE_EEPROM_STARTS = 0x01D1;
+ final public static int FREE_EEPROM_STARTS = 0x0184;
}
@@ -258,7 +260,7 @@ public boolean equals(int pid, int vid){
private int toolCountOnboard = -1; /// no count aka FFFF
Version toolVersion = new Version(0,0);
- Version accelerationVersion = new Version(0,0);
+ Version accelerationVersion = new Version(0,0);
/**
* Standard Constructor
@@ -275,8 +277,7 @@ public MightyBoard() {
// firmware version we want this driver to support.
minimumVersion = new Version(5,2);
preferredVersion = new Version(5,2);
- minimumAccelerationVersion = new Version(9,3);
-
+ minimumAccelerationVersion = new Version(5,3);
}
/**
@@ -326,15 +327,15 @@ public boolean initializeBot()
Base.logger.severe("Please double-check your selected machine.");
}
- boolean stepsPerMMMatched = checkEepromStepsPerMM();
- if (!stepsPerMMMatched) {
- int n = JOptionPane.showConfirmDialog(null, "The motherboard's stored steps/mm settings\ndon't match the selected machine profile.\nWould you like to update the motherboard\nsettings to match the profile and close the connection?\n", "Steps/mm mismatch", JOptionPane.YES_NO_OPTION);
- if (n == JOptionPane.YES_OPTION) {
- setEepromStepsPerMM();
- reset(/*reconnect*/ false);
- return false;
- }
- }
+ // boolean stepsPerMMMatched = checkEepromStepsPerMM();
+ // if (!stepsPerMMMatched) {
+ // int n = JOptionPane.showConfirmDialog(null, "The motherboard's stored steps/mm settings\ndon't match the selected machine profile.\nWould you like to update the motherboard\nsettings to match the profile and close the connection?\n", "Steps/mm mismatch", JOptionPane.YES_NO_OPTION);
+ // if (n == JOptionPane.YES_OPTION) {
+ // setEepromStepsPerMM();
+ // reset(/*reconnect*/ false);
+ // return false;
+ // }
+ // }
// I have no idea why we still do this, we may want to test and refactor away
getSpindleSpeedPWM();
@@ -1026,12 +1027,35 @@ public boolean canVerifyMachine() {
}
- /**
- * Returns true of the current firmware supports acceleration.
- * FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME
- */
@Override
- public boolean hasAccelerationSupport() {
+ // get stored acceleration status: either ON of OFF
+ // acceleration is applied to all moves, except homing when ON
+ public boolean getAccelerationStatus(){
+
+ Base.logger.finest("MightyBoard getAccelerationStatus");
+
+ checkEEPROM();
+
+ byte[] val = readFromEEPROM(MightyBoardEEPROM.ACCELERATION_SETTINGS,1);
+
+ return (val[0] > 0 ? true : false);
+ }
+
+ @Override
+ // set stored acceleration status: either ON of OFF
+ // acceleration is applied to all moves, except homing when ON
+ public void setAccelerationStatus(byte status){
+ Base.logger.info("MightyBoard setAccelerationStatus");
+
+ byte b[] = new byte[1];
+ b[0] = status;
+ writeToEEPROM(MightyBoardEEPROM.ACCELERATION_SETTINGS, b);
+ }
+
+ @Override
+ public boolean hasAcceleration() {
+ if (version.compareTo(getMinimumAccelerationVersion()) < 0)
+ return false;
return true;
}
@@ -1042,24 +1066,10 @@ public boolean hasAccelerationSupport() {
@Override
public Point5d getAxisAccelerationRates() {
checkEEPROM();
- byte[] defaultValue = {
- (byte)0xD0, (byte)0x07, (byte)0x00, (byte)0x00, /* X 2000 */
- (byte)0xD0, (byte)0x07, (byte)0x00, (byte)0x00, /* Y 2000 */
- (byte)0x0A, (byte)0x00, (byte)0x00, (byte)0x00, /* Z 10 */
- (byte)0x88, (byte)0x13, (byte)0x00, (byte)0x00, /* A 5000 */
- (byte)0x88, (byte)0x13, (byte)0x00, (byte)0x00, /* B 5000 */
- };
- byte[] r = readFromEEPROMwithDefault(
- MightyBoardEEPROM.EEPROM_AXIS_ACC_RATE_OFFSET, 20, defaultValue
- );
-
// Point5d stepsPerMM = getMachine().getStepsPerMM();
Point5d acceleration = new Point5d();
for (int axis = 0; axis < 5; axis++) {
- int val = 0;
- for (int i = 0; i < 4; i++) {
- val = val | (((int) r[i+(axis*4)] & 0xff) << 8 * i);
- }
+ int val = read16FromEEPROM(MightyBoardEEPROM.EEPROM_AXIS_ACC_RATE_OFFSET + (axis * 2));
acceleration.set(axis, (double)val);
}
return acceleration;
@@ -1074,7 +1084,7 @@ public void setAxisAccelerationRates(Point5d acceleration) {
// Point5d stepsPerMM = getMachine().getStepsPerMM();
for (int axis = 0; axis < 5; axis++) {
int val = (int)Math.ceil(acceleration.get(axis));
- writeToEEPROM(MightyBoardEEPROM.EEPROM_AXIS_ACC_RATE_OFFSET + (axis * 4), intToLE(val));
+ write16ToEEPROM(MightyBoardEEPROM.EEPROM_AXIS_ACC_RATE_OFFSET + (axis * 2), val);
}
}
@@ -1083,16 +1093,10 @@ public void setAxisAccelerationRates(Point5d acceleration) {
*/
@Override
public int getMasterAccelerationRate() {
+ Base.logger.finest("MightyBoard getMasterAccelerationRate" );
checkEEPROM();
- byte[] defaultValue = {(byte)0xd0, (byte)0x07, (byte)0x00, (byte)0x00, /* 2000 */};
- byte[] r = readFromEEPROMwithDefault(
- MightyBoardEEPROM.EEPROM_ACCELERATION_RATE_OFFSET, 4, defaultValue);
-
- int val = 0;
- for (int i = 0; i < 4; i++) {
- val = val | (((int) r[i] & 0xff) << 8 * i);
- }
+ int val = read16FromEEPROM(MightyBoardEEPROM.EEPROM_ACCELERATION_RATE_OFFSET);
return val;
}
@@ -1102,43 +1106,50 @@ public int getMasterAccelerationRate() {
*/
@Override
public void setMasterAccelerationRate(int acceleration) {
- checkEEPROM();
- writeToEEPROM(MightyBoardEEPROM.EEPROM_ACCELERATION_RATE_OFFSET, intToLE(acceleration));
- }
-
- /**
- * Checks that the StepsPerMM EEPROM settings on the motherboard matches those in the machine profile.
- * StepsPerMM are stored in fixed-point Q16 (top 16 bits are integert, bottom 16 are fractional).
- */
- @Override
- public boolean checkEepromStepsPerMM() {
- checkEEPROM();
- byte[] r = readFromEEPROM(
- MightyBoardEEPROM.EEPROM_STEPS_PER_MM_OFFSET, 20);
-
- Point5d stepsPerMM = getMachine().getStepsPerMM();
- for (int axis = 0; axis < 5; axis++) {
- byte[] check = floatTo32LE((float)stepsPerMM.get(axis));
- for (int i = 0; i < 4; i++) {
- if (r[i+(axis * 4)] != check[i])
- return false;
- }
- }
- return true;
- }
-
- /**
- * Writes the StepsPerMM from the machine profile to the EEPROM settings on the motherboard.
- * StepsPerMM are stored in fixed-point Q16 (top 16 bits are integert, bottom 16 are fractional).
- */
- @Override
- public void setEepromStepsPerMM() {
- Point5d stepsPerMM = getMachine().getStepsPerMM();
- for (int axis = 0; axis < 5; axis++) {
- float val = (float)stepsPerMM.get(axis);
- writeToEEPROM(MightyBoardEEPROM.EEPROM_STEPS_PER_MM_OFFSET + (axis * 4), floatTo32LE(val));
- }
- }
+ Base.logger.finest("MightyBoard setMasterAccelerationRate" );
+
+ // limit rate to 16 bit integer max
+ if(acceleration > 32767)
+ acceleration = 32767;
+ if(acceleration < -32768)
+ acceleration = -32768;
+
+ write16ToEEPROM(MightyBoardEEPROM.EEPROM_ACCELERATION_RATE_OFFSET, acceleration);
+ }
+
+ // /**
+ // * Checks that the StepsPerMM EEPROM settings on the motherboard matches those in the machine profile.
+ // * StepsPerMM are stored in fixed-point Q16 (top 16 bits are integert, bottom 16 are fractional).
+ // */
+ // @Override
+ // public boolean checkEepromStepsPerMM() {
+ // checkEEPROM();
+ // byte[] r = readFromEEPROM(
+ // MightyBoardEEPROM.EEPROM_STEPS_PER_MM_OFFSET, 20);
+ //
+ // Point5d stepsPerMM = getMachine().getStepsPerMM();
+ // for (int axis = 0; axis < 5; axis++) {
+ // byte[] check = floatTo32LE((float)stepsPerMM.get(axis));
+ // for (int i = 0; i < 4; i++) {
+ // if (r[i+(axis * 4)] != check[i])
+ // return false;
+ // }
+ // }
+ // return true;
+ // }
+ //
+ // /**
+ // * Writes the StepsPerMM from the machine profile to the EEPROM settings on the motherboard.
+ // * StepsPerMM are stored in fixed-point Q16 (top 16 bits are integert, bottom 16 are fractional).
+ // */
+ // @Override
+ // public void setEepromStepsPerMM() {
+ // Point5d stepsPerMM = getMachine().getStepsPerMM();
+ // for (int axis = 0; axis < 5; axis++) {
+ // float val = (float)stepsPerMM.get(axis);
+ // writeToEEPROM(MightyBoardEEPROM.EEPROM_STEPS_PER_MM_OFFSET + (axis * 4), floatTo32LE(val));
+ // }
+ // }
/**
* Reads the junction jerk values from the EEPROM settings on the motherboard and returns a Point5d.
@@ -1148,25 +1159,15 @@ public void setEepromStepsPerMM() {
@Override
public Point5d getAxisJunctionJerks() {
checkEEPROM();
- byte[] defaultValue = {
- 0x00, 0x00, 0x08, 0x00, /* X/Y = 8 */
- 0x00, 0x00, 0x08, 0x00, /* Z = 8 */
- 0x00, 0x00, 0x0A, 0x00, /* A = 10 */
- 0x00, 0x00, 0x0A, 0x00, /* A = 10 */
- };
- byte[] r = readFromEEPROMwithDefault(
- MightyBoardEEPROM.EEPROM_AXIS_JUNCTION_JERK_OFFSET, 16, defaultValue
- );
-
- // Point5d stepsPerMM = getMachine().getStepsPerMM();
+ byte[] r = readFromEEPROM(MightyBoardEEPROM.EEPROM_AXIS_JUNCTION_JERK_OFFSET, 8);
Point5d jerks = new Point5d();
int offset = 0;
for (int axis = 0; axis < 5; axis++) {
if (axis == 1)
continue;
- double val = byte32LEToFloat(r, offset);
+ double val = byte16LEToFloat(r, offset);
jerks.set(axis, val);
- offset += 4;
+ offset += 2;
}
return jerks;
}
@@ -1184,34 +1185,11 @@ public void setAxisJunctionJerks(Point5d jerks) {
if (axis == 1)
continue;
double val = jerks.get(axis);
- writeToEEPROM(MightyBoardEEPROM.EEPROM_AXIS_JUNCTION_JERK_OFFSET + (offset * 4), floatTo32LE((float)val));
- offset++;
+ writeToEEPROM(MightyBoardEEPROM.EEPROM_AXIS_JUNCTION_JERK_OFFSET + offset, floatTo16LE((float)val));
+ offset += 2;
}
}
- /**
- * Reads an double that contains the minimum planner speed.
- */
- @Override
- public double getMinimumPlannerSpeed() {
- checkEEPROM();
- byte[] defaultValue = floatTo32LE(4.0f);
- byte[] r = readFromEEPROMwithDefault(
- MightyBoardEEPROM.EEPROM_MINIMUM_PLANNER_SPEED_OFFSET, 4, defaultValue);
-
- double val = byte32LEToFloat(r);
- return val;
- }
-
- /**
- * Writes an double that contains the minimum planner speed to the motherboard EEPROM.
- */
- @Override
- public void setMinimumPlannerSpeed(double minPlannerSpeed) {
- checkEEPROM();
- writeToEEPROM(MightyBoardEEPROM.EEPROM_MINIMUM_PLANNER_SPEED_OFFSET, floatTo32LE((float)minPlannerSpeed));
- }
-
@Override
public boolean setConnectedToolIndex(int index) {
byte[] data = new byte[1];
@@ -1512,7 +1490,7 @@ private void write32ToEEPROM32(int offset, int value ) {
s = s >>> 8;
}
writeToEEPROM(offset,buf);
- }
+ }
/// read a 16 bit int from EEPROM at location 'offset'
private int read16FromEEPROM(int offset)
@@ -1536,7 +1514,7 @@ private void write16ToEEPROM(int offset, int value ) {
s = s >>> 8;
}
writeToEEPROM(offset,buf);
- }
+ }
View
116 src/replicatorg/drivers/gen3/Sanguino3GDriver.java
@@ -190,15 +190,15 @@ public boolean initializeBot()
}
}
- boolean stepsPerMMMatched = checkEepromStepsPerMM();
- if (!stepsPerMMMatched) {
- int n = JOptionPane.showConfirmDialog(null, "The motherboard's stored steps/mm settings\ndon't match the selected machine profile.\nWould you like to update the motherboard\nsettings to match the profile and close the connection?\n", "Steps/mm mismatch", JOptionPane.YES_NO_OPTION);
- if (n == JOptionPane.YES_OPTION) {
- setEepromStepsPerMM();
- reset(/*reconnect*/ false);
- return false;
- }
- }
+ // boolean stepsPerMMMatched = checkEepromStepsPerMM();
+ // if (!stepsPerMMMatched) {
+ // int n = JOptionPane.showConfirmDialog(null, "The motherboard's stored steps/mm settings\ndon't match the selected machine profile.\nWould you like to update the motherboard\nsettings to match the profile and close the connection?\n", "Steps/mm mismatch", JOptionPane.YES_NO_OPTION);
+ // if (n == JOptionPane.YES_OPTION) {
+ // setEepromStepsPerMM();
+ // reset(/*reconnect*/ false);
+ // return false;
+ // }
+ // }
return true;
}
@@ -2290,18 +2290,6 @@ public void eepromStoreToolDelta(int axis, double offset){
}
@Override
- public int getAccelerationRate(){
- Base.logger.info("Cannot get acceleration rate for S3G driver");
- return 0;
- }
-
- @Override
- public void setAccelerationRate(int rate){
- Base.logger.info("Cannot set acceleration rate for S3G driver");
-
- }
-
- @Override
public boolean getAccelerationStatus(){
Base.logger.info("Cannot get acceleration status for S3G driver");
return false;
@@ -2311,10 +2299,7 @@ public boolean getAccelerationStatus(){
public void setAccelerationStatus(byte status){
Base.logger.info("Cannot set acceleration status for S3G driver");
}
-
- @Override
- public boolean hasAcceleration() { return false;}
-
+
public void storeHomePositions(EnumSet<AxisId> axes) throws RetryException {
byte b = 0;
@@ -2376,7 +2361,7 @@ public void recallHomePositions(EnumSet<AxisId> axes) throws RetryException {
* Returns true of the current firmware supports acceleration.
* FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME
*/
- public boolean hasAccelerationSupport() {
+ public boolean hasAcceleration() {
return true;
}
@@ -2446,38 +2431,38 @@ public void setMasterAccelerationRate(int acceleration) {
checkEEPROM();
writeToEEPROM(Sanguino3GEEPRPOM.EEPROM_ACCELERATION_RATE_OFFSET, intToLE(acceleration));
}
-
- /**
- * Checks that the StepsPerMM EEPROM settings on the motherboard matches those in the machine profile.
- * StepsPerMM are stored in fixed-point Q16 (top 16 bits are integert, bottom 16 are fractional).
- */
- public boolean checkEepromStepsPerMM() {
- checkEEPROM();
- byte[] r = readFromEEPROM(
- Sanguino3GEEPRPOM.EEPROM_STEPS_PER_MM_OFFSET, 20);
-
- Point5d stepsPerMM = getMachine().getStepsPerMM();
- for (int axis = 0; axis < 5; axis++) {
- byte[] check = floatTo32LE((float)stepsPerMM.get(axis));
- for (int i = 0; i < 4; i++) {
- if (r[i+(axis * 4)] != check[i])
- return false;
- }
- }
- return true;
- }
-
- /**
- * Writes the StepsPerMM from the machine profile to the EEPROM settings on the motherboard.
- * StepsPerMM are stored in fixed-point Q16 (top 16 bits are integert, bottom 16 are fractional).
- */
- public void setEepromStepsPerMM() {
- Point5d stepsPerMM = getMachine().getStepsPerMM();
- for (int axis = 0; axis < 5; axis++) {
- float val = (float)stepsPerMM.get(axis);
- writeToEEPROM(Sanguino3GEEPRPOM.EEPROM_STEPS_PER_MM_OFFSET + (axis * 4), floatTo32LE(val));
- }
- }
+ //
+ // /**
+ // * Checks that the StepsPerMM EEPROM settings on the motherboard matches those in the machine profile.
+ // * StepsPerMM are stored in fixed-point Q16 (top 16 bits are integert, bottom 16 are fractional).
+ // */
+ // public boolean checkEepromStepsPerMM() {
+ // checkEEPROM();
+ // byte[] r = readFromEEPROM(
+ // Sanguino3GEEPRPOM.EEPROM_STEPS_PER_MM_OFFSET, 20);
+ //
+ // Point5d stepsPerMM = getMachine().getStepsPerMM();
+ // for (int axis = 0; axis < 5; axis++) {
+ // byte[] check = floatTo32LE((float)stepsPerMM.get(axis));
+ // for (int i = 0; i < 4; i++) {
+ // if (r[i+(axis * 4)] != check[i])
+ // return false;
+ // }
+ // }
+ // return true;
+ // }
+ //
+ // /**
+ // * Writes the StepsPerMM from the machine profile to the EEPROM settings on the motherboard.
+ // * StepsPerMM are stored in fixed-point Q16 (top 16 bits are integert, bottom 16 are fractional).
+ // */
+ // public void setEepromStepsPerMM() {
+ // Point5d stepsPerMM = getMachine().getStepsPerMM();
+ // for (int axis = 0; axis < 5; axis++) {
+ // float val = (float)stepsPerMM.get(axis);
+ // writeToEEPROM(Sanguino3GEEPRPOM.EEPROM_STEPS_PER_MM_OFFSET + (axis * 4), floatTo32LE(val));
+ // }
+ // }
/**
* Reads the junction jerk values from the EEPROM settings on the motherboard and returns a Point5d.
@@ -2673,6 +2658,21 @@ protected float byte32LEToFloat(byte[] r) {
return byte32LEToFloat(r, 0);
}
+ // This converts a float to a 32-bit (4-byte), litte-endien array.
+ // 16-bits are used for the integer part, and 16-bits are for the fractional part.
+ protected byte[] floatTo16LE(float f) {
+ double d = f;
+ int q16 = (int)Math.floor(d * 255.0);
+ return intToLE(q16, 2);
+ }
+
+ protected float byte16LEToFloat(byte[] r, int offset) {
+ return (float)(byteToInt(r[offset+1]) | byteToInt(r[offset])<<8)/255.0f;
+ }
+ protected float byte16LEToFloat(byte[] r) {
+ return byte16LEToFloat(r, 0);
+ }
+
protected byte[] intToLE(int s) {
return intToLE(s, 4);
}

0 comments on commit c6cfc17

Please sign in to comment.
Something went wrong with that request. Please try again.