-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing stop_reset function #16
Comments
It would be useful to have something of the sort. Perhaps the right way to do it would be to have stop() do what you suggest, and replace the current stop() function by pause(). This would break existing code, though. Another option would be to give it as an option to stop() eg. |
I suggest to not break the public interface. Also, I do not like something like But since calling For the pause functionality we already have resume(). What is the user case for a For reference: void Chrono::start(Chrono::chrono_t offset) {
restart(offset);
}
void Chrono::restart(Chrono::chrono_t offset) {
_startTime = _getTime();
_offset = offset;
_isRunning = true;
}
void Chrono::resume() {
if (!_isRunning) { // can only resume if was stopped
_startTime = _getTime();
_isRunning = true;
}
} |
I think the problem is that after calling My suggestion: add a function called |
There is already a |
@riodda Can you give an example of why you think that feature is important to have? |
@thomasfredericks |
Normally real-life chronometers have a |
This would be really helpful. I have the same problem and I want to reset the Chrono at a given time. My example is, that I want to give the user feedback on a display, that the interval time is starting again. In the first place it was really confusing until I got it, that the restart is not reseting the chrono to 0 again. So having a reset would be really intuitive. |
The restart() is resetting the chrono to 0 (basically start() and restart() do the same thing). So perhaps a reset() function would be the way to go. I would support adding something like this. void reset(chrono_t offset=0) {
_offset = offset; // reset to offset
_isRunning = false;
} |
I do not understand. How is restart not setting the Chrono to 0? It should! What do you need? |
@thomasfredericks It's true: restarts() does resets the Chrono to zero -- but it also starts the Chrono. So it is not possible to stop the Chrono (_isRunning = false) and set it to zero (or even, set it to some offset value). Think about an actual chronometer to time your 100m sprint or whatever. You cannot set it back to zero without actually starting it. I think there are applications where this is something you would want to do. In other words: to me, we are missing the possibility to set the chrono to zero (or some other offset) while also stopping it. We do not have that option right now. |
Stop, pause, and play/start behave differently depending on the implementation, the type of device and the manufacturer. Start In most documentation and examples of the Chrono library, restart is used instead of start as it explicitly states that the counter will be reset to 0 AND the run state will be activated . Based on wanting to keep this, the other methods could be distinguished as so:
Since start could be confused with restart it could be deprecated and renamed continue (but we already have resume). |
See the documentation here that uses |
I think this would be (almost) ideal. But it would break both the behavior of stop() and start() -- so it would not be back-compatible. I see two alternatives: First proposal (not back-compatible because change to stop() function):
Second proposal (back-compatible):
|
The word |
A better term could be |
Interesting but IMHO the "stop, pause, resume, start" is the clearest approach. It would break back-compatibility so we'd have to be ready for it and it could mean a period of adjustment, but I think it would be my preference, better to do it now than later. We could (and should) add a |
I would just modifiy the behavoir of For @22chrs , the simplest solution would be to just check if the Chrono is running:
|
@thomasfredericks Ok, so if I understand right, this would correspond to my first proposal, so it seems we agree:
I don't think we need a tooglePause() function because resume() is perfectly consistent IMHO. But we should definitely add a set() function which seems to be the missing part in our update. If we do these updates I would suggest we move to version 2.0 because we are breaking compatibility with current version. |
@sofian, yes I agree. |
I would suggest to add a function like stop_reset
void Chrono::stop_reset() {
_offset = 0; // reset to zero
_isRunning = false;
}
The text was updated successfully, but these errors were encountered: