# My extension for the Pimoroni scrollbit

**URL:** <https://forum.makecode.com/t/my-extension-for-the-pimoroni-scrollbit/1822>\
**Category:** micro:bit\
**Created:** [April 24, 2020, 12:37pm UTC](https://forum.makecode.com/t/my-extension-for-the-pimoroni-scrollbit/1822 "2020-04-24T12:37:55Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mkilpatr](https://avatars.discourse-cdn.com/v4/letter/m/ccd318/32.png) [@mkilpatr](https://forum.makecode.com/u/mkilpatr)\
**Post date:** [April 24, 2020, 12:37pm UTC](https://forum.makecode.com/t/my-extension-for-the-pimoroni-scrollbit/1822/1 "2020-04-24T12:37:56Z")

</div>

My graphics extension for the Pomoroni Scroll:bit 17x7 LED matrix is now on github. The README.md file is 75% complete but more functions (for the window mode) will be added later.

> **[MTKilpatrick/pxt-myscrollbit](https://github.com/MTKilpatrick/pxt-myscrollbit)**
>
> Variant of Pimoroni scrollbit. Contribute to MTKilpatrick/pxt-myscrollbit development by creating an account on GitHub.

All the pixel, line, scroll and text-scroll functions work but the extension is still a work in progress.

I’ve got a question about out-of-range plotting error detection: my pixel routines don’t yet do full out-of-range error detection because I noticed that putting a value int a negative buffer index like this  
x = -1  
pixel\_buffer[x] = 1

doesn’t appear to do any damage! However if x is 17 and the buffer is only 16 long, that does cause an error and the Microbit will crash. Am I OK to leave out negative error detection? What happens when addressing a negative buffer index?

---

<div class="post-metadata">

**Author:** ![peli](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/peli/32/12_2.png) [@peli](https://forum.makecode.com/u/peli)\
**Post date:** [April 24, 2020, 2:35pm UTC](https://forum.makecode.com/t/my-extension-for-the-pimoroni-scrollbit/1822/2 "2020-04-24T14:35:00Z")

</div>

You were lucky, you will want to do bounds check and ignore any input that is out of bound.

I noticed that you are using the built-in font in C++. We’ll have to see if we can give you a hook so that you can retrive that in TypeScript. In general, C++ should be avoided as it adds cloud compilation and does not work offline.

---

<div class="post-metadata">

**Author:** ![peli](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/peli/32/12_2.png) [@peli](https://forum.makecode.com/u/peli)\
**Post date:** [April 24, 2020, 2:37pm UTC](https://forum.makecode.com/t/my-extension-for-the-pimoroni-scrollbit/1822/3 "2020-04-24T14:37:01Z")

</div>

See this docs about enabling blocks rendering in your repo

> **[Blocks embedding](https://makecode.com/blocks-embed)**
>
> MakeCode provides a lightweight blocks rendering engine that renders code snippets as SVG images.

---

<div class="post-metadata">

**Author:** ![mkilpatr](https://avatars.discourse-cdn.com/v4/letter/m/ccd318/32.png) [@mkilpatr](https://forum.makecode.com/u/mkilpatr)\
**Post date:** [April 24, 2020, 3:42pm UTC](https://forum.makecode.com/t/my-extension-for-the-pimoroni-scrollbit/1822/4 "2020-04-24T15:42:53Z")

</div>

**Font** : the font.cpp file is inherited from the original Pimoroni scrollbit extension. I didn’t bother to look to see if there was a Typescript function to access it, and I assumed this was in C++ for a good reason. Let me know what is the best thing to do!

**Bounds** : Interesting, as I just did a few experiments on out of bounds buffers indexes. Is there a definitive answer as to what actually happens? I tried defining a buffer length 7 and wrote to the non-existent [7] element and this did not crash the Microbit. However, creating a buffer length 8 and writing to the [8] element did crash it. Something to do with multiples of 2 or 4 bytes being the actual memory usage?

Luckily my y-coord is a bitwise operation which has no effect when given an on out-of-range Y, so I don’t need to check _both_ x and y for bounds, only the x.

**SVG** : Do you prefer that I put SVG examples in the README.md document? I can do that at some point. If there’s a chance this extension can be approved - it will certainly make the Pimoroni Scroll:bit a dmaned sight more useable - then I’ll happy put in some extra effort.

I’m just adding a rectangle draw routine and I have additional things to do with the extended window mode but I’m mulling over whether to make that a separate “advanced scrollbit” extension instead of one monstrous one.

---

<div class="post-metadata">

**Author:** ![peli](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/peli/32/12_2.png) [@peli](https://forum.makecode.com/u/peli)\
**Post date:** [April 24, 2020, 4:00pm UTC](https://forum.makecode.com/t/my-extension-for-the-pimoroni-scrollbit/1822/5 "2020-04-24T16:00:00Z")

</div>

Bounds: we check them… [https://github.com/microsoft/pxt-common-packages/blob/master/libs/base/buffer.cpp#L15](https://github.com/microsoft/pxt-common-packages/blob/master/libs/base/buffer.cpp#L15)

---

<div class="post-metadata">

**Author:** ![mkilpatr](https://avatars.discourse-cdn.com/v4/letter/m/ccd318/32.png) [@mkilpatr](https://forum.makecode.com/u/mkilpatr)\
**Post date:** [April 24, 2020, 4:09pm UTC](https://forum.makecode.com/t/my-extension-for-the-pimoroni-scrollbit/1822/6 "2020-04-24T16:09:56Z")

</div>

I am currently using direct access via buffer[index] rather than buffer.setByte. I should so some runtime speed tests to see whether to use the in-built routines where bound-checking will be necessary.

---

<div class="post-metadata">

**Author:** ![peli](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/peli/32/12_2.png) [@peli](https://forum.makecode.com/u/peli)\
**Post date:** [April 24, 2020, 4:38pm UTC](https://forum.makecode.com/t/my-extension-for-the-pimoroni-scrollbit/1822/7 "2020-04-24T16:38:44Z")

</div>

You don’t need to put svg in the readme. if you use the “blocks” fenced code regions and our little javascript renderer, we’ll generate those on the fly.

---

<div class="post-metadata">

**Author:** ![peli](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/peli/32/12_2.png) [@peli](https://forum.makecode.com/u/peli)\
**Post date:** [April 24, 2020, 8:28pm UTC](https://forum.makecode.com/t/my-extension-for-the-pimoroni-scrollbit/1822/8 "2020-04-24T20:28:50Z")

</div>

Adding support for smaller buttons [https://github.com/microsoft/pxt/pull/6910](https://github.com/microsoft/pxt/pull/6910)
