Eliminate serial_writechar_P(). serial_writechar() perfoms better and

uses less memory. Also, reviewed all code for usage of single-character
strings.
This commit is contained in:
Markus Hitter 2010-07-04 18:34:24 +02:00
parent e79c7c4759
commit 8468f22e58
3 changed files with 11 additions and 10 deletions

View File

@ -332,14 +332,14 @@ void scan_char(uint8_t c) {
else {
serial_writestr_P(PSTR("Expected checksum "));
serwrite_uint8(next_target.checksum_calculated);
serial_writestr_P(PSTR("\n"));
serial_writechar('\n');
request_resend();
}
}
else {
serial_writestr_P(PSTR("Expected line number "));
serwrite_uint32(next_target.N_expected);
serial_writestr_P(PSTR("\n"));
serial_writechar('\n');
request_resend();
}
@ -735,6 +735,6 @@ void process_gcode_command(GCODE_COMMAND *gcmd) {
void request_resend() {
serial_writestr_P(PSTR("Resend:"));
serwrite_uint8(next_target.N);
serial_writestr_P(PSTR("\n"));
serial_writechar('\n');
}

View File

@ -163,19 +163,21 @@ void serial_writestr(uint8_t *data)
/*
Write from FLASH
*/
void serial_writechar_P(PGM_P data)
{
serial_writechar(pgm_read_byte(data));
}
Extensions to output flash memory pointers. This prevents the data to
become part of the .data segment instead of the .code segment. That means
less memory is consumed for multi-character writes.
For single character writes (i.e. '\n' instead of "\n"), using
serial_writechar() directly is the better choice.
*/
void serial_writeblock_P(PGM_P data, int datalen)
{
int i;
for (i = 0; i < datalen; i++)
serial_writechar_P(&data[i]);
serial_writechar(pgm_read_byte(&data[i]));
}
void serial_writestr_P(PGM_P data)

View File

@ -24,7 +24,6 @@ void serial_writeblock(void *data, int datalen);
void serial_writestr(uint8_t *data);
// write from flash
void serial_writechar_P(PGM_P data);
void serial_writeblock_P(PGM_P data, int datalen);
void serial_writestr_P(PGM_P data);