mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[apps/apps_container] Add timer to circuit breaker
poincareCircuitBreaker requires the Back key to be pressed for at least
50 ms before interrupting a computation.
This is effectively invisible for the user, but fixes a bug in
Calculation :
- When leaving the additional results for a result using units by
pressing the Back key, a reduction preceding a call to removeUnits
would be interrupted, causing an undefined behaviour.
Change-Id: Iec667ae964f190de2171850cc22e1726959e6cb5
This commit is contained in:
committed by
Émilie Feral
parent
df6383d2d8
commit
504223612d
@@ -51,8 +51,23 @@ AppsContainer::AppsContainer() :
|
||||
}
|
||||
|
||||
bool AppsContainer::poincareCircuitBreaker() {
|
||||
constexpr uint64_t minimalPressDuration = 20;
|
||||
static uint64_t beginningOfInterruption = 0;
|
||||
Ion::Keyboard::State state = Ion::Keyboard::scan();
|
||||
return state.keyDown(Ion::Keyboard::Key::Back) || state.keyDown(Ion::Keyboard::Key::Home) || state.keyDown(Ion::Keyboard::Key::OnOff);
|
||||
bool interrupt = state.keyDown(Ion::Keyboard::Key::Back) || state.keyDown(Ion::Keyboard::Key::Home) || state.keyDown(Ion::Keyboard::Key::OnOff);
|
||||
if (!interrupt) {
|
||||
beginningOfInterruption = 0;
|
||||
return false;
|
||||
}
|
||||
if (beginningOfInterruption == 0) {
|
||||
beginningOfInterruption = Ion::Timing::millis();
|
||||
return false;
|
||||
}
|
||||
if (Ion::Timing::millis() - beginningOfInterruption > minimalPressDuration) {
|
||||
beginningOfInterruption = 0;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
App::Snapshot * AppsContainer::hardwareTestAppSnapshot() {
|
||||
|
||||
@@ -254,9 +254,6 @@ Calculation::AdditionalInformationType Calculation::additionalInformationType(Co
|
||||
}
|
||||
if (o.hasUnit()) {
|
||||
Expression unit;
|
||||
/* FIXME : When this method is accessed via leaving the additional outputs,
|
||||
* ie via a press on BACK, the reduction is interrupted, and removeUnit
|
||||
* goes badly.*/
|
||||
PoincareHelpers::Reduce(&o, App::app()->localContext(), ExpressionNode::ReductionTarget::User, ExpressionNode::SymbolicComputation::ReplaceAllSymbolsWithDefinitionsOrUndefined, ExpressionNode::UnitConversion::None);
|
||||
o = o.removeUnit(&unit);
|
||||
double value = PoincareHelpers::ApproximateToScalar<double>(o, App::app()->localContext());
|
||||
|
||||
Reference in New Issue
Block a user