Commit e30b5fb7 authored by MagoKimbra's avatar MagoKimbra

Fix

parent cd948299
...@@ -933,20 +933,20 @@ void ConfigSD_ResetDefault() { ...@@ -933,20 +933,20 @@ void ConfigSD_ResetDefault() {
card.setroot(true); card.setroot(true);
card.startWrite((char *)CFG_SD_FILE, false); card.startWrite((char *)CFG_SD_FILE, false);
char buff[CFG_SD_MAX_VALUE_LEN]; char buff[CFG_SD_MAX_VALUE_LEN];
ltoa(print_job_counter.data.completePrints, buff, 10);
card.unparseKeyLine(cfgSD_KEY[SD_CFG_CPR], buff);
ltoa(print_job_counter.data.printer_usage_filament, buff, 10);
card.unparseKeyLine(cfgSD_KEY[SD_CFG_FIL], buff);
ltoa(print_job_counter.data.numberPrints, buff, 10);
card.unparseKeyLine(cfgSD_KEY[SD_CFG_NPR], buff);
#if HAS(POWER_CONSUMPTION_SENSOR) #if HAS(POWER_CONSUMPTION_SENSOR)
ltoa(power_consumption_hour, buff, 10); ltoa(power_consumption_hour, buff, 10);
card.unparseKeyLine(cfgSD_KEY[SD_CFG_PWR], buff); card.unparseKeyLine(cfgSD_KEY[SD_CFG_PWR], buff);
#endif #endif
ltoa(print_job_counter.data.numberPrints, buff, 10);
card.unparseKeyLine(cfgSD_KEY[SD_CFG_NPR], buff);
ltoa(print_job_counter.data.completePrints, buff, 10);
card.unparseKeyLine(cfgSD_KEY[SD_CFG_CPR], buff);
ltoa(print_job_counter.data.printTime, buff, 10);
card.unparseKeyLine(cfgSD_KEY[SD_CFG_TPR], buff);
ltoa(print_job_counter.data.printer_usage_seconds, buff, 10); ltoa(print_job_counter.data.printer_usage_seconds, buff, 10);
card.unparseKeyLine(cfgSD_KEY[SD_CFG_TME], buff); card.unparseKeyLine(cfgSD_KEY[SD_CFG_TME], buff);
ltoa(print_job_counter.data.printer_usage_filament, buff, 10); ltoa(print_job_counter.data.printTime, buff, 10);
card.unparseKeyLine(cfgSD_KEY[SD_CFG_FIL], buff); card.unparseKeyLine(cfgSD_KEY[SD_CFG_TPR], buff);
card.closeFile(); card.closeFile();
card.setlast(); card.setlast();
...@@ -966,44 +966,48 @@ void ConfigSD_ResetDefault() { ...@@ -966,44 +966,48 @@ void ConfigSD_ResetDefault() {
k_len = CFG_SD_MAX_KEY_LEN; k_len = CFG_SD_MAX_KEY_LEN;
v_len = CFG_SD_MAX_VALUE_LEN; v_len = CFG_SD_MAX_VALUE_LEN;
card.parseKeyLine(key, value, k_len, v_len); card.parseKeyLine(key, value, k_len, v_len);
if(k_len == 0 || v_len == 0) break; // no valid key or value founded if(k_len == 0 || v_len == 0) break; // no valid key or value founded
k_idx = ConfigSD_KeyIndex(key); k_idx = ConfigSD_KeyIndex(key);
if(k_idx == -1) continue; // unknow key ignore it if(k_idx == -1) continue; // unknow key ignore it
switch(k_idx) { switch(k_idx) {
#if HAS(POWER_CONSUMPTION_SENSOR) case SD_CFG_CPR: {
case SD_CFG_PWR: { if(addValue) print_job_counter.data.completePrints += (unsigned long)atol(value);
if(addValue) power_consumption_hour += (unsigned long)atol(value); else print_job_counter.data.completePrints = (unsigned long)atol(value);
else power_consumption_hour = (unsigned long)atol(value); }
break;
case SD_CFG_FIL: {
if(addValue) print_job_counter.data.printer_usage_filament += (unsigned long)atol(value);
else print_job_counter.data.printer_usage_filament = (unsigned long)atol(value);
} }
break; break;
#endif
case SD_CFG_NPR: { case SD_CFG_NPR: {
if(addValue) print_job_counter.data.numberPrints += (unsigned long)atol(value); if(addValue) print_job_counter.data.numberPrints += (unsigned long)atol(value);
else print_job_counter.data.numberPrints = (unsigned long)atol(value); else print_job_counter.data.numberPrints = (unsigned long)atol(value);
} }
break; break;
case SD_CFG_CPR: { #if HAS(POWER_CONSUMPTION_SENSOR)
if(addValue) print_job_counter.data.completePrints += (unsigned long)atol(value); case SD_CFG_PWR: {
else print_job_counter.data.completePrints = (unsigned long)atol(value); if(addValue) power_consumption_hour += (unsigned long)atol(value);
} else power_consumption_hour = (unsigned long)atol(value);
break;
case SD_CFG_TPR: {
if(addValue) print_job_counter.data.printTime += (unsigned long)atol(value);
else print_job_counter.data.printTime = (unsigned long)atol(value);
} }
break; break;
#endif
case SD_CFG_TME: { case SD_CFG_TME: {
if(addValue) print_job_counter.data.printer_usage_seconds += (unsigned long)atol(value); if(addValue) print_job_counter.data.printer_usage_seconds += (unsigned long)atol(value);
else print_job_counter.data.printer_usage_seconds = (unsigned long)atol(value); else print_job_counter.data.printer_usage_seconds = (unsigned long)atol(value);
} }
break; break;
case SD_CFG_FIL: { case SD_CFG_TPR: {
if(addValue) print_job_counter.data.printer_usage_filament += (unsigned long)atol(value); if(addValue) print_job_counter.data.printTime += (unsigned long)atol(value);
else print_job_counter.data.printer_usage_filament = (unsigned long)atol(value); else print_job_counter.data.printTime = (unsigned long)atol(value);
} }
break; break;
} }
} }
card.closeFile(); card.closeFile();
card.setlast(); card.setlast();
config_readed = true; config_readed = true;
...@@ -1012,6 +1016,7 @@ void ConfigSD_ResetDefault() { ...@@ -1012,6 +1016,7 @@ void ConfigSD_ResetDefault() {
int ConfigSD_KeyIndex(char *key) { // At the moment a binary search algorithm is used for simplicity, if it will be necessary (Eg. tons of key), an hash search algorithm will be implemented. int ConfigSD_KeyIndex(char *key) { // At the moment a binary search algorithm is used for simplicity, if it will be necessary (Eg. tons of key), an hash search algorithm will be implemented.
int begin = 0, end = SD_CFG_END - 1, middle, cond; int begin = 0, end = SD_CFG_END - 1, middle, cond;
while(begin <= end) { while(begin <= end) {
middle = (begin + end) / 2; middle = (begin + end) / 2;
cond = strcmp(cfgSD_KEY[middle], key); cond = strcmp(cfgSD_KEY[middle], key);
...@@ -1019,6 +1024,7 @@ void ConfigSD_ResetDefault() { ...@@ -1019,6 +1024,7 @@ void ConfigSD_ResetDefault() {
else if(cond < 0) begin = middle + 1; else if(cond < 0) begin = middle + 1;
else end = middle - 1; else end = middle - 1;
} }
return -1; return -1;
} }
......
...@@ -1907,6 +1907,7 @@ inline void do_blocking_move_to_z(float z) { do_blocking_move_to(current_positio ...@@ -1907,6 +1907,7 @@ inline void do_blocking_move_to_z(float z) { do_blocking_move_to(current_positio
for (int y = 0; y < AUTO_BED_LEVELING_GRID_POINTS; y++) { for (int y = 0; y < AUTO_BED_LEVELING_GRID_POINTS; y++) {
ECHO_S(DB); ECHO_S(DB);
for (int x = 0; x < AUTO_BED_LEVELING_GRID_POINTS; x++) { for (int x = 0; x < AUTO_BED_LEVELING_GRID_POINTS; x++) {
if(bed_level[x][y] >= 0) ECHO_M(" ");
ECHO_VM(bed_level[x][y], " ", 3); ECHO_VM(bed_level[x][y], " ", 3);
} }
ECHO_E; ECHO_E;
...@@ -3118,10 +3119,10 @@ void gcode_get_destination() { ...@@ -3118,10 +3119,10 @@ void gcode_get_destination() {
if (next_feedrate > 0.0) feedrate = next_feedrate; if (next_feedrate > 0.0) feedrate = next_feedrate;
} }
if (code_seen('P')) { if (code_seen('P'))
destination[E_AXIS] = (code_value() * density_multiplier[previous_extruder] / 100) + current_position[E_AXIS]; destination[E_AXIS] = (code_value() * density_multiplier[previous_extruder] / 100) + current_position[E_AXIS];
}
if(!DEBUGGING(DRYRUN))
print_job_counter.data.printer_usage_filament += (destination[E_AXIS] - current_position[E_AXIS]); print_job_counter.data.printer_usage_filament += (destination[E_AXIS] - current_position[E_AXIS]);
#if ENABLED(RFID_MODULE) #if ENABLED(RFID_MODULE)
...@@ -5423,7 +5424,7 @@ inline void gcode_M104() { ...@@ -5423,7 +5424,7 @@ inline void gcode_M104() {
* stand by mode, for instance in a dual extruder setup, without affecting * stand by mode, for instance in a dual extruder setup, without affecting
* the running print timer. * the running print timer.
*/ */
if (temp <= (EXTRUDE_MINTEMP)/2) { if (temp <= (EXTRUDE_MINTEMP) / 2) {
print_job_counter.stop(); print_job_counter.stop();
LCD_MESSAGEPGM(WELCOME_MSG); LCD_MESSAGEPGM(WELCOME_MSG);
} }
......
...@@ -50,7 +50,7 @@ extern volatile uint8_t buttons; //an extended version of the last checked butt ...@@ -50,7 +50,7 @@ extern volatile uint8_t buttons; //an extended version of the last checked butt
#define EN_C (_BV(BLEN_C)) #define EN_C (_BV(BLEN_C))
#endif #endif
#if BUTTON_EXISTS(BTN_BACK) #if BUTTON_EXISTS(BACK)
#define BLEN_D 3 #define BLEN_D 3
#define EN_D (_BV(BLEN_D)) #define EN_D (_BV(BLEN_D))
#endif #endif
......
...@@ -55,7 +55,7 @@ void PrintCounter::showStats() { ...@@ -55,7 +55,7 @@ void PrintCounter::showStats() {
ECHO_EV (this->data.numberPrints - this->data.completePrints - ECHO_EV (this->data.numberPrints - this->data.completePrints -
((this->isRunning() || this->isPaused()) ? 1 : 0)); // Removes 1 from failures with an active counter ((this->isRunning() || this->isPaused()) ? 1 : 0)); // Removes 1 from failures with an active counter
day = (this->data.printTime / 60 / 60 / 24); day = this->data.printTime / 60 / 60 / 24;
hours = (this->data.printTime / 60 / 60) % 24; hours = (this->data.printTime / 60 / 60) % 24;
minutes = (this->data.printTime / 60) % 60; minutes = (this->data.printTime / 60) % 60;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment