/** * Interactively adjust the backlight on a device * * @param cols The number of columns on the terminal * @param device The device on which to adjust backlight */ static void adjust(int cols, const char* device) { int min, max, cur, step, init, i, d; size_t lendir; char* dir = alloca(PATH_MAX * sizeof(char)); char* buf = alloca(256 * sizeof(char)); *dir = 0; dir = strcat(dir, BACKLIGHT_DIR "/"); dir = strcat(dir, device); dir = strcat(dir, "/"); lendir = strlen(dir); /* Get brightness parameters */ min = 0; if (readfile(buf, strcat(dir, "max_brightness"))) return; max = atoi(unnl(buf)); *(dir + lendir) = 0; if (readfile(buf, strcat(dir, "brightness"))) return; cur = atoi(unnl(buf)); if (max <= min) return; /* what the buck */ step = (max - min) / 200 ?: 1; init = cur; P("\n\n\n\n\n"); bars(min, max, init, cur, cols); while ((d = getchar()) != -1) switch (d) { case 'q': case '\n': case 4: P(""); return; case 'A': case 'C': cur += step << 1; /* fall through */ case 'B': case 'D': cur -= step; if (cur < min) cur = min; if (cur > max) cur = max; if (writefile(buf, cur, dir)) return; bars(min, max, init, cur, cols); } }
void test(uint8_t number) { bars(2); writeString_P("#### TEST #"); writeInteger(number, DEC); writeString_P(" ####\n"); }
void make_color_bars( const image_view_t& view) { typedef detail::color_bars_fn deref_t; typedef deref_t::point_t point_t; typedef boost::gil::virtual_2d_locator<deref_t,false> locator_t; typedef boost::gil::image_view<locator_t> my_virt_view_t; point_t dims( view.width(), view.height()); my_virt_view_t bars( dims, locator_t( point_t(0,0), point_t(1,1), deref_t( dims))); boost::gil::copy_pixels( bars, view); }
int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); Test lvl("Battery.ChargePercentage", print_int); Test bars("Battery.ChargeBars", print_int); Test timelow("Battery.TimeUntilLow", print_ulonglong); Test timefull("Battery.TimeUntilFull", print_ulonglong); Test ischg("Battery.IsCharging", print_bool); Test onbat("Battery.OnBattery", print_bool); Test lowbat("Battery.LowBattery", print_bool); return app.exec(); }
void make_color_bars( const image_view_t& view, const Imath::Box2i& domain, const Imath::Box2i& defined) { typedef detail::color_bars_fn deref_t; typedef deref_t::point_t point_t; typedef boost::gil::virtual_2d_locator<deref_t,false> locator_t; typedef boost::gil::image_view<locator_t> my_virt_view_t; point_t dims( domain.size().x+1, domain.size().y+1); my_virt_view_t bars( dims, locator_t( point_t(0,0), point_t(1,1), deref_t( dims))); boost::gil::copy_pixels( boost::gil::subimage_view( bars, defined.min.x - domain.min.x, defined.min.y - domain.min.y, defined.size().x+1, defined.size().y+1), view); }
void read_data(uint32 datum_count) { uint32 data[datum_count]; data_package pack = {datum_count, data}; for (uint32 cur = 0; cur < datum_count; cur++) { uint32 datum; cgc_read(&datum, sizeof(datum)); data[cur] = datum; } while(1) { transmit_all(STDOUT, "CHRT", 4); transmit_all(STDOUT, (char*)(&datum_count), 4); uint32 choice; cgc_read(&choice, sizeof(choice)); switch(choice) { case 1: sparks(pack); break; case 3: bars(pack); break; case 4: echo(); break; case 5: seed(); break; case 6: noise(); break; case 7: replacer(pack); break; default: _terminate(0); } } }
/* >>>>>>>>>> EX10_3 <<<<<<<<<< */ void ex10_3 (void) { char cbuf[80]; float x[5] = {2., 4., 6., 8., 10.}, y1[5] = {0., 0., 0., 0., 0.}, y2[5] = {3.2, 1.5, 2.0, 1.0, 3.0}; int ic1ray[5] = {50, 150, 100, 200, 175}, ic2ray[5] = {50, 150, 100, 200, 175}; setpag ("da4p"); disini (); pagera (); hwfont (); titlin ("3-D Bar Graph / 3-D Pie Chart", 2); htitle (40); shdpat (16L); axslen (1500, 1000); axspos (300, 1400); barwth (0.5); bartyp ("3dvert"); labels ("second", "bars"); labpos ("outside", "bars"); graf (0., 12., 0., 2., 0., 5., 0., 1.); title (); color ("red"); bars (x, y1, y2, 5); endgrf (); shdpat (16L); labels ("data", "pie"); chnpie ("none"); pieclr (ic1ray, ic2ray, 5); pietyp ("3d"); axspos (300, 2700); piegrf (cbuf, 0, y2, 5); disfin (); }
int main(void) { initRP6Control(); // Always call this first! The Processor will not work // correctly otherwise. bars(2); writeString_P("\n\nRP6Control Selftest!\n\n"); bars(2); setLEDs(0b1111); mSleep(50); initLCD(); showScreenLCD("################", "################"); mSleep(400); showScreenLCD("################", "################"); showScreenLCD("RP6Control M32", "SELFTEST"); mSleep(1000); uint8_t keynumber = 0; while(keynumber < 6) { uint8_t key = checkReleasedKeyEvent(); if(key == keynumber) { keynumber++; showScreenLCD("PRESS BUTTON", "NUMBER "); writeIntegerLCD(keynumber,DEC); setLEDs(0b0000); writeString_P("### PRESS BUTTON NUMBER "); writeInteger(keynumber,DEC); writeString_P("!\n"); } } showScreenLCD("Testing", "BEEPER & LEDS"); mSleep(250); // Play a sound to indicate that our program starts: sound(50,50,100); setLEDs(0b0000); sound(80,50,100); setLEDs(0b0001); sound(100,50,100);setLEDs(0b0010); sound(120,50,100);setLEDs(0b0100); sound(140,50,100);setLEDs(0b1000); sound(160,50,100);setLEDs(0b1001); sound(180,50,100);setLEDs(0b1011); sound(200,50,100);setLEDs(0b1111); mSleep(400); setLEDs(0b0000); showScreenLCD("Testing", "EERPOM"); test(1); writeString_P("\nEEPROM TEST\n"); writeString_P("\nErasing 250 Bytes...\n"); uint8_t cnt; for(cnt = 0; cnt < 250; cnt++) { SPI_EEPROM_writeByte(cnt, 0xFF); while(SPI_EEPROM_getStatus() & SPI_EEPROM_STAT_WIP); } writeString_P("...Done!\nWriting 250 Bytes to EEPROM:\n"); for(cnt = 0; cnt < 250; cnt++) { writeIntegerLength(cnt, DEC, 3); SPI_EEPROM_writeByte(cnt, cnt); while(SPI_EEPROM_getStatus() & SPI_EEPROM_STAT_WIP); writeChar(','); if(cnt % 10 == 0) writeChar('\n'); } mSleep(400); setLEDs(0b1111); writeString_P("\nReading and verifying:\n"); for(cnt = 0; cnt < 250; cnt++) { uint8_t result = SPI_EEPROM_readByte(cnt); if(result != cnt) { writeString_P("\nEEPROM VERIFY ERROR!!!! EEPROM DAMAGED!!!\n"); writeString_P("Data read: "); writeInteger(result,DEC); writeString_P(", should be: "); writeInteger(cnt,DEC); writeChar('\n'); errors++; } else writeIntegerLength(result,DEC,3); writeChar(','); if(cnt % 10 == 0) writeChar('\n'); } writeString_P("\nErasing 250 Bytes...\n"); for(cnt = 0; cnt < 250; cnt++) { SPI_EEPROM_writeByte(cnt, 0xFF); while(SPI_EEPROM_getStatus() & SPI_EEPROM_STAT_WIP); } mSleep(400); setLEDs(0b0000); writeString_P("\nEEPROM TEST DONE!\n"); writeString_P("\nI2C TWI TEST:\n"); showScreenLCD("I2C TWI", "TEST"); I2CTWI_initMaster(100); I2CTWI_setTransmissionErrorHandler(I2C_transmissionError); uint8_t runningLight = 1; for(cnt = 0; cnt < 24; cnt++) { writeIntegerLength(cnt,DEC,3); writeChar(':'); writeIntegerLength(runningLight,DEC,3); writeChar(','); writeChar(' '); I2CTWI_transmit3Bytes(I2C_RP6_BASE_ADR, 0, 3, runningLight); I2CTWI_transmitByte(I2C_RP6_BASE_ADR, 29); uint8_t result = I2CTWI_readByte(I2C_RP6_BASE_ADR); if(result != runningLight) { writeString_P("\nTWI TEST ERROR!\n"); errors++; } runningLight <<= 1; if(runningLight > 32) runningLight = 1; if((cnt+1) % 6 == 0) writeChar('\n'); mSleep(100); } I2CTWI_transmit3Bytes(I2C_RP6_BASE_ADR, 0, 3, 0); writeString_P("\nTWI TEST DONE!\n"); writeString_P("\nMicrophone Test\n"); writeString_P("Hit the Microphone three times with your finger!\n"); showScreenLCD("MIC TEST:", ""); #define PREPARE 1 #define WAIT 2 uint8_t state = PREPARE; startStopwatch2(); while(true) { static uint8_t peak_count = 3; if(state == PREPARE) { if(getStopwatch2() > 250) { setCursorPosLCD(1, 6); writeIntegerLengthLCD( peak_count, DEC, 1); dischargePeakDetector(); state = WAIT; setStopwatch2(0); } } else if(state == WAIT) { uint8_t key = checkReleasedKeyEvent(); if(key) { break; } if(getStopwatch2() > 50) { uint16_t tmp = getMicrophonePeak(); if(tmp > 4) { externalPort.LEDS = 0; uint16_t i; uint8_t j; for(i = 0, j = 2; i < tmp; i+= 40) { if(i < 40) { externalPort.LEDS++; } else { externalPort.LEDS <<=1; externalPort.LEDS++; } } outputExt(); if(tmp > 120) { state = PREPARE; peak_count--; } if(peak_count == 0) break; } else setLEDs(0b0000); setStopwatch2(0); } } } writeString_P("\nMICROPHONE TEST DONE!\n"); showScreenLCD("ALL TESTS", "DONE!"); writeString_P("\n\n\n\n"); bars(2); writeString_P("\n\nALL TESTS DONE!\n\n"); if(errors) { bars(4); writeString_P("\nERROR ERROR ERROR ERROR ERROR ERROR ERROR\n"); writeString_P("\nATTENTION: TESTS FINISHED WITH ERRORS!!!\n"); writeString_P("PLEASE CHECK RP6-M32 ASSEMBLY!!!\n\n"); bars(4); writeString_P("\n\n"); } // Now we just show a running light... startStopwatch1(); uint8_t runLEDs = 1; uint8_t dir = 0; while(true) { if(getStopwatch1() > 100) { setLEDs(runLEDs); if(dir == 0) runLEDs <<= 1; else runLEDs >>= 1; if(runLEDs > 7 ) dir = 1; else if (runLEDs < 2 ) dir = 0; setStopwatch1(0); } }
int main ( int argc, char *argv[] ) /******************************************************************************/ /* Purpose: MAIN demonstrates the use of bar graphs. Modified: 09 April 2011 Reference: Helmut Michels, The Data Plotting Software DISLIN - version 10.4, Shaker Media GmbH, January 2010, ISBN13: 978-3-86858-517-9. */ { static char cbuf[25]; static char *ctit = "Bar Graphs (BARS)"; int i; int nya = 2700; static float x[9] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 }; static float y[9] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; static float y1[9] = { 1.0, 1.5, 2.5, 1.3, 2.0, 1.2, 0.7, 1.4, 1.1 }; static float y2[9] = { 2.0, 2.7, 3.5, 2.1, 3.2, 1.9, 2.0, 2.3, 1.8 }; static float y3[9] = { 4.0, 3.5, 4.5, 3.7, 4.0, 2.9, 3.0, 3.2, 2.6 }; printf ( "\n" ); printf ( "DISLIN_EX05:\n" ); printf ( " C version:\n" ); printf ( " Demonstrate the display of data in bar graphs.\n" ); /* Specify the format of the output file. */ metafl ( "png" ); /* Specify that if a file already exists of the given name, the new data should overwrite the old. */ filmod ( "delete" ); /* Specify the name of the output graphics file. */ setfil ( "dislin_ex05.png" ); /* Choose the page size and orientation. */ setpag ( "usap" ); /* For PNG output, reverse the default black background to white. */ scrmod ( "reverse" ); /* Open DISLIN. */ disini ( ); /* Plot a border around the page. */ pagera ( ); /* Use the COMPLEX font. */ complx ( ); ticks ( 1, "x" ); intax ( ); axslen ( 1600, 700 ); titlin ( ctit, 3 ); legini ( cbuf, 3, 8 ); leglin ( cbuf, "FIRST", 1 ); leglin ( cbuf, "SECOND", 2 ); leglin ( cbuf, "THIRD", 3 ); legtit ( " " ); shdpat ( 5L ); for ( i = 1; i <= 3; i++ ) { if ( 1 < i ) { labels ( "none", "x" ); } axspos ( 300, nya-(i-1)*800 ); graf ( 0.0, 10.0, 0.0, 1.0, 0.0, 5.0, 0.0, 1.0 ); if ( i == 1 ) { bargrp ( 3, 0.15 ); color ( "red" ); bars ( x, y, y1, 9 ); color ( "green" ); bars ( x, y, y2, 9 ); color ( "blue" ); bars ( x, y, y3, 9 ); color ( "fore" ); reset ( "bargrp" ); } else if ( i == 2 ) { height ( 30 ); labels ( "delta", "bars" ); labpos ( "center", "bars" ); color ( "red" ); bars ( x, y, y1, 9 ); color ( "green" ); bars ( x, y1, y2, 9 ); color ( "blue" ); bars ( x, y2, y3, 9 ); color ( "fore" ); reset ( "height" ); } else if ( i == 3 ) { labels ( "second", "bars" ); labpos ( "outside", "bars" ); color ( "red" ); bars ( x, y, y1, 9 ); color ( "fore" ); } if ( i < 3 ) { legend ( cbuf, 7 ); } else { height ( 50 ); title ( ); } endgrf ( ); } /* Close DISLIN. */ disfin ( ); /* Terminate. */ printf ( "\n" ); printf ( "DISLIN_EX05:\n" ); printf ( " Normal end of execution.\n" ); return 0; }
int orus(){ unsigned short y = 1; bars ( y ); int blob = ( 65539 | int (y) ); return blob; //expect 65539, will be 3 if done in us type }
int ors(){ short y = 1; bars ( y ); int blob = ( 27 | int (y) ); return blob; //expect 27 }
bool ConvertKg::save(QString fileName) { QFile f(fileName); if (!f.open(QIODevice::WriteOnly)) return FALSE; QDataStream s(&f); // HEADER SIGNATURE s.writeRawData("KG\0", 3); // VERSION SIGNATURE s << (quint8) 2; // HEADER SONG DATA s << song->info["TITLE"]; s << song->info["ARTIST"]; s << song->info["TRANSCRIBER"]; s << song->info["COMMENTS"]; s << song->tempo; // TRACK DATA s << song->rowCount(); // Number of tracks bool needfx = FALSE; // Should we write FX event after tab? // For every track //foreach (TabTrack *trk, song->t) { for(int row = 0; row < song->rowCount(); row++) { auto trk = song->index(row, 0).data(TabSong::TrackPtrRole).value<TabTrack*>(); s << (quint8) trk->trackMode();// Track properties s << trk->name; s << (quint8) trk->channel; s << (quint16) trk->bank; s << (quint8) trk->patch; s << (quint8) trk->string; s << (quint8) trk->frets; for (int i = 0; i<trk->string; i++) s << (quint8) trk->tune[i]; // TRACK EVENTS quint8 tcsize = trk->string+2; uint bar = 1; s << (quint8) 'S'; // Time signature event s << (quint8) 3; // 3 byte event length s << (quint8) trk->bars()[0].time1; // Time signature itself s << (quint8) trk->bars()[0].time2; s << (qint8) trk->bars()[0].keysig; for (uint x = 0; x < trk->c.size(); x++) { if (bar+1 < trk->bars().size()) { // This bar's not last if ((uint)trk->bars()[bar+1].start == x) bar++; // Time for next bar } if ((bar < (uint)trk->bars().size()) && ((uint)trk->bars()[bar].start == x)) { s << (quint8) 'B'; // New bar event s << (quint8) 0; if ((trk->bars()[bar].time1 != trk->bars()[bar - 1].time1) || (trk->bars()[bar].time2 != trk->bars()[bar - 1].time2)) { s << (quint8) 'S'; // New signature s << (quint8) 2; s << (quint8) trk->bars()[bar].time1; s << (quint8) trk->bars()[bar].time2; } } if (trk->c[x].flags & FLAG_ARC) { s << (quint8) 'L'; // Continue of previous event s << (quint8) 2; // Size of event s << trk->c[x].fullDuration(); // Duration } else { s << (quint8) 'T'; // Tab column events s << (quint8) tcsize; // Size of event needfx = FALSE; for (int i = 0;i < trk->string; i++) { s << (qint8) trk->c[x].a[i]; if (trk->c[x].e[i]) needfx = TRUE; } s << trk->c[x].fullDuration(); // Duration if (needfx) { s << (quint8) 'E'; // Effect event s << (quint8) trk->string; // Size of event for (int i = 0; i < trk->string; i++) s << (quint8) trk->c[x].e[i]; } if (trk->c[x].effectFlags()) { s << (quint8) 'F'; // Flag event s << (quint8) 1; // Size of event s << (quint8) trk->c[x].effectFlags(); } } } s << (quint8) 'X'; // End of track marker s << (quint8) 0; // Length of end track event } f.close(); return TRUE; }
/* >>>>>>>>>> EX10_1 <<<<<<<<<< */ void ex10_1 (void) { int nya = 2700, i; static char *ctit = "Bar Graphs (BARS)", cbuf[25]; static float x[9] = {1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f}, y[9] = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f}, y1[9] = {1.f, 1.5f, 2.5f, 1.3f, 2.0f, 1.2f, 0.7f, 1.4f, 1.1f}, y2[9] = {2.f, 2.7f, 3.5f, 2.1f, 3.2f, 1.9f, 2.0f, 2.3f, 1.8f}, y3[9] = {4.f, 3.5f, 4.5f, 3.7f, 4.0f, 2.9f, 3.0f, 3.2f, 2.6f}; setpag ("da4p"); disini (); pagera (); hwfont (); ticks (1, "x"); intax ();; axslen (1600, 700); titlin (ctit, 3); legini (cbuf, 3, 8); leglin (cbuf, "FIRST", 1); leglin (cbuf, "SECOND", 2); leglin (cbuf, "THIRD", 3); legtit (" "); shdpat (5L); for (i = 1; i <= 3; i++) { if (i > 1) labels ("none", "x"); axspos (300, nya - (i - 1) * 800); graf (0.f, 10.f, 0.f, 1.f, 0.f, 5.f, 0.f, 1.f); if (i == 1) { bargrp (3, 0.15f); color ("red"); bars (x, y, y1, 9); color ("green"); bars (x, y, y2, 9); color ("blue"); bars (x, y, y3, 9); color ("fore"); reset ("bargrp"); } else if (i == 2) { height (30); labels ("delta", "bars"); labpos ("center", "bars"); color ("red"); bars (x, y, y1, 9); color ("green"); bars (x, y1, y2, 9); color ("blue"); bars (x, y2, y3, 9); color ("fore"); reset ("height"); } else if (i == 3) { labels ("second", "bars"); labpos ("outside", "bars"); color ("red"); bars (x, y, y1, 9); color ("fore"); } if (i != 3) legend (cbuf, 7); if (i == 3) { height (50); title (); } endgrf (); } disfin (); }