// Allow the user to calibrate the scales
void calibrateScales()
{
  short calibrateWeight = 0;

  eraseDisplay();
  displayCenteredTextLine(0, "GlideWheel-AS");
  displayCenteredTextLine(2, "Place the object");
  displayCenteredTextLine(3, "on the scales");
  displayCenteredTextLine(4, "and press");
  displayCenteredTextLine(5, "[enter]");
  displayCenteredTextLine(6, "to calibrate");
  while (nNxtButtonPressed != kEnterButton) sleep(1);
  debounce();
  eraseDisplay();
  calibrateWeight = weighObject();
  displayCenteredTextLine(0, "GlideWheel-AS");
  displayCenteredTextLine(2, "Enter the weight");
  displayCenteredTextLine(3, "in grams");
  displayCenteredTextLine(7, "-     OK     +");
  while (true)
  {
    displayCenteredBigTextLine(5, "%d", calibrateWeight);
    switch(nNxtButtonPressed)
    {
      case kLeftButton: playTone(500,10); calibrateWeight--; calibrateWeight = max2(0, calibrateWeight); break;
      case kRightButton: playTone(1000,10); calibrateWeight++; break;
      case kEnterButton: playTone(1500,10);gramsPerUnit = (float)calibrateWeight / (float)MSANGreadRaw(MSANG); eraseDisplay(); return;
    }
    sleep(20);
    debounce();
  }
}
Exemplo n.º 2
0
void soundLoop() {
    int select = digitalRead(JOYSTICK_BUTTON);  
    if (select == HIGH) {
        playTone(660,100);
        delay(10);playTone(700,100);
        delay(10);playTone(760,100);
        delay(10);playTone(880,100);
    }
}
Exemplo n.º 3
0
task lowBattery() {
	alarm = true;
	while(true) {
    playTone(700, 1); delay(1000);
    playTone(400, 1); delay(1000);
    playTone(200, 1); delay(1000);
    delay(1000);
	}
}
Exemplo n.º 4
0
void SmSnDevice::handleOSCBundleInternal(class OSCBundle &bundle) {
    if (bundle.hasError()) {
        errorCue();
        playTone(400,100);
        osc.sendOSCBundleError(bundle);
    } else if (!(handleOSCBundle(bundle)
        // TODO: copying addresses into buffers on the fly (via address()), one by one, is inefficient
        || bundle.dispatch(address(OSC_ERROR), handleErrorMessage)
        || bundle.dispatch(address(OSC_INFO), handleInfoMessage)
        //|| bundle.dispatch(address(OSC_MORSE), handleMorseMessage)
        || bundle.dispatch(address(OSC_OK), handleOkMessage)
        || bundle.dispatch(address(OSC_PING), handlePingMessage)
        || bundle.dispatch(address(OSC_READY), handleReadyMessage)
#ifdef BOUNTIFUL_RAM
        || bundle.dispatch(address(OSC_CONTEXT_SET), handleContextSetMessage)
        || bundle.dispatch(address(OSC_PING_REPLY), handlePingReplyMessage)
        || bundle.dispatch(address(OSC_RGB_SET), handleRGBSetMessage)
        || bundle.dispatch(address(OSC_TONE), handleToneMessage)
        || bundle.dispatch(address(OSC_VIBRO), handleVibroMessage)
#endif // BOUNTIFUL_RAM
        || bundle.dispatch(address(OSC_WARNING), handleWarningMessage)
        )) {
        if (!bundle.size()) {
            osc.sendError(ERR_EMPTY_OSC_BUNDLE);
        } else {
            for (int i = 0; i < bundle.size(); i++) {
                OSCMessage *m = bundle.getOSCMessage(i);
                char address[64];
                m->getAddress(address);
                osc.sendError(ERR_NO_HANDLER, address);
            }
        }
        errorCue();
    }
}
Exemplo n.º 5
0
void loop() {  
  int gasMonitor = analogRead(GASPIN);
  int currPeriod = millis()/TRANSMITPERIOD;
  if (currPeriod != lastPeriod) {
    Serial.print("\ngasMonitor=");
    Serial.println(gasMonitor);

    //send data
    theData.uptime = millis();
    theData.var2_float = gasMonitor;
    theData.var3_float = 0;

    Serial.print("Sending struct (");
    Serial.print(sizeof(theData));
    Serial.print(" bytes) ... ");
    if (radio.sendWithRetry(GATEWAYID, (const void*)(&theData), sizeof(theData))) {
      Serial.print(" ok!");
    } else {
      Serial.print(" nothing...");
    }
    lastPeriod=currPeriod;
  }
  while(gasMonitor > 100){
      theData.var3_float = 1;                                                     //Alarm signal
      radio.sendWithRetry(GATEWAYID, (const void*)(&theData), sizeof(theData));
      Serial.println("ALARM!! sending alarm");
      playTone(100, 2600, PIEZOPIN);
      analogWrite(REDPIN, 255);
      delay(100);
      digitalWrite(REDPIN, LOW);
      gasMonitor = analogRead(GASPIN);
    }
  analogWrite(PIEZOPIN, 0);
  delay(1000);
}
Exemplo n.º 6
0
/// Play the A.B.C's with each single syllable letter replaced by the
/// corresponding Morse code. W is transmitted once for each syllable.
/// After Z, the remainder of the song is played as simple tones.
void txAlphabetSong(MorseToken) {
  uint32_t saveHz(getTxHz());
  int saveDitMicros(getDitMicros());
  const char* letters("ABCDEFGHIJKLMNOPQRSTUVWWWXY Z ");
  const char*
    notes("C42C42G42G42" "A52A52G44" "F42F42E42E42" "D41D41D41D41C44"
	  "G42G42F44"    "E42E42D44" "G41G41G42F44" "E42E42D44"
	  "C42C42G42G42" "A52A52G44" "F42F42E42E42" "D42D42C44");
  char* l(const_cast<char*>(letters));
  char* p(const_cast<char*>(notes));
  while (*p) {
    size_t steps[] = { 0, 2, 3, 5, 7, 8, 10 };
    size_t note(steps[p[0] - 'A'] + 12 * (p[1]-'0'));
    size_t frequency(noteHz[note] + 0.5);
    size_t duration(saveDitMicros * (p[2] - '0') * 2 / 3);
    char buffer[] = { '\0', ' ', '\0' };
    buffer[0] = l[0];
    if (l[1]) {
      setTxHz(frequency);
      setDitMicros(duration);
      txString(buffer);
      delayMicroseconds((14 * saveDitMicros + 1) -
			(saveDitMicros * durationDits(l[0])));
      ++l;
    } else {
      // This part goes much faster, but it doesn't convey much
      // information.
      playTone(frequency, duration);
    }
    p += 3;
  }
  setTxHz(saveHz);
  setDitMicros(saveDitMicros);
}
Exemplo n.º 7
0
int main(void){
  //initialize GPIO pins
  set(PB3, 0);//set pb3 low
  
  //declare and initialize variables
  int32_t pause;
  int16_t repetition;
  //change this number to change the frequency
  //main loop
  while(1){    
    
    repetition = get(ADC1)/2;
    
    for (int j = 0; j<repetition; j++){
      set(PB1, HIGH);
      for (int i=0; i<max_count; i++) {
        tone = melody[i];
        beat = beats[i];
        //tempo = get(ADC1);
        //tempo *= 2;
        duration = beat * tempo; // Set up timing
        
        playTone();
        
        // A pause between chirps
      }
      
      set(PB1, LOW);
      pause = map(get(ADC1), 0, 255, 0, 7500000);
    }
    
    for(uint32_t j = 0; j < pause; j++) asm volatile("nop\n\t"::); //pause
  }
}
void playNote(char note, int duration) {
 char names[] = {'G','c','d','e','f','g','a','b','C'};
 int tones[] = {3500,1915,1700,1519,1432,1275,1136,1014,956};
 for(int i = 0;i<9;++i) {
   if(note==names[i]) playTone(tones[i],duration);
 }
}
Exemplo n.º 9
0
int main(void){
  //initialize GPIO pins
  set(PB3, 0);//set pb3 low
  
  //declare and initialize variables
  int32_t pause;
  //change this number to change the frequency
  //main loop
  while(1){    
    
    for (int i=0; i<max_count; i++) {
    tone = melody[i];
    beat = beats[i];
    //tempo = get(ADC1);
    //tempo *= 2;
    duration = beat * tempo; // Set up timing
    
    playTone();
    
    // A pause between chirps
    }
    
    set(PB1, HIGH);
    //pause = map(get(ADC1), 0, 255, 1000000, 0);
    pause = get(ADC1) * previous_chirp;
    previous_chirp = get(ADC1);
    if(previous_chirp == 0)
      previous_chirp = 1;
      
    pause *= 400;
    for(uint32_t j = 0; j < pause; j++) asm volatile("nop\n\t"::); //pause
    set(PB1, LOW);
  }
}
Exemplo n.º 10
0
void init() {
	playTone(700,10);
	startTask(LCD);
	startTask(flywheelVelocity);

	setBaudRate(UART1, baudRate57600);

	//Slave Motors
	slaveMotor(flywheel2,flywheel4);
	slaveMotor(flywheel3,flywheel4);
	slaveMotor(flywheel1,flywheel4);

	//Startup modes
	if(!debugMode)
		debugMode = (bool) SensorValue[debug];
	if(!tuneMode)
		tuneMode = (bool) SensorValue[tune];
	if(!encoderTestMode)
		encoderTestMode = (bool) SensorValue[encoderTest];

	//Boot into test encoder mode
	if(encoderTestMode)
		testEncoder();

	bool autonIntake = false;
	bool autonIndex = false;
	bool autonShoot = false;
}
Exemplo n.º 11
0
void Player::beep(int count)
  {
    for (int i = 0; i < count; i++)
    {
      playTone(440, _beepTempo/2);
      delay(_beepTempo/2);
    }
  }
