Graph 2 - Graphing calculator for Arduboy... 2!

This is my entry to the Arduboy Game Jam 4. It’s a fully-functional graphing calculator! It’s ten times better than Graph 1, because you can enter your own expression from scratch!

It’s still somewhat in development, however! I have a lot done, but I also have a lot to do. Implicit multiplication doesn’t work yet, so you’ll have to do 2*x^2 instead of 2x^2. You can track my development by going over to this project’s GitHub!

Here’s the post-jam build as of Nov. 9 10 11 14th Dec. 4th, 2019:
–graph2–.hex (62.4 KB)

Jam build:
–graph2–.hex

A bit janky. Some errors require you to powercycle your Arduboy. This is just my lazy error handling, don’t worry about your Arduboy, it’s okay! Also, don’t rely too hard on the calculator’s accuracy! Floating point precision can only go so far!

Edit: I almost forgot! Controls!

When on the main screen:

  • D-pad moves
  • A enters

When entering a number/function:

  • D-pad moves
  • A enters
  • B erases

When on the RPN screen (wacky screen with numbers and “>”):

  • Left lets you edit constants
  • Right lets you edit tokens (they’re displayed in hex, but not edited in hex)
  • A edits
  • B returns

Also, I didn’t really limit the cursor on the RPN screen, so try finding and editing the window variables!

Edit: Alright, last edit. moved statement to top
Edit: Updated build. Fancy UI! Not 100% functional!
Edit: Added Tables, to-do markers, some tweaks

6 Likes

I’m suddenly glad I didn’t make the calculator that I was considering making.


A few comments:

Be wary of StackArray.
It uses dynamic memory allocation so it has the potential to cause problems if you start running out of memory at runtime.

The version of lerp you’re using doesn’t guarantee that the result will be b when p is 1.0 because of floating point arithmetic error.
This may not be an issue in your case, but I thought I’d mention it in case you weren’t aware.
(See Wikipedia for more detail.)

Lastly you’re not supposed to include .cpp files,
though I think I know why you’re doing that.
I suspect you were having problems getting the .cpp files to be included in the build process.
Basically the Arduino IDE won’t compile any .cpp files unless they’re in the root of the project or somewhere in a folder named src.
(See this issue.)

1 Like

That is really good!

Quick question, why are there two ‘x’ buttons in the lower left of the keypad?

1 Like

@Pharap
Yeah, I’m still a little suspicious of StackArray, but I’m not sure if there’s another option that does the same thing. another option besides just making my own stack.
Anyway, I’ve fixed the lerp issue.
I was including .cpp files because I wanted the Arduino IDE to add my libraries at exact points, rather than dumping them all at the top in alphabetical order.

@filmote
I just had one extra button that wasn’t being used, so I just put another x button there.

Anyway, here’s the issues I’m working on:

  • Division operations are reversed (Function-related issue)
  • Cursor resets Arduboy when it goes offscreen on main menu (GraphFont-related issue)
  • Implicit Multiplication doesn’t work (Function-related issue)
  • Error reporting doesn’t exist - functions fail silently (Function-related issue)
  • Graph object wastes a lot of memory by storing all Y values (Graph-related issue)
  • Prepare for functions by converting existing char input system over to a token-based system (Big issue)
    • This means using a more TI-84-like system where there’s a dedicated unary minus token and it’s completely different from the subtraction token.
1 Like

If you’re happy with having a preallocated stack I could lend you a class.
I’ve written them before so I (or you) could just modify one of my existing ones.
If you’re happy to have more than one file dependency then you should be able to just use this.

(I think the first statically allocated stack I wrote was when @filmote was using StackArray in Choplifter.)

What for?
Making it easier to examine the generated assembly code?

That looks very useful, thanks! (Haven’t implemented, need to do that soon™)

Also, it seems that the bug that stopped me from compiling with my #includes in order is gone now.

1 Like