Merge branch 'main' into motion_units
commit
dc36afb82c
|
|
@ -190,6 +190,11 @@ void ReportVersion(const mp::RequestMsg &rq) {
|
||||||
case 2:
|
case 2:
|
||||||
v = project_version_revision;
|
v = project_version_revision;
|
||||||
break;
|
break;
|
||||||
|
case 3:
|
||||||
|
// @@TODO may be allow reporting uint16_t number of errors,
|
||||||
|
// but anything beyond 255 errors means there is something seriously wrong with the MMU
|
||||||
|
v = mg::globals.DriveErrors();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
v = 0;
|
v = 0;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ Buttons buttons;
|
||||||
int8_t Buttons::DecodeADC(uint16_t rawADC) {
|
int8_t Buttons::DecodeADC(uint16_t rawADC) {
|
||||||
// decode 3 buttons' levels from one ADC
|
// decode 3 buttons' levels from one ADC
|
||||||
// Button 1 - 0
|
// Button 1 - 0
|
||||||
// Button 2 - 344
|
// Button 2 - 90
|
||||||
// Button 3 - 516
|
// Button 3 - 170
|
||||||
// Doesn't handle multiple pressed buttons at once
|
// Doesn't handle multiple pressed buttons at once
|
||||||
|
|
||||||
for (int8_t buttonIndex = 0; buttonIndex < config::buttonCount; ++buttonIndex) {
|
for (int8_t buttonIndex = 0; buttonIndex < config::buttonCount; ++buttonIndex) {
|
||||||
|
|
|
||||||
|
|
@ -28,5 +28,13 @@ void Globals::SetFilamentLoaded(bool newFilamentLoaded) {
|
||||||
filamentLoaded = newFilamentLoaded;
|
filamentLoaded = newFilamentLoaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t Globals::DriveErrors() const {
|
||||||
|
return modules::permanent_storage::DriveError::get();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Globals::IncDriveErrors() {
|
||||||
|
modules::permanent_storage::DriveError::increment();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace globals
|
} // namespace globals
|
||||||
} // namespace modules
|
} // namespace modules
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,13 @@ public:
|
||||||
/// @param newFilamentLoaded new state
|
/// @param newFilamentLoaded new state
|
||||||
void SetFilamentLoaded(bool newFilamentLoaded);
|
void SetFilamentLoaded(bool newFilamentLoaded);
|
||||||
|
|
||||||
|
/// @returns the total number of MMU errors so far
|
||||||
|
/// Errors are stored in the EEPROM
|
||||||
|
uint16_t DriveErrors() const;
|
||||||
|
|
||||||
|
/// Increment MMU errors by 1
|
||||||
|
void IncDriveErrors();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t activeSlot;
|
uint8_t activeSlot;
|
||||||
bool filamentLoaded;
|
bool filamentLoaded;
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ st_timer_t Motion::Step() {
|
||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ISR() {}
|
void Isr() {}
|
||||||
|
|
||||||
} // namespace motion
|
} // namespace motion
|
||||||
} // namespace modules
|
} // namespace modules
|
||||||
|
|
|
||||||
|
|
@ -248,7 +248,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
/// ISR stepping routine
|
/// ISR stepping routine
|
||||||
//extern void ISR();
|
//extern void Isr();
|
||||||
|
|
||||||
extern Motion motion;
|
extern Motion motion;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,11 +51,11 @@ DecodeStatus Protocol::DecodeRequest(uint8_t c) {
|
||||||
return DecodeStatus::Error;
|
return DecodeStatus::Error;
|
||||||
}
|
}
|
||||||
case RequestStates::Value:
|
case RequestStates::Value:
|
||||||
if (c >= '0' && c <= '9') {
|
if (IsDigit(c)) {
|
||||||
requestMsg.value *= 10;
|
requestMsg.value *= 10;
|
||||||
requestMsg.value += c - '0';
|
requestMsg.value += c - '0';
|
||||||
return DecodeStatus::NeedMoreData;
|
return DecodeStatus::NeedMoreData;
|
||||||
} else if (c == '\n') {
|
} else if (IsNewLine(c)) {
|
||||||
rqState = RequestStates::Code;
|
rqState = RequestStates::Code;
|
||||||
return DecodeStatus::MessageCompleted;
|
return DecodeStatus::MessageCompleted;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -64,7 +64,7 @@ DecodeStatus Protocol::DecodeRequest(uint8_t c) {
|
||||||
return DecodeStatus::Error;
|
return DecodeStatus::Error;
|
||||||
}
|
}
|
||||||
default: //case error:
|
default: //case error:
|
||||||
if (c == '\n') {
|
if (IsNewLine(c)) {
|
||||||
rqState = RequestStates::Code;
|
rqState = RequestStates::Code;
|
||||||
return DecodeStatus::MessageCompleted;
|
return DecodeStatus::MessageCompleted;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -107,7 +107,7 @@ DecodeStatus Protocol::DecodeResponse(uint8_t c) {
|
||||||
return DecodeStatus::Error;
|
return DecodeStatus::Error;
|
||||||
}
|
}
|
||||||
case ResponseStates::RequestValue:
|
case ResponseStates::RequestValue:
|
||||||
if (c >= '0' && c <= '9') {
|
if (IsDigit(c)) {
|
||||||
responseMsg.request.value *= 10;
|
responseMsg.request.value *= 10;
|
||||||
responseMsg.request.value += c - '0';
|
responseMsg.request.value += c - '0';
|
||||||
return DecodeStatus::NeedMoreData;
|
return DecodeStatus::NeedMoreData;
|
||||||
|
|
@ -135,11 +135,11 @@ DecodeStatus Protocol::DecodeResponse(uint8_t c) {
|
||||||
return DecodeStatus::Error;
|
return DecodeStatus::Error;
|
||||||
}
|
}
|
||||||
case ResponseStates::ParamValue:
|
case ResponseStates::ParamValue:
|
||||||
if (c >= '0' && c <= '9') {
|
if (IsDigit(c)) {
|
||||||
responseMsg.paramValue *= 10;
|
responseMsg.paramValue *= 10;
|
||||||
responseMsg.paramValue += c - '0';
|
responseMsg.paramValue += c - '0';
|
||||||
return DecodeStatus::NeedMoreData;
|
return DecodeStatus::NeedMoreData;
|
||||||
} else if (c == '\n') {
|
} else if (IsNewLine(c)) {
|
||||||
rspState = ResponseStates::RequestCode;
|
rspState = ResponseStates::RequestCode;
|
||||||
return DecodeStatus::MessageCompleted;
|
return DecodeStatus::MessageCompleted;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -148,7 +148,7 @@ DecodeStatus Protocol::DecodeResponse(uint8_t c) {
|
||||||
return DecodeStatus::Error;
|
return DecodeStatus::Error;
|
||||||
}
|
}
|
||||||
default: //case error:
|
default: //case error:
|
||||||
if (c == '\n') {
|
if (IsNewLine(c)) {
|
||||||
rspState = ResponseStates::RequestCode;
|
rspState = ResponseStates::RequestCode;
|
||||||
return DecodeStatus::MessageCompleted;
|
return DecodeStatus::MessageCompleted;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,13 @@ private:
|
||||||
|
|
||||||
ResponseStates rspState;
|
ResponseStates rspState;
|
||||||
ResponseMsg responseMsg;
|
ResponseMsg responseMsg;
|
||||||
|
|
||||||
|
static bool IsNewLine(uint8_t c) {
|
||||||
|
return c == '\n' || c == '\r';
|
||||||
|
}
|
||||||
|
static bool IsDigit(uint8_t c) {
|
||||||
|
return c >= '0' && c <= '9';
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace protocol
|
} // namespace protocol
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ Timebase timebase;
|
||||||
void Timebase::Init() {
|
void Timebase::Init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Timebase::ISR() {
|
void Timebase::Isr() {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t Timebase::Millis() const {
|
uint16_t Timebase::Millis() const {
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint16_t ms;
|
uint16_t ms;
|
||||||
static void ISR();
|
static void Isr();
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The one and only instance of Selector in the FW
|
/// The one and only instance of Selector in the FW
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ uint16_t millis = 0;
|
||||||
|
|
||||||
void Timebase::Init() {}
|
void Timebase::Init() {}
|
||||||
|
|
||||||
void Timebase::ISR() {}
|
void Timebase::Isr() {}
|
||||||
|
|
||||||
uint16_t Timebase::Millis() const {
|
uint16_t Timebase::Millis() const {
|
||||||
return millis;
|
return millis;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue