Merge commit 'refs/tags/v3.8.0-RC1^{}' into enable_cutter

This commit is contained in:
Marek Bel 2019-08-15 14:48:28 +02:00
commit 469ca6e184
62 changed files with 3960 additions and 1232 deletions

1
.gitignore vendored
View file

@ -51,3 +51,4 @@ Firmware/Doc
/build-env/
/Firmware/Firmware.vcxproj
/Firmware/Configuration_prusa_bckp.h
/Firmware/variants/printers.h

View file

@ -1,6 +1,13 @@
dist: trusty
before_install:
- sudo apt-get install -y ninja-build
# Arduino IDE adds a lot of noise caused by network traffic, trying to firewall it off
- sudo iptables -P INPUT DROP
- sudo iptables -P FORWARD DROP
- sudo iptables -P OUTPUT ACCEPT
- sudo iptables -A INPUT -i lo -j ACCEPT
- sudo iptables -A OUTPUT -o lo -j ACCEPT
- sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
script:
- bash -x test.sh
- cp Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h Firmware/Configuration_prusa.h

View file

@ -15,6 +15,7 @@ set(TEST_SOURCES
Tests/Example_test.cpp
Tests/Timer_test.cpp
Tests/AutoDeplete_test.cpp
Tests/PrusaStatistics_test.cpp
Firmware/Timer.cpp
Firmware/AutoDeplete.cpp
)

View file

@ -0,0 +1,10 @@
#include "Configuration.h"
#include "Configuration_prusa.h"
const uint16_t _nPrinterType PROGMEM=PRINTER_TYPE;
const char _sPrinterName[] PROGMEM=PRINTER_NAME;
const uint16_t _nPrinterMmuType PROGMEM=PRINTER_MMU_TYPE;
const char _sPrinterMmuName[] PROGMEM=PRINTER_MMU_NAME;
uint16_t nPrinterType;
PGM_P sPrinterName;

View file

@ -6,15 +6,27 @@
#define STR_HELPER(x) #x
#define STR(x) STR_HELPER(x)
//-//
#include <avr/pgmspace.h>
extern const uint16_t _nPrinterType;
extern const char _sPrinterName[] PROGMEM;
extern const uint16_t _nPrinterMmuType;
extern const char _sPrinterMmuName[] PROGMEM;
extern uint16_t nPrinterType;
extern PGM_P sPrinterName;
// Firmware version
#define FW_VERSION "3.7.2-RC1"
#define FW_COMMIT_NR 2359
#define FW_VERSION "3.7.2"
#define FW_COMMIT_NR 2363
// 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
#define FW_REPOSITORY "Unknown"
#define FW_VERSION_FULL FW_VERSION "-" STR(FW_COMMIT_NR)
// G-code language level
#define GCODE_LEVEL 1
// Debug version has debugging enabled (the symbol DEBUG_BUILD is set).
// The debug build may be a bit slower than the non-debug build, therefore the debug build should
// not be shipped to a customer.

View file

@ -79,9 +79,9 @@ extern FILE _uartout;
#define SERIAL_PROTOCOL_F(x,y) (MYSERIAL.print(x,y))
#define SERIAL_PROTOCOLPGM(x) (serialprintPGM(PSTR(x)))
#define SERIAL_PROTOCOLRPGM(x) (serialprintPGM((x)))
#define SERIAL_PROTOCOLLN(x) (MYSERIAL.print(x),MYSERIAL.write('\n'))
#define SERIAL_PROTOCOLLNPGM(x) (serialprintPGM(PSTR(x)),MYSERIAL.write('\n'))
#define SERIAL_PROTOCOLLNRPGM(x) (serialprintPGM((x)),MYSERIAL.write('\n'))
#define SERIAL_PROTOCOLLN(x) (MYSERIAL.println(x)/*,MYSERIAL.write('\n')*/)
#define SERIAL_PROTOCOLLNPGM(x) (serialprintPGM(PSTR(x)),MYSERIAL.println()/*write('\n')*/)
#define SERIAL_PROTOCOLLNRPGM(x) (serialprintPGM((x)),MYSERIAL.println()/*write('\n')*/)
extern const char errormagic[] PROGMEM;
@ -111,15 +111,9 @@ void serial_echopair_P(const char *s_P, unsigned long v);
//Things to write to serial from Program memory. Saves 400 to 2k of RAM.
FORCE_INLINE void serialprintPGM(const char *str)
{
char ch=pgm_read_byte(str);
while(ch)
{
MYSERIAL.write(ch);
ch=pgm_read_byte(++str);
}
}
// Making this FORCE_INLINE is not a good idea when running out of FLASH
// I'd rather skip a few CPU ticks than 5.5KB (!!) of FLASH
void serialprintPGM(const char *str);
bool is_buffer_empty();
void get_command();
@ -172,6 +166,17 @@ void manage_inactivity(bool ignore_stepper_queue=false);
#define disable_z() {}
#endif
#ifdef PSU_Delta
void init_force_z();
void check_force_z();
#undef disable_z
#define disable_z() disable_force_z()
void disable_force_z();
#undef enable_z
#define enable_z() enable_force_z()
void enable_force_z();
#endif // PSU_Delta
@ -303,6 +308,11 @@ extern bool axis_known_position[3];
extern int fanSpeed;
extern int8_t lcd_change_fil_state;
const char smooth1[] PROGMEM = "Smooth1";
const char smooth2[] PROGMEM = "Smooth2";
const char textured[] PROGMEM = "Textur1";
const char *const defaultSheetNames[] PROGMEM = {smooth1,smooth2,textured};
#ifdef TMC2130
void homeaxis(int axis, uint8_t cnt = 1, uint8_t* pstep = 0);
#else
@ -323,7 +333,6 @@ extern float retract_recover_length_swap;
extern uint8_t host_keepalive_interval;
extern unsigned long starttime;
extern unsigned long stoptime;
extern int bowden_length[4];
@ -393,6 +402,7 @@ extern LongTimer safetyTimer;
#define PRINT_PERCENT_DONE_INIT 0xff
#define PRINTER_ACTIVE (IS_SD_PRINTING || is_usb_printing || isPrintPaused || (custom_message_type == CustomMsg::TempCal) || saved_printing || (lcd_commands_type == LcdCommands::Layer1Cal) || card.paused || mmu_print_saved)
//! Beware - mcode_in_progress is set as soon as the command gets really processed,
//! which is not the same as posting the M600 command into the command queue
//! There can be a considerable lag between posting M600 and its real processing which might result

View file

@ -96,7 +96,7 @@ class MarlinSerial //: public Stream
static int read(void);
static void flush(void);
static FORCE_INLINE int available(void)
static /*FORCE_INLINE*/ int available(void)
{
return (unsigned int)(RX_BUFFER_SIZE + rx_buffer.head - rx_buffer.tail) % RX_BUFFER_SIZE;
}
@ -184,14 +184,14 @@ class MarlinSerial //: public Stream
public:
static FORCE_INLINE void write(const char *str)
static /*FORCE_INLINE*/ void write(const char *str)
{
while (*str)
write(*str++);
}
static FORCE_INLINE void write(const uint8_t *buffer, size_t size)
static /*FORCE_INLINE*/ void write(const uint8_t *buffer, size_t size)
{
while (size--)
write(*buffer++);

File diff suppressed because it is too large Load diff

View file

@ -2050,7 +2050,7 @@ PERLMOD_MAKEVAR_PREFIX =
# C-preprocessor directives found in the sources and include files.
# The default value is: YES.
ENABLE_PREPROCESSING = YES
ENABLE_PREPROCESSING = NO
# If the MACRO_EXPANSION tag is set to YES, doxygen will expand all macro names
# in the source code. If set to NO, only conditional compilation will be

95
Firmware/eeprom.cpp Normal file
View file

@ -0,0 +1,95 @@
//! @file
//! @date Jun 20, 2019
//! @author Marek Běl
#include "eeprom.h"
#include "Marlin.h"
#include <avr/eeprom.h>
#include <stdint.h>
#include "language.h"
#if 0
template <typename T>
static T eeprom_read(T *address);
template<>
char eeprom_read<char>(char *address)
{
return eeprom_read_byte(reinterpret_cast<uint8_t*>(address));
}
#endif
template <typename T>
static void eeprom_write(T *address, T value);
template<>
void eeprom_write<char>(char *addres, char value)
{
eeprom_write_byte(reinterpret_cast<uint8_t*>(addres), static_cast<uint8_t>(value));
}
template <typename T>
static bool eeprom_is_uninitialized(T *address);
template <>
bool eeprom_is_uninitialized<char>(char *address)
{
return (0xff == eeprom_read_byte(reinterpret_cast<uint8_t*>(address)));
}
bool is_sheet_initialized(uint8_t sheet_num){
return (0xffff != eeprom_read_word(reinterpret_cast<uint16_t*>(&(EEPROM_Sheets_base->
s[sheet_num].z_offset))));
}
void eeprom_init()
{
if (eeprom_read_byte((uint8_t*)EEPROM_POWER_COUNT) == 0xff) eeprom_write_byte((uint8_t*)EEPROM_POWER_COUNT, 0);
if (eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_X) == 0xff) eeprom_write_byte((uint8_t*)EEPROM_CRASH_COUNT_X, 0);
if (eeprom_read_byte((uint8_t*)EEPROM_CRASH_COUNT_Y) == 0xff) eeprom_write_byte((uint8_t*)EEPROM_CRASH_COUNT_Y, 0);
if (eeprom_read_byte((uint8_t*)EEPROM_FERROR_COUNT) == 0xff) eeprom_write_byte((uint8_t*)EEPROM_FERROR_COUNT, 0);
if (eeprom_read_word((uint16_t*)EEPROM_POWER_COUNT_TOT) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_POWER_COUNT_TOT, 0);
if (eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_X_TOT) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_CRASH_COUNT_X_TOT, 0);
if (eeprom_read_word((uint16_t*)EEPROM_CRASH_COUNT_Y_TOT) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_CRASH_COUNT_Y_TOT, 0);
if (eeprom_read_word((uint16_t*)EEPROM_FERROR_COUNT_TOT) == 0xffff) eeprom_write_word((uint16_t*)EEPROM_FERROR_COUNT_TOT, 0);
if (eeprom_read_word((uint16_t*)EEPROM_MMU_FAIL_TOT) == 0xffff) eeprom_update_word((uint16_t *)EEPROM_MMU_FAIL_TOT, 0);
if (eeprom_read_word((uint16_t*)EEPROM_MMU_LOAD_FAIL_TOT) == 0xffff) eeprom_update_word((uint16_t *)EEPROM_MMU_LOAD_FAIL_TOT, 0);
if (eeprom_read_byte((uint8_t*)EEPROM_MMU_FAIL) == 0xff) eeprom_update_byte((uint8_t *)EEPROM_MMU_FAIL, 0);
if (eeprom_read_byte((uint8_t*)EEPROM_MMU_LOAD_FAIL) == 0xff) eeprom_update_byte((uint8_t *)EEPROM_MMU_LOAD_FAIL, 0);
if (eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)) == 0xff) eeprom_update_byte(&(EEPROM_Sheets_base->active_sheet), 0);
for (uint_least8_t i = 0; i < (sizeof(Sheets::s)/sizeof(Sheets::s[0])); ++i)
{
bool is_uninitialized = true;
for (uint_least8_t j = 0; j < (sizeof(Sheet::name)/sizeof(Sheet::name[0])); ++j)
{
if (!eeprom_is_uninitialized(&(EEPROM_Sheets_base->s[i].name[j]))) is_uninitialized = false;
}
if(is_uninitialized)
{
char sheet_PROGMEM_buffer[8];
strcpy_P(sheet_PROGMEM_buffer, (char *)pgm_read_word(&(defaultSheetNames[i])));
for (uint_least8_t a = 0; a < sizeof(Sheet::name); ++a){
eeprom_write(&(EEPROM_Sheets_base->s[i].name[a]), sheet_PROGMEM_buffer[a]);
}
// When upgrading from version older version (before multiple sheets were implemented in v3.8.0)
// Sheet 1 uses the previous Live adjust Z (@EEPROM_BABYSTEP_Z)
if(i == 0){
int last_babystep = eeprom_read_word((uint16_t *)EEPROM_BABYSTEP_Z);
eeprom_write_word(reinterpret_cast<uint16_t *>(&(EEPROM_Sheets_base->s[i].z_offset)), last_babystep);
}
}
}
check_babystep();
}

View file

@ -1,6 +1,36 @@
#ifndef EEPROM_H
#define EEPROM_H
#include <stdint.h>
#ifdef __cplusplus
void eeprom_init();
extern bool is_sheet_initialized(uint8_t sheet_num);
#endif
typedef struct
{
char name[7]; //!< Can be null terminated, doesn't need to be null terminated
int16_t z_offset; //!< Z_BABYSTEP_MIN .. Z_BABYSTEP_MAX = Z_BABYSTEP_MIN*2/1000 [mm] .. Z_BABYSTEP_MAX*2/1000 [mm]
uint8_t bed_temp; //!< 0 .. 254 [°C]
uint8_t pinda_temp; //!< 0 .. 254 [°C]
} Sheet;
typedef struct
{
Sheet s[3];
uint8_t active_sheet;
} Sheets;
// sizeof(Sheets). Do not change it unless EEPROM_Sheets_base is last item in EEPROM.
// Otherwise it would move following items.
#define EEPROM_SHEETS_SIZEOF 34
#ifdef __cplusplus
static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEPROM_SHEETS_SIZEOF.");
#endif
#define EEPROM_EMPTY_VALUE 0xFF
// The total size of the EEPROM is
// 4096 for the Atmega2560
#define EEPROM_TOP 4096
@ -166,32 +196,21 @@
#define EEPROM_CHECK_MODE (EEPROM_MMU_STEALTH-1) // uint8
#define EEPROM_NOZZLE_DIAMETER (EEPROM_CHECK_MODE-1) // uint8
#define EEPROM_NOZZLE_DIAMETER_uM (EEPROM_NOZZLE_DIAMETER-2) // uint16
#define EEPROM_CHECK_MODEL (EEPROM_NOZZLE_DIAMETER_uM-1) // uint8
#define EEPROM_CHECK_VERSION (EEPROM_CHECK_MODEL-1) // uint8
#define EEPROM_CHECK_GCODE (EEPROM_CHECK_VERSION-1) // uint8
#define EEPROM_SHEETS_BASE (EEPROM_CHECK_GCODE - EEPROM_SHEETS_SIZEOF) // Sheets
static Sheets * const EEPROM_Sheets_base = (Sheets*)(EEPROM_SHEETS_BASE);
//This is supposed to point to last item to allow EEPROM overrun check. Please update when adding new items.
#define EEPROM_LAST_ITEM EEPROM_SHEETS_BASE
// !!!!!
// !!!!! this is end of EEPROM section ... all updates MUST BE inserted before this mark !!!!!
// !!!!!
//TMC2130 configuration
#define EEPROM_TMC_AXIS_SIZE //axis configuration block size
#define EEPROM_TMC_X (EEPROM_TMC + 0 * EEPROM_TMC_AXIS_SIZE) //X axis configuration blok
#define EEPROM_TMC_Y (EEPROM_TMC + 1 * EEPROM_TMC_AXIS_SIZE) //Y axis
#define EEPROM_TMC_Z (EEPROM_TMC + 2 * EEPROM_TMC_AXIS_SIZE) //Z axis
#define EEPROM_TMC_E (EEPROM_TMC + 3 * EEPROM_TMC_AXIS_SIZE) //E axis
//TMC2130 - X axis
#define EEPROM_TMC_X_USTEPS_INTPOL (EEPROM_TMC_X + 0) // 1byte, bit 0..4 USTEPS, bit 7 INTPOL
#define EEPROM_TMC_X_PWM_AMPL (EEPROM_TMC_X + 1) // 1byte (0..255)
#define EEPROM_TMC_X_PWM_GRAD_FREQ (EEPROM_TMC_X + 2) // 1byte, bit 0..3 GRAD, bit 4..5 FREQ
#define EEPROM_TMC_X_TCOOLTHRS (EEPROM_TMC_X + 3) // 2bytes (0..)
#define EEPROM_TMC_X_SG_THRS (EEPROM_TMC_X + 5) // 1byte, (-64..+63)
#define EEPROM_TMC_X_CURRENT_H (EEPROM_TMC_X + 6) // 1byte, (0..63)
#define EEPROM_TMC_X_CURRENT_R (EEPROM_TMC_X + 7) // 1byte, (0..63)
#define EEPROM_TMC_X_HOME_SG_THRS (EEPROM_TMC_X + 8) // 1byte, (-64..+63)
#define EEPROM_TMC_X_HOME_CURRENT_R (EEPROM_TMC_X + 9) // 1byte, (-64..+63)
#define EEPROM_TMC_X_HOME_DTCOOLTHRS (EEPROM_TMC_X + 10) // 1byte (-128..+127)
#define EEPROM_TMC_X_DTCOOLTHRS_LOW (EEPROM_TMC_X + 11) // 1byte (-128..+127)
#define EEPROM_TMC_X_DTCOOLTHRS_HIGH (EEPROM_TMC_X + 12) // 1byte (-128..+127)
#define EEPROM_TMC_X_SG_THRS_LOW (EEPROM_TMC_X + 13) // 1byte, (-64..+63)
#define EEPROM_TMC_X_SG_THRS_HIGH (EEPROM_TMC_X + 14) // 1byte, (-64..+63)
// Currently running firmware, each digit stored as uint16_t.
// The flavor differentiates a dev, alpha, beta, release candidate or a release version.
@ -205,7 +224,9 @@
#ifdef __cplusplus
#include "ConfigurationStore.h"
static M500_conf * const EEPROM_M500_base = reinterpret_cast<M500_conf*>(20); //offset for storing settings using M500
static_assert(EEPROM_FIRMWARE_VERSION_END < 20, "Firmware version EEPROM address conflicts with EEPROM_M500_base");
static constexpr M500_conf * const EEPROM_M500_base = reinterpret_cast<M500_conf*>(20); //offset for storing settings using M500
static_assert(((sizeof(M500_conf) + 20) < EEPROM_LAST_ITEM), "M500_conf address space conflicts with previous items.");
#endif
enum

View file

@ -522,19 +522,6 @@ void fsensor_st_block_chunk(block_t* bl, int cnt)
}
}
//! This ensures generating z-position at least 25mm above the heat bed.
//! Making this a template enables changing the computation data type easily at all spots where necessary.
//! @param current_z current z-position
//! @return z-position at least 25mm above the heat bed plus FILAMENTCHANGE_ZADD
template <typename T>
inline T fsensor_clamp_z(float current_z){
T z( current_z );
if(z < T(25)){ // make sure the compiler understands, that the constant 25 is of correct type
// - necessary for uint8_t -> results in shorter code
z = T(25); // move to at least 25mm above heat bed
}
return z + T(FILAMENTCHANGE_ZADD); // always move above the printout by FILAMENTCHANGE_ZADD (default 2mm)
}
//! Common code for enqueing M600 and supplemental codes into the command queue.
//! Used both for the IR sensor and the PAT9125
@ -545,22 +532,6 @@ void fsensor_enque_M600(){
enquecommand_front_P(PSTR("PRUSA fsensor_recover"));
fsensor_m600_enqueued = true;
enquecommand_front_P((PSTR("M600")));
#define xstr(a) str(a)
#define str(a) #a
static const char gcodeMove[] PROGMEM =
"G1 X" xstr(FILAMENTCHANGE_XPOS)
" Y" xstr(FILAMENTCHANGE_YPOS)
" Z%u";
#undef str
#undef xstr
char buf[32];
// integer arithmetics is far shorter, I don't need a precise float position here, just move a bit above
// 8bit arithmetics in fsensor_clamp_z is 10B shorter than 16bit (not talking about float ;) )
// The compile-time static_assert here ensures, that the computation gets enough bits in case of Z-range too high,
// i.e. makes the user change the data type, which also results in larger code
static_assert(Z_MAX_POS < (255 - FILAMENTCHANGE_ZADD), "Z-range too high, change fsensor_clamp_z<uint8_t> to <uint16_t>");
sprintf_P(buf, gcodeMove, fsensor_clamp_z<uint8_t>(current_position[Z_AXIS]) );
enquecommand_front(buf, false);
}
//! @brief filament sensor update (perform M600 on filament runout)

109
Firmware/heatbed_pwm.cpp Executable file
View file

@ -0,0 +1,109 @@
#include <avr/io.h>
#include <avr/interrupt.h>
#include "io_atmega2560.h"
// All this is about silencing the heat bed, as it behaves like a loudspeaker.
// Basically, we want the PWM heating switched at 30Hz (or so) which is a well ballanced
// frequency for both power supply units (i.e. both PSUs are reasonably silent).
// The only trouble is the rising or falling edge of bed heating - that creates an audible click.
// This audible click may be suppressed by making the rising or falling edge NOT sharp.
// Of course, making non-sharp edges in digital technology is not easy, but there is a solution.
// It is possible to do a fast PWM sequence with duty starting from 0 to 255.
// Doing this at higher frequency than the bed "loudspeaker" can handle makes the click barely audible.
// Technically:
// timer0 is set to fast PWM mode at 62.5kHz (timer0 is linked to the bed heating pin) (zero prescaler)
// To keep the bed switching at 30Hz - we don't want the PWM running at 62kHz all the time
// since it would burn the heatbed's MOSFET:
// 16MHz/256 levels of PWM duty gives us 62.5kHz
// 62.5kHz/256 gives ~244Hz, that is still too fast - 244/8 gives ~30Hz, that's what we need
// So the automaton runs atop of inner 8 (or 16) cycles.
// The finite automaton is running in the ISR(TIMER0_OVF_vect)
///! Definition off finite automaton states
enum class States : uint8_t {
ZERO = 0,
RISE = 1,
ONE = 2,
FALL = 3
};
///! State table for the inner part of the finite automaton
///! Basically it specifies what shall happen if the outer automaton is requesting setting the heat pin to 0 (OFF) or 1 (ON)
///! ZERO: steady 0 (OFF), no change for the whole period
///! RISE: 8 (16) fast PWM cycles with increasing duty up to steady ON
///! ONE: steady 1 (ON), no change for the whole period
///! FALL: 8 (16) fast PWM cycles with decreasing duty down to steady OFF
///! @@TODO move it into progmem
static States stateTable[4*2] = {
// off on
States::ZERO, States::RISE, // ZERO
States::FALL, States::ONE, // RISE
States::FALL, States::ONE, // ONE
States::ZERO, States::RISE // FALL
};
///! Inner states of the finite automaton
static States state = States::ZERO;
///! Inner and outer PWM counters
static uint8_t outer = 0;
static uint8_t inner = 0;
static uint8_t pwm = 0;
///! the slow PWM duty for the next 30Hz cycle
///! Set in the whole firmware at various places
extern unsigned char soft_pwm_bed;
/// Fine tuning of automaton cycles
#if 1
static const uint8_t innerMax = 16;
static const uint8_t innerShift = 4;
#else
static const uint8_t innerMax = 8;
static const uint8_t innerShift = 5;
#endif
ISR(TIMER0_OVF_vect) // timer compare interrupt service routine
{
if( inner ){
switch(state){
case States::ZERO:
OCR0B = 255;
// Commenting the following code saves 6B, but it is left here for reference
// It is not necessary to set it all over again, because we can only get into the ZERO state from the FALL state (which sets this register)
// TCCR0A |= (1 << COM0B1) | (1 << COM0B0);
break;
case States::RISE:
OCR0B = (innerMax - inner) << innerShift;
// TCCR0A |= (1 << COM0B1); // this bit is always 1
TCCR0A &= ~(1 << COM0B0);
break;
case States::ONE:
OCR0B = 255;
// again - may be skipped, because we get into the ONE state only from RISE (which sets this register)
// TCCR0A |= (1 << COM0B1);
TCCR0A &= ~(1 << COM0B0);
break;
case States::FALL:
OCR0B = (innerMax - inner) << innerShift; // this is the same as in RISE, because now we are setting the zero part of duty due to inverting mode
// must switch to inverting mode already here, because it takes a whole PWM cycle and it would make a "1" at the end of this pwm cycle
TCCR0A |= /*(1 << COM0B1) |*/ (1 << COM0B0);
break;
}
--inner;
} else {
if( ! outer ){ // at the end of 30Hz PWM period
// synchro is not needed (almost), soft_pwm_bed is just 1 byte, 1-byte write instruction is atomic
pwm = soft_pwm_bed << 1;
}
if( pwm > outer || pwm >= 254 ){
// soft_pwm_bed has a range of 0-127, that why a <<1 is done here. That also means that we may get only up to 254 which we want to be full-time 1 (ON)
state = stateTable[ uint8_t(state) * 2 + 1 ];
} else {
// switch OFF
state = stateTable[ uint8_t(state) * 2 + 0 ];
}
++outer;
inner = innerMax;
}
}

