Beispiel #1
0
float
Mipmapping::initVariant(std::uint8_t level, std::uint32_t x, std::uint32_t y)
{
	assert(0 != x && 0 != y);
	assert(x < getSize() && y < getSize());

	float var[10] = { 0 };

	int iter = 0;

	if (level > 1)
	{
		int size = 1 << (level - 2);

		var[iter++] = initVariant(level - 1, x + size, y + size);
		var[iter++] = initVariant(level - 1, x - size, y + size);
		var[iter++] = initVariant(level - 1, x - size, y - size);
		var[iter++] = initVariant(level - 1, x + size, y - size);
	}

	int size = 1 << (level - 1);

	float lu = getHeight(x - size, y + size);
	float ld = getHeight(x - size, y - size);
	float ru = getHeight(x + size, y + size);
	float rd = getHeight(x + size, y - size);

	float left = (lu + ld) * 0.5f;
	float right = (ru + rd) * 0.5f;
	float up = (ru + lu) * 0.5f;
	float down = (rd + ld) * 0.5f;
	float center = (lu + rd) * 0.5f;

	var[iter++] = abs(getHeight(x - size, y) - left);
	var[iter++] = abs(getHeight(x + size, y) - right);
	var[iter++] = abs(getHeight(x, y + size) - up);
	var[iter++] = abs(getHeight(x, y - size) - down);
	var[iter++] = abs(getHeight(x, y) - center);

	float max = var[0];
	for (int i = 0; i < 10; i++)
	{
		if (max < var[i])
		{
			max = var[i];
		}
	}

	pVariant_.resize((std::size_t)max);

	return max;
}
/*
 * \brief Main entry point of Arduino application
 */
int main( void )
{
  /* Initialize watchdog */
  watchdogSetup();

  /* Initialize the Arduino Core API */
  init();

  /* Initialize the variant */
  initVariant();

  delay(1);
#if defined(USBCON)
  USBDevice.init();
  USBDevice.attach();
#endif

  setup();

  for (;;)
  {
    loop();
    if (serialEventRun) serialEventRun();
  }

  return 0;
}
void arduino_init(void) {
    uart_div_modify(0, UART_CLK_FREQ / (115200));

    init();  //disable uart0 debug, init wiring system: pins, timer1

    initVariant();

    cont_init(&g_cont);

    system_os_task(loop_task, LOOP_TASK_PRIORITY, g_loop_queue, LOOP_QUEUE_SIZE);

    system_init_done_cb(&init_done);
}
Beispiel #4
0
int main(void)
{
	__djgpp_set_ctrl_c(0);

	initVariant();
	
	setup();

	for (;;)
	{
		loop();
		if (serialEventRun) serialEventRun();
	}	
	return 0;
}
Beispiel #5
0
/*
 * \brief Main entry point of Arduino application
 */
int main( void )
{
    init();
 
    initVariant();

    osThreadDef(main_task, osPriorityRealtime, 1, 4096*4);
    main_tid = osThreadCreate (osThread (main_task), NULL);

    osKernelStart();

    while(1);

    return 0;
}
Beispiel #6
0
int main(int argc, char **argv)
{
	CMD.setArguments(argc, argv);

	init();

	initVariant();

	setup();
    
	for (;;) {
		loop();
		if (serialEventRun) serialEventRun();
	}
        
	return 0;
}
Beispiel #7
0
extern "C" void user_init(void) {
    struct rst_info *rtc_info_ptr = system_get_rst_info();
    memcpy((void *) &resetInfo, (void *) rtc_info_ptr, sizeof(resetInfo));

    uart_div_modify(0, UART_CLK_FREQ / (115200));

    init();

    initVariant();

    cont_init(&g_cont);

    system_os_task(loop_task,
        LOOP_TASK_PRIORITY, g_loop_queue,
        LOOP_QUEUE_SIZE);

    system_init_done_cb(&init_done);
}
Beispiel #8
0
int main(void)
{
	init();

	initVariant();

#if defined(USBCON)
	USBDevice.attach();
#endif
	
	setup();
    
	for (;;) {
		loop();
		if (serialEventRun) serialEventRun();
	}
        
	return 0;
}
int main( void )
{
  init();

  initVariant();

  delay(1);

  setup();

  for (;;)
  {
    loop();
    check_for_reset();
    if (serialEventRun) serialEventRun();
  }

  return 0;
}
Beispiel #10
0
bool
Mipmapping::init(HeightMap* T)
{
	setMap(T);

	std::uint32_t size = getSize();

	if (!bits_.create(size, size))
	{
		return false;
	}

	pVariant_.resize(size, size);

	std::uint32_t x = size >> 1;
	std::uint32_t y = size >> 1;

	initVariant(getDepth(), x, y);

	return true;
}
Beispiel #11
0
int main(void) {

#if defined(CORE_TEENSY)
        _init_Teensyduino_internal_();
#else
#if ARDUINO >= 106
        initVariant();
#endif
        init();
#if defined(USBCON)
        USBDevice.attach();
#endif
#endif


#if EXT_RAM
        xmem::begin(EXT_RAM_HEAP, EXT_RAM_STACK);
#if EXT_RAM_STACK
        if(xmem::getTotalBanks() == 0) goto no;
        if(XMEM_STACK_TOP == XRAMEND) goto no;
        noInterrupts();
        asm volatile ( "ldi     16, %0" ::"i" (XMEM_STACK_TOP >> 8));
        asm volatile ( "out     %0,16" ::"i" (AVR_STACK_POINTER_HI_ADDR));
        asm volatile ( "ldi     16, %0" ::"i" (XMEM_STACK_TOP & 0x0ff));
        asm volatile ( "out     %0,16" ::"i" (AVR_STACK_POINTER_LO_ADDR));
        interrupts();
#endif
no:
#endif
        setup();

        for(;;) {
                loop();
#if !defined(CORE_TEENSY)
                if(serialEventRun) serialEventRun();
#endif
        }

        return 0;
}
Beispiel #12
0
int main(void)
{

  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration----------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* Configure the system clock */
  SystemClock_Config();

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_CAN_Init();
  MX_I2C1_Init();
  MX_SPI1_Init();
  MX_USART1_UART_Init();
  MX_USART3_UART_Init();

  /* USER CODE BEGIN 2 */
  /* these calls are from arduino main */

	init();

	initVariant();
	
	HAL_Delay(3000); 	/* Wait 3 seconds to enable a serial coms channel */
	
	/* 
		Usart6 is linked to printf for diagnostic use It is also mapped to
		alternate function pins 12 and 14.  This code is adapted from
		the prinf demo in the STM32F401 Nucleo examples folder
	*/
	
	//printf("Serial backchannel enabled.\r\n");
  
  	/* Arduino optionally sets up USB callback stream here 
#if defined(USBCON)
	USBDevice.attach();
#endif
	*/
	
	setup();

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */
	loop();
	/* Arduino callback	if (serialEventRun) serialEventRun(); */

  }
  /* USER CODE END 3 */

}
/*
 * Set up and initialize hardware prior to call to main() in main.cpp
 * This is where we initialize basic system resources that any
 * board with this chip should have initialized
 */
void Board_SystemInit(void)
{
	// Initialization done in Board_Init() in arduino-xc-lpc13xx
	initVariant();
}