Add register for FSensorToNozzleFeedrate

pull/178/head
D.R.racer 2022-06-17 13:41:49 +02:00
parent 2b37573a1d
commit 1044990d74
4 changed files with 43 additions and 1 deletions

View File

@ -24,7 +24,9 @@ void logic::FeedToBondtech::GoToPushToNozzle() {
mg::globals.SetFilamentLoaded(mg::globals.ActiveSlot(), mg::FilamentLoadState::InFSensor); mg::globals.SetFilamentLoaded(mg::globals.ActiveSlot(), mg::FilamentLoadState::InFSensor);
// plan a slow move to help push filament into the nozzle // plan a slow move to help push filament into the nozzle
//@@TODO the speed in mm/s must correspond to printer's feeding speed! //@@TODO the speed in mm/s must correspond to printer's feeding speed!
mpu::pulley.PlanMove(config::fsensorToNozzle, config::pulleySlowFeedrate); mpu::pulley.PlanMove(
config::U_mm({ (long double)mg::globals.FSensorToNozzleMM() }),
config::U_mm_s({ (long double)mg::globals.FSensorToNozzleFeedrate() }));
state = PushingFilamentIntoNozzle; state = PushingFilamentIntoNozzle;
} }

View File

@ -20,6 +20,9 @@ void Globals::Init() {
// the filament is not present in the selector - we can move the selector freely // the filament is not present in the selector - we can move the selector freely
filamentLoaded = FilamentLoadState::AtPulley; filamentLoaded = FilamentLoadState::AtPulley;
} }
ResetFSensorToNozzleMM();
ResetFSensorToNozzleFeedrate();
} }
uint8_t Globals::ActiveSlot() const { uint8_t Globals::ActiveSlot() const {
@ -65,5 +68,13 @@ void Globals::SetMotorsMode(bool stealth) {
// @@TODO store into EEPROM // @@TODO store into EEPROM
} }
void Globals::ResetFSensorToNozzleMM() {
fsensorToNozzleMM = config::fsensorToNozzle.v;
}
void Globals::ResetFSensorToNozzleFeedrate() {
fsensorToNozzleFeedrate = config::pulleySlowFeedrate.v;
}
} // namespace globals } // namespace globals
} // namespace modules } // namespace modules

View File

@ -61,6 +61,14 @@ public:
/// @returns true if the motors are to be operated in stealth mode /// @returns true if the motors are to be operated in stealth mode
bool MotorsStealth() const { return stealthMode; } bool MotorsStealth() const { return stealthMode; }
uint8_t FSensorToNozzleMM() const { return fsensorToNozzleMM; }
void ResetFSensorToNozzleMM();
void SetFSensorToNozzleMM(uint8_t fss2NozzleMM) { fsensorToNozzleMM = fss2NozzleMM; }
uint8_t FSensorToNozzleFeedrate() const { return fsensorToNozzleFeedrate; }
void ResetFSensorToNozzleFeedrate();
void SetFSensorToNozzleFeedrate(uint8_t fs2NozzleFeedrate) { fsensorToNozzleFeedrate = fs2NozzleFeedrate; }
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
@ -70,6 +78,8 @@ private:
uint8_t activeSlot; uint8_t activeSlot;
FilamentLoadState filamentLoaded; FilamentLoadState filamentLoaded;
bool stealthMode; bool stealthMode;
uint8_t fsensorToNozzleMM;
uint8_t fsensorToNozzleFeedrate;
}; };
/// The one and only instance of global state variables /// The one and only instance of global state variables

View File

@ -1,4 +1,8 @@
#ifndef UNITTEST
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#else
#define PROGMEM /* */
#endif
#include "registers.h" #include "registers.h"
#include "version.h" #include "version.h"
@ -95,6 +99,21 @@ static const RegisterRec registers[] PROGMEM = {
1), 1),
RegisterRec([]() -> uint16_t { return mg::globals.MotorsStealth(); }, 1), // mode (stealth = 1/normal = 0) RegisterRec([]() -> uint16_t { return mg::globals.MotorsStealth(); }, 1), // mode (stealth = 1/normal = 0)
RegisterRec( // extra load distance after fsensor triggered (30mm default)
[]() -> uint16_t { return mg::globals.FSensorToNozzleMM(); },
[](uint16_t d) { mg::globals.SetFSensorToNozzleMM(d); },
1),
// The lambas seem to be pretty cheap:
// void SetFSensorToNozzleFeedrate(uint8_t fs2NozzleFeedrate) { fsensorToNozzleFeedrate = fs2NozzleFeedrate; }
// compiles to:
// sts <modules::globals::globals+0x4>, r24
// ret
RegisterRec( // extra load distance after fsensor triggered - feedrate (20mm/s default)
[]() -> uint16_t { return mg::globals.FSensorToNozzleFeedrate(); },
[](uint16_t d) { mg::globals.SetFSensorToNozzleFeedrate(d); },
1),
}; };
static constexpr uint8_t registersSize = sizeof(registers) / sizeof(RegisterRec); static constexpr uint8_t registersSize = sizeof(registers) / sizeof(RegisterRec);