Compare commits
1 Commits
v1.4.24
...
upgradetsv
Author | SHA1 | Date | |
---|---|---|---|
|
fecfdc4c11 |
40
.github/workflows/pxt-buildmain.yml
vendored
40
.github/workflows/pxt-buildmain.yml
vendored
@@ -1,40 +0,0 @@
|
||||
name: pxt-buildmain
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
- 'main'
|
||||
create:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [8.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: npm install
|
||||
run: |
|
||||
sudo apt-get install xvfb
|
||||
sudo npm install -g pxt
|
||||
npm install
|
||||
- name: pxt ci
|
||||
run: |
|
||||
pxt ci
|
||||
env:
|
||||
CROWDIN_KEY: ${{ secrets.CROWDIN_KEY }}
|
||||
PXT_ACCESS_TOKEN: ${{ secrets.PXT_ACCESS_TOKEN }}
|
||||
PXT_RELEASE_REPO: ${{ secrets.PXT_RELEASE_REPO }}
|
||||
NPM_ACCESS_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
|
||||
CHROME_BIN: chromium-browser
|
||||
DISPLAY: :99.0
|
||||
CI: true
|
31
.github/workflows/pxt-buildpr.yml
vendored
31
.github/workflows/pxt-buildpr.yml
vendored
@@ -1,31 +0,0 @@
|
||||
name: pxt-buildpr
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [8.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: npm install
|
||||
run: |
|
||||
sudo apt-get install xvfb
|
||||
sudo npm install -g pxt
|
||||
npm install
|
||||
- name: pxt ci
|
||||
run: |
|
||||
pxt ci
|
||||
env:
|
||||
CHROME_BIN: chromium-browser
|
||||
DISPLAY: :99.0
|
||||
CI: true
|
39
.github/workflows/pxt-buildpush.yml
vendored
39
.github/workflows/pxt-buildpush.yml
vendored
@@ -1,39 +0,0 @@
|
||||
name: pxt-buildpush
|
||||
|
||||
on:
|
||||
push:
|
||||
# main/master has its own build that includes the crowdin key
|
||||
branches-ignore:
|
||||
- 'main'
|
||||
- 'master'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [8.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: npm install
|
||||
run: |
|
||||
sudo apt-get install xvfb
|
||||
sudo npm install -g pxt
|
||||
npm install
|
||||
- name: pxt ci
|
||||
run: |
|
||||
pxt ci
|
||||
env:
|
||||
PXT_ACCESS_TOKEN: ${{ secrets.PXT_ACCESS_TOKEN }}
|
||||
PXT_RELEASE_REPO: ${{ secrets.PXT_RELEASE_REPO }}
|
||||
NPM_ACCESS_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
|
||||
CHROME_BIN: chromium-browser
|
||||
DISPLAY: :99.0
|
||||
CI: true
|
9
.travis.yml
Normal file
9
.travis.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "8.9.0"
|
||||
script:
|
||||
- "node node_modules/pxt-core/built/pxt.js travis"
|
||||
sudo: false
|
||||
cache:
|
||||
directories:
|
||||
- node_modules
|
@@ -27,6 +27,7 @@ while (true) {
|
||||
music.playSoundEffectUntilDone(sounds.mechanicalMotorStart)
|
||||
music.playSoundEffectUntilDone(sounds.mechanicalMotorIdle);
|
||||
}
|
||||
pause(1);
|
||||
}
|
||||
```
|
||||
|
||||
@@ -42,5 +43,6 @@ while (true) {
|
||||
music.playSoundEffectUntilDone(sounds.mechanicalMotorStart)
|
||||
music.playSoundEffectUntilDone(sounds.mechanicalMotorIdle);
|
||||
}
|
||||
pause(1);
|
||||
}
|
||||
```
|
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"appref": "v1.2.31"
|
||||
"appref": "v1.2.27"
|
||||
}
|
||||
|
@@ -2,16 +2,16 @@
|
||||
|
||||
## Example #example
|
||||
|
||||
Use a wait and the timer to generate a number.
|
||||
Use the a wait and the timer to generate a crazy number.
|
||||
|
||||
```blocks
|
||||
let something = 0
|
||||
let crazy = 0
|
||||
for (let i = 0; i < 100; i++) {
|
||||
control.waitMicros(100)
|
||||
something = control.millis()
|
||||
something += control.deviceSerialNumber()
|
||||
if (something != 0) {
|
||||
something = something / 1000000
|
||||
crazy = control.millis()
|
||||
crazy += control.deviceSerialNumber()
|
||||
if (crazy != 0) {
|
||||
crazy = crazy / 1000000
|
||||
}
|
||||
}
|
||||
```
|
@@ -116,7 +116,7 @@ export class Ev3Wrapper {
|
||||
if (this.dataDump)
|
||||
log("TALK: " + U.toHex(buf))
|
||||
return this.io.sendPacketAsync(buf)
|
||||
.then(() => this.msgs.shiftAsync(5000))
|
||||
.then(() => this.msgs.shiftAsync(1000))
|
||||
.then(resp => {
|
||||
if (resp[2] != buf[2] || resp[3] != buf[3])
|
||||
U.userError("msg count de-sync")
|
||||
|
10
libs/base/shims.d.ts
vendored
10
libs/base/shims.d.ts
vendored
@@ -87,6 +87,12 @@ declare interface Buffer {
|
||||
*/
|
||||
//% shim=BufferMethods::write
|
||||
write(dstOffset: int32, src: Buffer): void;
|
||||
|
||||
/**
|
||||
* Compute k-bit FNV-1 non-cryptographic hash of the buffer.
|
||||
*/
|
||||
//% shim=BufferMethods::hash
|
||||
hash(bits: int32): uint32;
|
||||
}
|
||||
declare namespace control {
|
||||
|
||||
@@ -94,14 +100,14 @@ declare namespace control {
|
||||
* Create a new zero-initialized buffer.
|
||||
* @param size number of bytes in the buffer
|
||||
*/
|
||||
//% shim=control::createBuffer
|
||||
//% deprecated=1 shim=control::createBuffer
|
||||
function createBuffer(size: int32): Buffer;
|
||||
|
||||
/**
|
||||
* Create a new buffer with UTF8-encoded string
|
||||
* @param str the string to put in the buffer
|
||||
*/
|
||||
//% shim=control::createBufferFromUTF8
|
||||
//% deprecated=1 shim=control::createBufferFromUTF8
|
||||
function createBufferFromUTF8(str: string): Buffer;
|
||||
}
|
||||
declare namespace loops {
|
||||
|
@@ -1,11 +0,0 @@
|
||||
namespace control {
|
||||
let lastPause = 0;
|
||||
const COOPERATION_INTERVAL = 20
|
||||
export function cooperate() {
|
||||
const now = control.millis()
|
||||
if (now - lastPause > COOPERATION_INTERVAL) {
|
||||
lastPause = now
|
||||
pause(1)
|
||||
}
|
||||
}
|
||||
}
|
@@ -21,7 +21,8 @@ namespace sensors.internal {
|
||||
const now = control.millis();
|
||||
if (now - this.lastQuery >= this.interval * 2)
|
||||
this.queryAndUpdate(); // sensor poller is not allowed to run
|
||||
control.cooperate(); // allow events to trigger
|
||||
if (now - this.lastPause >= this.interval * 5)
|
||||
pause(1); // allow events to trigger
|
||||
}
|
||||
|
||||
private queryAndUpdate() {
|
||||
|
@@ -124,7 +124,7 @@ namespace motors {
|
||||
export function stopAll() {
|
||||
const b = mkCmd(Output.ALL, DAL.opOutputStop, 0)
|
||||
writePWM(b);
|
||||
control.cooperate();
|
||||
pause(1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,7 +136,7 @@ namespace motors {
|
||||
//% help=motors/reset-all
|
||||
export function resetAll() {
|
||||
reset(Output.ALL)
|
||||
control.cooperate();
|
||||
pause(1);
|
||||
}
|
||||
|
||||
interface MoveSchedule {
|
||||
@@ -269,7 +269,7 @@ namespace motors {
|
||||
if (this._brake && this._brakeSettleTime > 0)
|
||||
pause(this._brakeSettleTime);
|
||||
else {
|
||||
control.cooperate();
|
||||
pause(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ namespace motors {
|
||||
// allow robot to settle
|
||||
this.settle();
|
||||
} else {
|
||||
control.cooperate();
|
||||
pause(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,7 +357,7 @@ namespace motors {
|
||||
// special: 0 is infinity
|
||||
if (schedule.steps[0] + schedule.steps[1] + schedule.steps[2] == 0) {
|
||||
this._run(schedule.speed);
|
||||
control.cooperate();
|
||||
pause(1);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -597,7 +597,7 @@ namespace motors {
|
||||
//% help=motors/motor/angle
|
||||
angle(): number {
|
||||
this.init();
|
||||
return getMotorData(this._port).count * this.invertedFactor();
|
||||
return getMotorData(this._port).count;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -28,8 +28,7 @@
|
||||
"platform.h",
|
||||
"platform.cpp",
|
||||
"dmesg.cpp",
|
||||
"integrator.ts",
|
||||
"cooperate.ts"
|
||||
"integrator.ts"
|
||||
],
|
||||
"testFiles": [
|
||||
"test.ts"
|
||||
|
@@ -12,5 +12,4 @@ music.setTempo(120)
|
||||
music.noteFrequency(Note.C)
|
||||
music.beat()
|
||||
music.setVolume(50)
|
||||
music.volume()
|
||||
```
|
||||
```
|
@@ -13,22 +13,7 @@
|
||||
|
||||
namespace music {
|
||||
|
||||
int _readSystemVolume() {
|
||||
char ParBuf[8];
|
||||
int volume;
|
||||
|
||||
int fd = open("../sys/settings/Volume.rtf", O_RDONLY);
|
||||
read(fd, ParBuf, sizeof(ParBuf));
|
||||
close(fd);
|
||||
if (sscanf(ParBuf,"%d",&volume) > 0) {
|
||||
if ((volume >= 0) && (volume <= 100)) {
|
||||
return volume;
|
||||
}
|
||||
}
|
||||
return 50;
|
||||
}
|
||||
|
||||
uint8_t currVolume = _readSystemVolume();
|
||||
uint8_t currVolume = 50;
|
||||
uint8_t *lmsSoundMMap;
|
||||
|
||||
int writeDev(void *data, int size) {
|
||||
@@ -52,18 +37,6 @@ void setVolume(int volume) {
|
||||
currVolume = max(0, min(100, volume));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the output volume of the sound synthesizer.
|
||||
*/
|
||||
//% weight=96
|
||||
//% blockId=synth_get_volume block="volume"
|
||||
//% parts="speaker" blockGap=8
|
||||
//% help=music/volume
|
||||
//% weight=1
|
||||
int volume() {
|
||||
return currVolume;
|
||||
}
|
||||
|
||||
#define SOUND_CMD_BREAK 0
|
||||
#define SOUND_CMD_TONE 1
|
||||
#define SOUND_CMD_PLAY 2
|
||||
@@ -72,7 +45,7 @@ int volume() {
|
||||
|
||||
struct ToneCmd {
|
||||
uint8_t cmd;
|
||||
uint8_t lvl;
|
||||
uint8_t vol;
|
||||
uint16_t freq;
|
||||
uint16_t duration;
|
||||
};
|
||||
@@ -82,26 +55,10 @@ static void _stopSound() {
|
||||
writeDev(&cmd, sizeof(cmd));
|
||||
}
|
||||
|
||||
static uint8_t _getVolumeLevel(uint8_t volume, uint8_t levels) {
|
||||
uint8_t level;
|
||||
uint8_t step = (uint8_t) (100 / (levels - 1));
|
||||
if (volume < step) {
|
||||
level = 0;
|
||||
} else if (volume > step * (levels - 1)) {
|
||||
level = levels;
|
||||
} else {
|
||||
level = (uint8_t) (volume / step);
|
||||
}
|
||||
return level;
|
||||
}
|
||||
|
||||
static void _playTone(uint16_t frequency, uint16_t duration, uint8_t volume) {
|
||||
// https://github.com/mindboards/ev3sources/blob/78ebaf5b6f8fe31cc17aa5dce0f8e4916a4fc072/lms2012/c_sound/source/c_sound.c#L471
|
||||
uint8_t level = _getVolumeLevel(volume, 13);
|
||||
|
||||
ToneCmd cmd;
|
||||
cmd.cmd = SOUND_CMD_TONE;
|
||||
cmd.lvl = level;
|
||||
cmd.vol = volume;
|
||||
cmd.freq = frequency;
|
||||
cmd.duration = duration;
|
||||
// (*SoundInstance.pSound).Busy = TRUE;
|
||||
@@ -165,8 +122,7 @@ void playSample(Buffer buf) {
|
||||
stopUser();
|
||||
pthread_mutex_lock(&pumpMutex);
|
||||
*lmsSoundMMap = 1; // BUSY
|
||||
// https://github.com/mindboards/ev3sources/blob/78ebaf5b6f8fe31cc17aa5dce0f8e4916a4fc072/lms2012/c_sound/source/c_sound.c#L605
|
||||
uint8_t cmd[] = {SOUND_CMD_PLAY, _getVolumeLevel(currVolume, 8)};
|
||||
uint8_t cmd[] = {SOUND_CMD_PLAY, (uint8_t)((currVolume / 33) + 1)};
|
||||
writeDev(cmd, 2);
|
||||
decrRC(currentSample);
|
||||
currentSample = buf;
|
||||
@@ -245,4 +201,4 @@ Buffer buffer(Sound snd) {
|
||||
void play(Sound snd) {
|
||||
music::playSample(snd);
|
||||
}
|
||||
}
|
||||
}
|
10
libs/music/shims.d.ts
vendored
10
libs/music/shims.d.ts
vendored
@@ -13,16 +13,6 @@ declare namespace music {
|
||||
//% weight=1 shim=music::setVolume
|
||||
function setVolume(volume: int32): void;
|
||||
|
||||
/**
|
||||
* Return the output volume of the sound synthesizer.
|
||||
*/
|
||||
//% weight=96
|
||||
//% blockId=synth_get_volume block="volume"
|
||||
//% parts="speaker" blockGap=8
|
||||
//% help=music/volume
|
||||
//% weight=1 shim=music::volume
|
||||
function volume(): int32;
|
||||
|
||||
/**
|
||||
* Play a tone through the speaker for some amount of time.
|
||||
* @param frequency pitch of the tone to play in Hertz (Hz), eg: Note.C
|
||||
|
@@ -5,4 +5,3 @@ music.playTone(1440, 500)
|
||||
pause(500)
|
||||
music.playTone(2440, 500)
|
||||
pause(500)
|
||||
music.volume()
|
||||
|
18
package.json
18
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pxt-ev3",
|
||||
"version": "1.4.24",
|
||||
"version": "1.4.21",
|
||||
"description": "LEGO MINDSTORMS EV3 for Microsoft MakeCode",
|
||||
"private": false,
|
||||
"keywords": [
|
||||
@@ -32,21 +32,21 @@
|
||||
"docs/*/*/*.md"
|
||||
],
|
||||
"devDependencies": {
|
||||
"typescript": "2.6.1",
|
||||
"react": "16.8.3",
|
||||
"semantic-ui-less": "2.2.14",
|
||||
"@types/bluebird": "2.0.33",
|
||||
"@types/marked": "0.3.0",
|
||||
"@types/node": "8.0.53",
|
||||
"webfonts-generator": "^0.4.0",
|
||||
"@types/jquery": "3.2.16",
|
||||
"@types/react": "16.0.25",
|
||||
"@types/react-dom": "16.0.3",
|
||||
"@types/web-bluetooth": "0.0.4"
|
||||
"@types/web-bluetooth": "0.0.4",
|
||||
"@types/bluebird": "^2.0.33",
|
||||
"@types/marked": "^0.3.0",
|
||||
"@types/node": "^9.3.0",
|
||||
"semantic-ui-less": "2.2.14",
|
||||
"typescript": "^3.7.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"pxt-common-packages": "6.18.2",
|
||||
"pxt-core": "5.32.3"
|
||||
"pxt-common-packages": "8.1.3",
|
||||
"pxt-core": "6.2.8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node node_modules/pxt-core/built/pxt.js travis"
|
||||
|
@@ -114,8 +114,7 @@
|
||||
"de",
|
||||
"ja",
|
||||
"ru",
|
||||
"zh-CN",
|
||||
"fr"
|
||||
"zh-CN"
|
||||
],
|
||||
"highContrast": true,
|
||||
"lightToc": true,
|
||||
|
@@ -37,7 +37,7 @@ namespace pxsim {
|
||||
return Math.round(this.angle);
|
||||
}
|
||||
|
||||
// returns the secondary motor if any
|
||||
// returns the slave motor if any
|
||||
getSynchedMotor() {
|
||||
return this._synchedMotor;
|
||||
}
|
||||
|
@@ -7,14 +7,6 @@ namespace pxsim.music {
|
||||
export function stopAllSounds() {
|
||||
SoundMethods.stop()
|
||||
}
|
||||
|
||||
pxsim.music.setVolume = (volume: number): void => {
|
||||
pxsim.getAudioState().volume = volume;
|
||||
};
|
||||
|
||||
export function volume() {
|
||||
return pxsim.getAudioState().volume;
|
||||
}
|
||||
}
|
||||
|
||||
namespace pxsim.SoundMethods {
|
||||
|
Reference in New Issue
Block a user