Exemplo n.º 12
0
void Player::otherBeep(int count)
  {
    for (int i = 0; i < count; i++)
    {
      playTone(880, _beepTempo/2);
      delay(_beepTempo/2);
    }
  }
Exemplo n.º 13
0
void Soundy::helloworld() {
  Serial.print("Pin is ");
  Serial.println(_pin);
  for (int i = 4000; i > 10; i-= 10) {
    playTone(i,100);
    delay(100);
  }  
}
Exemplo n.º 14
0
/// If the top two elements of the stack are digits, convert them to a
/// number between 0-99 inclusive. Play the corresponding note.
void playNote(MorseToken) {
  if (1 < symbolStackSize() && isdigit(s(0).toChar()) && isdigit(s(1).toChar())) {
    size_t note(10 * (s(1).toChar() - '0') + (s(0).toChar() - '0'));
    playTone(noteHz[note] + 0.5, getDitMicros() * 60);
    txUnsigned(note);
  } else {
    txError();
  }
}
Exemplo n.º 15
0
void playNote(char note, int beat, int tempo) {
  char names[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C' };
  int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956 };
  // play the tone corresponding to the note name
  for (int i = 0; i < 8; i++) {
    if (names[i] == note) {
      playTone(tones[i], beat * tempo);
    }
 }
}
Exemplo n.º 16
0
void ExtendoHand::multiCue(
    unsigned int toneFrequency, unsigned long toneDurationMs,
    unsigned long color,
    unsigned long vibrateDurationMs) {

    setColor(color);
    vibrateNonBlocking(vibrateDurationMs);
    playTone(toneFrequency, toneDurationMs);
    setColor(RGB_BLACK);
}
Exemplo n.º 17
0
void torpedoSound()
{
	int freqs[] = {6000, 5000, 4000, 3000, 2000, 1500, 1000, 900, 800, 700, 600,
	500, 400, 300, 200};
	int i;
	for(i=0;i<15;i++)
	{
		playTone(freqs[i],50);
		sleep(20);
	}
}
Exemplo n.º 18
0
void Soundy::playNote(String note, int duration) {
  String names[] = { "C", "D", "E", "F", "G", "A", "B", "c", "d", "e", "f", "g", "a", "b"};
  int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956, 741, 560, 473, 351, 212, 90 };
  
  // play the tone corresponding to the note name
  for (int i = 0; i < 14; i++) {
    if (names[i] == note) {
      playTone(tones[i], duration);
    }
  }
}
Exemplo n.º 19
0
void sploosh()
{
	int i;
	int freq;
	for(i = 0; i < 3; i++)
	{
		freq = random(100) + 100;
		playTone(freq, 5);
		wait1Msec(100);
	}
}
Exemplo n.º 20
0
// ToDo: Add some type of event handler that gets called when the melody/tone has finished
void SoundTask::playMelody(const uint16_t melody[], const uint16_t tempo[], const uint16_t length) {
    clear();
    for (uint16_t index = 0; index < length; index++) {
        // calculate note duration
        const uint16_t noteDuration = 1000 / tempo[index];
        const uint16_t pauseAfterwards = noteDuration * 1.30;

        // queue up for future use
        playTone(melody[index], noteDuration, pauseAfterwards);
    }
}
Exemplo n.º 21
0
void Player::playNote(char note, int duration)
  {
    // play the tone corresponding to the note name
    for (int i = 0; i < 8; i++)
    {
      if (_names[i] == note)
      {
        playTone(_tones[i], duration);
      }
    }
  }
