Example #1
0
/** @brief Function for main application entry.
 */
int main(void)
{
		spi_buffer_t spi_buffer[NUM_SPI_BUS];
	
		rgb_led_t led_array[NUM_LEDS];
	
		uint32_t current_limit;
		float dim;
	
		// Configure on-board LED-pins as outputs.
		LEDS_CONFIGURE(LEDS_MASK);

		// Initialize spi I/F
		for(uint8_t i=0;i<NUM_SPI_BUS;i++) {
			ws2812b_driver_spi_init(i, &spi[i]);
		}

		for(uint8_t i=0;i<NUM_SPI_BUS;i++) {
				alloc_spi_buffer(&spi_buffer[i], NUM_LEDS);
		}

		LEDS_ON(1 << leds_list[0]);
		LEDS_ON(1 << leds_list[1]);
		LEDS_ON(1 << leds_list[2]);
		LEDS_ON(1 << leds_list[3]);
	
		for(;;)
		{
			LEDS_INVERT(1 << leds_list[2]);

			for(int8_t idemo=0;idemo<size_of_list;idemo++)
			{
				LEDS_INVERT(1 << leds_list[1]);
				
				demo_list[idemo].function_init();
				
				int32_t rest = demo_list[idemo].demo_period;
				int32_t rap  = 0;
				int32_t step = demo_list[idemo].wait_ms + demo_list[idemo].process_time;
				
				while( rest > 0 )
				{
					LEDS_INVERT(1 << leds_list[0]);


					// animate and set up led_array_work 
					demo_list[idemo].function_update(led_array,rap);
					
					// dim LEDs until current limit 
					current_limit = CURRENT_LIMIT;
					ws2812b_driver_current_cap(led_array, NUM_LEDS, current_limit);

					// fade in/out effect
					if ( (demo_list[idemo].demo_period - rest) < FADE_IN_MS )
					{
						dim = (float)0.01+((float)0.99 * ((demo_list[idemo].demo_period - rest)/(float)FADE_IN_MS));
					}
					else if ( rest < FADE_IN_MS) 
					{
						dim = (float)0.01+((float)0.99 * (rest/(float)FADE_IN_MS));
					}
					if ( dim > (float)1.0 ) {
						dim = 1.0;
					}
					
					ws2812b_driver_dim(led_array, NUM_LEDS, dim);
					
					// LED update
					ws2812b_driver_xfer(led_array, spi_buffer[0], spi[0]);
					
					// delay (LED will be updated this period)
					nrf_delay_ms(demo_list[idemo].wait_ms);

					//
					rest -= step;
					rap += step;
				}

				// blank 3sec. between demos
				set_blank(led_array,NUM_LEDS);
				ws2812b_driver_xfer(led_array, spi_buffer[0], spi[0]);

				// delay (LED will be updated this period)
				nrf_delay_ms(3000);
			} // idemo
		} // end-less loop
}
Example #2
0
void gpio_init( void )
{
    nrf_gpio_range_cfg_output(8, 15);
    LEDS_CONFIGURE(LEDS_MASK);
}
Example #3
0
File: main.c Project: IOIOI/nRF51
/**@brief Function for the LEDs initialization.
 *
 * @details Initializes all LEDs used by the application.
 */
static void leds_init(void)
{
    LEDS_CONFIGURE(ADVERTISING_LED_PIN | CONNECTED_LED_PIN | LEDBUTTON_LED_PIN);
    LEDS_OFF(ADVERTISING_LED_PIN | CONNECTED_LED_PIN | LEDBUTTON_LED_PIN);
}
Example #4
0
File: main.c Project: JulianYG/WNR
/**
 * @brief Function for main application entry.
 */
int main(void)
{
    LEDS_CONFIGURE(LEDS_MASK);
    LEDS_OFF(LEDS_MASK);
    uint32_t err_code;
    const app_uart_comm_params_t comm_params =
      {
          RX_PIN_NUMBER,
          TX_PIN_NUMBER,
          RTS_PIN_NUMBER,
          CTS_PIN_NUMBER,
          APP_UART_FLOW_CONTROL_ENABLED,
          false,
          UART_BAUDRATE_BAUDRATE_Baud38400
      };

    APP_UART_FIFO_INIT(&comm_params,
                         UART_RX_BUF_SIZE,
                         UART_TX_BUF_SIZE,
                         uart_error_handle,
                         APP_IRQ_PRIORITY_LOW,
                         err_code);

    APP_ERROR_CHECK(err_code);

  //  printf("\n\rStart: \n\r");
		for(int time_ctr = 0; time_ctr <100000; time_ctr ++);


 //   printf("INPUT_BUFFER_SIZE: %u\r\n", HEATSHRINK_STATIC_INPUT_BUFFER_SIZE);
	//		for(int time_ctr = 0; time_ctr <100000; time_ctr ++);
  //  printf("WINDOW_BITS: %u\r\n", HEATSHRINK_STATIC_WINDOW_BITS);
	//		for(int time_ctr = 0; time_ctr <100000; time_ctr ++);
  //  printf("LOOKAHEAD_BITS: %u\r\n", HEATSHRINK_STATIC_LOOKAHEAD_BITS);
	//	for(int time_ctr = 0; time_ctr <100000; time_ctr ++);
 //   printf("sizeof(heatshrink_encoder): %zd\r\n", sizeof(heatshrink_encoder));
	//	for(int time_ctr = 0; time_ctr <100000; time_ctr ++);
 //   printf("sizeof(heatshrink_decoder): %zd\r\n", sizeof(heatshrink_decoder));
	//	for(int time_ctr = 0; time_ctr <100000; time_ctr ++);
			
 //   for (uint32_t size=4; size < 2048; size <<= 1) {
      pseudorandom_data_should_match(256);
//    }
//		printf("done\r\n");
    while(1);
		
    while (true)
    {
        uint8_t cr;
   //     while(app_uart_get(&cr) != NRF_SUCCESS);

        //uint8_t input[COMPRESSION_BUF_SIZE];
    	//fill_with_patient_data(input,size);
				
        while(app_uart_put(cr) != NRF_SUCCESS);

        if (cr == 'q' || cr == 'Q')
        {
            printf(" \n\rExit!\n\r");

            while (true)
            {
                // Do nothing.
            }
        }
    }
}