parent
7e2375deee
commit
e2ee6f6ff1
|
|
@ -2,12 +2,13 @@
|
||||||
#include "application.h"
|
#include "application.h"
|
||||||
#include "registers.h"
|
#include "registers.h"
|
||||||
|
|
||||||
#include "modules/leds.h"
|
|
||||||
#include "modules/globals.h"
|
|
||||||
#include "modules/user_input.h"
|
|
||||||
#include "modules/finda.h"
|
#include "modules/finda.h"
|
||||||
#include "modules/fsensor.h"
|
#include "modules/fsensor.h"
|
||||||
|
#include "modules/globals.h"
|
||||||
|
#include "modules/leds.h"
|
||||||
|
#include "modules/permanent_storage.h"
|
||||||
#include "modules/serial.h"
|
#include "modules/serial.h"
|
||||||
|
#include "modules/user_input.h"
|
||||||
|
|
||||||
#include "logic/command_base.h"
|
#include "logic/command_base.h"
|
||||||
#include "logic/cut_filament.h"
|
#include "logic/cut_filament.h"
|
||||||
|
|
@ -179,6 +180,51 @@ void Application::ReportWriteRegister(const mp::RequestMsg &rq) {
|
||||||
modules::serial::WriteToUSART(rsp, len);
|
modules::serial::WriteToUSART(rsp, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Performs a blocking (!) LED "snake" from one side to the other and back.
|
||||||
|
/// Intended only for visualization of EEPROM reset, not to be used in while the MMU is running normally
|
||||||
|
namespace EEPROMResetVis {
|
||||||
|
|
||||||
|
static void Delay(){
|
||||||
|
uint32_t start = mt::timebase.Millis();
|
||||||
|
while( ! mt::timebase.Elapsed(start, 100) ){
|
||||||
|
ml::leds.Step();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __attribute__((noinline)) Green(uint8_t i){
|
||||||
|
ml::leds.SetPairButOffOthers(i, ml::on, ml::off);
|
||||||
|
Delay();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __attribute__((noinline)) Red(uint8_t i){
|
||||||
|
ml::leds.SetPairButOffOthers(i, ml::on, ml::off);
|
||||||
|
Delay();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Run(){
|
||||||
|
for(uint8_t i = 0; i < ml::leds.LedPairsCount(); ++i){
|
||||||
|
Green(i);
|
||||||
|
Red(i);
|
||||||
|
}
|
||||||
|
for(uint8_t i = ml::leds.LedPairsCount(); i != 0; --i){
|
||||||
|
Red(i);
|
||||||
|
Green(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace EEPROMResetVis
|
||||||
|
|
||||||
|
void Application::ProcessReset(uint8_t resetType){
|
||||||
|
switch(resetType){
|
||||||
|
case 42: // perform an EEPROM reset if the resetType == The Answer to the Ultimate Question of Life, the Universe, and Everything :)
|
||||||
|
mps::EraseAll();
|
||||||
|
EEPROMResetVis::Run();
|
||||||
|
[[fallthrough]];
|
||||||
|
default: // anything else "just" restarts the board
|
||||||
|
hal::cpu::Reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Application::ProcessRequestMsg(const mp::RequestMsg &rq) {
|
void Application::ProcessRequestMsg(const mp::RequestMsg &rq) {
|
||||||
switch (rq.code) {
|
switch (rq.code) {
|
||||||
case mp::RequestMsgCodes::Button:
|
case mp::RequestMsgCodes::Button:
|
||||||
|
|
@ -196,7 +242,7 @@ void Application::ProcessRequestMsg(const mp::RequestMsg &rq) {
|
||||||
break;
|
break;
|
||||||
case mp::RequestMsgCodes::Reset:
|
case mp::RequestMsgCodes::Reset:
|
||||||
// immediately reset the board - there is no response in this case
|
// immediately reset the board - there is no response in this case
|
||||||
hal::cpu::Reset();
|
ProcessReset(rq.value);
|
||||||
break;
|
break;
|
||||||
case mp::RequestMsgCodes::Version:
|
case mp::RequestMsgCodes::Version:
|
||||||
case mp::RequestMsgCodes::Read:
|
case mp::RequestMsgCodes::Read:
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ private:
|
||||||
void ReportReadRegister(const mp::RequestMsg &rq);
|
void ReportReadRegister(const mp::RequestMsg &rq);
|
||||||
void ReportWriteRegister(const mp::RequestMsg &rq);
|
void ReportWriteRegister(const mp::RequestMsg &rq);
|
||||||
void ProcessRequestMsg(const mp::RequestMsg &rq);
|
void ProcessRequestMsg(const mp::RequestMsg &rq);
|
||||||
|
void ProcessReset(uint8_t resetType);
|
||||||
|
|
||||||
uint16_t lastCommandProcessedMs;
|
uint16_t lastCommandProcessedMs;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue