Misc. formatting, serial out

This commit is contained in:
Scott Lahteine 2021-04-13 21:34:21 -05:00
parent 4849d313fd
commit 0e9836649e
7 changed files with 855 additions and 856 deletions

View File

@ -320,8 +320,8 @@ void hook_cpu_exceptions() {
// So we'll simply mask the top 8 bits of the first handler as an hint of being in the flash or not -that's poor and will
// probably break if the flash happens to be more than 128MB, but in this case, we are not magician, we need help from outside.
unsigned long * vecAddr = (unsigned long*)get_vtor();
SERIAL_ECHO("Vector table addr: ");
unsigned long *vecAddr = (unsigned long*)get_vtor();
SERIAL_ECHOPGM("Vector table addr: ");
SERIAL_PRINTLN(get_vtor(), HEX);
#ifdef VECTOR_TABLE_SIZE
@ -348,7 +348,7 @@ void hook_cpu_exceptions() {
// 128 bytes alignement is required for writing the VTOR register
alignas(128) static unsigned long vectable[VECTOR_TABLE_SENTINEL];
SERIAL_ECHO("Detected vector table size: ");
SERIAL_ECHOPGM("Detected vector table size: ");
SERIAL_PRINTLN(vec_size, HEX);
#endif
@ -372,7 +372,7 @@ void hook_cpu_exceptions() {
HW_REG(0xE000ED08) = (unsigned long)vectable | _BV32(29); // 29th bit is for telling the CPU the table is now in SRAM (should be present already)
SERIAL_ECHOLN("Installed fault handlers");
SERIAL_ECHOLNPGM("Installed fault handlers");
#endif
}

View File

@ -28,11 +28,11 @@
// This is used like SERIAL_ECHOPAIR, that is: a key-value call of the local variables you want
// to dump to the serial port before stopping the CPU.
// \/ Don't replace by SERIAL_ECHOPAIR since ONLY_FILENAME cannot be transformed to a PGM string on Arduino and it breaks building
#define BUG_ON(V...) do { SERIAL_ECHO(ONLY_FILENAME); SERIAL_ECHO(__LINE__); SERIAL_ECHOLN(": "); SERIAL_ECHOLNPAIR(V); SERIAL_FLUSHTX(); *(char*)0 = 42; } while(0)
#define BUG_ON(V...) do { SERIAL_ECHO(ONLY_FILENAME); SERIAL_ECHO(__LINE__); SERIAL_ECHOLNPGM(": "); SERIAL_ECHOLNPAIR(V); SERIAL_FLUSHTX(); *(char*)0 = 42; } while(0)
#elif ENABLED(MARLIN_DEV_MODE)
// Don't stop the CPU here, but at least dump the bug on the serial port
// \/ Don't replace by SERIAL_ECHOPAIR since ONLY_FILENAME cannot be transformed to a PGM string on Arduino and it breaks building
#define BUG_ON(V...) do { SERIAL_ECHO(ONLY_FILENAME); SERIAL_ECHO(__LINE__); SERIAL_ECHOLN(": BUG!"); SERIAL_ECHOLNPAIR(V); SERIAL_FLUSHTX(); } while(0)
#define BUG_ON(V...) do { SERIAL_ECHO(ONLY_FILENAME); SERIAL_ECHO(__LINE__); SERIAL_ECHOLNPGM(": BUG!"); SERIAL_ECHOLNPAIR(V); SERIAL_FLUSHTX(); } while(0)
#else
// Release mode, let's ignore the bug
#define BUG_ON(V...) NOOP

View File

@ -88,7 +88,7 @@ static const uint8_t u8g_dev_ssd13xx_sleep_off[] PROGMEM = {
};
uint8_t u8g_dev_ssd1309_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg) {
switch(msg) {
switch (msg) {
case U8G_DEV_MSG_INIT:
u8g_InitCom(u8g, dev, U8G_SPI_CLK_CYCLE_300NS);
u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1309_128x64_init_seq);

View File

@ -35,22 +35,27 @@
using namespace ExtUI;
namespace Anycubic {
class FileNavigator {
class FileNavigator {
public:
FileNavigator();
void reset();
void getFiles(uint16_t);
void getFiles(uint16_t, panel_type_t, uint8_t filesneeded=4);
void upDIR();
void changeDIR(char *);
void sendFile();
void changeDIR(const char *);
void sendFile(panel_type_t);
void refresh();
char * getCurrentFolderName();
private:
void skiptofileindex(uint16_t);
static FileList filelist;
static char currentfoldername[MAX_PATH_LEN];
static uint16_t lastindex;
static uint8_t folderdepth;
private:
static uint16_t lastpanelindex;
static uint16_t currentindex;
};
extern FileNavigator filenavigator;
static uint8_t currentfolderdepth;
static uint16_t currentfolderindex[MAX_FOLDER_DEPTH];
static char currentfoldername[MAX_PATH_LEN];
};
extern FileNavigator filenavigator;
}

View File

@ -43,22 +43,22 @@
namespace Anycubic {
printer_state_t ChironTFT::printer_state;
paused_state_t ChironTFT::pause_state;
heater_state_t ChironTFT::hotend_state;
heater_state_t ChironTFT::hotbed_state;
xy_uint8_t ChironTFT::selectedmeshpoint;
char ChironTFT::selectedfile[MAX_PATH_LEN];
char ChironTFT::panel_command[MAX_CMND_LEN];
uint8_t ChironTFT::command_len;
float ChironTFT::live_Zoffset;
file_menu_t ChironTFT::file_menu;
printer_state_t ChironTFT::printer_state;
paused_state_t ChironTFT::pause_state;
heater_state_t ChironTFT::hotend_state;
heater_state_t ChironTFT::hotbed_state;
xy_uint8_t ChironTFT::selectedmeshpoint;
char ChironTFT::selectedfile[MAX_PATH_LEN];
char ChironTFT::panel_command[MAX_CMND_LEN];
uint8_t ChironTFT::command_len;
float ChironTFT::live_Zoffset;
file_menu_t ChironTFT::file_menu;
ChironTFT Chiron;
ChironTFT Chiron;
ChironTFT::ChironTFT(){}
ChironTFT::ChironTFT(){}
void ChironTFT::Startup() {
void ChironTFT::Startup() {
selectedfile[0] = '\0';
panel_command[0] = '\0';
command_len = 0;
@ -99,24 +99,24 @@ namespace Anycubic {
SERIAL_ECHOLNPAIR("AC Debug Level ", ACDEBUGLEVEL);
#endif
SendtoTFTLN(AC_msg_ready);
}
}
void ChironTFT::IdleLoop() {
void ChironTFT::IdleLoop() {
if (ReadTFTCommand()) {
ProcessPanelRequest();
command_len = 0;
}
CheckHeaters();
}
}
void ChironTFT::PrinterKilled(PGM_P error,PGM_P component) {
void ChironTFT::PrinterKilled(PGM_P error,PGM_P component) {
SendtoTFTLN(AC_msg_kill_lcd);
#if ACDEBUG(AC_MARLIN)
SERIAL_ECHOLNPAIR("PrinterKilled()\nerror: ", error , "\ncomponent: ", component);
#endif
}
}
void ChironTFT::MediaEvent(media_event_t event) {
void ChironTFT::MediaEvent(media_event_t event) {
#if ACDEBUG(AC_MARLIN)
SERIAL_ECHOLNPAIR("ProcessMediaStatus() ", event);
#endif
@ -133,9 +133,9 @@ namespace Anycubic {
SendtoTFTLN(AC_msg_no_sd_card);
break;
}
}
}
void ChironTFT::TimerEvent(timer_event_t event) {
void ChironTFT::TimerEvent(timer_event_t event) {
#if ACDEBUG(AC_MARLIN)
SERIAL_ECHOLNPAIR("TimerEvent() ", event);
SERIAL_ECHOLNPAIR("Printer State: ", printer_state);
@ -163,9 +163,9 @@ namespace Anycubic {
setSoftEndstopState(true); // enable endstops
} break;
}
}
}
void ChironTFT::FilamentRunout() {
void ChironTFT::FilamentRunout() {
#if ACDEBUG(AC_MARLIN)
SERIAL_ECHOLNPAIR("FilamentRunout() printer_state ", printer_state);
#endif
@ -173,9 +173,9 @@ namespace Anycubic {
SendtoTFTLN(isPrintingFromMedia() ? AC_msg_filament_out_alert : AC_msg_filament_out_block);
//printer_state = AC_printer_filament_out;
PlayTune(BEEPER_PIN, FilamentOut, 1);
}
}
void ChironTFT::ConfirmationRequest(const char * const msg) {
void ChironTFT::ConfirmationRequest(const char * const msg) {
// M108 continue
#if ACDEBUG(AC_MARLIN)
SERIAL_ECHOLNPAIR("ConfirmationRequest() ", msg, " printer_state:", printer_state);
@ -211,9 +211,9 @@ namespace Anycubic {
default:
break;
}
}
}
void ChironTFT::StatusChange(const char * const msg) {
void ChironTFT::StatusChange(const char * const msg) {
#if ACDEBUG(AC_MARLIN)
SERIAL_ECHOLNPAIR("StatusChange() ", msg);
SERIAL_ECHOLNPAIR("printer_state:", printer_state);
@ -279,23 +279,23 @@ namespace Anycubic {
hotbed_state = AC_heater_temp_set;
}
}
}
}
void ChironTFT::PowerLossRecovery() {
void ChironTFT::PowerLossRecovery() {
printer_state = AC_printer_resuming_from_power_outage; // Play tune to notify user we can recover.
PlayTune(BEEPER_PIN, SOS, 1);
SERIAL_ECHOLNPGM("Resuming from power outage...");
SERIAL_ECHOLNPGM("Select SD file then press resume");
}
}
void ChironTFT::SendtoTFT(PGM_P str) { // A helper to print PROGMEM string to the panel
void ChironTFT::SendtoTFT(PGM_P str) { // A helper to print PROGMEM string to the panel
#if ACDEBUG(AC_SOME)
SERIAL_ECHOPGM_P(str);
#endif
while (const char c = pgm_read_byte(str++)) TFTSer.write(c);
}
}
void ChironTFT::SendtoTFTLN(PGM_P str = nullptr) {
void ChironTFT::SendtoTFTLN(PGM_P str = nullptr) {
if (str) {
#if ACDEBUG(AC_SOME)
SERIAL_ECHOPGM("> ");
@ -306,9 +306,9 @@ namespace Anycubic {
#endif
}
TFTSer.println();
}
}
bool ChironTFT::ReadTFTCommand() {
bool ChironTFT::ReadTFTCommand() {
bool command_ready = false;
while (TFTSer.available() > 0 && command_len < MAX_CMND_LEN) {
panel_command[command_len] = TFTSer.read();
@ -334,15 +334,15 @@ namespace Anycubic {
#endif
}
return command_ready;
}
}
int8_t ChironTFT::Findcmndpos(const char * buff, char q) {
int8_t ChironTFT::Findcmndpos(const char * buff, char q) {
int8_t pos = 0;
do { if (buff[pos] == q) return pos; } while (++pos < MAX_CMND_LEN);
return -1;
}
}
void ChironTFT::CheckHeaters() {
void ChironTFT::CheckHeaters() {
uint8_t faultDuration = 0;
float temp = 0;
@ -388,9 +388,9 @@ namespace Anycubic {
hotbed_state = AC_heater_temp_reached;
}
}
}
}
void ChironTFT::SendFileList(int8_t startindex) {
void ChironTFT::SendFileList(int8_t startindex) {
// Respond to panel request for 4 files starting at index
#if ACDEBUG(AC_INFO)
SERIAL_ECHOLNPAIR("## SendFileList ## ", startindex);
@ -398,9 +398,9 @@ namespace Anycubic {
SendtoTFTLN(PSTR("FN "));
filenavigator.getFiles(startindex);
SendtoTFTLN(PSTR("END"));
}
}
void ChironTFT::SelectFile() {
void ChironTFT::SelectFile() {
strncpy(selectedfile, panel_command + 4, command_len - 4);
selectedfile[command_len - 5] = '\0';
#if ACDEBUG(AC_FILE)
@ -422,14 +422,14 @@ namespace Anycubic {
SendFileList( 0 );
break;
}
}
}
void ChironTFT::InjectCommandandWait(PGM_P cmd) {
void ChironTFT::InjectCommandandWait(PGM_P cmd) {
//injectCommands_P(cmnd); queue.enqueue_now_P(cmd);
//SERIAL_ECHOLN(PSTR("Inject>"));
}
}
void ChironTFT::ProcessPanelRequest() {
void ChironTFT::ProcessPanelRequest() {
// Break these up into logical blocks // as its easier to navigate than one huge switch case!
int8_t req = atoi(&panel_command[1]);
@ -443,9 +443,9 @@ namespace Anycubic {
else if (req <= 34) PanelProcess(req);
else SendtoTFTLN();
}
}
void ChironTFT::PanelInfo(uint8_t req) {
void ChironTFT::PanelInfo(uint8_t req) {
// information requests A0-A8 and A33
switch (req) {
case 0: // A0 Get HOTEND Temp
@ -516,9 +516,9 @@ namespace Anycubic {
SendtoTFTLN(PSTR(SHORT_BUILD_VERSION));
break;
}
}
}
void ChironTFT::PanelAction(uint8_t req) {
void ChironTFT::PanelAction(uint8_t req) {
switch (req) {
case 9: // A9 Pause SD print
if (isPrintingFromMedia()) {
@ -703,9 +703,9 @@ namespace Anycubic {
SendtoTFTLN();
break;
}
}
}
void ChironTFT::PanelProcess(uint8_t req) {
void ChironTFT::PanelProcess(uint8_t req) {
switch (req) {
case 29: { // A29 Read Mesh Point A29 X1 Y1
xy_uint8_t pos;
@ -832,8 +832,8 @@ namespace Anycubic {
setAxisPosition_mm(currZpos+constrain(Zshift,-0.05,0.05),Z);
}
}
} break;
} // end switch
}
}
} break;
case 32: { // A32 clean leveling beep flag
@ -843,7 +843,7 @@ namespace Anycubic {
//TFTSer.println();
} break;
// A33 firmware info request seet PanelInfo()
// A33 firmware info request see PanelInfo()
case 34: { // A34 Adjust single mesh point A34 C/S X1 Y1 V123
if (panel_command[3] == 'C') { // Restore original offsets
@ -879,7 +879,7 @@ namespace Anycubic {
}
} break;
}
}
}
} // Anycubic

View File

@ -35,7 +35,7 @@
namespace Anycubic {
class ChironTFT {
class ChironTFT {
private:
static printer_state_t printer_state;
static paused_state_t pause_state;
@ -73,8 +73,8 @@ namespace Anycubic {
static void PanelInfo(uint8_t);
static void PanelAction(uint8_t);
static void PanelProcess(uint8_t);
};
};
extern ChironTFT Chiron;
extern ChironTFT Chiron;
} // Anycubic

View File

@ -109,19 +109,16 @@
#define AC_cmnd_power_loss_recovery PSTR("G28XYR5\nG28Z") // Lift, home X and Y then home Z when in 'safe' position
namespace Anycubic {
enum heater_state_t : uint8_t {
AC_heater_off,
AC_heater_temp_set,
AC_heater_temp_reached
};
enum paused_state_t : uint8_t {
AC_paused_heater_timed_out,
AC_paused_purging_filament,
AC_paused_idle
};
enum printer_state_t : uint8_t {
AC_printer_idle,
AC_printer_probing,
@ -131,13 +128,11 @@ namespace Anycubic {
AC_printer_stopping,
AC_printer_resuming_from_power_outage
};
enum timer_event_t : uint8_t {
AC_timer_started,
AC_timer_paused,
AC_timer_stopped
};
enum media_event_t : uint8_t {
AC_media_inserted,
AC_media_removed,
@ -149,5 +144,4 @@ namespace Anycubic {
AC_menu_change_to_file,
AC_menu_change_to_command
};
} // Anycubic