Skip to content

Commit 3b46f04

Browse files
committed
Move line-clear into a variable.
1 parent 722d8ff commit 3b46f04

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

main.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ static void reset_devices(void) {
140140
STATIC uint8_t *_heap;
141141
STATIC uint8_t *_pystack;
142142

143+
STATIC const char line_clear[] = "\x1b[2K\x1b[0G";
144+
143145
#if MICROPY_ENABLE_PYSTACK || MICROPY_ENABLE_GC
144146
STATIC uint8_t *_allocate_memory(safe_mode_t safe_mode, const char *env_key, size_t default_size, size_t *final_size) {
145147
*final_size = default_size;
@@ -296,7 +298,7 @@ STATIC bool maybe_run_list(const char *const *filenames, size_t n_filenames) {
296298
if (_current_executing_filename == NULL) {
297299
return false;
298300
}
299-
mp_hal_stdout_tx_str("\x1b[2K\x1b[0G"); // Clear line of junk text
301+
mp_hal_stdout_tx_str(line_clear);
300302
mp_hal_stdout_tx_str(_current_executing_filename);
301303
serial_write_compressed(MP_ERROR_TEXT(" output:\n"));
302304

@@ -410,7 +412,7 @@ STATIC void cleanup_after_vm(mp_obj_t exception) {
410412
}
411413

412414
STATIC void print_code_py_status_message(safe_mode_t safe_mode) {
413-
mp_hal_stdout_tx_str("\x1b[2K\x1b[0G"); // Clear line
415+
mp_hal_stdout_tx_str(line_clear);
414416
if (autoreload_is_enabled()) {
415417
serial_write_compressed(
416418
MP_ERROR_TEXT("Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.\n"));
@@ -1006,7 +1008,7 @@ int __attribute__((used)) main(void) {
10061008

10071009
// Start the debug serial
10081010
serial_early_init();
1009-
mp_hal_stdout_tx_str("\x1b[2K\x1b[0G"); // Clear line
1011+
mp_hal_stdout_tx_str(line_clear);
10101012

10111013
// Wait briefly to give a reset window where we'll enter safe mode after the reset.
10121014
if (get_safe_mode() == SAFE_MODE_NONE) {
@@ -1058,7 +1060,7 @@ int __attribute__((used)) main(void) {
10581060
// displays init after filesystem, since they could share the flash SPI
10591061
board_init();
10601062

1061-
mp_hal_stdout_tx_str("\x1b[2K\x1b[0G"); // Clear line
1063+
mp_hal_stdout_tx_str(line_clear);
10621064

10631065
// This is first time we are running CircuitPython after a reset or power-up.
10641066
supervisor_set_run_reason(RUN_REASON_STARTUP);

0 commit comments

Comments
 (0)