moved all strings to pgm-memory

This commit is contained in:
Simen Svale Skogsrud 2010-03-07 23:10:41 +01:00
parent 3c98837a70
commit e409f10047
8 changed files with 38 additions and 23 deletions

View File

@ -24,6 +24,7 @@
#include "config.h"
#include "eeprom.h"
#include "wiring_serial.h"
#include <avr/pgmspace.h>
void reset_settings() {
settings.steps_per_mm[0] = X_STEPS_PER_MM;
@ -37,16 +38,16 @@ void reset_settings() {
}
void dump_settings() {
printString("$0 = "); printFloat(settings.steps_per_mm[0]);
printString(" (steps/mm x)\r\n$1 = "); printFloat(settings.steps_per_mm[1]);
printString(" (steps/mm y)\r\n$2 = "); printFloat(settings.steps_per_mm[2]);
printString(" (steps/mm z)\r\n$3 = "); printInteger(settings.pulse_microseconds);
printString(" (microseconds step pulse)\r\n$4 = "); printFloat(settings.default_feed_rate);
printString(" (mm/sec default feed rate)\r\n$5 = "); printFloat(settings.default_seek_rate);
printString(" (mm/sec default seek rate)\r\n$6 = "); printFloat(settings.mm_per_arc_segment);
printString(" (mm/arc segment)\r\n$7 = "); printInteger(settings.invert_mask);
printString(" (step port invert mask. binary = "); printIntegerInBase(settings.invert_mask, 2);
printString(")\r\n\r\n'$x=value' to set parameter or just '$' to dump current settings\r\n");
printPgmString(PSTR("$0 = ")); printFloat(settings.steps_per_mm[0]);
printPgmString(PSTR(" (steps/mm x)\r\n$1 = ")); printFloat(settings.steps_per_mm[1]);
printPgmString(PSTR(" (steps/mm y)\r\n$2 = ")); printFloat(settings.steps_per_mm[2]);
printPgmString(PSTR(" (steps/mm z)\r\n$3 = ")); printInteger(settings.pulse_microseconds);
printPgmString(PSTR(" (microseconds step pulse)\r\n$4 = ")); printFloat(settings.default_feed_rate);
printPgmString(PSTR(" (mm/sec default feed rate)\r\n$5 = ")); printFloat(settings.default_seek_rate);
printPgmString(PSTR(" (mm/sec default seek rate)\r\n$6 = ")); printFloat(settings.mm_per_arc_segment);
printPgmString(PSTR(" (mm/arc segment)\r\n$7 = ")); printInteger(settings.invert_mask);
printPgmString(PSTR(" (step port invert mask. binary = ")); printIntegerInBase(settings.invert_mask, 2);
printPgmString(PSTR(")\r\n\r\n'$x=value' to set parameter or just '$' to dump current settings\r\n"));
}
int read_settings() {
@ -76,18 +77,18 @@ void store_setting(int parameter, double value) {
case 6: settings.mm_per_arc_segment = value; break;
case 7: settings.invert_mask = trunc(value); break;
default:
printString("Unknown parameter\r\n");
printPgmString(PSTR("Unknown parameter\r\n"));
return;
}
write_settings();
printString("Stored new setting\r\n");
printPgmString(PSTR("Stored new setting\r\n"));
}
void config_init() {
if(read_settings()) {
printString("'$' to dump current settings\r\n");
printPgmString(PSTR("'$' to dump current settings\r\n"));
} else {
printString("EEPROM blank. Rewrote default settings:\r\n");
printPgmString(("EEPROM blank. Rewrote default settings:\r\n"));
reset_settings();
write_settings();
dump_settings();

View File

@ -25,7 +25,8 @@
// Settings that can only be set at compile-time:
#define BAUD_RATE 9600
// #define BAUD_RATE 9600
#define BAUD_RATE 115200
#define STEPPERS_ENABLE_DDR DDRD
#define STEPPERS_ENABLE_PORT PORTD

View File

@ -1,2 +1,3 @@
socat -d -d READLINE /dev/tty.usbserial-A9007QcR,clocal=1,nonblock=1,cread=1,cs8,ixon=1,ixoff=1
# socat -d -d READLINE /dev/tty.usbserial-A9007QcR,clocal=1,nonblock=1,cread=1,cs8,ixon=1,ixoff=1
socat -d -d READLINE /dev/tty.FireFly-A964-SPP-1,clocal=1,nonblock=1,cread=1,cs8,ixon=1,ixoff=1

View File

@ -24,7 +24,7 @@ if ARGV.empty?
exit
end
SerialPort.open('/dev/tty.usbserial-A9007QcR', 9600) do |sp|
SerialPort.open('/dev/tty.FireFly-A964-SPP-1', 115200) do |sp|
sp.write("\r\n\r\n");
sleep 5
ARGV.each do |file|

View File

@ -25,23 +25,23 @@
#include "config.h"
#include <math.h>
#include "nuts_bolts.h"
#define LINE_BUFFER_SIZE 60
#include <avr/pgmspace.h>
#define LINE_BUFFER_SIZE 30
char line[LINE_BUFFER_SIZE];
uint8_t char_counter;
void prompt() {
printString("ok\r\n");
printPgmString(PSTR("ok\r\n"));
}
void sp_init()
{
beginSerial(BAUD_RATE);
printString("\r\nGrbl ");
printString(VERSION);
printString("\r\n");
printPgmString(PSTR("\r\nGrbl "));
printPgmString(PSTR(VERSION));
printPgmString(PSTR("\r\n"));
prompt();
}

View File

@ -80,6 +80,7 @@ void st_buffer_line(int32_t steps_x, int32_t steps_y, int32_t steps_z, uint32_t
line_buffer_head = next_buffer_head;
// enable stepper interrupt
TIMSK1 |= (1<<OCIE1A);
}
// This timer interrupt is executed at the rate set with config_step_timer. It pops one instruction from

View File

@ -23,6 +23,8 @@
*/
#include "wiring_private.h"
#include <math.h>
#include <avr/pgmspace.h>
// Define constants and variables for buffering incoming serial data. We're
// using a ring buffer (I think), in which rx_buffer_head is the index of the
@ -149,6 +151,14 @@ void printString(const char *s)
printByte(*s++);
}
// Print a string stored in PGM-memory
void printPgmString(const char *s)
{
char c;
while ((c = pgm_read_byte_near(s++)))
printByte(c);
}
void printIntegerInBase(unsigned long n, unsigned long base)
{
unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars.

View File

@ -34,6 +34,7 @@ void printMode(int);
void printByte(unsigned char c);
void printNewline(void);
void printString(const char *s);
void printPgmString(const char *s);
void printInteger(long n);
void printHex(unsigned long n);
void printOctal(unsigned long n);