Skip to content

Commit

Permalink
move isCalibratedCompass() into core
Browse files Browse the repository at this point in the history
  • Loading branch information
Amerlander committed Nov 22, 2023
1 parent 0c24722 commit 9ece957
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"input": "Events and data from sensors",
"input.assumeCalibrationCompass": "Obsolete, compass calibration is automatic.",
"input.clearCalibrationCompass": "Obsolete, compass calibration is automatic.",
"input.isCalibratedCompass": "Returns 'true' when the compass is calibrated. Otherwise returns 'false'.",
"input.loudness": "gets the level of loudness from 0 (silent) to 255 (loud)",
"motors": "Blocks to control the onboard motors",
"motors.dualMotorPower": "Controls two motors attached to the board. Switches to dual-motor mode!",
Expand Down
4 changes: 1 addition & 3 deletions libs/core-mini-dal/_locales/core-mini-dal-strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"basic|block": "basic",
"input.assumeCalibrationCompass|block": "assume calibration compass",
"input.clearCalibrationCompass|block": "clear calibration compass",
"input.isCalibratedCompass|block": "is compass calibrated",
"input.loudness|block": "Loudness",
"input|block": "input",
"motors.dualMotorPower|block": "motor %motor|at %percent \\%",
Expand All @@ -14,6 +13,5 @@
"{id:category}Input": "Input",
"{id:category}Motors": "Motors",
"{id:group}Configuration": "Configuration",
"{id:group}RGB LED": "RGB LED",
"{id:group}System": "System"
"{id:group}RGB LED": "RGB LED"
}
15 changes: 2 additions & 13 deletions libs/core-mini-dal/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,14 @@
//% color=#c90072 weight=99 icon="\uf192"
namespace input {

/**
* Returns 'true' when the compass is calibrated. Otherwise returns 'false'.
*/
//% help=input/calibrate-compass advanced=true
//% blockId="input_compass_is_calibrated" block="is compass calibrated"
//% weight=19
//% group="System"
bool isCalibratedCompass() {
return (uBit.compass.isCalibrated() == 1);
}

/**
* Obsolete, compass calibration is automatic.
*/
//% help=input/calibrate-compass advanced=true
//% blockId="input_compass_clear_calibration" block="clear calibration compass"
//% weight=17
//% group="Configuration"
//% blockHidden=true
//% blockHidden=true deprecated=true
void clearCalibrationCompass() {
uBit.compass.clearCalibration();
}
Expand All @@ -33,7 +22,7 @@ namespace input {
//% blockId="input_compass_assume_calibration" block="assume calibration compass"
//% weight=16
//% group="Configuration"
//% blockHidden=true
//% blockHidden=true deprecated=true
void assumeCalibrationCompass() {
uBit.compass.assumeCalibration();
}
Expand Down
13 changes: 2 additions & 11 deletions libs/core-mini-dal/shims.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,14 @@
//% color=#c90072 weight=99 icon="\uf192"
declare namespace input {

/**
* Returns 'true' when the compass is calibrated. Otherwise returns 'false'.
*/
//% help=input/calibrate-compass advanced=true
//% blockId="input_compass_is_calibrated" block="is compass calibrated"
//% weight=19
//% group="System" shim=input::isCalibratedCompass
function isCalibratedCompass(): boolean;

/**
* Obsolete, compass calibration is automatic.
*/
//% help=input/calibrate-compass advanced=true
//% blockId="input_compass_clear_calibration" block="clear calibration compass"
//% weight=17
//% group="Configuration"
//% blockHidden=true shim=input::clearCalibrationCompass
//% blockHidden=true deprecated=true shim=input::clearCalibrationCompass
function clearCalibrationCompass(): void;

/**
Expand All @@ -31,7 +22,7 @@ declare namespace input {
//% blockId="input_compass_assume_calibration" block="assume calibration compass"
//% weight=16
//% group="Configuration"
//% blockHidden=true shim=input::assumeCalibrationCompass
//% blockHidden=true deprecated=true shim=input::assumeCalibrationCompass
function assumeCalibrationCompass(): void;
}

Expand Down
1 change: 1 addition & 0 deletions libs/core/_locales/core-jsdoc-strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@
"input.buttonIsPressed|param|button": "the button to query the request, eg: Button.A",
"input.calibrateCompass": "Obsolete, compass calibration is automatic.",
"input.compassHeading": "Get the current compass heading in degrees.",
"input.isCalibratedCompass": "Returns 'true' when the compass is calibrated. Otherwise returns 'false'.",
"input.isGesture": "Tests if a gesture is currently detected.",
"input.isGesture|param|gesture": "the type of gesture to detect, eg: Gesture.Shake",
"input.lightLevel": "Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.",
Expand Down
1 change: 1 addition & 0 deletions libs/core/_locales/core-strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@
"input.buttonIsPressed|block": "button|%NAME|is pressed",
"input.calibrateCompass|block": "calibrate compass",
"input.compassHeading|block": "compass heading (°)",
"input.isCalibratedCompass|block": "is compass calibrated",
"input.isGesture|block": "is %gesture gesture",
"input.lightLevel|block": "light level",
"input.magneticForce|block": "magnetic force (µT)|%NAME",
Expand Down
12 changes: 12 additions & 0 deletions libs/core/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,4 +438,16 @@ namespace input {
void setAccelerometerRange(AcceleratorRange range) {
uBit.accelerometer.setRange((int)range);
}

/**
* Returns 'true' when the compass is calibrated. Otherwise returns 'false'.
*/
//% help=input/calibrate-compass advanced=true
//% blockId="input_compass_is_calibrated" block="is compass calibrated"
//% weight=19
//% group="System"
bool isCalibratedCompass() {
return (uBit.compass.isCalibrated() == 1);
}

}
9 changes: 9 additions & 0 deletions libs/core/shims.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,15 @@ declare namespace input {
//% advanced=true
//% group="Configuration" shim=input::setAccelerometerRange
function setAccelerometerRange(range: AcceleratorRange): void;

/**
* Returns 'true' when the compass is calibrated. Otherwise returns 'false'.
*/
//% help=input/calibrate-compass advanced=true
//% blockId="input_compass_is_calibrated" block="is compass calibrated"
//% weight=19
//% group="System" shim=input::isCalibratedCompass
function isCalibratedCompass(): boolean;
}


Expand Down

0 comments on commit 9ece957

Please sign in to comment.