int main() { //PROFILER_OUTPUT_FILE("results.txt") PROFILER_CALL std::cout << "Hello World !" << std::endl; wait_for_it(500); why(); wait_for_it(500); return 0; }
int main() { init_timer(); init_SPI(); init_ATX_power(); sei(); enable_ATX_power(); repeat_LEDs_off(); uint32_t d = ROTATION_SECONDS * 1000L / (6 * 127); wait_for_it(d); #if 0 while (true) { for (uint8_t i = 0; i < 6; i++) { for (uint8_t j = 0; j < 127; j++) { wait_for_it(0); uint8_t r, g, b; calc_color(i, j, &r, &g, &b); set_LEDs_color(r, g, b); } } } #else while (true) { for (uint8_t i = 0; i < 6; i++) { for (uint8_t j = 0; j < 127; j++) { wait_for_it(0); begin_LEDs_refresh(); for (uint8_t p = 0; p < PIXEL_COUNT; p++) { uint8_t r=0, g=0, b=0; uint8_t ii = i, jj = j + 4 * p; if (jj >= 127) { jj -= 127; if (++ii == 6) ii = 0; } calc_color(ii, jj, &r, &g, &b); set_pixel_color(r, g, b); } end_LEDs_refresh(); } } } #endif }
/* the correct response to a return value of 0 is almost certainly tlscomm_close(scs): don't _expect() anything unless anything else would represent failure */ int tlscomm_expect(struct connection_state *scs, const char *prefix, char *linebuf, int buflen) { int prefixlen = (int) strlen(prefix); int buffered_bytes = 0; memset(linebuf, 0, buflen); TDM(DEBUG_INFO, "%s: expecting: %s\n", scs->name, prefix); /* if(scs->unprocessed[0]) { TDM(DEBUG_INFO, "%s: buffered: %s\n", scs->name, scs->unprocessed); } */ while (scs->unprocessed[0] != '\0' || wait_for_it(scs->sd, EXPECT_TIMEOUT)) { if (scs->unprocessed[buffered_bytes] == '\0') { int thisreadbytes; #ifdef USE_GNUTLS if (scs->tls_state) { /* BUF_SIZE - 1 leaves room for trailing \0 */ thisreadbytes = gnutls_read(scs->tls_state, &scs->unprocessed[buffered_bytes], BUF_SIZE - 1 - buffered_bytes); if (thisreadbytes < 0) { handle_gnutls_read_error(thisreadbytes, scs); return 0; } } else #endif { thisreadbytes = read(scs->sd, &scs->unprocessed[buffered_bytes], BUF_SIZE - 1 - buffered_bytes); if (thisreadbytes < 0) { TDM(DEBUG_ERROR, "%s: error reading: %s\n", scs->name, strerror(errno)); return 0; } } buffered_bytes += thisreadbytes; /* force null termination */ scs->unprocessed[buffered_bytes] = '\0'; if (buffered_bytes == 0) { return 0; /* bummer */ } } else { buffered_bytes = strlen(scs->unprocessed); } while (buffered_bytes >= prefixlen) { int linebytes; linebytes = getline_from_buffer(scs->unprocessed, linebuf, buflen); if (linebytes == 0) { buffered_bytes = 0; } else { buffered_bytes -= linebytes; if (strncmp(linebuf, prefix, prefixlen) == 0) { TDM(DEBUG_INFO, "%s: got: %*s", scs->name, linebytes, linebuf); return 1; /* got it! */ } TDM(DEBUG_INFO, "%s: dumped(%d/%d): %.*s", scs->name, linebytes, buffered_bytes, linebytes, linebuf); } } } if (buffered_bytes == -1) { TDM(DEBUG_INFO, "%s: timed out while expecting '%s'\n", scs->name, prefix); } else { TDM(DEBUG_ERROR, "%s: expecting: '%s', saw (%d): %s%s", scs->name, prefix, buffered_bytes, linebuf, /* only print the newline if the linebuf lacks it */ (linebuf[strlen(linebuf) - 1] == '\n') ? "\n" : ""); } return 0; /* wait_for_it failed */ }