Пример #1
0
int main(int argc, char **argv)
{
   fade(argc, argv);

}
Пример #2
0
 inline constexpr real noise(
     const real x = 0.0,
     const real y = 0.0,
     const real z = 0.0
 ){
     static_assert(
         std::is_floating_point<real>::value, 
         "real must be a floating point type"
     );
     const auto unit_x = (int)floor(x) & 255,
                unit_y = (int)floor(y) & 255,
                unit_z = (int)floor(z) & 255;
     const auto sub_x = x - floor(x),
                sub_y = y - floor(y),
                sub_z = z - floor(z);
     const auto u = fade(sub_x),
                v = fade(sub_y),
                w = fade(sub_z);
     const auto a = perm[unit_x] + unit_y,
               aa = perm[a] + unit_z,
               ab = perm[a + 1] + unit_z,
                b = perm[unit_x + 1] + unit_y,
               ba = perm[b] + unit_z,
               bb = perm[b + 1] + unit_z;
     return lerp(w,
         lerp(
             v,
             lerp(
                 u,
                 grad(
                     perm[aa],
                     sub_x,
                     sub_y,
                     sub_z
                 ),
                 grad(
                     perm[ba],
                     sub_x - 1,
                     sub_y,
                     sub_z
                 )
             ),
             lerp(
                 u,
                 grad(
                     perm[ab],
                     sub_x,
                     sub_y - 1,
                     sub_z
                 ),
                 grad(
                     perm[bb],
                     sub_x - 1,
                     sub_y - 1,
                     sub_z
                 )
             )
         ),
         lerp(
             v,
             lerp(
                 u,
                 grad(
                     perm[aa + 1],
                     sub_x,
                     sub_y,
                     sub_z - 1
                 ),
                 grad(
                     perm[ba + 1],
                     sub_x - 1,
                     sub_y,
                     sub_z - 1
                 )
             ),
             lerp(
                 u,
                 grad(
                     perm[ab + 1],
                     sub_x,
                     sub_y - 1,
                     sub_z - 1
                 ),
                 grad(
                     perm[bb + 1],
                     sub_x - 1,
                     sub_y - 1,
                     sub_z - 1
                 )
             )
         )
     );
 }
