First, please respond to the questions I ask in the comments on your question.
You mention that the device to be controlled is a motor. Bear in mind that rotating power is $P = \tau \omega$, or torque times speed, so you won't get the same response at high speed that you get at low speed because motor torque typically declines with increasing speed.
I'm not sure if this is the cause of your differing responses or not, but I believe it would have a large impact unless you're just using "1.0" and "2.0" as placeholders for some other value, or they are literally 1 and 2 and are very close together percentage-wise in terms of the entire speed band of the motor.
Regarding wind-up, mentioned in 50k4's answer, I wouldn't think it would be an issue unless your process is saturating, which is to say that it shouldn't be an issue unless your motor is hitting some physical limits that would prevent it from responding, like a current limit or something similar. Note however that if you are getting to the point where your response is saturating that you are also likely operating at a point where motor power is limited and thus you are unlikely to get the same response curves no matter what actions you take to tune a standard PID controller.
Ultimately, if I were you, I would evaluate the errors and determine if there is a problem with your error accounting or if you are realizing the physical limitations of a motor. Keep in mind that the entire point of the integral term is to accumulate error - this will speed control response if it is "taking too long". Accumulated error before settling is both normal and desirable as long as the controller output is still able to effect change in the system. Only when the system becomes unresponsive: linear actuators at an end stop; motors at top speed; motor drivers at a current limit; etc., will wind-up become an issue.
I would output integral error, set the motor setpoint to 1.0, then wait until integral error is (effectively) zero, then change the setpoint to 2.0. If the output response is still inconsistent, then you have a problem with the physical limitations of the system (increasing torque required at higher speeds). If you get consistent responses then you are entering "Phase 2" at time "t=N', which is still inside the response time for Phase 1. As the controller is still actively responding it will naturally generate a different response. At that point, consider waiting longer to enter Phase 2 or increasing the gains on your controller to achieve a settled response by time "t=N".
As a final comment, the last line of your code has "Term = k * (
error terms)". If you are doing everything else correctly (generally, have your sampling time correct), then you should leave $k=1$, or just use the sum of the PID terms as the controller output.