diff --git a/Marlin/Makefile b/Marlin/Makefile index 1315a9d43..626e387c6 100644 --- a/Marlin/Makefile +++ b/Marlin/Makefile @@ -229,6 +229,22 @@ OPT = s DEFINES ?= +# Program settings +CC = $(AVR_TOOLS_PATH)avr-gcc +CXX = $(AVR_TOOLS_PATH)avr-g++ +OBJCOPY = $(AVR_TOOLS_PATH)avr-objcopy +OBJDUMP = $(AVR_TOOLS_PATH)avr-objdump +AR = $(AVR_TOOLS_PATH)avr-ar +SIZE = $(AVR_TOOLS_PATH)avr-size +NM = $(AVR_TOOLS_PATH)avr-nm +AVRDUDE = avrdude +REMOVE = rm -f +MV = mv -f + +# Tool for testing compiler flags +cc-option=$(shell if test -z "`$(1) $(2) -S -o /dev/null -xc /dev/null 2>&1`" \ + ; then echo "$(2)"; else echo "$(3)"; fi ;) + # Place -D or -U options here CDEFS = -DF_CPU=$(F_CPU) ${addprefix -D , $(DEFINES)} CXXDEFS = $(CDEFS) @@ -259,10 +275,12 @@ CTUNING += -DMOTHERBOARD=${HARDWARE_MOTHERBOARD} endif #CEXTRA = -Wa,-adhlns=$(<:.c=.lst) -CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CEXTRA) $(CTUNING) -CXXFLAGS = $(CDEFS) $(CINCS) -O$(OPT) -Wall $(CEXTRA) $(CTUNING) +CFLAGS := $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CEXTRA) $(CTUNING) \ + $(call cc-option,$(CC),-flto -fwhole-program,) +CXXFLAGS := $(CDEFS) $(CINCS) -O$(OPT) -Wall $(CEXTRA) $(CTUNING) \ + $(call cc-option,$(CC),-flto -fwhole-program,) #ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs -LDFLAGS = -lm +LDFLAGS = -lm -Wl,--relax # Programming support using avrdude. Settings and variables. @@ -272,18 +290,6 @@ AVRDUDE_FLAGS = -D -C $(ARDUINO_INSTALL_DIR)/hardware/tools/avrdude.conf \ -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \ -b $(UPLOAD_RATE) -# Program settings -CC = $(AVR_TOOLS_PATH)avr-gcc -CXX = $(AVR_TOOLS_PATH)avr-g++ -OBJCOPY = $(AVR_TOOLS_PATH)avr-objcopy -OBJDUMP = $(AVR_TOOLS_PATH)avr-objdump -AR = $(AVR_TOOLS_PATH)avr-ar -SIZE = $(AVR_TOOLS_PATH)avr-size -NM = $(AVR_TOOLS_PATH)avr-nm -AVRDUDE = avrdude -REMOVE = rm -f -MV = mv -f - # Define all object files. OBJ = ${patsubst %.c, $(BUILD_DIR)/%.o, ${SRC}} OBJ += ${patsubst %.cpp, $(BUILD_DIR)/%.o, ${CXXSRC}} @@ -380,9 +386,13 @@ extcoff: $(TARGET).elf $(NM) -n $< > $@ # Link: create ELF output file from library. -$(BUILD_DIR)/$(TARGET).elf: $(OBJ) Configuration.h +$(BUILD_DIR)/$(TARGET).elf: $(BUILD_DIR)/$(TARGET).o + $(Pecho) " CXX $@" + $P $(CC) $(ALL_CXXFLAGS) -Wl,--gc-sections -o $@ -L. $^ $(LDFLAGS) + +$(BUILD_DIR)/$(TARGET).o: $(OBJ) Configuration.h $(Pecho) " CXX $@" - $P $(CC) $(ALL_CXXFLAGS) -Wl,--gc-sections -o $@ -L. $(OBJ) $(LDFLAGS) + $P $(CC) $(ALL_CXXFLAGS) -nostdlib -Wl,-r -o $@ $(OBJ) $(BUILD_DIR)/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE) $(Pecho) " CC $<" diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index 5a0762d9f..618767216 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -432,9 +432,9 @@ void manage_heater() soft_pwm_bed = 0; } - #elif not defined BED_LIMIT_SWITCHING + #elif !defined(BED_LIMIT_SWITCHING) // Check if temperature is within the correct range - if((current_temperature_bed > BED_MAXTEMP) && (current_temperature_bed < BED_MINTEMP)) + if((current_temperature_bed > BED_MINTEMP) && (current_temperature_bed < BED_MAXTEMP)) { if(current_temperature_bed >= target_temperature_bed) { @@ -1042,6 +1042,7 @@ ISR(TIMER0_COMPB_vect) #if EXTRUDERS > 2 current_temperature_raw[2] = raw_temp_2_value; #endif + current_temperature_bed_raw = raw_temp_bed_value; } temp_meas_ready = true; @@ -1101,9 +1102,9 @@ ISR(TIMER0_COMPB_vect) /* No bed MINTEMP error? */ #if defined(BED_MAXTEMP) && (TEMP_SENSOR_BED != 0) # if HEATER_BED_RAW_LO_TEMP > HEATER_BED_RAW_HI_TEMP - if(current_temperature_bed <= bed_maxttemp_raw) { + if(current_temperature_bed_raw <= bed_maxttemp_raw) { #else - if(current_temperature_bed >= bed_maxttemp_raw) { + if(current_temperature_bed_raw >= bed_maxttemp_raw) { #endif target_temperature_bed = 0; bed_max_temp_error(); diff --git a/Marlin/thermistortables.h b/Marlin/thermistortables.h index d963afff1..cdf591b2c 100644 --- a/Marlin/thermistortables.h +++ b/Marlin/thermistortables.h @@ -474,7 +474,7 @@ const short temptable_55[][2] PROGMEM = { //Set the high and low raw values for the heater, this indicates which raw value is a high or low temperature #ifndef HEATER_0_RAW_HI_TEMP -# if HEATER_0_USES_THERMISTOR //In case of a thermistor the highest temperature results in the lowest ADC value +# ifdef HEATER_0_USES_THERMISTOR //In case of a thermistor the highest temperature results in the lowest ADC value # define HEATER_0_RAW_HI_TEMP 0 # define HEATER_0_RAW_LO_TEMP 16383 # else //In case of an thermocouple the highest temperature results in the highest ADC value @@ -497,7 +497,7 @@ const short temptable_55[][2] PROGMEM = { //Set the high and low raw values for the heater, this indicates which raw value is a high or low temperature #ifndef HEATER_1_RAW_HI_TEMP -# if HEATER_1_USES_THERMISTOR //In case of a thermistor the highest temperature results in the lowest ADC value +# ifdef HEATER_1_USES_THERMISTOR //In case of a thermistor the highest temperature results in the lowest ADC value # define HEATER_1_RAW_HI_TEMP 0 # define HEATER_1_RAW_LO_TEMP 16383 # else //In case of an thermocouple the highest temperature results in the highest ADC value @@ -520,7 +520,7 @@ const short temptable_55[][2] PROGMEM = { //Set the high and low raw values for the heater, this indicates which raw value is a high or low temperature #ifndef HEATER_2_RAW_HI_TEMP -# if HEATER_2_USES_THERMISTOR //In case of a thermistor the highest temperature results in the lowest ADC value +# ifdef HEATER_2_USES_THERMISTOR //In case of a thermistor the highest temperature results in the lowest ADC value # define HEATER_2_RAW_HI_TEMP 0 # define HEATER_2_RAW_LO_TEMP 16383 # else //In case of an thermocouple the highest temperature results in the highest ADC value @@ -540,7 +540,7 @@ const short temptable_55[][2] PROGMEM = { //Set the high and low raw values for the heater, this indicates which raw value is a high or low temperature #ifndef HEATER_BED_RAW_HI_TEMP -# if BED_USES_THERMISTOR //In case of a thermistor the highest temperature results in the lowest ADC value +# ifdef BED_USES_THERMISTOR //In case of a thermistor the highest temperature results in the lowest ADC value # define HEATER_BED_RAW_HI_TEMP 0 # define HEATER_BED_RAW_LO_TEMP 16383 # else //In case of an thermocouple the highest temperature results in the highest ADC value diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 49cbe996d..beb79beee 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -476,7 +476,7 @@ static void lcd_control_temperature_preheat_pla_settings_menu() #if TEMP_SENSOR_BED != 0 MENU_ITEM_EDIT(int3, MSG_BED, &plaPreheatHPBTemp, 0, BED_MAXTEMP - 15); #endif -#if EEPROM_SETTINGS +#ifdef EEPROM_SETTINGS MENU_ITEM(function, MSG_STORE_EPROM, Config_StoreSettings); #endif END_MENU(); @@ -491,7 +491,7 @@ static void lcd_control_temperature_preheat_abs_settings_menu() #if TEMP_SENSOR_BED != 0 MENU_ITEM_EDIT(int3, MSG_BED, &absPreheatHPBTemp, 0, BED_MAXTEMP - 15); #endif -#if EEPROM_SETTINGS +#ifdef EEPROM_SETTINGS MENU_ITEM(function, MSG_STORE_EPROM, Config_StoreSettings); #endif END_MENU();