Calibrate compass (#392)
* adding 'calibrate-compass' function * fixing simulator. * updated docs * fixing compat test suite with 'calibrate()' function
This commit is contained in:
		@@ -99,7 +99,8 @@
 | 
			
		||||
  "input.acceleration|param|dimension": "TODO",
 | 
			
		||||
  "input.buttonIsPressed": "Get the button state (pressed or not) for ``A`` and ``B``.",
 | 
			
		||||
  "input.buttonIsPressed|param|button": "the button to query the request, eg: Button.A",
 | 
			
		||||
  "input.calibrate": "Obsolete, compass calibration is automatic.",
 | 
			
		||||
  "input.calibrate": "Obsolete, use input.calibrateCompass instead.",
 | 
			
		||||
  "input.calibrateCompass": "Obsolete, compass calibration is automatic.",
 | 
			
		||||
  "input.compassHeading": "Get the current compass heading in degrees.",
 | 
			
		||||
  "input.lightLevel": "Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.",
 | 
			
		||||
  "input.magneticForce": "Get the magnetic force value in ``micro-Teslas`` (``µT``). This function is not supported in the simulator.",
 | 
			
		||||
 
 | 
			
		||||
@@ -220,6 +220,7 @@
 | 
			
		||||
  "images|block": "images",
 | 
			
		||||
  "input.acceleration|block": "acceleration (mg)|%NAME",
 | 
			
		||||
  "input.buttonIsPressed|block": "button|%NAME|is pressed",
 | 
			
		||||
  "input.calibrateCompass|block": "calibrate compass",
 | 
			
		||||
  "input.compassHeading|block": "compass heading (°)",
 | 
			
		||||
  "input.lightLevel|block": "light level",
 | 
			
		||||
  "input.magneticForce|block": "magnetic force (µT)|%NAME",
 | 
			
		||||
 
 | 
			
		||||
@@ -313,8 +313,11 @@ namespace input {
 | 
			
		||||
    /**
 | 
			
		||||
     * Obsolete, compass calibration is automatic.
 | 
			
		||||
     */
 | 
			
		||||
    //% help=input/calibrate weight=0
 | 
			
		||||
    void calibrate() { }
 | 
			
		||||
    //% help=input/calibrate-compass advanced=true
 | 
			
		||||
    //% blockId="input_compass_calibrate" block="calibrate compass"
 | 
			
		||||
    void calibrateCompass() { 
 | 
			
		||||
        uBit.compass.calibrate();        
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Sets the accelerometer sample range in gravities.
 | 
			
		||||
 
 | 
			
		||||
@@ -47,4 +47,12 @@ namespace input {
 | 
			
		||||
    export function onLogoDown(body: Action): void {
 | 
			
		||||
        onGesture(Gesture.LogoDown, body);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Obsolete, use input.calibrateCompass instead.
 | 
			
		||||
     */
 | 
			
		||||
    //% weight=0 help=input/calibrate-compass
 | 
			
		||||
    export function calibrate() {
 | 
			
		||||
        input.calibrateCompass();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										5
									
								
								libs/core/shims.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								libs/core/shims.d.ts
									
									
									
									
										vendored
									
									
								
							@@ -339,8 +339,9 @@ declare namespace input {
 | 
			
		||||
    /**
 | 
			
		||||
     * Obsolete, compass calibration is automatic.
 | 
			
		||||
     */
 | 
			
		||||
    //% help=input/calibrate weight=0 shim=input::calibrate
 | 
			
		||||
    function calibrate(): void;
 | 
			
		||||
    //% help=input/calibrate-compass advanced=true
 | 
			
		||||
    //% blockId="input_compass_calibrate" block="calibrate compass" shim=input::calibrateCompass
 | 
			
		||||
    function calibrateCompass(): void;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Sets the accelerometer sample range in gravities.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user