Exemplo n.º 22
0
void kabloom()
{
	int i;
	int freq;
	for(i = 0; i < 20; i++)
	{
		freq = random(100) + 200*sin(PI*i/19);
		playTone(freq, 5);
		wait1Msec(20);
	}
}
Exemplo n.º 23
0
void ParkingShield::playNote(char note, int duration) const
{
    char names[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C' };
    int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956 };

    // play the tone corresponding to the note name
    for (int i = 0; i < 8; i++)
    {
        if (names[i] == note)
            playTone(tones[i], duration);
    }
}
Exemplo n.º 24
0
void SmSnDevice::checkConnection(unsigned long now) {
    if (!connecting) {
        return;
    }

    if (connected) {
        connecting = false;
        okCue();
        /*
        if (droidspeak) {
            droidspeak->speakOK();
        }*/
        playTone(1760,100);
        playTone(880,100);
    } else if (now - lastConnectionAttempt > connectionRetryIntervalMs) {
        lastConnectionAttempt = now;
        warningCue();
        OSCMessage m(address(OSC_PING));
        osc.sendOSC(m);
    }
}
Exemplo n.º 25
0
void playMelody( int melody[], int beats[], int count ) {
  // Set up a counter to pull from melody[] and beats[]
  for (int i=0; i<count; i++) {
    tone_ = melody[i];
    beat = beats[i];

    duration = beat * tempo; // Set up timing

    playTone();
    // A pause between notes...
    delayMicroseconds(pause);
  }
}
Exemplo n.º 26
0
void playNote(char note, int duration) {

    char names[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C', 'D' };
    int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956, 1702 };
    int i;

    // play the tone corresponding to the note name
    for (i = 0; i < 8; i++) {
        if (names[i] == note) {
          playTone(tones[i], duration);
        }
    }
}
Exemplo n.º 27
0
void playNote(char note, int duration) 
  { 
    char names[] = {'C', 'D', 'E', 'F', 'G', 'A', 'B', 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'x', 'y' }; 
    int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956, 834, 765, 593, 468, 346, 224, 655 , 715 }; 
    int SPEE = 5; // play the tone corresponding to the note name 
    for (int i = 0; i < 17; i++) 
      {   
        if (names[i] == note) 
          { 
            int newduration = duration/SPEE; 
            playTone(tones[i], newduration); 
          } 
       } 
   } 
Exemplo n.º 28
0
void Buzzer::playNote(char note, int beat) {
 
  int freq = getFrequency(note);
  if (freq == -1) {
    // not supported
    return;
  }
  else if (freq == 0) {
    // rest
    delay(beat * tempo); 
  }
  else {
    playTone(freq, beat * tempo);
  }
}
Exemplo n.º 29
0
void playNext()
{
  if (queueHead == NULL)/*No more queue items to play*/
    {
      /*we must notify, there are no more items to play*/
      printf("silence\n");
      fflush(stdout);
      return;
    }
  if (queueHead->type == QUEUE_ITEM_TONE)
    playTone(queueHead->freq, queueHead->duration);
  else
    execute(queueHead->synthCommand, queueHead->playerCommand, queueHead->text);
  popQueueFront();
}
Exemplo n.º 30
0
void guitarTune(MorseToken) {
   uint32_t duration(getDitMicros() * 6);
   // EADGBE
   playTone(noteHz[40] + 0.5, duration);
   playTone(noteHz[45] + 0.5, duration);
   playTone(noteHz[50] + 0.5, duration);
   playTone(noteHz[55] + 0.5, duration);
   playTone(noteHz[59] + 0.5, duration);
   playTone(noteHz[64] + 0.5, duration);
}