diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index dc7ca56b95..59114d35fc 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -555,7 +555,7 @@ enum CalibrationStatus // Try to maintain a minimum distance from the bed even when Z is // unknown when doing the following operations #define MIN_Z_FOR_LOAD 50 -#define MIN_Z_FOR_UNLOAD 20 +#define MIN_Z_FOR_UNLOAD 50 #define MIN_Z_FOR_PREHEAT 10 #include "Configuration_adv.h" diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 1b29c88fe0..3be4659123 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -5974,28 +5974,30 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) /*! ### M46 - Show the assigned IP address M46: Show the assigned IP address. */ - /* - case 46: + case 46: { // M46: Prusa3D: Show the assigned IP address. - uint8_t ip[4]; - bool hasIP = card.ToshibaFlashAir_GetIP(ip); - if (hasIP) { - SERIAL_ECHOPGM("Toshiba FlashAir current IP: "); - SERIAL_ECHO(int(ip[0])); - SERIAL_ECHOPGM("."); - SERIAL_ECHO(int(ip[1])); - SERIAL_ECHOPGM("."); - SERIAL_ECHO(int(ip[2])); - SERIAL_ECHOPGM("."); - SERIAL_ECHO(int(ip[3])); - SERIAL_ECHOLNPGM(""); + if (card.ToshibaFlashAir_isEnabled()) { + uint8_t ip[4]; + bool hasIP = card.ToshibaFlashAir_GetIP(ip); + if (hasIP) { + // SERIAL_PROTOCOLPGM("Toshiba FlashAir current IP: "); + SERIAL_PROTOCOL(int(ip[0])); + SERIAL_PROTOCOLPGM("."); + SERIAL_PROTOCOL(int(ip[1])); + SERIAL_PROTOCOLPGM("."); + SERIAL_PROTOCOL(int(ip[2])); + SERIAL_PROTOCOLPGM("."); + SERIAL_PROTOCOL(int(ip[3])); + SERIAL_PROTOCOLPGM("\n"); + } else { + SERIAL_PROTOCOLPGM("?Toshiba FlashAir GetIP failed\n"); + } } else { - SERIAL_ECHOLNPGM("Toshiba FlashAir GetIP failed"); + SERIAL_PROTOCOLPGM("n/a\n"); } break; } - */ /*! ### M47 - Show end stops dialog on the display M47: Show end stops dialog on the display @@ -9572,7 +9574,7 @@ static uint16_t nFSCheckCount=0; bInhibitFlag=bInhibitFlag||bMenuFSDetect; // Settings::HWsetup::FSdetect menu active #endif // IR_SENSOR_ANALOG #endif // IR_SENSOR - if ((mcode_in_progress != 600) && (eFilamentAction != FilamentAction::AutoLoad) && (!bInhibitFlag)) //M600 not in progress, preHeat @ autoLoad menu not active, Support::ExtruderInfo/SensorInfo menu not active + if ((mcode_in_progress != 600) && (eFilamentAction != FilamentAction::AutoLoad) && (!bInhibitFlag) && (menu_menu != lcd_move_e)) //M600 not in progress, preHeat @ autoLoad menu not active, Support::ExtruderInfo/SensorInfo menu not active { if (!moves_planned() && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LcdCommands::Layer1Cal) && ! eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE)) { diff --git a/Firmware/Sd2Card.cpp b/Firmware/Sd2Card.cpp index 449590f177..d1d3505635 100644 --- a/Firmware/Sd2Card.cpp +++ b/Firmware/Sd2Card.cpp @@ -767,6 +767,9 @@ uint8_t Sd2Card::waitStartBlock(void) { // Toshiba FlashAir support, copied from // https://flashair-developers.com/en/documents/tutorials/arduino/ +// However, the official website was closed in September 2019. +// There is an archived website (written in Japanese). +// https://flashair-developers.github.io/website/docs/tutorials/arduino/2.html //------------------------------------------------------------------------------ /** Perform Extention Read. */ @@ -774,7 +777,7 @@ uint8_t Sd2Card::readExt(uint32_t arg, uint8_t* dst, uint16_t count) { uint16_t i; // send command and argument. - if (cardCommand(CMD48, arg)) { + if (cardCommand(CMD48, arg) && cardCommand(CMD17, arg)) { // CMD48 for W-03, CMD17 for W-04 error(SD_CARD_ERROR_CMD48); goto fail; } diff --git a/Firmware/cmdqueue.h b/Firmware/cmdqueue.h index 017452a2a4..95fe731098 100644 --- a/Firmware/cmdqueue.h +++ b/Firmware/cmdqueue.h @@ -73,22 +73,32 @@ extern bool is_buffer_empty(); extern void get_command(); extern uint16_t cmdqueue_calc_sd_length(); + +#if defined(__cplusplus) +extern "C" { +#endif + extern double strtod_noE(const char* nptr, char** endptr); +#if defined(__cplusplus) +} +#endif + // Return True if a character was found static inline bool code_seen(char code) { return (strchr_pointer = strchr(CMDBUFFER_CURRENT_STRING, code)) != NULL; } static inline bool code_seen(const char *code) { return (strchr_pointer = strstr(CMDBUFFER_CURRENT_STRING, code)) != NULL; } -static inline float code_value() { return strtod(strchr_pointer+1, NULL);} +static inline float code_value() { return strtod_noE(strchr_pointer+1, NULL);} static inline long code_value_long() { return strtol(strchr_pointer+1, NULL, 10); } static inline int16_t code_value_short() { return int16_t(strtol(strchr_pointer+1, NULL, 10)); }; static inline uint8_t code_value_uint8() { return uint8_t(strtol(strchr_pointer+1, NULL, 10)); }; static inline float code_value_float() { - char* e = strchr(strchr_pointer, 'E'); - if (!e) return strtod(strchr_pointer + 1, NULL); - *e = 0; - float ret = strtod(strchr_pointer + 1, NULL); - *e = 'E'; - return ret; + // A correct version of strtod() has been implemented, this hack is unnecessary. + //char* e = strchr(strchr_pointer, 'E'); + //if (!e) return strtod(strchr_pointer + 1, NULL); + //*e = 0; + //float ret = strtod(strchr_pointer + 1, NULL); + //*e = 'E'; + return strtod_noE(strchr_pointer + 1, NULL); } diff --git a/Firmware/eeprom.h b/Firmware/eeprom.h index f234bb7152..731db1da13 100644 --- a/Firmware/eeprom.h +++ b/Firmware/eeprom.h @@ -98,19 +98,9 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP | 0x0FF1h 4081 | uint32 | EEPROM_FILAMENTUSED | ??? | 00 00 00 00h 0 __S/P__| Filament used in meters | ??? | D3 Ax0ff1 C4 | 0x0FEDh 4077 | uint32 | EEPROM_TOTALTIME | ??? | 00 00 00 00h 0 __S/P__| Total print time | ??? | D3 Ax0fed C4 | 0x0FE5h 4069 | float | EEPROM_BED_CALIBRATION_CENTER | ??? | ff ff ff ffh | ??? | ??? | D3 Ax0fe5 C8 -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ | 0x0FDDh 4061 | float | EEPROM_BED_CALIBRATION_VEC_X | ??? | ff ff ff ffh | ??? | ??? | D3 Ax0fdd C8 -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ | 0x0FD5h 4053 | float | EEPROM_BED_CALIBRATION_VEC_Y | ??? | ff ff ff ffh | ??? | ??? | D3 Ax0fd5 C8 -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ | 0x0FC5h 4037 | int16 | EEPROM_BED_CALIBRATION_Z_JITTER | ??? | ff ffh 65535 | ??? | ??? | D3 Ax0fc5 C16 -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ | 0x0FC4h 4036 | bool | EEPROM_FARM_MODE | 00h 0 | ffh 255 __P__ | Prusa farm mode: __off__ | G99 | D3 Ax0fc4 C1 | ^ | ^ | ^ | 01h 1 | ^ | Prusa farm mode: __on__ | G98 | ^ | 0x0FC3h 4035 | free | _EEPROM_FREE_NR1_ | ??? | ffh 255 | _Free EEPROM space_ | _free space_ | D3 Ax0fc3 C1 @@ -129,10 +119,6 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP | ^ | ^ | ^ | 01h 1 | ^ | Toshiba Air: __on__ | ^ | ^ | 0x0FBAh 4026 | uchar | EEPROM_PRINT_FLAG | ??? | ??? | _unsued_ | ??? | D3 Ax0fba C1 | 0x0FB0h 4016 | int16 | EEPROM_PROBE_TEMP_SHIFT | ??? | ??? | ??? | ??? | D3 Ax0fb0 C10 -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ | 0x0FAFh 4015 | bool | EEPROM_TEMP_CAL_ACTIVE | 00h 0 | 00h 0 | PINDA Temp cal.: __inactive__ | LCD menu | D3 Ax0faf C1 | ^ | ^ | ^ | ffh 255 | ^ | PINDA Temp cal.: __active__ | ^ | ^ | 0x0FA7h 4007 | uint32 | EEPROM_BOWDEN_LENGTH | ??? | ff 00 00 00h | Bowden length | ??? | D3 Ax0fae C8 @@ -143,16 +129,8 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP | ^ | ^ | ^ | 01h 1 | ^ | Power Panic flag: __active__ | ^ | ^ | ^ | ^ | ^ | 02h 2 | ^ | Power Panic flag: __???__ | ^ | ^ | 0x0F9Dh 3997 | float | EEPROM_UVLO_CURRENT_POSITION | ??? | ffh 255 | Power Panic position | ??? | D3 Ax0f9d C8 -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ | 0x0F95h 3989 | char | EEPROM_FILENAME | ??? | ffh 255 | Power Panic Filename | ??? | D3 Ax0f95 C8 -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| 0x0F91h 39851 | uint32 | EEPROM_FILE_POSITION | ??? | ff ff ff ffh | Power Panic File Position | ??? | D3 Ax0f91 C4 +| 0x0F91h 3985 | uint32 | EEPROM_FILE_POSITION | ??? | ff ff ff ffh | Power Panic File Position | ??? | D3 Ax0f91 C4 | 0x0F8Dh 3981 | float | EEPROM_UVLO_CURRENT_POSITION_Z | ??? | ff ff ff ffh | Power Panic Z Position | ^ | D3 Ax0f8d C4 | 0x0F8Ch 3980 | ??? | EEPROM_UVLO_UNUSED_001 | ??? | ffh 255 | Power Panic _unused_ | ^ | D3 Ax0f8c C1 | 0x0F8Bh 3979 | uint8 | EEPROM_UVLO_TARGET_BED | ??? | ffh 255 | Power Panic Bed temperature | ^ | D3 Ax0f8b C1 @@ -161,14 +139,6 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP | 0x0F87h 3975 | uint8 | EEPROM_FAN_CHECK_ENABLED | 00h 0 | ??? | Fan Check __disabled__ | LCD menu | D3 Ax0f87 C1 | ^ | ^ | ^ | 01h 1 | ffh 255 | Fan Check __enabled__ | ^ | ^ | 0x0F75h 3957 | uint16 | EEPROM_UVLO_MESH_BED_LEVELING | ??? | ff ffh 65535 | Power Panic Mesh Bed Leveling | ??? | D3 Ax0f75 C18 -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ^ | ^ | ^ | ^ | ^ | 0x0F73h 3955 | uint16 | EEPROM_UVLO_Z_MICROSTEPS | ??? | ff ffh 65535 | Power Panic Z microsteps | ??? | D3 Ax0f73 C2 | 0x0F72h 3954 | uint8 | EEPROM_UVLO_E_ABS | ??? | ffh 255 | Power Panic ??? position | ??? | D3 Ax0f72 C1 | 0x0F6Eh 3950 | foat | EEPROM_UVLO_CURRENT_POSITION_E | ??? | ff ff ff ffh | Power Panic E position | ??? | D3 Ax0f6e C4 @@ -203,7 +173,7 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP | 0x0F01h 3841 | uint16 | EEPROM_FERROR_COUNT_TOT | 0000-fffe | ff ffh __S/P__ | Total filament sensor errors | ??? | D3 Ax0f01 C2 | 0x0EFFh 3839 | uint16 | EEPROM_POWER_COUNT_TOT | 0000-fffe | ff ffh __S/P__ | Total power failures | ??? | D3 Ax0eff C2 | 0x0EFEh 3838 | uint8 | EEPROM_TMC2130_HOME_X_ORIGIN | ??? | ffh 255 | ??? | ??? | D3 Ax0efe C1 -| 0x0EFDh 3837 | uint8 | EEPROM MC2130_HOME_X_BSTEPS | ??? | ffh 255 | ??? | ??? | D3 Ax0efd C1 +| 0x0EFDh 3837 | uint8 | EEPROM MC2130_HOME_X_BSTEPS | ??? | ffh 255 | ??? | ??? | D3 Ax0efd C1 | 0x0EFCh 3836 | uint8 | EEPROM_TMC2130_HOME_X_FSTEPS | ??? | ffh 255 | ??? | ??? | D3 Ax0efc C1 | 0x0EFBh 3835 | uint8 | EEPROM_TMC2130_HOME_Y_ORIGIN | ??? | ffh 255 | ??? | ??? | D3 Ax0efb C1 | 0x0EFAh 3834 | uint8 | EEPROM_TMC2130_HOME_Y_BSTEPS | ??? | ffh 255 | ??? | ??? | D3 Ax0efa C1 @@ -257,28 +227,6 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP | ^ | ^ | ^ | 01h 1 | ^ | MMU2/s cutter: __enabled__ | ^ | ^ | ^ | ^ | ^ | 02h 2 | ^ | MMU2/s cutter: __always__ | ^ | ^ | 0x0DAE 3502 | uint16 | EEPROM_UVLO_MESH_BED_LEVELING_FULL | ??? | ff ffh 65535 | Power panic Mesh bed leveling points | ??? | D3 Ax0dae C288 -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ -| ^ | ^ | ^ | ??? | ^ | ^ | ^ | ^ | 0x0DAD 3501 | uint8 | EEPROM_MBL_TYPE | ??? | ffh 255 | Mesh bed leveling precision _unused atm_ | ??? | D3 Ax0dad C1 | 0x0DAC 3500 | bool | EEPROM_MBL_MAGNET_ELIMINATION | 01h 1 | ffh 255 | Mesh bed leveling does: __ignores__ magnets | LCD menu | D3 Ax0dac C1 | ^ | ^ | ^ | 00h 0 | ^ | Mesh bed leveling does: __NOT ignores__ magnets | ^ | ^ diff --git a/Firmware/fsensor.cpp b/Firmware/fsensor.cpp index c81a5ac6f1..b6ea778838 100755 --- a/Firmware/fsensor.cpp +++ b/Firmware/fsensor.cpp @@ -316,7 +316,7 @@ void fsensor_autoload_check_start(void) printf_P(ERRMSG_PAT9125_NOT_RESP, 3); return; } - puts_P(_N("fsensor_autoload_check_start - autoload ENABLED\n")); + puts_P(_N("fsensor_autoload_check_start - autoload ENABLED")); fsensor_autoload_y = pat9125_y; //save current y value fsensor_autoload_c = 0; //reset number of changes counter fsensor_autoload_sum = 0; @@ -334,7 +334,7 @@ void fsensor_autoload_check_stop(void) if (!fsensor_autoload_enabled) return; // puts_P(_N("fsensor_autoload_check_stop 2\n")); if (!fsensor_watch_autoload) return; - puts_P(_N("fsensor_autoload_check_stop - autoload DISABLED\n")); + puts_P(_N("fsensor_autoload_check_stop - autoload DISABLED")); fsensor_autoload_sum = 0; fsensor_watch_autoload = false; fsensor_watch_runout = true; diff --git a/Firmware/meatpack.cpp b/Firmware/meatpack.cpp index 55ac16a8c8..acc64b3d31 100644 --- a/Firmware/meatpack.cpp +++ b/Firmware/meatpack.cpp @@ -80,7 +80,7 @@ uint8_t mp_char_out_count = 0; // Stores number of characters to be read out #ifdef USE_LOOKUP_TABLE // The 15 most-common characters used in G-code, ~90-95% of all g-code uses these characters // NOT storing this with PROGMEM, given how frequently this table will be accessed. -uint8_t MeatPackLookupTbl[16] = { +volatile uint8_t MeatPackLookupTbl[16] = { '0', // 0000 '1', // 0001 '2', // 0010 @@ -160,11 +160,10 @@ void FORCE_INLINE mp_handle_output_char(const uint8_t c) { mp_char_out_buf[mp_char_out_count++] = c; #ifdef MP_DEBUG - if (mp_chars_decoded < 64) { + if (mp_chars_decoded < 4096) { ++mp_chars_decoded; - SERIAL_ECHOPGM("Rec Byte: "); - MYSERIAL.print("0x"); - MYSERIAL.print((uint8_t)c, HEX); + SERIAL_ECHOPGM("RB: "); + MYSERIAL.print((char)c); SERIAL_ECHOLNPGM(""); } #endif @@ -243,8 +242,10 @@ void FORCE_INLINE mp_handle_rx_char_inner(const uint8_t c) { } else { mp_handle_output_char(buf[0]); - if (res & MeatPack_NextPackedSecond) ++mp_full_char_queue; - else mp_handle_output_char(buf[1]); + if (buf[0] != '\n') { + if (res & MeatPack_NextPackedSecond) ++mp_full_char_queue; + else mp_handle_output_char(buf[1]); + } } } } @@ -275,7 +276,10 @@ void FORCE_INLINE mp_echo_config_state() { // Validate config vars #ifdef USE_LOOKUP_TABLE - MeatPackLookupTbl[MeatPack_SpaceCharIdx] = (uint8_t)((mp_config & MPConfig_NoSpaces) ? MeatPack_SpaceCharReplace : ' '); + if (mp_config & MPConfig_NoSpaces) + MeatPackLookupTbl[MeatPack_SpaceCharIdx] = (uint8_t)(MeatPack_SpaceCharReplace); + else + MeatPackLookupTbl[MeatPack_SpaceCharIdx] = ' '; #endif } diff --git a/Firmware/sm4.c b/Firmware/sm4.c index 34cf8a3c91..dab47042f4 100644 --- a/Firmware/sm4.c +++ b/Firmware/sm4.c @@ -173,7 +173,7 @@ uint16_t sm4_line_xyze_ui(uint16_t dx, uint16_t dy, uint16_t dz, uint16_t de) } if (ce <= de) { - sm |= 4; + sm |= 8; ce += dd; e++; } diff --git a/Firmware/strtod.c b/Firmware/strtod.c new file mode 100644 index 0000000000..b039f9dbd6 --- /dev/null +++ b/Firmware/strtod.c @@ -0,0 +1,178 @@ +// Note -- This is a modified stdtod() method, to prevent the catching of uppercase "E", used in 3D printing g-code. + + +#if !defined(__AVR_TINY__) + +#include +#include +#include +#include +#include /* INFINITY, NAN */ +#include + +/* Only GCC 4.2 calls the library function to convert an unsigned long + to float. Other GCC-es (including 4.3) use a signed long to float + conversion along with a large inline code to correct the result. */ +extern double __floatunsisf(unsigned long); + +PROGMEM static const float pwr_p10[6] = { + 1e+1, 1e+2, 1e+4, 1e+8, 1e+16, 1e+32 +}; +PROGMEM static const float pwr_m10[6] = { + 1e-1, 1e-2, 1e-4, 1e-8, 1e-16, 1e-32 +}; + +/* PSTR() is not used to save 1 byte per string: '\0' at the tail. */ +PROGMEM static const char pstr_inf[] = { 'I','N','F' }; +PROGMEM static const char pstr_inity[] = { 'I','N','I','T','Y' }; +PROGMEM static const char pstr_nan[] = { 'N','A','N' }; + + +double strtod_noE(const char* nptr, char** endptr) +{ + union { + unsigned long u32; + float flt; + } x; + unsigned char c; + int exp; + + unsigned char flag; +#define FL_MINUS 0x01 /* number is negative */ +#define FL_ANY 0x02 /* any digit was readed */ +#define FL_OVFL 0x04 /* overflow was */ +#define FL_DOT 0x08 /* decimal '.' was */ +#define FL_MEXP 0x10 /* exponent 'e' is neg. */ + + if (endptr) + *endptr = (char*)nptr; + + do { + c = *nptr++; + } while (isspace(c)); + + flag = 0; + if (c == '-') { + flag = FL_MINUS; + c = *nptr++; + } + else if (c == '+') { + c = *nptr++; + } + + if (!strncasecmp_P(nptr - 1, pstr_inf, 3)) { + nptr += 2; + if (!strncasecmp_P(nptr, pstr_inity, 5)) + nptr += 5; + if (endptr) + *endptr = (char*)nptr; + return flag & FL_MINUS ? -INFINITY : +INFINITY; + } + + /* NAN() construction is not realised. + Length would be 3 characters only. */ + if (!strncasecmp_P(nptr - 1, pstr_nan, 3)) { + if (endptr) + *endptr = (char*)nptr + 2; + return NAN; + } + + x.u32 = 0; + exp = 0; + while (1) { + + c -= '0'; + + if (c <= 9) { + flag |= FL_ANY; + if (flag & FL_OVFL) { + if (!(flag & FL_DOT)) + exp += 1; + } + else { + if (flag & FL_DOT) + exp -= 1; + /* x.u32 = x.u32 * 10 + c */ + x.u32 = (((x.u32 << 2) + x.u32) << 1) + c; + if (x.u32 >= (ULONG_MAX - 9) / 10) + flag |= FL_OVFL; + } + + } + else if (c == (('.' - '0') & 0xff) && !(flag & FL_DOT)) { + flag |= FL_DOT; + } + else { + break; + } + c = *nptr++; + } + + // Check for exponent "E", but disable capital E + if (c == (('e' - '0') & 0xff) /*|| c == (('E' - '0') & 0xff)*/) + { + int i; + c = *nptr++; + i = 2; + if (c == '-') { + flag |= FL_MEXP; + c = *nptr++; + } + else if (c == '+') { + c = *nptr++; + } + else { + i = 1; + } + c -= '0'; + if (c > 9) { + nptr -= i; + } + else { + i = 0; + do { + if (i < 3200) + i = (((i << 2) + i) << 1) + c; /* i = 10*i + c */ + c = *nptr++ - '0'; + } while (c <= 9); + if (flag & FL_MEXP) + i = -i; + exp += i; + } + } + + if ((flag & FL_ANY) && endptr) + *endptr = (char*)nptr - 1; + + x.flt = __floatunsisf(x.u32); /* manually */ + if ((flag & FL_MINUS) && (flag & FL_ANY)) + x.flt = -x.flt; + + if (x.flt != 0) { + int pwr; + if (exp < 0) { + nptr = (void*)(pwr_m10 + 5); + exp = -exp; + } + else { + nptr = (void*)(pwr_p10 + 5); + } + for (pwr = 32; pwr; pwr >>= 1) { + for (; exp >= pwr; exp -= pwr) { + union { + unsigned long u32; + float flt; + } y; + y.u32 = pgm_read_dword((float*)nptr); + x.flt *= y.flt; + } + nptr -= sizeof(float); + } + if (!isfinite(x.flt) || x.flt == 0) + errno = ERANGE; + } + + return x.flt; +} + +#endif diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 0ce3344ac4..0cd6fa97e4 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -2120,12 +2120,14 @@ static void lcd_support_menu() // Menu was entered or SD card status has changed (plugged in or removed). // Initialize its status. _md->status = 1; - _md->is_flash_air = card.ToshibaFlashAir_isEnabled() && card.ToshibaFlashAir_GetIP(_md->ip); - if (_md->is_flash_air) + _md->is_flash_air = card.ToshibaFlashAir_isEnabled(); + if (_md->is_flash_air) { + card.ToshibaFlashAir_GetIP(_md->ip); // ip[4] filled with 0 if it failed + // Prepare IP string from ip[4] sprintf_P(_md->ip_str, PSTR("%d.%d.%d.%d"), _md->ip[0], _md->ip[1], _md->ip[2], _md->ip[3]); - + } } else if (_md->is_flash_air && _md->ip[0] == 0 && _md->ip[1] == 0 && _md->ip[2] == 0 && _md->ip[3] == 0 && @@ -2191,7 +2193,11 @@ static void lcd_support_menu() if (_md->is_flash_air) { MENU_ITEM_BACK_P(STR_SEPARATOR); MENU_ITEM_BACK_P(PSTR("FlashAir IP Addr:")); //c=18 r=1 -///! MENU_ITEM(back_RAM, _md->ip_str, 0); + MENU_ITEM_BACK_P(PSTR(" ")); + if (((menu_item - 1) == menu_line) && lcd_draw_update) { + lcd_set_cursor(2, menu_row); + lcd_printf_P(PSTR("%s"), _md->ip_str); + } } #ifndef MK1BP @@ -2412,7 +2418,7 @@ void mFilamentItem(uint16_t nTemp, uint16_t nTempBed) case FilamentAction::None: case FilamentAction::Preheat: case FilamentAction::Lay1Cal: - + // handled earlier break; } if (bFilamentWaitingFlag) Sound_MakeSound(e_SOUND_TYPE_StandardPrompt); @@ -2420,34 +2426,45 @@ void mFilamentItem(uint16_t nTemp, uint16_t nTempBed) } else { - bFilamentWaitingFlag = true; lcd_set_cursor(0, 0); lcdui_print_temp(LCD_STR_THERMOMETER[0], (int) degHotend(0), (int) degTargetHotend(0)); - lcd_set_cursor(0, 1); - switch (eFilamentAction) + + if (!bFilamentWaitingFlag) { - case FilamentAction::Load: - case FilamentAction::AutoLoad: - case FilamentAction::MmuLoad: - lcd_puts_P(_i("Preheating to load")); ////MSG_ c=20 - break; - case FilamentAction::UnLoad: - case FilamentAction::MmuUnLoad: - lcd_puts_P(_i("Preheating to unload")); ////MSG_ c=20 - break; - case FilamentAction::MmuEject: - lcd_puts_P(_i("Preheating to eject")); ////MSG_ c=20 - break; - case FilamentAction::MmuCut: - lcd_puts_P(_i("Preheating to cut")); ////MSG_ c=20 - break; - case FilamentAction::None: - case FilamentAction::Preheat: - case FilamentAction::Lay1Cal: - break; + // First run after the filament preheat selection: + // setup the fixed LCD parts and raise Z as we wait + bFilamentWaitingFlag = true; + + lcd_set_cursor(0, 1); + switch (eFilamentAction) + { + case FilamentAction::Load: + case FilamentAction::AutoLoad: + case FilamentAction::MmuLoad: + lcd_puts_P(_i("Preheating to load")); ////MSG_ c=20 + raise_z_above(MIN_Z_FOR_LOAD); + break; + case FilamentAction::UnLoad: + case FilamentAction::MmuUnLoad: + lcd_puts_P(_i("Preheating to unload")); ////MSG_ c=20 + raise_z_above(MIN_Z_FOR_UNLOAD); + break; + case FilamentAction::MmuEject: + lcd_puts_P(_i("Preheating to eject")); ////MSG_ c=20 + break; + case FilamentAction::MmuCut: + lcd_puts_P(_i("Preheating to cut")); ////MSG_ c=20 + break; + case FilamentAction::None: + case FilamentAction::Preheat: + case FilamentAction::Lay1Cal: + // handled earlier + break; + } + lcd_set_cursor(0, 3); + lcd_puts_P(_i(">Cancel")); ////MSG_ c=20 r=1 } - lcd_set_cursor(0, 3); - lcd_puts_P(_i(">Cancel")); ////MSG_ c=20 r=1 + if (lcd_clicked()) { bFilamentWaitingFlag = false; @@ -2930,7 +2947,7 @@ static void _lcd_move(const char *name, int axis, int min, int max) } -static void lcd_move_e() +void lcd_move_e() { if (degHotend0() > EXTRUDE_MINTEMP) { diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index cca4eced32..b23a669192 100755 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -207,6 +207,7 @@ void lcd_farm_sdcard_menu_w(); void lcd_wait_for_heater(); void lcd_wait_for_cool_down(); +void lcd_move_e(); // NOT static due to usage in Marlin_main void lcd_extr_cal_reset(); void lcd_temp_cal_show_result(bool result); diff --git a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h index 7bd7be43eb..9fa2d2f82f 100644 --- a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h @@ -266,7 +266,6 @@ #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_CURRENTS_R_HOME {8, 10, 20, 18} // homing running currents for all axes -// #define TMC2130_UNLOAD_CURRENT_R 12 // lower current for M600 to protect filament sensor - Unused #define TMC2130_STEALTH_Z diff --git a/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h index 3056c43669..5cbe392f7a 100644 --- a/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h @@ -268,7 +268,6 @@ #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_CURRENTS_R_HOME {8, 10, 20, 18} // homing running currents for all axes -// #define TMC2130_UNLOAD_CURRENT_R 12 // lower current for M600 to protect filament sensor - Unused #define TMC2130_STEALTH_Z diff --git a/PF-build.sh b/PF-build.sh index f459095c91..b753957829 100755 --- a/PF-build.sh +++ b/PF-build.sh @@ -15,7 +15,7 @@ # 3. Install zip with 'apt-get install zip' # 4. Install python3 with 'apt-get install python3' # 5. Add command 'ln -sf /usr/bin/python3.5 /usr/bin/python' to link python3 to python. -# Donnot istall 'python' as python 2.x has end of life see https://pythonclock.org/ +# Do not install 'python' as python 2.x has end of life see https://pythonclock.org/ # 6. Add at top of ~/.bashrc following lines by using 'sudo nano ~/.bashrc' # # export OS="Linux" @@ -37,7 +37,7 @@ # 2. Another great tool to compare your custom mod and stock firmware is WinMerge http://winmerge.org/downloads/?lang=en # # Example for MK3: open git bash and change to your Firmware directory -# @ MINGW64 //path +# @ MINGW64 //path # bash build.sh 1_75mm_MK3-EINSy10a-E3Dv6full # # Example for MK25: open git bash and change to your directory @@ -56,15 +56,15 @@ # Some may argue that this is only used by a script, BUT as soon someone accidentally or on purpose starts Arduino IDE # it will use the default Arduino IDE folders and so can corrupt the build environment. # -# Version: 1.0.6-Build_18 +# Version: 1.0.6-Build_33 # Change log: # 12 Jan 2019, 3d-gussner, Fixed "compiler.c.elf.flags=-w -Os -Wl,-u,vfprintf -lprintf_flt -lm -Wl,--gc-sections" in 'platform.txt' # 16 Jan 2019, 3d-gussner, Build_2, Added development check to modify 'Configuration.h' to prevent unwanted LCD messages that Firmware is unknown # 17 Jan 2019, 3d-gussner, Build_3, Check for OS Windows or Linux and use the right build environment # 10 Feb 2019, ropaha, Pull Request, Select variant from list while using build.sh # 10 Feb 2019, ropaha, change FW_DEV_VERSION automatically depending on FW_VERSION RC/BETA/ALPHA -# 10 Feb 2019, 3d-gussner, 1st tests with english only -# 10 Feb 2019, ropaha, added compiling of all variants and english only +# 10 Feb 2019, 3d-gussner, 1st tests with English only +# 10 Feb 2019, ropaha, added compiling of all variants and English only # 10 Feb 2019, 3d-gussner, Set OUTPUT_FOLDER for hex files # 11 Feb 2019, 3d-gussner/ropaha, Minor changes and fixes # 11 Feb 2019, 3d-gussner, Ready for RC @@ -80,50 +80,62 @@ # Configuration_prusa.h # language build files # multi language firmware files exist and clean them up -# 15 Feb 2019, 3d-gussner, Fixed selction GOLD/UNKNOWN DEV_STATUS for ALL variants builds, so you have to choose only once +# 15 Feb 2019, 3d-gussner, Fixed selection GOLD/UNKNOWN DEV_STATUS for ALL variants builds, so you have to choose only once # 15 Feb 2019, 3d-gussner, Added some colored output # 15 Feb 2019, 3d-gussner, troubleshooting and minor fixes # 16 Feb 2019, 3d-gussner, Script can be run using arguments # $1 = variant, example "1_75mm_MK3-EINSy10a-E3Dv6full.h" at this moment it is not possible to use ALL -# $2 = multi language OR english only [ALL/EN_ONLY] +# $2 = multi language OR English only [ALL/EN_ONLY] # $3 = development status [GOLD/RC/BETA/ALPHA/DEVEL/DEBUG] # If one argument is wrong a list of valid one will be shown -# 13 Mar 2019, 3d-gussner, MKbel updated the linux build environment to version 1.0.2 with an Fix maximum firmware flash size. +# 13 Mar 2019, 3d-gussner, MKbel updated the Linux build environment to version 1.0.2 with an Fix maximum firmware flash size. # So did I # 11 Jul 2019, deliopoulos,Updated to v1.0.6 as Prusa needs a new board definition for Firmware 3.8.x86_64 -# - Splitted the Download of Windows Arduino IDE 1.8.5 and Prusa specific part +# - Split the Download of Windows Arduino IDE 1.8.5 and Prusa specific part # --> less download volume needed and saves some time # -# 13 Jul 2019, deliopoulos,Splitting of Ardunio IDE and Prusa parts also for Linux64 +# 13 Jul 2019, deliopoulos,Splitting of Arduino IDE and Prusa parts also for Linux64 # 13 Jul 2019, 3d-gussner, Added Linux 32-bit version (untested yet) # MacOS could be added in future if needs # 14 Jul 2019, 3d-gussner, Update preferences and make it really portable -# 15 Jul 2019, 3d-gussner, New PF-build-env gihub branch -# 16 Jul 2019, 3d-gussner, New Arduino_boards github fork +# 15 Jul 2019, 3d-gussner, New PF-build-env GitHub branch +# 16 Jul 2019, 3d-gussner, New Arduino_boards GitHub fork # 17 Jul 2019, 3d-gussner, Final tests under Windows 10 and Linux Subsystem for Windows # 18 Jul 2019, 3d-gussner, Added python check # 18 Jul 2019, deliopoulos, No need more for changing 'platform.txt' file as it comes with the Arduino Boards. # 18 Jul 2019, deliopoulos, Modified 'PF_BUILD_FILE_URL' to use 'BUILD_ENV' variable -# 22 Jul 2019, 3d-gussner, Modiffied checks to check folder and/or installation output exists. +# 22 Jul 2019, 3d-gussner, Modified checks to check folder and/or installation output exists. # 22 Jul 2019, 3d-gussner, Added check if Arduino IDE 1.8.5 boards have been updated # 22 Jul 2019, 3d-gussner, Changed exit numbers 1-13 for prepare build env 21-28 for prepare compiling 31-36 compiling -# 22 Jul 2019, 3d-gussner, Changed BOARD_URL to DRracers respository after he pulled my PR https://github.com/DRracer/Arduino_Boards/pull/1 +# 22 Jul 2019, 3d-gussner, Changed BOARD_URL to DRracers repository after he pulled my PR https://github.com/DRracer/Arduino_Boards/pull/1 # 23 Jul 2019, 3d-gussner, Changed Build-env path to "PF-build-dl" as requested in PR https://github.com/prusa3d/Prusa-Firmware/pull/2028 # Changed Hex-files folder to PF-build-hex as requested in PR # 23 Jul 2019, 3d-gussner, Added Finding OS version routine so supporting new OS should get easier # 26 Jul 2019, 3d-gussner, Change JSON repository to prusa3d after PR https://github.com/prusa3d/Arduino_Boards/pull/1 was merged -# 23 Sep 2019, 3d-gussner, Prepare PF-build.sh for comming Prusa3d/Arduino_Boards version 1.0.2 Pull Request -# 17 Oct 2019, 3d-gussner, Changed folder and check file names to have seperated build enviroments depening on Arduino IDE version and +# 23 Sep 2019, 3d-gussner, Prepare PF-build.sh for coming Prusa3d/Arduino_Boards version 1.0.2 Pull Request +# 17 Oct 2019, 3d-gussner, Changed folder and check file names to have separated build environments depending on Arduino IDE version and # board-versions. # 15 Dec 2019, 3d-gussner, Prepare for switch to Prusa3d/PF-build-env repository -# 15 Dec 2019, 3d-gussner, Fix Audrino user preferences for the chosen board. +# 15 Dec 2019, 3d-gussner, Fix Arduino user preferences for the chosen board. # 17 Dec 2019, 3d-gussner, Fix "timer0_fract = 0" warning by using Arduino_boards v1.0.3 # 28 Apr 2020, 3d-gussner, Added RC3 detection # 03 May 2020, deliopoulos, Accept all RCx as RC versions # 05 May 2020, 3d-gussner, Make a copy of `not_tran.txt`and `not_used.txt` as `not_tran_$VARIANT.txt`and `not_used_$VARIANT.txt` -# After compiling All multilanguage vairants it makes it easier to find missing or unused transltions. +# After compiling All multi-language variants it makes it easier to find missing or unused translations. # 12 May 2020, DRracer , Cleanup double MK2/s MK25/s `not_tran` and `not_used` files # 13 May 2020, leptun , If cleanup files do not exist don't try to. +# 01 Oct 2020, 3d-gussner, Bug fix if using argument EN_ONLY. Thank to @leptun for pointing out. +# Change Build number to script commits 'git rev-list --count HEAD PF-build.sh' +# 02 Oct 2020, 3d-gussner, Add UNKNOWN as argument option +# 05 Oct 2020, 3d-gussner, Disable pause and warnings using command line with all needed arguments +# Install needed apps under linux if needed. +# Clean PF-Firmware build when changing git branch +# 02 Nov 2020, 3d-gussner, Check for "gawk" on Linux +# Add argument to change build number automatically to current commit or define own number +# Update exit numbers 1-13 for prepare build env 21-29 for prepare compiling 30-36 compiling +# 08 Jan 2021, 3d-gussner, Comment out 'sudo' auto installation +# Add '-?' '-h' help option + #### Start check if OSTYPE is supported OS_FOUND=$( command -v uname) @@ -198,13 +210,14 @@ if ! type zip > /dev/null; then elif [ $TARGET_OS == "linux" ]; then echo "$(tput setaf 1)Missing 'zip' which is important to run this script" echo "install it with the command $(tput setaf 2)'sudo apt-get install zip'$(tput sgr0)" + #sudo apt-get update && apt-get install zip exit 3 fi fi # Check python ... needed during language build if ! type python > /dev/null; then if [ $TARGET_OS == "windows" ]; then - echo "$(tput setaf 1)Missing 'python' which is important to run this script" + echo "$(tput setaf 1)Missing 'python3' which is important to run this script" exit 4 elif [ $TARGET_OS == "linux" ]; then echo "$(tput setaf 1)Missing 'python' which is important to run this script" @@ -212,6 +225,17 @@ if ! type python > /dev/null; then echo "install it with the command $(tput setaf 2)'sudo apt-get install python3'." echo "Check which version of Python3 has been installed using 'ls /usr/bin/python3*'" echo "Use 'sudo ln -sf /usr/bin/python3.x /usr/bin/python' (where 'x' is your version number) to make it default.$(tput sgr0)" + #sudo apt-get update && apt-get install python3 && ln -sf /usr/bin/python3 /usr/bin/python + exit 4 + fi +fi + +# Check gawk ... needed during language build +if ! type gawk > /dev/null; then + if [ $TARGET_OS == "linux" ]; then + echo "$(tput setaf 1)Missing 'gawk' which is important to run this script" + echo "install it with the command $(tput setaf 2)'sudo apt-get install gawk'." + #sudo apt-get update && apt-get install gawk exit 4 fi fi @@ -241,7 +265,7 @@ echo "Script path :" $SCRIPT_PATH echo "OS :" $OS echo "OS type :" $TARGET_OS echo "" -echo "Ardunio IDE :" $ARDUINO_ENV +echo "Arduino IDE :" $ARDUINO_ENV echo "Build env :" $BUILD_ENV echo "Board :" $BOARD echo "Package name:" $BOARD_PACKAGE_NAME @@ -422,8 +446,63 @@ fi #### Start cd $SCRIPT_PATH -# First argument defines which variant of the Prusa Firmware will be compiled -if [ -z "$1" ] ; then +# Check if git is available +if type git > /dev/null; then + git_available="1" +fi + +while getopts v:l:d:b:o:?h flag + do + case "${flag}" in + v) variant_flag=${OPTARG};; + l) language_flag=${OPTARG};; + d) devel_flag=${OPTARG};; + b) build_flag=${OPTARG};; + o) output_flag=${OPTARG};; + ?) help_flag=1;; + h) help_flag=1;; + esac + done +#echo "variant_flag: $variant_flag"; +#echo "language_flag: $language_flag"; +#echo "devel_flag: $devel_flag"; +#echo "build_flag: $build_flag"; +#echo "output_flag: $output_flag"; +#echo "help_flag: $help_flag" + +# +# '?' 'h' argument usage and help +if [ "$help_flag" == "1" ] ; then +echo "***************************************" +echo "* PF-build.sh Version: 1.0.6-Build_33 *" +echo "***************************************" +echo "Arguments:" +echo "$(tput setaf 2)-v$(tput sgr0) Variant '$(tput setaf 2)All$(tput sgr0)' or variant file name" +echo "$(tput setaf 2)-l$(tput sgr0) Languages '$(tput setaf 2)ALL$(tput sgr0)' for multi language or '$(tput setaf 2)EN_ONLY$(tput sgr0)' for English only" +echo "$(tput setaf 2)-d$(tput sgr0) Devel build '$(tput setaf 2)GOLD$(tput sgr0)', '$(tput setaf 2)RC$(tput sgr0)', '$(tput setaf 2)BETA$(tput sgr0)', '$(tput setaf 2)ALPHA$(tput sgr0)', '$(tput setaf 2)DEBUG$(tput sgr0)', '$(tput setaf 2)DEVEL$(tput sgr0)' and '$(tput setaf 2)UNKNOWN$(tput sgr0)'" +echo "$(tput setaf 2)-b$(tput sgr0) Build/commit number '$(tput setaf 2)Auto$(tput sgr0)' needs git or a number" +echo "$(tput setaf 2)-o$(tput sgr0) Output '$(tput setaf 2)1$(tput sgr0)' force or '$(tput setaf 2)0$(tput sgr0)' block output and delays" +echo "$(tput setaf 2)-?$(tput sgr0) Help" +echo "$(tput setaf 2)-h$(tput sgr0) Help" +echo +echo "Brief USAGE:" +echo " $(tput setaf 2)./PF-build.sh$(tput sgr0) [-v] [-l] [-d] [-b] [-o]" +echo +echo "Example:" +echo " $(tput setaf 2)./PF-build.sh -v All -l ALL -d GOLD$(tput sgr0)" +echo " Will build all variants as multi language and final GOLD version" +echo +echo " $(tput setaf 2) ./PF-build.sh -v 1_75mm_MK3S-EINSy10a-E3Dv6full.h -b Auto -l ALL -d GOLD -o 1$(tput sgr0)" +echo " Will build MK3S multi language final GOLD firmware " +echo " with current commit count number and output extra information" +echo +exit + +fi + +# +# '-v' argument defines which variant of the Prusa Firmware will be compiled +if [ -z "$variant_flag" ] ; then # Select which variant of the Prusa Firmware will be compiled, like PS3="Select a variant: " while IFS= read -r -d $'\0' f; do @@ -443,7 +522,7 @@ if [ -z "$1" ] ; then ;; "Quit") echo "You chose to stop" - exit + exit 20 ;; *) echo "$(tput setaf 1)This is not a valid variant$(tput sgr0)" @@ -451,21 +530,28 @@ if [ -z "$1" ] ; then esac done else - if [ -f "$SCRIPT_PATH/Firmware/variants/$1" ] ; then - VARIANTS=$1 + if [ -f "$SCRIPT_PATH/Firmware/variants/$variant_flag" ] ; then + VARIANTS=$variant_flag + elif [ "$variant_flag" == "All" ] ; then + while IFS= read -r -d $'\0' f; do + options[i++]="$f" + done < <(find Firmware/variants/ -maxdepth 1 -type f -name "*.h" -print0 ) + VARIANT="All" + VARIANTS=${options[*]} else - echo "$(tput setaf 1)$1 could not be found in Firmware/variants please choose a valid one$(tput setaf 2)" + echo "$(tput setaf 1)Argument $variant_flag could not be found in Firmware/variants please choose a valid one.$(tput sgr0)" + echo "Only $(tput setaf 2)'All'$(tput sgr0) and file names below are allowed as variant '-v' argument.$(tput setaf 2)" ls -1 $SCRIPT_PATH/Firmware/variants/*.h | xargs -n1 basename echo "$(tput sgr0)" exit 21 fi fi -#Second argument defines if it is an english only version. Known values EN_ONLY / ALL +#'-l' argument defines if it is an English only version. Known values EN_ONLY / ALL #Check default language mode MULTI_LANGUAGE_CHECK=$(grep --max-count=1 "^#define LANG_MODE *" $SCRIPT_PATH/Firmware/config.h|sed -e's/ */ /g'|cut -d ' ' -f3) -if [ -z "$2" ] ; then +if [ -z "$language_flag" ] ; then PS3="Select a language: " echo echo "Which lang-build do you want?" @@ -473,12 +559,10 @@ if [ -z "$2" ] ; then case $yn in "Multi languages") LANGUAGES="ALL" - sed -i -- "s/^#define LANG_MODE *0/#define LANG_MODE 1/g" $SCRIPT_PATH/Firmware/config.h break ;; "English only") LANGUAGES="EN_ONLY" - sed -i -- "s/^#define LANG_MODE *1/#define LANG_MODE 0/g" $SCRIPT_PATH/Firmware/config.h break ;; *) @@ -487,47 +571,106 @@ if [ -z "$2" ] ; then esac done else - if [[ "$2" == "ALL" || "$2" == "EN_ONLY" ]] ; then - LANGUAGES=$2 + if [[ "$language_flag" == "ALL" || "$language_flag" == "EN_ONLY" ]] ; then + LANGUAGES=$language_flag else echo "$(tput setaf 1)Language argument is wrong!$(tput sgr0)" - echo "Only $(tput setaf 2)'ALL'$(tput sgr0) or $(tput setaf 2)'EN_ONLY'$(tput sgr0) are allowed as 2nd argument!" + echo "Only $(tput setaf 2)'ALL'$(tput sgr0) or $(tput setaf 2)'EN_ONLY'$(tput sgr0) are allowed as language '-l' argument!" exit 22 fi fi -#Check if DEV_STATUS is selected via argument 3 -if [ ! -z "$3" ] ; then - if [[ "$3" == "GOLD" || "$3" == "RC" || "$3" == "BETA" || "$3" == "ALPHA" || "$3" == "DEVEL" || "$3" == "DEBUG" ]] ; then - DEV_STATUS_SELECTED=$3 +#Check if DEV_STATUS is selected via argument '-d' +if [ ! -z "$devel_flag" ] ; then + if [[ "$devel_flag" == "GOLD" || "$devel_flag" == "RC" || "$devel_flag" == "BETA" || "$devel_flag" == "ALPHA" || "$devel_flag" == "DEVEL" || "$devel_flag" == "DEBUG" || "$devel_flag" == "UNKNOWN" ]] ; then + DEV_STATUS_SELECTED=$devel_flag else echo "$(tput setaf 1)Development argument is wrong!$(tput sgr0)" - echo "Only $(tput setaf 2)'GOLD', 'RC', 'BETA', 'ALPHA', 'DEVEL' or 'DEBUG'$(tput sgr0) are allowed as 3rd argument!$(tput sgr0)" + echo "Only $(tput setaf 2)'GOLD', 'RC', 'BETA', 'ALPHA', 'DEVEL', 'DEBUG' or 'UNKNOWN' $(tput sgr0) are allowed as devel '-d' argument!$(tput sgr0)" exit 23 fi fi +#Check if Build is selected via argument '-b' +if [ ! -z "$build_flag" ] ; then + if [[ "$build_flag" == "Auto" && "$git_available" == "1" ]] ; then + echo "Build changed to $build_flag" + BUILD=$(git rev-list --count HEAD) + elif [[ $build_flag =~ ^[0-9]+$ ]] ; then + BUILD=$build_flag + else + echo "$(tput setaf 1)Build number argument is wrong!$(tput sgr0)" + echo "Only $(tput setaf 2)'Auto' (git needed) or numbers $(tput sgr0) are allowed as build '-b' argument!$(tput sgr0)" + exit 24 + + fi + echo "New Build number is: $BUILD" +fi + +# check if script has been started with arguments +if [[ "$#" -eq "0" || "$output_flag" == 1 ]] ; then + OUTPUT=1 +else + OUTPUT=0 +fi +#echo "Output is:" $OUTPUT + +#Check git branch has changed +if [ ! -z "git_available" ]; then + BRANCH="" + CLEAN_PF_FW_BUILD=0 +else + BRANCH=$(git branch --show-current) + echo "Current branch is:" $BRANCH + if [ ! -f "$SCRIPT_PATH/../PF-build.branch" ]; then + echo "$BRANCH" >| $SCRIPT_PATH/../PF-build.branch + echo "created PF-build.branch file" + else + PRE_BRANCH=$(cat "$SCRIPT_PATH/../PF-build.branch") + echo "Previous branch was:" $PRE_BRANCH + if [ ! "$BRANCH" == "$PRE_BRANCH" ] ; then + CLEAN_PF_FW_BUILD=1 + echo "$BRANCH" >| $SCRIPT_PATH/../PF-build.branch + fi + fi +fi + #Set BUILD_ENV_PATH -cd ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor || exit 24 +cd ../PF-build-env-$BUILD_ENV/$ARDUINO_ENV-$BOARD_VERSION-$TARGET_OS-$Processor || exit 25 BUILD_ENV_PATH="$( pwd -P )" cd ../.. #Checkif BUILD_PATH exists and if not creates it if [ ! -d "Prusa-Firmware-build" ]; then - mkdir Prusa-Firmware-build || exit 25 + mkdir Prusa-Firmware-build || exit 26 fi #Set the BUILD_PATH for Arduino IDE -cd Prusa-Firmware-build || exit 26 +cd Prusa-Firmware-build || exit 27 BUILD_PATH="$( pwd -P )" +#Check git branch has changed +if [ "$CLEAN_PF_FW_BUILD" == "1" ]; then + read -t 10 -p "Branch changed, cleaning Prusa-Firmware-build folder" + rm -r * +else + echo "Nothing to clean up" +fi + for v in ${VARIANTS[*]} do VARIANT=$(basename "$v" ".h") # Find firmware version in Configuration.h file and use it to generate the hex filename FW=$(grep --max-count=1 "\bFW_VERSION\b" $SCRIPT_PATH/Firmware/Configuration.h | sed -e's/ */ /g'|cut -d '"' -f2|sed 's/\.//g') - # Find build version in Configuration.h file and use it to generate the hex filename - BUILD=$(grep --max-count=1 "\bFW_COMMIT_NR\b" $SCRIPT_PATH/Firmware/Configuration.h | sed -e's/ */ /g'|cut -d ' ' -f3) + if [ -z "$BUILD" ] ; then + # Find build version in Configuration.h file and use it to generate the hex filename + BUILD=$(grep --max-count=1 "\bFW_COMMIT_NR\b" $SCRIPT_PATH/Firmware/Configuration.h | sed -e's/ */ /g'|cut -d ' ' -f3) + else + # Find and replace build version in Configuration.h file + BUILD_ORG=$(grep --max-count=1 "\bFW_COMMIT_NR\b" $SCRIPT_PATH/Firmware/Configuration.h | sed -e's/ */ /g'|cut -d ' ' -f3) + echo "Original build number: $BUILD_ORG" + sed -i -- "s/^#define FW_COMMIT_NR.*/#define FW_COMMIT_NR $BUILD/g" $SCRIPT_PATH/Firmware/Configuration.h + fi # Check if the motherboard is an EINSY and if so only one hex file will generated MOTHERBOARD=$(grep --max-count=1 "\bMOTHERBOARD\b" $SCRIPT_PATH/Firmware/variants/$VARIANT.h | sed -e's/ */ /g' |cut -d ' ' -f3) # Check development status @@ -571,7 +714,7 @@ do fi #Prepare hex files folders if [ ! -d "$SCRIPT_PATH/../PF-build-hex/FW$FW-Build$BUILD/$MOTHERBOARD" ]; then - mkdir -p $SCRIPT_PATH/../PF-build-hex/FW$FW-Build$BUILD/$MOTHERBOARD || exit 27 + mkdir -p $SCRIPT_PATH/../PF-build-hex/FW$FW-Build$BUILD/$MOTHERBOARD || exit 28 fi OUTPUT_FOLDER="PF-build-hex/FW$FW-Build$BUILD/$MOTHERBOARD" @@ -580,18 +723,24 @@ do echo "" ls -1 $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT.hex | xargs -n1 basename echo "$(tput setaf 6)This hex file to be compiled already exists! To cancel this process press CRTL+C and rename existing hex file.$(tput sgr 0)" - read -t 10 -p "Press Enter to continue..." + if [ $OUTPUT == "1" ] ; then + read -t 10 -p "Press Enter to continue..." + fi elif [[ -f "$SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-EN_ONLY.hex" && "$LANGUAGES" == "EN_ONLY" ]]; then echo "" ls -1 $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-EN_ONLY.hex | xargs -n1 basename echo "$(tput setaf 6)This hex file to be compiled already exists! To cancel this process press CRTL+C and rename existing hex file.$(tput sgr 0)" - read -t 10 -p "Press Enter to continue..." + if [ $OUTPUT == "1" ] ; then + read -t 10 -p "Press Enter to continue..." + fi fi if [[ -f "$SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT.zip" && "$LANGUAGES" == "ALL" ]]; then echo "" ls -1 $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT.zip | xargs -n1 basename echo "$(tput setaf 6)This zip file to be compiled already exists! To cancel this process press CRTL+C and rename existing hex file.$(tput sgr 0)" - read -t 10 -p "Press Enter to continue..." + if [ $OUTPUT == "1" ] ; then + read -t 10 -p "Press Enter to continue..." + fi fi #List some useful data @@ -608,11 +757,13 @@ do #Prepare Firmware to be compiled by copying variant as Configuration_prusa.h if [ ! -f "$SCRIPT_PATH/Firmware/Configuration_prusa.h" ]; then - cp -f $SCRIPT_PATH/Firmware/variants/$VARIANT.h $SCRIPT_PATH/Firmware/Configuration_prusa.h || exit 28 + cp -f $SCRIPT_PATH/Firmware/variants/$VARIANT.h $SCRIPT_PATH/Firmware/Configuration_prusa.h || exit 29 else echo "$(tput setaf 6)Configuration_prusa.h already exist it will be overwritten in 10 seconds by the chosen variant.$(tput sgr 0)" - read -t 10 -p "Press Enter to continue..." - cp -f $SCRIPT_PATH/Firmware/variants/$VARIANT.h $SCRIPT_PATH/Firmware/Configuration_prusa.h || exit 28 + if [ $OUTPUT == "1" ] ; then + read -t 10 -p "Press Enter to continue..." + fi + cp -f $SCRIPT_PATH/Firmware/variants/$VARIANT.h $SCRIPT_PATH/Firmware/Configuration_prusa.h || exit 29 fi #Prepare Configuration.h to use the correct FW_DEV_VERSION to prevent LCD messages when connecting with OctoPrint @@ -621,14 +772,16 @@ do # set FW_REPOSITORY sed -i -- 's/#define FW_REPOSITORY "Unknown"/#define FW_REPOSITORY "Prusa3d"/g' $SCRIPT_PATH/Firmware/Configuration.h - #Prepare english only or multilanguage version to be build - if [ $LANGUAGES == "ALL" ]; then + #Prepare English only or multi-language version to be build + if [ $LANGUAGES == "EN_ONLY" ]; then echo " " - echo "Multi-language firmware will be built" + echo "English only language firmware will be built" + sed -i -- "s/^#define LANG_MODE *1/#define LANG_MODE 0/g" $SCRIPT_PATH/Firmware/config.h echo " " else echo " " - echo "English only language firmware will be built" + echo "Multi-language firmware will be built" + sed -i -- "s/^#define LANG_MODE *0/#define LANG_MODE 1/g" $SCRIPT_PATH/Firmware/config.h echo " " fi @@ -651,9 +804,11 @@ do echo "Start to build Prusa Firmware ..." echo "Using variant $VARIANT$(tput setaf 3)" - sleep 2 + if [ $OUTPUT == "1" ] ; then + sleep 2 + fi #$BUILD_ENV_PATH/arduino-builder -dump-prefs -debug-level 10 -compile -hardware $ARDUINO/hardware -hardware $ARDUINO/portable/packages -tools $ARDUINO/tools-builder -tools $ARDUINO/hardware/tools/avr -tools $ARDUINO/portable/packages -built-in-libraries $ARDUINO/libraries -libraries $ARDUINO/portable/sketchbook/libraries -fqbn=$BOARD_PACKAGE_NAME:avr:$BOARD -build-path=$BUILD_PATH -warnings=all $SCRIPT_PATH/Firmware/Firmware.ino || exit 14 - $BUILD_ENV_PATH/arduino-builder -compile -hardware $ARDUINO/hardware -hardware $ARDUINO/portable/packages -tools $ARDUINO/tools-builder -tools $ARDUINO/hardware/tools/avr -tools $ARDUINO/portable/packages -built-in-libraries $ARDUINO/libraries -libraries $ARDUINO/portable/sketchbook/libraries -fqbn=$BOARD_PACKAGE_NAME:avr:$BOARD -build-path=$BUILD_PATH -warnings=all $SCRIPT_PATH/Firmware/Firmware.ino || exit 14 + $BUILD_ENV_PATH/arduino-builder -compile -hardware $ARDUINO/hardware -hardware $ARDUINO/portable/packages -tools $ARDUINO/tools-builder -tools $ARDUINO/hardware/tools/avr -tools $ARDUINO/portable/packages -built-in-libraries $ARDUINO/libraries -libraries $ARDUINO/portable/sketchbook/libraries -fqbn=$BOARD_PACKAGE_NAME:avr:$BOARD -build-path=$BUILD_PATH -warnings=all $SCRIPT_PATH/Firmware/Firmware.ino || exit 30 echo "$(tput sgr 0)" if [ $LANGUAGES == "ALL" ]; then @@ -661,7 +816,9 @@ do echo "Building multi language firmware" $MULTI_LANGUAGE_CHECK echo "$(tput sgr 0)" - sleep 2 + if [ $OUTPUT == "1" ] ; then + sleep 2 + fi cd $SCRIPT_PATH/lang echo "$(tput setaf 3)" ./config.sh || exit 31 @@ -670,7 +827,9 @@ do if [ -f "lang_en.tmp" ]; then echo "" echo "$(tput setaf 6)Previous lang build files already exist these will be cleaned up in 10 seconds.$(tput sgr 0)" - read -t 10 -p "Press Enter to continue..." + if [ $OUTPUT == "1" ] ; then + read -t 10 -p "Press Enter to continue..." + fi echo "$(tput setaf 3)" ./lang-clean.sh echo "$(tput sgr 0)" @@ -678,7 +837,9 @@ do if [ -f "progmem.out" ]; then echo "" echo "$(tput setaf 6)Previous firmware build files already exist these will be cleaned up in 10 seconds.$(tput sgr 0)" - read -t 10 -p "Press Enter to continue..." + if [ $OUTPUT == "1" ] ; then + read -t 10 -p "Press Enter to continue..." + fi echo "$(tput setaf 3)" ./fw-clean.sh echo "$(tput sgr 0)" @@ -740,13 +901,19 @@ do then rm $SCRIPT_PATH/lang/not_used.txt fi + # Restore files to previous state sed -i -- "s/^#define FW_DEV_VERSION FW_VERSION_$DEV_STATUS/#define FW_DEV_VERSION FW_VERSION_UNKNOWN/g" $SCRIPT_PATH/Firmware/Configuration.h sed -i -- 's/^#define FW_REPOSITORY "Prusa3d"/#define FW_REPOSITORY "Unknown"/g' $SCRIPT_PATH/Firmware/Configuration.h + if [ ! -z "$BUILD_ORG" ] ; then + sed -i -- "s/^#define FW_COMMIT_NR.*/#define FW_COMMIT_NR $BUILD_ORG/g" $SCRIPT_PATH/Firmware/Configuration.h + fi echo $MULTI_LANGUAGE_CHECK #sed -i -- "s/^#define LANG_MODE * /#define LANG_MODE $MULTI_LANGUAGE_CHECK/g" $SCRIPT_PATH/Firmware/config.h sed -i -- "s/^#define LANG_MODE *1/#define LANG_MODE ${MULTI_LANGUAGE_CHECK}/g" $SCRIPT_PATH/Firmware/config.h sed -i -- "s/^#define LANG_MODE *0/#define LANG_MODE ${MULTI_LANGUAGE_CHECK}/g" $SCRIPT_PATH/Firmware/config.h - sleep 5 + if [ $OUTPUT == "1" ] ; then + sleep 5 + fi done # Switch to hex path and list build files diff --git a/README.md b/README.md index 1562552bcc..108214c0d1 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ _Note: Multi language build is not supported._ **c.** Modify compiler flags in `platform.txt` file -* The platform.txt file can be found in Arduino instalation directory, or after Arduino has been updated at: `"C:\Users\(user)\AppData\Local\Arduino15\packages\arduino\hardware\avr\(version)"` If you can locate the file in both places, file from user profile is probably used. +* The platform.txt file can be found in Arduino installation directory, or after Arduino has been updated at: `"C:\Users\(user)\AppData\Local\Arduino15\packages\arduino\hardware\avr\(version)"` If you can locate the file in both places, file from user profile is probably used. * Add `"-Wl,-u,vfprintf -lprintf_flt -lm"` to `"compiler.c.elf.flags="` before existing flag "-Wl,--gc-sections" @@ -111,10 +111,13 @@ _notes: Script and instructions contributed by 3d-gussner. Use at your own risk. - follow the Microsoft guide https://docs.microsoft.com/en-us/windows/wsl/install-win10 You can also use the 'prepare_winbuild.ps1' powershell script with Administrator rights - Tested versions are at this moment - - Ubuntu other may different + - Ubuntu and Debian, other may different - After the installation and reboot please open your Ubuntu bash and do following steps - - run command `apt-get update` - - to install zip run `apt-get install zip` + - run command `sudo apt-get update` + - run command `sudo apt-get upgrade` + - to install zip run `sudo apt-get install zip` + - to install dos2unix run `sudo apt-get install dos2unix` + - run `dos2unix PF-build.sh` to convert the windows line endings to unix line endings - add few lines at the top of `~/.bashrc` by running `sudo nano ~/.bashrc` export OS="Linux" @@ -122,11 +125,11 @@ _notes: Script and instructions contributed by 3d-gussner. Use at your own risk. export GPG_TTY=$(tty) use `CRTL-X` to close nano and confirm to write the new entries - - restart Ubuntu bash -Now your Ubuntu subsystem is ready to use the automatic `PF-build.sh` script and compile your firmware correctly + - restart Ubuntu/Debian bash + - Now your Ubuntu/Debian subsystem is ready to use the automatic `PF-build.sh` script and compile your firmware correctly -#### Some Tips for Ubuntu -- Linux is case sensetive so please don't forget to use capital letters where needed, like changing to a directory +#### Some Tips for Ubuntu and Debian +- Linux is case sensitive so please don't forget to use capital letters where needed, like changing to a directory - To change the path to your Prusa-Firmware location you downloaded and unzipped - Example: You files are under `C:\Users\\Downloads\Prusa-Firmware-MK3` - use under Ubuntu the following command `cd /mnt/c/Users//Downloads/Prusa-Firmware-MK3` @@ -137,7 +140,7 @@ Now your Ubuntu subsystem is ready to use the automatic `PF-build.sh` script and - If your Windows isn't in English the Paths may look different Example in other languages - English `/mnt/c/Users//Downloads/Prusa-Firmware-MK3` will be on a German Windows`/mnt/c/Anwender//Downloads/Prusa-Firmware-MK3` -#### Compile Prusa-firmware with Ubuntu Linux subsystem installed +#### Compile Prusa-firmware with Ubuntu/Debian Linux subsystem installed - open Ubuntu bash - change to your source code folder (case sensitive) - run `./PF-build.sh` @@ -206,7 +209,7 @@ or visit https://prusa3d.github.io/Prusa-Firmware-Doc for doxygen generated outp # 5. FAQ Q:I built firmware using Arduino and I see "?" instead of numbers in printer user interface. -A:Step 1.c was ommited or you updated Arduino and now platform.txt located somewhere in your user profile is used. +A:Step 1.c was omitted or you updated Arduino and now platform.txt located somewhere in your user profile is used. Q:I built firmware using Arduino and printer now speaks Klingon (nonsense characters and symbols are displayed @^#$&*°;~ÿ) @@ -218,4 +221,4 @@ A:Our production builds are 99.9% equivalent to https://github.com/prusa3d/Prusa Q:Why are build instructions for Arduino mess. -Y:We are too lazy to ship proper board definition for Arduino. We plan to swich to cmake + ninja to be inherently multiplatform, easily integrate build tools, suport more IDEs, get 10 times shorter build times and be able to update compiler whenewer we want. +Y:We are too lazy to ship proper board definition for Arduino. We plan to switch to cmake + ninja to be inherently multiplatform, easily integrate build tools, suport more IDEs, get 10 times shorter build times and be able to update compiler whenever we want.