Skip to content

Commit

Permalink
v1.0.13
Browse files Browse the repository at this point in the history
bug fixes
  • Loading branch information
IsakiMatsubara committed Sep 13, 2022
1 parent 9b4404a commit 83a96a0
Showing 1 changed file with 37 additions and 36 deletions.
73 changes: 37 additions & 36 deletions plenbit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,9 @@ namespace plenbit {
//フルカラーLEDを点灯
function setEyeLED() {
let data = pins.createBuffer(6)
for (let i = 0; i < 3; i++){
data[i] = (eyeColor[i] * eyeBrightnes / 255) & 0xFF
data[i+3] = data[i]
for (let i = 0; i < 3; i++) {
data[i] = (eyeColor[i] * eyeBrightnes / 255) & 0xFF
data[i + 3] = data[i]
}
ws2812b.sendBuffer(data, DigitalPin.P16)
}
Expand Down Expand Up @@ -886,40 +886,41 @@ namespace plenbit {
setAngle(angle, msec);
}

// センサー

/**
* Receive a IR signal from a remote controller by IR sensor.
*/
//% blockId=PLEN:bit_Sensor_IR
//% block="read %num side IR sensor"
//% weight=9 group="Sensor" advanced=true
export function checkIRSignal(num: DataPin) {
let data = []
let startTime = input.runningTimeMicros()
let signalLength = 0
while (plenbit.sensorLR(num) >= 100) {
signalLength = input.runningTimeMicros() - startTime
if (signalLength > 20000) return []
}
while (true) {
startTime = input.runningTimeMicros()
signalLength = 0
while (plenbit.sensorLR(num) < 100) {}
while (plenbit.sensorLR(num) >= 100) {
signalLength = input.runningTimeMicros() - startTime
if (signalLength > 20000) break
}
if (signalLength > 20000) {
break
} else if (signalLength > 1500) {
data.push(1)
} else {
data.push(0)
}
}
return data
// センサー

/**
* Receive a IR signal from a remote controller by IR sensor.
*/
//% blockId=PLEN:bit_Sensor_IR
//% block="read %num side IR sensor"
//% weight=9 group="Sensor" advanced=true
export function checkIRSignal(num: DataPin) {
let data = []
let startTime = input.runningTimeMicros()
let signalLength = 0
while (plenbit.sensorLR(num) >= 100) {
signalLength = input.runningTimeMicros() - startTime
if (signalLength > 20000) return []
}
while (true) {
startTime = input.runningTimeMicros()
signalLength = 0
while (plenbit.sensorLR(num) < 100) { }
while (plenbit.sensorLR(num) >= 100) {
signalLength = input.runningTimeMicros() - startTime
if (signalLength > 20000) break
}
if (signalLength > 20000) {
break
} else if (signalLength > 1500) {
data.push(1)
} else {
data.push(0)
}
}
if (data[0] == 1 && data.length > 1) data.shift()
return data
}


//v2専用
Expand Down

0 comments on commit 83a96a0

Please sign in to comment.