diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 29bb82095..aef7efcf8 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -881,7 +881,9 @@ void process_commands() unsigned long codenum; //throw away variable char *starpos = NULL; - printing_state = PRINT_STATE_NORMAL; + if (printing_state != PRINT_STATE_RECOVER) + printing_state = PRINT_STATE_NORMAL; + if(code_seen('G')) { switch((int)code_value()) @@ -908,6 +910,9 @@ void process_commands() return; } case 4: // G4 dwell + if (printing_state == PRINT_STATE_RECOVER) + break; + LCD_MESSAGEPGM(MSG_DWELL); codenum = 0; if(code_seen('P')) codenum = code_value(); // milliseconds to wait @@ -964,6 +969,9 @@ void process_commands() break; #endif //FWRETRACT case 28: //G28 Home all Axis one at a time + if (printing_state == PRINT_STATE_RECOVER) + break; + printing_state = PRINT_STATE_HOMING; saved_feedrate = feedrate; saved_feedmultiply = feedmultiply; @@ -1156,6 +1164,9 @@ void process_commands() case 0: // M0 - Unconditional stop - Wait for user button press on LCD case 1: // M1 - Conditional stop - Wait for user button press on LCD { + if (printing_state == PRINT_STATE_RECOVER) + break; + printing_state = PRINT_STATE_WAIT_USER; LCD_MESSAGEPGM(MSG_USERWAIT); codenum = 0; @@ -1188,6 +1199,9 @@ void process_commands() case 0: // M0 - Unconditional stop - Wait for user button press on LCD case 1: // M1 - Conditional stop - Wait for user button press on LCD { + if (printing_state == PRINT_STATE_RECOVER) + break; + card.pause = true; while(card.pause) { @@ -1200,6 +1214,8 @@ void process_commands() break; #endif case 17: + if (printing_state == PRINT_STATE_RECOVER) + break; LCD_MESSAGEPGM(MSG_NO_MOVE); enable_x(); enable_y(); @@ -1211,39 +1227,54 @@ void process_commands() #ifdef SDSUPPORT case 20: // M20 - list SD card + if (printing_state == PRINT_STATE_RECOVER) + break; SERIAL_PROTOCOLLNPGM(MSG_BEGIN_FILE_LIST); card.ls(); SERIAL_PROTOCOLLNPGM(MSG_END_FILE_LIST); break; case 21: // M21 - init SD card + if (printing_state == PRINT_STATE_RECOVER) + break; card.initsd(); - break; case 22: //M22 - release SD card + if (printing_state == PRINT_STATE_RECOVER) + break; card.release(); break; case 23: //M23 - Select file + if (printing_state == PRINT_STATE_RECOVER) + break; starpos = (strchr(strchr_pointer + 4,'*')); if(starpos!=NULL) *(starpos-1)='\0'; card.openFile(strchr_pointer + 4,true); break; case 24: //M24 - Start SD print + if (printing_state == PRINT_STATE_RECOVER) + break; card.startFileprint(); starttime=millis(); break; case 25: //M25 - Pause SD print + if (printing_state == PRINT_STATE_RECOVER) + break; //card.pauseSDPrint(); card.closefile(); break; case 26: //M26 - Set SD index + if (printing_state == PRINT_STATE_RECOVER) + break; if(card.isOk() && code_seen('S')) { card.setIndex(code_value_long()); } break; case 27: //M27 - Get SD status + if (printing_state == PRINT_STATE_RECOVER) + break; card.getStatus(); break; case 28: //M28 - Start SD write @@ -1260,6 +1291,8 @@ void process_commands() //card,saving = false; break; case 30: //M30 Delete File + if (printing_state == PRINT_STATE_RECOVER) + break; if (card.isOk()){ card.closefile(); starpos = (strchr(strchr_pointer + 4,'*')); @@ -1272,6 +1305,8 @@ void process_commands() } break; case 923: //M923 - Select file and start printing + if (printing_state == PRINT_STATE_RECOVER) + break; starpos = (strchr(strchr_pointer + 4,'*')); if(starpos!=NULL) *(starpos-1)='\0'; @@ -1394,9 +1429,7 @@ void process_commands() } #endif if (printing_state == PRINT_STATE_RECOVER) - { break; - } printing_state = PRINT_STATE_HEATING; LCD_MESSAGEPGM(MSG_HEATING); @@ -1506,6 +1539,8 @@ void process_commands() // PWM for HEATER_1_PIN #if defined(HEATER_1_PIN) && HEATER_1_PIN > -1 case 126: //M126 valve open + if (printing_state == PRINT_STATE_RECOVER) + break; if (code_seen('S')){ ValvePressure=constrain(code_value(),0,255); } @@ -1514,6 +1549,8 @@ void process_commands() } break; case 127: //M127 valve closed + if (printing_state == PRINT_STATE_RECOVER) + break; ValvePressure = 0; break; #endif //HEATER_1_PIN @@ -1521,6 +1558,8 @@ void process_commands() // PWM for HEATER_2_PIN #if defined(HEATER_2_PIN) && HEATER_2_PIN > -1 case 128: //M128 valve open + if (printing_state == PRINT_STATE_RECOVER) + break; if (code_seen('S')){ EtoPPressure=constrain(code_value(),0,255); } @@ -1529,6 +1568,8 @@ void process_commands() } break; case 129: //M129 valve closed + if (printing_state == PRINT_STATE_RECOVER) + break; EtoPPressure = 0; break; #endif //HEATER_2_PIN @@ -1560,6 +1601,8 @@ void process_commands() break; case 18: //compatibility case 84: // M84 + if (printing_state == PRINT_STATE_RECOVER) + break; if(code_seen('S')){ stepper_inactive_time = code_value() * 1000; } @@ -1992,6 +2035,9 @@ void process_commands() #ifdef FILAMENTCHANGEENABLE case 600: //Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal] { + if (printing_state == PRINT_STATE_RECOVER) + break; + float target[4]; float lastpos[4]; target[X_AXIS]=current_position[X_AXIS]; @@ -2118,6 +2164,9 @@ void process_commands() #ifdef ENABLE_ULTILCD2 case 601: //M601 Pause in UltiLCD2, X[pos] Y[pos] Z[relative lift] L[later retract distance] { + if (printing_state == PRINT_STATE_RECOVER) + break; + st_synchronize(); float target[4]; float lastpos[4]; diff --git a/Marlin/UltiLCD2_menu_maintenance.cpp b/Marlin/UltiLCD2_menu_maintenance.cpp index d3e413b37..6fd5cd433 100644 --- a/Marlin/UltiLCD2_menu_maintenance.cpp +++ b/Marlin/UltiLCD2_menu_maintenance.cpp @@ -215,11 +215,15 @@ void lcd_menu_maintenance_advanced() set_extrude_min_temp(0); active_extruder = 0; enquecommand_P(PSTR("G92 E0")); - target_temperature[active_extruder] = material[active_extruder].temperature; if (ui_mode & UI_MODE_EXPERT) { + if (current_temperature[active_extruder] < (material[active_extruder].temperature / 2)) + { + target_temperature[active_extruder] = material[active_extruder].temperature; + } menu.add_menu(menu_t(lcd_menu_expert_extrude)); }else{ + target_temperature[active_extruder] = material[active_extruder].temperature; menu.add_menu(menu_t(lcd_menu_maintenance_extrude, MAIN_MENU_ITEM_POS(0))); } } diff --git a/Marlin/UltiLCD2_menu_material.cpp b/Marlin/UltiLCD2_menu_material.cpp index 77f9be540..8e915d630 100644 --- a/Marlin/UltiLCD2_menu_material.cpp +++ b/Marlin/UltiLCD2_menu_material.cpp @@ -860,6 +860,7 @@ bool lcd_material_verify_material_settings() return false; eeprom_read_block(LCD_CACHE_FILENAME(0), EEPROM_MATERIAL_NAME_OFFSET(cnt), 8); + LCD_CACHE_FILENAME(0)[8] = '\0'; if (strcmp_P(LCD_CACHE_FILENAME(0), PSTR("UPET")) == 0) hasUPET = true; } diff --git a/Marlin/UltiLCD2_menu_print.cpp b/Marlin/UltiLCD2_menu_print.cpp index d37fafe56..6a09d854b 100644 --- a/Marlin/UltiLCD2_menu_print.cpp +++ b/Marlin/UltiLCD2_menu_print.cpp @@ -19,11 +19,9 @@ uint8_t lcd_cache[LCD_CACHE_SIZE]; #define LCD_CACHE_NR_OF_FILES() lcd_cache[(LCD_CACHE_COUNT*(LONG_FILENAME_LENGTH+2))] #define LCD_CACHE_TYPE(n) lcd_cache[LCD_CACHE_COUNT + (n)] -#define LCD_DETAIL_CACHE_START ((LCD_CACHE_COUNT*(LONG_FILENAME_LENGTH+2))+1) #define LCD_DETAIL_CACHE_ID() lcd_cache[LCD_DETAIL_CACHE_START] #define LCD_DETAIL_CACHE_MATERIAL(n) (*(uint32_t*)&lcd_cache[LCD_DETAIL_CACHE_START+5+4*n]) -void doCooldown();//TODO static void lcd_menu_print_heatup(); static void lcd_menu_print_printing(); static void lcd_menu_print_error(); @@ -31,10 +29,9 @@ static void lcd_menu_print_classic_warning(); static void lcd_menu_print_ready_cooled_down(); static void lcd_menu_print_tune_retraction(); -bool primed = false; +static bool primed = false; static bool pauseRequested = false; - void lcd_clear_cache() { for(uint8_t n=0; n 0 && buffer[strlen(buffer)-1] < ' ') buffer[strlen(buffer)-1] = '\0'; if (strncmp_P(buffer, PSTR(";TIME:"), 6) == 0) - LCD_DETAIL_CACHE_TIME() = atol(buffer + 6); + LCD_DETAIL_CACHE_TIME() = strtol(buffer + 6, 0, 0); else if (strncmp_P(buffer, PSTR(";MATERIAL:"), 10) == 0) - LCD_DETAIL_CACHE_MATERIAL(0) = atol(buffer + 10); + LCD_DETAIL_CACHE_MATERIAL(0) = strtol(buffer + 10, 0, 0); #if EXTRUDERS > 1 else if (strncmp_P(buffer, PSTR(";MATERIAL2:"), 11) == 0) - LCD_DETAIL_CACHE_MATERIAL(1) = atol(buffer + 11); + LCD_DETAIL_CACHE_MATERIAL(1) = strtol(buffer + 11 ,0 ,0); #endif } } @@ -952,7 +954,8 @@ void lcd_print_pause() else enquecommand_P(PSTR("M601 X10 Y200 Z0 L20")); } - else{ + else if (!pauseRequested) + { lcd_lib_beep(); pauseRequested = true; } diff --git a/Marlin/UltiLCD2_menu_print.h b/Marlin/UltiLCD2_menu_print.h index 029a2a8ad..4d5b2ba76 100644 --- a/Marlin/UltiLCD2_menu_print.h +++ b/Marlin/UltiLCD2_menu_print.h @@ -33,6 +33,6 @@ void doStartPrint(); void lcd_change_to_menu_change_material_return(); void lcd_menu_print_pause(); -extern bool primed; +//extern bool primed; #endif//ULTI_LCD2_MENU_PRINT_H diff --git a/Marlin/tinkergnome.cpp b/Marlin/tinkergnome.cpp index 5283c4d7d..01e52543b 100644 --- a/Marlin/tinkergnome.cpp +++ b/Marlin/tinkergnome.cpp @@ -4,6 +4,7 @@ #include "Marlin.h" #include "cardreader.h" #include "temperature.h" +#include "lifetime_stats.h" #include "UltiLCD2_low_lib.h" #include "UltiLCD2_hi_lib.h" #include "UltiLCD2.h" @@ -41,13 +42,15 @@ float recover_height = 0.0f; // these are used to maintain a simple low-pass filter on the speeds - thanks norpchen static float e_smoothed_speed[EXTRUDERS] = ARRAY_BY_EXTRUDERS(0.0, 0.0, 0.0); -static float xy_speed = 0.0; static float target_position[NUM_AXIS]; static int8_t movingSpeed = 0; static bool delayMove = false; static uint8_t printing_page = 0; +static float old_max_feedrate_e; +static float old_retract_acceleration; + const uint8_t thermometerGfx[] PROGMEM = { 5, 8, //size 0x60, 0x9E, 0x81, 0x9E, 0x60 @@ -987,7 +990,10 @@ static void drawPrintSubmenu (uint8_t nr, uint8_t &flags) if (flags & (MENU_SELECTED | MENU_ACTIVE)) { strcpy_P(LCD_CACHE_FILENAME(1), PSTR("Speed ")); - int_to_string(xy_speed+0.5, LCD_CACHE_FILENAME(1)+strlen(LCD_CACHE_FILENAME(1)), PSTR("mm" PER_SECOND_SYMBOL)); + if (current_block!=NULL) + { + int_to_string(current_block->nominal_speed+0.5, LCD_CACHE_FILENAME(1)+strlen(LCD_CACHE_FILENAME(1)), PSTR("mm" PER_SECOND_SYMBOL)); + } lcd_lib_draw_string_left(5, LCD_CACHE_FILENAME(1)); flags |= MENU_STATUSLINE; } @@ -1163,22 +1169,20 @@ void lcd_menu_printing_tg() } else { - static block_t *lastBlock = 0; +// static block_t *lastBlock = 0; lcd_basic_screen(); lcd_lib_draw_hline(3, 124, 13); - if (current_block != lastBlock) - { - lastBlock = current_block; +// if (current_block != lastBlock) +// { +// lastBlock = current_block; // calculate speeds - thanks norpchen if (current_block!=NULL) { - if (current_block->steps_e > 0) + if ((current_block->steps_e > 0) && (current_block->steps_x || current_block->steps_y)) { - xy_speed = current_block->nominal_speed; - // float block_time = current_block->millimeters / current_block->nominal_speed; // float mm_e = current_block->steps_e / axis_steps_per_unit[E_AXIS]; @@ -1186,13 +1190,13 @@ void lcd_menu_printing_tg() float speed_e = current_block->steps_e * current_block->nominal_rate / axis_steps_per_unit[E_AXIS] / current_block->step_event_count; float volume = (volume_to_filament_length[current_block->active_extruder] < 0.99) ? speed_e / volume_to_filament_length[current_block->active_extruder] : speed_e*DEFAULT_FILAMENT_AREA; - if (speed_e>0 && speed_e<15.0) - { - e_smoothed_speed[current_block->active_extruder] = (e_smoothed_speed[current_block->active_extruder]*LOW_PASS_SMOOTHING) + ( volume *(1.0-LOW_PASS_SMOOTHING)); - } +// if (speed_e>0.1) +// { + e_smoothed_speed[current_block->active_extruder] = (e_smoothed_speed[current_block->active_extruder]*LOW_PASS_SMOOTHING) + ( volume *(1.0-LOW_PASS_SMOOTHING)); +// } } } - } +// } if (printing_page == 1) { @@ -2118,22 +2122,34 @@ static void lcd_extrude_move() } } +static void lcd_extrude_init_pull() +{ + //Set E motor power lower so the motor will skip instead of grind. + digipot_current(2, motor_current_setting[2]*2/3); + //increase max. feedrate and reduce acceleration + old_max_feedrate_e = max_feedrate[E_AXIS]; + old_retract_acceleration = retract_acceleration; + max_feedrate[E_AXIS] = FILAMENT_REVERSAL_SPEED; + retract_acceleration = FILAMENT_LONG_MOVE_ACCELERATION; +} + +static void lcd_extrude_quit_pull() +{ + // reset feeedrate and acceleration to default + max_feedrate[E_AXIS] = old_max_feedrate_e; + retract_acceleration = old_retract_acceleration; + //Set E motor power to default. + digipot_current(2, motor_current_setting[2]); +} + static void lcd_extrude_pull() { if (lcd_lib_button_down) { if (printing_state == PRINT_STATE_NORMAL && movesplanned() < 1) { - float old_max_feedrate_e = max_feedrate[E_AXIS]; - float old_retract_acceleration = retract_acceleration; - max_feedrate[E_AXIS] = FILAMENT_REVERSAL_SPEED; - retract_acceleration = FILAMENT_LONG_MOVE_ACCELERATION; - current_position[E_AXIS] -= FILAMENT_REVERSAL_LENGTH / volume_to_filament_length[active_extruder]; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], FILAMENT_REVERSAL_SPEED*2/3, active_extruder); - - max_feedrate[E_AXIS] = old_max_feedrate_e; - retract_acceleration = old_retract_acceleration; } } else { quickStop(); @@ -2154,7 +2170,7 @@ static const menu_t & get_extrude_menuoption(uint8_t nr, menu_t &opt) } else if (nr == menu_index++) { - opt.setData(MENU_INPLACE_EDIT, lcd_extrude_pull); + opt.setData(MENU_INPLACE_EDIT, lcd_extrude_init_pull, lcd_extrude_pull, lcd_extrude_quit_pull); } else if (nr == menu_index++) { @@ -2297,10 +2313,181 @@ void lcd_menu_expert_extrude() } +static void lcd_recover_start() +{ + +} + +static void lcd_recover_zvalue() +{ + lcd_tune_value(target_position[Z_AXIS], min_pos[Z_AXIS], max_pos[Z_AXIS], 0.01f); +} + +static const menu_t & get_recover_menuoption(uint8_t nr, menu_t &opt) +{ + menu_index = 0; + if (nr == menu_index++) + { + opt.setData(MENU_NORMAL, lcd_recover_start); + } + else if (nr == menu_index++) + { + opt.setData(MENU_NORMAL, lcd_change_to_previous_menu); + } + else if (nr == menu_index++) + { + opt.setData(MENU_INPLACE_EDIT, lcd_recover_zvalue, 4); + } + return opt; +} + +static void drawRecoverSubmenu (uint8_t nr, uint8_t &flags) +{ + uint8_t index(0); + if (nr == index++) + { + if (flags & MENU_SELECTED) + { + lcd_lib_draw_string_leftP(5, PSTR("Start print")); + flags |= MENU_STATUSLINE; + } + LCDMenu::drawMenuString_P(LCD_CHAR_MARGIN_LEFT+2*LCD_CHAR_SPACING + , BOTTOM_MENU_YPOS + , 8*LCD_CHAR_SPACING + , LCD_CHAR_HEIGHT + , PSTR("PRINT") + , ALIGN_CENTER + , flags); + } + else if (nr == index++) + { + if (flags & MENU_SELECTED) + { + lcd_lib_draw_string_leftP(5, PSTR("Click to return")); + flags |= MENU_STATUSLINE; + } + LCDMenu::drawMenuString_P(LCD_GFX_WIDTH/2+LCD_CHAR_MARGIN_LEFT+2*LCD_CHAR_SPACING + , BOTTOM_MENU_YPOS + , 8*LCD_CHAR_SPACING + , LCD_CHAR_HEIGHT + , PSTR("RETURN") + , ALIGN_CENTER + , flags); + } + else if (nr == index++) + { + // temp nozzle + if (flags & (MENU_SELECTED | MENU_ACTIVE)) + { + lcd_lib_draw_string_leftP(5, PSTR("Recover height")); + flags |= MENU_STATUSLINE; + } + + float_to_string(recover_height, LCD_CACHE_FILENAME(1), PSTR(DEGREE_SYMBOL)); + LCDMenu::drawMenuString(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-4*LCD_CHAR_SPACING + , 20 + , 24 + , LCD_CHAR_HEIGHT + , LCD_CACHE_FILENAME(1) + , ALIGN_RIGHT | ALIGN_VCENTER + , flags); + } + else if (nr == index++) + { + // move material + if (flags & (MENU_SELECTED | MENU_ACTIVE)) + { + lcd_lib_draw_string_leftP(5, PSTR("Click & hold to pull")); + flags |= MENU_STATUSLINE; + } + // lcd_lib_draw_string_rightP(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-12*LCD_CHAR_SPACING, 35, PSTR("Pos. E")); + // lcd_lib_draw_gfx(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-13*LCD_CHAR_SPACING-1, 35, flowGfx); + LCDMenu::drawMenuBox(LCD_CHAR_MARGIN_LEFT+2 + , 35 + , 3*LCD_CHAR_SPACING + , LCD_CHAR_HEIGHT + , flags); + if (flags & MENU_SELECTED) + { + lcd_lib_clear_gfx(LCD_CHAR_MARGIN_LEFT+LCD_CHAR_SPACING+2, 35, revSpeedGfx); + } + else + { + lcd_lib_draw_gfx(LCD_CHAR_MARGIN_LEFT+LCD_CHAR_SPACING+2, 35, revSpeedGfx); + } + } + else if (nr == index++) + { + // move material + if (flags & (MENU_SELECTED | MENU_ACTIVE)) + { + lcd_lib_draw_string_leftP(5, PSTR("Reset position")); + flags |= MENU_STATUSLINE; + } + // lcd_lib_draw_string_rightP(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-12*LCD_CHAR_SPACING, 35, PSTR("Pos. E")); + // lcd_lib_draw_gfx(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-13*LCD_CHAR_SPACING-1, 35, flowGfx); + LCDMenu::drawMenuBox(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-13*LCD_CHAR_SPACING-LCD_CHAR_MARGIN_LEFT + , 35 + , LCD_CHAR_SPACING+2*LCD_CHAR_MARGIN_LEFT + , LCD_CHAR_HEIGHT + , flags); + if (flags & MENU_SELECTED) + { + lcd_lib_clear_gfx(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-13*LCD_CHAR_SPACING-1, 35, flowGfx); + } + else + { + lcd_lib_draw_gfx(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-13*LCD_CHAR_SPACING-1, 35, flowGfx); + } + } + else if (nr == index++) + { + // move material + if (flags & MENU_ACTIVE) + { + lcd_lib_draw_string_leftP(5, PSTR("Rotate to extrude")); + flags |= MENU_STATUSLINE; + } + // lcd_lib_draw_gfx(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-13*LCD_CHAR_SPACING-1, 35, flowGfx); + float_to_string(st_get_position(E_AXIS) / axis_steps_per_unit[E_AXIS], LCD_CACHE_FILENAME(1), PSTR("mm")); + LCDMenu::drawMenuString(LCD_GFX_WIDTH-LCD_CHAR_MARGIN_RIGHT-11*LCD_CHAR_SPACING + , 35 + , 11*LCD_CHAR_SPACING + , LCD_CHAR_HEIGHT + , LCD_CACHE_FILENAME(1) + , ALIGN_RIGHT | ALIGN_VCENTER + , flags); + } +} + +void lcd_menu_expert_recover() +{ + lcd_basic_screen(); + lcd_lib_draw_hline(3, 124, 13); + + menu.process_submenu(get_recover_menuoption, 5); + + uint8_t flags = 0; + for (uint8_t index=0; index<5; ++index) + { + menu.drawSubMenu(drawRecoverSubmenu, index, flags); + } + if (!(flags & MENU_STATUSLINE)) + { + lcd_lib_draw_string_leftP(5, PSTR("Recover print")); + } + + lcd_lib_update_screen(); + +} + void recover_start_print() { // recover print from current position + // heatup nozzle + + while (printing_state == PRINT_STATE_RECOVER) { manage_heater(); diff --git a/MarlinSimulator/arduino_sim/WString.cpp b/MarlinSimulator/arduino_sim/WString.cpp index c6839fc0d..5741d0b1d 100644 --- a/MarlinSimulator/arduino_sim/WString.cpp +++ b/MarlinSimulator/arduino_sim/WString.cpp @@ -185,10 +185,10 @@ void String::move(String &rhs) String & String::operator = (const String &rhs) { if (this == &rhs) return *this; - + if (rhs.buffer) copy(rhs.buffer, rhs.len); else invalidate(); - + return *this; } @@ -210,7 +210,7 @@ String & String::operator = (const char *cstr) { if (cstr) copy(cstr, strlen(cstr)); else invalidate(); - + return *this; } @@ -398,7 +398,7 @@ unsigned char String::equalsIgnoreCase( const String &s2 ) const const char *p2 = s2.buffer; while (*p1) { if (tolower(*p1++) != tolower(*p2++)) return 0; - } + } return 1; } @@ -429,7 +429,7 @@ char String::charAt(unsigned int loc) const return operator[](loc); } -void String::setCharAt(unsigned int loc, char c) +void String::setCharAt(unsigned int loc, char c) { if (loc < len) buffer[loc] = c; } @@ -543,7 +543,7 @@ String String::substring(unsigned int left, unsigned int right) const if (left > len) return out; if (right > len) right = len; char temp = buffer[right]; // save the replaced character - buffer[right] = '\0'; + buffer[right] = '\0'; out = buffer + left; // pointer arithmetic buffer[right] = temp; //restore character return out; @@ -638,7 +638,7 @@ void String::trim(void) long String::toInt(void) const { - if (buffer) return atol(buffer); + if (buffer) return strtol(buffer, 0, 0); return 0; }