Пример #1
0
void pars_beep(void) {
    switch (pars_number()) {
        case MSG_BEEPBEEP:
            if (strncmp(config->nick, packet, NICK_MAXLEN)) break;
            strncpy(status->nick, pars_word(), NICK_MAXLEN);
            if (user_ignore()) break;
            snprintf(message, MSG_SIZE, PARS_BEEP, time_get(), status->nick);
            if (config->verbose) {
                write_log(config->log_main);
                write_str(status->room->name, COL_MESG);
            }
            if ((config->mode == MOD_NORMAL) || (config->mode == MOD_DND) ||
                    ((config->mode == MOD_AWAY) && user_favorite())) {
                make_beepack();
                beep_beep();
            }
            break;
        case MSG_BEEPACK:
            if (strncmp(config->nick, packet, NICK_MAXLEN)) break;
            if (!config->packet_qchat) {
                strncpy(status->nick, pars_word(), NICK_MAXLEN); 
                status->gender = pars_number();
            }
            snprintf(message, MSG_SIZE, PARS_BEEPACK, time_get(), status->nick);
            write_log(config->log_main);
            write_str(status->room->name, COL_MESG);
            break;
        default:
#ifdef  DEBUG
            fprintf(debug_file, "error: Unknown beep type.\n");
            fflush(debug_file);
#endif  /* DEBUG */
            break;
    }
}
Пример #2
0
PROCESS_THREAD(blinker_process, ev, data)
{
  static struct etimer etimer, pir_timer, vib_timer;
  static int on = 0;
  PROCESS_EXITHANDLER(goto exit);
  PROCESS_BEGIN();

  etimer_stop(&pir_timer);
  etimer_stop(&vib_timer);
  etimer_set(&etimer, CLOCK_SECOND * 4);
  button_sensor.configure(SENSORS_ACTIVE, 1);
  vib_sensor.configure(SENSORS_ACTIVE, 1);
  pir_sensor.configure(SENSORS_ACTIVE, 1);

  while(1) {

    PROCESS_WAIT_EVENT();

    if(ev == sensors_event) {
      if(data == &vib_sensor) {
	if(etimer_expired(&vib_timer)) {
	  leds_on(LEDS_RED);
	  etimer_set(&vib_timer, CLOCK_SECOND);
	} else {
	  leds_off(LEDS_RED);
	  etimer_stop(&vib_timer);
	}
	beep();

      } else if(data == &pir_sensor) {
	leds_on(LEDS_YELLOW);
	etimer_set(&pir_timer, CLOCK_SECOND);

      } else if(data == &button_sensor) {
	beep_beep(100);
      }

    } else if(ev == PROCESS_EVENT_TIMER) {
      if(data == &etimer) {
	if(on) {
	  etimer_set(&etimer, CLOCK_SECOND * 4);
	  leds_off(LEDS_GREEN);
	} else {
	  etimer_set(&etimer, CLOCK_SECOND / 2);
	  leds_on(LEDS_GREEN);
	}
	on = !on;
      } else if(data == &pir_timer) {
	leds_off(LEDS_YELLOW);
      } else if(data == &vib_timer) {
	leds_off(LEDS_RED);
      }
    }
  }

 exit:
  leds_off(LEDS_ALL);
  PROCESS_END();
}
Пример #3
0
/*-----------------------------------------------------------------------------------*/
void
beep_down(int d)
{
  int i;
  for(i = 8; i < d; i += i / 8) {
    beep_beep(10);
    clock_delay(i);
  }
}
Пример #4
0
/*-----------------------------------------------------------------------------------*/
void
beep_quick(int n)
{
  int i;
  for(i = 0; i < n; ++i) {
    beep_beep(2000);
    clock_delay(20000);
  }
}
Пример #5
0
/*-----------------------------------------------------------------------------------*/
void
beep_spinup(void)
{
  unsigned int i;

  for(i = 10000; i > 80; i -= i / 20) {
    beep_beep(2);
    clock_delay(i);
  }

  for(i = 4980; i > 2000; i -= 20) {
    leds_on(LEDS_ALL);
    clock_delay(5000 - i);
    leds_off(LEDS_ALL);
    clock_delay(i);
  }

}
Пример #6
0
/*-----------------------------------------------------------------------------------*/
void
beep(void)
{
  beep_beep(20);
}