Ejemplo n.º 1
0
int main (void) {
  save_power();
  USART0Init();
  buttons_init();
  tone_init();


  int useless_steps = 0;
  int state = STATE_GO_OFF;

  while (1) {
    if (useless_steps >= 1000) {
      useless_steps = 0;
      state = STATE_GO_OFF;
    }

    if (state == STATE_GO_OFF) {
      state = STATE_IS_OFF;

      USART0SendString("");
      USART0BacklightOff();
      deep_sleep();
    }

    tick();

    if (toggle_state() == 0) {
      useless_steps = 0;

      USART0BacklightOn();
      write_next_chore();
      while (toggle_state() == 0) { tick(); } // Wait for button to be released

      int seconds = 0;
      int miliseconds = 0;

      while (1) {
        if (toggle_state() == 0) { state = STATE_GO_OFF; notone(); break; }
        if (timer_state() == 0) { miliseconds = 0; seconds = 0; notone(); }

        miliseconds++;
        if (miliseconds >= 1000) {
          seconds++;
          miliseconds = 0;
        }

        if (seconds == TIMER_LENGTH) {
          tone(4400);
        } else if (seconds > 1000) {
          seconds = (TIMER_LENGTH + 1);
        }

        tick();
      }
    } else {
      useless_steps++;
    }
  }
}
Ejemplo n.º 2
0
void Indigo::UIWidget::enable(bool enable)
{
	toggle_state(enable,eWS_enabled);
}
Ejemplo n.º 3
0
Archivo: input.c Proyecto: erikg/vp
int
handle_input ()
{
    SDL_Event e;

    SDL_WaitEvent (&e);
    switch (e.type)
    {
	/*
	 * thanks to Ted Mielczarek <*****@*****.**> for this, fixes the X
	 * Async request errors 
	 */
    case SDL_USEREVENT:
	if (e.user.code == SHOW_IMAGE)
	    image_freshen ();
	break;
    case SDL_KEYDOWN:
	switch (tolower (e.key.keysym.sym))
	{
	case 'x':
	case 'q':
	case SDLK_ESCAPE:
	    return 0;
	    break;
	case SDLK_SPACE:
	    timer_toggle ();
	    break;
	case SDLK_RETURN:
	    image_freshen ();
	    timer_stop ();
	    break;
	case SDLK_RIGHT:
	    timer_stop ();
	    image_next (0);
	    break;
	case SDLK_LEFT:
	    timer_stop ();
	    image_prev (0);
	    break;
	case 'z':
	    timer_stop ();
	    toggle_state (ZOOM);
	    image_freshen ();
	    break;
	case 'f':
	    timer_stop ();
	    toggle_state (FULLSCREEN);
	    if (get_state_int (FULLSCREEN))
		screen =
		    SDL_SetVideoMode (vid_width (), vid_height (),
		    vid_depth (), SDL_FULLSCREEN | SDL_DOUBLEBUF);
	    image_freshen ();
	    break;
#if 0
	case '+':
	case '=':
	    scale += .1;
	    image_freshen ();
	    break;
	case '-':
	    scale -= .1;
	    image_freshen ();
	    break;
#endif
	default:
	    /*
	     * do nothing 
	     */
	    break;
	}
	break;
    case SDL_QUIT:
	return 0;
	break;
    }
    return 1;
}
Ejemplo n.º 4
0
void Indigo::UIWidget::show(bool visible)
{
	toggle_state(visible,eWS_visible);
}