Merge branch 'main' into motion_units
commit
dc36afb82c
|
|
@ -190,6 +190,11 @@ void ReportVersion(const mp::RequestMsg &rq) {
|
|||
case 2:
|
||||
v = project_version_revision;
|
||||
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:
|
||||
v = 0;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ Buttons buttons;
|
|||
int8_t Buttons::DecodeADC(uint16_t rawADC) {
|
||||
// decode 3 buttons' levels from one ADC
|
||||
// Button 1 - 0
|
||||
// Button 2 - 344
|
||||
// Button 3 - 516
|
||||
// Button 2 - 90
|
||||
// Button 3 - 170
|
||||
// Doesn't handle multiple pressed buttons at once
|
||||
|
||||
for (int8_t buttonIndex = 0; buttonIndex < config::buttonCount; ++buttonIndex) {
|
||||
|
|
|
|||
|
|
@ -28,5 +28,13 @@ void Globals::SetFilamentLoaded(bool 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 modules
|
||||
|
|
|
|||
|
|
@ -33,6 +33,13 @@ public:
|
|||
/// @param newFilamentLoaded new state
|
||||
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:
|
||||
uint8_t activeSlot;
|
||||
bool filamentLoaded;
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ st_timer_t Motion::Step() {
|
|||
return next;
|
||||
}
|
||||
|
||||
void ISR() {}
|
||||
void Isr() {}
|
||||
|
||||
} // namespace motion
|
||||
} // namespace modules
|
||||
|
|
|
|||
|
|
@ -248,7 +248,7 @@ private:
|
|||
};
|
||||
|
||||
/// ISR stepping routine
|
||||
//extern void ISR();
|
||||
//extern void Isr();
|
||||
|
||||
extern Motion motion;
|
||||
|
||||
|
|
|
|||
|
|
@ -51,11 +51,11 @@ DecodeStatus Protocol::DecodeRequest(uint8_t c) {
|
|||
return DecodeStatus::Error;
|
||||
}
|
||||
case RequestStates::Value:
|
||||
if (c >= '0' && c <= '9') {
|
||||
if (IsDigit(c)) {
|
||||
requestMsg.value *= 10;
|
||||
requestMsg.value += c - '0';
|
||||
return DecodeStatus::NeedMoreData;
|
||||
} else if (c == '\n') {
|
||||
} else if (IsNewLine(c)) {
|
||||
rqState = RequestStates::Code;
|
||||
return DecodeStatus::MessageCompleted;
|
||||
} else {
|
||||
|
|
@ -64,7 +64,7 @@ DecodeStatus Protocol::DecodeRequest(uint8_t c) {
|
|||
return DecodeStatus::Error;
|
||||
}
|
||||
default: //case error:
|
||||
if (c == '\n') {
|
||||
if (IsNewLine(c)) {
|
||||
rqState = RequestStates::Code;
|
||||
return DecodeStatus::MessageCompleted;
|
||||
} else {
|
||||
|
|
@ -107,7 +107,7 @@ DecodeStatus Protocol::DecodeResponse(uint8_t c) {
|
|||
return DecodeStatus::Error;
|
||||
}
|
||||
case ResponseStates::RequestValue:
|
||||
if (c >= '0' && c <= '9') {
|
||||
if (IsDigit(c)) {
|
||||
responseMsg.request.value *= 10;
|
||||
responseMsg.request.value += c - '0';
|
||||
return DecodeStatus::NeedMoreData;
|
||||
|
|
@ -135,11 +135,11 @@ DecodeStatus Protocol::DecodeResponse(uint8_t c) {
|
|||
return DecodeStatus::Error;
|
||||
}
|
||||
case ResponseStates::ParamValue:
|
||||
if (c >= '0' && c <= '9') {
|
||||
if (IsDigit(c)) {
|
||||
responseMsg.paramValue *= 10;
|
||||
responseMsg.paramValue += c - '0';
|
||||
return DecodeStatus::NeedMoreData;
|
||||
} else if (c == '\n') {
|
||||
} else if (IsNewLine(c)) {
|
||||
rspState = ResponseStates::RequestCode;
|
||||
return DecodeStatus::MessageCompleted;
|
||||
} else {
|
||||
|
|
@ -148,7 +148,7 @@ DecodeStatus Protocol::DecodeResponse(uint8_t c) {
|
|||
return DecodeStatus::Error;
|
||||
}
|
||||
default: //case error:
|
||||
if (c == '\n') {
|
||||
if (IsNewLine(c)) {
|
||||
rspState = ResponseStates::RequestCode;
|
||||
return DecodeStatus::MessageCompleted;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -151,6 +151,13 @@ private:
|
|||
|
||||
ResponseStates rspState;
|
||||
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
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ Timebase timebase;
|
|||
void Timebase::Init() {
|
||||
}
|
||||
|
||||
void Timebase::ISR() {
|
||||
void Timebase::Isr() {
|
||||
}
|
||||
|
||||
uint16_t Timebase::Millis() const {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public:
|
|||
|
||||
private:
|
||||
uint16_t ms;
|
||||
static void ISR();
|
||||
static void Isr();
|
||||
};
|
||||
|
||||
/// The one and only instance of Selector in the FW
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ uint16_t millis = 0;
|
|||
|
||||
void Timebase::Init() {}
|
||||
|
||||
void Timebase::ISR() {}
|
||||
void Timebase::Isr() {}
|
||||
|
||||
uint16_t Timebase::Millis() const {
|
||||
return millis;
|
||||
|
|
|
|||
Loading…
Reference in New Issue