DS Lite Scientific Calculator

iam4722202468/DSCalculator

What is this?

This is a scientific calculator created to run on the Nintendo DS lite. It uses libnds, an open source C library for the Nintendo DS. It can follow order of operation to parse lines of math, and has a simple graphing feature built in.

The image at the bottom is static. The lower touchscreen is used to press the buttons.


Features

Calculate result of equation
  • Uses correct order of operation and includes functions like sin, int, and round
Graph simple equations
  • Limitations: 0,0 is assumed to be center of screen and each pixel is assumed to be one unit

How it works

The user inputs a string using the touchscreen. This string is stored, and when the user presses enter, it is parsed.

To parse the string, first the string is split up in to sections based on where the brackets are. The root of nested brackets are found, and solve_simple is called on them. solve_simple solves simple arithmetic such as 4-4*7-5 . The contents of the bracket are replaced with the result of solve_simple. This is done recursively until an answer is found.


Example code for integer function:

if (i == "int(")
{
    if(getbrackets(place, equation) != 1)
        function(place+1, equation);
    
    solve_simple(place, equation);
    
    answer = int(atof(equation.at(place+1).c_str()));
    equation.erase(equation.begin()+place, equation.begin()+place+3);
    
    equation.insert(equation.begin()+place, to_string(answer));
    place--;
} else if (i == "(")
...
Screenshot When in degrees mode, trigonometric functions work in degrees. Other modes include radians mode, and graphing mode
Screenshot Graph view. This is a graph of sin(x/6)*6+x

Repository Statistics


Commit History