// prints a graph comparing the sample values visually void printGraph(int samples[], int noOfSamples){ int max = findMax(samples, noOfSamples); cout << "Graph:" << endl; for (int i = 0; i < noOfSamples; i++){ printBar(samples[i], max); } }
void tryit(Puzzle *puzzle, PuzzleCreater create, int showpuzzle, int showroot) { Table fixes; puzzle->lastmove = 0; puzzle->lastmovecount = 0; fillTable(fixes, UNFIXED); fillTableRow(fixes, 0, FIXED); fillTableRow(fixes, TABLE_Y_SIZE - 1, FIXED); fillTabelColumn(fixes, 0, FIXED); fillTabelColumn(fixes, TABLE_X_SIZE - 1, FIXED); puzzle->show = 0; create(puzzle); if (showpuzzle != 0) { printPuzzle(puzzle); } puzzle->count = 0; puzzle->show = showroot; solve(puzzle, fixes); if (showpuzzle != 0) { printBar(); printPuzzle(puzzle); printf("count: %d\n", puzzle->count); } }
/* main function */ int main(void) { while (counter < NUM_DATA) { printBar(data[counter]); counter++; } return EXIT_SUCCESS; }
int main () { int i=0; int input[12]; char trash [20]; /*checks for new line to print the bar and checks for input that is too long * if its a letter, space or digit and either adds it to the input or * ignores it */ while((input[i]=getc(stdin))!=EOF){ if(input[i]=='\n'){ printBar(input, i); i=0; } else if(i>12){ printf("i is >11\n"); scanf("%s", trash); i=0; } else if(isalpha(input[i])){ printf("Invalid delivery data\n"); scanf("%s", trash); i=0; } else if(isspace(input[i])); /*subtracts 48 to convert from the char number to the actual number on the * ascii table*/ else if (isdigit(input[i])){ input[i]=input[i]-48; i++; } } return 0; }
// Calibrates the line sensors by turning left and right, then // displays a bar graph of calibrated sensor readings on the LCD. // Returns after the user presses A. static void lineSensorSetup() { lcd.clear(); lcd.print(F("Line cal")); // Delay so the robot does not move while the user is still // touching the button. delay(1000); // We use the gyro to turn so that we don't turn more than // necessary, and so that if there are issues with the gyro // then you will know before actually starting the robot. turnSensorReset(); // Turn to the left 90 degrees. motors.setSpeeds(-calibrationSpeed, calibrationSpeed); while((int32_t)turnAngle < turnAngle45 * 2) { lineSensors.calibrate(); turnSensorUpdate(); } // Turn to the right 90 degrees. motors.setSpeeds(calibrationSpeed, -calibrationSpeed); while((int32_t)turnAngle > -turnAngle45 * 2) { lineSensors.calibrate(); turnSensorUpdate(); } // Turn back to center using the gyro. motors.setSpeeds(-calibrationSpeed, calibrationSpeed); while((int32_t)turnAngle < 0) { lineSensors.calibrate(); turnSensorUpdate(); } // Stop the motors. motors.setSpeeds(0, 0); // Show the line sensor readings on the LCD until button A is // pressed. lcd.clear(); while(!buttonA.getSingleDebouncedPress()) { readSensors(); lcd.gotoXY(0, 0); for (uint8_t i = 0; i < numSensors; i++) { uint8_t barHeight = map(lineSensorValues[i], 0, 1000, 0, 8); printBar(barHeight); } } lcd.clear(); }
int main() { scanf("%d", &numPts); for (j = 1; j <= numPts; j++) { scanf("%d", &value); printBar(value); } return 0; }
/** Function specific to the value retrieved from EEPROM. Displays correct format for the retrieved value in EEPROM and displays the bar for that value. @param val - the value that is currently selected @param max - the max value to print bar */ void showEepromval(int val, int max) { if(val == 0) { intOut(26,37,0); } if(val != max) { if(val == -1) { Sm_Glcd_Out2(37,38,"????"); printBar(0, 46, 0, max); } else { intOut(26,37,val); printBar(0, 46, val, max); } } }
void printTable(char const *name, const Table table) { int x, y; printBar(); puts(name); for (y = 0; y < TABLE_Y_SIZE; y++) { for (x = 0; x < TABLE_X_SIZE; x++) { if (x > 0) { putchar(' '); } printf("%+2d", table[y][x]); } putchar('\n'); } }
void initScreens() { int i; for(i=1;i<8; i++) { terminals[i].video=videos[i-1]; terminals[i].cursor_x=0; terminals[i].cursor_y=0; terminals[i].color=WHITE_TXT; terminals[i].num=i; clear_screen(&terminals[i]); } terminals[0].video=VID_DIR; terminals[0].color=WHITE_TXT; terminals[0].cursor_x=0; terminals[0].cursor_y=0; clear_screen(&terminals[0]); printBar(); }
/** * Takes the progress array as parameter and prints out the progress for each * outstanding querie * @param progress */ void printProgress(int *progress){ if(repeated){ for(int k=0;k<2;k++){ #if defined(_WIN32) //The printf does not work on windows, native cursor functionality should be implemented #else printf("\033[K"); /* delete line */ printf("\033[A"); /* move cursor one line up */ #endif } for(int j = 0;j<MAXQUERIES;j++){ if(queries[j].running){ #if defined(_WIN32) //IMPLEMENT CURSORS #else printf("\033[K"); /* delete line */ printf("\033[A"); /* move cursor one line up */ #endif fflush(0); } } } cout << endl; for(int i=0;i<MAXQUERIES;i++){ if(queries[i].running){ cout << "query "<<i<<" : "<<progress[i]<<"%"; printBar(progress[i]); cout << endl; } } cout << endl; repeated = 1; }
void moveOneSpace(Puzzle *puzzle, const int dx, const int dy) { int x = (puzzle->space.x += dx); int y = (puzzle->space.y += dy); int n = (puzzle->table[y - dy][x - dx] = puzzle->table[y][x]); puzzle->table[y][x] = 0; puzzle->count++; if (puzzle->show != 0) { dcode(printBar()); printf("%d\n", n); dcode(printPuzzle(puzzle)); if (puzzle->lastmovecount > 4) { printf("lastmove error %d\n", n); printPuzzle(puzzle); exit(EXIT_SUCCESS); } if (puzzle->lastmove == n) { puzzle->lastmovecount++; } else { puzzle->lastmovecount = 0; puzzle->lastmove = n; } } }
void b(){ for(int i=0; i<100000000; i++) { printFoo(); printBar(); } }
void sendReportIfNeeded() { static uint32 lastReport; uint8 i, bytesToSend; uint16 result[6]; uint16 vddMillivolts; // Create reports. if (getMs() - lastReport >= param_report_period_ms && reportLength == 0) { lastReport = getMs(); reportBytesSent = 0; vddMillivolts = adcReadVddMillivolts(); adcSetMillivoltCalibration(vddMillivolts); for(i = 0; i < 6; i++) { result[i] = adcRead(i); } if (param_bar_graph) { printf("\x1B[0;0H"); // VT100 command for "go to 0,0" printBar("P0_0", result[0]); printBar("P0_1", result[1]); printBar("P0_2", result[2]); printBar("P0_3", result[3]); printBar("P0_4", result[4]); printBar("P0_5", result[5]); printf("VDD %4d mV", vddMillivolts); } else { printf("A, %4d, %4d, %4d, %4d, %4d, %4d,\r\n", adcConvertToMillivolts(result[0]), adcConvertToMillivolts(result[1]), adcConvertToMillivolts(result[2]), adcConvertToMillivolts(result[3]), adcConvertToMillivolts(result[4]), adcConvertToMillivolts(result[5]) ); } } // Send the report to USB in chunks. if (reportLength > 0) { bytesToSend = usbComTxAvailable(); if (bytesToSend > reportLength - reportBytesSent) { // Send the last part of the report. usbComTxSend(report+reportBytesSent, reportLength - reportBytesSent); reportLength = 0; } else { usbComTxSend(report+reportBytesSent, bytesToSend); reportBytesSent += bytesToSend; } } }
void main(void) { int an3now; int an3max = 0; char key; char eepromloc = 0; int eepromval; int eeprommax; char graphclear = 1; Glcd_Init(); Sm_Glcd_Out2(57, 67, "H.S.B V1.0"); Sm_Glcd_Out2(51, 1, "AN3:"); Sm_Glcd_Out2(37, 1, "ROM:"); Sm_Glcd_Out2(0, 1, "MIN"); Sm_Glcd_Out2(10, 1, "MAX"); Sm_Glcd_Out2(20, 1, "MEAN"); //Lines for graph Glcd_H_Line(62, 126, 32, 1); Glcd_V_Line(0,32,62,1); ADCON1 = 0; eepromval = getAn3(eepromloc); showEepromval(eepromval,eeprommax); an3now = ADC_Read(3); intOut(26, 51, an3now); while(1) { an3max = an3now; eeprommax = eepromval; an3now = ADC_Read(3); key = scanKeypad(); if(key == 1) //store an3 value { storeAn3(eepromloc, an3now); eepromval = an3now; } if(key == 2) //switch eeprom bank and return value { if(eepromloc == 0) eepromloc = 16; else if(eepromloc == 16) eepromloc = 32; else if(eepromloc == 32) eepromloc = 0; eepromval = getan3(eepromloc); } if(key == 4 && graphclear == 1) //run graph if it is clear { graphclear = 0; runGraph(); } if(key == 5 && graphclear == 0) //clear graph if it has been run { graphclear = 1; resetGraph(); } key = 0; if(an3now != an3max) { intOut(26, 51, an3now); printBar(0, 59, an3now, an3max); } showEepromval(eepromval, eeprommax); } }