1 #include <pololu/orangutan> 2 #include <stdio.h> 3 #include <avr/pgmspace.h> 4 #include "assert.h" 5 6 const char efg[] PROGMEM = "m S e8... f O5 <g"; 7 8 extern OrangutanLCD lcd; 9 extern OrangutanBuzzer buzzer; 10 test_buzzer()11void test_buzzer() 12 { 13 lcd.clear(); 14 printf("Volume\nchange?"); 15 16 buzzer.play("o5 l8 v1 c v2 c v3 c v4 c v5 c v6 c v7 c v8 c v9 v v10 c v11 c v12 c v13 c v14 c v15 c"); 17 while(buzzer.isPlaying()); 18 19 OrangutanPushbuttons::waitForButton(ALL_BUTTONS); 20 21 lcd.clear(); 22 printf("Nice\nscale?"); 23 24 buzzer.play("o4 l4 ms c"); 25 while(buzzer.isPlaying()); 26 buzzer.play("ML d 1 6 d 16 r 8"); 27 while(buzzer.isPlaying()); 28 buzzer.playFromProgramSpace(efg); 29 while(buzzer.isPlaying()); 30 31 while(buzzer.isPlaying()); 32 33 // buzzer.play a long note but cut it off at 250 ms 34 buzzer.play("o4 a2"); 35 delay(250); 36 buzzer.stopPlaying(); 37 delay(250); 38 39 buzzer.play("ml t240 o4 b t120 l8 >c "); // these notes should take 250 ms, like the others 40 buzzer.playMode(PLAY_CHECK); // should just buzzer.play the first note until we check 41 delay(500); 42 43 while(buzzer.isPlaying()) // should terminate correctly 44 buzzer.playCheck(); 45 46 buzzer.playMode(PLAY_AUTOMATIC); 47 48 OrangutanPushbuttons::waitForButton(ALL_BUTTONS); 49 } 50