@@ -362,6 +362,16 @@ enum BBirNoAny
362362 Go = 56
363363}
364364
365+ /**
366+ * Volume settings for Buzzer
367+ */
368+ enum BBBuzzVolume
369+ {
370+ Off = 0 ,
371+ Quiet = 130 ,
372+ Medium = 160 ,
373+ Loud = 200
374+ }
365375
366376/**
367377 * Custom blocks
@@ -1388,14 +1398,14 @@ namespace bitbot
13881398 }
13891399 }
13901400
1391- // Power Management Block
1401+ // General Blocks that don't quite fit anywhere else
13921402 /**
13931403 * Read the battery voltage
13941404 */
13951405 //% blockId="BBBattery" block="battery voltage"
13961406 //% weight=100
13971407 //% subcategory="BitBot PRO"
1398- //% group="Power "
1408+ //% group="General "
13991409 export function batteryVoltage ( ) : number
14001410 {
14011411 if ( isPRO ( ) )
@@ -1407,6 +1417,24 @@ namespace bitbot
14071417 return 0
14081418 }
14091419
1420+ /**
1421+ * Set the buzzer volume
1422+ */
1423+ //% blockId="BBVolume"
1424+ //% block="set buzzer volume%volume"
1425+ //% weight=90
1426+ //% subcategory="BitBot PRO"
1427+ //% group="General"
1428+ export function setVolume ( volume : BBBuzzVolume ) : void
1429+ {
1430+ if ( isPRO ( ) )
1431+ {
1432+ music . setVolume ( volume )
1433+ if ( control . hardwareVersion ( ) == '1' )
1434+ music . stopAllSounds ( )
1435+ }
1436+ }
1437+
14101438
14111439// Built-in Infrared Receiver Blocks - BitBot PRO Only
14121440
@@ -1863,7 +1891,7 @@ namespace bitbot
18631891// Built-in Sensors - Inputs and Outputs
18641892
18651893 /**
1866- * Sound a buzz.
1894+ * Turn On/Off buzzer
18671895 * @param flag state of buzzer (On or Off)
18681896 */
18691897 //% blockId="bitbot_buzz" block="turn buzzer%flag"
@@ -1886,6 +1914,20 @@ namespace bitbot
18861914 }
18871915 }
18881916
1917+ /**
1918+ * Sound buzzer for selected time
1919+ * @param duration time for buzzer to sound in ms eg: 400
1920+ */
1921+ //% blockId="bitbot_sound" block="sound buzzer for%duration|ms"
1922+ //% weight=95
1923+ //% subcategory="Inputs & Outputs"
1924+ export function buzzTime ( duration : number ) : void
1925+ {
1926+ buzz ( true )
1927+ basic . pause ( duration )
1928+ buzz ( false )
1929+ }
1930+
18891931 /**
18901932 * Read distance from sonar module connected to accessory connector.
18911933 * @param unit desired conversion unit
0 commit comments