pxt-chibitronics icon indicating copy to clipboard operation
pxt-chibitronics copied to clipboard

Sensing blocks and animations block don't work together

Open samelhusseini opened this issue 7 years ago • 6 comments

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))
})

samelhusseini avatar Jun 22 '18 22:06 samelhusseini

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 avatar Sep 06 '18 05:09 xobs

Fixed in ca0f5742bd7d80c777191da4bfa6ca42d083c1b7 by increasing the stack size.

xobs avatar Sep 06 '18 05:09 xobs

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 [email protected] 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 .

jieq avatar Sep 10 '18 18:09 jieq

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 avatar Sep 11 '18 01:09 xobs

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

xobs avatar Sep 14 '18 01:09 xobs

Huzzah! Works great now :) Thanks!

--Jie

On Thu, Sep 13, 2018 at 9:15 PM, Sean Cross [email protected] 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 .

jieq avatar Sep 14 '18 20:09 jieq