Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transferring blocks from the calibration section #1042

Merged
merged 3 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 20 additions & 18 deletions libs/color-sensor/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ namespace sensors {
//% parts="colorsensor"
//% blockNamespace=sensors
//% this.fieldEditor="ports"
//% weight=100 blockGap=12
//% weight=100 blockGap=8
//% group="Color Sensor"
onColorDetected(color: number, handler: () => void) {
this.setMode(ColorSensorMode.Color)
Expand All @@ -167,7 +167,7 @@ namespace sensors {
//% parts="colorsensor"
//% blockNamespace=sensors
//% this.fieldEditor="ports"
//% weight=99 blockGap=8
//% weight=98 blockGap=8
//% group="Color Sensor"
pauseUntilColorDetected(color: number) {
this.setMode(ColorSensorMode.Color);
Expand All @@ -187,9 +187,8 @@ namespace sensors {
//% parts="colorsensor"
//% blockNamespace=sensors
//% this.fieldEditor="ports"
//% weight=98
//% weight=97 blockGap=8
//% group="Color Sensor"
//% blockGap=8
color(): ColorSensorColor {
this.setMode(ColorSensorMode.Color);
this.poke();
Expand Down Expand Up @@ -221,9 +220,8 @@ namespace sensors {
//% parts="colorsensor"
//% blockNamespace=sensors
//% this.fieldEditor="ports"
//% weight=1
//% weight=89
//% group="Color Sensor"
//% blockGap=8
rgbRaw(): number[] {
this.setMode(ColorSensorMode.RgbRaw);
this.poke();
Expand All @@ -241,7 +239,7 @@ namespace sensors {
//% parts="colorsensor"
//% blockNamespace=sensors
//% this.fieldEditor="ports"
//% weight=89 blockGap=12
//% weight=79 blockGap=8
//% group="Color Sensor"
onLightDetected(mode: LightIntensityMode, condition: Light, handler: () => void) {
this.setMode(<ColorSensorMode><number>mode)
Expand All @@ -258,7 +256,7 @@ namespace sensors {
//% parts="colorsensor"
//% blockNamespace=sensors
//% this.fieldEditor="ports"
//% weight=88 blockGap=8
//% weight=78 blockGap=8
//% group="Color Sensor"
pauseUntilLightDetected(mode: LightIntensityMode, condition: Light) {
this.setMode(<ColorSensorMode><number>mode)
Expand All @@ -276,7 +274,7 @@ namespace sensors {
//% parts="colorsensor"
//% blockNamespace=sensors
//% this.fieldEditor="ports"
//% weight=87 blockGap=8
//% weight=77
//% group="Color Sensor"
light(mode: LightIntensityMode) {
this.setMode(<ColorSensorMode><number>mode);
Expand Down Expand Up @@ -318,11 +316,12 @@ namespace sensors {
* @param condition the dark or bright light condition
* @param value the value threshold, eg: 10
*/
//% help=sensors/color-sensor/set-threshold
//% blockId=colorSetThreshold block="set **color sensor** %this|%condition|to %value"
//% group="Calibration" blockGap=8 weight=90
//% value.min=0 value.max=100
//% this.fieldEditor="ports"
//% help=sensors/color-sensor/set-threshold
//% weight=67 blockGap=8
//% group="Color Sensor"
setThreshold(condition: Light, value: number) {
// threshold is used in ambient or reflected modes
if (this.mode != LightIntensityMode.Ambient &&
Expand All @@ -339,10 +338,11 @@ namespace sensors {
* Get a threshold value
* @param condition the light condition
*/
//% help=sensors/color-sensor/threshold
//% blockId=colorGetThreshold block="**color sensor** %this|%condition"
//% group="Calibration" weight=89
//% this.fieldEditor="ports"
//% help=sensors/color-sensor/threshold
//% weight=68 blockGap=8
//% group="Color Sensor"
threshold(condition: Light): number {
// threshold is used in ambient or reflected modes
if (this.mode != LightIntensityMode.Ambient &&
Expand All @@ -355,10 +355,11 @@ namespace sensors {
/**
* Collects measurement of the light condition and adjusts the threshold to 10% / 90%.
*/
//% help=sensors/color-sensor/calibrate-light
//% blockId=colorCalibrateLight block="calibrate **color sensor** %this|for %mode"
//% group="Calibration" weight=91 blockGap=8
//% this.fieldEditor="ports"
//% help=sensors/color-sensor/calibrate-light
//% weight=69 blockGap=8
//% group="Color Sensor"
calibrateLight(mode: LightIntensityMode, deviation: number = 8) {
this.calibrating = true; // prevent events

Expand Down Expand Up @@ -423,10 +424,11 @@ namespace sensors {
* @param color the color sensed by the sensor, eg: ColorSensorColor.Red
*/
//% shim=TD_ID
//% blockId=colorSensorColor block="color %color=colorEnumPicker"
//% group="Color Sensor"
//% weight=97
//% help=sensors/color
//% blockId=colorSensorColor
//% block="color %color=colorEnumPicker"
//% weight=96
//% group="Color Sensor"
export function color(color: number): ColorSensorColor {
return color;
}
Expand Down
2 changes: 1 addition & 1 deletion libs/ev3/ns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace brick {

//% color="#C8509B" weight=95 icon="\uf10f"
//% labelLineWidth=100
//% groups='["Touch Sensor", "Color Sensor", "Ultrasonic Sensor", "Gyro Sensor", "Infrared Sensor", "Remote Infrared Beacon", "Calibration"]'
//% groups='["Touch Sensor", "Color Sensor", "Ultrasonic Sensor", "Gyro Sensor", "Infrared Sensor", "Remote Infrared Beacon"]'
//% subcategories='["NXT", "HiTechnic"]'
namespace sensors {
}
Expand Down
14 changes: 7 additions & 7 deletions libs/gyro-sensor/gyro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace sensors {
//% parts="gyroscope"
//% blockNamespace=sensors
//% this.fieldEditor="ports"
//% weight=64 blockGap=8
//% weight=100 blockGap=8
//% group="Gyro Sensor"
angle(): number {
this.poke();
Expand All @@ -67,7 +67,7 @@ namespace sensors {
//% parts="gyroscope"
//% blockNamespace=sensors
//% this.fieldEditor="ports"
//% weight=65 blockGap=8
//% weight=99 blockGap=8
//% group="Gyro Sensor"
rate(): number {
this.poke();
Expand All @@ -86,7 +86,7 @@ namespace sensors {
//% parts="gyroscope"
//% blockNamespace=sensors
//% this.fieldEditor="ports"
//% weight=51 blockGap=8
//% weight=89 blockGap=8
//% group="Gyro Sensor"
calibrate(): void {
if (this._calibrating) return; // already in calibration mode
Expand Down Expand Up @@ -157,7 +157,7 @@ namespace sensors {
//% parts="gyroscope"
//% blockNamespace=sensors
//% this.fieldEditor="ports"
//% weight=50 blockGap=8
//% weight=88
//% group="Gyro Sensor"
reset(): void {
if (this._calibrating) return; // already in calibration mode
Expand Down Expand Up @@ -202,7 +202,7 @@ namespace sensors {
//% parts="gyroscope"
//% blockNamespace=sensors
//% this.fieldEditor="ports"
//% weight=9 blockGap=8
//% weight=78 blockGap=8
//% group="Gyro Sensor"
drift(): number {
return this._drift;
Expand All @@ -217,7 +217,7 @@ namespace sensors {
//% parts="gyroscope"
//% blockNamespace=sensors
//% this.fieldEditor="ports"
//% weight=10 blockGap=8
//% weight=79 blockGap=8
//% group="Gyro Sensor"
computeDrift() {
if (this._calibrating)
Expand All @@ -238,7 +238,7 @@ namespace sensors {
//% blockNamespace=sensors
//% this.fieldEditor="ports"
//% degrees.defl=90
//% weight=63
//% weight=98
//% group="Gyro Sensor"
pauseUntilRotated(degrees: number, timeOut?: number): void {
let a = this.angle();
Expand Down
8 changes: 5 additions & 3 deletions libs/infrared-sensor/ir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ namespace sensors {
//% blockId=infraredGetProximity
//% parts="infrared"
//% blockNamespace=sensors
//% weight=98 blockGap=8
//% weight=98
//% group="Infrared Sensor"
//% this.fieldEditor="ports"
proximity(): number {
Expand Down Expand Up @@ -262,7 +262,8 @@ namespace sensors {
* @param value the value threshold
*/
//% blockId=irSetThreshold block="set **infrared** %this|%condition|to %value"
//% group="Calibration" blockGap=8 weight=49
//% blockGap=8 weight=49
//% group="Infrared Sensor"
//% value.min=0 value.max=100
//% this.fieldEditor="ports"
setPromixityThreshold(condition: InfraredSensorEvent, value: number) {
Expand All @@ -277,7 +278,8 @@ namespace sensors {
* @param condition the proximity condition
*/
//% blockId=irGetThreshold block="**infrared** %this|%condition"
//% group="Calibration" weight=49
//% weight=48
//% group="Infrared Sensor"
//% this.fieldEditor="ports"
proximityThreshold(condition: InfraredSensorEvent): number {
return this._proximityThreshold.threshold(<ThresholdState><number>condition);
Expand Down
12 changes: 5 additions & 7 deletions libs/touch-sensor/touch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace sensors {
//% parts="touch"
//% blockNamespace=sensors
//% this.fieldEditor="ports"
//% weight=99 blockGap=12
//% weight=99 blockGap=8
//% group="Touch Sensor"
onEvent(ev: ButtonEvent, body: () => void) {
this.button.onEvent(ev, body)
Expand All @@ -54,7 +54,7 @@ namespace sensors {
//% parts="touch"
//% blockNamespace=sensors
//% this.fieldEditor="ports"
//% weight=98 blockGap=12
//% weight=98 blockGap=8
//% group="Touch Sensor"
pauseUntil(ev: ButtonEvent) {
this.button.pauseUntil(<ButtonEvent><number>ev);
Expand All @@ -65,8 +65,7 @@ namespace sensors {
* @param sensor the port to query the request
*/
//% help=sensors/touch-sensor/is-pressed
//% block="**touch** %this|is pressed"
//% blockId=touchIsPressed
//% blockId=touchIsPressed block="**touch** %this|is pressed"
//% parts="touch"
//% blockNamespace=sensors
//% this.fieldEditor="ports"
Expand All @@ -82,13 +81,12 @@ namespace sensors {
* @param sensor the port to query the request
*/
//% help=sensors/touch-sensor/was-pressed
//% block="**touch** %this|was pressed"
//% blockId=touchWasPressed
//% blockId=touchWasPressed block="**touch** %this|was pressed"
//% blockHidden=true
//% parts="touch"
//% blockNamespace=sensors
//% this.fieldEditor="ports"
//% weight=81
//% weight=80
//% group="Touch Sensor"
wasPressed() {
this.poke();
Expand Down
10 changes: 6 additions & 4 deletions libs/ultrasonic-sensor/ultrasonic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace sensors {
//% blockNamespace=sensors
//% this.fieldEditor="ports"
//% weight=100 blockGap=8
//% group="Ultrasonic Sensor"
//% group="Ultrasonic Sensor"
onEvent(event: UltrasonicSensorEvent, handler: () => void) {
control.onEvent(this._id, event, handler);
}
Expand Down Expand Up @@ -81,7 +81,7 @@ namespace sensors {
//% parts="ultrasonicsensor"
//% blockNamespace=sensors
//% this.fieldEditor="ports"
//% weight=65
//% weight=98
//% group="Ultrasonic Sensor"
distance(): number {
this.poke();
Expand All @@ -97,7 +97,8 @@ namespace sensors {
* @param value the value threshold
*/
//% blockId=ultrasonicSetThreshold block="set **ultrasonic** %this|%condition|to %value"
//% group="Calibration" blockGap=8 weight=80
//% weight=89 blockGap=8
//% group="Ultrasonic Sensor"
//% value.min=0 value.max=255
//% this.fieldEditor="ports"
setThreshold(condition: UltrasonicSensorEvent, value: number) {
Expand All @@ -112,7 +113,8 @@ namespace sensors {
* @param condition the proximity condition
*/
//% blockId=ultrasonicGetThreshold block="**ultrasonic** %this|%condition"
//% group="Calibration" weight=79
//% weight=88
//% group="Ultrasonic Sensor"
//% this.fieldEditor="ports"
threshold(condition: UltrasonicSensorEvent): number {
switch (condition) {
Expand Down