moved all strings to pgm-memory
This commit is contained in:
parent
3c98837a70
commit
e409f10047
29
config.c
29
config.c
@ -24,6 +24,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "eeprom.h"
|
#include "eeprom.h"
|
||||||
#include "wiring_serial.h"
|
#include "wiring_serial.h"
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
|
||||||
void reset_settings() {
|
void reset_settings() {
|
||||||
settings.steps_per_mm[0] = X_STEPS_PER_MM;
|
settings.steps_per_mm[0] = X_STEPS_PER_MM;
|
||||||
@ -37,16 +38,16 @@ void reset_settings() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void dump_settings() {
|
void dump_settings() {
|
||||||
printString("$0 = "); printFloat(settings.steps_per_mm[0]);
|
printPgmString(PSTR("$0 = ")); printFloat(settings.steps_per_mm[0]);
|
||||||
printString(" (steps/mm x)\r\n$1 = "); printFloat(settings.steps_per_mm[1]);
|
printPgmString(PSTR(" (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]);
|
printPgmString(PSTR(" (steps/mm y)\r\n$2 = ")); printFloat(settings.steps_per_mm[2]);
|
||||||
printString(" (steps/mm z)\r\n$3 = "); printInteger(settings.pulse_microseconds);
|
printPgmString(PSTR(" (steps/mm z)\r\n$3 = ")); printInteger(settings.pulse_microseconds);
|
||||||
printString(" (microseconds step pulse)\r\n$4 = "); printFloat(settings.default_feed_rate);
|
printPgmString(PSTR(" (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);
|
printPgmString(PSTR(" (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);
|
printPgmString(PSTR(" (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);
|
printPgmString(PSTR(" (mm/arc segment)\r\n$7 = ")); printInteger(settings.invert_mask);
|
||||||
printString(" (step port invert mask. binary = "); printIntegerInBase(settings.invert_mask, 2);
|
printPgmString(PSTR(" (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(")\r\n\r\n'$x=value' to set parameter or just '$' to dump current settings\r\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
int read_settings() {
|
int read_settings() {
|
||||||
@ -76,18 +77,18 @@ void store_setting(int parameter, double value) {
|
|||||||
case 6: settings.mm_per_arc_segment = value; break;
|
case 6: settings.mm_per_arc_segment = value; break;
|
||||||
case 7: settings.invert_mask = trunc(value); break;
|
case 7: settings.invert_mask = trunc(value); break;
|
||||||
default:
|
default:
|
||||||
printString("Unknown parameter\r\n");
|
printPgmString(PSTR("Unknown parameter\r\n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
write_settings();
|
write_settings();
|
||||||
printString("Stored new setting\r\n");
|
printPgmString(PSTR("Stored new setting\r\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void config_init() {
|
void config_init() {
|
||||||
if(read_settings()) {
|
if(read_settings()) {
|
||||||
printString("'$' to dump current settings\r\n");
|
printPgmString(PSTR("'$' to dump current settings\r\n"));
|
||||||
} else {
|
} else {
|
||||||
printString("EEPROM blank. Rewrote default settings:\r\n");
|
printPgmString(("EEPROM blank. Rewrote default settings:\r\n"));
|
||||||
reset_settings();
|
reset_settings();
|
||||||
write_settings();
|
write_settings();
|
||||||
dump_settings();
|
dump_settings();
|
||||||
|
3
config.h
3
config.h
@ -25,7 +25,8 @@
|
|||||||
|
|
||||||
// Settings that can only be set at compile-time:
|
// 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_DDR DDRD
|
||||||
#define STEPPERS_ENABLE_PORT PORTD
|
#define STEPPERS_ENABLE_PORT PORTD
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ if ARGV.empty?
|
|||||||
exit
|
exit
|
||||||
end
|
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");
|
sp.write("\r\n\r\n");
|
||||||
sleep 5
|
sleep 5
|
||||||
ARGV.each do |file|
|
ARGV.each do |file|
|
||||||
|
@ -25,23 +25,23 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "nuts_bolts.h"
|
#include "nuts_bolts.h"
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
#define LINE_BUFFER_SIZE 60
|
#define LINE_BUFFER_SIZE 30
|
||||||
|
|
||||||
char line[LINE_BUFFER_SIZE];
|
char line[LINE_BUFFER_SIZE];
|
||||||
uint8_t char_counter;
|
uint8_t char_counter;
|
||||||
|
|
||||||
void prompt() {
|
void prompt() {
|
||||||
printString("ok\r\n");
|
printPgmString(PSTR("ok\r\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void sp_init()
|
void sp_init()
|
||||||
{
|
{
|
||||||
beginSerial(BAUD_RATE);
|
beginSerial(BAUD_RATE);
|
||||||
|
|
||||||
printString("\r\nGrbl ");
|
printPgmString(PSTR("\r\nGrbl "));
|
||||||
printString(VERSION);
|
printPgmString(PSTR(VERSION));
|
||||||
printString("\r\n");
|
printPgmString(PSTR("\r\n"));
|
||||||
prompt();
|
prompt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
line_buffer_head = next_buffer_head;
|
||||||
// enable stepper interrupt
|
// enable stepper interrupt
|
||||||
TIMSK1 |= (1<<OCIE1A);
|
TIMSK1 |= (1<<OCIE1A);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This timer interrupt is executed at the rate set with config_step_timer. It pops one instruction from
|
// This timer interrupt is executed at the rate set with config_step_timer. It pops one instruction from
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "wiring_private.h"
|
#include "wiring_private.h"
|
||||||
|
#include <math.h>
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
|
||||||
// Define constants and variables for buffering incoming serial data. We're
|
// 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
|
// 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++);
|
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)
|
void printIntegerInBase(unsigned long n, unsigned long base)
|
||||||
{
|
{
|
||||||
unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars.
|
unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars.
|
||||||
|
@ -34,6 +34,7 @@ void printMode(int);
|
|||||||
void printByte(unsigned char c);
|
void printByte(unsigned char c);
|
||||||
void printNewline(void);
|
void printNewline(void);
|
||||||
void printString(const char *s);
|
void printString(const char *s);
|
||||||
|
void printPgmString(const char *s);
|
||||||
void printInteger(long n);
|
void printInteger(long n);
|
||||||
void printHex(unsigned long n);
|
void printHex(unsigned long n);
|
||||||
void printOctal(unsigned long n);
|
void printOctal(unsigned long n);
|
||||||
|
Loading…
Reference in New Issue
Block a user