extern "C" int main() { pinMode(LED_BUILTIN, OUTPUT); leds.begin(); // Announce firmware version serial_begin(BAUD2DIV(115200)); serial_print("Fadecandy v" DEVICE_VER_STRING "\r\n"); // Application main loop while (usb_dfu_state == DFU_appIDLE) { watchdog_refresh(); buffers.handleUSB(); updateDrawBuffer(calculateInterpCoefficient()); leds.show(); // Optionally disable dithering by clearing our residual buffer every frame. if (buffers.flags & CFLAG_NO_DITHERING) { for (unsigned i = 0; i < CHANNELS_TOTAL; ++i) residual[i] = 0; } } // Reboot into DFU bootloader dfu_reboot(); }
/* Configuración de pines de entrada/salida */ void setup() { TRISB=0; //defino PORTB como salida PORTB=0; PORTD=0; pinmode(ICR_DIG1,INPUT); pinmode(ICR_DIG2,INPUT); /* si se activa el sensor de ultra sonido, funciona como salida*/ pinmode(ICR_DIG3,TRIG); pinmode(ICR_DIG4,ECHO); pinmode(ICR_l293_P1,OUTPUT); pinmode(ICR_l293_P2,OUTPUT); pinmode(ICR_l293_P3,OUTPUT); pinmode(ICR_l293_P4,OUTPUT); ServoAttach(ICR_SRV1); ServoAttach(ICR_SRV2); ServoAttach(ICR_SRV3); ServoAttach(ICR_SRV4); ServoAttach(ICR_SRV5); #if defined(__USART__) serial_begin(9600); Delayms(1000); #endif #if defined(__LCD__) //Uso el PORTB para el LCD (usando los primeros 4bits y los // otros dos para RS y E lcd(4, 5, 0, 1, 2, 3, 0, 0, 0, 0); // RS, E, D4 ~ D8 // Defino el numero de columnas y filas del LCD: begin(8, 2); home(); #endif }
void setup() { for (i=0;i<8;i++) { pinmode(i,OUTPUT); digitalwrite(i,LOW); } serial_begin(9600); }
irom void setup() { serial_begin(115200); if (!bmp085_begin()) { serial_print("Could not find a valid BMP085 sensor,\ check wiring!\r\n"); while (1) {} }
irom void setup() { serial_begin(115200); //disable the wifi wifi_set_opmode(NULL_MODE); pinMode(ledPower,OUTPUT); digitalWrite(ledPower,HIGH); serial_printf("Sharp GP2Y1010AU0F Particle Sensor Example\r\n"); }
extern "C" int main() { pinMode(LED_BUILTIN, OUTPUT); leds.begin(); // Announce firmware version serial_begin(BAUD2DIV(115200)); serial_print("Fadecandy v" DEVICE_VER_STRING "\r\n"); // Application main loop while (usb_dfu_state == DFU_appIDLE) { watchdog_refresh(); // Select a different drawing loop based on our firmware config flags switch (buffers.flags & (CFLAG_NO_INTERPOLATION | CFLAG_NO_DITHERING)) { case 0: default: updateDrawBuffer_I1_D1(calculateInterpCoefficient()); break; case CFLAG_NO_INTERPOLATION: updateDrawBuffer_I0_D1(0x10000); break; case CFLAG_NO_DITHERING: updateDrawBuffer_I1_D0(calculateInterpCoefficient()); break; case CFLAG_NO_INTERPOLATION | CFLAG_NO_DITHERING: updateDrawBuffer_I0_D0(0x10000); break; } // Start sending the next frame over DMA leds.show(); // We can switch to the next frame's buffer now. buffers.finalizeFrame(); // Performance counter, for monitoring frame rate externally perf_frameCounter++; } // Reboot into DFU bootloader dfu_reboot(); }
// Arduino master setup void setup(void) { // set font for the console window u8g.setFont(u8g_font_6x10); // set upper left position for the string draw procedure u8g.setFontPosTop(); // calculate the number of rows for the display rows = u8g.getHeight() / u8g.getFontLineSpacing(); if (rows > ROW_MAX) rows = ROW_MAX; // estimate the number of columns for the display cols = u8g.getWidth() / u8g.getStrWidth("m"); if (cols > LINE_MAX - 1) cols = LINE_MAX - 1; clear_screen(); // clear screen delay(1000); // do some delay serial_begin(115200); // init serial exec_line(); // place the input buffer into the screen reset_line(); // clear input buffer }
int main(void) { int i; char buf[BUFSZ + 1]; init(); serial_init(); softserial_init(2, 3); serial_begin(&serial[0], 19200); softserial_begin(&sserial, 19200); serial_write(&serial[0], "\r\n", 2); while(1) { i = serial_read(&serial[0], buf, BUFSZ); if(i > 0) { softserial_write(&sserial, buf, i); } i = softserial_read(&sserial, buf, BUFSZ); if(i > 0) { serial_write(&serial[0], buf, i); } } return 0; }
void setup() { serial_begin(9600); }
int main(void) { uint8_t count = 0; uint8_t buf[64]; #if defined(BUTTERFLY) butterfly_init(); #endif // NOTE: If BUTTERFLY is defined then the serial_being() is bypassed // and the usart is set to 19200 regardless of what this says serial_begin(57600); /* buf[0] = 'H'; buf[1] = 'o'; buf[2] = 'w'; buf[3] = 'd'; buf[4] = 'y'; buf[5] = 0; serial_write(buf,6); // Insert a delay to keep this from stepping on the next statement delay(10); */ serial_out("Hello70"); // Send a bunch of stuff to see if it poops out serial_out("serial_println The quick brown fox jumped over the lazy dog."); serial_out("serial_out The quick brown fox jumped over the lazy dog.\n",0); serial_out("1serial_out The quick brown fox jumped over the lazy dog.\n",0); serial_out("2serial_out The quick brown fox jumped over the lazy dog.\n",0); serial_out("3serial_out The quick brown fox jumped over the lazy dog.\n",0); serial_out("4serial_out The quick brown fox jumped over the lazy dog.\n",0); serial_out("5serial_out The quick brown fox jumped over the lazy dog.\n",0); char c = 'A'; uint8_t x = 0x22; uint16_t X = 0x1122; serial_out("Test character: %c\n", c); serial_out("Test hexadecimal integer: %x\n", x); serial_out("Test 16-bit hexadecimal integer: %x\n", X); while(1) { delay(1000); usart0_transmit_buffer_insert('#'); if(serial_available()) { count = usart0_receive_buffer_inuse_count(); for(int i = 0 ; i < count; i++) { buf[i] = serial_in(); //usart0_transmit_buffer_insert(serial_read());//usart0_receive_buffer_remove()); } serial_write(buf,count); // Test serial_flush /* serial_write(buf,count); serial_flush(); serial_write(buf,count); */ // Test usart0_uninit() /* _delay_ms(500); serial_out("Before serial_end()\n",0); serial_end(); serial_out("After serial_end()\n",0); serial_begin(57600); serial_out("After serial_begin(57600)\n",0); */ } } }
extern "C" int main() { uint32_t last = systick_millis_count; uint32_t lastRender = 0; uint16_t i = 0; uint16_t j = 0; uint8_t index = 0; uint8_t startIndex = 0; pinMode(LED_BUILTIN, OUTPUT); for (i = 0; i < LUT_TOTAL_SIZE; i++) { buffers.lutCurrent.entries[i] = defaultLUT[i] >> 1;// (i % LUT_CH_SIZE) << 7; } #ifdef RAINBOW_LANTERNS int16_t numSteps = 64; #endif leds.begin(); rainbow10[0] = rainbow7[0] = color(0xFF, 0, 0); rainbow10[1] = rainbow7[1] = color(0xFF, 0xA5, 0); rainbow10[2] = rainbow7[2] = color(0xFF, 0xFF, 0); rainbow10[3] = rainbow7[3] = color(0, 0x80, 0); rainbow10[4] = color(0, 0xFF, 0); rainbow10[5] = color(0, 0xA5, 0x80); rainbow10[6] = rainbow7[4] = color(0, 0, 0xFF); rainbow10[7] = rainbow7[5] = color(0x4B, 0, 0x82); rainbow10[8] = rainbow7[6] = color(0xFF, 0, 0xFF); rainbow10[9] = color(0xEE, 0x82, 0xEE); buffers.flags = CFLAG_NO_ACTIVITY_LED; //buffers.flags |= CFLAG_LED_CONTROL; // Announce firmware version serial_begin(BAUD2DIV(115200)); serial_print("Fadecandy v" DEVICE_VER_STRING "\r\n"); //usb_serial_printf("test\n"); // Application main loop while (usb_dfu_state == DFU_appIDLE) { watchdog_refresh(); // Select a different drawing loop based on our firmware config flags switch (buffers.flags & (CFLAG_NO_INTERPOLATION | CFLAG_NO_DITHERING)) { case 0: default: updateDrawBuffer_I1_D1(calculateInterpCoefficient()); break; case CFLAG_NO_INTERPOLATION: updateDrawBuffer_I0_D1(0x10000); break; case CFLAG_NO_DITHERING: updateDrawBuffer_I1_D0(calculateInterpCoefficient()); break; case CFLAG_NO_INTERPOLATION | CFLAG_NO_DITHERING: updateDrawBuffer_I0_D0(0x10000); break; } //buffers.flags |= CFLAG_NO_ACTIVITY_LED; // Start sending the next frame over DMA leds.show(); if ((systick_millis_count - last) > 500) { //buffers.flags ^= CFLAG_LED_CONTROL; last = systick_millis_count; } #ifdef RAINBOW_CIRCLE if ((systick_millis_count - lastRender) > 500) { buffers.flags ^= CFLAG_LED_CONTROL; lastRender = systick_millis_count; index = startIndex; for (i = 0; i < 52/*32*/; i++) { uint8_t* pixel = buffers.fbNew->pixel(LEDS_PER_STRIP * 7 + i); uint32_t color = rainbow7[index]; pixel[0] = RED(color); pixel[1] = GREEN(color); pixel[2] = BLUE(color); index = (index + 1) % 7; } for (i = 0; i < 20; i++) { uint8_t* pixel = buffers.fbNew->pixel(LEDS_PER_STRIP * 6 + i); uint32_t color = rainbow7[index]; pixel[0] = RED(color); pixel[1] = GREEN(color); pixel[2] = BLUE(color); index = (index + 1) % 7; } startIndex = (startIndex + 1) % 7; buffers.finalizeFramebuffer(); } #endif #ifdef RAINBOW_TOPHAT (void)j; if ((systick_millis_count - lastRender) > 500) { buffers.flags ^= CFLAG_LED_CONTROL; lastRender = systick_millis_count; index = startIndex; for (i = 0; i < 52/*32*/; i++) { uint8_t* pixel = buffers.fbNew->pixel(LEDS_PER_STRIP * 7 + i); uint32_t color = rainbow7[index]; pixel[0] = RED(color); pixel[1] = GREEN(color); pixel[2] = BLUE(color); if (i>0 && i % 5 == 0) { index = (index + 1) % 7; } } for (i = 0; i < 20; i++) { uint8_t* pixel = buffers.fbNew->pixel(LEDS_PER_STRIP * 6 + i); uint32_t color = rainbow7[index]; pixel[0] = RED(color); pixel[1] = GREEN(color); pixel[2] = BLUE(color); index = (index + 1) % 7; } startIndex = (startIndex + 1) % 7; buffers.finalizeFramebuffer(); } #endif #ifdef RAINBOW_LANTERNS /*(void)j; (void)index; (void)startIndex; if ((systick_millis_count - lastRender) > 500) { buffers.flags ^= CFLAG_LED_CONTROL; lastRender = systick_millis_count; for (i = 0; i < 20; i++) { uint8_t* pixel = buffers.fbNew->pixel(LEDS_PER_STRIP * 7 + i); int16_t direction = directions[i] < 0 ? -1 : 1; uint32_t color1 = rainbow7[indexes[i]]; int16_t index2 = indexes[i] + direction; if (index2 < 0) { index2 = 6; } else if (index2 >= 7) { index2 = 0; } uint32_t color2 = rainbow7[index2]; int32_t reddiff = RED(color2) - RED(color1); int32_t bluediff = BLUE(color2) - BLUE(color1); int32_t greendiff = GREEN(color2) - BLUE(color1); reddiff *= steps[i]; reddiff /= numSteps; bluediff *= steps[i]; bluediff /= numSteps; greendiff *= steps[i]; greendiff /= numSteps; pixel[0] = RED(color1) + reddiff; pixel[1] = GREEN(color1) + greendiff; pixel[2] = BLUE(color1) + bluediff; steps[i] += abs(directions[i]); if (steps[i] >= numSteps) { steps[i] = 0; indexes[i] = index2; } } buffers.finalizeFramebuffer(); }*/ (void)j; (void)numSteps; if ((systick_millis_count - lastRender) > 5000) { buffers.flags ^= CFLAG_LED_CONTROL; lastRender = systick_millis_count; index = startIndex; for (i = 0; i < 20/*32*/; i++) { uint8_t* pixel = buffers.fbNew->pixel(LEDS_PER_STRIP * 7 + i); uint32_t color = rainbow7[index]; pixel[0] = RED(color); pixel[1] = GREEN(color); pixel[2] = BLUE(color); if (i>0 && i % 2 == 0) { index = (index + 1) % 7; } } for (i = 0; i < 20; i++) { uint8_t* pixel = buffers.fbNew->pixel(LEDS_PER_STRIP * 6 + i); uint32_t color = rainbow7[index]; pixel[0] = RED(color); pixel[1] = GREEN(color); pixel[2] = BLUE(color); index = (index + 1) % 7; } startIndex = (startIndex + 1) % 7; buffers.finalizeFramebuffer(); } #endif #ifdef PARASOL if ((systick_millis_count - lastRender) > 500) { buffers.flags ^= CFLAG_LED_CONTROL; lastRender = systick_millis_count; index = startIndex; for (i = 0; i < 8; i++) { for (j = 0; j < 3; j++) { uint8_t* pixel = buffers.fbNew->pixel(LEDS_PER_STRIP * i + j); uint32_t color = rainbow7[index]; pixel[0] = RED(color); pixel[1] = GREEN(color); pixel[2] = BLUE(color); } index = (index + 1) % 7; } startIndex = (startIndex + 1) % 7; buffers.finalizeFramebuffer(); } #endif #ifdef SMOOTH_RAINBOW (void)startIndex; (void)j; if ((systick_millis_count - lastRender) > 30) { lastRender = systick_millis_count; uint32_t ledIndex = 0; if (index >= 16) { buffers.flags ^= CFLAG_LED_CONTROL; index = 0; } index++; float color1[3]; float color2[3]; for (i = 0; i < 32; i++) { uint8_t* pixel = buffers.fbNew->pixel(LEDS_PER_STRIP * 7 + i); pixel[0] = 0xFF; pixel[1] = 0; pixel[2] = 0; float scaled = ledIndex / 44.0f; //fix16_t noise = 32768; (void)scaled; float noise = .5f + noise2(scaled, time); //float noise = .5f + fbm_noise3(scaled, time, .5f, 4, .25f, 2.0f); noise = fmax(fmin(1, noise), 0); float mult = 9 * noise; float index1 = floor(mult); float index2 = ceil(mult); float percent = mult - index1; uint32_t color = rainbow10[(int)index1]; color1[0] = RED(color); color1[1] = GREEN(color); color1[2] = BLUE(color); color = rainbow10[(int)index2]; color2[0] = RED(color); color2[1] = GREEN(color); color2[2] = BLUE(color); pixel[0] = (uint8_t)((int)(color1[0] + ((color2[0] - color1[0]) * percent)) & 0xFF); pixel[1] = (uint8_t)((int)(color1[1] + ((color2[1] - color1[1]) * percent)) & 0xFF); pixel[2] = (uint8_t)((int)(color1[2] + ((color2[2] - color1[2]) * percent)) & 0xFF); ledIndex++; } /* for (i = 0; i < 12; i++) { uint8_t* pixel = buffers.fbNew->pixel(LEDS_PER_STRIP * 6 + i); pixel[0] = 0xFF; pixel[1] = 0; pixel[2] = 0; float scaled = ledIndex / 44.0f; (void)scaled; float noise = 32768; //noise2(scaled, time); //fix16_t noise = 32768 + noise2(scaled, time); //fix16_t noise = 32768 + fbm_noise3(scaled, time, 0, 4, 16384, 131072); noise = fmax(fmin(noise, 1), 0); float mult = 9 * noise; float index1 = floor(mult); float index2 = ceil(mult); float percent = mult - index1; (void)index2; (void)percent; uint32_t color = rainbow10[1];// fix16_to_int(index1)]; color1[0] = RED(color); color1[1] = GREEN(color); color1[2] = BLUE(color); color = rainbow10[2];// fix16_to_int(index2)]; color2[0] = RED(color); color2[1] = GREEN(color); color2[2] = BLUE(color); pixel[0] = (uint8_t)((int)(color1[0] + ((color2[0] - color1[0]) * percent)) & 0xFF); pixel[1] = (uint8_t)((int)(color1[1] + ((color2[1] - color1[1]) * percent)) & 0xFF); pixel[2] = (uint8_t)((int)(color1[2] + ((color2[2] - color1[2]) * percent)) & 0xFF); ledIndex++; } */ time = (time + timestep); buffers.finalizeFramebuffer(); } #endif // We can switch to the next frame's buffer now. buffers.finalizeFrame(); // Performance counter, for monitoring frame rate externally perf_frameCounter++; } // Reboot into DFU bootloader dfu_reboot(); }
void setup() { serial_begin(115200); }
void setup_output() { serial_begin(SBUS_PORT, 100000); }