Пример #3
0
int main()
{
	volatile signed int i, aColumn, aLevel, mask, mux, patterncntr;

	patterncntr = 0;
	Hold = 0;

	InitPorts();
	CARDinit();
	USARTinit();

	while (1) 
	{
	
		while (patterncntr < numanimas)
		{
			X = 0;
			eX = 0;
			XChanged = 0;
			dX = pgm_read_byte(&AnimationA[patterncntr].hold);
			fademode = pgm_read_byte(&AnimationA[patterncntr].fade);

			for (i = 0; i < MaxLedPins; i++)
			{	
				eY[i] = 0;
				/*
				aDivRes = div(i, LedPinsPerLevel);
				aLevel = aDivRes.quot;
				aLedPin = i;
				aLedPin %= LedPinsPerLevel;
				*/
			  	YStart = pgm_read_byte(&AnimationA[patterncntr].pwm[i]);
				PWM[i] = YStart;
				if (patterncntr < numanimas-1) idx = patterncntr+1; else idx = 0;
				YEnd = pgm_read_byte(&AnimationA[idx].pwm[i]);
				dY[i] = YEnd-YStart;		 
			}
			Hold = 0;

			while (Hold <= pgm_read_byte(&AnimationA[patterncntr].hold))
			{
				
				if (fademode > 0) fade();

				for (i=0; i<=PWMres; i++)
				{	
					
					CARDloop();
					USARTloop();
					
					mux = MaxMux;
					while (mux > 0)
					{
						mux--;
						for (aColumn = LedPinsPerColumn-1; aColumn >= 0; aColumn--)
						{	
							mask = 0;
							aLevel = MaxLevels;
							while (aLevel > 0)
							{	
								aLevel--;
								idx = aColumn+mux * LedPinsPerColumn + aLevel * LedPinsPerLevel;
								if (i < PWM[idx]) mask |= (1 << aLevel);
							}
							SetLevelPins(mask);
			
						}
						switch (mux)
						{
							case 0 :
							   SetLevelPins(15);
							   SetLevelPins(0);
							   SetLevelPins(0);
							   SetLevelPins(0);
							   break;
							case 1 :
							   SetLevelPins(0);
							   SetLevelPins(15);
							   SetLevelPins(0);
							   SetLevelPins(0);
							   break;
							case 2 :
							   SetLevelPins(0);
							   SetLevelPins(0);
							   SetLevelPins(15);
							   SetLevelPins(0);
							   break;
							case 3 :
							   SetLevelPins(0);
							   SetLevelPins(0);
							   SetLevelPins(0);
							   SetLevelPins(15);
							   break;
						}
						i = i;	
						Latch();
					}		
				}
			if (fademode == 0)	Hold++;	
			} 
			Hold = 0;
			patterncntr++;	
		}
		patterncntr = 0;
	}
}
Пример #4
0
void Chore::fadeOut(uint msecs) {
	// Note: It doesn't matter whether the chore is playing or not. The keyframe
	// components should fade out in either case.
	fade(Animation::FadeOut, msecs);
}
Пример #5
0
double ClassicNoise::NoiseFunc(double xx, double yy, double zz)
{
    // Find unit grid cell containing point
    int X = floor(xx);
    int Y = floor(yy);
    int Z = floor(zz);

    // Get relative xyz coordinates of point within that cell
    double x = xx - X;
    double y = yy - Y;
    double z = zz - Z;

    // Wrap the integer cells at 255 (smaller integer period can be introduced here)
    X = X & 255;
    Y = Y & 255;
    Z = Z & 255;

    // Calculate a set of eight hashed gradient indices
    int p_z1 = permutations[Z];
    int p_z2 = permutations[Z + 1];
    int p_y1 = permutations[(Y + p_z1) % 256];
    int p_y2 = permutations[(Y + p_z2) % 256];
    int p_y3 = permutations[(Y + 1 + p_z1) % 256];
    int p_y4 = permutations[(Y + 1 + p_z2) % 256];
    int gi000 = permutations[(X + p_y1) % 256] % 12;
    int gi001 = permutations[(X + p_y2) % 256] % 12;
    int gi010 = permutations[(X + p_y3) % 256] % 12;
    int gi011 = permutations[(X + p_y4) % 256] % 12;
    int gi100 = permutations[(X + 1 + p_y1) % 256] % 12;
    int gi101 = permutations[(X + 1 + p_y2) % 256] % 12;
    int gi110 = permutations[(X + 1 + p_y3) % 256] % 12;
    int gi111 = permutations[(X + 1 + p_y4) % 256] % 12;

    // The gradients of each corner are now:
    // g000 = grad3[gi000];
    // g001 = grad3[gi001];
    // g010 = grad3[gi010];
    // g011 = grad3[gi011];
    // g100 = grad3[gi100];
    // g101 = grad3[gi101];
    // g110 = grad3[gi110];
    // g111 = grad3[gi111];

    // Calculate noise contributions from each of the eight corners
    double n000 = dot(gradients[gi000], x, y, z);
    double n100 = dot(gradients[gi100], x - 1, y, z);
    double n010 = dot(gradients[gi010], x, y - 1, z);
    double n110 = dot(gradients[gi110], x - 1, y - 1, z);
    double n001 = dot(gradients[gi001], x, y, z - 1);
    double n101 = dot(gradients[gi101], x - 1, y, z - 1);
    double n011 = dot(gradients[gi011], x, y - 1, z - 1);
    double n111 = dot(gradients[gi111], x - 1, y - 1, z - 1);

    // Compute the fade curve value for each of x, y, z
    double u = fade(x);
    double v = fade(y);
    double w = fade(z);

    // Interpolate along x the contributions from each of the corners
    double nx00 = mix(n000, n100, u);
    double nx01 = mix(n001, n101, u);
    double nx10 = mix(n010, n110, u);
    double nx11 = mix(n011, n111, u);

    // Interpolate the four results along y
    double nxy0 = mix(nx00, nx10, v);
    double nxy1 = mix(nx01, nx11, v);

    // Interpolate the two last results along z
    double nxyz = mix(nxy0, nxy1, w);

    return nxyz;
}
Пример #6
0
int main() {
    // The physical computations run at about 1500 Hz. 30 consecutive
    // time steps are mixed into a frame buffer for motion blur. But
    // this is not only about motion blur. This higher temporal resolution
    // is necessary to avoid discretization errors to grow too large and
    // to keep the whole thing "stable".
    //
    // The framebuffer is "oversampled" (higher resolution) for
    // anti-aliasing.
    const int num_particles = 10;
    const int substeps = 30; // temporal oversampling
    const int sover = 5; // spatial oversampling

    std::srand(std::time(0));
    std::vector<particle> ps;
    ps.push_back( // bottom border particle that is not moving
        make_particle(
            make_random_color(),
            -1
        )
    );
    for (int i = 0; i < num_particles; ++i) {
        ps.push_back( // almost equidistantly spaced particles
            make_particle(
                make_random_color(),
                (i + 0.9f + 0.2f * uniform_random()) / (1 + num_particles) * (num_leds + 1) - 1
            )
        );
    }
    ps.push_back( // top border particle that is not moving
        make_particle(
            make_random_color(),
            num_leds
        )
    );

    std::vector<int> framebuff (num_leds * 3 * sover);
    std::vector<unsigned char> scratch;
    int time = -1;
    int period = 10000; // time steps until next impulse
    int part_change_color_index = 1;
    color part_change_color_new = {{0}}, part_change_color_old = {{0}};
#ifdef WRITE_PPM
    const int iters = 500; // for debugging purposes
    write_binary_ppm_header(num_leds, iters, std::cout);
    for (int i = 0; i < iters; ++i) {
#else
    for (;;) {
#endif
        // blank frame buffer (black)
        std::fill(framebuff.begin(), framebuff.end(), 0);
        for (int s = 0; s < substeps; ++s) {
            render_frame(ps, sover, substeps, framebuff);
            time = (time + 1) % period;
            if (time <= 1000) { // impulse phase
                if (time == 0) {
                    period = 5000 + std::rand() % 10000;
                    part_change_color_index = (std::rand() % num_particles) + 1;
                    part_change_color_old = ps[part_change_color_index].col;
                    part_change_color_new = make_random_color();
                }
                float s1 = squared(std::sin(time * (3.14159265 / 2000)));
                float s2 = squared(std::sin(time * (3.14159265 / 1000)));
                ps[0].pos = s2 * 15 - 1; // move bottom particle around
                // also change the color of a random particle once in a while
                ps[part_change_color_index].col = fade(
                    part_change_color_old,
                    part_change_color_new, s1);
            }
            update_accels(ps);
            progress(ps);
        }
        write_frame(framebuff, 1.0f/substeps, sover, scratch, std::cout);
#ifndef WRITE_PPM
        usleep(20000); // wait 20 ms (=> about 50 frames/sec)
#endif
    }
    return 0;
}
Пример #7
0
int 
main(int argc, char **argv) 
{
  int windX=10;
  int windY=30;
  int windWidth=uiWidth;
  int windHeight=uiHeight;
  int c;
  int xx, xy;
  opterr = 0;

  /*
  KAboutData aboutData( "kscdmagic", I18N_NOOP("kscdmagic"),
			KSCDMAGICVERSION, I18N_NOOP("sound visualisation"), 
			KAboutData::License_GPL,
			"(c) 2000, Dirk Försterling");
  aboutData.addAuthor("Paul Harrison",0, "*****@*****.**");
  aboutData.addAuthor("Dirk Försterling",0, "*****@*****.**");

  KCmdLineArgs::init( argc, argv, &aboutData );

  KApplication magicApp;
  */


  openSound(SourceCD, 44100, "/dev/dsp", NULL);

  catchSignals();

  while ((c = getopt(argc, argv, "b:h:w:")) != -1){
    switch (c)
      {
      case '?':
	fprintf(stderr, "%s: unknown option \"%s\"\n", 
		argv[0], argv[optind-1]);
	usage(argv[0]);
	exit(1);	
      case 'b':
	bright = (double) atoi(optarg);
	bright = bright/10;
	break;
      case 'w':
	windWidth = atoi(optarg);
	break;
      case 'h':
	windHeight = atoi(optarg);
	break;
      }
  }
  
  if (bright > 1.0)
    bright = 1.0;
  else if (bright < 0.0)
    bright = 0.0;
  
  if (windWidth < 1)
    windWidth = uiWidth;
  if (windHeight < 1)
    windHeight = uiHeight;

  screenInit(windX,windY,windWidth,windHeight);

  allocOutput(outWidth,outHeight);

  coreInit();
  

  setStarSize(starSize);
  setBrightness(bright);

  time_t timer = time(NULL);
  
  int frames = 0;

  for(;;) {
    fade();
    if (-1 == coreGo())
      break;

    polygonEngine.clear();

    for( xy = 0; xy < 48; xy++)
      {
	for( xx = 0; xx < 48; xx++)
	  {
	    if ( logo[xy][xx] != 0)
	      {
		polygonEngine.add(32769, xx+10, xy+3);
	      }
	  }
      }
    polygonEngine.apply(outputBmp.data);
    screenShow(); 



    frames++;
    if(processUserInput() == -1)
      break;
  } 

  
  timer = time(NULL) - timer;
  delete ucoutput;
  closeSound();
  
  if (timer > 10)
    fprintf(stderr,"Frames per second: %f\n", double(frames)/timer);
  
  return 0;
} // main() /* linux */
/*---------------------------------------------------------------------------*/
int
main(void)
{

    /* Hardware initialization */
    bus_init();
    rtimer_init();

    stack_poison();

    /* model-specific h/w init. */
    model_init();

    /* Init LEDs here */
    leds_init();
    fade(LEDS_GREEN);

    /* initialize process manager. */
    process_init();

    /* Init UART1 */
    uart1_init();

#if DMA_ON
    dma_init();
#endif

#if SLIP_ARCH_CONF_ENABLE
    /* On cc2430, the argument is not used */
    slip_arch_init(0);
#else
    uart1_set_input(serial_line_input_byte);
    serial_line_init();
#endif

    PUTSTRING("##########################################\n");
    putstring(CONTIKI_VERSION_STRING "\n");
    putstring(SENSINODE_MODEL " (CC24");
    puthex(((CHIPID >> 3) | 0x20));
    putstring("-" FLASH_SIZE ")\n");

#if STARTUP_VERBOSE
#ifdef HAVE_SDCC_BANKING
    PUTSTRING("  With Banking.\n");
#endif /* HAVE_SDCC_BANKING */
#ifdef SDCC_MODEL_LARGE
    PUTSTRING("  --model-large\n");
#endif /* SDCC_MODEL_LARGE */
#ifdef SDCC_MODEL_HUGE
    PUTSTRING("  --model-huge\n");
#endif /* SDCC_MODEL_HUGE */
#ifdef SDCC_STACK_AUTO
    PUTSTRING("  --stack-auto\n");
#endif /* SDCC_STACK_AUTO */

    PUTCHAR('\n');

    PUTSTRING(" Net: ");
    PUTSTRING(NETSTACK_NETWORK.name);
    PUTCHAR('\n');
    PUTSTRING(" MAC: ");
    PUTSTRING(NETSTACK_MAC.name);
    PUTCHAR('\n');
    PUTSTRING(" RDC: ");
    PUTSTRING(NETSTACK_RDC.name);
    PUTCHAR('\n');

    PUTSTRING("##########################################\n");
#endif

    watchdog_init();

    /* Initialise the cc2430 RNG engine. */
    random_init(0);

    /* start services */
    process_start(&etimer_process, NULL);
    ctimer_init();

    /* initialize the netstack */
    netstack_init();
    set_rime_addr();

#if BUTTON_SENSOR_ON || ADC_SENSOR_ON
    process_start(&sensors_process, NULL);
    sensinode_sensors_activate();
#endif

#if NETSTACK_CONF_WITH_IPV6
    memcpy(&uip_lladdr.addr, &linkaddr_node_addr, sizeof(uip_lladdr.addr));
    queuebuf_init();
    process_start(&tcpip_process, NULL);

#if DISCO_ENABLED
    process_start(&disco_process, NULL);
#endif /* DISCO_ENABLED */

#if VIZTOOL_CONF_ON
    process_start(&viztool_process, NULL);
#endif

#if (!UIP_CONF_IPV6_RPL)
    {
        uip_ipaddr_t ipaddr;

        uip_ip6addr(&ipaddr, 0x2001, 0x630, 0x301, 0x6453, 0, 0, 0, 0);
        uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
        uip_ds6_addr_add(&ipaddr, 0, ADDR_TENTATIVE);
    }
#endif /* UIP_CONF_IPV6_RPL */
#endif /* NETSTACK_CONF_WITH_IPV6 */

    /*
     * Acknowledge the UART1 RX interrupt
     * now that we're sure we are ready to process it
     */
    model_uart_intr_en();

    energest_init();
    ENERGEST_ON(ENERGEST_TYPE_CPU);

    fade(LEDS_RED);

#if BATMON_CONF_ON
    process_start(&batmon_process, NULL);
#endif

    autostart_start(autostart_processes);

    watchdog_start();

    while(1) {
        uint8_t r;
        do {
            /* Reset watchdog and handle polls and events */
            watchdog_periodic();

#if CLOCK_CONF_STACK_FRIENDLY
            if(sleep_flag) {
                if(etimer_pending() &&
                        (etimer_next_expiration_time() - clock_time() - 1) > MAX_TICKS) {
                    etimer_request_poll();
                }
                sleep_flag = 0;
            }
#endif
            r = process_run();
        } while(r > 0);
#if NETSTACK_CONF_SHORTCUTS
        len = NETSTACK_RADIO.pending_packet();
        if(len) {
            packetbuf_clear();
            len = NETSTACK_RADIO.read(packetbuf_dataptr(), PACKETBUF_SIZE);
            if(len > 0) {
                packetbuf_set_datalen(len);
                NETSTACK_RDC.input();
            }
        }
#endif

#if LPM_MODE
#if (LPM_MODE==LPM_MODE_PM2)
        SLEEP &= ~OSC_PD;            /* Make sure both HS OSCs are on */
        while(!(SLEEP & HFRC_STB));  /* Wait for RCOSC to be stable */
        CLKCON |= OSC;               /* Switch to the RCOSC */
        while(!(CLKCON & OSC));      /* Wait till it's happened */
        SLEEP |= OSC_PD;             /* Turn the other one off */
#endif /* LPM_MODE==LPM_MODE_PM2 */

        /*
         * Set MCU IDLE or Drop to PM1. Any interrupt will take us out of LPM
         * Sleep Timer will wake us up in no more than 7.8ms (max idle interval)
         */
        SLEEP = (SLEEP & 0xFC) | (LPM_MODE - 1);

#if (LPM_MODE==LPM_MODE_PM2)
        /*
         * Wait 3 NOPs. Either an interrupt occurred and SLEEP.MODE was cleared or
         * no interrupt occurred and we can safely power down
         */
        __asm
        nop
        nop
        nop
        __endasm;

        if(SLEEP & SLEEP_MODE0) {
#endif /* LPM_MODE==LPM_MODE_PM2 */

            ENERGEST_SWITCH(ENERGEST_TYPE_CPU, ENERGEST_TYPE_LPM);

            /* We are only interested in IRQ energest while idle or in LPM */
            ENERGEST_IRQ_RESTORE(irq_energest);

            /* Go IDLE or Enter PM1 */
            PCON |= IDLE;

            /* First instruction upon exiting PM1 must be a NOP */
            __asm
            nop
            __endasm;

            /* Remember energest IRQ for next pass */
            ENERGEST_IRQ_SAVE(irq_energest);

            ENERGEST_SWITCH(ENERGEST_TYPE_LPM, ENERGEST_TYPE_CPU);

#if (LPM_MODE==LPM_MODE_PM2)
            SLEEP &= ~OSC_PD;            /* Make sure both HS OSCs are on */
            while(!(SLEEP & XOSC_STB));  /* Wait for XOSC to be stable */
            CLKCON &= ~OSC;              /* Switch to the XOSC */
            /*
             * On occasion the XOSC is reported stable when in reality it's not.
             * We need to wait for a safeguard of 64us or more before selecting it
             */
            clock_delay_usec(65);
            while(CLKCON & OSC);         /* Wait till it's happened */
        }
#endif /* LPM_MODE==LPM_MODE_PM2 */
#endif /* LPM_MODE */
    }
}
Пример #9
0
GameState* GameScreen::update()
{
    switch (status) {
    case START:
        if (fade(true)) status = NORMAL;
        return nullptr;
    case END:
        if (fade(false)) return new WinState(game, alive, score);
        return nullptr;
    case QUIT:
        return new MainMenu(game);
    }

    if (music.getStatus() == sf::Music::Stopped) music.play();
    delta = clock.restart().asSeconds();

    // Decrement score every second.
    timer += delta;
    if (timer >= 1) {
        score--;
        timer = 0;
    }

    sf::Event event;
    while (game->get_window().pollEvent(event))
        if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::P)
            game->push_state(new PauseState(game, this));

    status = END;
    alive = false;
    for (Entity *e : entities) {
        e->update(delta);
        if (Player *p = dynamic_cast<Player*>(e)) {
            status = NORMAL;
            alive = true;
            center_view(p);
            // Are we at the end of the current tilemap? Load next one if it exists. Else quit.
            if (level.getGoal().intersects(p->getBounds())) {
                if (level.hasNext()) {
                    p->transition();
                    game->push_state(new TransitionState(game, this));
                }
                else {
                    p->transition();
                    status = END;
                }
            }
        }
    }

    // Remove destroyed entities.
    // Erase-remove idiom
    // https://en.wikipedia.org/wiki/Erase%E2%80%93remove_idiom
    entities.erase( std::remove_if(std::begin(entities), std::end(entities),
                    [](Entity *entity) {
                        if (entity->isDestroyed()) {
                            delete entity;
                            return true;
                        }
                        return false;
                    }),
                    std::end(entities));

    // Add new entities from queue.
    for (Entity *e : queue) entities.push_back(std::move(e));
    queue.clear();

    scoretext.setString("Score: " + std::to_string(score));
    scoretext.setPosition(sf::Vector2f(view.getCenter().x, view.getCenter().y - WINDOW_HEIGHT / 2));

    return nullptr;
}
int main(void) {
  t_gravity_particles gravity_particles;
  t_particle_system* particle_system;
  t_particle* p;
  int i;
  
  show_msgbox(
    "Ndless - Particle System Demo",
    "------------------------\n"
    "       Particle System Demo\n" \
    "© 2010-2011 by the Ndless Team\n"
    "------------------------\n"
    "+  Add a particle\n"
    "-  Remove a particle\n"
    "*  Increase gravity\n"
    "/  Decrease gravity\n"
    "C  Enable/Disable collision detection\n"
    "T  Enable/Disable trace mode\n"
    "S  Clear screen\n"
    "ESC - Exit"
  );

	if (is_classic) { // programs are started with the screen cleared on non-classic
		void *scrbuf = malloc(SCREEN_BYTES_SIZE);
		memcpy(scrbuf, SCREEN_BASE_ADDRESS, SCREEN_BYTES_SIZE);
	  for (i = 0; i < 0x0F; ++i) {
	    fade(scrbuf, 1);
	    sleep(70);
	    if (isKeyPressed(KEY_NSPIRE_ESC)) {
	    	free(scrbuf);
	    	return 0;
	    }
	  }
	  free(scrbuf);
	}
	
	clrscr();
	lcd_ingray();

  gravity_particles_construct(&gravity_particles, 0.00006672f, 100);
  particle_system = &(gravity_particles.particleSystem);
  particle_system->detectCol = false;
  particle_system->trace = false;
  particle_system_start(particle_system);

  p = particle_construct3(&(t_vector){0.f, 0.f, 0.f}, &(t_vector){0.f, 0.f, 0.f}, 1500.f, 4, BLACK);
  (void) particle_system_addParticle(particle_system, p);
  add_particle(&gravity_particles);

  while (!isKeyPressed(KEY_NSPIRE_ESC)) {
    gravity_particles_draw(&gravity_particles);

    // Add a particule (+)
    if (isKeyPressed(KEY_NSPIRE_PLUS)) {
      if (particle_system->nParticles == 0) {
        p = particle_construct3(&(t_vector){0.f, 0.f, 0.f}, &(t_vector){0.f, 0.f, 0.f}, 1500.f, 4, BLACK);
        (void) particle_system_addParticle(particle_system, p);
      }
      add_particle(&gravity_particles);
      while (isKeyPressed(KEY_NSPIRE_PLUS));
    }

    // Remove a particle (-)
    if (isKeyPressed(KEY_NSPIRE_MINUS)) {
      remove_particle(&gravity_particles);
      while (isKeyPressed(KEY_NSPIRE_MINUS));
    }

    // High gravity (*)
    if (isKeyPressed(KEY_NSPIRE_MULTIPLY)) {
      gravity_particles.gravitationalConstant *= 10.f;
      while (isKeyPressed(KEY_NSPIRE_MULTIPLY));
    }

    // Low gravity (/)
    if (isKeyPressed(KEY_NSPIRE_DIVIDE)) {
      gravity_particles.gravitationalConstant /= 10.f;
      while (isKeyPressed(KEY_NSPIRE_DIVIDE));
    }

    // Collision (C)
    if (isKeyPressed(KEY_NSPIRE_C)) {
      particle_system->detectCol = !particle_system->detectCol;
      while (isKeyPressed(KEY_NSPIRE_C));
    }

    // Collision (T)
    if (isKeyPressed(KEY_NSPIRE_T)) {
      particle_system->trace = !particle_system->trace;
      while (isKeyPressed(KEY_NSPIRE_T));
    }

    // Collision (S)
    if (isKeyPressed(KEY_NSPIRE_S)) {
      clearScreen();
      while (isKeyPressed(KEY_NSPIRE_S));
    }
  }

  gravity_particles_destruct(&gravity_particles);

  return 0;
}
/**
 * \brief Main routine for the cc2538dk platform
 */
