Skip to content

Commit

Permalink
Pxt core bump 9.1.1x and more (#1038)
Browse files Browse the repository at this point in the history
* bump-pxt-core

Timely update of the pxt-core version to support the project.

* active-item-fill-height-change

* pxt-core-bump-9.1.14

* pxt-bump-9-1-15

* add-subcategories-planned-sens

* ht-color-sen-add-lib

* Remove-queryArr-and-infoArr

Got rid of queryArr and infoArr, which I created to support the color sensor in the RawRgb mode in the simulator.

* revert-ms-automation-ext

Revert automation extension.

* pxt-bump-9.1.16

* move-status-indicator-to-new-group

Move the status indicator to a separate group. It was in a button group, but according to the ev3 manual it is not a button, so I created a separate group for it and output the code to a separate file. It's logical.

* exitProgram-moved-from-buttons-to-program

exitProgram has been moved from buttons to the program group.

* bump-pxt-9.1.17

* pxt-bump-9.1.18

* pxt-bump-9.1.19

* i2c-sens-work-when-start-program

The i2c sensors will work when the program starts. Before this, the i2c sensor started working only when other sensors were reconnected, calling detectDevices() again.

* Update input.ts

* Update input.ts

* pxt-bump-9.1.21

* pxt-bump-9.1.23

* color-for-separator-lego-ana-microsoft-logos

* Update style.less

* Update style.less

* revert-approvedRepos

* Update targetconfig.json
  • Loading branch information
THEb0nny authored Nov 3, 2023
1 parent 7778d29 commit 92ff131
Show file tree
Hide file tree
Showing 14 changed files with 206 additions and 261 deletions.
36 changes: 11 additions & 25 deletions libs/color-sensor/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ namespace sensors {
else maxModeRange = 100; // ReflectedLightIntensity or AmbientLightIntensity
this._setMode(m); // Change mode
pause(MODE_SWITCH_DELAY);
pauseUntil(() => (this.getStatus() == 8 && (this.mode == ColorSensorMode.RgbRaw ? this._queryArr()[0] : this._query()) <= maxModeRange)); // Pause until mode change
pauseUntil(() => (this.getStatus() == 8 && this._query()[0] <= maxModeRange)); // Pause until mode change
} else {
this._setMode(m);
}
Expand All @@ -98,47 +98,33 @@ namespace sensors {
if (this.mode == ColorSensorMode.Color
|| this.mode == ColorSensorMode.AmbientLightIntensity
|| this.mode == ColorSensorMode.ReflectedLightIntensity)
return this.getNumber(NumberFormat.UInt8LE, 0)
return [this.getNumber(NumberFormat.UInt8LE, 0)];
else if (this.mode == ColorSensorMode.RefRaw)
return this.getNumber(NumberFormat.UInt16LE, 0)
return 0
}

_queryArr(): number[] {
if (this.mode == ColorSensorMode.RgbRaw) {
return [this.getNumber(NumberFormat.UInt16LE, 0)];
else if (this.mode == ColorSensorMode.RgbRaw) {
return [this.getNumber(NumberFormat.UInt16LE, 0), this.getNumber(NumberFormat.UInt16LE, 2), this.getNumber(NumberFormat.UInt16LE, 4)];
}
return [0, 0, 0];
return [0];
}

_info(): string {
_info() {
switch (this.mode) {
case ColorSensorMode.Color:
return ["none",
return [["none",
"black",
"blue",
"green",
"yellow",
"red",
"white",
"brown"][this._query()];
"brown"][this._query()[0]]];
case ColorSensorMode.AmbientLightIntensity:
case ColorSensorMode.ReflectedLightIntensity:
return `${this._query()}%`;
case ColorSensorMode.RgbRaw:
return "array";
default:
return this._query().toString();
}
}

_infoArr(): string[] {
switch (this.mode) {
return [`${this._query()}%`];
case ColorSensorMode.RgbRaw:
const queryArr = this._queryArr().map(number => number.toString());
return queryArr;
return this._query().map(number => number.toString());
default:
return ["0", "0", "0"];
return [this._query()[0].toString()];
}
}

Expand Down
59 changes: 1 addition & 58 deletions libs/core/buttons.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,3 @@

/**
* Patterns for lights under the buttons.
*/
const enum StatusLight {
//% block=off enumval=0
Off = 0,
//% block=green enumval=1
Green = 1,
//% block=red enumval=2
Red = 2,
//% block=orange enumval=3
Orange = 3,
//% block="green flash" enumval=4
GreenFlash = 4,
//% block="red flash" enumval=5
RedFlash = 5,
//% block="orange flash" enumval=6
OrangeFlash = 6,
//% block="green pulse" enumval=7
GreenPulse = 7,
//% block="red pulse" enumval=8
RedPulse = 8,
//% block="orange pulse" enumval=9
OrangePulse = 9,
}

/**
* User interaction on buttons
*/
Expand Down Expand Up @@ -246,34 +219,4 @@ namespace control {
}
return r
}
}

namespace brick {
// the brick starts with the red color
let currPattern: StatusLight = StatusLight.Off;

/**
* Gets the current light pattern.
*/
//% weight=99 group="Buttons"
//% help=brick/status-light
export function statusLight() {
return currPattern;
}

/**
* Set lights.
* @param pattern the lights pattern to use. eg: StatusLight.Orange
*/
//% blockId=setLights block="set status light to %pattern"
//% weight=100 group="Buttons"
//% help=brick/set-status-light
export function setStatusLight(pattern: StatusLight): void {
if (currPattern === pattern)
return
currPattern = pattern;
const cmd = output.createBuffer(2)
cmd[0] = pattern + 48
brick.internal.getBtnsMM().write(cmd)
}
}
}
55 changes: 55 additions & 0 deletions libs/core/indicator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* Patterns for lights under the buttons.
*/
const enum StatusLight {
//% block=off enumval=0
Off = 0,
//% block=green enumval=1
Green = 1,
//% block=red enumval=2
Red = 2,
//% block=orange enumval=3
Orange = 3,
//% block="green flash" enumval=4
GreenFlash = 4,
//% block="red flash" enumval=5
RedFlash = 5,
//% block="orange flash" enumval=6
OrangeFlash = 6,
//% block="green pulse" enumval=7
GreenPulse = 7,
//% block="red pulse" enumval=8
RedPulse = 8,
//% block="orange pulse" enumval=9
OrangePulse = 9,
}

namespace brick {
// the brick starts with the red color
let currPattern: StatusLight = StatusLight.Off;

/**
* Gets the current light pattern.
*/
//% weight=99 group="Indicator"
//% help=brick/status-light
export function statusLight() {
return currPattern;
}

/**
* Set lights.
* @param pattern the lights pattern to use. eg: StatusLight.Orange
*/
//% blockId=setLights block="set status light to %pattern"
//% weight=100 group="Indicator"
//% help=brick/set-status-light
export function setStatusLight(pattern: StatusLight): void {
if (currPattern === pattern)
return
currPattern = pattern;
const cmd = output.createBuffer(2)
cmd[0] = pattern + 48
brick.internal.getBtnsMM().write(cmd)
}
}
Loading

0 comments on commit 92ff131

Please sign in to comment.