コード例 #1
0
ファイル: hexbright.cpp プロジェクト: Bonculus13/hexbright
void hexbright::print_charge(unsigned char led) {
  unsigned char charge_state = get_charge_state();
  if(charge_state == CHARGING && get_led_state(led) == LED_OFF) {
    set_led(led, 350, 350);
  } else if (charge_state == CHARGED) {
    set_led(led,50);
  }
}
コード例 #2
0
ファイル: hwnotify.c プロジェクト: Shmuma/HW-notifier
static void hwnotify_conversation_updated(PurpleConversation *conv, 
                                          PurpleConvUpdateType type) {
	if( type != PURPLE_CONV_UPDATE_UNSEEN ) {
		return;
	}

        gboolean unread, important;

	get_pending_events (&unread, &important);
        unsigned char state = get_led_state ();
        state = set_led (state, color_unread, unread);
        state = set_led (state, color_important, important);
        set_led_state (state);
}
コード例 #3
0
/******************************************************************
*	blink_green()
*	nothing exciting, just blink the GRN LED for half a second
*	then return the LED to its original state
*******************************************************************/
int blink_green(){
	// record if the led was on or off so we can return later
	int old_state = get_led_state(GREEN);
	
	const int us_to_blink = 700000; // 0.7 seconds
	const int blink_hz = 10;
	const int delay = 1000000/(2*blink_hz); 
	const int blinks = blink_hz*us_to_blink/1000000;
	int i;
	for(i=0;i<blinks;i++){
		usleep(delay);
		set_led(GREEN,!old_state);
		usleep(delay);
		set_led(GREEN,old_state);
	}
	return 0;
}