void gps_out_once(void){ display_line1[0] = 'L'; display_line1[1] = 'A'; display_line1[2] = 'T'; display_line1[3] = ' '; display_line2[0] = 'L'; display_line2[1] = 'O'; display_line2[2] = 'N'; display_line2[3] = ' '; lcd_clear(); newFM(50); lcd_out(display_line1,LCD_LINE_1); // 16 characters max between quotes - line 1 newFM(50); lcd_out(display_line2,LCD_LINE_2); // 16 characters max between quotes - line 2 }
static void handle_counts ( SOURCE* s, CacheProfFile* cpf, char* fi, char* fn, char* newCountsStr ) { WordFM* countsMap; Bool freeNewCounts; UWord lnno; Counts* newCounts; FileFn* topKey; if (0) printf("%s %s %s\n", fi, fn, newCountsStr ); // parse the numbers newCounts = splitUpCountsLine( s, &lnno, newCountsStr ); // Did we get the right number? if (newCounts->n_counts != cpf->n_events) goto oom; // allocate the key topKey = malloc(sizeof(FileFn)); if (topKey) { topKey->fi_name = strdup(fi); topKey->fn_name = strdup(fn); } if (! (topKey && topKey->fi_name && topKey->fn_name)) mallocFail(s, "handle_counts:"); // search for it if (lookupFM( cpf->outerMap, (Word*)(&countsMap), (Word)topKey )) { // found it. Merge in new counts freeNewCounts = addCountsToMap( s, countsMap, lnno, newCounts ); ddel_FileFn(topKey); } else { // not found in the top map. Create new entry countsMap = newFM( malloc, free, cmp_unboxed_UWord ); if (!countsMap) goto oom; addToFM( cpf->outerMap, (Word)topKey, (Word)countsMap ); freeNewCounts = addCountsToMap( s, countsMap, lnno, newCounts ); } // also add to running summary total addCounts( s, cpf->summary, newCounts ); // if safe to do so, free up the count vector if (freeNewCounts) ddel_Counts(newCounts); return; oom: parseError(s, "# counts doesn't match # events"); }
void gps_wakeup(void){ int kick_out = 1; //time_pass_by = 0; //while (time_pass_by <= 10); newFM(10); PJOUT |= GPS_PWRCNTL; // GPS_PWRCNTL = GPS_ON; //time_pass_by = 0; newFM(20); //while ((time_pass_by <= 20) & kick_out){ //this is where carlson set trace to show me working gps while (kick_out){ if (PJIN & GPS_PWRCHK){ kick_out = 0; } } //commented this out to get this working! PJOUT &= ~GPS_PWRCNTL; // GPS_PWRCNTL = GPS_Off; //gps_out_once(); }
void GPS_Init() { // GPS Initialization //time_pass_by = 0; PJOUT &= ~GPS_RESET; // GPS_RESET = GPS in Reset; //time_pass_by = 0; //while (time_pass_by <= 200); newFM(200); //time_pass_by = 0; PJOUT |= GPS_RESET; // GPS_RESET = GPS NOT Reset; newFM(200); //while (time_pass_by <= 200); //PJOUT &= ~GPS_PWRCNTL; newFM(20); PJOUT |= GPS_PWRCNTL; newFM(40); if (PJIN & GPS_PWRCHK) { PJOUT &= ~GPS_PWRCNTL; } //PJOUT |= GPS_PWRCNTL; //newFM(210); //PJOUT &= ~GPS_PWRCNTL; //I commented this out return; gps_wakeup(); while(!(PJIN & GPS_PWRCHK)){ if (!(PJIN & GPS_PWRCHK)){ newFM(210); //while (time_pass_by <= 210); gps_wakeup(); } } lcd_clear(); lcd_out("GPS_UP", LCD_LINE_1); }
/* Parse a complete file from the stream in 's'. If a parse error happens, do not return; instead exit via parseError(). If an out-of-memory condition happens, do not return; instead exit via mallocError(). */ static CacheProfFile* parse_CacheProfFile ( SOURCE* s ) { #define M_TMP_DESCLINES 10 Int i; Bool b; char* tmp_desclines[M_TMP_DESCLINES]; char* p; int n_tmp_desclines = 0; CacheProfFile* cpf; Counts* summaryRead; char* curr_fn_init = "???"; char* curr_fl_init = "???"; char* curr_fn = curr_fn_init; char* curr_fl = curr_fl_init; cpf = new_CacheProfFile( NULL, NULL, NULL, 0, NULL, NULL, NULL ); if (cpf == NULL) mallocFail(s, "parse_CacheProfFile(1)"); // Parse "desc:" lines while (1) { b = readline(s); if (!b) break; if (!streqn(line, "desc: ", 6)) break; if (n_tmp_desclines >= M_TMP_DESCLINES) barf(s, "M_TMP_DESCLINES too low; increase and recompile"); tmp_desclines[n_tmp_desclines++] = strdup(line); } if (n_tmp_desclines == 0) parseError(s, "parse_CacheProfFile: no DESC lines present"); cpf->desc_lines = malloc( (1+n_tmp_desclines) * sizeof(char*) ); if (cpf->desc_lines == NULL) mallocFail(s, "parse_CacheProfFile(2)"); cpf->desc_lines[n_tmp_desclines] = NULL; for (i = 0; i < n_tmp_desclines; i++) cpf->desc_lines[i] = tmp_desclines[i]; // Parse "cmd:" line if (!streqn(line, "cmd: ", 5)) parseError(s, "parse_CacheProfFile: no CMD line present"); cpf->cmd_line = strdup(line); if (cpf->cmd_line == NULL) mallocFail(s, "parse_CacheProfFile(3)"); // Parse "events:" line and figure out how many events there are b = readline(s); if (!b) parseError(s, "parse_CacheProfFile: eof before EVENTS line"); if (!streqn(line, "events: ", 8)) parseError(s, "parse_CacheProfFile: no EVENTS line present"); // figure out how many events there are by counting the number // of space-alphanum transitions in the events_line cpf->events_line = strdup(line); if (cpf->events_line == NULL) mallocFail(s, "parse_CacheProfFile(3)"); cpf->n_events = 0; assert(cpf->events_line[6] == ':'); for (p = &cpf->events_line[6]; *p; p++) { if (p[0] == ' ' && isalpha(p[1])) cpf->n_events++; } // create the running cross-check summary cpf->summary = new_Counts_Zeroed( cpf->n_events ); if (cpf->summary == NULL) mallocFail(s, "parse_CacheProfFile(4)"); // create the outer map (file+fn name --> inner map) cpf->outerMap = newFM ( malloc, free, cmp_FileFn ); if (cpf->outerMap == NULL) mallocFail(s, "parse_CacheProfFile(5)"); // process count lines while (1) { b = readline(s); if (!b) parseError(s, "parse_CacheProfFile: eof before SUMMARY line"); if (isdigit(line[0])) { handle_counts(s, cpf, curr_fl, curr_fn, line); continue; } else if (streqn(line, "fn=", 3)) { if (curr_fn != curr_fn_init) free(curr_fn); curr_fn = strdup(line+3); continue; } else if (streqn(line, "fl=", 3)) { if (curr_fl != curr_fl_init) free(curr_fl); curr_fl = strdup(line+3); continue; } else if (streqn(line, "summary: ", 9)) { break; } else parseError(s, "parse_CacheProfFile: unexpected line in main data"); } // finally, the "summary:" line if (!streqn(line, "summary: ", 9)) parseError(s, "parse_CacheProfFile: missing SUMMARY line"); cpf->summary_line = strdup(line); if (cpf->summary_line == NULL) mallocFail(s, "parse_CacheProfFile(6)"); // there should be nothing more b = readline(s); if (b) parseError(s, "parse_CacheProfFile: " "extraneous content after SUMMARY line"); // check the summary counts are as expected summaryRead = splitUpCountsLine( s, NULL, &cpf->summary_line[8] ); if (summaryRead == NULL) mallocFail(s, "parse_CacheProfFile(7)"); if (summaryRead->n_counts != cpf->n_events) parseError(s, "parse_CacheProfFile: wrong # counts in SUMMARY line"); for (i = 0; i < summaryRead->n_counts; i++) { if (summaryRead->counts[i] != cpf->summary->counts[i]) { parseError(s, "parse_CacheProfFile: " "computed vs stated SUMMARY counts mismatch"); } } free(summaryRead->counts); sdel_Counts(summaryRead); // since the summary counts are OK, free up the summary_line text // which contains the same info. if (cpf->summary_line) { free(cpf->summary_line); cpf->summary_line = NULL; } if (curr_fn != curr_fn_init) free(curr_fn); if (curr_fl != curr_fl_init) free(curr_fl); // All looks OK return cpf; #undef N_TMP_DESCLINES }
void move(int count) //=========================================================================== // Function name: move // // Description: This function handles car movement shapes // // Passed : no variables passed // Locals: no variables declared // Returned: no values returned // Globals: None // Calls: void Init_Timer_B2(void) // // Author: Joseph Jarriel // Date: Sep 2014 // Compiler: Built with IAR Embedded Workbench Version (6.10.5) // ========================================================================== { int i; if (buttOne == START) { newFM(ONE_SEC); P3OUT &= ~L_FORWARD; P3OUT &= ~R_FORWARD; P3OUT &= ~L_REVERSE; P3OUT &= ~R_REVERSE; P3OUT |= L_FORWARD; P3OUT |= R_FORWARD; newFM(ONE_SEC); P3OUT &= ~L_FORWARD; P3OUT &= ~R_FORWARD; P3OUT &= ~L_REVERSE; P3OUT &= ~R_REVERSE; newFM(ONE_SEC); P3OUT |= L_REVERSE; P3OUT |= R_REVERSE; newFM(TWO_SEC); P3OUT &= ~L_REVERSE; P3OUT &= ~R_REVERSE; P3OUT &= ~L_FORWARD; P3OUT &= ~R_FORWARD; newFM(ONE_SEC); P3OUT |= L_FORWARD; P3OUT |= R_FORWARD; newFM(ONE_SEC); P3OUT &= ~L_REVERSE; P3OUT &= ~R_REVERSE; P3OUT &= ~L_FORWARD; P3OUT &= ~R_FORWARD; newFM(ONE_SEC); P3OUT |= L_FORWARD; P3OUT |= R_REVERSE; newFM(ONE_SEC); P3OUT &= ~L_REVERSE; P3OUT &= ~R_REVERSE; P3OUT &= ~L_FORWARD; P3OUT &= ~R_FORWARD; newFM(ONE_SEC); P3OUT |= R_FORWARD; P3OUT |= L_REVERSE; newFM(ONE_SEC); P3OUT &= ~L_REVERSE; P3OUT &= ~R_REVERSE; P3OUT &= ~L_FORWARD; P3OUT &= ~R_FORWARD; /* //straight line //five_msec_sleep(100); newFM(100); for (i=0; i<count; i++) { P3OUT |= L_FORWARD; P3OUT |= R_FORWARD; //five_msec_sleep(65); newFM(65); P3OUT &= ~L_FORWARD; //five_msec_sleep(35); newFM(35); //P3OUT &= ~R_FORWARD } */ } else if (buttOne == 2) { //Two Left circles //five_msec_sleep(100); newFM(100); for (i=0; i<62; i++) { P3OUT |= L_FORWARD; P3OUT |= R_FORWARD; //five_msec_sleep(2); newFM(2); P3OUT &= ~L_FORWARD; //five_msec_sleep(12); newFM(12); //P3OUT &= ~R_FORWARD } } else if (buttOne == 3) { //Right circle //five_msec_sleep(100); newFM(100); //Right circle for (i=0; i<38; i++) { P3OUT |= L_FORWARD; P3OUT |= R_FORWARD; //five_msec_sleep(2); newFM(2); P3OUT &= ~R_FORWARD; //five_msec_sleep(12); newFM(12); //P3OUT &= ~R_FORWARD } } else if (buttOne == 4) { //Figure 8 //Left Circle //five_msec_sleep(100); newFM(100); //Left circles //five_msec_sleep(100); for (i=0; i<37; i++) { P3OUT |= L_FORWARD; P3OUT |= R_FORWARD; //five_msec_sleep(2); newFM(2); P3OUT &= ~L_FORWARD; //five_msec_sleep(12); newFM(12); //P3OUT &= ~R_FORWARD } //for (i=0; i<count; i++) //{ // P3OUT |= L_FORWARD; // P3OUT |= R_FORWARD; // five_msec_sleep(10); // P3OUT &= ~L_FORWARD; // five_msec_sleep(90); //P3OUT &= ~R_FORWARD //} //Right circle for (i=0; i<38; i++) { P3OUT |= L_FORWARD; P3OUT |= R_FORWARD; //five_msec_sleep(2); newFM(2); P3OUT &= ~R_FORWARD; //five_msec_sleep(14); newFM(14); //P3OUT &= ~R_FORWARD } for (i=0; i<40; i++) { P3OUT |= L_FORWARD; P3OUT |= R_FORWARD; //five_msec_sleep(2); newFM(2); P3OUT &= ~L_FORWARD; //five_msec_sleep(12); newFM(12); //P3OUT &= ~R_FORWARD } //for (i=0; i<count; i++) //{ // P3OUT |= L_FORWARD; // P3OUT |= R_FORWARD; // five_msec_sleep(10); // P3OUT &= ~L_FORWARD; // five_msec_sleep(90); //P3OUT &= ~R_FORWARD //} //Right circle for (i=0; i<38; i++) { P3OUT |= L_FORWARD; P3OUT |= R_FORWARD; //five_msec_sleep(2); newFM(2); P3OUT &= ~R_FORWARD; //five_msec_sleep(14); newFM(14); //P3OUT &= ~R_FORWARD } } else if (buttOne == -1) { //Triangle //five_msec_sleep(100); newFM(100); for (i=2; i<count; i++) { P3OUT |= L_FORWARD; P3OUT |= R_FORWARD; //five_msec_sleep(40); newFM(40); //P3OUT &= ~L_FORWARD; //five_msec_sleep(5); } P3OUT &= ~R_FORWARD; //five_msec_sleep(110); newFM(110); for (i=2; i<count; i++) { P3OUT |= L_FORWARD; P3OUT |= R_FORWARD; //five_msec_sleep(30); newFM(30); P3OUT &= ~L_FORWARD; //five_msec_sleep(10); newFM(10); } P3OUT |= L_FORWARD; P3OUT &= ~R_FORWARD; //five_msec_sleep(110); newFM(110); for (i=2; i<count; i++) { P3OUT |= L_FORWARD; P3OUT |= R_FORWARD; //five_msec_sleep(40); //P3OUT &= ~L_FORWARD; //five_msec_sleep(5); //five_msec_sleep(30); newFM(30); P3OUT &= ~L_FORWARD; //five_msec_sleep(10); newFM(10); } P3OUT |= L_FORWARD; P3OUT &= ~R_FORWARD; //five_msec_sleep(110); newFM(110); //Triangle //five_msec_sleep(100); for (i=2; i<count; i++) { P3OUT |= L_FORWARD; P3OUT |= R_FORWARD; //five_msec_sleep(40); //P3OUT &= ~L_FORWARD; //five_msec_sleep(5); //five_msec_sleep(30); newFM(30); P3OUT &= ~L_FORWARD; //five_msec_sleep(10); newFM(10); } P3OUT |= L_FORWARD; P3OUT &= ~R_FORWARD; //five_msec_sleep(110); newFM(110); for (i=2; i<count; i++) { P3OUT |= L_FORWARD; P3OUT |= R_FORWARD; //five_msec_sleep(40); //P3OUT &= ~L_FORWARD; //five_msec_sleep(5); //five_msec_sleep(30); newFM(30); P3OUT &= ~L_FORWARD; //five_msec_sleep(10); newFM(10); } P3OUT |= L_FORWARD; P3OUT &= ~R_FORWARD; //five_msec_sleep(110); newFM(110); for (i=2; i<count; i++) { P3OUT |= L_FORWARD; P3OUT |= R_FORWARD; //five_msec_sleep(40); //P3OUT &= ~L_FORWARD; //five_msec_sleep(5); //five_msec_sleep(30); newFM(30); P3OUT &= ~L_FORWARD; //five_msec_sleep(10); newFM(10); } } P3OUT &= ~R_FORWARD; P3OUT &= ~L_FORWARD; }