View file

@ -368,6 +368,7 @@
#define PIN_SET(pin) PORT(pin) |= __MSK(pin)
#define PIN_VAL(pin, val) if (val) PIN_SET(pin); else PIN_CLR(pin);
#define PIN_GET(pin) (PIN(pin) & __MSK(pin))
#define PIN_INQ(pin) (PORT(pin) & __MSK(pin))
#endif //_IO_ATMEGA2560

View file

@ -10,12 +10,19 @@
#include "Configuration.h"
#include "pins.h"
#include <binary.h>
//#include <Arduino.h>
#include <Arduino.h>
#include "Marlin.h"
#include "fastio.h"
//-//
#include "sound.h"
#define LCD_DEFAULT_DELAY 100
#if (defined(LCD_PINS_D0) && defined(LCD_PINS_D1) && defined(LCD_PINS_D2) && defined(LCD_PINS_D3))
#define LCD_8BIT
#endif
// #define VT100
// commands
#define LCD_CLEARDISPLAY 0x01
@ -55,242 +62,204 @@
#define LCD_5x10DOTS 0x04
#define LCD_5x8DOTS 0x00
// bitmasks for flag argument settings
#define LCD_RS_FLAG 0x01
#define LCD_HALF_FLAG 0x02
FILE _lcdout; // = {0}; Global variable is always zero initialized, no need to explicitly state that.
uint8_t lcd_displayfunction = 0;
uint8_t lcd_displaycontrol = 0;
uint8_t lcd_displaymode = 0;
uint8_t lcd_rs_pin; // LOW: command. HIGH: character.
uint8_t lcd_rw_pin; // LOW: write to LCD. HIGH: read from LCD.
uint8_t lcd_enable_pin; // activated by a HIGH pulse.
uint8_t lcd_data_pins[8];
uint8_t lcd_displayfunction;
uint8_t lcd_displaycontrol;
uint8_t lcd_displaymode;
uint8_t lcd_numlines;
uint8_t lcd_currline;
#ifdef VT100
uint8_t lcd_escape[8];
#endif
static void lcd_display(void);
void lcd_pulseEnable(void)
{
digitalWrite(lcd_enable_pin, LOW);
delayMicroseconds(1);
digitalWrite(lcd_enable_pin, HIGH);
delayMicroseconds(1); // enable pulse must be >450ns
digitalWrite(lcd_enable_pin, LOW);
delayMicroseconds(100); // commands need > 37us to settle
#if 0
static void lcd_no_display(void);
static void lcd_no_cursor(void);
static void lcd_cursor(void);
static void lcd_no_blink(void);
static void lcd_blink(void);
static void lcd_scrollDisplayLeft(void);
static void lcd_scrollDisplayRight(void);
static void lcd_leftToRight(void);
static void lcd_rightToLeft(void);
static void lcd_autoscroll(void);
static void lcd_no_autoscroll(void);
#endif
#ifdef VT100
void lcd_escape_write(uint8_t chr);
#endif
static void lcd_pulseEnable(void)
{
WRITE(LCD_PINS_ENABLE,HIGH);
_delay_us(1); // enable pulse must be >450ns
WRITE(LCD_PINS_ENABLE,LOW);
}
void lcd_write4bits(uint8_t value)
static void lcd_writebits(uint8_t value)
{
for (int i = 0; i < 4; i++)
{
pinMode(lcd_data_pins[i], OUTPUT);
digitalWrite(lcd_data_pins[i], (value >> i) & 0x01);
}
#ifdef LCD_8BIT
WRITE(LCD_PINS_D0, value & 0x01);
WRITE(LCD_PINS_D1, value & 0x02);
WRITE(LCD_PINS_D2, value & 0x04);
WRITE(LCD_PINS_D3, value & 0x08);
#endif
WRITE(LCD_PINS_D4, value & 0x10);
WRITE(LCD_PINS_D5, value & 0x20);
WRITE(LCD_PINS_D6, value & 0x40);
WRITE(LCD_PINS_D7, value & 0x80);
lcd_pulseEnable();
}
void lcd_write8bits(uint8_t value)
static void lcd_send(uint8_t data, uint8_t flags, uint16_t duration = LCD_DEFAULT_DELAY)
{
for (int i = 0; i < 8; i++)
WRITE(LCD_PINS_RS,flags&LCD_RS_FLAG);
_delay_us(5);
lcd_writebits(data);
#ifndef LCD_8BIT
if (!(flags & LCD_HALF_FLAG))
{
pinMode(lcd_data_pins[i], OUTPUT);
digitalWrite(lcd_data_pins[i], (value >> i) & 0x01);
_delay_us(LCD_DEFAULT_DELAY);
lcd_writebits(data<<4);
}
lcd_pulseEnable();
#endif
delayMicroseconds(duration);
}
// write either command or data, with automatic 4/8-bit selection
void lcd_send(uint8_t value, uint8_t mode)
static void lcd_command(uint8_t value, uint16_t delayExtra = 0)
{
digitalWrite(lcd_rs_pin, mode);
// if there is a RW pin indicated, set it low to Write
if (lcd_rw_pin != 255) digitalWrite(lcd_rw_pin, LOW);
if (lcd_displayfunction & LCD_8BITMODE)
lcd_write8bits(value);
else
{
lcd_write4bits(value>>4);
lcd_write4bits(value);
}
lcd_send(value, LOW, LCD_DEFAULT_DELAY + delayExtra);
}
void lcd_command(uint8_t value)
{
lcd_send(value, LOW);
}
void lcd_clear(void);
void lcd_home(void);
void lcd_no_display(void);
void lcd_display(void);
void lcd_no_cursor(void);
void lcd_cursor(void);
void lcd_no_blink(void);
void lcd_blink(void);
void lcd_scrollDisplayLeft(void);
void lcd_scrollDisplayRight(void);
void lcd_leftToRight(void);
void lcd_rightToLeft(void);
void lcd_autoscroll(void);
void lcd_no_autoscroll(void);
void lcd_set_cursor(uint8_t col, uint8_t row);
void lcd_createChar_P(uint8_t location, const uint8_t* charmap);
uint8_t lcd_escape_write(uint8_t chr);
uint8_t lcd_write(uint8_t value)
static void lcd_write(uint8_t value)
{
if (value == '\n')
{
if (lcd_currline > 3) lcd_currline = -1;
lcd_set_cursor(0, lcd_currline + 1); // LF
return 1;
return;
}
if (lcd_escape[0] || (value == 0x1b))
return lcd_escape_write(value);
#ifdef VT100
if (lcd_escape[0] || (value == 0x1b)){
lcd_escape_write(value);
return;
}
#endif
lcd_send(value, HIGH);
return 1; // assume sucess
}
static void lcd_begin(uint8_t lines, uint8_t dotsize, uint8_t clear)
static void lcd_begin(uint8_t clear)
{
if (lines > 1) lcd_displayfunction |= LCD_2LINE;
lcd_numlines = lines;
lcd_currline = 0;
// for some 1 line displays you can select a 10 pixel high font
if ((dotsize != 0) && (lines == 1)) lcd_displayfunction |= LCD_5x10DOTS;
// SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION!
// according to datasheet, we need at least 40ms after power rises above 2.7V
// before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50
_delay_us(50000);
// Now we pull both RS and R/W low to begin commands
digitalWrite(lcd_rs_pin, LOW);
digitalWrite(lcd_enable_pin, LOW);
if (lcd_rw_pin != 255)
digitalWrite(lcd_rw_pin, LOW);
//put the LCD into 4 bit or 8 bit mode
if (!(lcd_displayfunction & LCD_8BITMODE))
{
// this is according to the hitachi HD44780 datasheet
// figure 24, pg 46
// we start in 8bit mode, try to set 4 bit mode
lcd_write4bits(0x03);
_delay_us(4500); // wait min 4.1ms
// second try
lcd_write4bits(0x03);
_delay_us(4500); // wait min 4.1ms
// third go!
lcd_write4bits(0x03);
_delay_us(150);
// finally, set to 4-bit interface
lcd_write4bits(0x02);
}
else
{
// this is according to the hitachi HD44780 datasheet
// page 45 figure 23
// Send function set command sequence
lcd_command(LCD_FUNCTIONSET | lcd_displayfunction);
_delay_us(4500); // wait more than 4.1ms
// second try
lcd_command(LCD_FUNCTIONSET | lcd_displayfunction);
_delay_us(150);
// third go
lcd_command(LCD_FUNCTIONSET | lcd_displayfunction);
}
// finally, set # lines, font size, etc.
lcd_command(LCD_FUNCTIONSET | lcd_displayfunction);
_delay_us(60);
lcd_send(LCD_FUNCTIONSET | LCD_8BITMODE, LOW | LCD_HALF_FLAG, 4500); // wait min 4.1ms
// second try
lcd_send(LCD_FUNCTIONSET | LCD_8BITMODE, LOW | LCD_HALF_FLAG, 150);
// third go!
lcd_send(LCD_FUNCTIONSET | LCD_8BITMODE, LOW | LCD_HALF_FLAG, 150);
#ifndef LCD_8BIT
// set to 4-bit interface
lcd_send(LCD_FUNCTIONSET | LCD_4BITMODE, LOW | LCD_HALF_FLAG, 150);
#endif
// finally, set # lines, font size, etc.0
lcd_command(LCD_FUNCTIONSET | lcd_displayfunction);
// turn the display on with no cursor or blinking default
lcd_displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF;
lcd_displaycontrol = LCD_CURSOROFF | LCD_BLINKOFF;
lcd_display();
_delay_us(60);
// clear it off
if (clear) lcd_clear();
_delay_us(3000);
// Initialize to default text direction (for romance languages)
lcd_displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;
// set the entry mode
lcd_command(LCD_ENTRYMODESET | lcd_displaymode);
_delay_us(60);
#ifdef VT100
lcd_escape[0] = 0;
#endif
}
int lcd_putchar(char c, FILE *)
static void lcd_putchar(char c, FILE *)
{
lcd_write(c);
return 0;
}
void lcd_init(void)
{
uint8_t fourbitmode = 1;
lcd_rs_pin = LCD_PINS_RS;
lcd_rw_pin = 255;
lcd_enable_pin = LCD_PINS_ENABLE;
lcd_data_pins[0] = LCD_PINS_D4;
lcd_data_pins[1] = LCD_PINS_D5;
lcd_data_pins[2] = LCD_PINS_D6;
lcd_data_pins[3] = LCD_PINS_D7;
lcd_data_pins[4] = 0;
lcd_data_pins[5] = 0;
lcd_data_pins[6] = 0;
lcd_data_pins[7] = 0;
pinMode(lcd_rs_pin, OUTPUT);
// we can save 1 pin by not using RW. Indicate by passing 255 instead of pin#
if (lcd_rw_pin != 255) pinMode(lcd_rw_pin, OUTPUT);
pinMode(lcd_enable_pin, OUTPUT);
if (fourbitmode) lcd_displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS;
else lcd_displayfunction = LCD_8BITMODE | LCD_1LINE | LCD_5x8DOTS;
lcd_begin(LCD_HEIGHT, LCD_5x8DOTS, 1);
//lcd_clear();
WRITE(LCD_PINS_ENABLE,LOW);
SET_OUTPUT(LCD_PINS_RS);
SET_OUTPUT(LCD_PINS_ENABLE);
#ifdef LCD_8BIT
SET_OUTPUT(LCD_PINS_D0);
SET_OUTPUT(LCD_PINS_D1);
SET_OUTPUT(LCD_PINS_D2);
SET_OUTPUT(LCD_PINS_D3);
#endif
SET_OUTPUT(LCD_PINS_D4);
SET_OUTPUT(LCD_PINS_D5);
SET_OUTPUT(LCD_PINS_D6);
SET_OUTPUT(LCD_PINS_D7);
#ifdef LCD_8BIT
lcd_displayfunction |= LCD_8BITMODE;
#endif
lcd_displayfunction |= LCD_2LINE;
_delay_us(50000);
lcd_begin(1); //first time init
fdev_setup_stream(lcdout, lcd_putchar, NULL, _FDEV_SETUP_WRITE); //setup lcdout stream
}
void lcd_refresh(void)
{
lcd_begin(LCD_HEIGHT, LCD_5x8DOTS, 1);
lcd_begin(1);
lcd_set_custom_characters();
}
void lcd_refresh_noclear(void)
{
lcd_begin(LCD_HEIGHT, LCD_5x8DOTS, 0);
lcd_begin(0);
lcd_set_custom_characters();
}
void lcd_clear(void)
{
lcd_command(LCD_CLEARDISPLAY); // clear display, set cursor position to zero
_delay_us(1600); // this command takes a long time
lcd_command(LCD_CLEARDISPLAY, 1600); // clear display, set cursor position to zero
lcd_currline = 0;
}
void lcd_home(void)
{
lcd_command(LCD_RETURNHOME); // set cursor position to zero
_delay_us(1600); // this command takes a long time!
lcd_command(LCD_RETURNHOME, 1600); // set cursor position to zero
lcd_currline = 0;
}
// Turn the display on/off (quickly)
void lcd_display(void)
{
lcd_displaycontrol |= LCD_DISPLAYON;
lcd_command(LCD_DISPLAYCONTROL | lcd_displaycontrol);
}
#if 0
void lcd_no_display(void)
{
lcd_displaycontrol &= ~LCD_DISPLAYON;
lcd_command(LCD_DISPLAYCONTROL | lcd_displaycontrol);
}
#endif
void lcd_display(void)
{
lcd_displaycontrol |= LCD_DISPLAYON;
lcd_command(LCD_DISPLAYCONTROL | lcd_displaycontrol);
}
#ifdef VT100 //required functions for VT100
// Turns the underline cursor on/off
void lcd_no_cursor(void)
{
@ -303,7 +272,9 @@ void lcd_cursor(void)
lcd_displaycontrol |= LCD_CURSORON;
lcd_command(LCD_DISPLAYCONTROL | lcd_displaycontrol);
}
#endif
#if 0
// Turn on and off the blinking cursor
void lcd_no_blink(void)
{
@ -355,12 +326,13 @@ void lcd_no_autoscroll(void)
lcd_displaymode &= ~LCD_ENTRYSHIFTINCREMENT;
lcd_command(LCD_ENTRYMODESET | lcd_displaymode);
}
#endif
void lcd_set_cursor(uint8_t col, uint8_t row)
{
int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 };
if ( row >= lcd_numlines )
row = lcd_numlines-1; // we count rows starting w/0
if (row >= LCD_HEIGHT)
row = LCD_HEIGHT - 1; // we count rows starting w/0
lcd_currline = row;
lcd_command(LCD_SETDDRAMADDR | (col + row_offsets[row]));
}
@ -375,12 +347,14 @@ void lcd_createChar_P(uint8_t location, const uint8_t* charmap)
lcd_send(pgm_read_byte(&charmap[i]), HIGH);
}
#ifdef VT100
//Supported VT100 escape codes:
//EraseScreen "\x1b[2J"
//CursorHome "\x1b[%d;%dH"
//CursorShow "\x1b[?25h"
//CursorHide "\x1b[?25l"
uint8_t lcd_escape_write(uint8_t chr)
void lcd_escape_write(uint8_t chr)
{
#define escape_cnt (lcd_escape[0]) //escape character counter
#define is_num_msk (lcd_escape[1]) //numeric character bit mask
@ -410,26 +384,26 @@ uint8_t lcd_escape_write(uint8_t chr)
switch (escape_cnt++)
{
case 0:
if (chr == 0x1b) return 1; // escape = "\x1b"
if (chr == 0x1b) return; // escape = "\x1b"
break;
case 1:
is_num_msk = 0x00; // reset 'is number' bit mask
if (chr == '[') return 1; // escape = "\x1b["
if (chr == '[') return; // escape = "\x1b["
break;
case 2:
switch (chr)
{
case '2': return 1; // escape = "\x1b[2"
case '?': return 1; // escape = "\x1b[?"
case '2': return; // escape = "\x1b[2"
case '?': return; // escape = "\x1b[?"
default:
if (chr_is_num) return 1; // escape = "\x1b[%1d"
if (chr_is_num) return; // escape = "\x1b[%1d"
}
break;
case 3:
switch (lcd_escape[2])
{
case '?': // escape = "\x1b[?"
if (chr == '2') return 1; // escape = "\x1b[?2"
if (chr == '2') return; // escape = "\x1b[?2"
break;
case '2':
if (chr == 'J') // escape = "\x1b[2J"
@ -438,20 +412,20 @@ uint8_t lcd_escape_write(uint8_t chr)
if (e_2_is_num && // escape = "\x1b[%1d"
((chr == ';') || // escape = "\x1b[%1d;"
chr_is_num)) // escape = "\x1b[%2d"
return 1;
return;
}
break;
case 4:
switch (lcd_escape[2])
{
case '?': // "\x1b[?"
if ((lcd_escape[3] == '2') && (chr == '5')) return 1; // escape = "\x1b[?25"
if ((lcd_escape[3] == '2') && (chr == '5')) return; // escape = "\x1b[?25"
break;
default:
if (e_2_is_num) // escape = "\x1b[%1d"
{
if ((lcd_escape[3] == ';') && chr_is_num) return 1; // escape = "\x1b[%1d;%1d"
else if (e_3_is_num && (chr == ';')) return 1; // escape = "\x1b[%2d;"
if ((lcd_escape[3] == ';') && chr_is_num) return; // escape = "\x1b[%1d;%1d"
else if (e_3_is_num && (chr == ';')) return; // escape = "\x1b[%2d;"
}
}
break;
@ -478,10 +452,10 @@ uint8_t lcd_escape_write(uint8_t chr)
if (chr == 'H') // escape = "\x1b%1d;%1dH"
lcd_set_cursor(e4_num, e2_num); // CursorHome
else if (chr_is_num)
return 1; // escape = "\x1b%1d;%2d"
return; // escape = "\x1b%1d;%2d"
}
else if (e_3_is_num && (lcd_escape[4] == ';') && chr_is_num)
return 1; // escape = "\x1b%2d;%1d"
return; // escape = "\x1b%2d;%1d"
}
}
break;
@ -495,7 +469,7 @@ uint8_t lcd_escape_write(uint8_t chr)
if (chr == 'H') // escape = "\x1b%2d;%1dH"
lcd_set_cursor(e5_num, e23_num); // CursorHome
else if (chr_is_num) // "\x1b%2d;%2d"
return 1;
return;
}
}
break;
@ -506,10 +480,9 @@ uint8_t lcd_escape_write(uint8_t chr)
break;
}
escape_cnt = 0; // reset escape
return 1; // assume sucess
}
#endif //VT100
int lcd_putc(int c)
@ -648,16 +621,6 @@ void lcd_printFloat(double number, uint8_t digits)
}
uint8_t lcd_draw_update = 2;
int32_t lcd_encoder = 0;
uint8_t lcd_encoder_bits = 0;
@ -704,16 +667,13 @@ uint8_t lcd_clicked(void)
void lcd_beeper_quick_feedback(void)
{
SET_OUTPUT(BEEPER);
//-//
Sound_MakeSound(e_SOUND_TYPE_ButtonEcho);
/*
for(int8_t i = 0; i < 10; i++)
{
WRITE(BEEPER,HIGH);
delayMicroseconds(100);
WRITE(BEEPER,LOW);
delayMicroseconds(100);
Sound_MakeCustom(100,0,false);
_delay_us(100);
}
*/
}
@ -725,13 +685,6 @@ void lcd_quick_feedback(void)
lcd_beeper_quick_feedback();
}
void lcd_update(uint8_t lcdDrawUpdateOverride)
{
if (lcd_draw_update < lcdDrawUpdateOverride)

View file

@ -11,8 +11,7 @@
extern FILE _lcdout;
#define lcdout (&_lcdout)
extern int lcd_putchar(char c, FILE *stream);
extern void lcd_putchar(char c, FILE *stream);
extern void lcd_init(void);
@ -20,13 +19,10 @@ extern void lcd_refresh(void);
extern void lcd_refresh_noclear(void);
extern void lcd_clear(void);
extern void lcd_home(void);
/*extern void lcd_no_display(void);
extern void lcd_display(void);
extern void lcd_no_blink(void);
@ -45,7 +41,6 @@ extern void lcd_set_cursor(uint8_t col, uint8_t row);
extern void lcd_createChar_P(uint8_t, const uint8_t*);
extern int lcd_putc(int c);
extern int lcd_puts_P(const char* str);
extern int lcd_puts_at_P(uint8_t c, uint8_t r, const char* str);
@ -66,7 +61,9 @@ extern void lcd_print(double, int = 2);
//! @brief Clear screen
#define ESC_2J "\x1b[2J"
//! @brief Show cursor
#define ESC_25h "\x1b[?25h"
//! @brief Hide cursor
#define ESC_25l "\x1b[?25l"
//! @brief Set cursor to
//! @param c column
@ -118,9 +115,6 @@ extern lcd_lcdupdate_func_t lcd_lcdupdate_func;
extern uint8_t lcd_clicked(void);
extern void lcd_beeper_quick_feedback(void);
@ -128,13 +122,6 @@ extern void lcd_beeper_quick_feedback(void);
//Cause an LCD refresh, and give the user visual or audible feedback that something has happened
extern void lcd_quick_feedback(void);
extern void lcd_update(uint8_t lcdDrawUpdateOverride);
extern void lcd_update_enable(uint8_t enabled);
@ -165,29 +152,6 @@ private:
};
/**
* Implementation of the LCD display routines for a Hitachi HD44780 display. These are common LCD character displays.
* When selecting the Russian language, a slightly different LCD implementation is used to handle UTF8 characters.
**/
////////////////////////////////////
// Setup button and encode mappings for each panel (into 'lcd_buttons' variable
//
@ -223,8 +187,6 @@ private:
#define encrot3 1
//Custom characters defined in the first 8 characters of the LCD
#define LCD_STR_BEDTEMP "\x00"
#define LCD_STR_DEGREE "\x01"

View file

@ -11,8 +11,7 @@
#include "ultralcd.h"
#include "language.h"
#include "static_assert.h"
#include "sound.h"
extern int32_t lcd_encoder;
@ -65,7 +64,11 @@ void menu_goto(menu_func_t menu, const uint32_t encoder, const bool feedback, bo
void menu_start(void)
{
if (lcd_encoder > 0x8000) lcd_encoder = 0;
if (lcd_encoder < 0) lcd_encoder = 0;
if (lcd_encoder < 0)
{
lcd_encoder = 0;
Sound_MakeSound(e_SOUND_TYPE_BlindAlert);
}
if (lcd_encoder < menu_top)
menu_top = lcd_encoder;
menu_line = menu_top;
@ -75,7 +78,10 @@ void menu_start(void)
void menu_end(void)
{
if (lcd_encoder >= menu_item)
{
lcd_encoder = menu_item - 1;
Sound_MakeSound(e_SOUND_TYPE_BlindAlert);
}
if (((uint8_t)lcd_encoder) >= menu_top + LCD_HEIGHT)
{
menu_top = lcd_encoder - LCD_HEIGHT + 1;
@ -168,16 +174,61 @@ int menu_draw_item_printf_P(char type_char, const char* format, ...)
}
*/
static char menu_selection_mark(){
return (lcd_encoder == menu_item)?'>':' ';
}
static void menu_draw_item_puts_P(char type_char, const char* str)
{
lcd_set_cursor(0, menu_row);
lcd_printf_P(PSTR("%c%-18.18S%c"), (lcd_encoder == menu_item)?'>':' ', str, type_char);
lcd_printf_P(PSTR("%c%-18.18S%c"), menu_selection_mark(), str, type_char);
}
//! @brief Format sheet name
//!
//! @param[in] sheet_E Sheet in EEPROM
//! @param[out] buffer for formatted output
void menu_format_sheet_E(const Sheet &sheet_E, SheetFormatBuffer &buffer)
{
uint_least8_t index = sprintf_P(buffer.c, PSTR("%.10S "), _T(MSG_SHEET));
eeprom_read_block(&(buffer.c[index]), sheet_E.name, 7);
//index += 7;
buffer.c[index + 7] = '\0';
}
//! @brief Format sheet name in select menu
//!
//! @param[in] sheet_E Sheet in EEPROM
//! @param[out] buffer for formatted output
void menu_format_sheet_select_E(const Sheet &sheet_E, SheetFormatBuffer &buffer)
{
uint_least8_t index = sprintf_P(buffer.c,PSTR("%-9.9S["), _T(MSG_SHEET));
eeprom_read_block(&(buffer.c[index]), sheet_E.name, 7);
buffer.c[index + 7] = ']';
buffer.c[index + 8] = '\0';
}
static void menu_draw_item_select_sheet_E(char type_char, const Sheet &sheet)
{
lcd_set_cursor(0, menu_row);
SheetFormatBuffer buffer;
menu_format_sheet_select_E(sheet, buffer);
lcd_printf_P(PSTR("%c%-18.18s%c"), menu_selection_mark(), buffer.c, type_char);
}
static void menu_draw_item_puts_E(char type_char, const Sheet &sheet)
{
lcd_set_cursor(0, menu_row);
SheetFormatBuffer buffer;
menu_format_sheet_E(sheet, buffer);
lcd_printf_P(PSTR("%c%-18.18s%c"), menu_selection_mark(), buffer.c, type_char);
}
static void menu_draw_item_puts_P(char type_char, const char* str, char num)
{
lcd_set_cursor(0, menu_row);
lcd_printf_P(PSTR("%c%-.16S "), (lcd_encoder == menu_item)?'>':' ', str);
lcd_printf_P(PSTR("%c%-.16S "), menu_selection_mark(), str);
lcd_putc(num);
lcd_set_cursor(19, menu_row);
lcd_putc(type_char);
@ -224,6 +275,36 @@ uint8_t menu_item_submenu_P(const char* str, menu_func_t submenu)
return 0;
}
uint8_t menu_item_submenu_E(const Sheet &sheet, menu_func_t submenu)
{
if (menu_item == menu_line)
{
if (lcd_draw_update) menu_draw_item_puts_E(LCD_STR_ARROW_RIGHT[0], sheet);
if (menu_clicked && (lcd_encoder == menu_item))
{
menu_submenu(submenu);
return menu_item_ret();
}
}
menu_item++;
return 0;
}
uint8_t menu_item_submenu_select_sheet_E(const Sheet &sheet, menu_func_t submenu)
{
if (menu_item == menu_line)
{
if (lcd_draw_update) menu_draw_item_select_sheet_E(LCD_STR_ARROW_RIGHT[0], sheet);
if (menu_clicked && (lcd_encoder == menu_item))
{
menu_submenu(submenu);
return menu_item_ret();
}
}
menu_item++;
return 0;
}
uint8_t menu_item_back_P(const char* str)
{
if (menu_item == menu_line)
@ -399,7 +480,7 @@ uint8_t menu_item_edit_P(const char* str, T pval, int16_t min_val, int16_t max_v
if (lcd_draw_update)
{
lcd_set_cursor(0, menu_row);
menu_draw_P<T>((lcd_encoder == menu_item)?'>':' ', str, *pval);
menu_draw_P<T>(menu_selection_mark(), str, *pval);
}
if (menu_clicked && (lcd_encoder == menu_item))
{

View file

@ -3,6 +3,7 @@
#define _MENU_H
#include <inttypes.h>
#include "eeprom.h"
#define MENU_DATA_SIZE 32
@ -99,6 +100,12 @@ extern uint8_t menu_item_text_P(const char* str);
#define MENU_ITEM_SUBMENU_P(str, submenu) do { if (menu_item_submenu_P(str, submenu)) return; } while (0)
extern uint8_t menu_item_submenu_P(const char* str, menu_func_t submenu);
#define MENU_ITEM_SUBMENU_E(sheet, submenu) do { if (menu_item_submenu_E(sheet, submenu)) return; } while (0)
extern uint8_t menu_item_submenu_E(const Sheet &sheet, menu_func_t submenu);
#define MENU_ITEM_SUBMENU_SELECT_SHEET_E(sheet, submenu) do { if (menu_item_submenu_select_sheet_E(sheet, submenu)) return; } while (0)
extern uint8_t menu_item_submenu_select_sheet_E(const Sheet &sheet, menu_func_t submenu);
#define MENU_ITEM_BACK_P(str) do { if (menu_item_back_P(str)) return; } while (0)
extern uint8_t menu_item_back_P(const char* str);
@ -125,6 +132,13 @@ extern void menu_draw_float31(const char* str, float val);
extern void menu_draw_float13(const char* str, float val);
struct SheetFormatBuffer
{
char c[19];
};
extern void menu_format_sheet_E(const Sheet &sheet_E, SheetFormatBuffer &buffer);
#define MENU_ITEM_EDIT_int3_P(str, pval, minval, maxval) do { if (menu_item_edit_P(str, pval, minval, maxval)) return; } while (0)
//#define MENU_ITEM_EDIT_int3_P(str, pval, minval, maxval) MENU_ITEM_EDIT(int3, str, pval, minval, maxval)

View file

@ -3031,7 +3031,8 @@ void babystep_load()
check_babystep(); //checking if babystep is in allowed range, otherwise setting babystep to 0
// End of G80: Apply the baby stepping value.
EEPROM_read_B(EEPROM_BABYSTEP_Z, &babystepLoadZ);
babystepLoadZ = eeprom_read_word(reinterpret_cast<uint16_t *>(&(EEPROM_Sheets_base->
s[(eeprom_read_byte(&(EEPROM_Sheets_base->active_sheet)))].z_offset)));
#if 0
SERIAL_ECHO("Z baby step: ");
@ -3186,4 +3187,4 @@ void mbl_interpolation(uint8_t meas_points) {
}
}
}
}
}

View file

@ -10,7 +10,7 @@
//internationalized messages
const char MSG_AUTO_HOME[] PROGMEM_I1 = ISTR("Auto home"); ////
const char MSG_AUTO_MODE_ON[] PROGMEM_I1 = ISTR("Mode [auto power]"); ////
const char MSG_BABYSTEP_Z[] PROGMEM_I1 = ISTR("Live adjust Z"); ////
const char MSG_BABYSTEP_Z[] PROGMEM_I1 = ISTR("Live adjust Z"); //// c=18
const char MSG_BABYSTEP_Z_NOT_SET[] PROGMEM_I1 = ISTR("Distance between tip of the nozzle and the bed surface has not been set yet. Please follow the manual, chapter First steps, section First layer calibration."); ////c=20 r=12
const char MSG_BED[] PROGMEM_I1 = ISTR("Bed"); ////
const char MSG_BED_DONE[] PROGMEM_I1 = ISTR("Bed done"); ////
@ -55,6 +55,7 @@ const char MSG_CUT_FILAMENT[] PROGMEM_I1 = ISTR("Cut filament"); //// Number 1 t
const char MSG_M117_V2_CALIBRATION[] PROGMEM_I1 = ISTR("M117 First layer cal."); ////c=25 r=1
const char MSG_MAIN[] PROGMEM_I1 = ISTR("Main"); ////
const char MSG_BACK[] PROGMEM_I1 = ISTR("Back"); ////
const char MSG_SHEET[] PROGMEM_I1 = ISTR("Sheet"); ////c=10
const char MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE1[] PROGMEM_I1 = ISTR("Measuring reference height of calibration point"); ////c=60
const char MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE2[] PROGMEM_I1 = ISTR(" of 9"); ////c=14
const char MSG_MENU_CALIBRATION[] PROGMEM_I1 = ISTR("Calibration"); ////
@ -83,6 +84,7 @@ const char MSG_SELFTEST_MOTOR[] PROGMEM_I1 = ISTR("Motor"); ////
const char MSG_SELFTEST_FILAMENT_SENSOR[] PROGMEM_I1 = ISTR("Filament sensor"); ////c=17
const char MSG_SELFTEST_WIRINGERROR[] PROGMEM_I1 = ISTR("Wiring error"); ////
const char MSG_SETTINGS[] PROGMEM_I1 = ISTR("Settings"); ////
const char MSG_HW_SETUP[] PROGMEM_I1 = ISTR("HW Setup"); ////
const char MSG_SILENT_MODE_OFF[] PROGMEM_I1 = ISTR("Mode [high power]"); ////
const char MSG_SILENT_MODE_ON[] PROGMEM_I1 = ISTR("Mode [silent]"); ////
const char MSG_STEALTH_MODE_OFF[] PROGMEM_I1 = ISTR("Mode [Normal]"); ////
@ -100,6 +102,7 @@ const char MSG_WIZARD_DONE[] PROGMEM_I1 = ISTR("All is done. Happy printing!");
const char MSG_WIZARD_HEATING[] PROGMEM_I1 = ISTR("Preheating nozzle. Please wait."); ////c=20 r=3
const char MSG_WIZARD_QUIT[] PROGMEM_I1 = ISTR("You can always resume the Wizard from Calibration -> Wizard."); ////c=20 r=8
const char MSG_YES[] PROGMEM_I1 = ISTR("Yes"); ////
const char MSG_V2_CALIBRATION[] PROGMEM_I1 = ISTR("First layer cal."); ////c=17 r=1
const char WELCOME_MSG[] PROGMEM_I1 = ISTR(CUSTOM_MENDEL_NAME " OK."); ////c=20
//not internationalized messages
const char MSG_SD_WORKDIR_FAIL[] PROGMEM_N1 = "workDir open failed"; ////
@ -126,3 +129,4 @@ const char MSG_ENDSTOP_OPEN[] PROGMEM_N1 = "open"; ////
const char MSG_POWERUP[] PROGMEM_N1 = "PowerUp"; ////
const char MSG_ERR_STOPPED[] PROGMEM_N1 = "Printer stopped due to errors. Fix the error and use M999 to restart. (Temperature is reset. Set it after restarting)"; ////
const char MSG_ENDSTOP_HIT[] PROGMEM_N1 = "TRIGGERED"; ////
const char MSG_OCTOPRINT_PAUSE[] PROGMEM_N1 = "// action:pause"; ////

View file

@ -54,6 +54,7 @@ extern const char MSG_LOADING_FILAMENT[];
extern const char MSG_M117_V2_CALIBRATION[];
extern const char MSG_MAIN[];
extern const char MSG_BACK[];
extern const char MSG_SHEET[];
extern const char MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE1[];
extern const char MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE2[];
extern const char MSG_MENU_CALIBRATION[];
@ -83,6 +84,7 @@ extern const char MSG_SELFTEST_MOTOR[];
extern const char MSG_SELFTEST_FILAMENT_SENSOR[];
extern const char MSG_SELFTEST_WIRINGERROR[];
extern const char MSG_SETTINGS[];
extern const char MSG_HW_SETUP[];
extern const char MSG_SILENT_MODE_OFF[];
extern const char MSG_SILENT_MODE_ON[];
extern const char MSG_STEALTH_MODE_OFF[];
@ -100,6 +102,7 @@ extern const char MSG_WIZARD_DONE[];
extern const char MSG_WIZARD_HEATING[];
extern const char MSG_WIZARD_QUIT[];
extern const char MSG_YES[];
extern const char MSG_V2_CALIBRATION[];
extern const char WELCOME_MSG[];
//not internationalized messages
extern const char MSG_BROWNOUT_RESET[];
@ -127,6 +130,7 @@ extern const char MSG_ERR_STOPPED[];
extern const char MSG_ENDSTOP_HIT[];
extern const char MSG_EJECT_FILAMENT[];
extern const char MSG_CUT_FILAMENT[];
extern const char MSG_OCTOPRINT_PAUSE[];
#if defined(__cplusplus)
}

View file

@ -15,6 +15,8 @@
#include <avr/pgmspace.h>
#include "io_atmega2560.h"
#include "AutoDeplete.h"
//-//
#include "util.h"
#ifdef TMC2130
#include "tmc2130.h"
@ -265,6 +267,9 @@ void mmu_loop(void)
FDEBUG_PRINTF_P(PSTR("MMU => '%dok'\n"), mmu_finda);
puts_P(PSTR("MMU - ENABLED"));
mmu_enabled = true;
//-//
// ... PrinterType/Name
fSetMmuMode(true);
mmu_state = S::Idle;
}
return;
@ -418,9 +423,11 @@ void mmu_loop(void)
}
else if ((mmu_last_request + MMU_CMD_TIMEOUT) < _millis())
{ //resend request after timeout (5 min)
if (mmu_last_cmd >= MmuCmd::T0 && mmu_last_cmd <= MmuCmd::T4)
if (mmu_last_cmd != MmuCmd::None)
{
if (mmu_attempt_nr++ < MMU_MAX_RESEND_ATTEMPTS) {
if (mmu_attempt_nr++ < MMU_MAX_RESEND_ATTEMPTS &&
mmu_last_cmd >= MmuCmd::T0 && mmu_last_cmd <= MmuCmd::T4)
{
DEBUG_PRINTF_P(PSTR("MMU retry attempt nr. %d\n"), mmu_attempt_nr - 1);
mmu_cmd = mmu_last_cmd;
}
@ -833,7 +840,7 @@ void mmu_M600_wait_and_beep() {
}
SET_OUTPUT(BEEPER);
if (counterBeep == 0) {
if((eSoundMode==e_SOUND_MODE_LOUD)||((eSoundMode==e_SOUND_MODE_ONCE)&&bFirst))
if((eSoundMode==e_SOUND_MODE_BLIND)|| (eSoundMode==e_SOUND_MODE_LOUD)||((eSoundMode==e_SOUND_MODE_ONCE)&&bFirst))
{
bFirst=false;
WRITE(BEEPER, HIGH);
@ -971,7 +978,7 @@ void extr_adj(uint8_t extruder) //loading filament for SNMM
{
#ifndef SNMM
MmuCmd cmd = MmuCmd::L0 + extruder;
if (cmd > MmuCmd::L4)
if (extruder > (MmuCmd::L4 - MmuCmd::L0))
{
printf_P(PSTR("Filament out of range %d \n"),extruder);
return;

View file

@ -3,14 +3,38 @@
#define PRINTER_UNKNOWN 0
#define PRINTER_MK1 100
#define PRINTER_MK2 200
#define PRINTER_MK2_SNMM 201
#define PRINTER_MK25 250
#define PRINTER_MK25_SNMM 251
#define PRINTER_MK25S 252
#define PRINTER_MK3 300
#define PRINTER_MK3_SNMM 301
#define PRINTER_MK3S 302
// *** MK1
#define PRINTER_MK1 100
#define PRINTER_MK1_NAME "MK1"
// *** MK2
#define PRINTER_MK2 200
#define PRINTER_MK2_NAME "MK2"
#define PRINTER_MK2_SNMM 201 // better is "10200"
#define PRINTER_MK2_SNMM_NAME "MK2MM" // better is "MK2MMU1"
// *** MK2S ??? is same as "MK2" ???
#define PRINTER_MK2S 202
#define PRINTER_MK2S_NAME "MK2S"
#define PRINTER_MK2S_SNMM 203 // better is "10202"
#define PRINTER_MK2S_SNMM_NAME "MK2SMM" // better is "MK2SMMU1"
// *** MK2.5
#define PRINTER_MK25 250
#define PRINTER_MK25_NAME "MK2.5"
#define PRINTER_MK25_MMU2 20250
#define PRINTER_MK25_MMU2_NAME "MK2.5MMU2"
// *** MK2.5S
#define PRINTER_MK25S 252
#define PRINTER_MK25S_NAME "MK2.5S"
#define PRINTER_MK25S_MMU2 20252
#define PRINTER_MK25S_MMU2_NAME "MK2.5SMMU2S"
// *** MK3
#define PRINTER_MK3 300
#define PRINTER_MK3_NAME "MK3"
#define PRINTER_MK3_MMU2 20300
#define PRINTER_MK3_MMU2_NAME "MK3MMU2"
// *** MK3S
#define PRINTER_MK3S 302
#define PRINTER_MK3S_NAME "MK3S"
#define PRINTER_MK3S_MMU2 20302
#define PRINTER_MK3S_MMU2_NAME "MK3SMMU2S"
#endif //PRINTERS_H

View file

@ -17,7 +17,8 @@ static void Sound_SaveMode(void);
static void Sound_DoSound_Echo(void);
static void Sound_DoSound_Prompt(void);
static void Sound_DoSound_Alert(bool bOnce);
static void Sound_DoSound_Encoder_Move(void);
static void Sound_DoSound_Blind_Alert(void);
void Sound_Init(void)
{
@ -49,9 +50,9 @@ switch(eSoundMode)
eSoundMode=e_SOUND_MODE_SILENT;
break;
case e_SOUND_MODE_SILENT:
eSoundMode=e_SOUND_MODE_MUTE;
eSoundMode=e_SOUND_MODE_BLIND;
break;
case e_SOUND_MODE_MUTE:
case e_SOUND_MODE_BLIND:
eSoundMode=e_SOUND_MODE_LOUD;
break;
default:
@ -60,6 +61,37 @@ switch(eSoundMode)
Sound_SaveMode();
}
//if critical is true then silend and once mode is ignored
void Sound_MakeCustom(uint16_t ms,uint16_t tone_,bool critical){
if (!critical){
if (eSoundMode != e_SOUND_MODE_SILENT){
if(!tone_){
WRITE(BEEPER, HIGH);
_delay(ms);
WRITE(BEEPER, LOW);
}
else{
_tone(BEEPER, tone_);
_delay(ms);
_noTone(BEEPER);
}
}
}
else{
if(!tone_){
WRITE(BEEPER, HIGH);
_delay(ms);
WRITE(BEEPER, LOW);
_delay(ms);
}
else{
_tone(BEEPER, tone_);
_delay(ms);
_noTone(BEEPER);
}
}
}
void Sound_MakeSound(eSOUND_TYPE eSoundType)
{
switch(eSoundMode)
@ -84,13 +116,48 @@ switch(eSoundMode)
if(eSoundType==e_SOUND_TYPE_StandardAlert)
Sound_DoSound_Alert(true);
break;
case e_SOUND_MODE_MUTE:
break;
case e_SOUND_MODE_BLIND:
if(eSoundType==e_SOUND_TYPE_ButtonEcho)
Sound_DoSound_Echo();
if(eSoundType==e_SOUND_TYPE_StandardPrompt)
Sound_DoSound_Prompt();
if(eSoundType==e_SOUND_TYPE_StandardAlert)
Sound_DoSound_Alert(false);
if(eSoundType==e_SOUND_TYPE_EncoderMove)
Sound_DoSound_Encoder_Move();
if(eSoundType==e_SOUND_TYPE_BlindAlert)
Sound_DoSound_Blind_Alert();
break;
default:
;
break;
}
}
static void Sound_DoSound_Blind_Alert(void)
{
uint8_t nI;
for(nI=0; nI<20; nI++)
{
WRITE(BEEPER,HIGH);
delayMicroseconds(94);
WRITE(BEEPER,LOW);
delayMicroseconds(94);
}
}
static void Sound_DoSound_Encoder_Move(void)
{
uint8_t nI;
for(nI=0;nI<5;nI++)
{
WRITE(BEEPER,HIGH);
delayMicroseconds(75);
WRITE(BEEPER,LOW);
delayMicroseconds(75);
}
}
static void Sound_DoSound_Echo(void)
{
@ -108,7 +175,7 @@ for(nI=0;nI<10;nI++)
static void Sound_DoSound_Prompt(void)
{
WRITE(BEEPER,HIGH);
delay_keep_alive(500);
_delay_ms(500);
WRITE(BEEPER,LOW);
}
@ -120,8 +187,8 @@ nMax=bOnce?1:3;
for(nI=0;nI<nMax;nI++)
{
WRITE(BEEPER,HIGH);
delay_keep_alive(200);
delayMicroseconds(200);
WRITE(BEEPER,LOW);
delay_keep_alive(500);
delayMicroseconds(500);
}
}

View file

@ -1,3 +1,4 @@
#include <stdint.h>
#ifndef SOUND_H
#define SOUND_H
@ -5,16 +6,16 @@
#define MSG_SOUND_MODE_LOUD "Sound [loud]"
#define MSG_SOUND_MODE_ONCE "Sound [once]"
#define MSG_SOUND_MODE_SILENT "Sound [silent]"
#define MSG_SOUND_MODE_MUTE "Sound [mute]"
#define MSG_SOUND_MODE_BLIND "Sound [blind]"
#define e_SOUND_MODE_NULL 0xFF
typedef enum
{e_SOUND_MODE_LOUD,e_SOUND_MODE_ONCE,e_SOUND_MODE_SILENT,e_SOUND_MODE_MUTE} eSOUND_MODE;
{e_SOUND_MODE_LOUD,e_SOUND_MODE_ONCE,e_SOUND_MODE_SILENT,e_SOUND_MODE_BLIND} eSOUND_MODE;
#define e_SOUND_MODE_DEFAULT e_SOUND_MODE_LOUD
typedef enum
{e_SOUND_TYPE_ButtonEcho,e_SOUND_TYPE_EncoderEcho,e_SOUND_TYPE_StandardPrompt,e_SOUND_TYPE_StandardConfirm,e_SOUND_TYPE_StandardWarning,e_SOUND_TYPE_StandardAlert} eSOUND_TYPE;
{e_SOUND_TYPE_ButtonEcho,e_SOUND_TYPE_EncoderEcho,e_SOUND_TYPE_StandardPrompt,e_SOUND_TYPE_StandardConfirm,e_SOUND_TYPE_StandardWarning,e_SOUND_TYPE_StandardAlert,e_SOUND_TYPE_EncoderMove,e_SOUND_TYPE_BlindAlert} eSOUND_TYPE;
typedef enum
{e_SOUND_CLASS_Echo,e_SOUND_CLASS_Prompt,e_SOUND_CLASS_Confirm,e_SOUND_CLASS_Warning,e_SOUND_CLASS_Alert} eSOUND_CLASS;
@ -27,6 +28,7 @@ extern void Sound_Default(void);
extern void Sound_Save(void);
extern void Sound_CycleState(void);
extern void Sound_MakeSound(eSOUND_TYPE eSoundType);
extern void Sound_MakeCustom(uint16_t ms,uint16_t tone_ ,bool critical);
//static void Sound_DoSound_Echo(void);
//static void Sound_DoSound_Prompt(void);

View file

@ -1122,7 +1122,7 @@ void clear_current_adv_vars() {
}
#endif // LIN_ADVANCE
void st_init()
{
#ifdef TMC2130
@ -1306,6 +1306,9 @@ void st_init()
SET_OUTPUT(Z2_STEP_PIN);
WRITE(Z2_STEP_PIN,INVERT_Z_STEP_PIN);
#endif
#ifdef PSU_Delta
init_force_z();
#endif // PSU_Delta
disable_z();
#endif
#if defined(E0_STEP_PIN) && (E0_STEP_PIN > -1)

View file

@ -4,7 +4,7 @@
#define FIRMWARE_SYSTEM_TIMER_H_
#include "Arduino.h"
//#define SYSTEM_TIMER_2
#define SYSTEM_TIMER_2
#ifdef SYSTEM_TIMER_2
#include "timer02.h"
@ -13,12 +13,15 @@
#define _delay delay2
#define _tone tone2
#define _noTone noTone2
#define timer02_set_pwm0(pwm0)
#else //SYSTEM_TIMER_2
#define _millis millis
#define _micros micros
#define _delay delay
#define _tone tone
#define _noTone noTone
#define _tone(x, y) /*tone*/
#define _noTone(x) /*noTone*/
#define timer02_set_pwm0(pwm0)
#endif //SYSTEM_TIMER_2

View file

@ -40,12 +40,10 @@
#include <avr/wdt.h>
#include "adc.h"
#include "ConfigurationStore.h"
#include "messages.h"
#include "Timer.h"
#include "Configuration_prusa.h"
//===========================================================================
//=============================public variables============================
//===========================================================================
@ -500,12 +498,16 @@ void checkFanSpeed()
max_print_fan_errors = 15; //15 seconds
max_extruder_fan_errors = 5; //5 seconds
#endif //FAN_SOFT_PWM
fans_check_enabled = (eeprom_read_byte((uint8_t*)EEPROM_FAN_CHECK_ENABLED) > 0);
if(fans_check_enabled != false)
fans_check_enabled = (eeprom_read_byte((uint8_t*)EEPROM_FAN_CHECK_ENABLED) > 0);
static unsigned char fan_speed_errors[2] = { 0,0 };
#if (defined(FANCHECK) && defined(TACH_0) && (TACH_0 >-1))
if ((fan_speed[0] == 0) && (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE)) fan_speed_errors[0]++;
else fan_speed_errors[0] = 0;
if ((fan_speed[0] == 0) && (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE)){ fan_speed_errors[0]++;}
else{
fan_speed_errors[0] = 0;
host_keepalive();
}
#endif
#if (defined(FANCHECK) && defined(TACH_1) && (TACH_1 >-1))
if ((fan_speed[1] < 5) && ((blocks_queued() ? block_buffer[block_buffer_tail].fan_speed : fanSpeed) > MIN_PRINT_FAN_SPEED)) fan_speed_errors[1]++;
@ -535,12 +537,7 @@ void checkFanSpeed()
static void fanSpeedErrorBeep(const char *serialMsg, const char *lcdMsg){
SERIAL_ECHOLNRPGM(serialMsg);
if (get_message_level() == 0) {
if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)||(eSoundMode==e_SOUND_MODE_SILENT)){
WRITE(BEEPER, HIGH);
delayMicroseconds(200);
WRITE(BEEPER, LOW);
delayMicroseconds(100); // what is this wait for?
}
Sound_MakeCustom(200,0,true);
LCD_ALERTMESSAGERPGM(lcdMsg);
}
}
@ -548,18 +545,19 @@ static void fanSpeedErrorBeep(const char *serialMsg, const char *lcdMsg){
void fanSpeedError(unsigned char _fan) {
if (get_message_level() != 0 && isPrintPaused) return;
//to ensure that target temp. is not set to zero in case taht we are resuming print
if (card.sdprinting) {
if (card.sdprinting || is_usb_printing) {
if (heating_status != 0) {
lcd_print_stop();
}
else {
fan_check_error = EFCE_DETECTED;
}
}
else {
SERIAL_PROTOCOLLNRPGM(MSG_OCTOPRINT_PAUSE); //for octoprint
setTargetHotend0(0);
SERIAL_ECHOLNPGM("// action:pause"); //for octoprint
heating_status = 0;
fan_check_error = EFCE_REPORTED;
}
switch (_fan) {
case 0: // extracting the same code from case 0 and case 1 into a function saves 72B
@ -569,6 +567,7 @@ void fanSpeedError(unsigned char _fan) {
fanSpeedErrorBeep(PSTR("Print fan speed is lower than expected"), PSTR("Err: PRINT FAN ERROR") );
break;
}
SERIAL_PROTOCOLLNRPGM(MSG_OK);
}
#endif //(defined(TACH_0) && TACH_0 >-1) || (defined(TACH_1) && TACH_1 > -1)
@ -1130,18 +1129,9 @@ void tp_init()
adc_init();
#ifdef SYSTEM_TIMER_2
timer02_init();
timer0_init();
OCR2B = 128;
TIMSK2 |= (1<<OCIE2B);
#else //SYSTEM_TIMER_2
// Use timer0 for temperature measurement
// Interleave temperature interrupt with millies interrupt
OCR0B = 128;
TIMSK0 |= (1<<OCIE0B);
#endif //SYSTEM_TIMER_2
// Wait for temperature measurement to settle
_delay(250);
@ -1406,13 +1396,9 @@ void temp_runaway_stop(bool isPreheat, bool isBed)
disable_e2();
manage_heater();
lcd_update(0);
if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)||(eSoundMode==e_SOUND_MODE_SILENT))
WRITE(BEEPER, HIGH);
delayMicroseconds(500);
WRITE(BEEPER, LOW);
delayMicroseconds(100);
if (isPreheat)
Sound_MakeCustom(200,0,true);
if (isPreheat)
{
Stop();
isBed ? LCD_ALERTMESSAGEPGM("BED PREHEAT ERROR") : LCD_ALERTMESSAGEPGM("PREHEAT ERROR");
@ -1472,8 +1458,8 @@ void disable_heater()
target_temperature_bed=0;
soft_pwm_bed=0;
timer02_set_pwm0(soft_pwm_bed << 1);
#if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1
WRITE(HEATER_BED_PIN,LOW);
#if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1
//WRITE(HEATER_BED_PIN,LOW);
#endif
#endif
}
@ -1506,7 +1492,6 @@ void max_temp_error(uint8_t e) {
SET_OUTPUT(BEEPER);
WRITE(FAN_PIN, 1);
WRITE(EXTRUDER_0_AUTO_FAN_PIN, 1);
if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE)||(eSoundMode==e_SOUND_MODE_SILENT))
WRITE(BEEPER, 1);
// fanSpeed will consumed by the check_axes_activity() routine.
fanSpeed=255;
@ -1544,7 +1529,7 @@ void min_temp_error(uint8_t e) {
void bed_max_temp_error(void) {
#if HEATER_BED_PIN > -1
WRITE(HEATER_BED_PIN, 0);
//WRITE(HEATER_BED_PIN, 0);
#endif
if(IsStopped() == false) {
SERIAL_ERROR_START;
@ -1563,7 +1548,7 @@ void bed_min_temp_error(void) {
#endif
//if (current_temperature_ambient < MINTEMP_MINAMBIENT) return;
#if HEATER_BED_PIN > -1
WRITE(HEATER_BED_PIN, 0);
//WRITE(HEATER_BED_PIN, 0);
#endif
static const char err[] PROGMEM = "Err: MINTEMP BED";
if(IsStopped() == false) {
@ -1660,7 +1645,6 @@ void adc_ready(void) //callback from adc when sampling finished
} // extern "C"
// Timer2 (originaly timer0) is shared with millies
#ifdef SYSTEM_TIMER_2
ISR(TIMER2_COMPB_vect)
@ -1676,8 +1660,8 @@ ISR(TIMER0_COMPB_vect)
if (!temp_meas_ready) adc_cycle();
lcd_buttons_update();
static unsigned char pwm_count = (1 << SOFT_PWM_SCALE);
static unsigned char soft_pwm_0;
static uint8_t pwm_count = (1 << SOFT_PWM_SCALE);
static uint8_t soft_pwm_0;
#ifdef SLOW_PWM_HEATERS
static unsigned char slow_pwm_count = 0;
static unsigned char state_heater_0 = 0;
@ -1698,7 +1682,7 @@ ISR(TIMER0_COMPB_vect)
#endif
#endif
#if HEATER_BED_PIN > -1
static unsigned char soft_pwm_b;
// @@DR static unsigned char soft_pwm_b;
#ifdef SLOW_PWM_HEATERS
static unsigned char state_heater_b = 0;
static unsigned char state_timer_heater_b = 0;
@ -1733,14 +1717,25 @@ ISR(TIMER0_COMPB_vect)
#endif
}
#if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1
#if 0 // @@DR vypnuto pro hw pwm bedu
// tuhle prasarnu bude potreba poustet ve stanovenych intervalech, jinak nemam moc sanci zareagovat
// teoreticky by se tato cast uz vubec nemusela poustet
if ((pwm_count & ((1 << HEATER_BED_SOFT_PWM_BITS) - 1)) == 0)
{
soft_pwm_b = soft_pwm_bed >> (7 - HEATER_BED_SOFT_PWM_BITS);
#ifndef SYSTEM_TIMER_2
if(soft_pwm_b > 0) WRITE(HEATER_BED_PIN,1); else WRITE(HEATER_BED_PIN,0);
#endif //SYSTEM_TIMER_2
# ifndef SYSTEM_TIMER_2
// tady budu krokovat pomalou frekvenci na automatu - tohle je rizeni spinani a rozepinani
// jako ridici frekvenci mam 2khz, jako vystupni frekvenci mam 30hz
// 2kHz jsou ovsem ve slysitelnem pasmu, mozna bude potreba jit s frekvenci nahoru (a tomu taky prizpusobit ostatni veci)
// Teoreticky bych mohl stahnout OCR0B citac na 6, cimz bych se dostal nekam ke 40khz a tady potom honit PWM rychleji nebo i pomaleji
// to nicemu nevadi. Soft PWM scale by se 20x zvetsilo (no dobre, 16x), cimz by se to posunulo k puvodnimu 30Hz PWM
//if(soft_pwm_b > 0) WRITE(HEATER_BED_PIN,1); else WRITE(HEATER_BED_PIN,0);
# endif //SYSTEM_TIMER_2
}
#endif
#endif
#ifdef FAN_SOFT_PWM
if ((pwm_count & ((1 << FAN_SOFT_PWM_BITS) - 1)) == 0)
{
@ -1762,8 +1757,14 @@ ISR(TIMER0_COMPB_vect)
#if EXTRUDERS > 2
if(soft_pwm_2 < pwm_count) WRITE(HEATER_2_PIN,0);
#endif
#if 0 // @@DR
#if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1
if (soft_pwm_b < (pwm_count & ((1 << HEATER_BED_SOFT_PWM_BITS) - 1))) WRITE(HEATER_BED_PIN,0);
if (soft_pwm_b < (pwm_count & ((1 << HEATER_BED_SOFT_PWM_BITS) - 1))){
//WRITE(HEATER_BED_PIN,0);
}
//WRITE(HEATER_BED_PIN, pwm_count & 1 );
#endif
#endif
#ifdef FAN_SOFT_PWM
if (soft_pwm_fan < (pwm_count & ((1 << FAN_SOFT_PWM_BITS) - 1))) WRITE(FAN_PIN,0);

View file

@ -122,6 +122,7 @@ inline void babystepsTodoZsubtract(int n)
//inline so that there is no performance decrease.
//deg=degreeCelsius
// Doesn't save FLASH when FORCE_INLINE removed.
FORCE_INLINE float degHotend(uint8_t extruder) {
return current_temperature[extruder];
};
@ -140,6 +141,7 @@ FORCE_INLINE float degBed() {
return current_temperature_bed;
};
// Doesn't save FLASH when FORCE_INLINE removed.
FORCE_INLINE float degTargetHotend(uint8_t extruder) {
return target_temperature[extruder];
};
@ -148,11 +150,13 @@ FORCE_INLINE float degTargetBed() {
return target_temperature_bed;
};
// Doesn't save FLASH when FORCE_INLINE removed.
FORCE_INLINE void setTargetHotend(const float &celsius, uint8_t extruder) {
target_temperature[extruder] = celsius;
resetPID(extruder);
};
// Doesn't save FLASH when not inlined.
static inline void setTargetHotendSafe(const float &celsius, uint8_t extruder)
{
if (extruder<EXTRUDERS) {
@ -161,6 +165,7 @@ static inline void setTargetHotendSafe(const float &celsius, uint8_t extruder)
}
}
// Doesn't save FLASH when not inlined.
static inline void setAllTargetHotends(const float &celsius)
{
for(int i=0;i<EXTRUDERS;i++) setTargetHotend(celsius,i);

View file

@ -9,48 +9,27 @@
#include <avr/io.h>
#include <avr/interrupt.h>
#include "Arduino.h"
#include "io_atmega2560.h"
#define BEEPER 84
uint8_t timer02_pwm0 = 0;
void timer02_set_pwm0(uint8_t pwm0)
{
if (timer02_pwm0 == pwm0) return;
if (pwm0)
{
TCCR0A |= (2 << COM0B0);
OCR0B = pwm0 - 1;
}
else
{
TCCR0A &= ~(2 << COM0B0);
OCR0B = 0;
}
timer02_pwm0 = pwm0;
}
void timer02_init(void)
void timer0_init(void)
{
//save sreg
uint8_t _sreg = SREG;
//disable interrupts for sure
cli();
//mask timer0 interrupts - disable all
TIMSK0 &= ~(1<<TOIE0);
TIMSK0 &= ~(1<<OCIE0A);
TIMSK0 &= ~(1<<OCIE0B);
//setup timer0
TCCR0A = 0x00; //COM_A-B=00, WGM_0-1=00
TCCR0B = (1 << CS00); //WGM_2=0, CS_0-2=011
//switch timer0 to fast pwm mode
TCCR0A |= (3 << WGM00); //WGM_0-1=11
//set OCR0B register to zero
OCR0B = 0;
//disable OCR0B output (will be enabled in timer02_set_pwm0)
TCCR0A &= ~(2 << COM0B0);
TCNT0 = 0;
// Fast PWM duty (0-255).
// Due to invert mode (following rows) the duty is set to 255, which means zero all the time (bed not heating)
OCR0B = 255;
// Set fast PWM mode and inverting mode.
TCCR0A = (1 << WGM01) | (1 << WGM00) | (1 << COM0B1) | (1 << COM0B0);
TCCR0B = (1 << CS00); // no clock prescaling
TIMSK0 |= (1 << TOIE0); // enable timer overflow interrupt
// Everything, that used to be on timer0 was moved to timer2 (delay, beeping, millis etc.)
//setup timer2
TCCR2A = 0x00; //COM_A-B=00, WGM_0-1=00
TCCR2B = (4 << CS20); //WGM_2=0, CS_0-2=011
@ -66,11 +45,9 @@ void timer02_init(void)
}
//following code is OVF handler for timer 2
//it is copy-paste from wiring.c and modified for timer2
//variables timer0_overflow_count and timer0_millis are declared in wiring.c
// The following code is OVF handler for timer 2
// it was copy-pasted from wiring.c and modified for timer2
// variables timer0_overflow_count and timer0_millis are declared in wiring.c
// the prescaler is set so that timer0 ticks every 64 clock cycles, and the
// the overflow handler is called every 256 ticks.
@ -85,9 +62,6 @@ void timer02_init(void)
#define FRACT_INC ((MICROSECONDS_PER_TIMER0_OVERFLOW % 1000) >> 3)
#define FRACT_MAX (1000 >> 3)
//extern volatile unsigned long timer0_overflow_count;
//extern volatile unsigned long timer0_millis;
//unsigned char timer0_fract = 0;
volatile unsigned long timer2_overflow_count;
volatile unsigned long timer2_millis;
unsigned char timer2_fract = 0;

View file

@ -11,24 +11,25 @@
extern "C" {
#endif //defined(__cplusplus)
///! Initializes TIMER0 for fast PWM mode-driven bed heating
extern void timer0_init(void);
extern uint8_t timer02_pwm0;
extern void timer02_set_pwm0(uint8_t pwm0);
extern void timer02_init(void);
///! Reimplemented original millis() using timer2
extern unsigned long millis2(void);
///! Reimplemented original micros() using timer2
extern unsigned long micros2(void);
///! Reimplemented original delay() using timer2
extern void delay2(unsigned long ms);
///! Reimplemented original tone() using timer2
///! Does not perform any PWM tone generation, it just sets the beeper pin to 1
extern void tone2(uint8_t _pin, unsigned int frequency/*, unsigned long duration*/);
///! Turn off beeping - set beeper pin to 0
extern void noTone2(uint8_t _pin);
#if defined(__cplusplus)
}
#endif //defined(__cplusplus)

View file

@ -142,8 +142,11 @@ uint16_t __tcoolthrs(uint8_t axis)
}
return 0;
}
#ifdef PSU_Delta
void tmc2130_init(bool bSupressFlag)
#else
void tmc2130_init()
#endif
{
// DBG(_n("tmc2130_init(), mode=%S\n"), tmc2130_mode?_n("STEALTH"):_n("NORMAL"));
WRITE(X_TMC2130_CS, HIGH);
@ -216,6 +219,11 @@ void tmc2130_init()
tmc2130_set_wave(E_AXIS, 247, tmc2130_wave_fac[E_AXIS]);
#endif //TMC2130_LINEARITY_CORRECTION
#ifdef PSU_Delta
if(!bSupressFlag)
check_force_z();
#endif // PSU_Delta
}
uint8_t tmc2130_sample_diag()

View file

@ -51,7 +51,11 @@ typedef struct
extern tmc2130_chopper_config_t tmc2130_chopper_config[4];
//initialize tmc2130
#ifdef PSU_Delta
extern void tmc2130_init(bool bSupressFlag=false);
#else
extern void tmc2130_init();
#endif
//check diag pins (called from stepper isr)
extern void tmc2130_st_isr();
//update stall guard (called from st_synchronize inside the loop)

File diff suppressed because it is too large Load diff

View file

@ -7,9 +7,6 @@
#include "menu.h"
#include "mesh_bed_calibration.h"
extern int lcd_puts_P(const char* str);
extern int lcd_printf_P(const char* format, ...);
extern void menu_lcd_longpress_func(void);
extern void menu_lcd_charsetup_func(void);
extern void menu_lcd_lcdupdate_func(void);
@ -143,6 +140,10 @@ void lcd_ignore_click(bool b=true);
void lcd_commands();
extern bool bSettings; // flag (i.e. 'fake parameter') for 'lcd_hw_setup_menu()' function
void lcd_hw_setup_menu(void); // NOT static due to using inside "util" module ("nozzle_diameter_check()")
void change_extr(int extr);
#ifdef SNMM

View file

@ -27,7 +27,7 @@ const char STR_REVISION_RC [] PROGMEM = "rc";
inline bool is_whitespace_or_nl(char c)
{
return c == ' ' || c == '\t' || c == '\n' || c == 'r';
return c == ' ' || c == '\t' || c == '\n' || c == '\r';
}
inline bool is_whitespace_or_nl_or_eol(char c)
@ -295,15 +295,9 @@ bool show_upgrade_dialog_if_version_newer(const char *version_string)
for (const char *c = version_string; ! is_whitespace_or_nl_or_eol(*c); ++ c)
lcd_putc(*c);
lcd_puts_at_P(0, 3, _i("Please upgrade."));////MSG_NEW_FIRMWARE_PLEASE_UPGRADE c=20
if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
_tone(BEEPER, 1000);
delay_keep_alive(50);
_noTone(BEEPER);
Sound_MakeCustom(50,1000,false);
delay_keep_alive(500);
if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
_tone(BEEPER, 1000);
delay_keep_alive(50);
_noTone(BEEPER);
Sound_MakeCustom(50,1000,false);
lcd_wait_for_click_delay(30);
lcd_update_enable(true);
lcd_clear();
@ -330,43 +324,279 @@ void update_current_firmware_version_to_eeprom()
//-//
eNOZZLE_DIAMETER eNozzleDiameter=e_NOZZLE_DIAMETER_400;
eCHECK_MODE eCheckMode=e_CHECK_MODE_none;
#define MSG_PRINT_CHECKING_FAILED_TIMEOUT 30
ClNozzleDiameter oNozzleDiameter=ClNozzleDiameter::_Diameter_400;
ClCheckMode oCheckMode=ClCheckMode::_None;
ClCheckModel oCheckModel=ClCheckModel::_None;
ClCheckVersion oCheckVersion=ClCheckVersion::_None;
ClCheckGcode oCheckGcode=ClCheckGcode::_None;
void fCheckModeInit()
{
eCheckMode=(eCHECK_MODE)eeprom_read_byte((uint8_t*)EEPROM_CHECK_MODE);
if(eCheckMode==e_CHECK_MODE_NULL)
oCheckMode=(ClCheckMode)eeprom_read_byte((uint8_t*)EEPROM_CHECK_MODE);
if(oCheckMode==ClCheckMode::_Undef)
{
eCheckMode=e_CHECK_MODE_warn;
eeprom_update_byte((uint8_t*)EEPROM_CHECK_MODE,(uint8_t)eCheckMode);
oCheckMode=ClCheckMode::_Warn;
eeprom_update_byte((uint8_t*)EEPROM_CHECK_MODE,(uint8_t)oCheckMode);
}
if(farm_mode)
eCheckMode=e_CHECK_MODE_strict;
eNozzleDiameter=(eNOZZLE_DIAMETER)eeprom_read_byte((uint8_t*)EEPROM_NOZZLE_DIAMETER);
if((eNozzleDiameter==e_NOZZLE_DIAMETER_NULL)&& !farm_mode)
oCheckMode=ClCheckMode::_Strict;
oNozzleDiameter=(ClNozzleDiameter)eeprom_read_byte((uint8_t*)EEPROM_NOZZLE_DIAMETER);
if((oNozzleDiameter==ClNozzleDiameter::_Diameter_Undef)&& !farm_mode)
{
eNozzleDiameter=e_NOZZLE_DIAMETER_400;
eeprom_update_byte((uint8_t*)EEPROM_NOZZLE_DIAMETER,(uint8_t)eNozzleDiameter);
oNozzleDiameter=ClNozzleDiameter::_Diameter_400;
eeprom_update_byte((uint8_t*)EEPROM_NOZZLE_DIAMETER,(uint8_t)oNozzleDiameter);
eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,400);
}
oCheckModel=(ClCheckModel)eeprom_read_byte((uint8_t*)EEPROM_CHECK_MODEL);
if(oCheckModel==ClCheckModel::_Undef)
{
oCheckModel=ClCheckModel::_Warn;
eeprom_update_byte((uint8_t*)EEPROM_CHECK_MODEL,(uint8_t)oCheckModel);
}
oCheckVersion=(ClCheckVersion)eeprom_read_byte((uint8_t*)EEPROM_CHECK_VERSION);
if(oCheckVersion==ClCheckVersion::_Undef)
{
oCheckVersion=ClCheckVersion::_Warn;
eeprom_update_byte((uint8_t*)EEPROM_CHECK_VERSION,(uint8_t)oCheckVersion);
}
oCheckGcode=(ClCheckGcode)eeprom_read_byte((uint8_t*)EEPROM_CHECK_GCODE);
if(oCheckGcode==ClCheckGcode::_Undef)
{
oCheckGcode=ClCheckGcode::_Warn;
eeprom_update_byte((uint8_t*)EEPROM_CHECK_GCODE,(uint8_t)oCheckGcode);
}
}
void nozzle_diameter_check(uint16_t nDiameter)
{
uint16_t nDiameter_um;
if(oCheckMode==ClCheckMode::_None)
return;
nDiameter_um=eeprom_read_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM);
if(nDiameter==nDiameter_um)
return;
switch(eCheckMode)
//SERIAL_ECHO_START;
//SERIAL_ECHOLNPGM("Printer nozzle diameter differs from the G-code ...");
//SERIAL_ECHOPGM("actual : ");
//SERIAL_ECHOLN((float)(nDiameter_um/1000.0));
//SERIAL_ECHOPGM("expected: ");
//SERIAL_ECHOLN((float)(nDiameter/1000.0));
switch(oCheckMode)
{
case e_CHECK_MODE_warn:
lcd_show_fullscreen_message_and_wait_P(_i("Nozzle diameter doesn't match! Press the knob to continue."));
case ClCheckMode::_Warn:
// lcd_show_fullscreen_message_and_wait_P(_i("Printer nozzle diameter differs from the G-code. Continue?"));
lcd_display_message_fullscreen_P(_i("Printer nozzle diameter differs from the G-code. Continue?"));
lcd_wait_for_click_delay(MSG_PRINT_CHECKING_FAILED_TIMEOUT);
//???custom_message_type=CUSTOM_MSG_TYPE_STATUS; // display / status-line recovery
lcd_update_enable(true); // display / status-line recovery
break;
case e_CHECK_MODE_strict:
lcd_show_fullscreen_message_and_wait_P(_i("Nozzle diameter doesn't match! Print is aborted, press the knob."));
case ClCheckMode::_Strict:
lcd_show_fullscreen_message_and_wait_P(_i("Printer nozzle diameter differs from the G-code. Please check the value in settings. Print cancelled."));
lcd_print_stop();
break;
case ClCheckMode::_None:
case ClCheckMode::_Undef:
break;
}
if(!farm_mode)
{
bSettings=false; // flag ('fake parameter') for 'lcd_hw_setup_menu()' function
menu_submenu(lcd_hw_setup_menu);
}
}
void printer_model_check(uint16_t nPrinterModel)
{
if(oCheckModel==ClCheckModel::_None)
return;
if(nPrinterModel==nPrinterType)
return;
//SERIAL_ECHO_START;
//SERIAL_ECHOLNPGM("Printer model differs from the G-code ...");
//SERIAL_ECHOPGM("actual : ");
//SERIAL_ECHOLN(nPrinterType);
//SERIAL_ECHOPGM("expected: ");
//SERIAL_ECHOLN(nPrinterModel);
switch(oCheckModel)
{
case ClCheckModel::_Warn:
// lcd_show_fullscreen_message_and_wait_P(_i("Printer model differs from the G-code. Continue?"));
lcd_display_message_fullscreen_P(_i("G-code sliced for a different printer type. Continue?"));
lcd_wait_for_click_delay(MSG_PRINT_CHECKING_FAILED_TIMEOUT);
//???custom_message_type=CUSTOM_MSG_TYPE_STATUS; // display / status-line recovery
lcd_update_enable(true); // display / status-line recovery
break;
case ClCheckModel::_Strict:
lcd_show_fullscreen_message_and_wait_P(_i("G-code sliced for a different printer type. Please re-slice the model again. Print cancelled."));
lcd_print_stop();
break;
case ClCheckModel::_None:
case ClCheckModel::_Undef:
break;
}
}
uint8_t mCompareValue(uint16_t nX,uint16_t nY)
{
if(nX>nY)
return((uint8_t)ClCompareValue::_Greater);
if(nX<nY)
return((uint8_t)ClCompareValue::_Less);
return((uint8_t)ClCompareValue::_Equal);
}
void fw_version_check(const char *pVersion)
{
uint16_t aVersion[4];
uint8_t nCompareValueResult;
if(oCheckVersion==ClCheckVersion::_None)
return;
parse_version(pVersion,aVersion);
nCompareValueResult=mCompareValue(aVersion[0],eeprom_read_word((uint16_t*)EEPROM_FIRMWARE_VERSION_MAJOR))<<6;
nCompareValueResult+=mCompareValue(aVersion[1],eeprom_read_word((uint16_t*)EEPROM_FIRMWARE_VERSION_MINOR))<<4;
nCompareValueResult+=mCompareValue(aVersion[2],eeprom_read_word((uint16_t*)EEPROM_FIRMWARE_VERSION_REVISION))<<2;
nCompareValueResult+=mCompareValue(aVersion[3],eeprom_read_word((uint16_t*)EEPROM_FIRMWARE_VERSION_FLAVOR));
if(nCompareValueResult==COMPARE_VALUE_EQUAL)
return;
if((nCompareValueResult<COMPARE_VALUE_EQUAL)&&oCheckVersion==ClCheckVersion::_Warn)
return;
//SERIAL_ECHO_START;
//SERIAL_ECHOLNPGM("Printer FW version differs from the G-code ...");
//SERIAL_ECHOPGM("actual : ");
//SERIAL_ECHOLN(FW_VERSION);
//SERIAL_ECHOPGM("expected: ");
//SERIAL_ECHOLN(pVersion);
switch(oCheckVersion)
{
case ClCheckVersion::_Warn:
// lcd_show_fullscreen_message_and_wait_P(_i("Printer FW version differs from the G-code. Continue?"));
lcd_display_message_fullscreen_P(_i("G-code sliced for a newer firmware. Continue?"));
lcd_wait_for_click_delay(MSG_PRINT_CHECKING_FAILED_TIMEOUT);
//???custom_message_type=CUSTOM_MSG_TYPE_STATUS; // display / status-line recovery
lcd_update_enable(true); // display / status-line recovery
break;
case ClCheckVersion::_Strict:
lcd_show_fullscreen_message_and_wait_P(_i("G-code sliced for a newer firmware. Please update the firmware. Print cancelled."));
lcd_print_stop();
break;
case ClCheckVersion::_None:
case ClCheckVersion::_Undef:
break;
}
}
void gcode_level_check(uint16_t nGcodeLevel)
{
if(oCheckGcode==ClCheckGcode::_None)
return;
if(nGcodeLevel==(uint16_t)GCODE_LEVEL)
return;
if((nGcodeLevel<(uint16_t)GCODE_LEVEL)&&(oCheckGcode==ClCheckGcode::_Warn))
return;
//SERIAL_ECHO_START;
//SERIAL_ECHOLNPGM("Printer G-code level differs from the G-code ...");
//SERIAL_ECHOPGM("actual : ");
//SERIAL_ECHOLN(GCODE_LEVEL);
//SERIAL_ECHOPGM("expected: ");
//SERIAL_ECHOLN(nGcodeLevel);
switch(oCheckGcode)
{
case ClCheckGcode::_Warn:
// lcd_show_fullscreen_message_and_wait_P(_i("Printer G-code level differs from the G-code. Continue?"));
lcd_display_message_fullscreen_P(_i("G-code sliced for a different level. Continue?"));
lcd_wait_for_click_delay(MSG_PRINT_CHECKING_FAILED_TIMEOUT);
//???custom_message_type=CUSTOM_MSG_TYPE_STATUS; // display / status-line recovery
lcd_update_enable(true); // display / status-line recovery
break;
case ClCheckGcode::_Strict:
lcd_show_fullscreen_message_and_wait_P(_i("G-code sliced for a different level. Please re-slice the model again. Print cancelled."));
lcd_print_stop();
break;
case ClCheckGcode::_None:
case ClCheckGcode::_Undef:
break;
}
}
//-// -> cmdqueue ???
#define PRINTER_NAME_LENGTH ((sizeof(PRINTER_MMU_NAME)>sizeof(PRINTER_NAME))?(sizeof(PRINTER_MMU_NAME)-1):(sizeof(PRINTER_NAME)-1))
#define GCODE_DELIMITER '"'
#define ELLIPSIS "..."
char* code_string(char* pStr,size_t* nLength)
{
char* pStrBegin;
char* pStrEnd;
pStrBegin=strchr(pStr,GCODE_DELIMITER);
if(!pStrBegin)
return(NULL);
pStrBegin++;
pStrEnd=strchr(pStrBegin,GCODE_DELIMITER);
if(!pStrEnd)
return(NULL);
*nLength=pStrEnd-pStrBegin;
return(pStrBegin);
}
void printer_smodel_check(char* pStrPos)
{
char* pResult;
size_t nLength,nPrinterNameLength;
bool bCheckOK;
char sPrinterName[PRINTER_NAME_LENGTH+sizeof(ELLIPSIS)-1+1]="";
nPrinterNameLength=strlen_P(::sPrinterName);
pResult=code_string(pStrPos,&nLength);
if(pResult!=NULL)
{
strlcpy(sPrinterName,pResult,min(nPrinterNameLength,nLength)+1);
if(nLength>nPrinterNameLength)
strcat(sPrinterName,ELLIPSIS);
bCheckOK=(nLength==nPrinterNameLength);
if(bCheckOK&&(!strncasecmp_P(pResult,::sPrinterName,nLength))) // i.e. string compare execute only if lengths are same
return;
}
//SERIAL_ECHO_START;
//SERIAL_ECHOLNPGM("Printer model differs from the G-code ...");
//SERIAL_ECHOPGM("actual : \"");
//serialprintPGM(::sPrinterName);
//SERIAL_ECHOLNPGM("\"");
//SERIAL_ECHOPGM("expected: \"");
////SERIAL_ECHO(sPrinterName);
//SERIAL_ECHOLNPGM("\"");
switch(oCheckModel)
{
case ClCheckModel::_Warn:
// lcd_show_fullscreen_message_and_wait_P(_i("Printer model differs from the G-code. Continue?"));
lcd_display_message_fullscreen_P(_i("G-code sliced for a different printer type. Continue?"));
lcd_wait_for_click_delay(MSG_PRINT_CHECKING_FAILED_TIMEOUT);
//???custom_message_type=CUSTOM_MSG_TYPE_STATUS; // display / status-line recovery
lcd_update_enable(true); // display / status-line recovery
break;
case ClCheckModel::_Strict:
lcd_show_fullscreen_message_and_wait_P(_i("G-code sliced for a different printer type. Please re-slice the model again. Print cancelled."));
lcd_print_stop();
break;
case ClCheckModel::_None:
case ClCheckModel::_Undef:
break;
}
}
void fSetMmuMode(bool bMMu)
{
if(bMMu)
{
nPrinterType=pgm_read_word(&_nPrinterMmuType);
sPrinterName=_sPrinterMmuName;
}
else {
nPrinterType=pgm_read_word(&_nPrinterType);
sPrinterName=_sPrinterName;
}
}

View file

@ -35,27 +35,76 @@ inline void eeprom_update_int8(unsigned char* addr, int8_t v) {
//-//
#define e_CHECK_MODE_NULL 0xFF
#define e_NOZZLE_DIAMETER_NULL 0xFF
typedef enum
enum class ClPrintChecking:uint_least8_t
{
e_NOZZLE_DIAMETER_250,
e_NOZZLE_DIAMETER_400,
e_NOZZLE_DIAMETER_600
} eNOZZLE_DIAMETER;
_Nozzle=1,
_Model=2,
_Smodel=3,
_Version=4,
_Gcode=5
};
typedef enum
enum class ClNozzleDiameter:uint_least8_t
{
e_CHECK_MODE_none,
e_CHECK_MODE_warn,
e_CHECK_MODE_strict
} eCHECK_MODE;
_Diameter_250=25,
_Diameter_400=40,
_Diameter_600=60,
_Diameter_Undef=EEPROM_EMPTY_VALUE
};
extern eNOZZLE_DIAMETER eNozzleDiameter;
extern eCHECK_MODE eCheckMode;
enum class ClCheckMode:uint_least8_t
{
_None,
_Warn,
_Strict,
_Undef=EEPROM_EMPTY_VALUE
};
enum class ClCheckModel:uint_least8_t
{
_None,
_Warn,
_Strict,
_Undef=EEPROM_EMPTY_VALUE
};
enum class ClCheckVersion:uint_least8_t
{
_None,
_Warn,
_Strict,
_Undef=EEPROM_EMPTY_VALUE
};
enum class ClCheckGcode:uint_least8_t
{
_None,
_Warn,
_Strict,
_Undef=EEPROM_EMPTY_VALUE
};
#define COMPARE_VALUE_EQUAL (((uint8_t)ClCompareValue::_Equal<<6)+((uint8_t)ClCompareValue::_Equal<<4)+((uint8_t)ClCompareValue::_Equal<<2)+((uint8_t)ClCompareValue::_Equal))
enum class ClCompareValue:uint_least8_t
{
_Less=0,
_Equal=1,
_Greater=2
};
extern ClNozzleDiameter oNozzleDiameter;
extern ClCheckMode oCheckMode;
extern ClCheckModel oCheckModel;
extern ClCheckVersion oCheckVersion;
extern ClCheckGcode oCheckGcode;
void fCheckModeInit();
void nozzle_diameter_check(uint16_t nDiameter);
void printer_model_check(uint16_t nPrinterModel);
void printer_smodel_check(char* pStrPos);
void fw_version_check(const char *pVersion);
void gcode_level_check(uint16_t nGcodeLevel);
void fSetMmuMode(bool bMMu);
#endif /* UTIL_H */

View file

@ -2,12 +2,16 @@
#define CONFIGURATION_PRUSA_H
#include <limits.h>
#include "printers.h"
/*------------------------------------
GENERAL SETTINGS
*------------------------------------*/
// Printer revision
#define PRINTER_TYPE PRINTER_MK2
#define PRINTER_NAME PRINTER_MK2_NAME
#define PRINTER_MMU_TYPE PRINTER_MK2 // dummy item (due to successfully compilation / building only)
#define PRINTER_MMU_NAME PRINTER_MK2_NAME // dummy item (due to successfully compilation / building only)
#define FILAMENT_SIZE "1_75mm_MK2"
#define NOZZLE_TYPE "E3Dv6full"

View file

@ -2,12 +2,16 @@
#define CONFIGURATION_PRUSA_H
#include <limits.h>
#include "printers.h"
/*------------------------------------
GENERAL SETTINGS
*------------------------------------*/
// Printer revision
#define PRINTER_TYPE PRINTER_MK2
#define PRINTER_NAME PRINTER_MK2_NAME
#define PRINTER_MMU_TYPE PRINTER_MK2 // dummy item (due to successfully compilation / building only)
#define PRINTER_MMU_NAME PRINTER_MK2_NAME // dummy item (due to successfully compilation / building only)
#define FILAMENT_SIZE "1_75mm_MK2"
#define NOZZLE_TYPE "E3Dv6full"

View file

@ -2,12 +2,16 @@
#define CONFIGURATION_PRUSA_H
#include <limits.h>
#include "printers.h"
/*------------------------------------
GENERAL SETTINGS
*------------------------------------*/
// Printer revision
#define PRINTER_TYPE PRINTER_MK25
#define PRINTER_NAME PRINTER_MK25_NAME
#define PRINTER_MMU_TYPE PRINTER_MK25_MMU2
#define PRINTER_MMU_NAME PRINTER_MK25_MMU2_NAME
#define FILAMENT_SIZE "1_75mm_MK25"
#define NOZZLE_TYPE "E3Dv6full"

View file

@ -2,12 +2,16 @@
#define CONFIGURATION_PRUSA_H
#include <limits.h>
#include "printers.h"
/*------------------------------------
GENERAL SETTINGS
*------------------------------------*/
// Printer revision
#define PRINTER_TYPE PRINTER_MK25
#define PRINTER_NAME PRINTER_MK25_NAME
#define PRINTER_MMU_TYPE PRINTER_MK25_MMU2
#define PRINTER_MMU_NAME PRINTER_MK25_MMU2_NAME
#define FILAMENT_SIZE "1_75mm_MK25"
#define NOZZLE_TYPE "E3Dv6full"

View file

@ -2,12 +2,16 @@
#define CONFIGURATION_PRUSA_H
#include <limits.h>
#include "printers.h"
/*------------------------------------
GENERAL SETTINGS
*------------------------------------*/
// Printer revision
#define PRINTER_TYPE PRINTER_MK25S
#define PRINTER_NAME PRINTER_MK25S_NAME
#define PRINTER_MMU_TYPE PRINTER_MK25S_MMU2
#define PRINTER_MMU_NAME PRINTER_MK25S_MMU2_NAME
#define FILAMENT_SIZE "1_75mm_MK25S"
#define NOZZLE_TYPE "E3Dv6full"

View file

@ -2,12 +2,16 @@
#define CONFIGURATION_PRUSA_H
#include <limits.h>
#include "printers.h"
/*------------------------------------
GENERAL SETTINGS
*------------------------------------*/
// Printer revision
#define PRINTER_TYPE PRINTER_MK25S
#define PRINTER_NAME PRINTER_MK25S_NAME
#define PRINTER_MMU_TYPE PRINTER_MK25S_MMU2
#define PRINTER_MMU_NAME PRINTER_MK25S_MMU2_NAME
#define FILAMENT_SIZE "1_75mm_MK25"
#define NOZZLE_TYPE "E3Dv6full"

View file

@ -2,12 +2,17 @@
#define CONFIGURATION_PRUSA_H
#include <limits.h>
//-//
#include "printers.h"
/*------------------------------------
GENERAL SETTINGS
*------------------------------------*/
// Printer revision
#define PRINTER_TYPE PRINTER_MK3
#define PRINTER_NAME PRINTER_MK3_NAME
#define PRINTER_MMU_TYPE PRINTER_MK3_MMU2
#define PRINTER_MMU_NAME PRINTER_MK3_MMU2_NAME
#define FILAMENT_SIZE "1_75mm_MK3"
#define NOZZLE_TYPE "E3Dv6full"

View file

@ -2,12 +2,16 @@
#define CONFIGURATION_PRUSA_H
#include <limits.h>
#include "printers.h"
/*------------------------------------
GENERAL SETTINGS
*------------------------------------*/
// Printer revision
#define PRINTER_TYPE PRINTER_MK3S
#define PRINTER_NAME PRINTER_MK3S_NAME
#define PRINTER_MMU_TYPE PRINTER_MK3S_MMU2
#define PRINTER_MMU_NAME PRINTER_MK3S_MMU2_NAME
#define FILAMENT_SIZE "1_75mm_MK3"
#define NOZZLE_TYPE "E3Dv6full"
@ -22,6 +26,9 @@
#define STEEL_SHEET
#define HAS_SECOND_SERIAL_PORT
// PSU
#define PSU_Delta // uncomment if DeltaElectronics PSU installed
// Uncomment the below for the E3D PT100 temperature sensor (with or without PT100 Amplifier)
//#define E3D_PT100_EXTRUDER_WITH_AMP

View file

@ -2,6 +2,7 @@
# This bash script is used to compile automatically the Prusa firmware with a dedicated build environment and settings
#
# Supported OS: Windows 10, Linux64 bit
# Beta OS: Linux32 bit
#
# Linux:
#
@ -10,9 +11,12 @@
#
# Linux Subsystem Ubuntu
# 1. Follow these instructions
# 2. Open Ubuntu bash and get latest updates with 'apt-get upgate'
# 2. Open Ubuntu bash and get latest updates with 'apt-get update'
# 3. Install zip with 'apt-get install zip'
# 4. Add at top of ~/.bashrc following lines by using 'sudo nano ~/.bashrc'
# 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/
# 6. Add at top of ~/.bashrc following lines by using 'sudo nano ~/.bashrc'
#
# export OS="Linux"
# export JAVA_TOOL_OPTIONS="-Djava.net.preferIPv4Stack=true"
@ -44,11 +48,19 @@
# gussner@WIN01 MINGW64 /d/Data/Prusa-Firmware
# FW351-Build1778-1_75mm_MK25-RAMBo13a-E3Dv6full.hex
#
# Version: 1.0.1-Build_8
# Why make Arduino IDE portable?
# To have a distinguished Prusa Firmware build environment I decided to use Arduino IDE in portable mode.
# - Changes made to other Arduino instances do not change anything in this build environment.
# By default Arduino IDE uses "users" and shared library folders which is useful as soon you update the Software.
# But in this case we need a stable and defined build environment, so keep it separated it kind of important.
# 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_9
# 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 enviroment
# 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
@ -76,108 +88,320 @@
# $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 enviromentto 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
# --> 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, 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
# 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, 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
# 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
#### Start check if OSTYPE is supported
OS_FOUND=$( command -v uname)
###Check if OSTYPE is supported
if [ $OSTYPE == "msys" ]; then
case $( "${OS_FOUND}" | tr '[:upper:]' '[:lower:]') in
linux*)
TARGET_OS="linux"
;;
msys*|cygwin*|mingw*)
# or possible 'bash on windows'
TARGET_OS='windows'
;;
nt|win*)
TARGET_OS='windows'
;;
*)
TARGET_OS='unknown'
;;
esac
# Windows
if [ $TARGET_OS == "windows" ]; then
if [ $(uname -m) == "x86_64" ]; then
echo "$(tput setaf 2)Windows 64-bit found$(tput sgr0)"
Processor="64"
elif [ $(uname -m) == "i386" ]; then
echo "$(tput setaf 2)Windows 32-bit found$(tput sgr0)"
Processor="32"
else
echo "$(tput setaf 1)Unsupported OS: Windows $(uname -m)"
echo "Please refer to the notes of build.sh$(tput sgr0)"
exit 1
fi
elif [ $OSTYPE == "linux-gnu" ]; then
# Linux
elif [ $TARGET_OS == "linux" ]; then
if [ $(uname -m) == "x86_64" ]; then
echo "$(tput setaf 2)Linux 64-bit found$(tput sgr0)"
Processor="64"
elif [[ $(uname -m) == "i386" || $(uname -m) == "i686" ]]; then
echo "$(tput setaf 2)Linux 32-bit found$(tput sgr0)"
Processor="32"
else
echo "$(tput setaf 1)Unsupported OS: Linux $(uname -m)"
echo "Please refer to the notes of build.sh$(tput sgr0)"
exit 1
fi
else
echo "$(tput setaf 1)This script doesn't support your Operating system!"
echo "Please use Linux 64-bit or Windows 10 64-bit with Linux subsystem / git-bash"
echo "Read the notes of build.sh$(tput sgr0)"
exit
exit 1
fi
sleep 2
###Prepare bash enviroment and check if wget and zip are available
#### End check if OSTYPE is supported
#### Prepare bash environment and check if wget, zip and other needed things are available
# Check wget
if ! type wget > /dev/null; then
echo "$(tput setaf 1)Missing 'wget' which is important to run this script"
echo "Please follow these instructions https://gist.github.com/evanwill/0207876c3243bbb6863e65ec5dc3f058 to install wget$(tput sgr0)"
exit
exit 2
fi
# Check for zip
if ! type zip > /dev/null; then
if [ $OSTYPE == "msys" ]; then
if [ $TARGET_OS == "windows" ]; then
echo "$(tput setaf 1)Missing 'zip' which is important to run this script"
echo "Download and install 7z-zip from its official website https://www.7-zip.org/"
echo "By default, it is installed under the directory /c/Program Files/7-Zip in Windows 10 as my case."
echo "Run git Bash under Administrator privilege and"
echo "navigate to the directory /c/Program Files/Git/mingw64/bin,"
echo "you can run the command $(tput setaf 2)ln -s /c/Program Files/7-Zip/7z.exe zip.exe$(tput sgr0)"
exit
elif [ $OSTYPE == "linux-gnu" ]; then
exit 3
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)"
exit
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"
exit 4
elif [ $TARGET_OS == "linux" ]; then
echo "$(tput setaf 1)Missing 'python' which is important to run this script"
echo "As Python 2.x will not be maintained from 2020 please,"
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)"
exit 4
fi
fi
###End prepare bash enviroment
BUILD_ENV="1.0.2"
#### End prepare bash environment
#### Set build environment
ARDUINO_ENV="1.8.5"
BUILD_ENV="1.0.6"
BOARD="PrusaResearchRambo"
BOARD_VERSION="1.0.1"
BOARD_URL="https://raw.githubusercontent.com/prusa3d/Arduino_Boards/master/IDE_Board_Manager/package_prusa3d_index.json"
BOARD_FILENAME="prusa3drambo"
BOARD_FILE_URL="https://raw.githubusercontent.com/prusa3d/Arduino_Boards/master/IDE_Board_Manager/prusa3drambo-1.0.1.tar.bz2"
PF_BUILD_FILE_URL="https://github.com/3d-gussner/PF-build-env/releases/download/$BUILD_ENV/PF-build-env-$BUILD_ENV.zip"
LIB="PrusaLibrary"
SCRIPT_PATH="$( cd "$(dirname "$0")" ; pwd -P )"
# List few useful data
echo
echo "Script path:" $SCRIPT_PATH
echo "OS :" $OS
echo "OS type :" $OSTYPE
echo "Script path :" $SCRIPT_PATH
echo "OS :" $OS
echo "OS type :" $TARGET_OS
echo ""
echo "Ardunio IDE :" $ARDUINO_ENV
echo "Build env :" $BUILD_ENV
echo "Board :" $BOARD
echo "Specific Lib:" $LIB
echo ""
#### Start prepare building
#### Start prepare building environment
#Check if build exists and creates it if not
if [ ! -d "../build-env" ]; then
mkdir ../build-env || exit 2
if [ ! -d "../PF-build-dl" ]; then
mkdir ../PF-build-dl || exit 5
fi
cd ../build-env || exit 3
cd ../PF-build-dl || exit 6
BUILD_ENV_PATH="$( cd "$(dirname "$0")" ; pwd -P )"
# Check if PF-build-env-<version> exists and downloads + creates it if not
# The build enviroment is based on the Arduino IDE 1.8.5 portal version with some changes
# The build environment is based on the supported Arduino IDE portable version with some changes
if [ ! -d "../PF-build-env-$BUILD_ENV" ]; then
echo "$(tput setaf 6)PF-build-env-$BUILD_ENV is missing ... creating it now for you$(tput sgr 0)"
mkdir ../PF-build-env-$BUILD_ENV
sleep 5
fi
if [ $OSTYPE == "msys" ]; then
if [ ! -f "PF-build-env-Win-$BUILD_ENV.zip" ]; then
echo "$(tput setaf 6)Downloading Windows build environment...$(tput setaf 2)"
# Download and extract supported Arduino IDE depending on OS
# Windows
if [ $TARGET_OS == "windows" ]; then
if [ ! -f "arduino-$ARDUINO_ENV-windows.zip" ]; then
echo "$(tput setaf 6)Downloading Windows 32/64-bit Arduino IDE portable...$(tput setaf 2)"
sleep 2
wget https://github.com/3d-gussner/PF-build-env/releases/download/Win-$BUILD_ENV/PF-build-env-Win-$BUILD_ENV.zip || exit 4
#cp -f ../../PF-build-env/PF-build-env-Win-$BUILD_ENV.zip PF-build-env-Win-$BUILD_ENV.zip || exit4
wget https://downloads.arduino.cc/arduino-$ARDUINO_ENV-windows.zip || exit 7
echo "$(tput sgr 0)"
fi
if [ ! -d "../PF-build-env-$BUILD_ENV/$OSTYPE" ]; then
echo "$(tput setaf 6)Unzipping Windows build environment...$(tput setaf 2)"
if [ ! -d "../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor" ]; then
echo "$(tput setaf 6)Unzipping Windows 32/64-bit Arduino IDE portable...$(tput setaf 2)"
sleep 2
unzip PF-build-env-Win-$BUILD_ENV.zip -d ../PF-build-env-$BUILD_ENV/$OSTYPE || exit 4
unzip arduino-$ARDUINO_ENV-windows.zip -d ../PF-build-env-$BUILD_ENV || exit 7
mv ../PF-build-env-$BUILD_ENV/arduino-$ARDUINO_ENV ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor
echo "# arduino-$ARDUINO_ENV-$TARGET_OS-$Processor" >> ../PF-build-env-$BUILD_ENV/arduino-$ARDUINO_ENV-$TARGET_OS-$Processor
echo "$(tput sgr0)"
fi
fi
# Linux
if [ $TARGET_OS == "linux" ]; then
# 32 or 64 bit version
if [ ! -f "arduino-$ARDUINO_ENV-linux$Processor.tar.xz" ]; then
echo "$(tput setaf 6)Downloading Linux $Processor Arduino IDE portable...$(tput setaf 2)"
sleep 2
wget --no-check-certificate https://downloads.arduino.cc/arduino-$ARDUINO_ENV-linux$Processor.tar.xz || exit 8
echo "$(tput sgr 0)"
fi
if [[ ! -d "../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor" && ! -e "../PF-build-env-$BUILD_ENV/arduino-$ARDUINO_ENV-$TARGET_OS-$Processor.txt" ]]; then
echo "$(tput setaf 6)Unzipping Linux $Processor Arduino IDE portable...$(tput setaf 2)"
sleep 2
tar -xvf arduino-$ARDUINO_ENV-linux$Processor.tar.xz -C ../PF-build-env-$BUILD_ENV/ || exit 8
mv ../PF-build-env-$BUILD_ENV/arduino-$ARDUINO_ENV ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor
echo "# arduino-$ARDUINO_ENV-$TARGET_OS-$Processor" >> ../PF-build-env-$BUILD_ENV/arduino-$ARDUINO_ENV-$TARGET_OS-$Processor.txt
echo "$(tput sgr0)"
fi
fi
# Make Arduino IDE portable
if [ ! -d ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/ ]; then
mkdir ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/
fi
if [ ! -d ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/ ]; then
mkdir ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable
fi
if [ ! -d ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/output/ ]; then
mkdir ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/output
fi
if [ ! -d ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/ ]; then
mkdir ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages
fi
if [ ! -d ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/sketchbook/ ]; then
mkdir ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/sketchbook
fi
if [ ! -d ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/sketchbook/libraries/ ]; then
mkdir ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/sketchbook/libraries
fi
if [ ! -d ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/staging/ ]; then
mkdir ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/staging
fi
# Change Arduino IDE preferences
if [ ! -e ../PF-build-env-$BUILD_ENV/Preferences-$TARGET_OS-$Processor.txt ]; then
echo "$(tput setaf 6)Setting $TARGET_OS-$Processor Arduino IDE preferences for portable GUI usage...$(tput setaf 2)"
sleep 2
echo "update.check"
sed -i 's/update.check = true/update.check = false/g' ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/lib/preferences.txt
echo "board"
sed -i 's/board = uno/board = rambo/g' ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/lib/preferences.txt
echo "editor.linenumbers"
sed -i 's/editor.linenumbers = false/editor.linenumbers = true/g' ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/lib/preferences.txt
echo "boardsmanager.additional.urls"
echo "boardsmanager.additional.urls=$BOARD_URL" >>../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/lib/preferences.txt
echo "build.verbose=true" >>../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/lib/preferences.txt
echo "compiler.cache_core=false" >>../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/lib/preferences.txt
echo "compiler.warning_level=all" >>../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/lib/preferences.txt
echo "# Preferences-$TARGET_OS-$Processor" >> ../PF-build-env-$BUILD_ENV/Preferences-$TARGET_OS-$Processor.txt
echo "$(tput sgr0)"
fi
# Download and extract Prusa Firmware related parts
# Download and extract PrusaResearchRambo board
if [ ! -f "$BOARD_FILENAME-$BOARD_VERSION.tar.bz2" ]; then
echo "$(tput setaf 6)Downloading Prusa Research AVR MK3 RAMBo EINSy build environment...$(tput setaf 2)"
sleep 2
wget $BOARD_FILE_URL || exit 9
fi
if [[ ! -d "../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD/hardware/avr/$BOARD_VERSION" || ! -e "../PF-build-env-$BUILD_ENV/$BOARD_FILENAME-$BOARD_VERSION-$TARGET_OS-$Processor.txt" ]]; then
echo "$(tput setaf 6)Unzipping $BOARD Arduino IDE portable...$(tput setaf 2)"
sleep 2
tar -xvf $BOARD_FILENAME-$BOARD_VERSION.tar.bz2 -C ../PF-build-env-$BUILD_ENV/ || exit 10
if [ ! -d ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD ]; then
mkdir ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD
fi
if [ ! -d ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD ]; then
mkdir ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD
fi
if [ ! -d ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD/hardware ]; then
mkdir ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD/hardware
fi
if [ ! -d ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD/hardware/avr ]; then
mkdir ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD/hardware/avr
fi
mv ../PF-build-env-$BUILD_ENV/$BOARD_FILENAME-$BOARD_VERSION ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/$BOARD/hardware/avr/$BOARD_VERSION
echo "# $BOARD_FILENAME-$BOARD_VERSION" >> ../PF-build-env-$BUILD_ENV/$BOARD_FILENAME-$BOARD_VERSION-$TARGET_OS-$Processor.txt
echo "$(tput sgr 0)"
fi
# Download and extract Prusa Firmware specific library files
if [ ! -f "PF-build-env-$BUILD_ENV.zip" ]; then
echo "$(tput setaf 6)Downloading Prusa Firmware build environment...$(tput setaf 2)"
sleep 2
wget $PF_BUILD_FILE_URL || exit 11
echo "$(tput sgr 0)"
fi
if [ ! -e "../PF-build-env-$BUILD_ENV/PF-build-env-$BUILD_ENV-$TARGET_OS-$Processor.txt" ]; then
echo "$(tput setaf 6)Unzipping Prusa Firmware build environment...$(tput setaf 2)"
sleep 2
unzip -o PF-build-env-$BUILD_ENV.zip -d ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor || exit 12
echo "# PF-build-env-$TARGET_OS-$Processor-$BUILD_ENV" >> ../PF-build-env-$BUILD_ENV/PF-build-env-$BUILD_ENV-$TARGET_OS-$Processor.txt
echo "$(tput sgr0)"
fi
if [ $OSTYPE == "linux-gnu" ]; then
if [ ! -f "PF-build-env-Linux64-$BUILD_ENV.zip" ]; then
echo "$(tput setaf 6)Downloading Linux 64 build environment...$(tput setaf 2)"
sleep 2
wget https://github.com/mkbel/PF-build-env/releases/download/$BUILD_ENV/PF-build-env-Linux64-$BUILD_ENV.zip || exit 3
echo "$(tput sgr0)"
fi
if [ ! -d "../PF-build-env-$BUILD_ENV/$OSTYPE" ]; then
echo "$(tput setaf 6)Unzipping Linux build enviroment...$(tput setaf 2)"
sleep 2
unzip PF-build-env-Linux64-$BUILD_ENV.zip -d ../PF-build-env-$BUILD_ENV/$OSTYPE || exit 4
echo "$(tput sgr0)"
fi
# Check if User updated Arduino IDE 1.8.5 boardsmanager and tools
if [ -d "../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/arduino/tools" ]; then
echo "$(tput setaf 6)Arduino IDE boards / tools have been manually updated...$"
echo "Please don't update the 'Arduino AVR boards' as this will prevent running this script (tput setaf 2)"
sleep 2
fi
if [ -d "../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2" ]; then
echo "$(tput setaf 6)PrusaReasearch compatible tools have been manually updated...$(tput setaf 2)"
sleep 2
echo "$(tput setaf 6)Copying Prusa Firmware build environment to manually updated boards / tools...$(tput setaf 2)"
sleep 2
cp -f ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/hardware/tools/avr/avr/lib/ldscripts/avr6.xn ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/arduino/tools/avr-gcc/4.9.2-atmel3.5.4-arduino2/avr/lib/ldscripts/avr6.xn
echo "# PF-build-env-portable-$TARGET_OS-$Processor-$BUILD_ENV" >> ../PF-build-env-$BUILD_ENV/PF-build-env-portable-$BUILD_ENV-$TARGET_OS-$Processor.txt
echo "$(tput sgr0)"
fi
if [ -d "../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor/portable/packages/arduino/tools/avr-gcc/5.4.0-atmel3.6.1-arduino2" ]; then
echo "$(tput setaf 1)Arduino IDE tools have been updated manually to a non supported version!!!"
echo "Delete ../PF-build-env-$BUILD_ENV and start the script again"
echo "Script will not continue until this have been fixed $(tput setaf 2)"
sleep 2
echo "$(tput sgr0)"
exit 13
fi
#### End prepare building
#### Start
cd $SCRIPT_PATH
# First argument defines which variant of the Prusa Firmware will be compiled
@ -201,7 +425,7 @@ if [ -z "$1" ] ; then
;;
"Quit")
echo "You chose to stop"
exit 1
exit
;;
*)
echo "$(tput setaf 1)This is not a valid variant$(tput sgr0)"
@ -215,7 +439,7 @@ else
echo "$(tput setaf 1)$1 could not be found in Firmware/variants please choose a valid one$(tput setaf 2)"
ls -1 $SCRIPT_PATH/Firmware/variants/*.h | xargs -n1 basename
echo "$(tput sgr0)"
exit
exit 21
fi
fi
@ -250,7 +474,7 @@ else
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!"
exit
exit 22
fi
fi
#Check if DEV_STATUS is selected via argument 3
@ -260,23 +484,23 @@ if [ ! -z "$3" ] ; then
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)"
exit
exit 23
fi
fi
#Set BUILD_ENV_PATH
cd ../PF-build-env-$BUILD_ENV/$OSTYPE || exit 5
cd ../PF-build-env-$BUILD_ENV/$TARGET_OS-$Processor || exit 24
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 6
mkdir Prusa-Firmware-build || exit 25
fi
#Set the BUILD_PATH for Arduino IDE
cd Prusa-Firmware-build || exit 7
cd Prusa-Firmware-build || exit 26
BUILD_PATH="$( pwd -P )"
for v in ${VARIANTS[*]}
@ -328,10 +552,10 @@ do
DEV_STATUS=$DEV_STATUS_SELECTED
fi
#Prepare hex files folders
if [ ! -d "$SCRIPT_PATH/../Hex-files/FW$FW-Build$BUILD/$MOTHERBOARD" ]; then
mkdir -p $SCRIPT_PATH/../Hex-files/FW$FW-Build$BUILD/$MOTHERBOARD || exit 10
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
fi
OUTPUT_FOLDER="Hex-files/FW$FW-Build$BUILD/$MOTHERBOARD"
OUTPUT_FOLDER="PF-build-hex/FW$FW-Build$BUILD/$MOTHERBOARD"
#Check if exactly the same hexfile already exists
if [[ -f "$SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT.hex" && "$LANGUAGES" == "ALL" ]]; then
@ -366,11 +590,11 @@ 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 11
cp -f $SCRIPT_PATH/Firmware/variants/$VARIANT.h $SCRIPT_PATH/Firmware/Configuration_prusa.h || exit 28
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 11
cp -f $SCRIPT_PATH/Firmware/variants/$VARIANT.h $SCRIPT_PATH/Firmware/Configuration_prusa.h || exit 28
fi
#Prepare Configuration.h to use the correct FW_DEV_VERSION to prevent LCD messages when connecting with OctoPrint
@ -391,22 +615,9 @@ do
fi
#Check if compiler flags are set to Prusa specific needs for the rambo board.
if [ $OSTYPE == "msys" ]; then
RAMBO_PLATFORM_FILE="rambo/hardware/avr/1.0.1/platform.txt"
COMP_FLAGS="compiler.c.elf.flags={compiler.warning_flags} -Os -g -flto -fuse-linker-plugin -Wl,-u,vfprintf -lprintf_flt -lm -Wl,--gc-sections"
CHECK_FLAGS=$(grep --max-count=1 "$COMP_FLAGS" $BUILD_ENV_PATH/portable/packages/$RAMBO_PLATFORM_FILE)
if [ -z "$CHECK_FLAGS" ]; then
echo "Compiler flags not found, adding flags"
if [ ! -f $BUILD_ENV_PATH/portable/packages/$RAMBO_PLATFORM_FILE.bck ]; then
echo "making a backup"
ls -1 $BUILD_ENV_PATH/portable/packages/rambo/hardware/avr/1.0.1/
cp -f $BUILD_ENV_PATH/portable/packages/$RAMBO_PLATFORM_FILE $BUILD_ENV_PATH/portable/packages/$RAMBO_PLATFORM_FILE.bck
fi
echo $COMP_FLAGS >> $BUILD_ENV_PATH/portable/packages/$RAMBO_PLATFORM_FILE
else
echo "Compiler flags are set in rambo platform.txt" $CHECK_FLAGS
fi
fi
# if [ $TARGET_OS == "windows" ]; then
# RAMBO_PLATFORM_FILE="PrusaResearchRambo/avr/platform.txt"
# fi
#### End of Prepare building
@ -414,37 +625,28 @@ do
export ARDUINO=$BUILD_ENV_PATH
#echo $BUILD_ENV_PATH
export BUILDER=$ARDUINO/arduino-builder
#export BUILDER=$ARDUINO/arduino-builder
echo
#read -t 5 -p "Press Enter..."
echo
if [ $OSTYPE == "msys" ]; then
echo "Start to build Prusa Firmware under Windows..."
echo "Using variant $VARIANT$(tput setaf 3)"
sleep 2
#$BUILDER -dump-prefs -logger=machine -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=rambo:avr:rambo -ide-version=10805 -build-path=$BUILD_PATH -warnings=none -quiet $SCRIPT_PATH/Firmware/Firmware.ino || exit 12
#$BUILDER -compile -logger=machine -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=rambo:avr:rambo -ide-version=10805 -build-path=$BUILD_PATH -warnings=none -quiet $SCRIPT_PATH/Firmware/Firmware.ino || exit 13
$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=rambo:avr:rambo -ide-version=10805 -build-path=$BUILD_PATH -warnings=default $SCRIPT_PATH/Firmware/Firmware.ino || exit 14
echo "$(tput sgr 0)"
fi
if [ $OSTYPE == "linux-gnu" ] ; then
echo "Start to build Prusa Firmware under Linux 64..."
echo "Using variant $VARIANT$(tput setaf 3)"
sleep 2
$BUILD_ENV_PATH/arduino $SCRIPT_PATH/Firmware/Firmware.ino --verify --board rambo:avr:rambo --pref build.path=$BUILD_PATH || exit 14
echo "$(tput sgr 0)"
fi
echo "Start to build Prusa Firmware ..."
echo "Using variant $VARIANT$(tput setaf 3)"
sleep 2
#$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:avr:rambo -ide-version=10805 -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:avr:rambo -ide-version=10805 -build-path=$BUILD_PATH -warnings=all $SCRIPT_PATH/Firmware/Firmware.ino || exit 14
echo "$(tput sgr 0)"
if [ $LANGUAGES == "ALL" ]; then
echo "$(tput setaf 2)"
echo "Building multi language firmware" $MULTI_LANGUAGE_CHECK
echo "$(tput sgr 0)"
sleep 2
cd $SCRIPT_PATH/lang
echo "$(tput setaf 3)"
./config.sh || exit 15
./config.sh || exit 31
echo "$(tput sgr 0)"
# Check if previous languages and firmware build exist and if so clean them up
if [ -f "lang_en.tmp" ]; then
@ -465,43 +667,43 @@ do
fi
# build languages
echo "$(tput setaf 3)"
./lang-build.sh || exit 16
./lang-build.sh || exit 32
# Combine compiled firmware with languages
./fw-build.sh || exit 17
./fw-build.sh || exit 33
echo "$(tput sgr 0)"
# 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)
# If the motherboard is an EINSY just copy one hexfile
if [ "$MOTHERBOARD" = "BOARD_EINSY_1_0a" ]; then
echo "$(tput setaf 2)Copying multi language firmware for MK3/Einsy board to Hex-files folder$(tput sgr 0)"
echo "$(tput setaf 2)Copying multi language firmware for MK3/Einsy board to PF-build-hex folder$(tput sgr 0)"
cp -f firmware.hex $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT.hex
else
echo "$(tput setaf 2)Zip multi language firmware for MK2.5/miniRAMbo board to Hex-files folder$(tput sgr 0)"
echo "$(tput setaf 2)Zip multi language firmware for MK2.5/miniRAMbo board to PF-build-hex folder$(tput sgr 0)"
cp -f firmware_cz.hex $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-cz.hex
cp -f firmware_de.hex $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-de.hex
cp -f firmware_es.hex $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-es.hex
cp -f firmware_fr.hex $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-fr.hex
cp -f firmware_it.hex $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-it.hex
cp -f firmware_pl.hex $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-pl.hex
if [ $OSTYPE == "msys" ]; then
if [ $TARGET_OS == "windows" ]; then
zip a $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT.zip $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-??.hex
rm $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-??.hex
elif [ $OSTYPE == "linux-gnu" ]; then
elif [ $TARGET_OS == "linux" ]; then
zip -m -j ../../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT.zip ../../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-??.hex
fi
fi
# Cleanup after build
echo "$(tput setaf 3)"
./fw-clean.sh || exit 18
./lang-clean.sh || exit 19
./fw-clean.sh || exit 34
./lang-clean.sh || exit 35
echo "$(tput sgr 0)"
else
echo "$(tput setaf 2)Copying English only firmware to Hex-files folder$(tput sgr 0)"
cp -f $BUILD_PATH/Firmware.ino.hex $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-EN_ONLY.hex || exit 20
echo "$(tput setaf 2)Copying English only firmware to PF-build-hex folder$(tput sgr 0)"
cp -f $BUILD_PATH/Firmware.ino.hex $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-EN_ONLY.hex || exit 34
fi
# Cleanup Firmware
rm $SCRIPT_PATH/Firmware/Configuration_prusa.h || exit 17
rm $SCRIPT_PATH/Firmware/Configuration_prusa.h || exit 36
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
echo $MULTI_LANGUAGE_CHECK
@ -511,14 +713,6 @@ do
sleep 5
done
# Cleanup compiler flags are set to Prusa specific needs for the rambo board.
#if [ $OSTYPE == "msys" ]; then
# echo " "
# echo "Restore Windows platform.txt"
# echo " "
# cp -f $BUILD_ENV_PATH/portable/packages/$RAMBO_PLATFORM_FILE.bck $BUILD_ENV_PATH/portable/packages/$RAMBO_PLATFORM_FILE
#fi
# Switch to hex path and list build files
cd $SCRIPT_PATH
cd ..

112
README.md
View file

@ -14,75 +14,73 @@
# Build
## Linux
Run shell script build.sh to build for MK3 and flash with Sli3er.
If you have different printel model, follow step [2.b](#2b) from Windows build first.
If you wish to flash from Arduino, follow step [2.c](#2c) from Windows build first.
The script downloads Arduino with our modifications and Rambo board support installed, unpacks it into folder PF-build-env-\<version\> on the same level, as your Prusa-Firmware folder is located, builds firmware for MK3 using that Arduino in Prusa-Firmware-build folder on the same level as Prusa-Firmware, runs secondary language support scripts. Firmware with secondary language support is generated in lang subfolder. Use firmware.hex for MK3 variant. Use firmware_\<lang\>.hex for other printers. Don't forget to follow step [2.b](#2b) first for non-MK3 printers.
1. Clone this repository and checkout the correct branch for your desired release version.
2. Set your printer model.
- For MK3 --> skip to step 3.
- If you have a different printer model, follow step [2.b](#2b) from Windows build
3. Run `sudo ./build.sh`
- Output hex file is at `"PrusaFirmware/lang/firmware.hex"` . In the same folder you can hex files for other languages as well.
4. Connect your printer and flash with PrusaSlicer ( Configuration --> Flash printer firmware ) or Slic3r PE.
- If you wish to flash from Arduino, follow step [2.c](#2c) from Windows build first.
_Notes:_
The script downloads Arduino with our modifications and Rambo board support installed, unpacks it into folder `PF-build-env-\<version\>` on the same level, as your Prusa-Firmware folder is located, builds firmware for MK3 using that Arduino in Prusa-Firmware-build folder on the same level as Prusa-Firmware, runs secondary language support scripts. Firmware with secondary language support is generated in lang subfolder. Use firmware.hex for MK3 variant. Use `firmware_\<lang\>.hex` for other printers. Don't forget to follow step [2.b](#2b) first for non-MK3 printers.
## Windows
### Using Arduino
note: Multi language build is not supported.
_Note: Multi language build is not supported._
#### 1. Development environment preparation
a. install `"Arduino Software IDE"` for your preferred operating system
`https://www.arduino.cc -> Software->Downloads`
it is recommended to use version `"1.8.5"`, as it is used on out build server to produce official builds.
_note: in the case of persistent compilation problems, check the version of the currently used C/C++ compiler (GCC) - should be `4.8.1`; version can be verified by entering the command
`avr-gcc --version`
if you are not sure where the file is placed (depends on how `"Arduino Software IDE"` was installed), you can use the search feature within the file system_
_note: name collision for `"LiquidCrystal"` library known from previous versions is now obsolete (so there is no need to delete or rename original file/-s)_
**a.** Install `"Arduino Software IDE"` from the official website `https://www.arduino.cc -> Software->Downloads`
_It is recommended to use version `"1.8.5"`, as it is used on out build server to produce official builds._
b. add (`UltiMachine`) `RAMBo` board into the list of Arduino target boards
`File->Preferences->Settings`
into text field `"Additional Boards Manager URLs"`
type location
`"https://raw.githubusercontent.com/ultimachine/ArduinoAddons/master/package_ultimachine_index.json"`
or you can 'manually' modify the item
`"boardsmanager.additional.urls=....."`
at the file `"preferences.txt"` (this parameter allows you to write a comma-separated list of addresses)
_note: you can find location of this file on your disk by following way:
`File->Preferences->Settings` (`"More preferences can be edited in file ..."`)_
than do it
`Tools->Board->BoardsManager`
from viewed list select an item `"RAMBo"` (will probably be labeled as `"RepRap Arduino-compatible Mother Board (RAMBo) by UltiMachine"`
_note: select this item for any variant of board used in printers `'Prusa i3 MKx'`, that is for `RAMBo-mini x.y` and `EINSy x.y` to_
'clicking' the item will display the installation button; select choice `"1.0.1"` from the list(last known version as of the date of issue of this document)
_(after installation, the item is labeled as `"INSTALLED"` and can then be used for target board selection)_
**b.** Setup Arduino to use Prusa Rambo board definition
c. modify platform.txt to enable float printf support:
add "-Wl,-u,vfprintf -lprintf_flt -lm" to "compiler.c.elf.flags=" before existing flag "-Wl,--gc-sections"
example:
`"compiler.c.elf.flags=-w -Os -Wl,-u,vfprintf -lprintf_flt -lm -Wl,--gc-sections"`
The 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.
* Open Arduino and navigate to File -> Preferences -> Settings
* To the text field `"Additional Boards Manager URLSs"` add `https://raw.githubusercontent.com/prusa3d/Arduino_Boards/master/IDE_Board_Manager/package_prusa3d_index.json`
* Open Board manager (`Tools->Board->Board manager`), and install `Prusa Research AVR MK3 RAMBo EINSy board`
**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.
* Add `"-Wl,-u,vfprintf -lprintf_flt -lm"` to `"compiler.c.elf.flags="` before existing flag "-Wl,--gc-sections"
For example: `"compiler.c.elf.flags=-w -Os -Wl,-u,vfprintf -lprintf_flt -lm -Wl,--gc-sections"`
_Notes:_
_In the case of persistent compilation problems, check the version of the currently used C/C++ compiler (GCC) - should be at leas `4.8.1`;
If you are not sure where the file is placed (depends on how `"Arduino Software IDE"` was installed), you can use the search feature within the file system_
_Name collision for `"LiquidCrystal"` library known from previous versions is now obsolete (so there is no need to delete or rename original file/-s)_
#### 2. Source code compilation
a. place the source codes corresponding to your printer model obtained from the repository into the selected directory on your disk
`https://github.com/prusa3d/Prusa-Firmware/`
**a.** Clone this repository`https://github.com/prusa3d/Prusa-Firmware/` to your local drive.
b.<a name="2b"></a> In the subdirectory `"Firmware/variants/"` select the configuration file (`.h`) corresponding to your printer model, make copy named `"Configuration_prusa.h"` (or make simple renaming) and copy it into `"Firmware/"` directory.
**b.**<a name="2b"></a> In the subdirectory `"Firmware/variants/"` select the configuration file (`.h`) corresponding to your printer model, make copy named `"Configuration_prusa.h"` (or make simple renaming) and copy it into `"Firmware/"` directory.
c.<a name="2c"></a> In file `"Firmware/config.h"` set LANG_MODE to 0.
**c.**<a name="2c"></a> In file `"Firmware/config.h"` set LANG_MODE to 0.
run `"Arduino IDE"`; select the file `"Firmware.ino"` from the subdirectory `"Firmware/"` at the location, where you placed the source codes
`File->Open`
make the desired code customizations; **all changes are on your own risk!**
**d.** Run `"Arduino IDE"`; select the file `"Firmware.ino"` from the subdirectory `"Firmware/"` at the location, where you placed the source code `File->Open` Make the desired code customizations; **all changes are on your own risk!**
select the target board `"RAMBo"`
`Tools->Board->RAMBo`
_note: it is not possible to use any of the variants `"Arduino Mega …"`, even though it is the same MCU_
**e.** Select the target board `"Tools->Board->PrusaResearch Einsy RAMBo"`
run the compilation
`Sketch->Verify/Compile`
**f.** Run the compilation `Sketch->Verify/Compile`
upload the result code into the connected printer
`Sketch->Upload`
**g.** Upload the result code into the connected printer `Sketch->Upload`
or you can also save the output code to the file (in so called `HEX`-format) `"Firmware.ino.rambo.hex"`:
`Sketch->ExportCompiledBinary`
and then upload it to the printer using the program `"FirmwareUpdater"`
* or you can also save the output code to the file (in so called `HEX`-format) `"Firmware.ino.rambo.hex"`: `Sketch->ExportCompiledBinary` and then upload it to the printer using the program `"FirmwareUpdater"`
_note: this file is created in the directory `"Firmware/"`_
### Using Linux subsystem under Windows 10 64-bit
@ -139,14 +137,12 @@ _notes: Script and instructions contributed by 3d-gussner. Use at your own risk.
# 3. Automated tests
## Prerequisites
c++11 compiler e.g. g++ 6.3.1
cmake
build system - ninja or gnu make
* c++11 compiler e.g. g++ 6.3.1
* cmake
* build system - ninja or gnu make
## Building
Create folder where you want to build tests.
Create a folder where you want to build tests.
Example:

View file

@ -0,0 +1,799 @@
/**
* @file
* @author Marek Kuhn
*/
// For now the functions are just COPIED (lots of depencendies in ultralcd.h)
#include "catch.hpp"
#include <iostream>
static bool VERBOSE_MODE = false; // If true - output additional info to std:cout
std::string itostr3(int i){
return std::to_string(i);
}
std::string eeprom_read_word(uint16_t* /*i*/){
return "eeprom_read";
}
int _millis(){return 10000;}
static int farm_no;
static int busy_state;
static int PAUSED_FOR_USER;
static int status_number;
static int total_filament_used;
static int feedmultiply;
static int longFilenameOLD;
static int starttime;
static int isPrintPaused;
static int IS_SD_PRINTING;
static int farm_status;
static int farm_timer;
static int loading_flag;
static int target_temperature[1];
static int current_temperature[1];
static int target_temperature_bed;
static int current_temperature_bed;
static uint16_t nozzle_diameter;
static uint16_t* EEPROM_NOZZLE_DIAMETER_uM;
static std::string FW_VERSION;
struct Card {
int paused = 0;
int percentDone(){ return 50; }
};
static Card card;
void setup_mockups(){
farm_no = 0;
busy_state = 0;
status_number = 0;
PAUSED_FOR_USER = 0;
total_filament_used = 0;
feedmultiply = 0;
longFilenameOLD = 0;
starttime = 0;
FW_VERSION = "3.8.0";
isPrintPaused = 0;
IS_SD_PRINTING = 0;
farm_status = 0;
farm_timer = 1;
loading_flag = 0;
target_temperature[0] = {215};
current_temperature[0] = {204};
target_temperature_bed = 60;
current_temperature_bed = 55;
nozzle_diameter = 400;
EEPROM_NOZZLE_DIAMETER_uM = &nozzle_diameter;
}
// Copy of pre 3.8 version set of functions
namespace old_code
{
// Mocking Serial line
static std::string SERIAL_BUFFER = "";
void SERIAL_ECHO(std::string s){
SERIAL_BUFFER += s;
}
void SERIAL_ECHO(int i){
SERIAL_BUFFER += std::to_string(i);
}
void SERIAL_ECHO(char c){
SERIAL_BUFFER += char(c);
}
void SERIAL_ECHOLN(std::string s){
SERIAL_BUFFER += s + "\n";
}
void SERIAL_ECHOLN(char c){
SERIAL_BUFFER += char(c);
}
void SERIAL_RESET(){
SERIAL_BUFFER.clear();
}
struct MySerial {
void print(int i){
SERIAL_ECHO(i);
}
void println(){
SERIAL_ECHO("\n");
}
};
static MySerial MYSERIAL;
static void prusa_stat_printerstatus(int _status)
{
SERIAL_ECHO("[PRN:");
SERIAL_ECHO(_status);
SERIAL_ECHO("]");
}
static void prusa_stat_farm_number() {
SERIAL_ECHO("[PFN:");
SERIAL_ECHO(farm_no);
SERIAL_ECHO("]");
}
static void prusa_stat_diameter() {
SERIAL_ECHO("[DIA:");
SERIAL_ECHO(eeprom_read_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM));
SERIAL_ECHO("]");
}
static void prusa_stat_temperatures()
{
SERIAL_ECHO("[ST0:");
SERIAL_ECHO(target_temperature[0]);
SERIAL_ECHO("][STB:");
SERIAL_ECHO(target_temperature_bed);
SERIAL_ECHO("][AT0:");
SERIAL_ECHO(current_temperature[0]);
SERIAL_ECHO("][ATB:");
SERIAL_ECHO(current_temperature_bed);
SERIAL_ECHO("]");
}
static void prusa_stat_printinfo()
{
SERIAL_ECHO("[TFU:");
SERIAL_ECHO(total_filament_used);
SERIAL_ECHO("][PCD:");
SERIAL_ECHO(itostr3(card.percentDone()));
SERIAL_ECHO("][FEM:");
SERIAL_ECHO(itostr3(feedmultiply));
SERIAL_ECHO("][FNM:");
SERIAL_ECHO(longFilenameOLD);
SERIAL_ECHO("][TIM:");
if (starttime != 0)
{
SERIAL_ECHO(_millis() / 1000 - starttime / 1000);
}
else
{
SERIAL_ECHO(0);
}
SERIAL_ECHO("][FWR:");
SERIAL_ECHO(FW_VERSION);
SERIAL_ECHO("]");
prusa_stat_diameter();
}
void prusa_statistics(int _message, uint8_t _fil_nr) {
#ifdef DEBUG_DISABLE_PRUSA_STATISTICS
return;
#endif //DEBUG_DISABLE_PRUSA_STATISTICS
switch (_message)
{
case 0: // default message
if (busy_state == PAUSED_FOR_USER)
{
SERIAL_ECHO("{");
prusa_stat_printerstatus(15);
prusa_stat_farm_number();
prusa_stat_printinfo();
SERIAL_ECHOLN("}");
status_number = 15;
}
else if (isPrintPaused || card.paused)
{
SERIAL_ECHO("{");
prusa_stat_printerstatus(14);
prusa_stat_farm_number();
prusa_stat_printinfo();
SERIAL_ECHOLN("}");
status_number = 14;
}
else if (IS_SD_PRINTING || loading_flag)
{
SERIAL_ECHO("{");
prusa_stat_printerstatus(4);
prusa_stat_farm_number();
prusa_stat_printinfo();
SERIAL_ECHOLN("}");
status_number = 4;
}
else
{
SERIAL_ECHO("{");
prusa_stat_printerstatus(1);
prusa_stat_farm_number();
prusa_stat_diameter();
SERIAL_ECHOLN("}");
status_number = 1;
}
break;
case 1: // 1 heating
farm_status = 2;
SERIAL_ECHO("{");
prusa_stat_printerstatus(2);
prusa_stat_farm_number();
SERIAL_ECHOLN("}");
status_number = 2;
farm_timer = 1;
break;
case 2: // heating done
farm_status = 3;
SERIAL_ECHO("{");
prusa_stat_printerstatus(3);
prusa_stat_farm_number();
SERIAL_ECHOLN("}");
status_number = 3;
farm_timer = 1;
if (IS_SD_PRINTING || loading_flag)
{
farm_status = 4;
SERIAL_ECHO("{");
prusa_stat_printerstatus(4);
prusa_stat_farm_number();
SERIAL_ECHOLN("}");
status_number = 4;
}
else
{
SERIAL_ECHO("{");
prusa_stat_printerstatus(3);
prusa_stat_farm_number();
SERIAL_ECHOLN("}");
status_number = 3;
}
farm_timer = 1;
break;
case 3: // filament change
break;
case 4: // print succesfull
SERIAL_ECHO("{[RES:1][FIL:");
MYSERIAL.print(int(_fil_nr));
SERIAL_ECHO("]");
prusa_stat_printerstatus(status_number);
prusa_stat_farm_number();
SERIAL_ECHOLN("}");
farm_timer = 2;
break;
case 5: // print not succesfull
SERIAL_ECHO("{[RES:0][FIL:");
MYSERIAL.print(int(_fil_nr));
SERIAL_ECHO("]");
prusa_stat_printerstatus(status_number);
prusa_stat_farm_number();
SERIAL_ECHOLN("}");
farm_timer = 2;
break;
case 6: // print done
SERIAL_ECHO("{[PRN:8]");
prusa_stat_farm_number();
SERIAL_ECHOLN("}");
status_number = 8;
farm_timer = 2;
break;
case 7: // print done - stopped
SERIAL_ECHO("{[PRN:9]");
prusa_stat_farm_number();
SERIAL_ECHOLN("}");
status_number = 9;
farm_timer = 2;
break;
case 8: // printer started
SERIAL_ECHO("{[PRN:0][PFN:");
status_number = 0;
SERIAL_ECHO(farm_no);
SERIAL_ECHOLN("]}");
farm_timer = 2;
break;
case 20: // echo farm no
SERIAL_ECHO("{");
prusa_stat_printerstatus(status_number);
prusa_stat_farm_number();
SERIAL_ECHOLN("}");
farm_timer = 4;
break;
case 21: // temperatures
SERIAL_ECHO("{");
prusa_stat_temperatures();
prusa_stat_farm_number();
prusa_stat_printerstatus(status_number);
SERIAL_ECHOLN("}");
break;
case 22: // waiting for filament change
SERIAL_ECHO("{[PRN:5]");
prusa_stat_farm_number();
SERIAL_ECHOLN("}");
status_number = 5;
break;
case 90: // Error - Thermal Runaway
SERIAL_ECHO("{[ERR:1]");
prusa_stat_farm_number();
SERIAL_ECHOLN("}");
break;
case 91: // Error - Thermal Runaway Preheat
SERIAL_ECHO("{[ERR:2]");
prusa_stat_farm_number();
SERIAL_ECHOLN("}");
break;
case 92: // Error - Min temp
SERIAL_ECHO("{[ERR:3]");
prusa_stat_farm_number();
SERIAL_ECHOLN("}");
break;
case 93: // Error - Max temp
SERIAL_ECHO("{[ERR:4]");
prusa_stat_farm_number();
SERIAL_ECHOLN("}");
break;
case 99: // heartbeat
SERIAL_ECHO("{[PRN:99]");
prusa_stat_temperatures();
SERIAL_ECHO("[PFN:");
SERIAL_ECHO(farm_no);
SERIAL_ECHO("]");
SERIAL_ECHOLN("}");
break;
}
}
}
// Copy of 3.8 version of functions
namespace new_code
{
// Mocking Serial line
static std::string SERIAL_BUFFER = "";
void SERIAL_ECHO(std::string s){
SERIAL_BUFFER += s;
}
void SERIAL_ECHO(int i){
SERIAL_BUFFER += std::to_string(i);
}
void SERIAL_ECHO(char c){
SERIAL_BUFFER += char(c);
}
void SERIAL_ECHOLN(std::string s){
SERIAL_BUFFER += s + "\n";
}
void SERIAL_ECHOLN(char c){
SERIAL_BUFFER += char(c);
SERIAL_BUFFER += "\n";
}
void SERIAL_RESET(){
SERIAL_BUFFER.clear();
}
struct MySerial {
void print(int i){
SERIAL_ECHO(i);
}
void println(){
SERIAL_ECHO("\n");
}
};
static MySerial MYSERIAL;
static void prusa_stat_printerstatus(int _status)
{
SERIAL_ECHO("[PRN:");
SERIAL_ECHO(_status);
SERIAL_ECHO(']');
}
static void prusa_stat_farm_number() {
SERIAL_ECHO("[PFN:");
SERIAL_ECHO(farm_no);
SERIAL_ECHO(']');
}
static void prusa_stat_diameter() {
SERIAL_ECHO("[DIA:");
SERIAL_ECHO(eeprom_read_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM));
SERIAL_ECHO(']');
}
static void prusa_stat_temperatures()
{
SERIAL_ECHO("[ST0:");
SERIAL_ECHO(target_temperature[0]);
SERIAL_ECHO("][STB:");
SERIAL_ECHO(target_temperature_bed);
SERIAL_ECHO("][AT0:");
SERIAL_ECHO(current_temperature[0]);
SERIAL_ECHO("][ATB:");
SERIAL_ECHO(current_temperature_bed);
SERIAL_ECHO(']');
}
static void prusa_stat_printinfo()
{
SERIAL_ECHO("[TFU:");
SERIAL_ECHO(total_filament_used);
SERIAL_ECHO("][PCD:");
SERIAL_ECHO(itostr3(card.percentDone()));
SERIAL_ECHO("][FEM:");
SERIAL_ECHO(itostr3(feedmultiply));
SERIAL_ECHO("][FNM:");
SERIAL_ECHO(longFilenameOLD);
SERIAL_ECHO("][TIM:");
if (starttime != 0)
{
SERIAL_ECHO(_millis() / 1000 - starttime / 1000);
}
else
{
SERIAL_ECHO(0);
}
SERIAL_ECHO("][FWR:");
SERIAL_ECHO(FW_VERSION);
SERIAL_ECHO(']');
prusa_stat_diameter();
}
void prusa_statistics_err(char c){
SERIAL_ECHO("{[ERR:");
SERIAL_ECHO(c);
SERIAL_ECHO(']');
prusa_stat_farm_number();
}
void prusa_statistics_case0(uint8_t statnr){
SERIAL_ECHO("{");
prusa_stat_printerstatus(statnr);
prusa_stat_farm_number();
prusa_stat_printinfo();
}
void prusa_statistics(int _message, uint8_t _fil_nr) {
#ifdef DEBUG_DISABLE_PRUSA_STATISTICS
return;
#endif //DEBUG_DISABLE_PRUSA_STATISTICS
switch (_message)
{
case 0: // default message
if (busy_state == PAUSED_FOR_USER)
{
prusa_statistics_case0(15);
}
else if (isPrintPaused || card.paused)
{
prusa_statistics_case0(14);
}
else if (IS_SD_PRINTING || loading_flag)
{
prusa_statistics_case0(4);
}
else
{
SERIAL_ECHO("{");
prusa_stat_printerstatus(1);
prusa_stat_farm_number();
prusa_stat_diameter();
status_number = 1;
}
break;
case 1: // 1 heating
farm_status = 2;
SERIAL_ECHO('{');
prusa_stat_printerstatus(2);
prusa_stat_farm_number();
status_number = 2;
farm_timer = 1;
break;
case 2: // heating done
farm_status = 3;
SERIAL_ECHO('{');
prusa_stat_printerstatus(3);
prusa_stat_farm_number();
SERIAL_ECHOLN('}');
status_number = 3;
farm_timer = 1;
if (IS_SD_PRINTING || loading_flag)
{
farm_status = 4;
SERIAL_ECHO('{');
prusa_stat_printerstatus(4);
prusa_stat_farm_number();
status_number = 4;
}
else
{
SERIAL_ECHO('{');
prusa_stat_printerstatus(3);
prusa_stat_farm_number();
status_number = 3;
}
farm_timer = 1;
break;
case 3: // filament change
// must do a return here to prevent doing SERIAL_ECHOLN("}") at the very end of this function
// saved a considerable amount of FLASH
return;
case 4: // print succesfull
SERIAL_ECHO("{[RES:1][FIL:");
MYSERIAL.print(int(_fil_nr));
SERIAL_ECHO(']');
prusa_stat_printerstatus(status_number);
prusa_stat_farm_number();
farm_timer = 2;
break;
case 5: // print not succesfull
SERIAL_ECHO("{[RES:0][FIL:");
MYSERIAL.print(int(_fil_nr));
SERIAL_ECHO(']');
prusa_stat_printerstatus(status_number);
prusa_stat_farm_number();
farm_timer = 2;
break;
case 6: // print done
SERIAL_ECHO("{[PRN:8]");
prusa_stat_farm_number();
status_number = 8;
farm_timer = 2;
break;
case 7: // print done - stopped
SERIAL_ECHO("{[PRN:9]");
prusa_stat_farm_number();
status_number = 9;
farm_timer = 2;
break;
case 8: // printer started
SERIAL_ECHO("{[PRN:0][PFN:");
status_number = 0;
SERIAL_ECHO(farm_no);
SERIAL_ECHO(']');
farm_timer = 2;
break;
case 20: // echo farm no
SERIAL_ECHO('{');
prusa_stat_printerstatus(status_number);
prusa_stat_farm_number();
farm_timer = 4;
break;
case 21: // temperatures
SERIAL_ECHO('{');
prusa_stat_temperatures();
prusa_stat_farm_number();
prusa_stat_printerstatus(status_number);
break;
case 22: // waiting for filament change
SERIAL_ECHO("{[PRN:5]");
prusa_stat_farm_number();
status_number = 5;
break;
case 90: // Error - Thermal Runaway
prusa_statistics_err('1');
break;
case 91: // Error - Thermal Runaway Preheat
prusa_statistics_err('2');
break;
case 92: // Error - Min temp
prusa_statistics_err('3');
break;
case 93: // Error - Max temp
prusa_statistics_err('4');
break;
case 99: // heartbeat
SERIAL_ECHO("{[PRN:99]");
prusa_stat_temperatures();
SERIAL_ECHO("[PFN:");
SERIAL_ECHO(farm_no);
SERIAL_ECHO(']');
break;
}
SERIAL_ECHOLN('}');
}
} // end namespace new
void SERIALS_RESET(){
old_code::SERIAL_RESET();
new_code::SERIAL_RESET();
}
std::string SERIALS_SERIALIZE(){
return old_code::SERIAL_BUFFER + "\n" + new_code::SERIAL_BUFFER;
}
void SERIALS_PRINT(){
std::cout << "[Printing buffers...] \n";
std::cout << old_code::SERIAL_BUFFER << "\n";
std::cout << new_code::SERIAL_BUFFER << "\n";
}
int SERIALS_COMPARE(){
// Trim the newline at the end
if(old_code::SERIAL_BUFFER.back() == '\n'){
old_code::SERIAL_BUFFER.pop_back();
}
if(new_code::SERIAL_BUFFER.back() == '\n'){
new_code::SERIAL_BUFFER.pop_back();
}
if(VERBOSE_MODE){
std::cout << "Comparing: \n";
std::cout << old_code::SERIAL_BUFFER << "\n";
std::cout << new_code::SERIAL_BUFFER << "\n";
}
return old_code::SERIAL_BUFFER.compare(new_code::SERIAL_BUFFER);
}
// --------------- TEST CASES ---------------- //
TEST_CASE("Serials compare ignore newline at the end", "[helper]")
{
SERIALS_RESET();
old_code::SERIAL_BUFFER = "Hello compare me.";
new_code::SERIAL_BUFFER = "Hello compare me.";
CHECK(SERIALS_COMPARE() == 0);
SERIALS_RESET();
old_code::SERIAL_BUFFER = "Hello compare me.\n";
new_code::SERIAL_BUFFER = "Hello compare me.";
CHECK(SERIALS_COMPARE() == 0);
SERIALS_RESET();
old_code::SERIAL_BUFFER = "Hello compare me.";
new_code::SERIAL_BUFFER = "Hello compare me.\n";
CHECK(SERIALS_COMPARE() == 0);
}
TEST_CASE("Printer status is shown", "[prusa_stats]")
{
SERIALS_RESET();
setup_mockups();
old_code::prusa_stat_printerstatus(1);
new_code::prusa_stat_printerstatus(1);
INFO(SERIALS_SERIALIZE());
CHECK(SERIALS_COMPARE() == 0);
}
TEST_CASE("Printer info is shown", "[prusa_stats]")
{
SERIALS_RESET();
setup_mockups();
old_code::prusa_stat_printinfo();
new_code::prusa_stat_printinfo();
INFO(SERIALS_SERIALIZE());
CHECK(SERIALS_COMPARE() == 0);
}
TEST_CASE("Printer temperatures are shown", "[prusa_stats]")
{
SERIALS_RESET();
setup_mockups();
old_code::prusa_stat_temperatures();
new_code::prusa_stat_temperatures();
INFO(SERIALS_SERIALIZE());
CHECK(SERIALS_COMPARE() == 0);
}
TEST_CASE("Prusa_statistics test", "[prusa_stats]")
{
SERIALS_RESET();
setup_mockups();
int test_codes[] = {0,1,2,3,4,5,6,7,8,20,21,22,90,91,92,93,99};
int size = sizeof(test_codes)/sizeof(test_codes[0]);
for(int i = 0; i < size; i++){
if(VERBOSE_MODE){
std::cout << "Testing prusa_statistics(" << std::to_string(i) << ")\n";
}
switch(i)
{
case 0: {
busy_state = 0;
PAUSED_FOR_USER = 0;
old_code::prusa_statistics(test_codes[i],0);
new_code::prusa_statistics(test_codes[i],0);
CHECK(SERIALS_COMPARE() == 0);
SERIALS_RESET();
busy_state = 1;
PAUSED_FOR_USER = 0;
isPrintPaused = 1;
old_code::prusa_statistics(test_codes[i],0);
new_code::prusa_statistics(test_codes[i],0);
CHECK(SERIALS_COMPARE() == 0);
SERIALS_RESET();
isPrintPaused = 0;
card.paused = 0;
IS_SD_PRINTING = 1;
old_code::prusa_statistics(test_codes[i],0);
new_code::prusa_statistics(test_codes[i],0);
CHECK(SERIALS_COMPARE() == 0);
SERIALS_RESET();
busy_state = 1;
PAUSED_FOR_USER = 0;
isPrintPaused = 0;
IS_SD_PRINTING = 0;
loading_flag = 0;
old_code::prusa_statistics(test_codes[i],0);
new_code::prusa_statistics(test_codes[i],0);
CHECK(SERIALS_COMPARE() == 0);
SERIALS_RESET();
break;
}
case 2: {
IS_SD_PRINTING = 1;
old_code::prusa_statistics(test_codes[i],0);
new_code::prusa_statistics(test_codes[i],0);
CHECK(SERIALS_COMPARE() == 0);
SERIALS_RESET();
IS_SD_PRINTING = 0;
loading_flag = 0;
old_code::prusa_statistics(test_codes[i],0);
new_code::prusa_statistics(test_codes[i],0);
CHECK(SERIALS_COMPARE() == 0);
SERIALS_RESET();
break;
}
default:{
old_code::prusa_statistics(test_codes[i],0);
new_code::prusa_statistics(test_codes[i],0);
CHECK(SERIALS_COMPARE() == 0);
SERIALS_RESET();
}
}
}
}

