Drop pgm_read_*_near and let headers choose (#12301)
- Drop `pgm_read_*_near` and let headers choose. - Define `USE_EXECUTE_COMMANDS_IMMEDIATE` as a conditional. - Add `process_subcommands_now` for SRAM-based commands.
This commit is contained in:
parent
fce150f094
commit
31c28d0dd2
@ -173,7 +173,7 @@ void GcodeSuite::dwell(millis_t time) {
|
||||
* Process the parsed command and dispatch it to its handler
|
||||
*/
|
||||
void GcodeSuite::process_parsed_command(
|
||||
#if ENABLED(USE_EXECUTE_COMMANDS_IMMEDIATE)
|
||||
#if USE_EXECUTE_COMMANDS_IMMEDIATE
|
||||
const bool no_ok
|
||||
#endif
|
||||
) {
|
||||
@ -698,7 +698,7 @@ void GcodeSuite::process_parsed_command(
|
||||
|
||||
KEEPALIVE_STATE(NOT_BUSY);
|
||||
|
||||
#if ENABLED(USE_EXECUTE_COMMANDS_IMMEDIATE)
|
||||
#if USE_EXECUTE_COMMANDS_IMMEDIATE
|
||||
if (!no_ok)
|
||||
#endif
|
||||
ok_to_send();
|
||||
@ -725,35 +725,43 @@ void GcodeSuite::process_next_command() {
|
||||
process_parsed_command();
|
||||
}
|
||||
|
||||
#if ENABLED(USE_EXECUTE_COMMANDS_IMMEDIATE)
|
||||
#if USE_EXECUTE_COMMANDS_IMMEDIATE
|
||||
|
||||
/**
|
||||
* Run a series of commands, bypassing the command queue to allow
|
||||
* G-code "macros" to be called from within other G-code handlers.
|
||||
*/
|
||||
|
||||
void GcodeSuite::process_subcommands_now_P(PGM_P pgcode) {
|
||||
// Save the parser state
|
||||
char * const saved_cmd = parser.command_ptr;
|
||||
|
||||
// Process individual commands in string
|
||||
while (pgm_read_byte_near(pgcode)) {
|
||||
// Break up string at '\n' delimiters
|
||||
PGM_P const delim = strchr_P(pgcode, '\n');
|
||||
size_t len = delim ? delim - pgcode : strlen_P(pgcode);
|
||||
char cmd[len + 1];
|
||||
strncpy_P(cmd, pgcode, len);
|
||||
cmd[len] = '\0';
|
||||
pgcode += len;
|
||||
if (delim) pgcode++;
|
||||
|
||||
// Parse the next command in the string
|
||||
parser.parse(cmd);
|
||||
process_parsed_command(true);
|
||||
char * const saved_cmd = parser.command_ptr; // Save the parser state
|
||||
for (;;) {
|
||||
PGM_P const delim = strchr_P(pgcode, '\n'); // Get address of next newline
|
||||
const size_t len = delim ? delim - pgcode : strlen_P(pgcode); // Get the command length
|
||||
char cmd[len + 1]; // Allocate a stack buffer
|
||||
strncpy_P(cmd, pgcode, len); // Copy the command to the stack
|
||||
cmd[len] = '\0'; // End with a nul
|
||||
parser.parse(cmd); // Parse the command
|
||||
process_parsed_command(true); // Process it
|
||||
if (!delim) break; // Last command?
|
||||
pgcode = delim + 1; // Get the next command
|
||||
}
|
||||
|
||||
// Restore the parser state
|
||||
parser.parse(saved_cmd);
|
||||
parser.parse(saved_cmd); // Restore the parser state
|
||||
}
|
||||
#endif
|
||||
|
||||
void GcodeSuite::process_subcommands_now(char * gcode) {
|
||||
char * const saved_cmd = parser.command_ptr; // Save the parser state
|
||||
for (;;) {
|
||||
const char * const delim = strchr(gcode, '\n'); // Get address of next newline
|
||||
if (delim) *delim = '\0'; // Replace with nul
|
||||
parser.parse(gcode); // Parse the current command
|
||||
process_parsed_command(true); // Process it
|
||||
if (!delim) break; // Last command?
|
||||
gcode = delim + 1; // Get the next command
|
||||
}
|
||||
parser.parse(saved_cmd); // Restore the parser state
|
||||
}
|
||||
|
||||
#endif // USE_EXECUTE_COMMANDS_IMMEDIATE
|
||||
|
||||
#if ENABLED(HOST_KEEPALIVE_FEATURE)
|
||||
|
||||
|
@ -293,14 +293,15 @@ public:
|
||||
static bool get_target_extruder_from_command();
|
||||
static void get_destination_from_command();
|
||||
static void process_parsed_command(
|
||||
#if ENABLED(USE_EXECUTE_COMMANDS_IMMEDIATE)
|
||||
#if USE_EXECUTE_COMMANDS_IMMEDIATE
|
||||
const bool no_ok = false
|
||||
#endif
|
||||
);
|
||||
static void process_next_command();
|
||||
|
||||
#if ENABLED(USE_EXECUTE_COMMANDS_IMMEDIATE)
|
||||
#if USE_EXECUTE_COMMANDS_IMMEDIATE
|
||||
static void process_subcommands_now_P(PGM_P pgcode);
|
||||
static void process_subcommands_now(char * gcode);
|
||||
#endif
|
||||
|
||||
FORCE_INLINE static void home_all_axes() { G28(true); }
|
||||
|
@ -1626,9 +1626,7 @@
|
||||
// If platform requires early initialization of watchdog to properly boot
|
||||
#define EARLY_WATCHDOG (ENABLED(USE_WATCHDOG) && defined(ARDUINO_ARCH_SAM))
|
||||
|
||||
#if ENABLED(G29_RETRY_AND_RECOVER)
|
||||
#define USE_EXECUTE_COMMANDS_IMMEDIATE
|
||||
#endif
|
||||
#define USE_EXECUTE_COMMANDS_IMMEDIATE ENABLED(G29_RETRY_AND_RECOVER)
|
||||
|
||||
#if ENABLED(Z_TRIPLE_STEPPER_DRIVERS)
|
||||
#define Z_STEPPER_COUNT 3
|
||||
|
@ -96,7 +96,7 @@ void ST7920_Lite_Status_Screen::write_str(const char *str, uint8_t len) {
|
||||
|
||||
void ST7920_Lite_Status_Screen::write_str_P(PGM_P const str) {
|
||||
PGM_P p_str = (PGM_P)str;
|
||||
while (char c = pgm_read_byte_near(p_str++)) write_byte(c);
|
||||
while (char c = pgm_read_byte(p_str++)) write_byte(c);
|
||||
}
|
||||
|
||||
void ST7920_Lite_Status_Screen::write_str(progmem_str str) {
|
||||
@ -221,7 +221,7 @@ void ST7920_Lite_Status_Screen::load_cgram_icon(const uint16_t addr, const void
|
||||
set_cgram_address(addr);
|
||||
begin_data();
|
||||
for (uint8_t i = 16; i--;)
|
||||
write_word(pgm_read_word_near(p_word++));
|
||||
write_word(pgm_read_word(p_word++));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -239,7 +239,7 @@ void ST7920_Lite_Status_Screen::draw_gdram_icon(uint8_t x, uint8_t y, const void
|
||||
for (int i = 0; i < 16; i++) {
|
||||
set_gdram_address(x, i + y * 16);
|
||||
begin_data();
|
||||
write_word(pgm_read_word_near(p_word++));
|
||||
write_word(pgm_read_word(p_word++));
|
||||
}
|
||||
}
|
||||
|
||||
@ -416,8 +416,8 @@ void ST7920_Lite_Status_Screen::draw_degree_symbol(uint8_t x, uint8_t y, bool dr
|
||||
const uint8_t y_top = degree_symbol_y_top;
|
||||
const uint8_t y_bot = y_top + sizeof(degree_symbol)/sizeof(degree_symbol[0]);
|
||||
for(uint8_t i = y_top; i < y_bot; i++) {
|
||||
uint8_t byte = pgm_read_byte_near(p_bytes++);
|
||||
set_gdram_address(x_word,i+y*16);
|
||||
uint8_t byte = pgm_read_byte(p_bytes++);
|
||||
set_gdram_address(x_word, i + y * 16);
|
||||
begin_data();
|
||||
if (draw) {
|
||||
write_byte(oddChar ? 0x00 : byte);
|
||||
|
@ -1803,7 +1803,7 @@ void MarlinSettings::reset(PORTARG_SOLO) {
|
||||
LOOP_XYZE_N(i) {
|
||||
planner.settings.axis_steps_per_mm[i] = pgm_read_float(&tmp1[ALIM(i, tmp1)]);
|
||||
planner.settings.max_feedrate_mm_s[i] = pgm_read_float(&tmp2[ALIM(i, tmp2)]);
|
||||
planner.settings.max_acceleration_mm_per_s2[i] = pgm_read_dword_near(&tmp3[ALIM(i, tmp3)]);
|
||||
planner.settings.max_acceleration_mm_per_s2[i] = pgm_read_dword(&tmp3[ALIM(i, tmp3)]);
|
||||
}
|
||||
|
||||
planner.settings.min_segment_time_us = DEFAULT_MINSEGMENTTIME;
|
||||
|
@ -95,8 +95,8 @@ extern int16_t feedrate_percentage;
|
||||
|
||||
extern float soft_endstop_min[XYZ], soft_endstop_max[XYZ];
|
||||
|
||||
FORCE_INLINE float pgm_read_any(const float *p) { return pgm_read_float_near(p); }
|
||||
FORCE_INLINE signed char pgm_read_any(const signed char *p) { return pgm_read_byte_near(p); }
|
||||
FORCE_INLINE float pgm_read_any(const float *p) { return pgm_read_float(p); }
|
||||
FORCE_INLINE signed char pgm_read_any(const signed char *p) { return pgm_read_byte(p); }
|
||||
|
||||
#define XYZ_DEFS(type, array, CONFIG) \
|
||||
extern const type array##_P[XYZ]; \
|
||||
|
@ -526,15 +526,15 @@ class Stepper {
|
||||
if (step_rate >= (8 * 256)) { // higher step rate
|
||||
const uint8_t tmp_step_rate = (step_rate & 0x00FF);
|
||||
const uint16_t table_address = (uint16_t)&speed_lookuptable_fast[(uint8_t)(step_rate >> 8)][0],
|
||||
gain = (uint16_t)pgm_read_word_near(table_address + 2);
|
||||
gain = (uint16_t)pgm_read_word(table_address + 2);
|
||||
timer = MultiU16X8toH16(tmp_step_rate, gain);
|
||||
timer = (uint16_t)pgm_read_word_near(table_address) - timer;
|
||||
timer = (uint16_t)pgm_read_word(table_address) - timer;
|
||||
}
|
||||
else { // lower step rates
|
||||
uint16_t table_address = (uint16_t)&speed_lookuptable_slow[0][0];
|
||||
table_address += ((step_rate) >> 1) & 0xFFFC;
|
||||
timer = (uint16_t)pgm_read_word_near(table_address)
|
||||
- (((uint16_t)pgm_read_word_near(table_address + 2) * (uint8_t)(step_rate & 0x0007)) >> 3);
|
||||
timer = (uint16_t)pgm_read_word(table_address)
|
||||
- (((uint16_t)pgm_read_word(table_address + 2) * (uint8_t)(step_rate & 0x0007)) >> 3);
|
||||
}
|
||||
// (there is no need to limit the timer value here. All limits have been
|
||||
// applied above, and AVR is able to keep up at 30khz Stepping ISR rate)
|
||||
|
Loading…
Reference in New Issue
Block a user