Open minacode opened 1 year ago
Thank you very much for the review! I hope to find the time soon to fix these bugs.
I tried to update to the new interface for optional apps, but can't fix the overflowing RAM. If someone knows how to fix this, please write a comment.
I updated this to the new CMake optional apps interface and tested it on the device. I think it is ready to merge.
Have been running this app for a while now, works great. Few minor code comments as above (but I haven't reviewed the whole thing in depth, just scanned through it)
This comment in the other calculator implementation is interesting. Saving it here for later.
Turns out that adding this const
to the button matrix does indeed change something, because we no longer need to reduce the FreeRTOS heap size.
Runs well on my watch for a day now.
Nice! Is constexpr possible or more correct here? I think it's preferred way when it's possible but I'm honestly not entirely sure...
I don't know, but I will try.
What exactly? The first const
? Both? 😄
I think constexpr const char*
should suffice?
AFAIK this means compile time evaluate this constant list of const char*
(i.e constant strings)
The last commit did not change something, so I guess that was all we will get.
Oh they're equivalent, it's that constexpr is nicer to use in general as it is a guarantee of compile time evaluation (if it cannot be evaluated at compile time compilation fails). The way you had previously is the way to do it in C, with constexpr added to C++ constexpr const char*
is the more modern way from what I understand
So we just leave it like this, because more const -> more good? :grinning:
The const immediately after constexpr is redundant (constexpr implies const) so I'd remove that personally but it doesn't make a difference in terms of semantics
This PR implements a simple fixed-point calculator. In contrast to #375 it aims to be simpler by not parsing whole equations but just evaluating one operation at a time over an accumulated result.
It takes an operation and a value (digit-wise) and applies the value to the result with the chosen operation whenever a new operation is chosen or
=
is pressed.=
: evaluate current input<
: removes the input charwise or reset the result if the input is zero.(-)
: toggle the sign of the current input (thanks @FintasticMan)+ -
/* /
: press the button to cycle through the operators and "no-operator".It uses fixed-point numbers and checks for errors like too big results and zero division.
Known issues:
from @yusufmte's comment below:
[x] Bug with crashing on large operations (thanks to @CCF100 too!)
[x] Bug when typing a number larger than the interface allows
[x] Bug with any use of the decimal point
[x] Bug where if the result exceeds 12 digits, you will only see the last 12.
[x] Bug when pressing ^, sometimes it will repeat whichever number you last placed
[x] UI gripe / Suggestion (not a bug); backspace and extra clear button
[x]
=
should repeat the last operation (thanks @Avamander!)[x] Check power overflow.
[x] Show error messages.
[x] Add power button toggle.
[x] Fix button colors.
[x] Set one check feature.
[x] -3 * -5 results in "too large"
[x] -6 repeatedly divided by -2 does not swap the sign right
[x] number input is broken when value is negative
[x] operator should only be removed if value is zero
[x] 987654321*100 does not trigger a "too large" warning
[x] implement the interface for optional apps