View file

@ -1,5 +1,5 @@
#!/bin/bash
BUILD_ENV="1.0.2"
BUILD_ENV="1.0.6"
SCRIPT_PATH="$( cd "$(dirname "$0")" ; pwd -P )"
if [ ! -d "build-env" ]; then
@ -31,7 +31,7 @@ if [ ! -f "$SCRIPT_PATH/Firmware/Configuration_prusa.h" ]; then
cp $SCRIPT_PATH/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h $SCRIPT_PATH/Firmware/Configuration_prusa.h || exit 8
fi
$BUILD_ENV_PATH/arduino $SCRIPT_PATH/Firmware/Firmware.ino --verify --board rambo:avr:rambo --pref build.path=$BUILD_PATH --pref compiler.warning_level=all || exit 9
$BUILD_ENV_PATH/arduino $SCRIPT_PATH/Firmware/Firmware.ino --verify --board PrusaResearchRambo:avr:rambo --pref build.path=$BUILD_PATH --pref compiler.warning_level=all || exit 9
export ARDUINO=$BUILD_ENV_PATH

View file

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# postbuild.sh - multi-language support script
# Generate binary with secondary language.

View file

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# fw-clean.sh - multi-language support script
# Remove all firmware output files from lang folder.

View file

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# lang-add.sh - multi-language support script
# add new texts from list (lang_add.txt) to all dictionary files

