Gateway: ENGI E1112 CS Lab Project Ross Basri Ruchir Khaitan - - PowerPoint PPT Presentation

gateway engi e1112 cs lab project
SMART_READER_LITE
LIVE PREVIEW

Gateway: ENGI E1112 CS Lab Project Ross Basri Ruchir Khaitan - - PowerPoint PPT Presentation

Gateway: ENGI E1112 CS Lab Project Ross Basri Ruchir Khaitan Design Brief Program and integrate new firmware for an HP 20b calculator. Specifications Final product must Limitations HP20b calculator Linux Workstation


slide-1
SLIDE 1

Gateway: ENGI E1112 CS Lab Project

Ross Basri Ruchir Khaitan

slide-2
SLIDE 2

Design Brief

  • Program and integrate new firmware for

an HP 20b calculator.

slide-3
SLIDE 3

Specifications

  • Final product must…
slide-4
SLIDE 4

Limitations

  • HP20b calculator
  • Linux Workstation
  • JTAG adaptor
slide-5
SLIDE 5

Lab 1: Hello World

  • Objective: To create a function that

takes an integer argument and displays it in decimal on the calculator.

slide-6
SLIDE 6

void lcdprint(int input){ if(input == 0){ lcd_put_char7('0', NUM_COLUMNS); return; } int remainder, count = NUM_COLUMNS; int negative = input < 0 ? 1 : 0; int output = negative ? -1*input : input; while(output>0){ remainder = output%10; lcd_put_char7('remainder',count--);

  • utput = output/10;

} if(negative) lcd_put_char7(45, count); //print minus sign }

slide-7
SLIDE 7

Lab 2: Listening to the Keyboard

  • Objective: To write software that will

read the keyboard on the HP 20b and display which key is pressed.

slide-8
SLIDE 8

Lab 2: Listening to the Keyboard

slide-9
SLIDE 9

int returnColumn=NUM_COLUMNS; //default case extern int keyboard_key() { int column, row; for(column=0; column<NUM_COLUMNS; column++){ keyboard_column_low(column); for(row=0; row<NUM_ROWS; row++){ if(!keyboard_row_read(row)) return row; returnColumn = column; } keyboard_column_high(column); } return NUM_ROWS; //default case } extern int getColumn(){ //accessor for which column was pressed return returnColumn; }

slide-10
SLIDE 10

Lab 3: Entering and Displaying Numbers

  • Objective: To write code that will let the

user enter and edit numbers.

slide-11
SLIDE 11

void keyboard_get_entry(struct entry *result) { int key; unsigned int num = INT_MAX; for (;;) { while (keyboard_key()) ; //wait until no key is pressed while (!(key = keyboard_key())) ; //wait until key is pressed if ( key >= '0' && key <= '9') { if (num == INT_MAX) num = 0; if (num < 100000000) num = num * 10 + (key - '0'); } else if (key == '\r' || key == '+' || key == '-' || key == '*' || key == '/') { result->number = num; result->operation = key; return; } lcd_print_int(num); } }

slide-12
SLIDE 12

Lab 4: An RPN Calculator

  • Objective: To create a functioning,

reverse-polish notation calculator.

slide-13
SLIDE 13

Lab 4: An RPN Calculator

slide-14
SLIDE 14

… if(current > STACK_SIZE-1) lcd_print7("OVERFLOW"); //Handle overflow else{ if(current < 0) lcd_print7("UNDERFLOW"); //Handle underflow else lcd_print_int(popped); //Print 0 in case of clear } } else if(entry.operation == '\r') stack[current++]=entry.number; else{ popped = stack[--current]; if(entry.number == INT_MAX) popped2=stack[--current]; //no number pressed, only operation, i.e. 5 3 4 + + else popped2=entry.number; //number and operation given if(entry.operation == '+') result=popped+popped2; if(entry.operation == '-') result=popped-popped2; if(entry.operation == '*') result=popped*popped2; if(entry.operation == '/') result=popped/popped2; stack[current++]=result; lcd_print_int(result); }

slide-15
SLIDE 15

To Conclude…