-
Notifications
You must be signed in to change notification settings - Fork 250
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
Add simple calculator face #454
Add simple calculator face #454
Conversation
Playing around with this in the simulator — love it! One issue with the long press of mode: it conflicts with the ability of the wearer to quickly advance past the calculator face. Like if they had Clock -> Calculator -> Stopwatch in rotation, they'd have to remember to long press on this face. A suggestion: could you add to your conditional for the mode button that if all the numbers are 0, and you're in calculator mode 0, a short press of mode just advances to the next watch face? This way if the wearer just need to advance through their watch faces, calculator won't stop them. It feels like a simple tradeoff at very little cost: when you're in mode 0, and all the numbers are 0, it doesn't really make sense to advance to selecting an operator since zero plus or minus any number is just that number, and zero multiplied, divided or raised to any power is still zero. |
Okay, I made the suggested changes and tested them out and agree that's much smoother. I also added back the default of mode long press going to |
Whoops -- accidentally deleted the branch!! It's back now, though 😄 |
I'm pretty sure I just found a bug in this so please don't accept it yet -- my suspicion is that the |
Two more notes that occur to me:
case EVENT_MODE_LONG_PRESS:
if ((state->first_num == 0) && (state->second_num == 0)) {
movement_move_to_face(0);
} else {
state->mode == MODE_ENTERING_FIRST_NUM;
state->operation = OP_ADD;
state->first_num = 0;
state->second_num = 0;
}
break; From here, your existing MODE_BUTTON_UP code works as-is, moving to the next watch face since the conditions for doing that are now met. |
Found the bug -- negative toggle was logically only affecting the |
I've tinkered with this enough to want to save the last value -- the way I use this is in calculations that I revisit -- but if you think the general user wants a clean start every time, that is the essence of the PR into
Let me give this a test tomorrow after some dinner and sleep and I'll let you know 😄 Thanks again for looking at the code |
This works fine in the emulator, but it runs differently on hardware. I'm seeing results with the '-' sign when the number is positive, though the calculations are working otherwise. For instance, inputting 5 + -2 will make 3, but the negative sign '-' is displayed. I can't get this to happen in the emulator, though. I'm not sure what could be going on? |
Okay, I finally squashed that bug -- I forgot to explicitly make the |
Adds a simple calculator watch face to the sensor watch capable of addition, subtraction, multiplication, division and exponentiation. Reviewed-by: Joey Castillo <[email protected]> Reviewed-by: Matheus Afonso Martins Moreira <[email protected]> Tested-by: Joey Castillo <[email protected]> Tested-on-hardware-by: mcguirepr89 <[email protected]> GitHub-Pull-Request: #454
Adds a simple calculator watch face to the sensor watch capable of addition, subtraction, multiplication, division and exponentiation. Reviewed-by: Joey Castillo <[email protected]> Reviewed-by: Matheus Afonso Martins Moreira <[email protected]> Tested-by: Joey Castillo <[email protected]> Tested-on-hardware-by: mcguirepr89 <[email protected]> GitHub-Pull-Request: joeycastillo#454
This is a small UX thing: the calculator doesn't show the display until a tick occurs. Below is an easy fix to this, but I only reviewed the source code for 3 minutes :) switch (event.event_type) {
case EVENT_ACTIVATE:
- break;
-
case EVENT_TICK:
switch (state->mode) {
case MODE_ENTERING_FIRST_NUM:
// See the WISH for this function above
set_number(&state->first_num,
state->placeholder,
display_string,
temp_display_string,
event,
1);
break;
case MODE_CHOOSING:
set_operation(state);
break; |
How to use:
Important note: LONG PRESS MODE to move to next watch faceFlow:
Enter first number -> Select operator -> Enter second number -> View Results
How to read the display:
first number (1), entering the second number (2), or viewing the results (3).
number is negative, a "-" will be displayed, otherwise it is empty.
on the right are the tenths and hundredths decimal places.
Entering the first number:
negative
Selecting the operator:
+ Add
- Subtract
* Multiply
/ Divide
sqrtf() Square root
powf() Power (exponent calculation)
Entering the second number:
MODE here will proceed to viewing the results
Viewing the results:
number. (LONG PRESS ALARM to reset the value to 0)
Errors:
is, if the value is greater than 9,999.99 or less than -9,999.99.
for instance trying to divide by 0 or get the square root of a negative
number.