ENGI E1112 Department Project Report:Computer Science/Computer EngineeringAnkita Gore, Christina Huang, Shikhar KumarDecember 16, 2011PlatformSoftware ArchitectureTutorialSoftware Details - Lab 11 //Ankita Gore, Shikhar Kumar, Christina Huang2 #include "AT91SAM7L128.h"3 #include "lcd.h"45 #define DELAY 50000 //Delay factor6 #define STRLEN 19 //Length of display string7 #define COLS 15 //Number of spaces allotted to display on the LCD8 #define BLANKSPACES 2 //Number of blank spaces to display before wrapping around9 10 int main()11 {12 *AT91C_WDTC_WDMR = AT91C_WDTC_WDDIS; //Turn off watchdog timer13 lcd_init();14 15 char name1[] = "HELLO WORLD ABC123"; //Display string16 char name2[COLS]; //String which will be displayed on LCD17 int i, j, p;18 for(;;) {19 for (j=0;j<STRLEN;j++) { //Iterate through display string20 for (i=0;i<COLS;i++) { //Iterate through LCD display21 if (i+j>COLS+BLANKSPACES) { //LCD string has reached end of display string22 name2[i]=" ";23 }24 else { //LCD string still within display string25 name2[i]=name1[i+j];26 }27 }28 lcd_print7(name2);29 for (p=0;p<DELAY;p++) { //Delay30 }31 }32 }33 return 0;34 }Software Details - Lab 21 //Ankita Gore, Shikhar Kumar, Christina Huang2 #define NUMCOLS 7 //Number of columns in calculator configuration3 #define NUMROWS 6 //Number of rows in calculator configuration45 int keyboard_key() {6 int r;7 int c;8 for (c = 0; c < NUMCOLS; c++) { //iterate through columns9 keyboard_column_low(c); // change current column to low10 for (r = 0 ; r < NUMROWS ; r++) { // iterate through rows in current column11 if (!keyboard_row_read(r)) { // current row also reads low12 keyboard_column_high(c);13 return (c*10)+r; //return array position of key14 }15 }16 keyboard_column_high(c); //reset column back to high17 }18 return -1;19 }2021 int main() {2223 lcd_init();24 keyboard_init();25 for (;;) {26 int x = keyboard_key();2728 if (x==-1) {29 lcd_print7("No key");30 }31 else {32 lcd_print7("KEY ");33 lcd_put_char7(’0’+(x/10), 4); //place first digit of keyboard_key in fourth spot34 lcd_put_char7(’0’+(x%10), 5); //place second digit of keyboard_key in fifth spot35 }36 }37 return 0;38 }Software Details - Lab 31 // Ankita Gore, Shikhar Kumar, Christina Huang2 void keyboard_get_entry(struct entry *result) {3 result->number = 0; // entry.number4 int a = -1; // nothing is being pressed5 int numOfKeysPressed = 0;6 int sign = 1; // sign is positive7 int position = 1;8 9 for (;;) {10 int b = a; // b stores previous value of a11 a = keyboard_key();12 if (a>=’0’ && a<=’9’ && b==1) { // a is an integer and a has not been held down13 lcd_put_char7(a, position); // displays key pressed in appropriate position14 position++;15 numOfKeysPressed++;16 int num_to_add = a- ‘0’; // converts key pressed to int and adds to entry number17 result -> number = (result -> number)*10 + num_to_add;18 }19 20 if (a==’~’ && b==1) { // negative button has been pressed21 if (sign==1) {22 lcd_put_char7(’-’, 0); // put negative sign23 }24 else {25 lcd_put_char7(’ ’, 0); // get rid of negative sign26 }27 sign = sign*-1; // switch sign of variable ‘sign’28 }29 30 if (a==’/’ || a==’*’ || a==’+’ || a==’’ || a==’\r’) { // operation/input key pressed31 if(numOfKeysPressed == 0) {32 result-> number = INT_MAX; // return INT_MAX if no key pressed33 }34 if (a==’/’ || a==’*’ || a==’+’ || a==’-’) {35 lcd_put_char7(a, position);36 }37 result->operation = a;38 if (sign==-1) {39 result->number*=-1; // Switch sign of result40 }41 return; // if operation/input pressed, break out of infinite for loop42 }43 }44 }Software Details - Lab 41 //Ankita Gore, Shikhar Kumar, Christina Huang2 3 #include "AT91SAM7L128.h"4 #include "lcd.h"5 #include "keyboard.h"67 int main() {89 struct entry entry;10 // Disable the watchdog timer11 *AT91C_WDTC_WDMR = AT91C_WDTC_WDDIS;12 13 lcd_init();14 keyboard_init();15 int stack[10]; //Declare stack16 int numOfTermsInStack = 0; // Keeps track of how many terms in track17 lcd_put_char7('0',11); //Start off by displaying 018
View Full Document