int
main(void)
{
  nvic_init();
  sys_ctrl_init();
  clock_init();
  dint();
  /*Init Watchdog*/
  watchdog_init();//Need to check the watchdog on 123gxl

  rtimer_init();
  lpm_init();  
  gpio_init();
  ioc_init();

  leds_init();
  fade(LEDS_YELLOW);
  button_sensor_init();

  /*
   * Character I/O Initialisation.
   * When the UART receives a character it will call serial_line_input_byte to
   * notify the core. The same applies for the USB driver.
   *
   * If slip-arch is also linked in afterwards (e.g. if we are a border router)
   * it will overwrite one of the two peripheral input callbacks. Characters
   * received over the relevant peripheral will be handled by
   * slip_input_byte instead
   */
#if UART_CONF_ENABLE
  uart_init(0);
  uart_init(1);
  uart_set_input(SERIAL_LINE_CONF_UART, serial_line_input_byte);
#endif

#if USB_SERIAL_CONF_ENABLE
  usb_serial_init();
  usb_serial_set_input(serial_line_input_byte);
#endif

  serial_line_init();

  /*Enable EA*/
  eint();
  INTERRUPTS_ENABLE();
  fade(LEDS_GREEN);
  PRINTF("=================================\r\n");
  PUTS(CONTIKI_VERSION_STRING);
  PRINTF("======================\r\n");  
  PRINTF("\r\n");
  PUTS(BOARD_STRING);
  PRINTF("\r\n");

#ifdef NODEID
  node_id = NODEID;
#ifdef BURN_NODEID
  node_id_burn(node_id);
  node_id_restore(); /* also configures node_mac[] */
#endif /* BURN_NODEID */
#else
  node_id_restore(); /* also configures node_mac[] */
#endif /* NODE_ID */

  /* for setting "hardcoded" IEEE 802.15.4 MAC addresses */
#ifdef MAC_1
  {
    uint8_t ieee[] = { MAC_1, MAC_2, MAC_3, MAC_4, MAC_5, MAC_6, MAC_7, MAC_8 };
    memcpy(node_mac, ieee, sizeof(uip_lladdr.addr));
  }
#endif

  /*
   * Initialize Contiki and our processes.
   */
  process_init();
  process_start(&sensors_process, NULL);
  button_sensor_init();

  process_start(&etimer_process, NULL);

  ctimer_init();

  set_rime_addr();
  printf("finish addr seting\r\n");

  /* Initialise the H/W RNG engine. */
  random_init(0);

  udma_init();

  if(node_id > 0) {
    printf("Node id %u.\r\n", node_id);
  } else {
    printf("Node id not set.\r\n");
  }

#if WITH_UIP6
  memcpy(&uip_lladdr.addr, node_mac, sizeof(uip_lladdr.addr));
  /* Setup nullmac-like MAC for 802.15.4 */

  queuebuf_init();

  netstack_init();
  PRINTF("CC2538 IEEE802154 PANID %d\r\n", IEEE802154_PANID);  
  cc2538_rf_set_addr(IEEE802154_PANID);

  printf("%s/%s %lu %u\r\n",
         NETSTACK_RDC.name,
         NETSTACK_MAC.name,
         CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0 ? 1:
                         NETSTACK_RDC.channel_check_interval()),
         RF_CHANNEL);

  process_start(&tcpip_process, NULL);

  printf("IPv6 ");
  {
    uip_ds6_addr_t *lladdr;
    int i;
    lladdr = uip_ds6_get_link_local(-1);
    for(i = 0; i < 7; ++i) {
      printf("%02x%02x:", lladdr->ipaddr.u8[i * 2],
             lladdr->ipaddr.u8[i * 2 + 1]);
    }
    printf("%02x%02x\r\n", lladdr->ipaddr.u8[14], lladdr->ipaddr.u8[15]);
  }

  if(1) {
    uip_ipaddr_t ipaddr;
    int i;
    uip_ip6addr(&ipaddr, 0xfc00, 0, 0, 0, 0, 0, 0, 0);
    uip_ds6_set_addr_iid(&ipaddr, &uip_lladdr);
    uip_ds6_addr_add(&ipaddr, 0, ADDR_TENTATIVE);
    printf("Tentative global IPv6 address ");
    for(i = 0; i < 7; ++i) {
      printf("%02x%02x:",
             ipaddr.u8[i * 2], ipaddr.u8[i * 2 + 1]);
    }
    printf("%02x%02x\r\n",
           ipaddr.u8[7 * 2], ipaddr.u8[7 * 2 + 1]);
  }