View file

@ -82,7 +82,7 @@ generate_binary()
rm -f lang_$1.dat
LNG=$1
#check lang dictionary
/usr/bin/env python lang-check.py $1
/usr/bin/env python lang-check.py $1 --no-warning
#create lang_xx.tmp - different processing for 'en' language
if [ "$1" = "en" ]; then
#remove comments and empty lines

View file

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# lang_check.sh - multi-language support script
# check lang_xx.bin (language binary file)

View file

@ -8,10 +8,10 @@
"[0;0] point offset"
#MSG_CRASH_DET_ONLY_IN_NORMAL c=20 r=4
"\x1b[2JCrash detection can\x1b[1;0Hbe turned on only in\x1b[2;0HNormal mode"
"Crash detection can\x0abe turned on only in\x0aNormal mode"
#MSG_CRASH_DET_STEALTH_FORCE_OFF c=20 r=4
"\x1b[2JWARNING:\x1b[1;0HCrash detection\x1b[2;0Hdisabled in\x1b[3;0HStealth mode"
"WARNING:\x0aCrash detection\x0adisabled in\x0aStealth mode"
#
">Cancel"

View file

@ -11,12 +11,12 @@
"[0;0] odsazeni bodu"
#MSG_CRASH_DET_ONLY_IN_NORMAL c=20 r=4
"\x1b[2JCrash detection can\x1b[1;0Hbe turned on only in\x1b[2;0HNormal mode"
"\x1b[2JCrash detekce muze\x1b[1;0Hbyt zapnuta pouze v\x1b[2;0HNormal modu"
"Crash detection can\x0abe turned on only in\x0aNormal mode"
"Crash detekce muze\x0abyt zapnuta pouze v\x0aNormal modu"
#MSG_CRASH_DET_STEALTH_FORCE_OFF c=20 r=4
"\x1b[2JWARNING:\x1b[1;0HCrash detection\x1b[2;0Hdisabled in\x1b[3;0HStealth mode"
"\x1b[2JPOZOR:\x1b[1;0HCrash detekce\x1b[2;0Hdeaktivovana ve\x1b[3;0HStealth modu"
"WARNING:\x0aCrash detection\x0adisabled in\x0aStealth mode"
"POZOR:\x0aCrash detekce\x0adeaktivovana ve\x0aStealth modu"
#
">Cancel"
@ -828,7 +828,7 @@
#
"Press the knob"
"Stisknete hl. tlacitko"
"Stisknete tlacitko"
#MSG_PRINT_PAUSED c=20 r=1
"Print paused"

View file

@ -11,12 +11,12 @@
"[0;0] Punktversatz"
#MSG_CRASH_DET_ONLY_IN_NORMAL c=20 r=4
"\x1b[2JCrash detection can\x1b[1;0Hbe turned on only in\x1b[2;0HNormal mode"
"\x1b[2JCrash Erkennung kann\x1b[1;0Hnur im Modus Normal\x1b[2;0Hgenutzt werden"
"Crash detection can\x0abe turned on only in\x0aNormal mode"
"Crash Erkennung kann\x0anur im Modus Normal\x0agenutzt werden"
#MSG_CRASH_DET_STEALTH_FORCE_OFF c=20 r=4
"\x1b[2JWARNING:\x1b[1;0HCrash detection\x1b[2;0Hdisabled in\x1b[3;0HStealth mode"
"\x1b[2JWARNUNG:\x1b[1;0HCrash Erkennung\x1b[2;0Hdeaktiviert im\x1b[3;0HStealth Modus"
"WARNING:\x0aCrash detection\x0adisabled in\x0aStealth mode"
"WARNUNG:\x0aCrash Erkennung\x0adeaktiviert im\x0aStealth Modus"
#
">Cancel"
@ -936,7 +936,7 @@
#MSG_SELFTEST_FAILED c=20
"Selftest failed "
"Selbsttest misslung "
"Selbsttest misslang "
#MSG_FORCE_SELFTEST c=20 r=8
"Selftest will be run to calibrate accurate sensorless rehoming."

View file

@ -11,12 +11,12 @@
"[0;0] punto offset"
#MSG_CRASH_DET_ONLY_IN_NORMAL c=20 r=4
"\x1b[2JCrash detection can\x1b[1;0Hbe turned on only in\x1b[2;0HNormal mode"
"\x1b[2JDec. choque\x1b[1;0Hpuede ser activada solo en\x1b[2;0HModo normal"
"Crash detection can\x0abe turned on only in\x0aNormal mode"
"Dec. choque puede\x0aser activada solo en\x0aModo normal"
#MSG_CRASH_DET_STEALTH_FORCE_OFF c=20 r=4
"\x1b[2JWARNING:\x1b[1;0HCrash detection\x1b[2;0Hdisabled in\x1b[3;0HStealth mode"
"\x1b[2JATENCION:\x1b[1;0HDec. choque\x1b[2;0Hdesactivada en\x1b[3;0HModo silencio"
"WARNING:\x0aCrash detection\x0adisabled in\x0aStealth mode"
"ATENCION:\x0aDec. choque\x0adesactivada en\x0aModo silencio"
#
">Cancel"

View file

@ -11,12 +11,12 @@
"Offset point [0;0]"
#MSG_CRASH_DET_ONLY_IN_NORMAL c=20 r=4
"\x1b[2JCrash detection can\x1b[1;0Hbe turned on only in\x1b[2;0HNormal mode"
"\x1b[2JLa detection de crash peut etre\x1b[1;0Hactive seulement\x1b[2;0Hen mode Normal"
"Crash detection can\x0abe turned on only in\x0aNormal mode"
"La detection de\x0acrash peut etre\x0aactive seulement en\x0amode Normal"
#MSG_CRASH_DET_STEALTH_FORCE_OFF c=20 r=4
"\x1b[2JWARNING:\x1b[1;0HCrash detection\x1b[2;0Hdisabled in\x1b[3;0HStealth mode"
"\x1b[2JATTENTION :\x1b[1;0HDetection de crash\x1b[2;0H desactivee en\x1b[3;0Hmode Furtif"
"WARNING:\x0aCrash detection\x0adisabled in\x0aStealth mode"
"ATTENTION:\x0aDetection de crash\x0adesactivee en\x0amode Furtif"
#
">Cancel"

View file

@ -11,12 +11,12 @@
"[0;0] punto offset"
#MSG_CRASH_DET_ONLY_IN_NORMAL c=20 r=4
"\x1b[2JCrash detection can\x1b[1;0Hbe turned on only in\x1b[2;0HNormal mode"
"\x1b[2JRilev. impatto\x1b[1;0Hattivabile solo\x1b[2;0Hin Modalita normale"
"Crash detection can\x0abe turned on only in\x0aNormal mode"
"Rilev. impatto\x0aattivabile solo\x0ain Modalita normale"
#MSG_CRASH_DET_STEALTH_FORCE_OFF c=20 r=4
"\x1b[2JWARNING:\x1b[1;0HCrash detection\x1b[2;0Hdisabled in\x1b[3;0HStealth mode"
"\x1b[2JATTENZIONE:\x1b[1;0HRilev. impatto\x1b[2;0Hdisattivato in\x1b[3;0HModalita silenziosa"
"WARNING:\x0aCrash detection disabled in Stealth mode"
"ATTENZIONE:\x0aRilev. impatto\x0adisattivato in\x0aModalita silenziosa"
#
">Cancel"

View file

@ -11,12 +11,12 @@
"[0;0] przesuniecie punktu"
#MSG_CRASH_DET_ONLY_IN_NORMAL c=20 r=4
"\x1b[2JCrash detection can\x1b[1;0Hbe turned on only in\x1b[2;0HNormal mode"
"\x1b[2JWykrywanie zderzen moze\x1b[1;0Hbyc wlaczone tylko w\x1b[2;0Htrybie Normalnym"
"Crash detection can\x0abe turned on only in\x0aNormal mode"
"Wykrywanie zderzen\x0amoze byc wlaczone\x0atylko w\x0atrybie Normalnym"
#MSG_CRASH_DET_STEALTH_FORCE_OFF c=20 r=4
"\x1b[2JWARNING:\x1b[1;0HCrash detection\x1b[2;0Hdisabled in\x1b[3;0HStealth mode"
"\x1b[2JUWAGA:\x1b[1;0HWykrywanie zderzen\x1b[2;0Hwylaczone w\x1b[3;0Htrybie Stealth"
"WARNING:\x0aCrash detection\x0adisabled in\x0aStealth mode"
"UWAGA:\x0aWykrywanie zderzen\x0awylaczone w\x0atrybie Stealth"
#
">Cancel"

View file

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# progmem.sh - multi-language support script
# Examine content of progmem sections (default is progmem1).
@ -104,6 +104,7 @@ cat $PROGMEM.chr | \
sed 's/\\x1b/\\\\\\x1b/g;' | \
sed 's/\\x01/\\\\\\x01/g;' | \
sed 's/\\xf8/\\\\\\xf8/g;' | \
sed 's/\\x0a/\\\\\\x0a/g;' | \
sed 's/\\x00$/\n/;s/^/\"/;s/$/\"\\/'; \
) | sh > $PROGMEM.var