microsoft / pxt-chibitronics

Chibitronics Love To Code board editor with Microsoft MakeCode
https://makecode.chibitronics.com
Other
23 stars 15 forks source link

Sensing blocks and animations block don't work together #234

Open samelhusseini opened 6 years ago

samelhusseini commented 6 years ago

It appears using the sensing blocks to trigger animations on a different pin crashes the running code. Here's an example:

sensing.onPinEvent(DigitalPin.D0, PinEvent.Pressed, function () {
    rgb.setColor(rgb.wheel(Math.randomRange(0, 255)))
    for (let i = 0; i < 500; i++) {
        lights.effect(Effect.Twinkle, AnalogPin.A2)
    }
})

I suspect it's an issue with the thread that the sensing block starts, maybe that's interfering somehow. @xobs any insight here.

This issue was reported by @nataliefreed and Ryan Jenkins.


and here's an example where the sensing block works:

sensing.onPinEvent(DigitalPin.D0, PinEvent.Pressed, function () {
    rgb.setColor(rgb.wheel(Math.randomRange(0, 255)))
    lights.set(Math.randomRange(1, 6), Math.randomRange(0, 2))
})
xobs commented 6 years ago

The board enters an error condition, as evidenced by the blinking red LED. Investigating now...

It's actually crashed in the timer handler:

(gdb) bt
#0  0x00001cf4 in errorCondition () at esplanade_app.c:46
#1  0x00001736 in HardFault_Handler_C (context=<optimized out>, is_irq=<optimized out>) at orchard-vectors.c:40
#2  <signal handler called>
#3  0x00002400 in chVTDoSetI (vtp=<optimized out>, delay=<optimized out>, vtfunc=<optimized out>,
    par=<optimized out>) at ../os/rt/src/chvt.c:167
#4  0x0000251c in chSchGoSleepTimeoutS (newstate=newstate@entry=8 '\b', time=<optimized out>)
    at ../os/rt/src/chschd.c:338
#5  0x000026ec in chThdSleepS (time=<optimized out>) at ../os/rt/include/chthreads.h:268
#6  chThdSleep (time=<optimized out>) at ../os/rt/src/chthreads.c:314
#7  0x00005324 in delay (msecs=<optimized out>) at arduino-time.c:17
#8  0x00005d16 in loops::pause (ms=<optimized out>) at src\core/basic.cpp:52
#9  0x000067aa in ?? ()
(gdb)
xobs commented 6 years ago

Fixed in ca0f5742bd7d80c777191da4bfa6ca42d083c1b7 by increasing the stack size.

jieq commented 6 years ago

When I try using the sensing pin and twinkle effect (one of the most popular combos in workshops), still seems to crash causing program light to blink red.

Thanks for looking into this!

On Thu, Sep 6, 2018 at 1:45 AM, Sean Cross notifications@github.com wrote:

Fixed in ca0f574 https://github.com/Microsoft/pxt-chibitronics/commit/ca0f5742bd7d80c777191da4bfa6ca42d083c1b7 by increasing the stack size.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Microsoft/pxt-chibitronics/issues/234#issuecomment-418971825, or mute the thread https://github.com/notifications/unsubscribe-auth/ADq2aepbFxkCfnU4jYNjg0QZsTlwgP0Hks5uYLaVgaJpZM4U0gIB .

xobs commented 6 years ago

This fix is sitting in the fix-twinkle-effect branch and hasn't been merged yet, so it's not live. You'd need to check out and build that branch yourself.

xobs commented 6 years ago

It should be in beta now. @jieq can you try http://makecode.chibitronics.com/beta ?

jieq commented 6 years ago

Huzzah! Works great now :) Thanks!

--Jie

On Thu, Sep 13, 2018 at 9:15 PM, Sean Cross notifications@github.com wrote:

It should be in beta now. @jieq https://github.com/jieq can you try http://makecode.chibitronics.com/beta ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Microsoft/pxt-chibitronics/issues/234#issuecomment-421200019, or mute the thread https://github.com/notifications/unsubscribe-auth/ADq2aTj2WdnOIPBb4WeyoW4iUuT9Z9qVks5uawNDgaJpZM4U0gIB .