Fix debug sprintf variant
parent
5cf4a496e3
commit
b13214b7f5
|
|
@ -5,6 +5,7 @@
|
||||||
#include "hal/usart.h"
|
#include "hal/usart.h"
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
namespace debug {
|
namespace debug {
|
||||||
|
|
@ -21,21 +22,21 @@ const char modules[] PROGMEM = "mod:";
|
||||||
const char hal[] PROGMEM = "hal:";
|
const char hal[] PROGMEM = "hal:";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void dbg_usart(const char *layer_P, const char *s) {
|
void __attribute__((noinline)) dbg_usart(const char *layer_P, const char *s) {
|
||||||
hu::usart1.WriteS_P(layer_P);
|
hu::usart1.WriteS_P(layer_P);
|
||||||
hu::usart1.puts(s);
|
hu::usart1.puts(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dbg_usart_P(const char *layer_P, const char *s_P) {
|
void __attribute__((noinline)) dbg_usart_P(const char *layer_P, const char *s_P) {
|
||||||
hu::usart1.WriteS_P(layer_P);
|
hu::usart1.WriteS_P(layer_P);
|
||||||
hu::usart1.puts_P(s_P);
|
hu::usart1.puts_P(s_P);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dbg_usart_sprintf_P(const char *fmt_P, ...) {
|
void __attribute__((noinline)) dbg_usart_sprintf_P(const char *fmt_P, ...) {
|
||||||
char tmp[30];
|
char tmp[30];
|
||||||
va_list argptr;
|
va_list argptr;
|
||||||
va_start(argptr, fmt_P);
|
va_start(argptr, fmt_P);
|
||||||
vsprintf(tmp, fmt_P, argptr);
|
vsnprintf_P(tmp, 30, fmt_P, argptr);
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
dbg_logic(tmp);
|
dbg_logic(tmp);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ bool FeedToBondtech::Step() {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case EngagingIdler:
|
case EngagingIdler:
|
||||||
if (mi::idler.Engaged()) {
|
if (mi::idler.Engaged()) {
|
||||||
dbg_logic_sprintf_P(PSTR("\nPulley start steps %u\n\n"), mm::motion.CurPosition(mm::Pulley));
|
dbg_logic_sprintf_P(PSTR("Pulley start steps %u"), mm::motion.CurPosition(mm::Pulley));
|
||||||
state = PushingFilament;
|
state = PushingFilament;
|
||||||
mm::motion.InitAxis(mm::Pulley);
|
mm::motion.InitAxis(mm::Pulley);
|
||||||
mm::motion.PlanMove<mm::Pulley>(config::defaultBowdenLength, config::pulleyFeedrate); //@@TODO constants - there was some strange acceleration sequence in the original FW,
|
mm::motion.PlanMove<mm::Pulley>(config::defaultBowdenLength, config::pulleyFeedrate); //@@TODO constants - there was some strange acceleration sequence in the original FW,
|
||||||
|
|
@ -30,7 +30,7 @@ bool FeedToBondtech::Step() {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
case PushingFilament:
|
case PushingFilament:
|
||||||
dbg_logic_P(PSTR("\nFeed to Bondtech --> Pushing\n\n"));
|
dbg_logic_P(PSTR("Feed to Bondtech --> Pushing"));
|
||||||
if (mfs::fsensor.Pressed()) {
|
if (mfs::fsensor.Pressed()) {
|
||||||
mm::motion.AbortPlannedMoves(); // stop pushing filament
|
mm::motion.AbortPlannedMoves(); // stop pushing filament
|
||||||
mi::idler.Disengage();
|
mi::idler.Disengage();
|
||||||
|
|
@ -43,7 +43,7 @@ bool FeedToBondtech::Step() {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
case DisengagingIdler:
|
case DisengagingIdler:
|
||||||
dbg_logic_P(PSTR("\nFeed to Bondtech --> DisengagingIdler\n\n"));
|
dbg_logic_P(PSTR("Feed to Bondtech --> DisengagingIdler"));
|
||||||
if (!mi::idler.Engaged()) {
|
if (!mi::idler.Engaged()) {
|
||||||
state = OK;
|
state = OK;
|
||||||
mm::motion.Disable(mm::Pulley);
|
mm::motion.Disable(mm::Pulley);
|
||||||
|
|
@ -51,9 +51,9 @@ bool FeedToBondtech::Step() {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
case OK:
|
case OK:
|
||||||
dbg_logic_P(PSTR("\nFeed to Bondtech\n\n"));
|
dbg_logic_P(PSTR("Feed to Bondtech"));
|
||||||
case Failed:
|
case Failed:
|
||||||
dbg_logic_P(PSTR("\nFeed to Bondtech FAILED\n\n"));
|
dbg_logic_P(PSTR("Feed to Bondtech FAILED"));
|
||||||
default:
|
default:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ void LoadFilament::Reset(uint8_t param) {
|
||||||
if (!CheckToolIndex(param)) {
|
if (!CheckToolIndex(param)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dbg_logic_P(PSTR("Load Filament\n\n"));
|
dbg_logic_P(PSTR("Load Filament"));
|
||||||
state = ProgressCode::EngagingIdler;
|
state = ProgressCode::EngagingIdler;
|
||||||
error = ErrorCode::RUNNING;
|
error = ErrorCode::RUNNING;
|
||||||
mg::globals.SetActiveSlot(param);
|
mg::globals.SetActiveSlot(param);
|
||||||
|
|
|
||||||
|
|
@ -30,13 +30,13 @@ void ToolChange::Reset(uint8_t param) {
|
||||||
plannedSlot = param;
|
plannedSlot = param;
|
||||||
|
|
||||||
if (mg::globals.FilamentLoaded()) {
|
if (mg::globals.FilamentLoaded()) {
|
||||||
dbg_logic_P(PSTR("Filament is loaded --> unload\n"));
|
dbg_logic_P(PSTR("Filament is loaded --> unload"));
|
||||||
state = ProgressCode::UnloadingFilament;
|
state = ProgressCode::UnloadingFilament;
|
||||||
unl.Reset(mg::globals.ActiveSlot());
|
unl.Reset(mg::globals.ActiveSlot());
|
||||||
} else {
|
} else {
|
||||||
state = ProgressCode::FeedingToFinda;
|
state = ProgressCode::FeedingToFinda;
|
||||||
error = ErrorCode::RUNNING;
|
error = ErrorCode::RUNNING;
|
||||||
dbg_logic_P(PSTR("Filament is not loaded --> load\n"));
|
dbg_logic_P(PSTR("Filament is not loaded --> load"));
|
||||||
mg::globals.SetActiveSlot(plannedSlot);
|
mg::globals.SetActiveSlot(plannedSlot);
|
||||||
feed.Reset(true);
|
feed.Reset(true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,24 +12,24 @@ Idler idler;
|
||||||
|
|
||||||
void Idler::PrepareMoveToPlannedSlot() {
|
void Idler::PrepareMoveToPlannedSlot() {
|
||||||
mm::motion.PlanMoveTo<mm::Idler>(SlotPosition(plannedSlot), mm::unitToAxisUnit<mm::I_speed_t>(config::idlerFeedrate));
|
mm::motion.PlanMoveTo<mm::Idler>(SlotPosition(plannedSlot), mm::unitToAxisUnit<mm::I_speed_t>(config::idlerFeedrate));
|
||||||
dbg_logic_sprintf_P(PSTR("Prepare Move Idler slot %d\n"), plannedSlot);
|
dbg_logic_sprintf_P(PSTR("Prepare Move Idler slot %d"), plannedSlot);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Idler::PlanHomingMove() {
|
void Idler::PlanHomingMove() {
|
||||||
mm::motion.PlanMove<mm::Idler>(mm::unitToAxisUnit<mm::I_pos_t>(-config::idlerLimits.lenght * 2), mm::unitToAxisUnit<mm::I_speed_t>(config::idlerFeedrate));
|
mm::motion.PlanMove<mm::Idler>(mm::unitToAxisUnit<mm::I_pos_t>(-config::idlerLimits.lenght * 2), mm::unitToAxisUnit<mm::I_speed_t>(config::idlerFeedrate));
|
||||||
dbg_logic_P(PSTR("Plan Homing Idler\n"));
|
dbg_logic_P(PSTR("Plan Homing Idler"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Idler::OperationResult Idler::Disengage() {
|
Idler::OperationResult Idler::Disengage() {
|
||||||
if (state == Moving) {
|
if (state == Moving) {
|
||||||
dbg_logic_P(PSTR("Moving --> Disengage refused\n"));
|
dbg_logic_P(PSTR("Moving --> Disengage refused"));
|
||||||
return OperationResult::Refused;
|
return OperationResult::Refused;
|
||||||
}
|
}
|
||||||
plannedSlot = IdleSlotIndex();
|
plannedSlot = IdleSlotIndex();
|
||||||
plannedEngage = false;
|
plannedEngage = false;
|
||||||
|
|
||||||
if (!Engaged()) {
|
if (!Engaged()) {
|
||||||
dbg_logic_P(PSTR("Disengage Idler\n"));
|
dbg_logic_P(PSTR("Disengage Idler"));
|
||||||
return OperationResult::Accepted;
|
return OperationResult::Accepted;
|
||||||
}
|
}
|
||||||
return InitMovement(mm::Idler);
|
return InitMovement(mm::Idler);
|
||||||
|
|
@ -37,7 +37,7 @@ Idler::OperationResult Idler::Disengage() {
|
||||||
|
|
||||||
Idler::OperationResult Idler::Engage(uint8_t slot) {
|
Idler::OperationResult Idler::Engage(uint8_t slot) {
|
||||||
if (state == Moving) {
|
if (state == Moving) {
|
||||||
dbg_logic_P(PSTR("Moving --> Engage refused\n"));
|
dbg_logic_P(PSTR("Moving --> Engage refused"));
|
||||||
return OperationResult::Refused;
|
return OperationResult::Refused;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -45,7 +45,7 @@ Idler::OperationResult Idler::Engage(uint8_t slot) {
|
||||||
plannedEngage = true;
|
plannedEngage = true;
|
||||||
|
|
||||||
if (Engaged()) {
|
if (Engaged()) {
|
||||||
dbg_logic_P(PSTR("Engage Idler\n"));
|
dbg_logic_P(PSTR("Engage Idler"));
|
||||||
return OperationResult::Accepted;
|
return OperationResult::Accepted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -63,15 +63,15 @@ bool Idler::Home() {
|
||||||
bool Idler::Step() {
|
bool Idler::Step() {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case Moving:
|
case Moving:
|
||||||
// dbg_logic_P(PSTR("Moving Idler\n"));
|
// dbg_logic_P(PSTR("Moving Idler"));
|
||||||
PerformMove(mm::Idler);
|
PerformMove(mm::Idler);
|
||||||
return false;
|
return false;
|
||||||
case Homing:
|
case Homing:
|
||||||
dbg_logic_P(PSTR("Homing Idler\n"));
|
dbg_logic_P(PSTR("Homing Idler"));
|
||||||
PerformHome(mm::Idler);
|
PerformHome(mm::Idler);
|
||||||
return false;
|
return false;
|
||||||
case Ready:
|
case Ready:
|
||||||
// dbg_logic_P(PSTR("Idler Ready\n"));
|
// dbg_logic_P(PSTR("Idler Ready"));
|
||||||
currentlyEngaged = plannedEngage;
|
currentlyEngaged = plannedEngage;
|
||||||
currentSlot = plannedSlot;
|
currentSlot = plannedSlot;
|
||||||
|
|
||||||
|
|
@ -80,7 +80,7 @@ bool Idler::Step() {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
case Failed:
|
case Failed:
|
||||||
dbg_logic_P(PSTR("Idler Failed\n"));
|
dbg_logic_P(PSTR("Idler Failed"));
|
||||||
default:
|
default:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ void Motion::StallGuardReset(Axis axis) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Motion::PlanMoveTo(Axis axis, pos_t pos, steps_t feed_rate, steps_t end_rate) {
|
void Motion::PlanMoveTo(Axis axis, pos_t pos, steps_t feed_rate, steps_t end_rate) {
|
||||||
dbg_logic_sprintf_P(PSTR("Move axis %d to %u\n"), axis, pos);
|
dbg_logic_sprintf_P(PSTR("Move axis %d to %u"), axis, pos);
|
||||||
|
|
||||||
if (axisData[axis].ctrl.PlanMoveTo(pos, feed_rate, end_rate)) {
|
if (axisData[axis].ctrl.PlanMoveTo(pos, feed_rate, end_rate)) {
|
||||||
// move was queued, prepare the axis
|
// move was queued, prepare the axis
|
||||||
|
|
|
||||||
|
|
@ -12,23 +12,23 @@ Selector selector;
|
||||||
|
|
||||||
void Selector::PrepareMoveToPlannedSlot() {
|
void Selector::PrepareMoveToPlannedSlot() {
|
||||||
mm::motion.PlanMoveTo<mm::Selector>(SlotPosition(plannedSlot), mm::unitToAxisUnit<mm::S_speed_t>(config::selectorFeedrate));
|
mm::motion.PlanMoveTo<mm::Selector>(SlotPosition(plannedSlot), mm::unitToAxisUnit<mm::S_speed_t>(config::selectorFeedrate));
|
||||||
dbg_logic_sprintf_P(PSTR("Prepare Move Selector slot %d\n"), plannedSlot);
|
dbg_logic_sprintf_P(PSTR("Prepare Move Selector slot %d"), plannedSlot);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Selector::PlanHomingMove() {
|
void Selector::PlanHomingMove() {
|
||||||
mm::motion.PlanMove<mm::Selector>(mm::unitToAxisUnit<mm::S_pos_t>(config::selectorLimits.lenght * 2), mm::unitToAxisUnit<mm::S_speed_t>(config::selectorFeedrate));
|
mm::motion.PlanMove<mm::Selector>(mm::unitToAxisUnit<mm::S_pos_t>(config::selectorLimits.lenght * 2), mm::unitToAxisUnit<mm::S_speed_t>(config::selectorFeedrate));
|
||||||
dbg_logic_P(PSTR("Plan Homing Selector\n"));
|
dbg_logic_P(PSTR("Plan Homing Selector"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Selector::OperationResult Selector::MoveToSlot(uint8_t slot) {
|
Selector::OperationResult Selector::MoveToSlot(uint8_t slot) {
|
||||||
if (state == Moving) {
|
if (state == Moving) {
|
||||||
dbg_logic_P(PSTR("Moving --> Selector refused\n"));
|
dbg_logic_P(PSTR("Moving --> Selector refused"));
|
||||||
return OperationResult::Refused;
|
return OperationResult::Refused;
|
||||||
}
|
}
|
||||||
plannedSlot = slot;
|
plannedSlot = slot;
|
||||||
|
|
||||||
if (currentSlot == slot) {
|
if (currentSlot == slot) {
|
||||||
dbg_logic_P(PSTR("Moving Selector\n"));
|
dbg_logic_P(PSTR("Moving Selector"));
|
||||||
return OperationResult::Accepted;
|
return OperationResult::Accepted;
|
||||||
}
|
}
|
||||||
return InitMovement(mm::Selector);
|
return InitMovement(mm::Selector);
|
||||||
|
|
@ -45,19 +45,19 @@ bool Selector::Step() {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case Moving:
|
case Moving:
|
||||||
PerformMove(mm::Selector);
|
PerformMove(mm::Selector);
|
||||||
//dbg_logic_P(PSTR("Moving Selector\n"));
|
//dbg_logic_P(PSTR("Moving Selector"));
|
||||||
return false;
|
return false;
|
||||||
case Homing:
|
case Homing:
|
||||||
dbg_logic_P(PSTR("Homing Selector\n"));
|
dbg_logic_P(PSTR("Homing Selector"));
|
||||||
PerformHome(mm::Selector);
|
PerformHome(mm::Selector);
|
||||||
return false;
|
return false;
|
||||||
case Ready:
|
case Ready:
|
||||||
//dbg_logic_P(PSTR("Selector Ready\n"));
|
//dbg_logic_P(PSTR("Selector Ready"));
|
||||||
currentSlot = plannedSlot;
|
currentSlot = plannedSlot;
|
||||||
mm::motion.Disable(mm::Selector); // turn off selector motor's power every time
|
mm::motion.Disable(mm::Selector); // turn off selector motor's power every time
|
||||||
return true;
|
return true;
|
||||||
case Failed:
|
case Failed:
|
||||||
dbg_logic_P(PSTR("Selector Failed\n"));
|
dbg_logic_P(PSTR("Selector Failed"));
|
||||||
default:
|
default:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue