Merge branch 'MK3' into use_Timer

This commit is contained in:
Marek Bel 2018-07-11 21:24:18 +02:00
commit fc657bc31e
33 changed files with 2470 additions and 813 deletions

View File

@ -7,8 +7,8 @@
#define STR(x) STR_HELPER(x)
// Firmware version
#define FW_VERSION "3.2.1"
#define FW_COMMIT_NR 576
#define FW_VERSION "3.3.0"
#define FW_COMMIT_NR 830
// FW_VERSION_UNKNOWN means this is an unofficial build.
// The firmware should only be checked into github with this symbol.
#define FW_DEV_VERSION FW_VERSION_UNKNOWN

View File

@ -229,13 +229,18 @@ bool IsStopped();
//put an ASCII command at the end of the current buffer.
void enquecommand(const char *cmd, bool from_progmem = false);
//put an ASCII command at the end of the current buffer, read from flash
#define enquecommand_P(cmd) enquecommand(cmd, true)
//put an ASCII command at the begin of the current buffer
void enquecommand_front(const char *cmd, bool from_progmem = false);
//put an ASCII command at the end of the current buffer, read from flash
#define enquecommand_P(cmd) enquecommand(cmd, true)
//put an ASCII command at the begin of the current buffer, read from flash
#define enquecommand_front_P(cmd) enquecommand_front(cmd, true)
void repeatcommand_front();
// Remove all lines from the command queue.
void cmdqueue_reset();

View File

