void testApp::draw() { ofSetColor(255); ofPushMatrix(); ofTranslate(16, 16); ofDrawBitmapString("Frequency Domain", 0, 0); plot(drawBins, -plotHeight, plotHeight / 2); ofPopMatrix(); string msg = ofToString((int) ofGetFrameRate()) + " fps"; ofDrawBitmapString(msg, ofGetWidth() - 80, ofGetHeight() - 20); ofSetColor(255, 255, 255); // bargraph(tBuffer1,10.0, 32, 512, 800, 128); bargraph(tBuffer2,50.0, 32, 200, 800, 128); ofSetColor(255, 255, 0); bargraph(tBuffer3,50.0, 32, 200, 800, 128); ofSetColor(255, 0, 0); bargraph(tBuffer4,50.0, 32, 200, 800, 128); ofSetColor(255, 255, 255); bargraphB(tBuffer2B,50.0, 32, 400, 800, 128); ofSetColor(255, 255, 0); bargraphB(tBuffer3B,50.0, 32, 400, 800, 128); ofSetColor(255, 0, 0); bargraphB(tBuffer4B,50.0, 32, 400, 800, 128); }
void HTMLWriter::_write(double data) { no_ident_this_section=true; switch(getNumericFormat()) { case NUMERIC: stream<<data; break; case PERCENT: stream<<QString::number(data*100,5,2) <<Qt::escape("%"); break; case BARGRAPH: bargraph(getColor(),data); break; } }
inst_t disk_install(const char *datfile, char *fromdir, char *destdir) { char lsmfile[MAXPATH]; /* Linux software map file */ char *s; int dat_count; /* size of the dat array */ int ret; int ch; int i; int pkg_yesToAll = 0; /* Assume default yes to all = not specified */ dat_t *dat_ary; /* the DAT array */ inst_t this; /* return: no. of errors,warnings */ /* Initialize variables */ this.errors = 0; this.warnings = 0; /* Read dat file */ dat_ary = dat_read (datfile, &dat_count); if (dat_ary == NULL) { s = catgets (cat, SET_ERRORS, MSG_ERROR, MSG_ERROR_STR); fprintf (stderr, s); log("<error msg=\"%s\" />\n", s); s = catgets (cat, SET_ERRORS, MSG_ERRALLOCMEMFDF, MSG_ERRALLOCMEMFDF_STR); fprintf (stderr, s); log("<error msg=\"%s\" />\n", s); pause(); return (this); } if (dat_count < 1) { s = catgets (cat, SET_ERRORS, MSG_ERROR, MSG_ERROR_STR); fprintf (stderr, s); log("<error msg=\"%s\" />\n", s); s = catgets (cat, SET_ERRORS, MSG_ERREMPTYFLOPPYDATAFILE, MSG_ERREMPTYFLOPPYDATAFILE_STR); fprintf (stderr, s); log("<error msg=\"%s\" />\n", s); pause(); free (dat_ary); return (this); } /* Run the install */ for (i = 0; i < dat_count; i++) { /* Print the screen and progress bargraph */ repaint_empty(); box (14, 16, 66, 18); gotoxy (15, 17); bargraph (i, dat_count, 50 /* width */); /* Print the package name */ gotoxy (2, 5); s = catgets (cat, SET_PKG_GENERAL, MSG_PACKAGE, MSG_PACKAGE_STR); cputs (s); cputs (dat_ary[i].name); /* Show the package description */ /* Generate the lsmfile name */ fnmerge (lsmfile, "", fromdir, dat_ary[i].name, "LSM"); if (isfile (lsmfile)) { lsm_description (8, 2, 10, lsmfile); } else { /* no lsm file. try it again with a plain txt file (or localized version) */ fnmerge (lsmfile, "", fromdir, dat_ary[i].name, ""); gotoxy (2, 8); cat_file (lsmfile, 10 /* no. lines */); } /* Find out which ones the user wants to install */ gotoxy (2, 25); switch (dat_ary[i].rank) { case 'n': case 'N': /* Do not install */ log("<package name=\"%s\" choice=\"n\" />\n", dat_ary[i].name); s = catgets (cat, SET_PKG_NEED, MSG_SKIPPED, MSG_SKIPPED_STR); cputs (s); break; case 'y': case 'Y': /* Always install */ log("<package name=\"%s\" choice=\"y\" ", dat_ary[i].name); s = catgets (cat, SET_PKG_NEED, MSG_REQUIRED, MSG_REQUIRED_STR); cputs (s); ret = unzip_file (dat_ary[i].name, fromdir, destdir); reregisterSIGINTHandler(); /* unzip installs its own SIGINT handler */ if (ret != 0) { /* Print an error message */ s = catgets (cat, SET_PKG_GENERAL, MSG_ERRREQPKG, MSG_ERRREQPKG_STR); cputs (s); log(">\n"); log("<error msg=\"%s\" />\n", s); log("</package>\n"); /* Return an error */ this.errors++; /* Does the user want to continue anyway? */ s = catgets (cat, SET_PROMPT_YN, MSG_CONTINSTDISK, MSG_CONTINSTDISK_STR); ch = select_yn(s, yes, no, NULL, NULL); if (ch) { log("<abort msg=\"User choose not to continue after error.\" />\n"); return (this); } } else /* ret == 0, ie no errors */ log("/>\n"); break; default: /* Optional */ s = catgets (cat, SET_PKG_NEED, MSG_OPTIONAL, MSG_OPTIONAL_STR); cputs (s); /* Ask the user if you want to install it */ s = catgets (cat, SET_PROMPT_YN, MSG_INSTALLPKG, MSG_INSTALLPKG_STR); if (!pkg_yesToAll) { ch = select_yn (s, yes, no, catgets (cat, SET_PROMPT_YN, MSG_YESTOALL, MSG_YESTOALL_STR), NULL); if (ch == 2) pkg_yesToAll = 1; } if (pkg_yesToAll || ch==0) /* Yes or YesToAll */ { log("<package name=\"%s\" choice=\"y\" ", dat_ary[i].name); ret = unzip_file (dat_ary[i].name, fromdir, destdir); reregisterSIGINTHandler(); /* unzip installs its own SIGINT handler */ if (ret != 0) { /* Print a warning message */ gotoxy (2, 13); s = catgets (cat, SET_PKG_GENERAL, MSG_WARNOPTPKG, MSG_WARNOPTPKG_STR); cputs (s); log(">\n"); log("<warning msg=\"%s\" />\n", s); log("</package>\n"); pause(); this.warnings++; } else log("/>\n"); } else /* user selected no */ log("<package name=\"%s\" choice=\"n\" />\n", dat_ary[i].name); break; } /* switch */ } /* for */ /* Print the screen and 100% complete progress bargraph */ repaint_empty(); box (14, 16, 66, 18); gotoxy (15, 17); bargraph (1, 1, 50 /* width */); /* Free memory for this disk */ free (dat_ary); return (this); }
inst_t disk_install(const char *datfile, const char *descfile, char *fromdir, char *destdir) { char *s; char lsmfile[_MAX_PATH]; /* Linux software map file */ int ret; int ch; int i; int dat_size = 30; /* malloc size of the dat array */ int dat_count; /* size of the dat array */ dat_t *dat_ary; /* the DAT array */ inst_t this; /* return: no. of errors,warnings */ /* Initialize variables */ this.errors = 0; this.warnings = 0; /* Read dat file */ dat_ary = malloc (sizeof (dat_t) * dat_size); if (dat_ary == NULL) { fprintf (stderr, "Error!\n"); fprintf (stderr, "Unable to allocate enough memory for install floppy data file!\n"); gotoxy (1, 25); s = catgets (cat, 1, 0, "Press any key to continue"); cputs (s); getch(); return (this); } dat_count = dat_read (datfile, dat_ary, dat_size); if (dat_count < 1) { fprintf (stderr, "Error!\n"); fprintf (stderr, "The install floppy data file is empty!\n"); gotoxy (1, 25); s = catgets (cat, 1, 0, "Press any key to continue"); cputs (s); getch(); free (dat_ary); return (this); } /* Run the install */ for (i = 0; i < dat_count; i++) { /* Print the screen and progress bargraph */ repaint_empty(); gotoxy (15, 20); bargraph (i, dat_count, 50 /* width */); /* Print the package name */ gotoxy (1, 5); s = catgets (cat, 3, 3, "Package: "); cputs (s); cputs (dat_ary[i].name); /* Show the package description */ /* Generate the lsmfile name */ _makepath (lsmfile, "", fromdir, dat_ary[i].name, "LSM"); if (isfile (lsmfile)) { lsm_description (8, 1, 10, lsmfile); } else { /* no lsm file. try it again with a plain txt file */ _makepath (lsmfile, "", fromdir, dat_ary[i].name, "TXT"); if (isfile (lsmfile)) { cat_file (lsmfile, 8 /* start line */, 10 /* no. lines */); } } /* Find out which ones the user wants to install */ gotoxy (1, 23); switch (dat_ary[i].rank) { case 'n': case 'N': /* Do not install */ s = catgets (cat, 4, 2, "SKIPPED"); cputs (s); break; case 'y': case 'Y': /* Always install */ s = catgets (cat, 4, 1, "REQUIRED"); cputs (s); ret = unzip_file (dat_ary[i].name, fromdir, destdir); if (ret != 0) { /* Print an error message */ s = catgets (cat, 3, 6, "ERROR! Failed to install REQUIRED package."); cputs (s); /* Return an error */ this.errors++; /* Does the user want to continue anyway? */ gotoxy (1, 25); s = catgets (cat, 2, 3, "Continue installing this disk? [yn]"); cputs (s); ch = getch_yn(); if ((ch != 'y') && (ch != 'Y')) { return (this); } } break; default: /* Optional */ s = catgets (cat, 4, 0, "OPTIONAL"); cputs (s); /* Ask the user if you want to install it */ gotoxy (1, 23); s = catgets (cat, 2, 4, "Install this package? [yn]"); cputs (s); ch = getch_yn(); if ((ch == 'y') || (ch == 'Y')) { ret = unzip_file (dat_ary[i].name, fromdir, destdir); if (ret != 0) { /* Print a warning message */ gotoxy (1, 23); s = catgets (cat, 3, 7, "WARNING! Failed to install OPTIONAL package."); cputs (s); gotoxy (1, 25); s = catgets (cat, 1, 0, "Press any key to continue"); cputs (s); getch(); this.warnings++; } } break; } /* switch */ } /* for */ /* Free memory for this disk */ free (dat_ary); return (this); }
int main(int argc, char **argv) { int spi_fd; int effect=EFFECT_RANDOM; if (argc>1) { if ((!strncmp(argv[1],"-h",2)) || (!strncmp(argv[1],"help",4))) { help(argv[0]); return 0; } if (!strncmp(argv[1],"bargraph_mannual",15)) { effect=EFFECT_BARGRAPH_MANUAL; } if (!strncmp(argv[1],"bargraph",8)) { effect=EFFECT_BARGRAPH; } if (!strncmp(argv[1],"disable",7)) { effect=EFFECT_DISABLE; } if (!strncmp(argv[1],"falling",7)) { effect=EFFECT_FALLING; } if (!strncmp(argv[1],"fish",4)) { effect=EFFECT_FISH; } if (!strncmp(argv[1],"gradient",8)) { effect=EFFECT_GRADIENT; } if (!strncmp(argv[1],"noise",5)) { effect=EFFECT_NOISE; } if (!strncmp(argv[1],"pulsar",6)) { effect=EFFECT_PULSAR; } if (!strncmp(argv[1],"rainbow",7)) { effect=EFFECT_RAINBOW; } if (!strncmp(argv[1],"stars",5)) { effect=EFFECT_STARS; } if (!strncmp(argv[1],"red_green",9)) { effect=EFFECT_RED_GREEN; } if (!strncmp(argv[1],"blue_yellow",11)) { effect=EFFECT_BLUE_YELLOW; } if (!strncmp(argv[1],"two_color_scroll",15)) { effect=EFFECT_TWO_COLOR_SCROLL; } if (!strncmp(argv[1],"scanner_blinky",14)) { effect=EFFECT_SCANNER_BLINKY; } else if (!strncmp(argv[1],"scanner_dual",12)) { effect=EFFECT_SCANNER_DUAL; } else if (!strncmp(argv[1],"scanner_random",14)) { effect=EFFECT_SCANNER_RANDOM; } else if (!strncmp(argv[1],"scanner",7)) { effect=EFFECT_SCANNER; } } spi_fd=lpd8806_init(); if (spi_fd<0) { exit(-1); } switch(effect) { case EFFECT_BARGRAPH: bargraph(spi_fd,argc>2?argv[2]:NULL, argc>3?argv[3]:NULL); break; case EFFECT_BARGRAPH_MANUAL: bargraph_manual(spi_fd,argc>2?argv[2]:NULL, argc>3?argv[3]:NULL); break; case EFFECT_DISABLE: disable(spi_fd); break; case EFFECT_FALLING: falling(spi_fd, argc>2?argv[2]:NULL, argc>2?argv[3]:NULL); break; case EFFECT_FISH: fish(spi_fd,argc>2?argv[2]:NULL); break; case EFFECT_GRADIENT: gradient(spi_fd,argc>2?argv[2]:NULL); break; case EFFECT_NOISE: noise(spi_fd); break; case EFFECT_PULSAR: pulsar(spi_fd,argc>2?argv[2]:NULL); break; case EFFECT_RAINBOW: rainbow(spi_fd); break; case EFFECT_STARS: stars(spi_fd,argc>2?argv[2]:NULL, argc>3?argv[3]:NULL); break; case EFFECT_TWO_COLOR_SCROLL: two_color_scroll(spi_fd, argc>2?argv[2]:NULL, argc>3?argv[3]:NULL, argc>4?argv[4]:NULL); break; case EFFECT_RED_GREEN: two_color_scroll(spi_fd, "red", "green", "1"); break; case EFFECT_BLUE_YELLOW: two_color_scroll(spi_fd, "blue", "yellow", "0"); break; case EFFECT_SCANNER: scanner(spi_fd,argc>2?argv[2]:NULL); break; case EFFECT_SCANNER_BLINKY: scanner_blinky(spi_fd); break; case EFFECT_SCANNER_DUAL: scanner_dual(spi_fd, argc>2?argv[2]:NULL, argc>3?argv[3]:NULL); break; case EFFECT_SCANNER_RANDOM: scanner_random(spi_fd); break; } lpd8806_close(spi_fd); return 0; }
int main(int argc, char **argv) { int spi_fd; int effect=EFFECT_RANDOM; if (argc>1) { if (!strncmp(argv[1],"-h",2)) { help(argv[0]); return 0; } if (!strncmp(argv[1],"bargraph",8)) { effect=EFFECT_BARGRAPH; } if (!strncmp(argv[1],"rainbow",7)) { effect=EFFECT_RAINBOW; } if (!strncmp(argv[1],"stars",5)) { effect=EFFECT_STARS; } if (!strncmp(argv[1],"red_green",9)) { effect=EFFECT_RED_GREEN; } if (!strncmp(argv[1],"blue_yellow",11)) { effect=EFFECT_BLUE_YELLOW; } if (!strncmp(argv[1],"two_color_scroll",15)) { effect=EFFECT_TWO_COLOR_SCROLL; } } spi_fd=lpd8806_init(); if (spi_fd<0) { exit(-1); } switch(effect) { case EFFECT_BARGRAPH: bargraph(spi_fd,argc>2?argv[2]:NULL, argc>3?argv[3]:NULL); break; case EFFECT_RAINBOW: rainbow(spi_fd); break; case EFFECT_STARS: stars(spi_fd,argc>2?argv[2]:NULL, argc>3?argv[3]:NULL); break; case EFFECT_TWO_COLOR_SCROLL: two_color_scroll(spi_fd, argc>2?argv[2]:NULL, argc>3?argv[3]:NULL, argc>4?argv[4]:NULL); break; case EFFECT_RED_GREEN: two_color_scroll(spi_fd, "red", "green", "1"); break; case EFFECT_BLUE_YELLOW: two_color_scroll(spi_fd, "blue", "yellow", "0"); break; } lpd8806_close(spi_fd); return 0; }