#else /* WITH_UIP6 */

  netstack_init();
  PRINTF("CC2538 IEEE802154 PANID %d\r\n", IEEE802154_PANID);  
  cc2538_rf_set_addr(IEEE802154_PANID);
  
  printf("%s %lu %u\r\n",
         NETSTACK_RDC.name,
         CLOCK_SECOND / (NETSTACK_RDC.channel_check_interval() == 0? 1:
                         NETSTACK_RDC.channel_check_interval()),
         RF_CHANNEL);
#endif /* WITH_UIP6 */

#if !WITH_UIP6
  uart1_set_input(serial_line_input_byte);
  serial_line_init();
#endif

#ifdef NETSTACK_AES_H
#ifndef NETSTACK_AES_KEY
#error Please define NETSTACK_AES_KEY!
#endif /* NETSTACK_AES_KEY */
  {
    const uint8_t key[] = NETSTACK_AES_KEY;
    netstack_aes_set_key(key);
  }
  /*printf("AES encryption is enabled: '%s'\n", NETSTACK_AES_KEY);*/
  printf("AES encryption is enabled\r\n");
#else /* NETSTACK_AES_H */
  printf("Warning: AES encryption is disabled\r\n");
#endif /* NETSTACK_AES_H */

#if TIMESYNCH_CONF_ENABLED
  timesynch_init();
  timesynch_set_authority_level(rimeaddr_node_addr.u8[0]);