@ -71,6 +71,7 @@
#include "math.h"
#include "util.h"
#include "Timer.h"
#include "uart2.h"
#include <avr/wdt.h>
#include <avr/pgmspace.h>
@ -528,6 +529,7 @@ static float saved_pos[4] = { 0, 0, 0, 0 };
static float saved_feedrate2 = 0;
static uint8_t saved_active_extruder = 0;
static bool saved_extruder_under_pressure = false;
static bool saved_extruder_relative_mode = false;
//===========================================================================
//=============================Routines======================================
@ -663,12 +665,12 @@ void crashdet_disable()
void crashdet_stop_and_save_print()
{
stop_and_save_print_to_ram(10, -2); //XY - no change, Z 10mm up, E -2mm retract
stop_and_save_print_to_ram(10, -DEFAULT_RETRACTION); //XY - no change, Z 10mm up, E -1mm retract
}
void crashdet_restore_print_and_continue()
{
restore_print_from_ram_and_continue(2); //XYZ = orig, E +2mm unretract
restore_print_from_ram_and_continue(DEFAULT_RETRACTION); //XYZ = orig, E +1mm unretract
// babystep_apply();
}
@ -847,6 +849,15 @@ void factory_reset(char level, bool quiet)
farm_mode = false;
eeprom_update_byte((uint8_t*)EEPROM_FARM_MODE, farm_mode);
EEPROM_save_B(EEPROM_FARM_NUMBER, &farm_no);
eeprom_update_dword((uint32_t *)EEPROM_TOTALTIME, 0);
eeprom_update_dword((uint32_t *)EEPROM_FILAMENTUSED, 0);
eeprom_update_word((uint16_t *)EEPROM_CRASH_COUNT_X_TOT, 0);
eeprom_update_word((uint16_t *)EEPROM_CRASH_COUNT_Y_TOT, 0);
eeprom_update_word((uint16_t *)EEPROM_FERROR_COUNT_TOT, 0);
eeprom_update_word((uint16_t *)EEPROM_POWER_COUNT_TOT, 0);
fsensor_enable();
WRITE(BEEPER, HIGH);
_delay_ms(100);
@ -1113,7 +1124,7 @@ uint8_t lang_xflash_enum_codes(uint16_t* codes)
printf_P(_n(" _lt_count = 0x%04x (%d)\n"), header.count, header.count);
printf_P(_n(" _lt_chsum = 0x%04x\n"), header.checksum);
printf_P(_n(" _lt_code = 0x%04x (%c%c)\n"), header.code, header.code >> 8, header.code & 0xff);
printf_P(_n(" _lt_resv1 = 0x%08lx\n"), header.reserved1);
printf_P(_n(" _lt_sign = 0x%08lx\n"), header.signature);
addr += header.size;
codes[count] = header.code;
@ -1173,11 +1184,19 @@ void setup()
selectedSerialPort = eeprom_read_byte((uint8_t*)EEPROM_SECOND_SERIAL_ACTIVE);
if (selectedSerialPort == 0xFF) selectedSerialPort = 0;
if (farm_mode)
{
{
no_response = true; //we need confirmation by recieving PRUSA thx
important_status = 8;
prusa_statistics(8);
selectedSerialPort = 1;
#ifdef TMC2130
//increased extruder current (PFW363)
tmc2130_current_h[E_AXIS] = 36;
tmc2130_current_r[E_AXIS] = 36;
#endif //TMC2130
//disabled filament autoload (PFW360)
filament_autoload_enabled = false;
eeprom_update_byte((uint8_t*)EEPROM_FSENS_AUTOLOAD_ENABLED, 0);
}
MYSERIAL.begin(BAUDRATE);
fdev_setup_stream(uartout, uart_putchar, NULL, _FDEV_SETUP_WRITE); //setup uart out stream
@ -1186,11 +1205,13 @@ void setup()
SERIAL_ECHO_START;
printf_P(PSTR(" " FW_VERSION_FULL "\n"));
uart2_init();
#ifdef DEBUG_SEC_LANG
lang_table_header_t header;
uint32_t src_addr = 0x00000;
if (lang_get_header(3, &header, &src_addr))
if (lang_get_header(1, &header, &src_addr))
{
//this is comparsion of some printing-methods regarding to flash space usage and code size/readability
#define LT_PRINT_TEST 2
@ -1207,7 +1228,7 @@ void setup()
printf_P(_n(" _lt_count = 0x%04x (%d)\n"), header.count, header.count);
printf_P(_n(" _lt_chsum = 0x%04x\n"), header.checksum);
printf_P(_n(" _lt_code = 0x%04x (%c%c)\n"), header.code, header.code >> 8, header.code & 0xff);
printf_P(_n(" _lt_resv1 = 0x%08lx\n"), header.reserved1);
printf_P(_n(" _lt_sign = 0x%08lx\n"), header.signature);
#elif (LT_PRINT_TEST==2) //optimized printf
printf_P(
_n(
@ -1225,7 +1246,7 @@ void setup()
header.count, header.count,
header.checksum,
header.code, header.code >> 8, header.code & 0xff,
header.reserved1
header.signature
);
#elif (LT_PRINT_TEST==3) //arduino print/println (leading zeros not solved)
MYSERIAL.print(" _src_addr = 0x");
@ -1252,7 +1273,7 @@ void setup()
MYSERIAL.print((char)(header.code & 0xff), 0);
MYSERIAL.println(")");
MYSERIAL.print(" _lt_resv1 = 0x");
MYSERIAL.println(header.reserved1, 16);
MYSERIAL.println(header.signature, 16);
#endif //(LT_PRINT_TEST==)
#undef LT_PRINT_TEST
@ -1265,7 +1286,22 @@ void setup()
if ((i % 16) == 15) putchar('\n');
}
#endif
#if 1
uint16_t sum = 0;
for (uint16_t i = 0; i < header.size; i++)
sum += (uint16_t)pgm_read_byte((uint8_t*)(_SEC_LANG_TABLE + i)) << ((i & 1)?0:8);
printf_P(_n("_SEC_LANG_TABLE checksum = %04x\n"), sum);
sum -= header.checksum; //subtract checksum
printf_P(_n("_SEC_LANG_TABLE checksum = %04x\n"), sum);
sum = (sum >> 8) | ((sum & 0xff) << 8); //swap bytes
if (sum == header.checksum)
printf_P(_n("Checksum OK\n"), sum);
else
printf_P(_n("Checksum NG\n"), sum);
}
else
printf_P(_n("lang_get_header failed!\n"));
#if 0
for (uint16_t i = 0; i < 1024*10; i++)
{
if ((i % 16) == 0) printf_P(_n("%04x:"), _SEC_LANG_TABLE+i);
@ -1273,10 +1309,6 @@ void setup()
if ((i % 16) == 15) putchar('\n');
}
#endif
}
else
printf_P(_n("lang_get_header failed!\n"));
#if 0
SERIAL_ECHOLN("Reading eeprom from 0 to 100: start");
@ -3222,16 +3254,59 @@ void process_commands()
}
else if (strncmp_P(CMDBUFFER_CURRENT_STRING, PSTR("TMC_"), 4) == 0)
{
if (strncmp_P(CMDBUFFER_CURRENT_STRING + 4, PSTR("SET_WAVE_E"), 10) == 0)
if (strncmp_P(CMDBUFFER_CURRENT_STRING + 4, PSTR("SET_WAVE_"), 9) == 0)
{
uint8_t fac = (uint8_t)strtol(CMDBUFFER_CURRENT_STRING + 14, NULL, 10);
tmc2130_set_wave(E_AXIS, 247, fac);
uint8_t axis = *(CMDBUFFER_CURRENT_STRING + 13);
axis = (axis == 'E')?3:(axis - 'X');
if (axis < 4)
{
uint8_t fac = (uint8_t)strtol(CMDBUFFER_CURRENT_STRING + 14, NULL, 10);
tmc2130_set_wave(axis, 247, fac);
}
}
else if (strncmp_P(CMDBUFFER_CURRENT_STRING + 4, PSTR("SET_STEP_E"), 10) == 0)
else if (strncmp_P(CMDBUFFER_CURRENT_STRING + 4, PSTR("SET_STEP_"), 9) == 0)
{
uint8_t step = (uint8_t)strtol(CMDBUFFER_CURRENT_STRING + 14, NULL, 10);
uint16_t res = tmc2130_get_res(E_AXIS);
tmc2130_goto_step(E_AXIS, step & (4*res - 1), 2, 1000, res);
uint8_t axis = *(CMDBUFFER_CURRENT_STRING + 13);
axis = (axis == 'E')?3:(axis - 'X');
if (axis < 4)
{
uint8_t step = (uint8_t)strtol(CMDBUFFER_CURRENT_STRING + 14, NULL, 10);
uint16_t res = tmc2130_get_res(axis);
tmc2130_goto_step(axis, step & (4*res - 1), 2, 1000, res);
}
}
else if (strncmp_P(CMDBUFFER_CURRENT_STRING + 4, PSTR("SET_CHOP_"), 9) == 0)
{
uint8_t axis = *(CMDBUFFER_CURRENT_STRING + 13);
axis = (axis == 'E')?3:(axis - 'X');
if (axis < 4)
{
uint8_t chop0 = tmc2130_chopper_config[axis].toff;
uint8_t chop1 = tmc2130_chopper_config[axis].hstr;
uint8_t chop2 = tmc2130_chopper_config[axis].hend;
uint8_t chop3 = tmc2130_chopper_config[axis].tbl;
char* str_end = 0;
if (CMDBUFFER_CURRENT_STRING[14])
{
chop0 = (uint8_t)strtol(CMDBUFFER_CURRENT_STRING + 14, &str_end, 10) & 15;
if (str_end && *str_end)
{
chop1 = (uint8_t)strtol(str_end, &str_end, 10) & 7;
if (str_end && *str_end)
{
chop2 = (uint8_t)strtol(str_end, &str_end, 10) & 15;
if (str_end && *str_end)
chop3 = (uint8_t)strtol(str_end, &str_end, 10) & 3;
}
}
}
tmc2130_chopper_config[axis].toff = chop0;
tmc2130_chopper_config[axis].hstr = chop1 & 7;
tmc2130_chopper_config[axis].hend = chop2 & 15;
tmc2130_chopper_config[axis].tbl = chop3 & 3;
tmc2130_setup_chopper(axis, tmc2130_mres[axis], tmc2130_current_h[axis], tmc2130_current_r[axis]);
//printf_P(_N("TMC_SET_CHOP_%c %hhd %hhd %hhd %hhd\n"), "xyze"[axis], chop0, chop1, chop2, chop3);
}
}
}
#endif //TMC2130
@ -3259,6 +3334,20 @@ void process_commands()
}
else if (code_seen("thx")) {
no_response = false;
} else if (code_seen("RESET")) {
// careful!
if (farm_mode) {
#ifdef WATCHDOG
wdt_enable(WDTO_15MS);
cli();
while(1);
#else //WATCHDOG
asm volatile("jmp 0x3E000");
#endif //WATCHDOG
}
else {
MYSERIAL.println("Not in farm mode.");
}
}else if (code_seen("fv")) {
// get file version
#ifdef SDSUPPORT
@ -4377,6 +4466,7 @@ void process_commands()
}
KEEPALIVE_STATE(NOT_BUSY);
// Restore custom message state
lcd_setstatuspgm(_T(WELCOME_MSG));
custom_message = custom_message_old;
custom_message_type = custom_message_type_old;
custom_message_state = custom_message_state_old;
@ -6986,6 +7076,45 @@ Sigma_Exit:
tmp_extruder = code_value();
}
snmm_filaments_used |= (1 << tmp_extruder); //for stop print
#ifdef SNMM_V2
printf_P(PSTR("T code: %d \n"), tmp_extruder);
switch (tmp_extruder)
{
case 1:
fprintf_P(uart2io, PSTR("T1\n"));
break;
case 2:
fprintf_P(uart2io, PSTR("T2\n"));
break;
case 3:
fprintf_P(uart2io, PSTR("T3\n"));
break;
case 4:
fprintf_P(uart2io, PSTR("T4\n"));
break;
default:
fprintf_P(uart2io, PSTR("T0\n"));
break;
}
// get response
uart2_rx_clr();
while (!uart2_rx_ok())
{
//printf_P(PSTR("waiting..\n"));
delay_keep_alive(100);
}
#endif
#ifdef SNMM
#ifdef LIN_ADVANCE
@ -7148,8 +7277,8 @@ void FlushSerialRequestResend()
void ClearToSend()
{
previous_millis_cmd = millis();
if ((CMDBUFFER_CURRENT_TYPE == CMDBUFFER_CURRENT_TYPE_USB) || (CMDBUFFER_CURRENT_TYPE == CMDBUFFER_CURRENT_TYPE_USB_WITH_LINENR))
SERIAL_PROTOCOLLNRPGM(_T(MSG_OK));
if ((CMDBUFFER_CURRENT_TYPE == CMDBUFFER_CURRENT_TYPE_USB) || (CMDBUFFER_CURRENT_TYPE == CMDBUFFER_CURRENT_TYPE_USB_WITH_LINENR))
SERIAL_PROTOCOLLNRPGM(_T(MSG_OK));
}
#if MOTHERBOARD == BOARD_RAMBO_MINI_1_0 || MOTHERBOARD == BOARD_RAMBO_MINI_1_3
@ -7297,6 +7426,7 @@ void clamp_to_software_endstops(float target[3])
float de = e - current_position[E_AXIS];
for (int i = 1; i < n_segments; ++ i) {
float t = float(i) / float(n_segments);
if (saved_printing || (mbl.active == false)) return;
plan_buffer_line(
current_position[X_AXIS] + t * dx,
current_position[Y_AXIS] + t * dy,
@ -8792,11 +8922,11 @@ void stop_and_save_print_to_ram(float z_move, float e_move)
uint16_t value;
} sdlen_single;
int _bufindr = bufindr;
for (int _buflen = buflen; _buflen > 0; ++ iline) {
for (int _buflen = buflen; _buflen > 0; ++ iline) {
if (cmdbuffer[_bufindr] == CMDBUFFER_CURRENT_TYPE_SDCARD) {
sdlen_single.lohi.lo = cmdbuffer[_bufindr + 1];
sdlen_single.lohi.hi = cmdbuffer[_bufindr + 2];
}
}
SERIAL_ECHOPGM("Buffer line (from buffer): ");
MYSERIAL.print(int(iline), DEC);
SERIAL_ECHOPGM(", type: ");
@ -8807,7 +8937,6 @@ void stop_and_save_print_to_ram(float z_move, float e_move)
MYSERIAL.println(cmdbuffer + _bufindr + CMDHDRSIZE);
SERIAL_ECHOPGM("Buffer line (from file): ");
MYSERIAL.print(int(iline), DEC);
MYSERIAL.println(int(iline), DEC);
for (; sdlen_single.value > 0; -- sdlen_single.value)
MYSERIAL.print(char(card.get()));
@ -8840,7 +8969,7 @@ void stop_and_save_print_to_ram(float z_move, float e_move)
saved_active_extruder = active_extruder; //save active_extruder
saved_extruder_under_pressure = extruder_under_pressure; //extruder under pressure flag - currently unused
saved_extruder_relative_mode = axis_relative_modes[E_AXIS];
cmdqueue_reset(); //empty cmdqueue
card.sdprinting = false;
// card.closefile();
@ -8854,10 +8983,16 @@ void stop_and_save_print_to_ram(float z_move, float e_move)
char buf[48];
// First unretract (relative extrusion)
if(!saved_extruder_relative_mode){
strcpy_P(buf, PSTR("M83"));
enquecommand(buf, false);
}
//retract 45mm/s
strcpy_P(buf, PSTR("G1 E"));
dtostrf(e_move, 6, 3, buf + strlen(buf));
strcat_P(buf, PSTR(" F"));
dtostrf(retract_feedrate*60, 8, 3, buf + strlen(buf));
dtostrf(2700, 8, 3, buf + strlen(buf));
enquecommand(buf, false);
// Then lift Z axis
@ -8886,26 +9021,37 @@ void restore_print_from_ram_and_continue(float e_move)
// current_position[axis] = st_get_position_mm(axis);
active_extruder = saved_active_extruder; //restore active_extruder
feedrate = saved_feedrate2; //restore feedrate
axis_relative_modes[E_AXIS] = saved_extruder_relative_mode;
float e = saved_pos[E_AXIS] - e_move;
plan_set_e_position(e);
plan_buffer_line(saved_pos[X_AXIS], saved_pos[Y_AXIS], saved_pos[Z_AXIS], saved_pos[E_AXIS], homing_feedrate[Z_AXIS]/13, active_extruder);
//first move print head in XY to the saved position:
plan_buffer_line(saved_pos[X_AXIS], saved_pos[Y_AXIS], current_position[Z_AXIS], saved_pos[E_AXIS] - e_move, homing_feedrate[Z_AXIS]/13, active_extruder);
st_synchronize();
//then move Z
plan_buffer_line(saved_pos[X_AXIS], saved_pos[Y_AXIS], saved_pos[Z_AXIS], saved_pos[E_AXIS] - e_move, homing_feedrate[Z_AXIS]/13, active_extruder);
st_synchronize();
//and finaly unretract (35mm/s)
plan_buffer_line(saved_pos[X_AXIS], saved_pos[Y_AXIS], saved_pos[Z_AXIS], saved_pos[E_AXIS], 35, active_extruder);
st_synchronize();
memcpy(current_position, saved_pos, sizeof(saved_pos));
memcpy(destination, current_position, sizeof(destination));
if (saved_printing_type == PRINTING_TYPE_SD) { //was sd printing
card.setIndex(saved_sdpos);
sdpos_atomic = saved_sdpos;
card.sdprinting = true;
printf_P(PSTR("ok\n")); //dummy response because of octoprint is waiting for this
}
else if (saved_printing_type == PRINTING_TYPE_USB) { //was usb printing
gcode_LastN = saved_sdpos; //saved_sdpos was reused for storing line number when usb printing
serial_count = 0;
FlushSerialRequestResend();
}
else {
//not sd printing nor usb printing
}
lcd_setstatuspgm(_T(WELCOME_MSG));
saved_printing = false;
}
void print_world_coordinates()

View File

@ -385,7 +385,8 @@ void get_command()
rx_buffer_full = true; //sets flag that buffer was full
}
while (MYSERIAL.available() > 0) {
// start of serial line processing loop
while (MYSERIAL.available() > 0 && !saved_printing) { //is print is saved (crash detection or filament detection), dont process data from serial line
char serial_char = MYSERIAL.read();
/* if (selectedSerialPort == 1)

View File

@ -27,9 +27,9 @@
#define W25X20CL_SPSR SPI_SPSR(W25X20CL_SPI_RATE)
//LANG - Multi-language support
//#define LANG_MODE 0 // primary language only
#define LANG_MODE 1 // sec. language support
#define LANG_SIZE_RESERVED 0x2700 // reserved space for secondary language (~10kb)
//#define LANG_MODE 0 // primary language only
#define LANG_MODE 1 // sec. language support
#define LANG_SIZE_RESERVED 0x2400 // reserved space for secondary language (~12kb)
//#define LANG_SIZE_RESERVED 0x1ef8 // reserved space for secondary language (~10kb)

View File

@ -5,6 +5,7 @@
#include "bootapp.h"
#include "Configuration.h"
#include "pins.h"
#ifdef W25X20CL
#include "w25x20cl.h"
@ -28,6 +29,9 @@ uint8_t lang_is_selected(void) { return 1; }
//reserved xx kbytes for secondary language table
const char _SEC_LANG[LANG_SIZE_RESERVED] PROGMEM_I2 = "_SEC_LANG";
//primary language signature
const uint32_t _PRI_LANG_SIGNATURE[1] __attribute__((section(".progmem0"))) = {0xffffffff};
//lang_table pointer
lang_table_t* lang_table = 0;
@ -56,11 +60,28 @@ uint8_t lang_select(uint8_t lang)
{
if (pgm_read_dword(((uint32_t*)_SEC_LANG_TABLE)) == LANG_MAGIC) //magic valid
{
lang_table = _SEC_LANG_TABLE; // set table pointer
lang_selected = lang; // set language id
if (lang_check(_SEC_LANG_TABLE))
if (pgm_read_dword(((uint32_t*)(_SEC_LANG_TABLE + 12))) == pgm_read_dword(((uint32_t*)(_PRI_LANG_SIGNATURE)))) //signature valid
{
lang_table = _SEC_LANG_TABLE; // set table pointer
lang_selected = lang; // set language id
}
}
}
#else //W25X20CL
if (lang == LANG_ID_SEC)
{
uint16_t table = _SEC_LANG_TABLE;
if (pgm_read_dword(((uint32_t*)table)) == LANG_MAGIC) //magic valid
{
if (lang_check(table))
if (pgm_read_dword(((uint32_t*)(table + 12))) == pgm_read_dword(((uint32_t*)(_PRI_LANG_SIGNATURE)))) //signature valid
{
lang_table = table; // set table pointer
lang_selected = lang; // set language id
}
}
}
#endif //W25X20CL
if (lang_selected == lang)
{
@ -70,8 +91,22 @@ uint8_t lang_select(uint8_t lang)
return 0;
}
uint8_t lang_check(uint16_t addr)
{
uint16_t sum = 0;
uint16_t size = pgm_read_word((uint16_t*)(addr + 4));
uint16_t lt_sum = pgm_read_word((uint16_t*)(addr + 8));
uint16_t i; for (i = 0; i < size; i++)
sum += (uint16_t)pgm_read_byte((uint8_t*)(addr + i)) << ((i & 1)?0:8);
sum -= lt_sum; //subtract checksum
sum = (sum >> 8) | ((sum & 0xff) << 8); //swap bytes
return (sum == lt_sum);
}
uint8_t lang_get_count()
{
if (pgm_read_dword(((uint32_t*)(_PRI_LANG_SIGNATURE))) == 0xffffffff)
return 1; //signature not set - only primary language will be available
#ifdef W25X20CL
W25X20CL_SPI_ENTER();
uint8_t count = 2; //count = 1+n (primary + secondary + all in xflash)
@ -84,9 +119,16 @@ uint8_t lang_get_count()
addr += header.size; //calc address of next table
count++; //inc counter
}
return count;
#else //W25X20CL
uint16_t table = _SEC_LANG_TABLE;
uint8_t count = 1; //count = 1 (primary)
while (pgm_read_dword(((uint32_t*)table)) == LANG_MAGIC) //magic valid
{
table += pgm_read_word((uint16_t*)(table + 4));
count++;
}
#endif //W25X20CL
return count;
}
uint8_t lang_get_header(uint8_t lang, lang_table_header_t* header, uint32_t* offset)
@ -98,7 +140,7 @@ uint8_t lang_get_header(uint8_t lang, lang_table_header_t* header, uint32_t* off
uint16_t ui = _SEC_LANG_TABLE; //table pointer
memcpy_P(header, ui, sizeof(lang_table_header_t)); //read table header from progmem
if (offset) *offset = ui;
return (header == LANG_MAGIC)?1:0; //return 1 if magic valid
return (header->magic == LANG_MAGIC)?1:0; //return 1 if magic valid
}
W25X20CL_SPI_ENTER();
uint32_t addr = 0x00000; //start of xflash
@ -111,9 +153,16 @@ uint8_t lang_get_header(uint8_t lang, lang_table_header_t* header, uint32_t* off
if (--lang == 0) return 1;
addr += header->size; //calc address of next table
}
return 0;
#else //W25X20CL
if (lang == LANG_ID_SEC)
{
uint16_t ui = _SEC_LANG_TABLE; //table pointer
memcpy_P(header, ui, sizeof(lang_table_header_t)); //read table header from progmem
if (offset) *offset = ui;
return (header->magic == LANG_MAGIC)?1:0; //return 1 if magic valid
}
#endif //W25X20CL
return 0;
}
uint16_t lang_get_code(uint8_t lang)
@ -138,14 +187,15 @@ uint16_t lang_get_code(uint8_t lang)
addr += header.size; //calc address of next table
}
#else //W25X20CL
uint16_t table = _SEC_LANG_TABLE;
uint8_t count = 1; //count = 1 (primary)
while (pgm_read_dword((uint32_t*)table) == LANG_MAGIC) //magic valid
{
if (count == lang) return pgm_read_word(((uint16_t*)(table + 10))); //read language code
table += pgm_read_word((uint16_t*)(table + 4));
count++;
}
#endif //W25X20CL
// if (lang == LANG_ID_SEC)
// {
// uint16_t ui = _SEC_LANG_TABLE; //table pointer
// if (pgm_read_dword(((uint32_t*)(ui + 0))) == LANG_MAGIC) //magic num is OK
// return pgm_read_word(((uint16_t*)(ui + 10))); //read language code
// }
return LANG_CODE_XX;
}

View File

@ -2,7 +2,6 @@
#ifndef LANGUAGE_H
#define LANGUAGE_H
#define W25X20CL
#include "config.h"
#include <inttypes.h>
@ -52,7 +51,7 @@ typedef struct
uint16_t count; //+6
uint16_t checksum; //+8
uint16_t code; //+10
uint32_t reserved1; //+12
uint32_t signature; //+12
} lang_table_header_t;
//lang_table_t structure - (size= 16byte + 2*count)
@ -98,10 +97,13 @@ extern uint8_t lang_selected;
extern const char _SEC_LANG[LANG_SIZE_RESERVED];
extern const char* lang_get_translation(const char* s);
#define _SEC_LANG_TABLE ((((uint16_t)&_SEC_LANG) + 0x00ff) & 0xff00)
//extern const uint32_t _PRI_LANG_SIGNATURE;
#endif //(LANG_MODE != 0)
//selects language, eeprom is updated in case of success
extern uint8_t lang_select(uint8_t lang);
//performs checksum test of secondary language data
extern uint8_t lang_check(uint16_t addr);
//returns total number of languages (primary + all in xflash)
extern uint8_t lang_get_count(void);
//reads lang table header and offset in xflash or progmem

View File

@ -2845,11 +2845,11 @@ bool sample_mesh_and_store_reference()
{
// Verify the span of the Z values.
float zmin = mbl.z_values[0][0];
float zmax = zmax;
float zmax = zmin;
for (int8_t j = 0; j < 3; ++ j)
for (int8_t i = 0; i < 3; ++ i) {
zmin = min(zmin, mbl.z_values[j][i]);
zmax = min(zmax, mbl.z_values[j][i]);
zmax = max(zmax, mbl.z_values[j][i]);
}
if (zmax - zmin > 3.f) {
// The span of the Z offsets is extreme. Give up.

View File

@ -5,6 +5,7 @@
#include "Marlin.h"
#include "w25x20cl.h"
#include "stk500.h"
#include "bootapp.h"
#define OPTIBOOT_MAJVER 6
#define OPTIBOOT_CUSTOMVER 0
@ -98,6 +99,7 @@ extern struct block_t *block_buffer;
void optiboot_w25x20cl_enter()
{
if (boot_app_flags & BOOT_APP_FLG_USER0) return;
uint8_t ch;
uint8_t rampz = 0;
register uint16_t address = 0;

View File

@ -16,7 +16,7 @@
#define PAT9125_SWI2C
#define PAT9125_SWI2C_SDA 20 //SDA on P3
#define PAT9125_SWI2C_SCL 21 //SCL on P3
#define PAT9125_SWI2C_SCL 84 //PH2 on P3, sensor cable must be rewired
#define PAT9125_SWI2C_CFG 0xb1 //2us clock delay, 2048 cycles timeout
//#define PAT9125_HWI2C

65
Firmware/rbuf.c Normal file
View File

@ -0,0 +1,65 @@
//rbuf.c
#include "rbuf.h"
//#include <avr/interrupt.h>
void rbuf_ini(uint8_t* ptr, uint8_t l)
{
ptr[0] = l;
ptr[1] = 0;
ptr[2] = 0;
}
//lock/unlock macros
//#define _lock() uint8_t _sreg = SREG; cli();
//#define _unlock() SREG = _sreg;
#define _lock()
#define _unlock()
//put single byte to buffer
int rbuf_put(uint8_t* ptr, uint8_t b)
{
//#ifdef _NO_ASM
_lock(); //lock
uint8_t buf_w = ptr[1]; //get write index
uint8_t buf_r = ptr[2]; //get read index
_unlock(); //unlock
ptr[4 + buf_w] = b; //store byte to buffer
buf_w++; //incerment write index
uint8_t buf_l = ptr[0]; //get length
if (buf_w >= buf_l) buf_w = 0; //rotate write index
if (buf_w == buf_r) return -1; //return -1 to signal buffer full
ptr[1] = buf_w; //store write index
return 0; //return 0 to signal success
//#else //_NO_ASM
// TODO - optimized assembler version
// asm("movw r26, r24");
// asm("ld r18, X+");
// asm("cli");
// asm("ld r19, X+");
// asm("ld r20, X");
// asm("cp r19, r18");
// asm("brne .-6");*/
//#endif //_NO_ASM
}
//get single byte from buffer
int rbuf_get(uint8_t* ptr)
{
//#ifdef _NO_ASM
_lock(); //lock
uint8_t buf_w = ptr[1]; //get write index
uint8_t buf_r = ptr[2]; //get read index
_unlock(); //unlock
if (buf_r == buf_w) return -1; //return -1 to signal buffer empty
int ret = ptr[4 + buf_r]; //get byte from buffer
buf_r++; //increment read index
uint8_t buf_l = ptr[0]; //get length
if (buf_r >= buf_l) buf_r = 0; //rotate read index
ptr[2] = buf_r; //store read index
return ret; //return byte (0-255)
// return 0; //return 0 to signal success
//#else //_NO_ASM
// TODO - optimized assembler version
//#endif //_NO_ASM
}

27
Firmware/rbuf.h Normal file
View File

@ -0,0 +1,27 @@
//rbuf.h
#ifndef _RBUF_H
#define _RBUF_H
#include <inttypes.h>
#define rbuf_l(ptr) (ptr[0])
#define rbuf_w(ptr) (ptr[1])
#define rbuf_r(ptr) (ptr[2])
#define rbuf_empty(ptr) (ptr[1] == ptr[2])
#if defined(__cplusplus)
extern "C" {
#endif //defined(__cplusplus)
extern void rbuf_ini(uint8_t* ptr, uint8_t len);
extern int rbuf_put(uint8_t* ptr, uint8_t val);
extern int rbuf_get(uint8_t* ptr);
#if defined(__cplusplus)
}
#endif //defined(__cplusplus)
#endif //_RBUF_H

View File

@ -62,6 +62,13 @@ uint8_t tmc2130_home_fsteps[2] = {48, 48};
uint8_t tmc2130_wave_fac[4] = {0, 0, 0, 0};
tmc2130_chopper_config_t tmc2130_chopper_config[4] = {
{TMC2130_TOFF_XYZ, 5, 1, 2, 0},
{TMC2130_TOFF_XYZ, 5, 1, 2, 0},
{TMC2130_TOFF_XYZ, 5, 1, 2, 0},
{TMC2130_TOFF_E, 5, 1, 2, 0}
};
bool tmc2130_sg_stop_on_crash = true;
uint8_t tmc2130_sg_diag_mask = 0x00;
uint8_t tmc2130_sg_crash = 0;
@ -418,13 +425,13 @@ void tmc2130_check_overtemp()
void tmc2130_setup_chopper(uint8_t axis, uint8_t mres, uint8_t current_h, uint8_t current_r)
{
uint8_t intpol = 1;
uint8_t toff = TMC2130_TOFF_XYZ; // toff = 3 (fchop = 27.778kHz)
uint8_t hstrt = 5; //initial 4, modified to 5
uint8_t hend = 1;
uint8_t toff = tmc2130_chopper_config[axis].toff; // toff = 3 (fchop = 27.778kHz)
uint8_t hstrt = tmc2130_chopper_config[axis].hstr; //initial 4, modified to 5
uint8_t hend = tmc2130_chopper_config[axis].hend; //original value = 1
uint8_t fd3 = 0;
uint8_t rndtf = 0; //random off time
uint8_t chm = 0; //spreadCycle
uint8_t tbl = 2; //blanking time
uint8_t tbl = tmc2130_chopper_config[axis].tbl; //blanking time, original value = 2
if (axis == E_AXIS)
{
#ifdef TMC2130_CNSTOFF_E
@ -434,9 +441,11 @@ void tmc2130_setup_chopper(uint8_t axis, uint8_t mres, uint8_t current_h, uint8_
hend = 0; //sine wave offset
chm = 1; // constant off time mod
#endif //TMC2130_CNSTOFF_E
toff = TMC2130_TOFF_E; // toff = 3-5
// toff = TMC2130_TOFF_E; // toff = 3-5
// rndtf = 1;
}
DBG(_n("tmc2130_setup_chopper(axis=%hhd, mres=%hhd, curh=%hhd, curr=%hhd\n"), axis, mres, current_h, current_r);
DBG(_n(" toff=%hhd, hstr=%hhd, hend=%hhd, tbl=%hhd\n"), toff, hstrt, hend, tbl);
if (current_r <= 31)
{
tmc2130_wr_CHOPCONF(axis, toff, hstrt, hend, fd3, 0, rndtf, chm, tbl, 1, 0, 0, 0, mres, intpol, 0, 0);
@ -475,10 +484,7 @@ void tmc2130_print_currents()
void tmc2130_set_pwm_ampl(uint8_t axis, uint8_t pwm_ampl)
{
MYSERIAL.print("tmc2130_set_pwm_ampl ");
MYSERIAL.print((int)axis);
MYSERIAL.print(" ");
MYSERIAL.println((int)pwm_ampl);
DBG(_n("tmc2130_set_pwm_ampl(axis=%hhd, pwm_ampl=%hhd\n"), axis, pwm_ampl);
tmc2130_pwm_ampl[axis] = pwm_ampl;
if (((axis == 0) || (axis == 1)) && (tmc2130_mode == TMC2130_MODE_SILENT))
tmc2130_wr_PWMCONF(axis, tmc2130_pwm_ampl[axis], tmc2130_pwm_grad[axis], tmc2130_pwm_freq[axis], tmc2130_pwm_auto[axis], 0, 0);
@ -486,10 +492,7 @@ void tmc2130_set_pwm_ampl(uint8_t axis, uint8_t pwm_ampl)
void tmc2130_set_pwm_grad(uint8_t axis, uint8_t pwm_grad)
{
MYSERIAL.print("tmc2130_set_pwm_grad ");
MYSERIAL.print((int)axis);
MYSERIAL.print(" ");
MYSERIAL.println((int)pwm_grad);
DBG(_n("tmc2130_set_pwm_grad(axis=%hhd, pwm_grad=%hhd\n"), axis, pwm_grad);
tmc2130_pwm_grad[axis] = pwm_grad;
if (((axis == 0) || (axis == 1)) && (tmc2130_mode == TMC2130_MODE_SILENT))
tmc2130_wr_PWMCONF(axis, tmc2130_pwm_ampl[axis], tmc2130_pwm_grad[axis], tmc2130_pwm_freq[axis], tmc2130_pwm_auto[axis], 0, 0);

View File

@ -36,6 +36,19 @@ extern uint8_t tmc2130_home_fsteps[2];
extern uint8_t tmc2130_wave_fac[4];
#pragma pack(push)
#pragma pack(1)
typedef struct
{
uint8_t toff:4;
uint8_t hstr:3;
uint8_t hend:4;
uint8_t tbl:2;
uint8_t res:3;
} tmc2130_chopper_config_t;
#pragma pack(pop)
extern tmc2130_chopper_config_t tmc2130_chopper_config[4];
//initialize tmc2130
extern void tmc2130_init();
@ -55,6 +68,7 @@ extern void tmc2130_sg_meassure_start(uint8_t axis);
//stop current stallguard meassuring and report result
extern uint16_t tmc2130_sg_meassure_stop();
extern void tmc2130_setup_chopper(uint8_t axis, uint8_t mres, uint8_t current_h, uint8_t current_r);
//set holding current for any axis (M911)
extern void tmc2130_set_current_h(uint8_t axis, uint8_t current);
@ -80,6 +94,7 @@ extern bool tmc2130_wait_standstill_xy(int timeout);
extern void tmc2130_eeprom_load_config();
extern void tmc2130_eeprom_save_config();
#pragma pack(push)
#pragma pack(1)
struct

79
Firmware/uart2.c Normal file
View File

@ -0,0 +1,79 @@
//uart2.c
#include "uart2.h"
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include "rbuf.h"
#define UART2_BAUD 115200
#define UART_BAUD_SELECT(baudRate,xtalCpu) (((float)(xtalCpu))/(((float)(baudRate))*8.0)-1.0+0.5)
#define uart2_rxcomplete (UCSR2A & (1 << RXC2))
#define uart2_txcomplete (UCSR2A & (1 << TXC2))
#define uart2_txready (UCSR2A & (1 << UDRE2))
uint8_t uart2_ibuf[10] = {0, 0};
FILE _uart2io = {0};
int uart2_putchar(char c, FILE *stream)
{
while (!uart2_txready);
UDR2 = c; // transmit byte
// while (!uart2_txcomplete); // wait until byte sent
// UCSR2A |= (1 << TXC2); // delete TXCflag
return 0;
}
int uart2_getchar(FILE *stream)
{
if (rbuf_empty(uart2_ibuf)) return -1;
return rbuf_get(uart2_ibuf);
}
void uart2_init(void)
{
rbuf_ini(uart2_ibuf, 6);
UCSR2A |= (1 << U2X2); // baudrate multiplier
UBRR2L = UART_BAUD_SELECT(UART2_BAUD, F_CPU); // select baudrate
UCSR2B = (1 << RXEN2) | (1 << TXEN2); // enable receiver and transmitter
UCSR2B |= (1 << RXCIE2); // enable rx interrupt
fdev_setup_stream(uart2io, uart2_putchar, uart2_getchar, _FDEV_SETUP_WRITE | _FDEV_SETUP_READ); //setup uart2 i/o stream
}
uint8_t uart2_rx_clr(void)
{
rbuf_w(uart2_ibuf) = 0;
rbuf_r(uart2_ibuf) = 0;
}
uint8_t uart2_rx_ok(void)
{
//printf_P(PSTR("uart2_rx_ok %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu %hhu\n"), uart2_ibuf[0], uart2_ibuf[1], uart2_ibuf[2], uart2_ibuf[3], uart2_ibuf[4], uart2_ibuf[5], uart2_ibuf[6], uart2_ibuf[7], uart2_ibuf[8], uart2_ibuf[9]);
// return 0;
// _lock(); //lock
uint8_t i = rbuf_w(uart2_ibuf); //get write index
// _unlock(); //unlock
uint8_t e = rbuf_l(uart2_ibuf) - 1; //get end index
// printf_P(PSTR("%d %d \n"), i, e);
// return 0;
if ((i--) == 255) i = e; //decrement index
if ((uart2_ibuf[4 + i] != '\n') &&
(uart2_ibuf[4 + i] != '\r')) return 0; //no match - exit
if ((i--) == 255) i = e; //decrement index
if (uart2_ibuf[4 + i] != 'k') return 0; //no match - exit
if ((i--) == 255) i = e; //decrement index
if (uart2_ibuf[4 + i] != 'o') return 0; //no match - exit
uart2_ibuf[4 + i] = 0; //discard char
return 1; //match "ok\n"
}
ISR(USART2_RX_vect)
{
//printf_P(PSTR("USART2_RX_vect \n") );
if (rbuf_put(uart2_ibuf, UDR2) < 0) // put received byte to buffer
{
//rx buffer full
}
}

29
Firmware/uart2.h Normal file
View File

@ -0,0 +1,29 @@
//uart2.h
#ifndef _UART2_H
#define _UART2_H
#include <inttypes.h>
#include <stdio.h>
#if defined(__cplusplus)
extern "C" {
#endif //defined(__cplusplus)
extern FILE _uart2io;
#define uart2io (&_uart2io)
//extern uint8_t uart2_ibuf[10];
extern void uart2_init(void);
extern uint8_t uart2_rx_clr(void);
extern uint8_t uart2_rx_ok(void);
#if defined(__cplusplus)
}
#endif //defined(__cplusplus)
#endif //_UART2_H

File diff suppressed because it is too large Load Diff

View File

@ -699,7 +699,7 @@ static inline void lcd_print_percent_done() {
{
lcd_printPGM(PSTR("---"));
}
lcd.print('%');
lcd_printPGM(PSTR("% "));
}
static inline void lcd_print_time() {
@ -718,8 +718,14 @@ static inline void lcd_print_time() {
lcd.print(itostr2(print_t/60));
lcd.print(':');
lcd.print(itostr2(print_t%60));
(print_time_remaining_normal != PRINT_TIME_REMAINING_INIT) ? lcd.print('R') : lcd.print(' ');
(feedmultiply == 100) ? lcd.print(' ') : lcd.print('?');
if (print_time_remaining_normal != PRINT_TIME_REMAINING_INIT)
{
lcd.print('R');
(feedmultiply == 100) ? lcd.print(' ') : lcd.print('?');
}
else {
lcd_printPGM(PSTR(" "));
}
}else{
lcd_printPGM(PSTR("--:-- "));
}
@ -828,7 +834,7 @@ if (print_sd_status)
// Farm number display
if (farm_mode)
{
lcd.setCursor(0, 6);
lcd.setCursor(6, 2);
lcd_printPGM(PSTR(" F"));
lcd.print(farm_no);
lcd_printPGM(PSTR(" "));
@ -1352,18 +1358,7 @@ static void lcd_implementation_drawmenu_sddirectory(uint8_t row, const char* pst
while(n--)
lcd.print(' ');
}
#define lcd_implementation_drawmenu_back_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
#define lcd_implementation_drawmenu_back(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_UPLEVEL[0])
#define lcd_implementation_drawmenu_back_RAM_selected(row, str, data) lcd_implementation_drawmenu_generic_RAM(row, str, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
#define lcd_implementation_drawmenu_back_RAM(row, str, data) lcd_implementation_drawmenu_generic_RAM(row, str, ' ', LCD_STR_UPLEVEL[0])
#define lcd_implementation_drawmenu_submenu_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
#define lcd_implementation_drawmenu_submenu(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_ARROW_RIGHT[0])
#define lcd_implementation_drawmenu_gcode_selected(row, pstr, gcode) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ')
#define lcd_implementation_drawmenu_gcode(row, pstr, gcode) lcd_implementation_drawmenu_generic(row, pstr, ' ', ' ')
#define lcd_implementation_drawmenu_function_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ')
#define lcd_implementation_drawmenu_function(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', ' ')
#define lcd_implementation_drawmenu_setlang_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ')
#define lcd_implementation_drawmenu_setlang(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', ' ')
static void lcd_implementation_quick_feedback()
{

View File

@ -467,6 +467,8 @@
// FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles.
#endif // PIDTEMPBED
//connect message when communication with monitoring broken
//#define FARM_CONNECT_MESSAGE
/*-----------------------------------
PREHEAT SETTINGS
@ -598,7 +600,7 @@
#define MIN_PRINT_FAN_SPEED 75
#ifdef SNMM
#if defined (SNMM) || defined (SNMM_V2)
#define DEFAULT_RETRACTION 4 //used for PINDA temp calibration and pause print
#else
#define DEFAULT_RETRACTION 1 //used for PINDA temp calibration and pause print

View File

@ -0,0 +1,627 @@
#ifndef CONFIGURATION_PRUSA_H
#define CONFIGURATION_PRUSA_H
/*------------------------------------
GENERAL SETTINGS
*------------------------------------*/
// Printer revision
#define PRINTER_TYPE PRINTER_MK3
#define FILAMENT_SIZE "1_75mm_MK3"
#define NOZZLE_TYPE "E3Dv6full"
// Developer flag
#define DEVELOPER
// Printer name
#define CUSTOM_MENDEL_NAME "Prusa i3 MK3"
// Electronics
#define MOTHERBOARD BOARD_EINSY_1_0a
#define STEEL_SHEET
#define HAS_SECOND_SERIAL_PORT
#define SNMM_V2
// Uncomment the below for the E3D PT100 temperature sensor (with or without PT100 Amplifier)
//#define E3D_PT100_EXTRUDER_WITH_AMP
//#define E3D_PT100_EXTRUDER_NO_AMP
//#define E3D_PT100_BED_WITH_AMP
//#define E3D_PT100_BED_NO_AMP
/*------------------------------------
AXIS SETTINGS
*------------------------------------*/
// Steps per unit {X,Y,Z,E}
//#define DEFAULT_AXIS_STEPS_PER_UNIT {100,100,3200/8,140}
#define DEFAULT_AXIS_STEPS_PER_UNIT {100,100,3200/8,280}
//#define DEFAULT_AXIS_STEPS_PER_UNIT {100,100,3200/8,560}
// Endstop inverting
#define X_MIN_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop.
#define Y_MIN_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop.
#define Z_MIN_ENDSTOP_INVERTING 0 // set to 1 to invert the logic of the endstop.
// Direction inverting
#define INVERT_X_DIR 1 // for Mendel set to 0, for Orca set to 1
#define INVERT_Y_DIR 0 // for Mendel set to 1, for Orca set to 0
#define INVERT_Z_DIR 1 // for Mendel set to 0, for Orca set to 1
#define INVERT_E0_DIR 0 // for direct drive extruder v9 set to 1, for geared extruder set to 0
#define INVERT_E1_DIR 0 // for direct drive extruder v9 set to 1, for geared extruder set to 0
#define INVERT_E2_DIR 0 // for direct drive extruder v9 set to 1, for geared extruder set to 0
// Home position
#define MANUAL_X_HOME_POS 0
#define MANUAL_Y_HOME_POS -2.2
#define MANUAL_Z_HOME_POS 0.2
// Travel limits after homing
#define X_MAX_POS 255
#define X_MIN_POS 0
#define Y_MAX_POS 212.5
#define Y_MIN_POS -4 //orig -4
#define Z_MAX_POS 210
#define Z_MIN_POS 0.15
// Canceled home position
#define X_CANCEL_POS 50
#define Y_CANCEL_POS 190
//Pause print position
#define X_PAUSE_POS 50
#define Y_PAUSE_POS 190
#define Z_PAUSE_LIFT 20
#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
#define HOMING_FEEDRATE {3000, 3000, 800, 0} // set the homing speeds (mm/min) // 3000 is also valid for stallGuard homing. Valid range: 2200 - 3000
//#define DEFAULT_Y_OFFSET 4.f // Default distance of Y_MIN_POS point from endstop, when the printer is not calibrated.
/**
* [0,0] steel sheet print area point X coordinate in bed print area coordinates
*/
#define SHEET_PRINT_ZERO_REF_X 0.f
/**
* [0,0] steel sheet print area point Y coordinate in bed print area coordinates
*/
#define SHEET_PRINT_ZERO_REF_Y -2.f
#define DEFAULT_MAX_FEEDRATE {200, 200, 12, 120} // (mm/sec) max feedrate (M203)
#define DEFAULT_MAX_ACCELERATION {1000, 1000, 200, 5000} // (mm/sec^2) max acceleration (M201)
#define DEFAULT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for printing moves (M204S)
#define DEFAULT_RETRACT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for retracts (M204T)
#define MANUAL_FEEDRATE {2700, 2700, 1000, 100} // set the speeds for manual moves (mm/min)
//Silent mode limits
#define SILENT_MAX_ACCEL 960 // max axxeleration in silent mode in mm/s^2
#define SILENT_MAX_ACCEL_ST (100*SILENT_MAX_ACCEL) // max accel in steps/s^2
#define SILENT_MAX_FEEDRATE 172 //max feedrate in mm/s, because mode switched to normal for homming , this value limits also homing, it should be greater (172mm/s=9600mm/min>2700mm/min)
//Normal mode limits
#define NORMAL_MAX_ACCEL 2500 // Y-axis max axxeleration in normal mode in mm/s^2
#define NORMAL_MAX_ACCEL_ST (100*NORMAL_MAX_ACCEL) // max accel in steps/s^2
#define NORMAL_MAX_FEEDRATE 200 //max feedrate in mm/s, because mode switched to normal for homming , this value limits also homing, it should be greater (172mm/s=9600mm/min>2700mm/min)
//#define SIMPLE_ACCEL_LIMIT //new limitation method for normal/silent
//number of bytes from end of the file to start check
#define END_FILE_SECTION 10000
#define Z_AXIS_ALWAYS_ON 1
//Crash detection
#define CRASHDET_TIMER 45 //seconds
#define CRASHDET_COUNTER_MAX 3
// New XYZ calibration
#define NEW_XYZCAL
// Watchdog support
#define WATCHDOG
// Power panic
#define UVLO_SUPPORT
// Fan check
#define FANCHECK
// Safety timer
#define SAFETYTIMER
#define DEFAULT_SAFETYTIMER_TIME_MINS 30
// Filament sensor
#define PAT9125
// Disable some commands
#define _DISABLE_M42_M226
// Minimum ambient temperature limit to start triggering MINTEMP errors [C]
// this value is litlebit higher that real limit, because ambient termistor is on the board and is temperated from it,
// temperature inside the case is around 31C for ambient temperature 25C, when the printer is powered on long time and idle
// the real limit is 15C (same as MINTEMP limit), this is because 15C is end of scale for both used thermistors (bed, heater)
#define MINTEMP_MINAMBIENT 25
#define MINTEMP_MINAMBIENT_RAW 978
//#define DEBUG_BUILD
//#define DEBUG_SEC_LANG //secondary language debug output at startup
//#define DEBUG_W25X20CL //debug external spi flash
#ifdef DEBUG_BUILD
//#define _NO_ASM
#define DEBUG_DCODES //D codes
#define DEBUG_STACK_MONITOR //Stack monitor in stepper ISR
//#define DEBUG_FSENSOR_LOG //Reports fsensor status to serial
//#define DEBUG_CRASHDET_COUNTERS //Display crash-detection counters on LCD
//#define DEBUG_RESUME_PRINT //Resume/save print debug enable
//#define DEBUG_UVLO_AUTOMATIC_RECOVER // Power panic automatic recovery debug output
//#define DEBUG_DISABLE_XMINLIMIT //x min limit ignored
//#define DEBUG_DISABLE_XMAXLIMIT //x max limit ignored
//#define DEBUG_DISABLE_YMINLIMIT //y min limit ignored
//#define DEBUG_DISABLE_YMAXLIMIT //y max limit ignored
//#define DEBUG_DISABLE_ZMINLIMIT //z min limit ignored
//#define DEBUG_DISABLE_ZMAXLIMIT //z max limit ignored
#define DEBUG_DISABLE_STARTMSGS //no startup messages
//#define DEBUG_DISABLE_MINTEMP //mintemp error ignored
//#define DEBUG_DISABLE_SWLIMITS //sw limits ignored
//#define DEBUG_DISABLE_LCD_STATUS_LINE //empty four lcd line
//#define DEBUG_DISABLE_PREVENT_EXTRUDER //cold extrusion and long extrusion allowed
//#define DEBUG_DISABLE_PRUSA_STATISTICS //disable prusa_statistics() mesages
//#define DEBUG_DISABLE_FORCE_SELFTEST //disable force selftest
//#define DEBUG_XSTEP_DUP_PIN 21 //duplicate x-step output to pin 21 (SCL on P3)
//#define DEBUG_YSTEP_DUP_PIN 21 //duplicate y-step output to pin 21 (SCL on P3)
//#define DEBUG_BLINK_ACTIVE
//#define DEBUG_DISABLE_FANCHECK //disable fan check (no ISR INT7, check disabled)
//#define DEBUG_DISABLE_FSENSORCHECK //disable fsensor check (no ISR INT7, check disabled)
#define DEBUG_DUMP_TO_2ND_SERIAL //dump received characters to 2nd serial line
#define DEBUG_STEPPER_TIMER_MISSED // Stop on stepper timer overflow, beep and display a message.
#define PLANNER_DIAGNOSTICS // Show the planner queue status on printer display.
#define CMD_DIAGNOSTICS //Show cmd queue length on printer display
#endif /* DEBUG_BUILD */
//#define EXPERIMENTAL_FEATURES
#define TMC2130_LINEARITY_CORRECTION
#define TMC2130_LINEARITY_CORRECTION_XYZ
//#define TMC2130_VARIABLE_RESOLUTION
/*------------------------------------
TMC2130 default settings
*------------------------------------*/
#define TMC2130_FCLK 12000000 // fclk = 12MHz
#define TMC2130_USTEPS_XY 16 // microstep resolution for XY axes
#define TMC2130_USTEPS_Z 16 // microstep resolution for Z axis
#define TMC2130_USTEPS_E 32 // microstep resolution for E axis
#define TMC2130_INTPOL_XY 1 // extrapolate 256 for XY axes
#define TMC2130_INTPOL_Z 1 // extrapolate 256 for Z axis
#define TMC2130_INTPOL_E 1 // extrapolate 256 for E axis
#define TMC2130_PWM_GRAD_X 2 // PWMCONF
#define TMC2130_PWM_AMPL_X 230 // PWMCONF
#define TMC2130_PWM_AUTO_X 1 // PWMCONF
#define TMC2130_PWM_FREQ_X 2 // PWMCONF
#define TMC2130_PWM_GRAD_Y 2 // PWMCONF
#define TMC2130_PWM_AMPL_Y 235 // PWMCONF
#define TMC2130_PWM_AUTO_Y 1 // PWMCONF
#define TMC2130_PWM_FREQ_Y 2 // PWMCONF
#define TMC2130_PWM_GRAD_Z 4 // PWMCONF
#define TMC2130_PWM_AMPL_Z 200 // PWMCONF
#define TMC2130_PWM_AUTO_Z 1 // PWMCONF
#define TMC2130_PWM_FREQ_Z 2 // PWMCONF
#define TMC2130_PWM_GRAD_E 4 // PWMCONF
#define TMC2130_PWM_AMPL_E 240 // PWMCONF
#define TMC2130_PWM_AUTO_E 1 // PWMCONF
#define TMC2130_PWM_FREQ_E 2 // PWMCONF
#define TMC2130_TOFF_XYZ 3 // CHOPCONF // fchop = 27.778kHz
#define TMC2130_TOFF_E 3 // CHOPCONF // fchop = 27.778kHz
//#define TMC2130_TOFF_E 4 // CHOPCONF // fchop = 21.429kHz
//#define TMC2130_TOFF_E 5 // CHOPCONF // fchop = 17.442kHz
//#define TMC2130_STEALTH_E // Extruder stealthChop mode
//#define TMC2130_CNSTOFF_E // Extruder constant-off-time mode (similar to MK2)
//#define TMC2130_PWM_DIV 683 // PWM frequency divider (1024, 683, 512, 410)
#define TMC2130_PWM_DIV 512 // PWM frequency divider (1024, 683, 512, 410)
#define TMC2130_PWM_CLK (2 * TMC2130_FCLK / TMC2130_PWM_DIV) // PWM frequency (23.4kHz, 35.1kHz, 46.9kHz, 58.5kHz for 12MHz fclk)
#define TMC2130_TPWMTHRS 0 // TPWMTHRS - Sets the switching speed threshold based on TSTEP from stealthChop to spreadCycle mode
#define TMC2130_THIGH 0 // THIGH - unused
//#define TMC2130_TCOOLTHRS_X 450 // TCOOLTHRS - coolstep treshold
//#define TMC2130_TCOOLTHRS_Y 450 // TCOOLTHRS - coolstep treshold
#define TMC2130_TCOOLTHRS_X 430 // TCOOLTHRS - coolstep treshold
#define TMC2130_TCOOLTHRS_Y 430 // TCOOLTHRS - coolstep treshold
#define TMC2130_TCOOLTHRS_Z 500 // TCOOLTHRS - coolstep treshold
#define TMC2130_TCOOLTHRS_E 500 // TCOOLTHRS - coolstep treshold
#define TMC2130_SG_HOMING 1 // stallguard homing
#define TMC2130_SG_THRS_X 3 // stallguard sensitivity for X axis
#define TMC2130_SG_THRS_Y 3 // stallguard sensitivity for Y axis
#define TMC2130_SG_THRS_Z 4 // stallguard sensitivity for Z axis
#define TMC2130_SG_THRS_E 3 // stallguard sensitivity for E axis
//new settings is possible for vsense = 1, running current value > 31 set vsense to zero and shift both currents by 1 bit right (Z axis only)
#define TMC2130_CURRENTS_H {16, 20, 35, 30} // default holding currents for all axes
#define TMC2130_CURRENTS_R {16, 20, 35, 30} // default running currents for all axes
#define TMC2130_UNLOAD_CURRENT_R 12 // lowe current for M600 to protect filament sensor
#define TMC2130_STEALTH_Z
//#define TMC2130_DEBUG
//#define TMC2130_DEBUG_WR
//#define TMC2130_DEBUG_RD
/*------------------------------------
EXTRUDER SETTINGS
*------------------------------------*/
// Mintemps
#define HEATER_0_MINTEMP 15
#define HEATER_1_MINTEMP 5
#define HEATER_2_MINTEMP 5
#define BED_MINTEMP 15
// Maxtemps
#if defined(E3D_PT100_EXTRUDER_WITH_AMP) || defined(E3D_PT100_EXTRUDER_NO_AMP)
#define HEATER_0_MAXTEMP 410
#else
#define HEATER_0_MAXTEMP 305
#endif
#define HEATER_1_MAXTEMP 305
#define HEATER_2_MAXTEMP 305
#define BED_MAXTEMP 125
#if defined(E3D_PT100_EXTRUDER_WITH_AMP) || defined(E3D_PT100_EXTRUDER_NO_AMP)
// Define PID constants for extruder with PT100
#define DEFAULT_Kp 21.70
#define DEFAULT_Ki 1.60
#define DEFAULT_Kd 73.76
#else
// Define PID constants for extruder
//#define DEFAULT_Kp 40.925
//#define DEFAULT_Ki 4.875
//#define DEFAULT_Kd 86.085
#define DEFAULT_Kp 16.13
#define DEFAULT_Ki 1.1625
#define DEFAULT_Kd 56.23
#endif
// Extrude mintemp
#define EXTRUDE_MINTEMP 190
// Extruder cooling fans
#define EXTRUDER_0_AUTO_FAN_PIN 8
#define EXTRUDER_1_AUTO_FAN_PIN -1
#define EXTRUDER_2_AUTO_FAN_PIN -1
#define EXTRUDER_AUTO_FAN_TEMPERATURE 50
#define EXTRUDER_AUTO_FAN_SPEED 255 // == full speed
/*------------------------------------
LOAD/UNLOAD FILAMENT SETTINGS
*------------------------------------*/
// Load filament commands
#define LOAD_FILAMENT_0 "M83"
#define LOAD_FILAMENT_1 "G1 E70 F400"
#define LOAD_FILAMENT_2 "G1 E40 F100"
// Unload filament commands
#define UNLOAD_FILAMENT_0 "M83"
#define UNLOAD_FILAMENT_1 "G1 E-80 F7000"
/*------------------------------------
CHANGE FILAMENT SETTINGS
*------------------------------------*/
// Filament change configuration
#define FILAMENTCHANGEENABLE
#ifdef FILAMENTCHANGEENABLE
#define FILAMENTCHANGE_XPOS 211
#define FILAMENTCHANGE_YPOS 0
#define FILAMENTCHANGE_ZADD 2
#define FILAMENTCHANGE_FIRSTRETRACT -2
#define FILAMENTCHANGE_FINALRETRACT -80
#define FILAMENTCHANGE_FIRSTFEED 70
#define FILAMENTCHANGE_FINALFEED 50
#define FILAMENTCHANGE_RECFEED 5
#define FILAMENTCHANGE_XYFEED 50
#define FILAMENTCHANGE_EFEED 20
//#define FILAMENTCHANGE_RFEED 400
#define FILAMENTCHANGE_RFEED 7000 / 60
#define FILAMENTCHANGE_EXFEED 2
#define FILAMENTCHANGE_ZFEED 15
#endif
/*------------------------------------
ADDITIONAL FEATURES SETTINGS
*------------------------------------*/
// Define Prusa filament runout sensor
//#define FILAMENT_RUNOUT_SUPPORT
#ifdef FILAMENT_RUNOUT_SUPPORT
#define FILAMENT_RUNOUT_SENSOR 1
#endif
// temperature runaway
#define TEMP_RUNAWAY_BED_HYSTERESIS 5
#define TEMP_RUNAWAY_BED_TIMEOUT 360
#define TEMP_RUNAWAY_EXTRUDER_HYSTERESIS 15
#define TEMP_RUNAWAY_EXTRUDER_TIMEOUT 45
/*------------------------------------
MOTOR CURRENT SETTINGS
*------------------------------------*/
// Motor Current setting for BIG RAMBo
#define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A)
#define DIGIPOT_MOTOR_CURRENT_LOUD {135,135,135,135,135}
// Motor Current settings for RAMBo mini PWM value = MotorCurrentSetting * 255 / range
#if MOTHERBOARD == BOARD_RAMBO_MINI_1_0 || MOTHERBOARD == BOARD_RAMBO_MINI_1_3
#define MOTOR_CURRENT_PWM_RANGE 2000
#define DEFAULT_PWM_MOTOR_CURRENT {400, 750, 750} // {XY,Z,E}
#define DEFAULT_PWM_MOTOR_CURRENT_LOUD {400, 750, 750} // {XY,Z,E}
#endif
/*------------------------------------
PAT9125 SETTINGS
*------------------------------------*/
#define PAT9125_XRES 0
#define PAT9125_YRES 255
/*------------------------------------
BED SETTINGS
*------------------------------------*/
// Define Mesh Bed Leveling system to enable it
#define MESH_BED_LEVELING
#ifdef MESH_BED_LEVELING
#define MBL_Z_STEP 0.01
// Mesh definitions
#define MESH_MIN_X 35
#define MESH_MAX_X 238
#define MESH_MIN_Y 6
#define MESH_MAX_Y 202
// Mesh upsample definition
#define MESH_NUM_X_POINTS 7
#define MESH_NUM_Y_POINTS 7
// Mesh measure definition
#define MESH_MEAS_NUM_X_POINTS 3
#define MESH_MEAS_NUM_Y_POINTS 3
#define MESH_HOME_Z_CALIB 0.2
#define MESH_HOME_Z_SEARCH 5 //Z lift for homing, mesh bed leveling etc.
#define X_PROBE_OFFSET_FROM_EXTRUDER 23 // Z probe to nozzle X offset: -left +right
#define Y_PROBE_OFFSET_FROM_EXTRUDER 5 // Z probe to nozzle Y offset: -front +behind
#define Z_PROBE_OFFSET_FROM_EXTRUDER -0.4 // Z probe to nozzle Z offset: -below (always!)
#endif
// Bed Temperature Control
// Select PID or bang-bang with PIDTEMPBED. If bang-bang, BED_LIMIT_SWITCHING will enable hysteresis
//
// Uncomment this to enable PID on the bed. It uses the same frequency PWM as the extruder.
// If your PID_dT above is the default, and correct for your hardware/configuration, that means 7.689Hz,
// which is fine for driving a square wave into a resistive load and does not significantly impact you FET heating.
// This also works fine on a Fotek SSR-10DA Solid State Relay into a 250W heater.
// If your configuration is significantly different than this and you don't understand the issues involved, you probably
// shouldn't use bed PID until someone else verifies your hardware works.
// If this is enabled, find your own PID constants below.
#define PIDTEMPBED
//
//#define BED_LIMIT_SWITCHING
// This sets the max power delivered to the bed, and replaces the HEATER_BED_DUTY_CYCLE_DIVIDER option.
// all forms of bed control obey this (PID, bang-bang, bang-bang with hysteresis)
// setting this to anything other than 255 enables a form of PWM to the bed just like HEATER_BED_DUTY_CYCLE_DIVIDER did,
// so you shouldn't use it unless you are OK with PWM on your bed. (see the comment on enabling PIDTEMPBED)
#define MAX_BED_POWER 255 // limits duty cycle to bed; 255=full current
// Bed temperature compensation settings
#define BED_OFFSET 10
#define BED_OFFSET_START 40
#define BED_OFFSET_CENTER 50
#ifdef PIDTEMPBED
//120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
//from FOPDT model - kp=.39 Tp=405 Tdead=66, Tc set to 79.2, aggressive factor of .15 (vs .1, 1, 10)
#if defined(E3D_PT100_BED_WITH_AMP) || defined(E3D_PT100_BED_NO_AMP)
// Define PID constants for extruder with PT100
#define DEFAULT_bedKp 21.70
#define DEFAULT_bedKi 1.60
#define DEFAULT_bedKd 73.76
#else
#define DEFAULT_bedKp 126.13
#define DEFAULT_bedKi 4.30
#define DEFAULT_bedKd 924.76
#endif
//120v 250W silicone heater into 4mm borosilicate (MendelMax 1.5+)
//from pidautotune
// #define DEFAULT_bedKp 97.1
// #define DEFAULT_bedKi 1.41
// #define DEFAULT_bedKd 1675.16
// FIND YOUR OWN: "M303 E-1 C8 S90" to run autotune on the bed at 90 degreesC for 8 cycles.
#endif // PIDTEMPBED
//connect message when communication with monitoring broken
//#define FARM_CONNECT_MESSAGE
/*-----------------------------------
PREHEAT SETTINGS
*------------------------------------*/
#define FARM_PREHEAT_HOTEND_TEMP 250
#define FARM_PREHEAT_HPB_TEMP 60
#define FARM_PREHEAT_FAN_SPEED 0
#define PLA_PREHEAT_HOTEND_TEMP 215
#define PLA_PREHEAT_HPB_TEMP 60
#define PLA_PREHEAT_FAN_SPEED 0
#define ABS_PREHEAT_HOTEND_TEMP 255
#define ABS_PREHEAT_HPB_TEMP 100
#define ABS_PREHEAT_FAN_SPEED 0
#define HIPS_PREHEAT_HOTEND_TEMP 220
#define HIPS_PREHEAT_HPB_TEMP 100
#define HIPS_PREHEAT_FAN_SPEED 0
#define PP_PREHEAT_HOTEND_TEMP 254
#define PP_PREHEAT_HPB_TEMP 100
#define PP_PREHEAT_FAN_SPEED 0
#define PET_PREHEAT_HOTEND_TEMP 230
#define PET_PREHEAT_HPB_TEMP 85
#define PET_PREHEAT_FAN_SPEED 0
#define FLEX_PREHEAT_HOTEND_TEMP 240
#define FLEX_PREHEAT_HPB_TEMP 50
#define FLEX_PREHEAT_FAN_SPEED 0
/*------------------------------------
THERMISTORS SETTINGS
*------------------------------------*/
//
//--NORMAL IS 4.7kohm PULLUP!-- 1kohm pullup can be used on hotend sensor, using correct resistor and table
//
//// Temperature sensor settings:
// -2 is thermocouple with MAX6675 (only for sensor 0)
// -1 is thermocouple with AD595
// 0 is not used
// 1 is 100k thermistor - best choice for EPCOS 100k (4.7k pullup)
// 2 is 200k thermistor - ATC Semitec 204GT-2 (4.7k pullup)
// 3 is Mendel-parts thermistor (4.7k pullup)
// 4 is 10k thermistor !! do not use it for a hotend. It gives bad resolution at high temp. !!
// 5 is 100K thermistor - ATC Semitec 104GT-2 (Used in ParCan & J-Head) (4.7k pullup)
// 6 is 100k EPCOS - Not as accurate as table 1 (created using a fluke thermocouple) (4.7k pullup)
// 7 is 100k Honeywell thermistor 135-104LAG-J01 (4.7k pullup)
// 71 is 100k Honeywell thermistor 135-104LAF-J01 (4.7k pullup)
// 8 is 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup)
// 9 is 100k GE Sensing AL03006-58.2K-97-G1 (4.7k pullup)
// 10 is 100k RS thermistor 198-961 (4.7k pullup)
// 11 is 100k beta 3950 1% thermistor (4.7k pullup)
// 12 is 100k 0603 SMD Vishay NTCS0603E3104FXT (4.7k pullup) (calibrated for Makibox hot bed)
// 13 is 100k Hisens 3950 1% up to 300°C for hotend "Simple ONE " & "Hotend "All In ONE"
// 20 is the PT100 circuit found in the Ultimainboard V2.x
// 60 is 100k Maker's Tool Works Kapton Bed Thermistor beta=3950
//
// 1k ohm pullup tables - This is not normal, you would have to have changed out your 4.7k for 1k
// (but gives greater accuracy and more stable PID)
// 51 is 100k thermistor - EPCOS (1k pullup)
// 52 is 200k thermistor - ATC Semitec 204GT-2 (1k pullup)
// 55 is 100k thermistor - ATC Semitec 104GT-2 (Used in ParCan & J-Head) (1k pullup)
//
// 1047 is Pt1000 with 4k7 pullup
// 1010 is Pt1000 with 1k pullup (non standard)
// 147 is Pt100 with 4k7 pullup
// 148 is E3D Pt100 with 4k7 pullup and no PT100 Amplifier on a MiniRambo 1.3a
// 247 is Pt100 with 4k7 pullup and PT100 Amplifier
// 110 is Pt100 with 1k pullup (non standard)
#if defined(E3D_PT100_EXTRUDER_WITH_AMP)
#define TEMP_SENSOR_0 247
#elif defined(E3D_PT100_EXTRUDER_NO_AMP)
#define TEMP_SENSOR_0 148
#else
#define TEMP_SENSOR_0 5
#endif
#define TEMP_SENSOR_1 0
#define TEMP_SENSOR_2 0
#if defined(E3D_PT100_BED_WITH_AMP)
#define TEMP_SENSOR_BED 247
#elif defined(E3D_PT100_BED_NO_AMP)
#define TEMP_SENSOR_BED 148
#else
#define TEMP_SENSOR_BED 1
#endif
#define TEMP_SENSOR_PINDA 1
#define TEMP_SENSOR_AMBIENT 2000
#define STACK_GUARD_TEST_VALUE 0xA2A2
#define MAX_BED_TEMP_CALIBRATION 50
#define MAX_HOTEND_TEMP_CALIBRATION 50
#define MAX_E_STEPS_PER_UNIT 250
#define MIN_E_STEPS_PER_UNIT 100
#define Z_BABYSTEP_MIN -3999
#define Z_BABYSTEP_MAX 0
#define PINDA_PREHEAT_X 20
#define PINDA_PREHEAT_Y 60
#define PINDA_PREHEAT_Z 0.15
/*
#define PINDA_PREHEAT_X 70
#define PINDA_PREHEAT_Y -3
#define PINDA_PREHEAT_Z 1*/
#define PINDA_HEAT_T 120 //time in s
#define PINDA_MIN_T 50
#define PINDA_STEP_T 10
#define PINDA_MAX_T 100
#define PING_TIME 60 //time in s
#define PING_TIME_LONG 600 //10 min; used when length of commands buffer > 0 to avoid 0 triggering when dealing with long gcodes
#define PING_ALLERT_PERIOD 60 //time in s
#define NC_TIME 10 //time in s for periodic important status messages sending which needs reponse from monitoring
#define NC_BUTTON_LONG_PRESS 15 //time in s
#define LONG_PRESS_TIME 1000 //time in ms for button long press
#define BUTTON_BLANKING_TIME 200 //time in ms for blanking after button release
#define DEFAULT_PID_TEMP 210
#define MIN_PRINT_FAN_SPEED 75
#if defined (SNMM) || defined (SNMM_V2)
#define DEFAULT_RETRACTION 4 //used for PINDA temp calibration and pause print
#else
#define DEFAULT_RETRACTION 1 //used for PINDA temp calibration and pause print
#endif
// How much shall the print head be lifted on power panic?
// Ideally the Z axis will reach a zero phase of the stepper driver on power outage. To simplify this,
// UVLO_Z_AXIS_SHIFT shall be an integer multiply of the stepper driver cycle, that is 4x full step.
// For example, the Prusa i3 MK2 with 16 microsteps per full step has Z stepping of 400 microsteps per mm.
// At 400 microsteps per mm, a full step lifts the Z axis by 0.04mm, and a stepper driver cycle is 0.16mm.
// The following example, 12 * (4 * 16 / 400) = 12 * 0.16mm = 1.92mm.
//#define UVLO_Z_AXIS_SHIFT 1.92
#define UVLO_Z_AXIS_SHIFT 0.64
// If power panic occured, and the current temperature is higher then target temperature before interrupt minus this offset, print will be recovered automatically.
#define AUTOMATIC_UVLO_BED_TEMP_OFFSET 5
#define HEATBED_V2
#define M600_TIMEOUT 600 //seconds
//#define SUPPORT_VERBOSITY
#endif //__CONFIGURATION_PRUSA_H

61
lang/fw-clean.sh Normal file
View File

@ -0,0 +1,61 @@
#!/bin/sh
#
# fw-clean.sh - multi-language support script
# Remove all firmware output files from lang folder.
#
result=0
rm_if_exists()
{
if [ -e $1 ]; then
echo -n " removing '$1'..." >&2
if rm $1; then
echo "OK" >&2
else
echo "NG!" >&2
result=1
fi
fi
}
echo "fw-clean.sh started" >&2
rm_if_exists text.sym
rm_if_exists progmem1.sym
rm_if_exists progmem1.lss
rm_if_exists progmem1.hex
rm_if_exists progmem1.chr
rm_if_exists progmem1.var
rm_if_exists progmem1.txt
rm_if_exists textaddr.txt
rm_if_exists firmware.bin
rm_if_exists firmware.hex
rm_if_exists firmware_cz.hex
rm_if_exists firmware_de.hex
rm_if_exists firmware_es.hex
rm_if_exists firmware_it.hex
rm_if_exists firmware_pl.hex
rm_if_exists progmem.out
rm_if_exists textaddr.out
rm_if_exists update_lang.out
rm_if_exists update_lang_cz.out
rm_if_exists update_lang_de.out
rm_if_exists update_lang_es.out
rm_if_exists update_lang_it.out
rm_if_exists update_lang_pl.out
rm_if_exists lang.bin
rm_if_exists lang.hex
echo -n "fw-clean.sh finished" >&2
if [ $result -eq 0 ]; then
echo " with success" >&2
else
echo " with errors!" >&2
fi
case "$-" in
*i*) echo "press enter key"; read ;;
esac
exit $result

10
lang/iso639-1.txt Normal file
View File

@ -0,0 +1,10 @@
#language codes ISO639-1
# iso english localized
#-----------------------
# en English English
# de German Deutsch
# cs Czech Cestina
# es Spanish Espanol
# fr
# it Italian Italiano
# pl Polish Polski

139
lang/lang-build.sh Normal file
View File

@ -0,0 +1,139 @@
#!/bin/sh
#
# lang-build.sh - multi-language support script
# generate lang_xx.bin (language binary file)
#
# Input files:
# lang_en.txt or lang_en_xx.txt
#
# Output files:
# lang_xx.bin
#
# Temporary files:
# lang_xx.tmp
# lang_xx.dat
#
#awk code to format ui16 variables for dd
awk_ui16='{ h=int($1/256); printf("\\x%02x\\x%02x\n", int($1-256*h), h); }'
#startup message
echo "lang-build.sh started" >&2
#exiting function
finish()
{
if [ $1 -eq 0 ]; then
echo "lang-build.sh finished with success" >&2
else
echo "lang-build.sh finished with errors!" >&2
fi
exit $1
}
#returns hexadecial data for lang code
lang_code_hex_data()
# $1 - language code ('en', 'cz'...)
{
case "$1" in
*en*) echo '\x6e\x65' ;;
*cz*) echo '\x73\x63' ;;
*de*) echo '\x65\x64' ;;
*es*) echo '\x73\x65' ;;
*fr*) echo '\x72\x66' ;;
*it*) echo '\x74\x69' ;;
*pl*) echo '\x6c\x70' ;;
esac
echo '??'
}
write_header()
# $1 - lang
# $2 - size
# $3 - count
# $4 - checksum
# $5 - signature
{
/bin/echo -n -e "\xa5\x5a\xb4\x4b" |\
dd of=lang_$1.bin bs=1 count=4 seek=0 conv=notrunc 2>/dev/null
/bin/echo -n -e $(echo -n "$(($2))" | awk "$awk_ui16") |\
dd of=lang_$1.bin bs=1 count=2 seek=4 conv=notrunc 2>/dev/null
/bin/echo -n -e $(echo -n "$(($3))" | awk "$awk_ui16") |\
dd of=lang_$1.bin bs=1 count=2 seek=6 conv=notrunc 2>/dev/null
/bin/echo -n -e $(echo -n "$(($4))" | awk "$awk_ui16") |\
dd of=lang_$1.bin bs=1 count=2 seek=8 conv=notrunc 2>/dev/null
/bin/echo -n -e "$(lang_code_hex_data $1)" |\
dd of=lang_$1.bin bs=1 count=2 seek=10 conv=notrunc 2>/dev/null
sig_h=$(($5 / 65536))
/bin/echo -n -e $(echo -n "$sig_h" | awk "$awk_ui16") |\
dd of=lang_$1.bin bs=1 count=2 seek=14 conv=notrunc 2>/dev/null
sig_l=$(($5 - $sig_h * 65536))
/bin/echo -n -e $(echo -n "$sig_l" | awk "$awk_ui16") |\
dd of=lang_$1.bin bs=1 count=2 seek=12 conv=notrunc 2>/dev/null
}
generate_binary()
# $1 - language code ('en', 'cz'...)
{
echo "lang="$1 >&2
#remove output and temporary files
rm -f lang_$1.bin
rm -f lang_$1.tmp
rm -f lang_$1.dat
LNG=$1
#create lang_xx.tmp - different processing for 'en' language
if [ "$1" = "en" ]; then
#remove comments and empty lines
cat lang_en.txt | sed '/^$/d;/^#/d'
else
#remove comments and empty lines, print lines with translated text only
cat lang_en_$1.txt | sed '/^$/d;/^#/d' | sed -n 'n;p'
fi | sed 's/^\"\\x00\"$/\"\"/' > lang_$1.tmp
#create lang_xx.dat (binary text data file)
# cat lang_$1.tmp | sed 's/^\"/\/bin\/echo -e \"/;s/"$/\\x00\"/' > lang_$1.shx
cat lang_$1.tmp | sed 's/^\"/\/bin\/echo -e -n \"/;s/"$/\\x00\"/' | sh >lang_$1.dat
#calculate number of strings
count=$(grep -c '^"' lang_$1.tmp)
echo "count="$count >&2
#calculate text data offset
offs=$((16 + 2 * $count))
echo "offs="$offs >&2
#calculate text data size
size=$(($offs + $(wc -c lang_$1.dat | cut -f1 -d' ')))
echo "size="$size >&2
#write header with empty signature and checksum
write_header $1 $size $count 0x0000 0x00000000
#write offset table
offs_hex=$(cat lang_$1.tmp | sed 's/^\"//;s/\"$//' |\
sed 's/\\x[0-9a-f][0-9a-f]/\./g;s/\\[0-7][0-7][0-7]/\./g;s/\ /\./g' |\
awk 'BEGIN { o='$offs';} { h=int(o/256); printf("\\x%02x\\x%02x",int(o-256*h), h); o+=(length($0)+1); }')
/bin/echo -n -e "$offs_hex" | dd of=./lang_$1.bin bs=1 seek=16 conv=notrunc 2>/dev/null
#write binary text data
dd if=./lang_$1.dat of=./lang_$1.bin bs=1 seek=$offs conv=notrunc 2>/dev/null
#write signature
if [ "$1" != "en" ]; then
dd if=lang_en.bin of=lang_$1.bin bs=1 count=4 skip=6 seek=12 conv=notrunc 2>/dev/null
fi
#calculate and update checksum
chsum=$(cat lang_$1.bin | xxd | cut -c11-49 | tr ' ' "\n" | sed '/^$/d' | awk 'BEGIN { sum = 0; } { sum += strtonum("0x"$1); if (sum > 0xffff) sum -= 0x10000; } END { printf("%x\n", sum); }')
/bin/echo -n -e $(echo -n $((0x$chsum)) | awk "$awk_ui16") |\
dd of=lang_$1.bin bs=1 count=2 seek=8 conv=notrunc 2>/dev/null
#remove temporary files
# rm -f lang_$1.tmp
# rm -f lang_$1.dat
}
if [ -z "$1" ]; then set 'all'; fi
if [ "$1" = "all" ]; then
generate_binary 'en'
generate_binary 'cz'
generate_binary 'de'
generate_binary 'es'
generate_binary 'it'
generate_binary 'pl'
else
generate_binary $1
fi
finish 0

75
lang/lang-check.sh Normal file
View File

@ -0,0 +1,75 @@
#!/bin/sh
#
# lang_check.sh - multi-language support script
# check lang_xx.bin (language binary file)
#
# Input files:
# lang_$1.bin
# lang_en.txt or lang_en_$1.txt
#
#
#set 'cz'
#dictionary txt file
fn_t=lang_en_$1.txt
if [ "$1" = "en" ]; then fn_t=lang_en.txt; fi
#binary file to check
fn_b=lang_$1.bin
#check txt dictionary file
echo -n "dictionary file: $fn_t"
if [ -e $fn_t ]; then echo " - OK"; else echo " - Not found!"; exit 1; fi
#create lang_xx.tmp - different processing for 'en' language
if [ "$1" = "en" ]; then
#remove comments and empty lines
cat lang_en.txt | sed '/^$/d;/^#/d'
else
#remove comments and empty lines, print lines with translated text only
cat lang_en_$1.txt | sed '/^$/d;/^#/d' | sed -n 'n;p'
fi | sed 's/^\"\\x00\"$/\"\"/' > lang_$1.tmp
count_txt=$(grep -c '^"' lang_$1.tmp)
echo -n "language bin file: $fn_b"
if [ -e $fn_b ]; then echo " - OK"; else echo " - Not found!"; exit 1; fi
#read header and convert to hex
header=$(dd if=$fn_b bs=1 count=16 2>/dev/null | xxd | cut -c11-49 | sed 's/\([0-9a-f][0-9a-f]\)[\ ]*/\1 /g')
echo "header='$header'"
magic=0x$(echo $header | tr -d ' ' | cut -c1-8)
echo "magic='$magic'"
size=$(echo $header | tr -d ' ' | cut -c9-12)
size=0x${size:2:2}${size:0:2}
echo "size='$size' ($(($size)))"
count=$(echo $header | tr -d ' ' | cut -c13-16)
count=0x${count:2:2}${count:0:2}
echo "count='$count' ($(($count)))"
o=0
l=0
#create lang_xx_1.tmp (temporary text file from binary data)
(dd if=$fn_b bs=1 count=$((2*$count)) skip=16 2>/dev/null | xxd | cut -c11-49 | tr ' ' "\n" |\
sed 's/\([0-9a-f][0-9a-f]\)\([0-9a-f][0-9a-f]\)/\2\1 /g;/^$/d'; printf "%04x\n" $(($size)) ) |\
while read offs; do
if [ $o -ne 0 ]; then
l=$((0x$offs - $o))
echo -n '"'
dd if=$fn_b bs=1 count=$((l-1)) skip=$o 2>/dev/null
echo '"'
fi
o=$((0x$offs))
done > lang_$1_1.tmp
#create lang_xx_2.tmp (temporary text file from dictionary)
cat lang_$1.tmp | sed 's/^\"/printf \"\\x22/;s/"$/\\x22\\x0a\"/' | sh >lang_$1_2.tmp
#compare temporary files
diff -a lang_$1_1.tmp lang_$1_2.tmp >lang_$1_check.dif
dif=$(cat lang_$1_check.dif)
if [ -z "$dif" ]; then
echo 'binary data OK'
else
echo 'binary data NG!'
fi
read
exit

57
lang/lang-clean.sh Normal file
View File

@ -0,0 +1,57 @@
#!/bin/sh
#
# clean.sh - multi-language support script
# Remove all language output files from lang folder.
#
result=0
rm_if_exists()
{
if [ -e $1 ]; then
echo -n " removing '$1'..." >&2
if rm $1; then
echo "OK" >&2
else
echo "NG!" >&2
result=1
fi
fi
}
clean_lang()
{
if [ "$1" = "en" ]; then
rm_if_exists lang_$1.tmp
else
rm_if_exists lang_en_$1.tmp
rm_if_exists lang_en_$1.dif
rm_if_exists lang_$1.ofs
rm_if_exists lang_$1.txt
fi
rm_if_exists lang_$1.bin
rm_if_exists lang_$1.dat
}
echo "lang-clean.sh started" >&2
clean_lang en
clean_lang cz
clean_lang de
clean_lang es
clean_lang fr
clean_lang it
clean_lang pl
echo -n "lang-clean.sh finished" >&2
if [ $result -eq 0 ]; then
echo " with success" >&2
else
echo " with errors!" >&2
fi
case "$-" in
*i*) echo "press enter key" >&2; read ;;
esac
exit $result

