microsoft / pxt-maker

MakeCode target for "Maker" boards (beta)

Home Page:https://maker.makecode.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Plot of temperature using onboard neopixels does not work on CPB board

V2man opened this issue · comments

commented

Temperature does not display correctly on CPB. Works on CPX board. The code below works with Microsoft Makecode and Maker Makecode with CPX board. Try it on Maker Makecode with hardware set to CPB board to recreate problem. With CPB board all neopixels light up for about 3 seconds then go off after reset button is pushed once. May not be reading input.temperature at all. With CPX board Neopixels turn on in clockwise direction with increase temperature. Temperature Farenheit is constrained between 60 and 80 degrees. The code does not work in Maker Makecode with CPB! It does not use graph block.
`/**

  • CP-Temperature-CW
  • Example of using neopixels to measure temperature rise in
  • clockwise direction on CPX/CPB board.
    */
    let np = 0
    let n = 0
    let Tc = 0
    let T = 0
    light.onboardStrip().setBrightness(20)
    let Tmin = 60
    let Tmax = 80
    forever(function () {
    T = input.temperature(TemperatureUnit.Fahrenheit)
    Tc = Math.constrain(T, Tmin, Tmax)
    n = Math.map(Tc, Tmin, Tmax, 0, light.onboardStrip().length() - 1)
    if (T < Tmin) {
    light.onboardStrip().setAll(0x000000)
    } else {
    for (let index = 0; index <= light.onboardStrip().length() - 1; index++) {
    np = light.onboardStrip().length() - 1 - index
    if (index <= n) {
    light.onboardStrip().setPixelColor(np, light.hsv(18 * np, 255, 255))
    } else {
    light.onboardStrip().setPixelColor(np, 0x000000)
    }
    }
    }
    pause(1000)
    }) `

Here's another example that uses the graph block to plot temperature on the onboard neopixels.
It works on CPX but not on CPB. All the onboard neopixels on the CPB board are on.

CPX-T20t30-With-Graph.txt
CPX-T20t30-With-Graph