#endif /* TIMESYNCH_CONF_ENABLED */  

  energest_init();
  ENERGEST_ON(ENERGEST_TYPE_CPU);

  simple_rpl_init();
  /*Watch dog configuration*/
  watchdog_periodic();
  watchdog_start();

  autostart_start(autostart_processes);

  //duty_cycle_scroller_start(CLOCK_SECOND * 2);
#if IP64_CONF_UIP_FALLBACK_INTERFACE_SLIP && WITH_SLIP
  /* Start the SLIP */
  printf("Initiating SLIP: my IP is 172.16.0.2...\r\n");
  slip_arch_init(0);
  {
    uip_ip4addr_t ipv4addr, netmask;

    uip_ipaddr(&ipv4addr, 172, 16, 0, 2);
    uip_ipaddr(&netmask, 255, 255, 255, 0);
    ip64_set_ipv4_address(&ipv4addr, &netmask);
  }
  uart1_set_input(slip_input_byte);
#endif /* IP64_CONF_UIP_FALLBACK_INTERFACE_SLIP */

  fade(LEDS_ORANGE);

  /*
   * This is the scheduler loop.
   */
  while(1) {
    uint8_t r;
    do {
      /* Reset watchdog and handle polls and events */
      // printf("reset watchdog\r\n");
      watchdog_periodic();

      r = process_run();
    } while(r > 0);

    /* We have serviced all pending events. Enter a Low-Power mode. */
    lpm_enter();
  }
}
Пример #12
0
static bool clean_shutdown(void (*callback)(void *), void *parameter)
{
    long msg_id = -1;
    int i;

    scrobbler_poweroff();

#if CONFIG_CHARGING && !defined(HAVE_POWEROFF_WHILE_CHARGING)
    if(!charger_inserted())
#endif
    {
        bool batt_safe = battery_level_safe();
        int audio_stat = audio_status();

        FOR_NB_SCREENS(i)
        {
            screens[i].clear_display();
            screens[i].update();
        }

        if (batt_safe)
        {
#ifdef HAVE_TAGCACHE
            if (!tagcache_prepare_shutdown())
            {
                cancel_shutdown();
                splash(HZ, ID2P(LANG_TAGCACHE_BUSY));
                return false;
            }
#endif
            if (battery_level() > 10)
                splash(0, str(LANG_SHUTTINGDOWN));
            else
            {
                msg_id = LANG_WARNING_BATTERY_LOW;
                splashf(0, "%s %s", str(LANG_WARNING_BATTERY_LOW),
                                    str(LANG_SHUTTINGDOWN));
            }
        }
        else
        {
            msg_id = LANG_WARNING_BATTERY_EMPTY;
            splashf(0, "%s %s", str(LANG_WARNING_BATTERY_EMPTY),
                                str(LANG_SHUTTINGDOWN));
        }

        if (global_settings.fade_on_stop
            && (audio_stat & AUDIO_STATUS_PLAY))
        {
            fade(false, false);
        }

        if (batt_safe) /* do not save on critical battery */
        {
#if defined(HAVE_RECORDING) && CONFIG_CODEC == SWCODEC
            if (audio_stat & AUDIO_STATUS_RECORD)
            {
                rec_command(RECORDING_CMD_STOP);
                /* wait for stop to complete */
                while (audio_status() & AUDIO_STATUS_RECORD)
                    sleep(1);
            }
#endif
            bookmark_autobookmark(false);

            /* audio_stop_recording == audio_stop for HWCODEC */
            audio_stop();

            if (callback != NULL)
                callback(parameter);

#if CONFIG_CODEC != SWCODEC
            /* wait for audio_stop or audio_stop_recording to complete */
            while (audio_status())
                sleep(1);
#endif

#if defined(HAVE_RECORDING) && CONFIG_CODEC == SWCODEC
            audio_close_recording();
#endif

            if(global_settings.talk_menu)
            {
                bool enqueue = false;
                if(msg_id != -1)
                {
                    talk_id(msg_id, enqueue);
                    enqueue = true;
                }
                talk_id(LANG_SHUTTINGDOWN, enqueue);
#if CONFIG_CODEC == SWCODEC
                voice_wait();
#endif
            }

            system_flush();
#ifdef HAVE_EEPROM_SETTINGS
            if (firmware_settings.initialized)
            {
                firmware_settings.disk_clean = true;
                firmware_settings.bl_version = 0;
                eeprom_settings_store();
            }
#endif
        }
#ifdef HAVE_DIRCACHE
        else
            dircache_disable();
#endif

        shutdown_hw();
    }
Пример #13
0
static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
{
    AVFilterContext *ctx = inlink->dst;
    AVFilterLink *outlink = ctx->outputs[0];
    AudioVectorScopeContext *p = ctx->priv;
    const int hw = p->hw;
    const int hh = p->hh;
    unsigned x, y;
    const double zoom = p->zoom;
    int i;

    if (!p->outpicref || p->outpicref->width  != outlink->w ||
                         p->outpicref->height != outlink->h) {
        av_frame_free(&p->outpicref);
        p->outpicref = ff_get_video_buffer(outlink, outlink->w, outlink->h);
        if (!p->outpicref)
            av_frame_free(&insamples);
            return AVERROR(ENOMEM);

        for (i = 0; i < outlink->h; i++)
            memset(p->outpicref->data[0] + i * p->outpicref->linesize[0], 0, outlink->w * 4);
    }
    p->outpicref->pts = insamples->pts;

    fade(p);

    switch (insamples->format) {
    case AV_SAMPLE_FMT_S16:
        for (i = 0; i < insamples->nb_samples; i++) {
            int16_t *src = (int16_t *)insamples->data[0] + i * 2;

            if (p->mode == LISSAJOUS) {
                x = ((src[1] - src[0]) * zoom / (float)(UINT16_MAX) + 1) * hw;
                y = (1.0 - (src[0] + src[1]) * zoom / (float)UINT16_MAX) * hh;
            } else {
                x = (src[1] * zoom / (float)INT16_MAX + 1) * hw;
                y = (src[0] * zoom / (float)INT16_MAX + 1) * hh;
            }

            draw_dot(p, x, y);
        }
        break;
    case AV_SAMPLE_FMT_FLT:
        for (i = 0; i < insamples->nb_samples; i++) {
            float *src = (float *)insamples->data[0] + i * 2;

            if (p->mode == LISSAJOUS) {
                x = ((src[1] - src[0]) * zoom / 2 + 1) * hw;
                y = (1.0 - (src[0] + src[1]) * zoom / 2) * hh;
            } else {
                x = (src[1] * zoom + 1) * hw;
                y = (src[0] * zoom + 1) * hh;
            }

            draw_dot(p, x, y);
        }
        break;
    }

    av_frame_free(&insamples);

    return ff_filter_frame(outlink, av_frame_clone(p->outpicref));
}
Пример #14
0
void plasmaTest()
{
	int32_t col, scale;
	int32_t sqx, sqy, sqz;
	int32_t x, y, z;
	scale = 3*0x5100;
	ioffset = 0;
	
	while (1)
	{
		ioffset += 290; //700;
		
		for(x = 0; x < MAX_X; x++)
		{
			for(y = 0; y < MAX_Y; y++)
			{
				for(z = 0; z < MAX_Z; z++)
				{
					//reset color;
					col = 0;
					
					//diagonal scrolling sine 
					col += 0x2000 * Sine((-x * (0x8000*0x8000 / (MAX_X * scale))) + 
							               (y * (0x8000*0x8000 / (MAX_Y * scale))) + 
										   (-z * (0x8000*0x8000 / (MAX_Z * scale))) + 
										   ioffset
										   ) / 0x8000;
					
					//polar sine
					sqx  = x - 2;
					sqx *= sqx*0x8000;
					sqy  = y - 2;
					sqy *= sqy*0x8000;
					sqz  = z - 2;
					sqz *= sqz*0x8000;
					col += 0x8000/5 * Sine(
						isqrt(sqx + sqy + sqz)*SQRT0x8000/8 + ioffset + 
					    (x*y*z*0x8000*20)/(scale*(1+x+y+z))
				    ) / 0x8000;  //end of sine
					col +=  (
							  (0x3200 * Sine(( x * (0x8000*0x8000 / (MAX_X * scale))) + ioffset) / 0x8000) 
							+ (0x5300 * Sine((-y * (0x8000*0x8000 / (MAX_Y * scale))) + ioffset) / 0x8000)
							+ (0x4400 * Sine((-z * (0x8000*0x8000 / (MAX_Z * scale))) + ioffset) / 0x8000)
							) / (0x13000);
					
					//colorspace offset
					col += 0x2500 + (ioffset/32);

					setVoxelH(x,y,z,col);
				} 
				//printf("\n");
			}
			//printf("\n");
		}
		//printf("\n");
		
		fade(10,2);
		
		if ((ioffset) >= 4*0x8000)
			break;
	}
	clearImage(black);
	fade(15, 100);
}
Пример #15
0
void ChoiceView::paintEvent(QPaintEvent *event) {
    QFontMetrics metrics(font());
    QPainter painter(this);

    int y = arrowHeight + 2;
    const int baseline = metrics.leading() + metrics.ascent() + 1;
    const int w = width(), h = height() - (y * 2);
    const int yInc = h / 10;
    const int labelWidth = w - yInc - 10;
    const int hotkeyCenter = w - (yInc / 2);

    // Top arrow
    const int center = w / 2;
    painter.eraseRect(0, 0, w, y);
    if (_offset > 0) {
        painter.drawLine(center, 0, center - arrowHeight, arrowHeight);
        painter.drawLine(center, 0, center + arrowHeight, arrowHeight);
        painter.drawLine(center - arrowHeight, arrowHeight, center + arrowHeight, arrowHeight);
    }

    // Bottom arrow
    painter.eraseRect(0, height() - y, w, y);
    if (_offset + 10 < _choices.size()) {
        painter.drawLine(center, height() - 1, center - arrowHeight, height() - arrowHeight - 1);
        painter.drawLine(center, height() - 1, center + arrowHeight, height() - arrowHeight - 1);
        painter.drawLine(center - arrowHeight, height() - arrowHeight - 1,
                         center + arrowHeight, height() - arrowHeight - 1);
    }

    QLinearGradient fade(QPointF(0,0), QPointF(labelWidth, 0));
    fade.setColorAt(0, Qt::black);
    fade.setColorAt(0.95, Qt::black);
    fade.setColorAt(1.0, QColor(0xAA, 0xAA, 0xAA));

    QTextOption noWrap;
    noWrap.setWrapMode(QTextOption::NoWrap);

    // Choice area
    for (int row = 0; row < NUM_CHOICES; row++) {
        const int item = row + _offset;
        painter.eraseRect(0, y, w, yInc);
        if (item < _choices.size()) {
            const Choice &c = _choices[item];
            if (metrics.width(c.title()) > labelWidth) {
                painter.setPen(QPen(QBrush(fade), 1));
            } else {
                painter.setPen(QPen(Qt::black));
            }

            painter.drawText(QRectF(0, y, labelWidth, yInc), c.title(), noWrap);

            painter.save();
            if (row > 0) {
                painter.setPen(QColor(0xAA, 0xAA, 0xAA));
                painter.drawLine(50, y - 10, w - 50, y - 10);
            }

            painter.setPen(QColor(0x55, 0x55, 0x55));
            painter.drawRoundedRect(labelWidth + 10, y + metrics.leading(), yInc - 1, metrics.height(), 4, 4);
            painter.drawText(hotkeyCenter - (metrics.width(_hotkeys[row]) / 2), y + baseline,
                             QString(1, _hotkeys[row]));

            painter.restore();
        }
        y += yInc;
    }
}
Пример #16
0
    //________________________________________________
    void TransitionWidget::paintEvent( QPaintEvent* event )
    {

        // fully transparent case
        if( opacity() >= 1.0 && endPixmap().isNull() ) return;
        if( !_paintEnabled ) return;

        // get rect
        QRect rect = event->rect();
        if( !rect.isValid() ) rect = this->rect();

        // local pixmap
        const bool paintOnWidget( testFlag( PaintOnWidget ) && !testFlag( Transparent ) );
        if( !paintOnWidget )
        {

            if( _currentPixmap.isNull() || _currentPixmap.size() != size() )
            { _currentPixmap = QPixmap( size() ); }

        }

        // fill
        _currentPixmap.fill( Qt::transparent );

        // copy local pixmap to current
        {

            QPainter p;

            // draw end pixmap first, provided that opacity is small enough
            if( opacity() >= 0.004 && !_endPixmap.isNull() )
            {

                // faded endPixmap if parent target is transparent and opacity is
                if( opacity() <= 0.996 && testFlag( Transparent ) )
                {

                    fade( _endPixmap, _currentPixmap, opacity(), rect );
                    p.begin( &_currentPixmap );
                    p.setClipRect( event->rect() );

                } else {

                    if( paintOnWidget ) p.begin( this );
                    else p.begin( &_currentPixmap );
                    p.setClipRect( event->rect() );
                    p.drawPixmap( QPoint(), _endPixmap );

                }

            } else {

                if( paintOnWidget ) p.begin( this );
                else p.begin( &_currentPixmap );
                p.setClipRect( event->rect() );

            }

            // draw fading start pixmap
            if( opacity() <= 0.996 && !_startPixmap.isNull() )
            {
                if( opacity() >= 0.004 )
                {

                    fade( _startPixmap, _localStartPixmap, 1.0-opacity(), rect );
                    p.drawPixmap( QPoint(), _localStartPixmap );

                } else p.drawPixmap( QPoint(), _startPixmap );

            }

            p.end();
        }

        // copy current pixmap on widget
        if( !paintOnWidget )
        {
            QPainter p( this );
            p.setClipRect( event->rect() );
            p.drawPixmap( QPoint(0,0), _currentPixmap );
            p.end();
        }
    }
Пример #17
0
void mediaElement::fadeIn(float speed) {
    ofLogNotice("mediaElement") << ofGetFrameNum() << "\t"  << "fadeIn at: " << speed << " " << file;
    opacity = 0.0f;
    fade(speed);
}
Пример #18
0
/**
 * \brief Main routine for the cc2538dk platform
 */
int
main(void)
{
  nvic_init();
  ioc_init();
  sys_ctrl_init();
  clock_init();
  lpm_init();
  rtimer_init();
  gpio_init();

  leds_init();
  fade(LEDS_YELLOW);

  process_init();

  watchdog_init();
  button_sensor_init();

  /*
   * Character I/O Initialisation.
   * When the UART receives a character it will call serial_line_input_byte to
   * notify the core. The same applies for the USB driver.
   *
   * If slip-arch is also linked in afterwards (e.g. if we are a border router)
   * it will overwrite one of the two peripheral input callbacks. Characters
   * received over the relevant peripheral will be handled by
   * slip_input_byte instead
   */
#if UART_CONF_ENABLE
  uart_init(0);
  uart_init(1);
  uart_set_input(SERIAL_LINE_CONF_UART, serial_line_input_byte);
#endif

#if USB_SERIAL_CONF_ENABLE
  usb_serial_init();
  usb_serial_set_input(serial_line_input_byte);
#endif

  serial_line_init();

  INTERRUPTS_ENABLE();
  fade(LEDS_GREEN);

  PUTS(CONTIKI_VERSION_STRING);
  PUTS(BOARD_STRING);

  PRINTF(" Net: ");
  PRINTF("%s\n", NETSTACK_NETWORK.name);
  PRINTF(" MAC: ");
  PRINTF("%s\n", NETSTACK_MAC.name);
  PRINTF(" RDC: ");
  PRINTF("%s\n", NETSTACK_RDC.name);

  /* Initialise the H/W RNG engine. */
  random_init(0);

  udma_init();

  process_start(&etimer_process, NULL);
  ctimer_init();

  set_rf_params();
  netstack_init();

#if NETSTACK_CONF_WITH_IPV6
  memcpy(&uip_lladdr.addr, &linkaddr_node_addr, sizeof(uip_lladdr.addr));
  queuebuf_init();
  process_start(&tcpip_process, NULL);
#endif /* NETSTACK_CONF_WITH_IPV6 */

  process_start(&sensors_process, NULL);

  energest_init();
  ENERGEST_ON(ENERGEST_TYPE_CPU);

  autostart_start(autostart_processes);

  watchdog_start();
  fade(LEDS_ORANGE);

  while(1) {
    uint8_t r;
    do {
      /* Reset watchdog and handle polls and events */
      watchdog_periodic();

      r = process_run();
    } while(r > 0);

    /* We have serviced all pending events. Enter a Low-Power mode. */
    lpm_enter();
  }
}
Пример #19
-1
void mediaElement::fadeOut(float speed, float op, bool destroy) {
    ofLogNotice("mediaElement") << ofGetFrameNum() << "\tfadeOut(" << speed << ") " << file;
    opacity = op;
    fadeoutDestroy = destroy;
    fade(-speed);
}
Пример #20
-1
/**
 * \brief Main routine for the OpenMote-CC2538 platforms
 */
int
main(void)
{
  nvic_init();
  ioc_init();
  sys_ctrl_init();
  clock_init();
  lpm_init();
  rtimer_init();
  gpio_init();
  leds_init();
  fade(LEDS_RED);
  process_init();
  watchdog_init();

#if UART_CONF_ENABLE
  uart_init(0);
  uart_init(1);
  uart_set_input(SERIAL_LINE_CONF_UART, serial_line_input_byte);
#endif

#if USB_SERIAL_CONF_ENABLE
  usb_serial_init();
  usb_serial_set_input(serial_line_input_byte);
#endif

  i2c_init(I2C_SDA_PORT, I2C_SDA_PIN, I2C_SCL_PORT, I2C_SCL_PIN, I2C_SCL_NORMAL_BUS_SPEED);

  serial_line_init();

  INTERRUPTS_ENABLE();
  fade(LEDS_BLUE);

  PUTS(CONTIKI_VERSION_STRING);
  PUTS(BOARD_STRING);
#if STARTUP_CONF_VERBOSE
  soc_print_info();
#endif

  random_init(0);

  udma_init();

  process_start(&etimer_process, NULL);
  ctimer_init();

  board_init();

#if CRYPTO_CONF_INIT
  crypto_init();
  crypto_disable();
#endif

  netstack_init();
  set_rf_params();

  PRINTF("Net: ");
  PRINTF("%s\n", NETSTACK_NETWORK.name);
  PRINTF("MAC: ");
  PRINTF("%s\n", NETSTACK_MAC.name);
  PRINTF("RDC: ");
  PRINTF("%s\n", NETSTACK_RDC.name);

#if NETSTACK_CONF_WITH_IPV6
  memcpy(&uip_lladdr.addr, &linkaddr_node_addr, sizeof(uip_lladdr.addr));
  queuebuf_init();
  process_start(&tcpip_process, NULL);
#endif /* NETSTACK_CONF_WITH_IPV6 */

  process_start(&sensors_process, NULL);

  SENSORS_ACTIVATE(button_sensor);

  energest_init();
  ENERGEST_ON(ENERGEST_TYPE_CPU);

  autostart_start(autostart_processes);

  watchdog_start();
  fade(LEDS_GREEN);

  while(1) {
    uint8_t r;
    do {
      watchdog_periodic();

      r = process_run();
    } while(r > 0);

    lpm_enter();
  }
}