View File

@ -76,7 +76,7 @@
#MSG_AUTOLOADING_ONLY_IF_FSENS_ON c=20 r=4
"Autoloading filament available only when filament sensor is turned on..."
"La carga automatica de filamento solo funciona si el sensor de filamento está activado..."
"La carga automatica de filamento solo funciona si el sensor de filamento esta activado..."
#MSG_AUTOLOADING_ENABLED c=20 r=4
"Autoloading filament is active, just press the knob and insert filament..."
@ -132,7 +132,7 @@
#MSG_RECOVER_PRINT c=20 r=2
"Blackout occurred. Recover print?"
"Se fue la luz. ¿Reanudar la impresion?"
"Se fue la luz. Reanudar la impresion?"
#MSG_CALIBRATE_BED c=0 r=0
"Calibrate XYZ"
@ -252,7 +252,7 @@
#MSG_STACK_ERROR c=20 r=4
"Error - static memory has been overwritten"
"Error - se ha sobre-escrito la memoria estática"
"Error - se ha sobre-escrito la memoria estatica"
#MSG_SD_ERR_WRITE_TO_FILE c=0 r=0
"error writing to file"
@ -260,7 +260,7 @@
#MSG_FSENS_NOT_RESPONDING c=20 r=4
"ERROR: Filament sensor is not responding, please check connection."
"ERROR: El sensor de filamento no responde, por favor comprueba la conexión."
"ERROR: El sensor de filamento no responde, por favor comprueba la conexion."
#MSG_ERROR c=0 r=0
"ERROR:"
@ -336,7 +336,7 @@
#MSG_FILE_INCOMPLETE c=20 r=2
"File incomplete. Continue anyway?"
"Archivo incompleto. ¿Continuar de todos modos?"
"Archivo incompleto. Continuar de todos modos?"
#MSG_SD_FILE_OPENED c=0 r=0
"File opened: "
@ -508,7 +508,7 @@
#MSG_STEEL_SHEET_CHECK c=20 r=2
"Is steel sheet on heatbed?"
"¿Esta colocada la lamina de acero sobre la base?"
"Esta colocada la lamina de acero sobre la base?"
#MSG_FIND_BED_OFFSET_AND_SKEW_ITERATION c=20 r=0
"Iteration "
@ -584,7 +584,7 @@
#MSG_MESH_BED_LEVELING c=0 r=0
"Mesh Bed Leveling"
"Nivelación Mesh Level"
"Nivelacion Mesh Level"
#MSG_STEALTH_MODE_OFF c=0 r=0
"Mode [Normal]"
@ -668,7 +668,7 @@
#MSG_DEFAULT_SETTINGS_LOADED c=20 r=4
"Old settings found. Default PID, Esteps etc. will be set."
"Se han encontrado ajustes anteriores. Se ajustará el PID, los pasos del extrusor, etc"
"Se han encontrado ajustes anteriores. Se ajustara el PID, los pasos del extrusor, etc"
#MSG_SD_OPEN_FILE_FAIL c=0 r=0
"open failed, File: "
@ -820,7 +820,7 @@
#MSG_RECOVERING_PRINT c=20 r=1
"Recovering print "
"Recuperando impresión"
"Recuperando impresion"
#MSG_M119_REPORT c=0 r=0
"Reporting endstop status"
@ -908,7 +908,7 @@
#MSG_FORCE_SELFTEST c=20 r=8
"Selftest will be run to calibrate accurate sensorless rehoming."
"Se realizará el auto-test para calibrar con precisión la vuelta a la posición inicial sin sensores."
"Se realizara el auto-test para calibrar con precision la vuelta a la posicion inicial sin sensores."
#MSG_SET_TEMPERATURE c=19 r=1
"Set temperature:"
@ -940,7 +940,7 @@
#MSG_SORT_ALPHA c=17 r=1
"Sort: [Alphabet]"
"Orden:[Alfabétic]"
"Orden:[Alfabetic]"
#MSG_SORTING c=20 r=1
"Sorting files"
@ -1052,7 +1052,7 @@
#MSG_WAITING_TEMP_PINDA c=20 r=3
"Waiting for PINDA probe cooling"
"Esperando a que se enfríe la sonda PINDA"
"Esperando a que se enfrie la sonda PINDA"
#MSG_CHANGED_BOTH c=20 r=4
"Warning: both printer type and motherboard type changed."
@ -1068,7 +1068,7 @@
#MSG_UNLOAD_SUCCESSFUL c=20 r=2
"Was filament unload successful?"
"¿Se cargocon exito el filamento?"
"Se cargocon exito el filamento?"
#MSG_SELFTEST_WIRINGERROR c=0 r=0
"Wiring error"

View File

@ -76,11 +76,11 @@
#MSG_AUTOLOADING_ONLY_IF_FSENS_ON c=20 r=4
"Autoloading filament available only when filament sensor is turned on..."
"Il caricamento automatico del filamento è disponibile solo quando il sensore è acceso..."
"Il caricamento automatico del filamento e disponibile solo quando il sensore e acceso..."
#MSG_AUTOLOADING_ENABLED c=20 r=4
"Autoloading filament is active, just press the knob and insert filament..."
"Il caricamento automatico è attivo, premete la manopola e inserite il filamento..."
"Il caricamento automatico e attivo, premete la manopola e inserite il filamento..."
#MSG_SELFTEST_AXIS_LENGTH c=0 r=0
"Axis length"
@ -132,7 +132,7 @@
#MSG_RECOVER_PRINT c=20 r=2
"Blackout occurred. Recover print?"
"C'è stato un Blackout. Recuperare la stampa?"
"C'e stato un Blackout. Recuperare la stampa?"
#MSG_CALIBRATE_BED c=0 r=0
"Calibrate XYZ"
@ -252,7 +252,7 @@
#MSG_STACK_ERROR c=20 r=4
"Error - static memory has been overwritten"
"Errore - la memoria statica è stata sovrascritta"
"Errore - la memoria statica e stata sovrascritta"
#MSG_SD_ERR_WRITE_TO_FILE c=0 r=0
"error writing to file"
@ -292,7 +292,7 @@
#MSG_FAN_SPEED c=14 r=0
"Fan speed"
"Velocità ventola"
"Velocita ventola"
#MSG_SELFTEST_FAN c=20 r=0
"Fan test"
@ -356,7 +356,7 @@
#MSG_WIZARD_SELFTEST c=20 r=8
"First, I will run the selftest to check most common assembly problems."
"Per primo avvierò l'autotest per controllare gli errori di assemblaggio più comuni."
"Per primo avviero l'autotest per controllare gli errori di assemblaggio piu comuni."
#MSG_FLOW c=0 r=0
"Flow"
@ -456,11 +456,11 @@
#MSG_WIZARD_XYZ_CAL c=20 r=8
"I will run xyz calibration now. It will take approx. 12 mins."
"Adesso avviero una Calibrazione XYZ. Può durare circa 12 min."
"Adesso avviero una Calibrazione XYZ. Puo durare circa 12 min."
#MSG_WIZARD_Z_CAL c=20 r=8
"I will run z calibration now."
"Adesso avvierò la Calibrazione Z."
"Adesso avviero la Calibrazione Z."
#MSG_WIZARD_V2_CAL_2 c=20 r=12
"I will start to print line and you will gradually lower the nozzle by rotating the knob, until you reach optimal height. Check the pictures in our handbook in chapter Calibration."
@ -656,7 +656,7 @@
#MSG_WIZARD_WILL_PREHEAT c=20 r=4
"Now I will preheat nozzle for PLA."
"Adesso preriscalderò l'ugello per PLA."
"Adesso preriscaldero l'ugello per PLA."
#MSG_NOZZLE c=0 r=0
"Nozzle"
@ -804,7 +804,7 @@
#MSG_ERR_STOPPED c=0 r=0
"Printer stopped due to errors. Fix the error and use M999 to restart. (Temperature is reset. Set it after restarting)"
"La stampante si è fermata a causa di errori. Correggete l'errore e usate M999 per riavviare. (La temperatura viene resettate. Impostatela dopo il riavvio)"
"La stampante si e fermata a causa di errori. Correggete l'errore e usate M999 per riavviare. (La temperatura viene resettate. Impostatela dopo il riavvio)"
#WELCOME_MSG c=20 r=0
"Prusa i3 MK3 ready."
@ -908,7 +908,7 @@
#MSG_FORCE_SELFTEST c=20 r=8
"Selftest will be run to calibrate accurate sensorless rehoming."
"Verrà effettuato un self test per calibrare l'homing senza sensori"
"Verra effettuato un self test per calibrare l'homing senza sensori"
#MSG_SET_TEMPERATURE c=19 r=1
"Set temperature:"
@ -928,7 +928,7 @@
#MSG_FILE_CNT c=20 r=4
"Some files will not be sorted. Max. No. of files in 1 folder for sorting is 100."
"Alcuni file non saranno ordinati. Il numero massimo di file in una cartella è 100 perché siano ordinati."
"Alcuni file non saranno ordinati. Il numero massimo di file in una cartella e 100 perche siano ordinati."
#MSG_SORT_NONE c=17 r=1
"Sort: [None]"
@ -948,7 +948,7 @@
#MSG_SPEED c=0 r=0
"Speed"
"Velocità"
"Velocita"
#MSG_SELFTEST_FAN_YES c=19 r=0
"Spinning"
@ -964,7 +964,7 @@
#MSG_STEPPER_TOO_HIGH c=0 r=0
"Steprate too high: "
"Velocità passo troppo alta: "
"Velocita passo troppo alta: "
#MSG_STOP_PRINT c=0 r=0
"Stop print"
@ -1004,7 +1004,7 @@
#MSG_TEMP_CALIBRATION_DONE c=20 r=12
"Temperature calibration is finished and active. Temp. calibration can be disabled in menu Settings->Temp. cal."
"Calibrazione temperatura completata e attiva. Può essere disattivata dal menù Impostazioni ->Cal. Temp."
"Calibrazione temperatura completata e attiva. Puo essere disattivata dal menu Impostazioni ->Cal. Temp."
#MSG_TEMPERATURE c=0 r=0
"Temperature"

File diff suppressed because it is too large Load Diff

View File

@ -5,18 +5,18 @@
#
# Input files:
# lang_en.txt
# lang_en_$LANG.txt
# lang_en_xx.txt
#
# Output files:
# lang_en.tmp (temporary, will be removed when finished)
# lang_en_$LANG.tmp ==||==
# lang_en_$LANG.dif ==||==
# lang_$LANG.txt
# lang_en_xx.tmp ==||==
# lang_en_xx.dif ==||==
# lang_xx.txt
#
#
# Selected language:
LANG=$1
if [ -z "$LANG" ]; then LANG='cz'; fi
LNG=$1
if [ -z "$LNG" ]; then LNG='cz'; fi
#
#
@ -24,8 +24,8 @@ finish()
{
if [ $1 -eq 0 ]; then
if [ -e lang_en.tmp ]; then rm lang_en.tmp; fi
if [ -e lang_en_$LANG.tmp ]; then rm lang_en_$LANG.tmp; fi
if [ -e lang_en_$LANG.dif ]; then rm lang_en_$LANG.dif; fi
if [ -e lang_en_$LNG.tmp ]; then rm lang_en_$LNG.tmp; fi
if [ -e lang_en_$LNG.dif ]; then rm lang_en_$LNG.dif; fi
fi
# echo >&2
if [ $1 -eq 0 ]; then
@ -38,59 +38,59 @@ finish()
make_lang()
{
LANG=$1
LNG=$1
echo "make_lang.sh started" >&2
echo "selected language=$LANG" >&2
echo "selected language=$LNG" >&2
#check if input files exists
echo -n " checking input files..." >&2
if [ ! -e lang_en.txt ]; then echo "NG! file lang_en.txt not found!" >&2; exit 1; fi
if [ ! -e lang_en_$LANG.txt ]; then echo "NG! file lang_en_$LANG.txt not found!" >&2; exit 1; fi
if [ ! -e lang_en_$LNG.txt ]; then echo "NG! file lang_en_$LNG.txt not found!" >&2; exit 1; fi
echo "OK" >&2
#filter comment and empty lines from key and dictionary files, create temporary files
echo -n " creating tmp files..." >&2
cat lang_en.txt | sed "/^$/d;/^#/d" > lang_en.tmp
cat lang_en_$LANG.txt | sed "/^$/d;/^#/d" > lang_en_$LANG.tmp
cat lang_en_$LNG.txt | sed "/^$/d;/^#/d" > lang_en_$LNG.tmp
echo "OK" >&2
#cat lang_en_$LANG.tmp | sed 'n;d' >test1.txt
#cat lang_en_$LNG.tmp | sed 'n;d' >test1.txt
#compare files using diff and check for differences
echo -n " comparing tmp files..." >&2
if ! cat lang_en_$LANG.tmp | sed 'n;d' | diff lang_en.tmp - > lang_en_$LANG.dif; then
if ! cat lang_en_$LNG.tmp | sed 'n;d' | diff lang_en.tmp - > lang_en_$LNG.dif; then
echo "NG!" >&2
echo "Entries in lang_en_$LANG.txt are different from lang_en.txt!" >&2
echo "please check lang_en_$LANG.dif" >&2
echo "Entries in lang_en_$LNG.txt are different from lang_en.txt!" >&2
echo "please check lang_en_$LNG.dif" >&2
finish 1
fi
echo "OK" >&2
#generate lang_xx.txt (secondary language text data sorted by ids)
echo -n " generating lang_$LANG.txt..." >&2
cat lang_en_$LANG.tmp | sed '1~2d' | sed "s/^\"\\\\x00/\"/" > lang_$LANG.txt
echo -n " generating lang_$LNG.txt..." >&2
cat lang_en_$LNG.tmp | sed '1~2d' | sed "s/^\"\\\\x00/\"/" > lang_$LNG.txt
echo "OK" >&2
#generate lang_xx.dat (secondary language text data in binary form)
echo -n " generating lang_$LANG.dat..." >&2
cat lang_$LANG.txt | sed "s/\\\\/\\\\\\\\/g" | while read s; do
echo -n " generating lang_$LNG.dat..." >&2
cat lang_$LNG.txt | sed "s/\\\\/\\\\\\\\/g" | while read s; do
s=${s#\"}
s=${s%\"}
/bin/echo -e -n "$s\x00"
done >lang_$LANG.dat
done >lang_$LNG.dat
echo "OK" >&2
#calculate variables
lt_magic='\xa5\x5a\xb4\x4b'
lt_count=$(grep -c '^' lang_$LANG.txt)
lt_data_size=$(wc -c lang_$LANG.dat | cut -f1 -d' ')
lt_count=$(grep -c '^' lang_$LNG.txt)
lt_data_size=$(wc -c lang_$LNG.dat | cut -f1 -d' ')
lt_offs_size=$((2 * $lt_count))
lt_size=$((16 + $lt_offs_size + $lt_data_size))
lt_chsum=1
lt_chsum=0
lt_code='\xff\xff'
lt_resv1='\xff\xff\xff\xff'
case "$LANG" in
case "$LNG" in
*en*) lt_code='\x6e\x65' ;;
*cz*) lt_code='\x73\x63' ;;
*de*) lt_code='\x65\x64' ;;
@ -100,15 +100,15 @@ case "$LANG" in
esac
#generate lang_xx.ofs (secondary language text data offset table)
echo -n " generating lang_$LANG.ofs..." >&2
cat lang_$LANG.txt | sed "s/\\\\x[0-9a-f][0-9a-f]/\./g;s/\\\\[0-7][0-7][0-7]/\./g" |\
awk 'BEGIN { o='$((16 + $lt_offs_size))';} { printf("%d\n",o); o+=(length($0)-1); }' > lang_$LANG.ofs
echo -n " generating lang_$LNG.ofs..." >&2
cat lang_$LNG.txt | sed "s/\\\\x[0-9a-f][0-9a-f]/\./g;s/\\\\[0-7][0-7][0-7]/\./g" |\
awk 'BEGIN { o='$((16 + $lt_offs_size))';} { printf("%d\n",o); o+=(length($0)-1); }' > lang_$LNG.ofs
echo "OK" >&2
#generate lang_xx.bin (secondary language result binary file)
echo " generating lang_$LANG.bin:" >&2
echo " generating lang_$LNG.bin:" >&2
#create empty file
dd if=/dev/zero of=lang_$LANG.bin bs=1 count=$lt_size 2>/dev/null
dd if=/dev/zero of=lang_$LNG.bin bs=1 count=$lt_size 2>/dev/null
#awk code to format ui16 variables for dd
awk_ui16='{ h=int($1/256); printf("\\x%02x\\x%02x\n", int($1-256*h), h); }'
@ -116,37 +116,48 @@ awk_ui16='{ h=int($1/256); printf("\\x%02x\\x%02x\n", int($1-256*h), h); }'
echo -n " writing header (16 bytes)..." >&2
/bin/echo -n -e "$lt_magic" |\
dd of=lang_$LANG.bin bs=1 count=4 seek=0 conv=notrunc 2>/dev/null
dd of=lang_$LNG.bin bs=1 count=4 seek=0 conv=notrunc 2>/dev/null
/bin/echo -n -e $(echo -n "$lt_size" | awk "$awk_ui16") |\
dd of=lang_$LANG.bin bs=1 count=2 seek=4 conv=notrunc 2>/dev/null
dd of=lang_$LNG.bin bs=1 count=2 seek=4 conv=notrunc 2>/dev/null
/bin/echo -n -e $(echo -n "$lt_count" | awk "$awk_ui16") |\
dd of=lang_$LANG.bin bs=1 count=2 seek=6 conv=notrunc 2>/dev/null
dd of=lang_$LNG.bin bs=1 count=2 seek=6 conv=notrunc 2>/dev/null
/bin/echo -n -e $(echo -n "$lt_chsum" | awk "$awk_ui16") |\
dd of=lang_$LANG.bin bs=1 count=2 seek=8 conv=notrunc 2>/dev/null
dd of=lang_$LNG.bin bs=1 count=2 seek=8 conv=notrunc 2>/dev/null
/bin/echo -n -e "$lt_code" |\
dd of=lang_$LANG.bin bs=1 count=2 seek=10 conv=notrunc 2>/dev/null
dd of=lang_$LNG.bin bs=1 count=2 seek=10 conv=notrunc 2>/dev/null
/bin/echo -n -e "$lt_resv1" |\
dd of=lang_$LANG.bin bs=1 count=4 seek=12 conv=notrunc 2>/dev/null
dd of=lang_$LNG.bin bs=1 count=4 seek=12 conv=notrunc 2>/dev/null
echo "OK" >&2
echo -n " writing offset table ($lt_offs_size bytes)..." >&2
/bin/echo -n -e $(cat lang_$LANG.ofs | awk "$awk_ui16" | tr -d '\n'; echo) |\
dd of=./lang_$LANG.bin bs=1 count=$lt_offs_size seek=16 conv=notrunc 2>/dev/null
/bin/echo -n -e $(cat lang_$LNG.ofs | awk "$awk_ui16" | tr -d '\n'; echo) |\
dd of=./lang_$LNG.bin bs=1 count=$lt_offs_size seek=16 conv=notrunc 2>/dev/null
echo "OK" >&2
echo -n " writing text data ($lt_data_size bytes)..." >&2
dd if=./lang_$LANG.dat of=./lang_$LANG.bin bs=1 count=$lt_data_size seek=$((16 + $lt_offs_size)) conv=notrunc 2>/dev/null
dd if=./lang_$LNG.dat of=./lang_$LNG.bin bs=1 count=$lt_data_size seek=$((16 + $lt_offs_size)) conv=notrunc 2>/dev/null
echo "OK" >&2
#update signature
echo -n " updating signature..." >&2
dd if=lang_en.bin of=lang_$LNG.bin bs=1 count=4 skip=6 seek=12 conv=notrunc 2>/dev/null
echo "OK" >&2
#calculate and update checksum
lt_chsum=$(cat lang_$LNG.bin | xxd | cut -c11-49 | tr ' ' "\n" | sed '/^$/d' | awk 'BEGIN { sum = 0; } { sum += strtonum("0x"$1); if (sum > 0xffff) sum -= 0x10000; } END { printf("%x\n", sum); }')
/bin/echo -n -e $(echo -n $((0x$lt_chsum)) | awk "$awk_ui16") |\
dd of=lang_$LNG.bin bs=1 count=2 seek=8 conv=notrunc 2>/dev/null
echo " lang_table details:" >&2
echo " lt_count = $lt_count" >&2
echo " lt_size = $lt_size" >&2
echo " lt_chsum = $lt_chsum" >&2
}
echo $LANG
echo $LNG
if [ "$LANG" = "all" ]; then
if [ "$LNG" = "all" ]; then
./lang-build.sh en
make_lang cz
make_lang de
make_lang es
@ -154,7 +165,7 @@ if [ "$LANG" = "all" ]; then
make_lang pl
exit 0
else
make_lang $LANG
make_lang $LNG
fi
finish 0

