コード例 #1
0
ファイル: Simon.c プロジェクト: UCLA-IEEE/Soldering-SimonSays
void display_mode(void) {
    uint8_t mode, last_mode;

    mode = last_mode = read_mode();
    set_mode_lights(mode);

    input_clear_button_pressed();
    while (1) {
        last_mode = mode;
        mode = read_mode();

        if(mode != last_mode)
        {
            set_mode_lights(mode);

            play_tone(2000,10);

            game_set_mode(mode);
        }

        if (input_button_pressed())
        {
            _delay_ms(100);
            break;
        }
    }

    set_leds(ALL_LEDS, OFF);
}
コード例 #2
0
ファイル: play.c プロジェクト: mralexgray/baresip
/**
 * Play an audio file in WAV format
 *
 * @param playp    Pointer to allocated player object
 * @param filename Name of WAV file to play
 * @param repeat   Number of times to repeat
 *
 * @return 0 if success, otherwise errorcode
 */
int play_file(struct play **playp, const char *filename, int repeat)
{
	struct mbuf *mb;
	char path[256];
	uint32_t srate;
	uint8_t ch;
	int err;

	if (playp && *playp)
		return EALREADY;

#ifndef PREFIX
#define PREFIX "/usr"
#endif
	if (re_snprintf(path, sizeof(path), PREFIX "/share/baresip/%s",
			filename) < 0)
		return ENOMEM;

	mb = mbuf_alloc(1024);
	if (!mb)
		return ENOMEM;

	err = aufile_load(mb, path, &srate, &ch);
	if (err) {
		DEBUG_WARNING("%s: %m\n", path, err);
		goto out;
	}

	err = play_tone(playp, mb, srate, ch, repeat);

 out:
	mem_deref(mb);

	return err;
}
コード例 #3
0
ファイル: main.c プロジェクト: jbremnant/project_ledi
void mode_msg(char *strbuf, int i)
{
  play_tone(A5, 4); _delay_ms(5);
  // play_tone(A5, 4); _delay_ms(5);
  // play_tone(B5, 5); _delay_ms(5);
  // play_tone(E5, 8);
  ht1632_scrollstr(strbuf, i, 40);
}
コード例 #4
0
ファイル: main.c プロジェクト: ChristofferAlenskog/musicbox
int modify_pitch2(int change_pitch) {
	if (btns & 0x1) {
		btn1_set2 += change_pitch;
		tone = tone_frq[btn1_set2];
		play_tone(tone, tone_length);		
	} if (btns & 0x2) {
		btn2_set2 += change_pitch;		
		tone = tone_frq[btn2_set2];
		play_tone(tone, tone_length);		
	} if (btns & 0x4) {
		btn3_set2 += change_pitch;	
		tone = tone_frq[btn3_set2];
		play_tone(tone, tone_length);			
	} if (btns & 0x8) {
		btn4_set2 += change_pitch;	
		tone = tone_frq[btn4_set2];
		play_tone(tone, tone_length);			
	} if (btns & 0x10) {
		btn5_set2 += change_pitch;
		tone = tone_frq[btn5_set2];
		play_tone(tone, tone_length);				
	} if (btns & 0x20) {
		btn6_set2 += change_pitch;
		tone = tone_frq[btn6_set2];
		play_tone(tone, tone_length);				
	} if (btns & 0x40) {
		btn7_set2 += change_pitch;
		tone = tone_frq[btn7_set2];
		play_tone(tone, tone_length);		
	}	
	return 0;
}
コード例 #5
0
ファイル: ToneAlarm_PX4.cpp プロジェクト: 2013-8-15/ardupilot
void ToneAlarm_PX4::check_cont_tone() {
    uint32_t tnow_ms = AP_HAL::millis();
    // if we are supposed to be playing a continuous tone,
    // and it was interrupted, and the interrupting tone has timed out,
    // resume the continuous tone

    if (_cont_tone_playing != -1 && _tone_playing != _cont_tone_playing && tnow_ms-_tone_beginning_ms > AP_NOTIFY_PX4_MAX_TONE_LENGTH_MS) {
        play_tone(_cont_tone_playing);
    }
}
コード例 #6
0
ファイル: breakmeggy.c プロジェクト: nelfin/yameggyjros
void play_bgmusic(void) {
    uint16_t i;
    for (;;) {
        for (i = 0; i < SONG; i += 2) {
            play_tone(bgmusic[i], (float) bgmusic[i+1]);
            while (is_sound_playing());
            delay(100);
        }
    }
}
コード例 #7
0
ファイル: main.c プロジェクト: jslack-smith/Universian
int main(void) {

	// Sets the speed at which the song plays.
	int rate = 52000; 
	
	int i = 0;

	// Setup the DAC 
	setup_DAC();
	
	// Play the song
	while(1) {
		if (i > song_duration) { 		// End of the song has been reached
			i = 58; 									// Skip the intro and play the main melody again.
		} else { 										// Play the note
			play_tone(rate * song_data[i].duration, song_data[i].pitch, song_data[i].volume);
			i++;
		}
	}

}
コード例 #8
0
ファイル: main.c プロジェクト: jbremnant/project_ledi
void mode_timeset(char *strbuf, int i)
{
  uint8_t j, timegood = 0;
  uint8_t digits[4] = {0,0,0,0};
  char tok;

  play_tone(A5, 10); _delay_ms(10);
  play_tone(B5, 10); _delay_ms(10);

  timegood = 1; 
  for(j=0; j<4; j++)
  {
    tok = strbuf[j+2];
    if(tok >= '0' && tok <= '9')
    {
      digits[j] = tok - '0';      
    }
    else
    {
      timegood = 0;
    }
  }

  if(timegood)
  {
    // indicate that timeset is good
    play_tone(B5, 5); _delay_ms(2);
    play_tone(D6, 5);
    hours   = 10*digits[0] + digits[1];
    minutes = 10*digits[2] + digits[3];
  }
  else
  {
    // indicate that it's bad
    play_tone(G5, 20); _delay_ms(5);
    play_tone(G5, 20);
  }
}
コード例 #9
0
ファイル: main.c プロジェクト: jbremnant/project_ledi
int main()
{
  uint8_t i = 0;
  uint8_t n = 0;
  uint8_t pos;
  char strbuf[64];
  char timebuf[16];
  uint8_t seconds_last = seconds;
  uint8_t minutes_last = minutes;
  unsigned int ch;

  // FILE uart_stream = FDEV_SETUP_STREAM(uart_putchar, uart_getchar, _FDEV_SETUP_RW);
  // stdin = stdout = &uart_stream;

  // always calibrate the internal RC oscillator using external 32Khz crystal
  do_calibration();
  // OSCCAL = 55;

  rtc_init();
  key_init();
  extra_init();
  ht1632_setup(1); // use ram

#ifdef USE_UARTSYNC
  uart_init();
#else

  #ifdef USE_V0
  uart_init( UART_BAUD_SELECT(9600,F_CPU) );
  #else
  // uart_init( UART_BAUD_SELECT(38400,F_CPU) );
  uart_init( UART_BAUD_SELECT(9600,F_CPU) );
  #endif

#endif

  sei(); // turn on interrupt handler

  // strncpy(strbuf, "ready: ", 7);
  // sprintf(&strbuf[7], "%d", OSCCAL);
  // ht1632_scrollstr(strbuf, 10, 10);
  int start = 5;
  ht1632_putchar(start,1,'L'); 
  ht1632_putchar(start+6,1,'E'); 
  ht1632_putchar(start+12,1,'D'); 
  ht1632_putchar(start+18,1,'I'); 
  delay_ms(5000); 

  set_time(timebuf);
  disp_time(timebuf);

  // play tone to indicate we started
  play_tone(A5, 4); _delay_ms(5);
  play_tone(A5, 4); _delay_ms(10);

  while(1)
  {
    n = term_recvstr(BUF, BUFSIZE);

    if(n<0)
    {
      term_sendstr(PSTR("error occurred on uart\r\n"));
    }
    if(n>0)
    {
      MODE = term_check_mode(BUF,n);
      switch(MODE)
      {
        case MODE_TIMESET:
          mode_timeset(BUF,n);
          break;
        case MODE_DRAW:
          mode_draw();
          break;
        case MODE_INVALID:
        default:
          mode_msg(BUF,n);
          break;
      }
      // just to be paranoid
      stop_led_sync_timer();

      // hack to force time display
      minutes_last = minutes - 1;
    }

    if(last_button1state == 1)
    {
      demo_life(); 
      // if we come out of demo_life, we show time 
      set_time(timebuf);
      disp_time(timebuf);
    }

    if(seconds_last != seconds || last_buttonstate & BT_PRESS) 
    {
      seconds_last = seconds;

      if(minutes_last != minutes)
      {
        minutes_last = minutes;
        set_time(timebuf);
        disp_time(timebuf);
      }

      disp_bindots();
    }

    // fast cycle
    if(last_buttonstate & BT_HOLD)
    {
      while(!(PINC & (1<<BUTTON2)))
      {
        minutes++;
        update_datetime(1);
        set_time(timebuf);
        disp_time(timebuf);
        minutes_last = minutes;
        _delay_ms(20);
      }
      intcount = 0;
    }

    // while ((ASSR & (1<<OCR2BUB)) != 0) {} 
  }
}
コード例 #10
0
void Brick::beep(unsigned int time, bool reply){
  play_tone(1000,time, reply);
}
コード例 #11
0
ファイル: main.c プロジェクト: ChristofferAlenskog/musicbox
int main(void){
    setup();	
	tone_length = 5;
    while(1){
    	update_status(); 
		if (sw == 0) {
	        if (btns & 0x1) {
				tone = tone_frq[btn1_set1];
				play_tone(tone, tone_length);
	        } if (btns & 0x2) {
				tone = tone_frq[btn2_set1];
				play_tone(tone, tone_length);
	        } if (btns & 0x4) {
				tone = tone_frq[btn3_set1];
				play_tone(tone, tone_length);
	        } if (btns & 0x8) {
				tone = tone_frq[btn4_set1];
				play_tone(tone, tone_length);
	        } if (btns & 0x10) {
				tone = tone_frq[btn5_set1];
				play_tone(tone, tone_length);
	        } if (btns & 0x20) {
				tone = tone_frq[btn6_set1];
				play_tone(tone, tone_length);
	        } if (btns & 0x40) {
				tone = tone_frq[btn7_set1];
				play_tone(tone, tone_length);      
			}
		} else if (sw == 0x1) {
			modify_pitch1(1);
		} else if (sw == 0x3) {
			modify_pitch1(-1);
		} else if (sw == 0x8) {
	        if (btns & 0x1) {
				tone = tone_frq[btn1_set2];
				play_tone(tone, tone_length);
	        } if (btns & 0x2) {
				tone = tone_frq[btn2_set2];
				play_tone(tone, tone_length);
	        } if (btns & 0x4) {
				tone = tone_frq[btn3_set2];
				play_tone(tone, tone_length);
	        } if (btns & 0x8) {
				tone = tone_frq[btn4_set2];
				play_tone(tone, tone_length);
	        } if (btns & 0x10) {
				tone = tone_frq[btn5_set2];
				play_tone(tone, tone_length);
	        } if (btns & 0x20) {
				tone = tone_frq[btn6_set2];
				play_tone(tone, tone_length);
	        } if (btns & 0x40) {
				tone = tone_frq[btn7_set2];
				play_tone(tone, tone_length);      
			}
		} else if (sw == 0x9) {
			modify_pitch2(1);
		} else if (sw == 0xb) {
			modify_pitch2(-1);
		} else if (sw == 0xc) {
			if (btns & 0x1) {
				melody_arabix();
			} else if (btns & 0x2) {
				melody_small();
			} if (btns & 0x4) {
				tone = tone_frq[btn3_set1];
				play_tone(tone, tone_length);
	        } if (btns & 0x8) {
				tone = tone_frq[btn4_set1];
				play_tone(tone, tone_length);
	        } if (btns & 0x10) {
				tone = tone_frq[btn5_set1];
				play_tone(tone, tone_length);
	        } if (btns & 0x20) {
				tone = tone_frq[btn6_set1];
				play_tone(tone, tone_length);
	        } if (btns & 0x40) {
				tone = tone_frq[btn7_set1];
				play_tone(tone, tone_length);      
			}
		} else if (sw == 0xd) {
			if (btns & 0x1) {
				tone = tone_frq[btn1_set1];
				play_tone(tone, tone_length);
			} else if (btns & 0x2) {
				melody_happy();
			} else if (btns & 0x4) {
				melody_sad();
			} else if (btns & 0x8) {
				play_song();
			} if (btns & 0x10) {
				tone = tone_frq[btn5_set1];
				play_tone(tone, tone_length);
	        } if (btns & 0x20) {
				tone = tone_frq[btn6_set1];
				play_tone(tone, tone_length);
	        } if (btns & 0x40) {
				tone = tone_frq[btn7_set1];
				play_tone(tone, tone_length);      
			}
		} else if (sw == 0xa) {
			if (btns & 0x1) {
				melody_sad();
			} if (btns & 0x2) {
				tone = tone_frq[btn2_set1];
				play_tone(tone, tone_length);
	        } if (btns & 0x4) {
				tone = tone_frq[btn3_set1];
				play_tone(tone, tone_length);
	        } if (btns & 0x8) {
				tone = tone_frq[btn4_set1];
				play_tone(tone, tone_length);
	        } if (btns & 0x10) {
				tone = tone_frq[btn5_set1];
				play_tone(tone, tone_length);
	        } if (btns & 0x20) {
				tone = tone_frq[btn6_set1];
				play_tone(tone, tone_length);
	        } if (btns & 0x40) {
				tone = tone_frq[btn7_set1];
				play_tone(tone, tone_length);      
			}
		}  else if (sw == 0xe) {
			if (btns & 0x1) {
				melody_slow();
			} if (btns & 0x2) {
				tone = tone_frq[btn2_set1];
				play_tone(tone, tone_length);
	        } if (btns & 0x4) {
				tone = tone_frq[btn3_set1];
				play_tone(tone, tone_length);
	        } if (btns & 0x8) {
				tone = tone_frq[btn4_set1];
				play_tone(tone, tone_length);
	        } if (btns & 0x10) {
				tone = tone_frq[btn5_set1];
				play_tone(tone, tone_length);
	        } if (btns & 0x20) {
				tone = tone_frq[btn6_set1];
				play_tone(tone, tone_length);
	        } if (btns & 0x40) {
				tone = tone_frq[btn7_set1];
				play_tone(tone, tone_length);      
			}
		} else if (sw == 0xf) {
			if (btns & 0x1) {
				melody_arabix();
			} if (btns & 0x2) {
				play_example(example_twinkle, twinkle_length);
	        } if (btns & 0x4) {
				play_example(example_imperial, imperial_length);
	        } if (btns & 0x8) {
				tone = tone_frq[btn4_set1];
				play_tone(tone, tone_length);
	        } if (btns & 0x10) {
				tone = tone_frq[btn5_set1];
				play_tone(tone, tone_length);
	        } if (btns & 0x20) {
				tone = tone_frq[btn6_set1];
				play_tone(tone, tone_length);
	        } if (btns & 0x40) {
				tone = tone_frq[btn7_set1];
				play_tone(tone, tone_length);      
			}
		} else {
	        if (btns & 0x1) {
				tone = tone_frq[btn1_set1];
				play_tone(tone, tone_length);
	        } if (btns & 0x2) {
				tone = tone_frq[btn2_set1];
				play_tone(tone, tone_length);
	        } if (btns & 0x4) {
				tone = tone_frq[btn3_set1];
				play_tone(tone, tone_length);
	        } if (btns & 0x8) {
				tone = tone_frq[btn4_set1];
				play_tone(tone, tone_length);
	        } if (btns & 0x10) {
				tone = tone_frq[btn5_set1];
				play_tone(tone, tone_length);
	        } if (btns & 0x20) {
				tone = tone_frq[btn6_set1];
				play_tone(tone, tone_length);
	        } if (btns & 0x40) {
				tone = tone_frq[btn7_set1];
				play_tone(tone, tone_length);      
			}
		}
        // Clear tones etc.
		PORTECLR = 0xff;
    }
	return 0;
}
コード例 #12
0
int main()
{
  play_tone(a4,500);
  play_tone(a4,500);
  play_tone(a4,500);
  play_tone(f4,350);
  play_tone(c5,150);
  play_tone(a4,500);
  play_tone(f4,350);
  play_tone(c5,150);
  play_tone(a4,1000);
  play_tone(e5,500);
  play_tone(e5,500);
  play_tone(e5,500);
  play_tone(f5,350);
  play_tone(c5,150);
  play_tone(g4,500);
  play_tone(f4,350);
  play_tone(c5,150);
  play_tone(a4,1000);


  return 0;
}
コード例 #13
0
int main()
{
  play_tone(b4,400);
  play_tone(c5,200);
  play_tone(d5,200);
  play_tone(d5,200);
  play_tone(c5,200);
  play_tone(b4,200);
  play_tone(a4,200);
  play_tone(g4,200);
  play_tone(g4,200);
  play_tone(a4,200);
  play_tone(b4,200);
  play_tone(b4,300);
  play_tone(a4,100);
  play_tone(a4,400);
  play_tone(b4,400);
  play_tone(c5,200);
  play_tone(d5,200);
  play_tone(d5,200);
  play_tone(c5,200);
  play_tone(b4,200);
  play_tone(a4,200);
  play_tone(g4,200);
  play_tone(g4,200);
  play_tone(a4,200);
  play_tone(b4,200);
  play_tone(a4,300);
  play_tone(g4,100);
  play_tone(g4,400);
  play_tone(silence,200);
  play_tone(a4,400);
  play_tone(b4,200);
  play_tone(g4,200);
  play_tone(a4,200);
  play_tone(b4,100);
  play_tone(c5,100);
  play_tone(b4,200);
  play_tone(g4,200);
  play_tone(a4,200);
  play_tone(b4,100);
  play_tone(c5,100);
  play_tone(b4,200);
  play_tone(a4,200);
  play_tone(g4,200);
  play_tone(a4,200);
  play_tone(d4,400);
  play_tone(b4,400);
  play_tone(c5,200);
  play_tone(d5,200);
  play_tone(d5,200);
  play_tone(c5,200);
  play_tone(b4,200);
  play_tone(a4,200);
  play_tone(g4,200);
  play_tone(g4,200);
  play_tone(a4,200);
  play_tone(b4,200);
  play_tone(a4,300);
  play_tone(g4,100);
  play_tone(g4,400);
  play_tone(silence,400);


  return 0;
}
コード例 #14
0
ファイル: main.cpp プロジェクト: mnorman4/ftf2016
static void play_note2() {
    play_tone(NOTE_D4);
}
コード例 #15
0
ファイル: ToneAlarm_PX4.cpp プロジェクト: 2013-8-15/ardupilot
// update - updates led according to timed_updated.  Should be called at 50Hz
void ToneAlarm_PX4::update()
{
    // exit immediately if we haven't initialised successfully
    if (_tonealarm_fd == -1) {
        return;
    }

    // exit if buzzer is not enabled
    if (pNotify->buzzer_enabled() == false) {
        return;
    }

    check_cont_tone();

    if (AP_Notify::flags.compass_cal_running != flags.compass_cal_running) {
        if(AP_Notify::flags.compass_cal_running) {
            play_tone(AP_NOTIFY_PX4_TONE_QUIET_COMPASS_CALIBRATING_CTS);
            play_tone(AP_NOTIFY_PX4_TONE_QUIET_POS_FEEDBACK);
        } else {
            if(_cont_tone_playing == AP_NOTIFY_PX4_TONE_QUIET_COMPASS_CALIBRATING_CTS) {
                stop_cont_tone();
            }
        }
    }
    flags.compass_cal_running = AP_Notify::flags.compass_cal_running;

    if (AP_Notify::events.compass_cal_canceled) {
        play_tone(AP_NOTIFY_PX4_TONE_QUIET_NEU_FEEDBACK);
        return;
    }

    if (AP_Notify::events.initiated_compass_cal) {
        play_tone(AP_NOTIFY_PX4_TONE_QUIET_NEU_FEEDBACK);
        return;
    }

    if (AP_Notify::events.compass_cal_saved) {
        play_tone(AP_NOTIFY_PX4_TONE_QUIET_READY_OR_FINISHED);
        return;
    }

    if (AP_Notify::events.compass_cal_failed) {
        play_tone(AP_NOTIFY_PX4_TONE_QUIET_NEG_FEEDBACK);
        return;
    }

    // don't play other tones if compass cal is running
    if (AP_Notify::flags.compass_cal_running) {
        return;
    }

    // notify the user when autotune or mission completes
    if (AP_Notify::flags.armed && (AP_Notify::events.autotune_complete || AP_Notify::events.mission_complete)) {
        play_tone(AP_NOTIFY_PX4_TONE_LOUD_READY_OR_FINISHED);
    }

    //notify the user when autotune fails
    if (AP_Notify::flags.armed && (AP_Notify::events.autotune_failed)) {
        play_tone(AP_NOTIFY_PX4_TONE_LOUD_NEG_FEEDBACK);
    }

    // notify the user when a waypoint completes
    if (AP_Notify::events.waypoint_complete) {
        play_tone(AP_NOTIFY_PX4_TONE_LOUD_WP_COMPLETE);
    }

    // notify the user when their mode change was successful
    if (AP_Notify::events.user_mode_change) {
        if (AP_Notify::flags.armed) {
            play_tone(AP_NOTIFY_PX4_TONE_LOUD_NEU_FEEDBACK);
        } else {
            play_tone(AP_NOTIFY_PX4_TONE_QUIET_NEU_FEEDBACK);
        }
    }

    // notify the user when their mode change failed
    if (AP_Notify::events.user_mode_change_failed) {
        if (AP_Notify::flags.armed) {
            play_tone(AP_NOTIFY_PX4_TONE_LOUD_NEG_FEEDBACK);
        } else {
            play_tone(AP_NOTIFY_PX4_TONE_QUIET_NEG_FEEDBACK);
        }
    }

    // failsafe initiated mode change
    if(AP_Notify::events.failsafe_mode_change) {
        play_tone(AP_NOTIFY_PX4_TONE_LOUD_ATTENTION_NEEDED);
    }

    // notify the user when arming fails
    if (AP_Notify::events.arming_failed) {
        play_tone(AP_NOTIFY_PX4_TONE_QUIET_NEG_FEEDBACK);
    }

    // notify the user when RC contact is lost
    if (flags.failsafe_radio != AP_Notify::flags.failsafe_radio) {
        flags.failsafe_radio = AP_Notify::flags.failsafe_radio;
        if (flags.failsafe_radio) {
            // armed case handled by events.failsafe_mode_change
            if (!AP_Notify::flags.armed) {
                play_tone(AP_NOTIFY_PX4_TONE_QUIET_NEG_FEEDBACK);
            }
        } else {
            if (AP_Notify::flags.armed) {
                play_tone(AP_NOTIFY_PX4_TONE_LOUD_POS_FEEDBACK);
            } else {
                play_tone(AP_NOTIFY_PX4_TONE_QUIET_POS_FEEDBACK);
            }
        }
    }

    // notify the user when pre_arm checks are passing
    if (flags.pre_arm_check != AP_Notify::flags.pre_arm_check) {
        flags.pre_arm_check = AP_Notify::flags.pre_arm_check;
        if (flags.pre_arm_check) {
            play_tone(AP_NOTIFY_PX4_TONE_QUIET_READY_OR_FINISHED);
        }
    }

    // check if arming status has changed
    if (flags.armed != AP_Notify::flags.armed) {
        flags.armed = AP_Notify::flags.armed;
        if (flags.armed) {
            // arming tune
            play_tone(AP_NOTIFY_PX4_TONE_QUIET_ARMING_WARNING);
        }else{
            // disarming tune
            play_tone(AP_NOTIFY_PX4_TONE_QUIET_NEU_FEEDBACK);
            stop_cont_tone();
        }
    }

    // check if battery status has changed
    if (flags.failsafe_battery != AP_Notify::flags.failsafe_battery) {
        flags.failsafe_battery = AP_Notify::flags.failsafe_battery;
        if (flags.failsafe_battery) {
            // battery warning tune
            play_tone(AP_NOTIFY_PX4_TONE_LOUD_BATTERY_ALERT_CTS);
        }
    }

    // check parachute release
    if (flags.parachute_release != AP_Notify::flags.parachute_release) {
        flags.parachute_release = AP_Notify::flags.parachute_release;
        if (flags.parachute_release) {
            // parachute release warning tune
            play_tone(AP_NOTIFY_PX4_TONE_LOUD_ATTENTION_NEEDED);
        }
    }

    // lost vehicle tone
    if (flags.vehicle_lost != AP_Notify::flags.vehicle_lost) {
        flags.vehicle_lost = AP_Notify::flags.vehicle_lost;
        if (flags.vehicle_lost) {
            play_tone(AP_NOTIFY_PX4_TONE_LOUD_VEHICLE_LOST_CTS);
        } else {
            stop_cont_tone();
        }
    }

    // waiting to be thrown vehicle tone
    if (flags.waiting_for_throw != AP_Notify::flags.waiting_for_throw) {
        flags.waiting_for_throw = AP_Notify::flags.waiting_for_throw;
        if (flags.waiting_for_throw) {
            play_tone(AP_NOTIFY_PX4_TONE_WAITING_FOR_THROW);
        } else {
            stop_cont_tone();
        }
    }

    if (AP_Notify::events.tune_started) {
        play_tone(AP_NOTIFY_PX4_TONE_TUNING_START);
        AP_Notify::events.tune_started = 0;        
    }
    if (AP_Notify::events.tune_next) {
        // signify which parameter in the set is starting
        play_tone(AP_NOTIFY_PX4_TONE_LOUD_1 + (AP_Notify::events.tune_next-1));
        AP_Notify::events.tune_next = 0;        
    }
    if (AP_Notify::events.tune_save) {
        play_tone(AP_NOTIFY_PX4_TONE_TUNING_SAVE);
        AP_Notify::events.tune_save = 0;
    }
    if (AP_Notify::events.tune_error) {
        play_tone(AP_NOTIFY_PX4_TONE_TUNING_ERROR);
        AP_Notify::events.tune_error = 0;
    }
}
コード例 #16
0
ファイル: happycard.c プロジェクト: pdp7/attiny
int main() {

	delay_us(0xFFFF); //brief delay at startup
  	DDRB = 0xFF; //set pins to output, ideally should be more granular

	//Play "Happy Birthday" one time
	play_tone(D5, DUR8D); 
	play_tone(D5, DUR16);
	play_tone(E5, DUR4);
	play_tone(D5, DUR4);
	play_tone(G5, DUR4);
	play_tone(Fsh5, DUR2);
	play_tone(D5, DUR8D);
	play_tone(D5, DUR16);
	play_tone(E5, DUR4);
	play_tone(D5, DUR4);
	play_tone(A5, DUR4);
	play_tone(G5, DUR2);
	play_tone(D5, DUR8D); 
	play_tone(D5, DUR16);
	play_tone(D6, DUR4);
	play_tone(B5, DUR4);
	play_tone(G5, DUR4);
	play_tone(Fsh5, DUR4);
	play_tone(E5, DUR2);
	play_tone(C6, DUR8D); 
	play_tone(C6, DUR16);
	play_tone(B5, DUR4);
	play_tone(G5, DUR4);
	play_tone(A5, DUR4);
	play_tone(G5, DUR2);

	PORTB=0x00; //all pins GND
	DDRB=0xFF; //all pin states Input
        MCUCR = _BV(SM1) |  _BV(SE); //configure sleep mode 
        sleep_cpu(); //sleep until button pressed again  

  	return 0;

}
コード例 #17
0
ファイル: ToneAlarm_PX4.cpp プロジェクト: MarkMote/ardupilot
// update - updates led according to timed_updated.  Should be called at 50Hz
void ToneAlarm_PX4::update()
{
    // exit immediately if we haven't initialised successfully
    if (_tonealarm_fd == -1) {
        return;
    }

    check_cont_tone();

    // notify the user when autotune or mission completes
    if (AP_Notify::flags.armed && (AP_Notify::events.autotune_complete || AP_Notify::events.mission_complete)) {
        play_tone(AP_NOTIFY_PX4_TONE_LOUD_READY_OR_FINISHED);
    }

    //notify the user when autotune fails
    if (AP_Notify::flags.armed && (AP_Notify::events.autotune_failed)) {
        play_tone(AP_NOTIFY_PX4_TONE_LOUD_NEG_FEEDBACK);
    }

    // notify the user when a waypoint completes
    if (AP_Notify::events.waypoint_complete) {
        play_tone(AP_NOTIFY_PX4_TONE_LOUD_WP_COMPLETE);
    }

    // notify the user when their mode change was successful
    if (AP_Notify::events.user_mode_change) {
        if (AP_Notify::flags.armed) {
            play_tone(AP_NOTIFY_PX4_TONE_LOUD_NEU_FEEDBACK);
        } else {
            play_tone(AP_NOTIFY_PX4_TONE_QUIET_NEU_FEEDBACK);
        }
    }

    // notify the user when their mode change failed
    if (AP_Notify::events.user_mode_change_failed) {
        if (AP_Notify::flags.armed) {
            play_tone(AP_NOTIFY_PX4_TONE_LOUD_NEG_FEEDBACK);
        } else {
            play_tone(AP_NOTIFY_PX4_TONE_QUIET_NEG_FEEDBACK);
        }
    }

    // failsafe initiated mode change
    if(AP_Notify::events.failsafe_mode_change) {
        play_tone(AP_NOTIFY_PX4_TONE_LOUD_ATTENTION_NEEDED);
    }

    // notify the user when arming fails
    if (AP_Notify::events.arming_failed) {
        play_tone(AP_NOTIFY_PX4_TONE_QUIET_NEG_FEEDBACK);
    }

    // notify the user when RC contact is lost
    if (flags.failsafe_radio != AP_Notify::flags.failsafe_radio) {
        flags.failsafe_radio = AP_Notify::flags.failsafe_radio;
        if (flags.failsafe_radio) {
            // armed case handled by events.failsafe_mode_change
            if (!AP_Notify::flags.armed) {
                play_tone(AP_NOTIFY_PX4_TONE_QUIET_NEG_FEEDBACK);
            }
        } else {
            if (AP_Notify::flags.armed) {
                play_tone(AP_NOTIFY_PX4_TONE_LOUD_POS_FEEDBACK);
            } else {
                play_tone(AP_NOTIFY_PX4_TONE_QUIET_POS_FEEDBACK);
            }
        }
    }

    // notify the user when pre_arm checks are passing
    if (flags.pre_arm_check != AP_Notify::flags.pre_arm_check) {
        flags.pre_arm_check = AP_Notify::flags.pre_arm_check;
        if (flags.pre_arm_check) {
            play_tone(AP_NOTIFY_PX4_TONE_QUIET_READY_OR_FINISHED);
        }
    }

    // check if arming status has changed
    if (flags.armed != AP_Notify::flags.armed) {
        flags.armed = AP_Notify::flags.armed;
        if (flags.armed) {
            // arming tune
            play_tone(AP_NOTIFY_PX4_TONE_QUIET_ARMING_WARNING);
        }else{
            // disarming tune
            play_tone(AP_NOTIFY_PX4_TONE_QUIET_NEU_FEEDBACK);
            stop_cont_tone();
        }
    }

    // check if battery status has changed
    if (flags.failsafe_battery != AP_Notify::flags.failsafe_battery) {
        flags.failsafe_battery = AP_Notify::flags.failsafe_battery;
        if (flags.failsafe_battery) {
            // battery warning tune
            play_tone(AP_NOTIFY_PX4_TONE_LOUD_BATTERY_ALERT_CTS);
        }
    }

    // check parachute release
    if (flags.parachute_release != AP_Notify::flags.parachute_release) {
        flags.parachute_release = AP_Notify::flags.parachute_release;
        if (flags.parachute_release) {
            // parachute release warning tune
            play_tone(AP_NOTIFY_PX4_TONE_LOUD_ATTENTION_NEEDED);
        }
    }
}
コード例 #18
0
ファイル: breakmeggy.c プロジェクト: nelfin/yameggyjros
void play_breakmeggy(void) {
    uint8_t i;
    uint8_t tick;
    uint8_t lives = 3;
    key_t keyp, lastp = 0;
    /* - 0 1 2 3 4 5 - */
    uint8_t pos = 2;
    uint8_t ball_x = 3, ball_y = 1;
    uint8_t ball_v = STOP;
    /* XXX: This could be packed if space becomes a serious issue */
    uint8_t blocks[4][4] = {
        { 1, 1, 1, 1 },
        { 1, 1, 1, 1 },
        { 1, 1, 1, 1 },
        { 1, 1, 1, 1 },
    };

    /* 3 lives = 3 aux LEDs */
    status_lights = LED_2 | LED_1 | LED_0;
    draw_pixel(ball_x, ball_y, BALL_COLOUR);

    for (;;) {
        draw_paddle(pos);
        draw_blocks(blocks);
        draw_pixel(ball_x, ball_y, BALL_COLOUR);
        /*
         * Paddle movement and time delay
         */
        for (tick = 0; tick < TICKS; tick++) {
            keyp = get_key_down();
            if (keyp != lastp) {
                switch (keyp) {
                    case D_LEFT:
                        pos = (pos > 0) ? pos - 1 : 0;
                        if (ball_v == STOP) {
                            draw_pixel(ball_x, ball_y, c000000);
                            ball_x = (ball_x > 1) ? ball_x - 1 : 1;
                            draw_pixel(ball_x, ball_y, BALL_COLOUR);
                        }
                        draw_paddle(pos);
                        break;
                    case D_RIGHT:
                        pos = (pos < 5) ? pos + 1 : 5;
                        if (ball_v == STOP) {
                            draw_pixel(ball_x, ball_y, c000000);
                            ball_x = (ball_x < 6) ? ball_x + 1 : 6;
                            draw_pixel(ball_x, ball_y, BALL_COLOUR);
                        }
                        draw_paddle(pos);
                        break;
                    case B_RIGHT:
                        if (ball_v == STOP) {
                            ball_v = RIGHT | UP;
                        }
                        break;
                    default:
                        delay_us(2);
                        break;
                }
            }
            lastp = keyp;
            delay(20);
        }
        /*
         * Update world if ball is moving
         */
        if (ball_v != STOP) {
            /*
             * Clear old ball position
             */
            draw_pixel(ball_x, ball_y, c000000);
            /*
             * Apply standard ball velocity
             */
            ball_x = (ball_v & RIGHT) ? ball_x + 1 : ball_x - 1;
            ball_y = (ball_v & UP) ? ball_y + 1 : ball_y - 1;
            if (ball_x == 7) {
                ball_v &= ~RIGHT;
            }
            if (ball_x == 0) {
                ball_v |= RIGHT;
            }
            if (ball_y == 7) {
                ball_v &= ~UP;
            }
            /*
             * Check paddle hit
             */
            if (ball_y == 1 && (ball_x >= pos && ball_x <= pos + 2)) {
                ball_v |= UP;
            }
            /*
             * Collision detection
             */
            if (ball_y > 3) {
                /* Check block rows */
                for (i = 0; i < 4; i++) {
                    if (blocks[i][ball_y - 4] &&
                            (ball_x == 2*i || ball_x == 2*i+1)) {
                        blocks[i][ball_y - 4] = 0;
                        ball_v &= ~UP;
                        play_tone(tCs2, 100);
                        break;
                    }
                }
            }
            /*
             * Ball missed
             */
            if (ball_y == 0) {
                die_anim(75);
                if (--lives == 0) {
                    break;
                }
                /*
                 * Re-initialise game state
                 */
                pos = 2;
                ball_x = 3, ball_y = 1;
                ball_v = STOP;
                status_lights = LED_0;
                if (lives == 2) {
                    status_lights |= LED_1;
                }
            }
            draw_pixel(ball_x, ball_y, BALL_COLOUR);
        }
    }
    /*
     * Game over... ;_;
     */
}
コード例 #19
0
ファイル: main.cpp プロジェクト: mnorman4/ftf2016
static void play_note1() {
    play_tone(NOTE_C4);
}