calculator hp 20b
play

CALCULATOR HP 20b Aaron Burger and Isabel Baransky From RPN to - PowerPoint PPT Presentation

CALCULATOR HP 20b Aaron Burger and Isabel Baransky From RPN to beyond HP 20b CALCULATOR HOW TO USE DISPLAY 4 DISPLAY 4 DISPLAY - 4 SIGN CHANGE - 4 SIGN CHANGE 4 SIGN CHANGE 4 SIGN CHANGE 0 RESET 4 ALGEBRA (4+5) X 2 4


  1. CALCULATOR HP 20b Aaron Burger and Isabel Baransky From RPN to beyond

  2. HP 20b CALCULATOR

  3. HOW TO USE

  4. DISPLAY

  5. 4 DISPLAY

  6. 4 DISPLAY

  7. - 4 SIGN CHANGE

  8. - 4 SIGN CHANGE

  9. 4 SIGN CHANGE

  10. 4 SIGN CHANGE

  11. 0 RESET

  12. 4 ALGEBRA (4+5) X 2

  13. 4 ALGEBRA (4+5) X 2 4

  14. 5 ALGEBRA (4+5) X 2 4

  15. 5 ALGEBRA (4+5) X 2 4; 5

  16. 9 ALGEBRA (4+5) X 2 9

  17. 2 ALGEBRA (4+5) X 2 9

  18. 2 ALGEBRA (4+5) X 2 9; 2

  19. 18 ALGEBRA (4+5) X 2 18

  20. WITH IMPROVEMENTS

  21. 4 ALGEBRA 4+5 X 2

  22. 4 ALGEBRA 4+5 X 2

  23. 5 ALGEBRA 4+5 X 2

  24. 5 ALGEBRA 4+5 X 2

  25. 2 ALGEBRA 4+5 X 2

  26. 14 ALGEBRA 4+5 X 2

  27. HARDWARE

  28. Atmel AT91SAM7L128 PROCESSOR • “AT” is for Atmel • “SAM” is “smart ARM core” • 7L series of microcontrollers ▫ designed for low power (hence the L) ▫ Allows it to run off low voltage batteries (watch batteries) • 128K of flash program memory

  29. LCD DISPLAY • 12 Digit LCD • Large 2 line LCD display

  30. KEYBOARD

  31. PROGRAMMING

  32. LAB 1 CODE EXPLANATION  We tell the calculator to display int myFavoriteNumber(int x) the interger at position 11 {  If the number is less than zero, int position = 11; display a negative sign and treat if (x == 0) { number as positive lcd_put_char7(48, 11); return 0;  If the number is not 0, loop } through  Receives numerical input if (x < 0) { from main function lcd_put_char7('-', 0);  Displays on the right side of x = -x; the screen }  Would later use an while (x != 0) { unsigned integer char d = (x%10 + 48); lcd_put_char7(d, position);  Device not yet a calculator x /= 10; // x = x/10 and display the digits position -= 1; } return (12-position); }

  33. int keyboard_key () { int i = 0; KEYBOARD.C int j = 0; • Initialize the for loop operators for (i=0; i<7; i++) keyboard_column_high(i); • Set all colmnus to high • Iterate through all columns for (i=0; i<7; i++) { • Set this column to low keyboard_column_low(i); • Detect if this column is being read for (j=0; j<6; j++) { • Encode x, y as a two digit number if (!keyboard_row_read(j)) { • Set this column back to high return j*10 + i; • Set all columns back to low } • Return -1 to indicate no input } keyboard_column_high(i); } for (i=0; i<7; i++) keyboard_column_low(i); return -1; }

  34. LAB 2 AND 3 CODE EXPLANATION int main() { • Forever ... • This if/else block converts the char A[4][4] = { {'7', '8', '9', '/'}, two digits returned by {'4', '5', '6', 'X'}, keyboard_key into a 1x2 array, {'1', '2', '3', '-'}, the x,y coo {'0', '.', '=', '+'} }; • If the keyboard_key() function returns that there is no input for (;;) { coordinate inn = keyboard_key(); • We check for the low pin if (inn != -1) { values, as they indicate the res[0] = (inn - (inn % 10))/10; button is being pressed res[1] = inn % 10; } • The location on the grid is mapped onto an array else { res[0] = -1; • The array contains the res[1] = -1; characters that we could } then display

  35. LAB 2 AND 3 CODE EXPLANATION if (res[1]>2 && res[1]<8 && res[0]>0 && • If the inputs are within the res[0]<6 && len < 10) { if (pause == 1) { number grid num*=10; • And the debounce is disabled num+=A[res[1]-3][res[0]-1] - '0'; len = myFavoriteNumber(num); • Enable the debounce pause = 0; } • If the ‘reset’ button is struck } • Clear the screen else if (res[1]==0 && res[0]==0) { for (j=0; j<12; j++) • Redisplay 0 lcd_put_char7(' ', j); num = 0; • Disable the debounce myFavoriteNumber(num); • Using a makeshift reset len=0; } button, would later else if (pause == 0){ employ On-Clr Button pause = 1; } • Still not a calculator } ... }

  36. for (;;) { keyboard_get_entry(&beta); if (beta.operation == 'q') { opp = &op[0]; LAB 4 } else if (beta.operation == '\r') { *opp = beta.number; • Parallel of operations makes this opp++; method easily condensible while(keyboard_key() != -1) { continue; • Stack depth is semi-arbitrary, but it was } set to 5 } • Device is now a calculator else if (beta.operation == '+' || beta.operation == '-' || beta.operation == '*') { else { if (beta.newNum == 1) lcd_put_char7('r', 1); *opp = beta.number; else if (beta.newNum == 0) opp--; opp++; } if (opp > &op[0]) { if (beta.operation == '+') *(opp-1) = *(opp-1) + *opp; while(keyboard_key() != -1) { else if (beta.operation == '-') continue; *(opp-1) = *(opp-1) - *opp; } else if (beta.operation == '*') *(opp-1) = *(opp-1) * *opp; } myFavoriteNumber(*(opp-1) < 0 ? -*(opp-1) : *(opp-1), } *(opp-1) < 0); }

  37. for (;;) { keyboard_get_entry(&beta); if (beta.operation == 'q') { opp = &op[0]; xSign = 1; LAB 5 pHold = 1; } else if (beta.operation == '+' || beta.operation == '-') { if (beta.newNum == 1) { • Addition, subtraction, and *opp = beta.number; multiplication are consistent with the if (opp == &op[0]) { order of operations opp++; • Didn't have time to optimize code } properly, or develop parenthesis else if (opp == &op[1]) { • A functioning calculator in the *(opp-1) += *opp * xSign; myFavoriteNumber(*(opp-1) < 0 ? -*(opp-1) : *(opp- traditional sense 1), *(opp-1) < 0); } if (beta.newNum == 1) { xSign = (beta.operation == '-' ? -1 : 1); } pHold *= beta.number; while(keyboard_key() != -1) { myFavoriteNumber(pHold < 0 ? continue; -pHold : pHold, pHold < 0); } keyboard_get_entry(&beta); } else if (beta.operation == '*') { do { while(keyboard_key() != -1) { continue; } }

  38. else { keyboard_get_entry(&beta); } } while(beta.operation == '*'); LAB 5 if (beta.operation == '+' || beta.operation == '-') xSign = (beta.operation == '-' ? -1 : 1); • Addition, subtraction, and multiplication are consistent with the if (opp == &op[0]) { order of operations *opp = pHold * beta.number; • Didn't have time to optimize code properly, or develop parenthesis if (beta.operation == '=') { • A functioning calculator in the myFavoriteNumber(*opp < 0 ? -*opp : *opp, *opp < traditional sense 0); pHold = 1; opp = &op[0]; } while(keyboard_key() != -1) { else { opp++; continue; } } } } else if (opp == &op[1]) { *(opp-1) += pHold * beta.number * xSign; myFavoriteNumber(*(opp-1) < 0 ? -*(opp-1) : *(opp-1), *(opp-1) < 0); }

  39. else if (beta.operation == '=') { if (beta.newNum == 1) { *opp = beta.number; LAB 5 if (opp == &op[1]) { if (tOp == '-' || tOp == '+') { • Addition, subtraction, and *(opp-1) += *opp * xSign; multiplication are consistent with the myFavoriteNumber(*(opp-1) < 0 ? -*(opp- order of operations 1) : *(opp-1), *(opp-1) < 0); • Didn't have time to optimize code opp = &op[0]; properly, or develop parenthesis } • A functioning calculator in the traditional sense } } while(keyboard_key() != -1) { continue; } } tOp = beta.operation; }

  40. SOCIAL IMPLICATIONS

  41. REFLECTION LESSON LEARNED CRITICISM • Plan ahead • Assumed knowledge of C makes it hard for those • Be organized without solid programming knowledge to participate • More time should be sectioned off to teach C

  42. FINAL THOUGHTS

Recommend


More recommend