Add cutLength register (0x23)
parent
ce0df08b89
commit
907510f584
|
|
@ -94,7 +94,7 @@ bool CutFilament::StepInner() {
|
||||||
case ProgressCode::PreparingBlade:
|
case ProgressCode::PreparingBlade:
|
||||||
if (ms::selector.Slot() == cutSlot + 1) {
|
if (ms::selector.Slot() == cutSlot + 1) {
|
||||||
state = ProgressCode::PushingFilament;
|
state = ProgressCode::PushingFilament;
|
||||||
mpu::pulley.PlanMove(config::cutLength + config::cuttingEdgeRetract, config::pulleySlowFeedrate);
|
mpu::pulley.PlanMove(mg::globals.CutLength() + config::cuttingEdgeRetract, config::pulleySlowFeedrate);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ProgressCode::PushingFilament:
|
case ProgressCode::PushingFilament:
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ void Globals::Init() {
|
||||||
ResetIdlerHomingFeedrate();
|
ResetIdlerHomingFeedrate();
|
||||||
|
|
||||||
ResetCutIRunCurrent();
|
ResetCutIRunCurrent();
|
||||||
|
ResetCutLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Globals::ActiveSlot() const {
|
uint8_t Globals::ActiveSlot() const {
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,10 @@ public:
|
||||||
void ResetCutIRunCurrent() { cutIRunCurrent = config::selectorCutIRun; }
|
void ResetCutIRunCurrent() { cutIRunCurrent = config::selectorCutIRun; }
|
||||||
void SetCutIRunCurrent(uint8_t v) { cutIRunCurrent = v; }
|
void SetCutIRunCurrent(uint8_t v) { cutIRunCurrent = v; }
|
||||||
|
|
||||||
|
config::U_mm CutLength() const { return config::U_mm({ (long double)cutLength_mm }); }
|
||||||
|
void ResetCutLength() { cutLength_mm = config::cutLength.v; }
|
||||||
|
void SetCutLength(uint8_t v) { cutLength_mm = v; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Sets the active slot, usually after some command/operation.
|
/// Sets the active slot, usually after some command/operation.
|
||||||
/// Also updates the EEPROM records accordingly
|
/// Also updates the EEPROM records accordingly
|
||||||
|
|
@ -132,6 +136,7 @@ private:
|
||||||
uint16_t idlerHomingFeedrate_deg_s;
|
uint16_t idlerHomingFeedrate_deg_s;
|
||||||
|
|
||||||
uint8_t cutIRunCurrent;
|
uint8_t cutIRunCurrent;
|
||||||
|
uint8_t cutLength_mm;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The one and only instance of global state variables
|
/// The one and only instance of global state variables
|
||||||
|
|
|
||||||
|
|
@ -166,6 +166,7 @@
|
||||||
| 0x20h 32 | uint16 | Set/Get Idler iRun current | 0-31 | 1fh 31 | 31->530mA: see TMC2130 current conversion| Read / Write | M707 A0x20 | M708 A0x20 Xn
|
| 0x20h 32 | uint16 | Set/Get Idler iRun current | 0-31 | 1fh 31 | 31->530mA: see TMC2130 current conversion| Read / Write | M707 A0x20 | M708 A0x20 Xn
|
||||||
| 0x21h 33 | uint16 | Reserved for internal use | 225 | | N/A | N/A | N/A | N/A
|
| 0x21h 33 | uint16 | Reserved for internal use | 225 | | N/A | N/A | N/A | N/A
|
||||||
| 0x22h 34 | uint16 | Bowden length | 341-1000 | 168h 360 | unit mm | Read / Write Persistent | M707 A0x22 | M708 A0x22 Xn
|
| 0x22h 34 | uint16 | Bowden length | 341-1000 | 168h 360 | unit mm | Read / Write Persistent | M707 A0x22 | M708 A0x22 Xn
|
||||||
|
| 0x23h 35 | uint8 | Cut length | 0-255 | 8 | unit mm | Read / Write | M707 A0x23 | M708 A0x23 Xn
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct __attribute__((packed)) RegisterFlags {
|
struct __attribute__((packed)) RegisterFlags {
|
||||||
|
|
@ -437,10 +438,16 @@ static const RegisterRec registers[] PROGMEM = {
|
||||||
[]() -> uint16_t { return mps::BowdenLength::Get(); },
|
[]() -> uint16_t { return mps::BowdenLength::Get(); },
|
||||||
[](uint16_t d) { mps::BowdenLength::Set(d); },
|
[](uint16_t d) { mps::BowdenLength::Set(d); },
|
||||||
2),
|
2),
|
||||||
|
|
||||||
|
// 0x23 Cut length
|
||||||
|
RegisterRec(
|
||||||
|
[]() -> uint16_t { return mg::globals.CutLength().v; },
|
||||||
|
[](uint16_t d) { mg::globals.SetCutLength(d); },
|
||||||
|
2),
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr uint8_t registersSize = sizeof(registers) / sizeof(RegisterRec);
|
static constexpr uint8_t registersSize = sizeof(registers) / sizeof(RegisterRec);
|
||||||
static_assert(registersSize == 35);
|
static_assert(registersSize == 36);
|
||||||
|
|
||||||
bool ReadRegister(uint8_t address, uint16_t &value) {
|
bool ReadRegister(uint8_t address, uint16_t &value) {
|
||||||
if (address >= registersSize) {
|
if (address >= registersSize) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue