You are on page 1of 3

Final Project/Calculator Read Me

B.Bachmann, S. Grob

Figure 1: Finite State Machine Diagram

States:
State 1: Gather/Store Data

When the user enters a number on the keypad for the 1 st time, the number is stored as 0 times
10 times the value of the key pressed. This number is then stored and utilized again in place of the 0 in
the following calculations until the user has completed entering the 1 st number indicated by the pressing
of an operation or the enter key, entering State 2 or 3 respectively.
1+10+100+1000
=1111

Figure 2: State 1 Example

As Shown through Figure 2, the values of the different numbers are stored as described above.

State 2: Operation

When the user presses an operation key +/-, the operation is stored, and State 1 is entered.
1-2
=-2

Figure 3: State 2 Example

State 3: Print Result

Utilizes the stored math type to print the result of the desired operation to the LCD.

1+1
=2

Figure 4: State 3 Example

Utilized Functions
WriteCharacterToLCD(unsigned char character)

Prints entered char onto LCD display

ClearLCD(void)

Clears the lCD display and all stored number values

BackspaceLCD(void)

Moves the cursor back, prints a blank character, and then moves the cursor forward again

11+20+30 11+20+3_

11+20+3
=34

Figure 6: BackSpaceLCD(void) Example

clac_int(int64_t num1, int64_t num2, int64_t op)

Performs the desired operation on the 2 entered numbers: op = 0 for addition and op = 1 for
subtraction.

WriteIntToLCD(int64_t temp_num)
Finds the length of the number, converts the integer into an array, and then prints out each
integer within that array one at a time using WriteCharacterToLCD(unsigned char character).

WriteToRightSide(int64_t temp_num)

Finds the length of the integer, moves cursor to the right far enough to fit the integer, then
prints the resultant integer.

You might also like