View File

@ -5,11 +5,11 @@
#
SRCDIR="../../Firmware"
#
LANG=$1
if [ -z "$LANG" ]; then LANG=cz; fi
LNG=$1
if [ -z "$LNG" ]; then LNG=cz; fi
#
if [ "$LANG" == "all" ]; then
if [ "$LNG" == "all" ]; then
./make_po.sh cz
./make_po.sh de
./make_po.sh es
@ -19,13 +19,13 @@ if [ "$LANG" == "all" ]; then
fi
echo "make_po.sh started" >&2
echo " selected language=$LANG" >&2
echo " selected language=$LNG" >&2
#remove output file if exists
if [ -e lang_$LANG.po ]; then rm lang_$LANG.po; fi
if [ -e lang_$LNG.po ]; then rm lang_$LNG.po; fi
lang_name=$(\
case "$LANG" in
case "$LNG" in
*en*) echo "English" ;;
*cz*) echo "Czech" ;;
*de*) echo "German" ;;
@ -35,7 +35,7 @@ lang_name=$(\
esac)
lang_short=$(\
case "$LANG" in
case "$LNG" in
*en*) echo "en" ;;
*cz*) echo "cs" ;;
*de*) echo "de" ;;
@ -47,29 +47,29 @@ lang_short=$(\
po_date=$(date)
#write po header
echo "# Translation of Prusa-Firmware into $lang_name." > lang_$LANG.po
echo "#" >> lang_$LANG.po
echo 'msgid ""' >> lang_$LANG.po
echo 'msgstr ""' >> lang_$LANG.po
echo '"MIME-Version: 1.0\n"' >> lang_$LANG.po
echo '"Content-Type: text/plain; charset=UTF-8\n"' >> lang_$LANG.po
echo '"Content-Transfer-Encoding: 8bit\n"' >> lang_$LANG.po
echo '"Language: '$lang_short'\n"' >> lang_$LANG.po
echo '"Project-Id-Version: Prusa-Firmware\n"' >> lang_$LANG.po
echo '"POT-Creation-Date: '$po_date'\n"' >> lang_$LANG.po
echo '"PO-Revision-Date: '$po_date'\n"' >> lang_$LANG.po
echo '"Language-Team: \n"' >> lang_$LANG.po
echo '"X-Generator: Poedit 2.0.7\n"' >> lang_$LANG.po
echo '"X-Poedit-SourceCharset: UTF-8\n"' >> lang_$LANG.po
echo '"Last-Translator: \n"' >> lang_$LANG.po
echo '"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"' >> lang_$LANG.po
echo >> lang_$LANG.po
echo "# Translation of Prusa-Firmware into $lang_name." > lang_$LNG.po
echo "#" >> lang_$LNG.po
echo 'msgid ""' >> lang_$LNG.po
echo 'msgstr ""' >> lang_$LNG.po
echo '"MIME-Version: 1.0\n"' >> lang_$LNG.po
echo '"Content-Type: text/plain; charset=UTF-8\n"' >> lang_$LNG.po
echo '"Content-Transfer-Encoding: 8bit\n"' >> lang_$LNG.po
echo '"Language: '$lang_short'\n"' >> lang_$LNG.po
echo '"Project-Id-Version: Prusa-Firmware\n"' >> lang_$LNG.po
echo '"POT-Creation-Date: '$po_date'\n"' >> lang_$LNG.po
echo '"PO-Revision-Date: '$po_date'\n"' >> lang_$LNG.po
echo '"Language-Team: \n"' >> lang_$LNG.po
echo '"X-Generator: Poedit 2.0.7\n"' >> lang_$LNG.po
echo '"X-Poedit-SourceCharset: UTF-8\n"' >> lang_$LNG.po
echo '"Last-Translator: \n"' >> lang_$LNG.po
echo '"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"' >> lang_$LNG.po
echo >> lang_$LNG.po
#list .cpp, .c and .h files
files=$(ls "$SRCDIR"/*.cpp "$SRCDIR"/*.c "$SRCDIR"/*.h)
num_texts=$(grep '^#' -c ../lang_en_$LANG.txt)
num_texts_nt=$(grep '^\"\\x00\"' -c ../lang_en_$LANG.txt)
num_texts=$(grep '^#' -c ../lang_en_$LNG.txt)
num_texts_nt=$(grep '^\"\\x00\"' -c ../lang_en_$LNG.txt)
echo " $num_texts texts, $num_texts_nt not translated" >&2
#loop over all messages
@ -77,7 +77,7 @@ s0=''
s1=''
s2=''
num=1
cat ../lang_en_$LANG.txt | sed "s/\\\\/\\\\\\\\/g" | while read -r s; do
cat ../lang_en_$LNG.txt | sed "s/\\\\/\\\\\\\\/g" | while read -r s; do
if [ "$s" == "" ]; then
echo " processing $num of $num_texts" >&2
if [ "$s0" == "\"\\\\x00\"" ]; then
@ -103,11 +103,11 @@ cat ../lang_en_$LANG.txt | sed "s/\\\\/\\\\\\\\/g" | while read -r s; do
s2=$s1
s1=$s0
s0=$s
done >> lang_$LANG.po
done >> lang_$LNG.po
#replace LF with CRLF
sync
sed -i 's/$/\r/' lang_$LANG.po
sed -i 's/$/\r/' lang_$LNG.po
echo "make_po.sh finished" >&2
#read

View File

@ -2,14 +2,14 @@
#
#
LANG=$1
if [ -z "$LANG" ]; then exit -1; fi
LNG=$1
if [ -z "$LNG" ]; then exit -1; fi
#convert '\\e' sequencies to 'x1b' and '\\' to '\'
cat $LANG.po | sed 's/\\\\e/\\x1b/g;s/\\\\/\\/g' > $LANG'_filtered.po'
cat $LNG.po | sed 's/\\\\e/\\x1b/g;s/\\\\/\\/g' > $LNG'_filtered.po'
#join lines with multi-line string constants
cat $LANG'_filtered.po' | sed ':a;N;$!ba;s/\x22\n\x22//g' > $LANG'_new.po'
cat $LNG'_filtered.po' | sed ':a;N;$!ba;s/\x22\n\x22//g' > $LNG'_new.po'
#generate dictionary
cat ../lang_en.txt | sed 's/\\/\\\\/g' | while read -r s; do
@ -17,7 +17,7 @@ cat ../lang_en.txt | sed 's/\\/\\\\/g' | while read -r s; do
if [ "${s:0:1}" = "\"" ]; then
# /bin/echo -e "$s"
s=$(/bin/echo -e "$s")
s2=$(grep -F -A1 -B0 "$s" "$LANG"_new.po | tail -n1 | sed 's/^msgstr //')
s2=$(grep -F -A1 -B0 "$s" "$LNG"_new.po | tail -n1 | sed 's/^msgstr //')
if [ -z "$s2" ]; then
echo '"\x00"'
else
@ -25,4 +25,4 @@ cat ../lang_en.txt | sed 's/\\/\\\\/g' | while read -r s; do
fi
# echo
fi
done > lang_en_$LANG.txt
done > lang_en_$LNG.txt

View File

@ -23,8 +23,8 @@ if [ -z "$CONFIG_OK" ]; then eval "$(cat config.sh)"; fi
if [ -z "$CONFIG_OK" ] | [ $CONFIG_OK -eq 0 ]; then echo 'Config NG!' >&2; exit 1; fi
#
# Selected language:
LANG=$1
#if [ -z "$LANG" ]; then LANG='cz'; fi
LNG=$1
#if [ -z "$LNG" ]; then LNG='cz'; fi
#
# Params:
IGNORE_MISSING_TEXT=1
@ -80,7 +80,7 @@ else
echo "OK" >&2
fi
#update progmem1 id entries in binary file
#extract binary file
echo -n " extracting binary..." >&2
$OBJCOPY -I ihex -O binary $INOHEX ./firmware.bin
echo "OK" >&2
@ -97,10 +97,35 @@ cat textaddr.txt | grep "^ADDR OK" | cut -f3- -d' ' | sed "s/^0000/0x/" |\
done
echo "OK" >&2
#update primary language signature in binary file
echo -n " primary language signature..." >&2
if [ -e lang_en.bin ]; then
#find symbol _PRI_LANG_SIGNATURE in section '.text'
pri_lang=$(cat text.sym | grep -E "\b_PRI_LANG_SIGNATURE\b")
if [ -z "$pri_lang" ]; then echo "NG!\n symbol _PRI_LANG_SIGNATURE not found!" >&2; finish 1; fi
#get pri_lang address
pri_lang_addr='0x'$(echo $pri_lang | cut -f1 -d' ')
#read header from primary language binary file
header=$(dd if=lang_en.bin bs=1 count=16 2>/dev/null | xxd | cut -c11-49 | sed 's/\([0-9a-f][0-9a-f]\)[\ ]*/\1 /g')
#read checksum and count data as 4 byte signature
chscnt=$(echo $header | cut -c18-29 | sed "s/ /\\\\x/g")
/bin/echo -e -n "$chscnt" |\
dd of=firmware.bin bs=1 count=4 seek=$(($pri_lang_addr)) conv=notrunc 2>/dev/null
echo "OK" >&2
else
echo "NG! - file lang_en.bin not found!" >&2;
finish 1
fi
#convert bin to hex
echo -n " converting to hex..." >&2
$OBJCOPY -I binary -O ihex ./firmware.bin ./firmware.hex
echo "OK" >&2
#update _SEC_LANG in binary file if language is selected
echo -n " secondary language data..." >&2
if [ ! -z "$LANG" ]; then
./update_lang.sh $LANG 2>./update_lang.out
if [ ! -z "$LNG" ]; then
./update_lang.sh $LNG 2>./update_lang.out
if [ $? -ne 0 ]; then echo "NG! - check update_lang.out file" >&2; finish 1; fi
echo "OK" >&2
finish 0
@ -134,9 +159,20 @@ else
# echo "skipped" >&2
fi
#convert bin to hex
#echo -n " converting to hex..." >&2
#$OBJCOPY -I binary -O ihex ./firmware.bin ./firmware.hex
#echo "OK" >&2
#create binary file with all languages
rm -f lang.bin
if [ -e lang_cz.bin ]; then cat lang_cz.bin >> lang.bin; fi
if [ -e lang_de.bin ]; then cat lang_de.bin >> lang.bin; fi
if [ -e lang_es.bin ]; then cat lang_es.bin >> lang.bin; fi
if [ -e lang_it.bin ]; then cat lang_it.bin >> lang.bin; fi
if [ -e lang_pl.bin ]; then cat lang_pl.bin >> lang.bin; fi
#convert lang.bin to lang.hex
echo -n " converting to hex..." >&2
$OBJCOPY -I binary -O ihex ./lang.bin ./lang.hex
echo "OK" >&2
#append languages to hex file
cat ./lang.hex >> firmware.hex
finish 0

View File

@ -9,8 +9,8 @@ if [ -z "$OBJCOPY" ]; then echo 'variable OBJCOPY not set!' >&2; exit 1; fi
if [ -z "$CONFIG_OK" ] | [ $CONFIG_OK -eq 0 ]; then echo 'Config NG!' >&2; exit 1; fi
#
# Selected language:
LANG=$1
if [ -z "$LANG" ]; then LANG='cz'; fi
LNG=$1
if [ -z "$LNG" ]; then LNG='cz'; fi
#
finish()
@ -28,11 +28,11 @@ finish()
}
echo "update_lang.sh started" >&2
echo " selected language=$LANG" >&2
echo " selected language=$LNG" >&2
echo -n " checking files..." >&2
if [ ! -e text.sym ]; then echo "NG! file text.sym not found!" >&2; finish 1; fi
if [ ! -e lang_$LANG.bin ]; then echo "NG! file lang_$LANG.bin not found!" >&2; finish 1; fi
if [ ! -e lang_$LNG.bin ]; then echo "NG! file lang_$LNG.bin not found!" >&2; finish 1; fi
if [ ! -e firmware.bin ]; then echo "NG! file firmware.bin not found!" >&2; finish 1; fi
echo "OK" >&2
@ -40,9 +40,15 @@ echo -n " checking symbols..." >&2
#find symbol _SEC_LANG in section '.text'
sec_lang=$(cat text.sym | grep -E "\b_SEC_LANG\b")
if [ -z "$sec_lang" ]; then echo "NG!\n symbol _SEC_LANG not found!" >&2; finish 1; fi
#find symbol _PRI_LANG_SIGNATURE in section '.text'
pri_lang=$(cat text.sym | grep -E "\b_PRI_LANG_SIGNATURE\b")
if [ -z "$pri_lang" ]; then echo "NG!\n symbol _PRI_LANG_SIGNATURE not found!" >&2; finish 1; fi
echo "OK" >&2
echo " calculating vars:" >&2
#get pri_lang addres
pri_lang_addr='0x'$(echo $pri_lang | cut -f1 -d' ')
echo " pri_lang_addr =$pri_lang_addr" >&2
#get addres and size
sec_lang_addr='0x'$(echo $sec_lang | cut -f1 -d' ')
sec_lang_size='0x'$(echo $sec_lang | cut -f2 -d' ')
@ -56,16 +62,17 @@ lang_table_size=$((256*$((($sec_lang_size - ($lang_table_addr - $sec_lang_addr))
printf " lang_table_size =0x%04x (=%d bytes)\n" $lang_table_size $lang_table_size >&2
#get lang_xx.bin file size
lang_file_size=$(wc -c lang_$LANG.bin | cut -f1 -d' ')
lang_file_size=$(wc -c lang_$LNG.bin | cut -f1 -d' ')
printf " lang_file_size =0x%04x (=%d bytes)\n" $lang_file_size $lang_file_size >&2
if [ $lang_file_size -gt $lang_table_size ]; then echo "Lanaguage binary file size too big!" >&2; finish 1; fi
echo "updating 'firmware.bin'..." >&2
dd if=lang_$LANG.bin of=firmware.bin bs=1 seek=$lang_table_addr conv=notrunc 2>/dev/null
dd if=lang_$LNG.bin of=firmware.bin bs=1 seek=$lang_table_addr conv=notrunc 2>/dev/null
#convert bin to hex
echo "converting to hex..." >&2
$OBJCOPY -I binary -O ihex ./firmware.bin ./firmware_$LANG.hex
$OBJCOPY -I binary -O ihex ./firmware.bin ./firmware_$LNG.hex
finish 0