Skip to content

Wds firmware -> radioShield #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 44 commits into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
0fcaa1a
update getting started
thomasjball Jan 15, 2025
fc5024c
update tutorial
thomasjball Jan 15, 2025
7e98016
0.1.22
thomasjball Jan 15, 2025
97d251a
renaming
thomasjball Jan 16, 2025
0c85bf7
Merge pull request #9 from microbit-apps/display-shield
thomasjball Jan 16, 2025
9c111e7
Update README.md
thomasjball Jan 16, 2025
3fa9645
1.0.0
thomasjball Jan 16, 2025
8d9fe35
1.0.1
thomasjball Jan 16, 2025
b85c3d2
update simx
thomasjball Jan 16, 2025
084288a
1.0.2
thomasjball Jan 16, 2025
37ba6f9
bump simx
thomasjball Jan 16, 2025
4f7a049
remove
thomasjball Jan 16, 2025
ee5d759
move back
thomasjball Jan 16, 2025
237c686
update URLs
thomasjball Jan 16, 2025
7520360
update pic
thomasjball Jan 16, 2025
e11dc7c
fix some language
thomasjball Jan 17, 2025
3fb727c
screen.cpp
KierPalin Jan 26, 2025
6072900
reverting prior commit
KierPalin Jan 27, 2025
9fc545c
update with delay
thomasjball Feb 4, 2025
bfbc4e1
1.0.3
thomasjball Feb 4, 2025
8208647
set high drive on backlight
thomasjball Feb 5, 2025
47478a1
1.0.4
thomasjball Feb 5, 2025
5b037b6
Update the image to replace the old newbit with the latest one
smfox10 Feb 8, 2025
a948a68
Merge pull request #14 from KittenBot/master
thomasjball Feb 8, 2025
a8e76b0
this is the way
thomasjball Feb 25, 2025
c968ff1
reduce
thomasjball Feb 25, 2025
b4bcf34
1.0.5
thomasjball Feb 25, 2025
3551528
fix: prevent smartConfigure from overwriting offset bytes.
fabianhugo Feb 27, 2025
54560cd
Merge pull request #16 from fabianhugo/master
thomasjball Feb 28, 2025
548601d
bring back display config
thomasjball Feb 28, 2025
cea7ebf
oops
thomasjball Feb 28, 2025
adb88bb
one more error!
thomasjball Feb 28, 2025
ec35b7c
test with calliope
thomasjball Mar 2, 2025
79be719
Merge pull request #17 from microbit-apps/tball/getConfig
thomasjball Mar 2, 2025
afa60ab
remove config update
thomasjball Mar 2, 2025
0bfde41
redo comment
thomasjball Mar 2, 2025
90832a2
fix overwrite logic
thomasjball Apr 4, 2025
d280d70
1.0.6
thomasjball Apr 4, 2025
f5cc47d
Working but with white flashes inbetween colours
KierPalin Apr 21, 2025
7966bef
Test changes
KierPalin Apr 22, 2025
9f9b03b
coinciding with working 'extra ,' commit in codal-microbit-v2
KierPalin Apr 22, 2025
eb00164
working state, cleanup comments
KierPalin Apr 22, 2025
1ef241a
working buttons
KierPalin Apr 29, 2025
a1f7016
Merge branch 'radioShield' into wds-firmware
KierPalin Apr 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 27 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# MakeCode extension: Arcade Shield for BBC micro:bit (V2)
# Display shield MakeCode extension for BBC micro:bit

This MakeCode extension allows you to use any of the MakeCode Arcade shields with the MakeCode for BBC micro:bit editor. The extension provides access
to the screen and buttons on the shield, and has
This MakeCode extension allows you to use any of the MakeCode Arcade shields with the MakeCode for BBC micro:bit editor.
The extension provides access to the color display and buttons on the shield, and has
a Bitmap abstraction with numerous drawing primitives
(draw line, circle, square, etc).
Bitmaps also can be created using the built-in
image editor in MakeCode.

> **NOTE: This extension will only work in https://makecode.microbit.org/beta**. The extension is still under development and is subject to changes. Please file issues at https://github.com/microbit-apps/arcadeshield/issues
> **NOTE: This extension will only work in https://makecode.microbit.org/beta**. The extension is still under development and is subject to changes. Please file issues at https://github.com/microbit-apps/display-shield/issues

## Arcade Shields for the micro:bit V2
## Arcade shields for the micro:bit V2

Various Arcade shields for the micro:bit V2 are available on the market today, including:
Various Arcade (display) shields for the micro:bit V2 are available on the market today, including:

* [Kittenbot's newbit Arcade shield](https://www.kittenbot.cc/products/newbit-arcade-shield): No assembly required Small screen and nice enclosure with LiPo battery inside. One [Jacdac](https://aka.ms/jacdac) port.
* [ELECFREAK's micro:bit Arcade shield](https://www.kittenbot.cc/products/newbit-arcade-shield): Assembly required. Small screen. AAA Battery pack on back. One [Jacdac](https://aka.ms/jacdac) port.
* [ICShopping's Game:bit Arcade shield](https://www.icshop.com.tw/products/368112100137?locale=en): No assembly required. Large screen and 3d-printed enclosure with LiPo battery inside. Two [Jacdac](https://aka.ms/jacdac) ports.
* [Kitronik's Arcade for BBC micro:bit](https://kitronik.co.uk/products/56116-kitronik-arcade-for-bbc-micro-bit-makecode-arcade): No assembly required. Small screen. Battery holder on back. No Jacdac port.

![MakeCode Arcade Shields](https://github.com/microbit-apps/arcadeshield/blob/master/assets/shields.png?raw=true)
![MakeCode Arcade shields](https://github.com/microbit-apps/display-shield/blob/master/assets/shields.png?raw=true)


## Simulator support
Expand All @@ -30,25 +30,24 @@ D-pad, see arrow buttons). Blocks
for the shield are under the toolbox categories `Controller` and
`Drawing` and are described further below.

![MakeCode with Arcade Shield Simulator](https://github.com/microbit-apps/arcadeshield/blob/master/assets/shieldSim.png?raw=true)
![MakeCode with Display Shield Simulator](https://github.com/microbit-apps/display-shield/blob/master/assets/shieldSim.png?raw=true)


> [Open in MakeCode](https://makecode.microbit.org/beta/#pub:S07267-08481-73083-11887)
> [Open in MakeCode](https://makecode.microbit.org/beta/#pub:S80683-78265-58968-34229)


## Using this extension

- Open https://makecode.microbit.org/beta
- Create a new project
- Add an extension via the "Extensions" item in the gear wheel (upper right)
- Type "arcade" into the search box
- Select the **arcadeshield** extension, as shown below
- Type "display shield" into the search box
- Select the **display-shield** extension, as shown below

![MakeCode extension dialog](https://github.com/microbit-apps/arcadeshield/blob/master/assets/extensions.png?raw=true)
![MakeCode extension dialog](https://github.com/microbit-apps/display-shield/blob/master/assets/extensions.png?raw=true)

## Mashup!!!

With this extension, you have access to **all** the MakeCode APIs for the micro:bit, and the new ability to plot data or create your own user interface. For example, one very cool thing about the micro:bit is it's (X,Y,Z) accelerometer, which senses motion in three dimensions. Below is a program that maps the three accelerometer values to a scrolling line graph:
With this extension, you have access to **all** the MakeCode APIs for the micro:bit, and the new ability to plot data or create your own user interface. For example, one very cool thing about the micro:bit is its (X,Y,Z) accelerometer, which senses motion in three dimensions. Below is a program that maps the three accelerometer values to a scrolling line graph:
```block
let x = 0, old_x = 0
let y = 0, old_y = 0
Expand Down Expand Up @@ -76,13 +75,13 @@ basic.forever(function () {

## Tutorials

- [Getting started](https://makecode.microbit.org/beta#tutorial:github:microbit-apps/arcadeshield/tutorials/getting-started)
- [Getting started](https://makecode.microbit.org/beta#tutorial:github:microbit-apps/display-shield/tutorials/getting-started)

## Overview of API

The examples below are illustrative. All blocks have their own
detailed help pages, available from the MakeCode editor.
[This page with block rendering](https://makecode.microbit.org/pkg/microbit-apps/arcadeshield). More APIs are available via TypeScript.
[This page with block rendering](https://makecode.microbit.org/pkg/microbit-apps/display-shield). More APIs are available via TypeScript.

### Controller

Expand All @@ -99,7 +98,7 @@ controller.left.onEvent(ControllerButtonEvent.Pressed, function () {
})
```

> [Open in MakeCode](https://makecode.microbit.org/beta/#pub:S24163-00898-21210-28197)
> [Open in MakeCode](https://makecode.microbit.org/beta/#pub:S64613-82831-68506-89974)

### Drawing into the screen bitmap

Expand All @@ -115,7 +114,7 @@ screen().fill(8)
screen().drawLine(0, 0, 159, 119, 2)
screen().drawLine(159, 0, 0, 119, 5)
```
> [Open in MakeCode](https://makecode.microbit.org/beta/#pub:S31225-91260-81293-38509)
> [Open in MakeCode](https://makecode.microbit.org/beta/#pub:S96327-83750-33845-21213)

The first two parameters to the function are the (x,y)
coordinate where the line should start, while the next
Expand Down Expand Up @@ -221,13 +220,12 @@ screen().drawCircle(10, 10, 8, 5)

### Bitmap

Let's dig into bitmaps, which you can create yourself (the screen is represented by a bitmap, as we have seen already). A bitmap is some number of rows and columns of color pixels that make up rectangular picture. A _pixel_ is a single point of color inside the bitmap.

Bitmaps are have a set height (number of rows) and width (number of columns). When a bitmap is declared, or created, the height and width are specified either by the _layout_ of the bitmap or as parameters to it's `create` method.
Let's dig into bitmaps, which you can create yourself (the screen is represented by a bitmap, as we have seen already). A bitmap is some number of rows and columns of color pixels that make up rectangular picture. A _pixel_ is a single point of color inside the bitmap. A bitmap has a fixed height (number of rows) and width (number of columns). When a bitmap is declared, or created, the height and width are specified either by the _layout_ of the bitmap or as parameters to its `create` method.

#### Bitmap editor

The easiest way to create a bitmap is with the bitmap editor, which is accessible both from blocks and text view. Here is the block view of an
The easiest way to create a bitmap is with the bitmap editor,
which is accessible both from blocks and text view. Here is the block view of an
16x16 bitmap of an apple:

```block
Expand Down Expand Up @@ -256,10 +254,10 @@ screen().drawTransparentBitmap(apple, 70, 50)

Here is the bitmap editor, which appears when you click on the icon in bitmap block

![MakeCode Arcade Shields](https://github.com/microbit-apps/arcadeshield/blob/master/assets/appleBitmapEditor.png?raw=true)
![MakeCode Arcade Shields](https://github.com/microbit-apps/display-shield/blob/master/assets/appleBitmapEditor.png?raw=true)


The bitmap also is represented as a text literal, as shown below
A bitmap is represented in code as a text literal, as shown below

```
screen().fill(6)
Expand All @@ -286,7 +284,7 @@ screen().drawTransparentBitmap(apple, 70, 50)

Click on the painter's palette icon next to the bitmap literal in the text view to bring up the bitmap editor

![MakeCode Arcade Shields](https://github.com/microbit-apps/arcadeshield/blob/master/assets/bitmapEditorFromText.png?raw=true)
![MakeCode Arcade Shields](https://github.com/microbit-apps/display-shield/blob/master/assets/bitmapEditorFromText.png?raw=true)


#### Bitmap layout
Expand Down Expand Up @@ -333,7 +331,7 @@ let sixByTwo = bmp`

##### Transparent pixels

A pixel value of `.` means an empty pixel. This pixel has no color and that pixel _location_ in the bitmap is _transparent_. Being transparent means that if this bitmap is on top of another bitmap (overlapping) that has some pixel color, then the color of the pixel in the bitmap underneath shows through to the bitmap above it.
A pixel value of `.` denotes a transparent pixel. This pixel has no color and that pixel _location_ in the bitmap is _transparent_. Being transparent means that if this bitmap is on top of another bitmap (overlapping) that has some pixel color, then the color of the pixel in the bitmap underneath shows through to the bitmap above it.

##### Pixel colors

Expand Down Expand Up @@ -365,7 +363,7 @@ let oneRed = bmp`2`

As a block it looks like this:

```
```block
let oneRed = bmp`2`
```

Expand Down Expand Up @@ -458,7 +456,7 @@ let yellowSquare = bmp`
screen().drawBitmap(yellowSquare, 0, 0)
screen().drawTransparentBitmap(greenBall, 0, 0)
```
> [Open in MakeCode](https://makecode.microbit.org/beta/#pub:S29479-80151-27505-97683)
> [Open in MakeCode](https://makecode.microbit.org/beta/#pub:S62195-40202-75476-02422)

#### Setting pixels at locations

Expand Down Expand Up @@ -493,7 +491,7 @@ screen().fill(8)
screen().drawTransparentBitmap(orangeBox, 0, 0)
screen().drawTransparentBitmap(orangeBox, 32, 32)
```
> [Open in MakeCode](https://makecode.microbit.org/beta/#pub:S29084-47427-55388-74348)
> [Open in MakeCode](https://makecode.microbit.org/beta/#pub:S62672-77446-94897-23460)


# Supported targets
Expand Down
Binary file modified assets/extensions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/newbit-shield.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/shields.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 15 additions & 15 deletions bitmap.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ interface Bitmap {
//% shim=BitmapMethods::fill blockNamespace="drawing" group="Drawing"
//% blockId=bitmapFill
//% block="fill $this with $c=colorindexpicker"
//% help=github:arcadeshield/docs/fill
//% help=github:display-shield/docs/fill
//% this.shadow="theScreen"
//% weight=100
//% c.defl=8
Expand All @@ -17,7 +17,7 @@ interface Bitmap {
//% shim=BitmapMethods::setPixel blockNamespace="drawing" group="Drawing"
//% block="set $this color at x $x y $y to $c=colorindexpicker"
//% blockId=bitmapSetPixel
//% help=github:arcadeshield/docs/set-pixel
//% help=github:display-shield/docs/set-pixel
//% this.shadow="theScreen"
//% weight=96
//% x.defl=80
Expand All @@ -31,7 +31,7 @@ interface Bitmap {
//% shim=BitmapMethods::getPixel blockNamespace="drawing" group="Drawing"
//% block="$this color at x $x y $y"
//% blockId=bitmapGetPixel
//% help=github:arcadeshield/docs/get-pixel
//% help=github:display-shield/docs/get-pixel
//% this.shadow="theScreen"
//% weight=92
//% x.defl=80
Expand All @@ -44,7 +44,7 @@ interface Bitmap {
//% helper=imageDrawLine blockNamespace="drawing" inlineInputMode="inline" group="Drawing"
//% block="draw line in $this from x $x0 y $y0 to x $x1 y $y1 $c=colorindexpicker"
//% blockId=bitmapDrawLine
//% help=github:arcadeshield/docs/draw-line
//% help=github:display-shield/docs/draw-line
//% this.shadow="theScreen"
//% weight=88
//% x0.defl=0
Expand All @@ -60,7 +60,7 @@ interface Bitmap {
//% helper=imageDrawRect blockNamespace="drawing" inlineInputMode="inline" group="Drawing"
//% block="draw rectangle in $this at x $x y $y width $w height $h $c=colorindexpicker"
//% blockId=bitmapDrawRect
//% help=github:arcadeshield/docs/draw-rect
//% help=github:display-shield/docs/draw-rect
//% this.shadow="theScreen"
//% weight=84
//% x.defl=0
Expand All @@ -76,7 +76,7 @@ interface Bitmap {
//% helper=imageFillRect blockNamespace="drawing" inlineInputMode="inline" group="Drawing"
//% block="fill rectangle in $this at x $x y $y width $w height $h $c=colorindexpicker"
//% blockId=bitmapFillRect
//% help=github:arcadeshield/docs/fill-rect
//% help=github:display-shield/docs/fill-rect
//% this.shadow="theScreen"
//% weight=80
//% x.defl=0
Expand Down Expand Up @@ -142,7 +142,7 @@ interface Bitmap {
//% group="Drawing"
//% block="draw $from in $this at x $x y $y"
//% blockId=bitmapDrawBitmap
//% help=github:arcadeshield/docs/draw-bitmap
//% help=github:display-shield/docs/draw-bitmap
//% this.shadow="theScreen"
//% this.defl=bitmap
//% from.shadow=variables_get
Expand All @@ -158,7 +158,7 @@ interface Bitmap {
//% blockId=bitmapDrawTransparentBitmap
//% group="Drawing"
//% block="draw $from transparent in $this at x $x y $y"
//% help=github:arcadeshield/docs/draw-transparent-bitmap
//% help=github:display-shield/docs/draw-transparent-bitmap
//% this.shadow="theScreen"
//% this.defl=bitmap
//% from.shadow=variables_get
Expand All @@ -172,7 +172,7 @@ interface Bitmap {
//% shim=BitmapMethods::flipX blockNamespace="drawing" group="Transformations"
//% block="flip $this horizontally"
//% blockId=bitmapFlipX
//% help=github:arcadeshield/docs/flip-x
//% help=github:display-shield/docs/flip-x
//% this.shadow="theScreen"
//% weight=72
flipX(): void;
Expand All @@ -183,7 +183,7 @@ interface Bitmap {
//% shim=BitmapMethods::flipY blockNamespace="drawing" group="Transformations"
//% block="flip $this vertically"
//% blockId=bitmapFlipY
//% help=github:arcadeshield/docs/flip-y
//% help=github:display-shield/docs/flip-y
//% this.shadow="theScreen"
//% weight=68
flipY(): void;
Expand All @@ -192,7 +192,7 @@ interface Bitmap {
* Every pixel in bitmap is moved by (dx,dy)
*/
//% shim=BitmapMethods::scroll blockNamespace="drawing" group="Transformations"
//% help=github:arcadeshield/docs/scroll
//% help=github:display-shield/docs/scroll
//% this.shadow="theScreen"
//% block="scroll $this by x $dx y $dy"
//% blockId=bitmapScroll
Expand All @@ -207,7 +207,7 @@ interface Bitmap {
//% block="change color in $this from $from=colorindexpicker to $to=colorindexpicker"
//% blockId=bitmapReplace
//% help=bitmaps/bitmap/replace
//% help=github:arcadeshield/docs/replace
//% help=github:display-shield/docs/replace
//% this.shadow="theScreen"
//% weight=60
replace(from: int32, to: int32): void;
Expand All @@ -224,7 +224,7 @@ interface Bitmap {
//% other.shadow=variables_get
//% this.defl="bitmap"
//% other.defl="bitmap2"
//% help=github:arcadeshield/docs/equals
//% help=github:display-shield/docs/equals
equals(other: Bitmap): boolean;

//% shim=BitmapMethods::isStatic
Expand All @@ -246,7 +246,7 @@ interface Bitmap {
//% weight=40
//% block="clone $this"
//% blockId=bitmapClone
//% help=github:arcadeshield/docs/clone
//% help=github:display-shield/docs/clone
//% this.shadow=variables_get
//% this.defl="bitmap"
clone(): Bitmap;
Expand All @@ -258,7 +258,7 @@ declare namespace bitmaps {
//% block="create bitmap width $width height $height" group="Create"
//% weight=80
//% blockSetVariable=bitmap
//% help=github:arcadeshield/docs/create
//% help=github:display-shield/docs/create
//% width.defl=16
//% height.defl=16
function create(width: number, height: number): Bitmap;
Expand Down
2 changes: 1 addition & 1 deletion bitmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
//% blockNamespace="drawing" group="Create"
//% blockId=theScreen block="screen"
//% help=github:arcadeshield/docs/screen-bitmap
//% help=github:display-shield/docs/screen-bitmap
function screen(): Bitmap {
return theScreen;
}
Expand Down
7 changes: 7 additions & 0 deletions config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
// button configuration for Arcade Shield here
namespace config {

// the following are the default values used in C++
// add to your code, uncomment and change to get different value
// export const DISPLAY_TYPE = 4242 // smart shield
// export const DISPLAY_CFG0 = 0x02000080 // allow execution without shield plugged in
// export const DISPLAY_CFG1 = 0x00000603
// export const DISPLAY_CFG2 = 8 // maximum SPI frequency for smart shield

// pybadge-like layout
export const PIN_BTN_LEFT = 1050
export const PIN_BTN_UP = 1051
Expand Down
6 changes: 3 additions & 3 deletions controllerbutton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace controller {
* Run some code when shield is absent/present
*/
//% weight=30
//% help=github:arcadeshield/docs/on-shield-event
//% help=github:display-shield/docs/on-shield-event
//% blockId=shieldEvent block="on shield $event"
export function onShieldEvent(event: ControllerShieldEvent, handler: () => void) {
context.onEvent(event, 0, handler);
Expand Down Expand Up @@ -146,7 +146,7 @@ namespace controller {
* Run some code when a button is pressed, released, or held
*/
//% weight=99 blockGap=8
//% help=github:arcadeshield/docs/on-button-event
//% help=github:display-shield/docs/on-button-event
//% blockId=keyonevent block="on $this **button** $event"
onEvent(event: ControllerButtonEvent, handler: () => void) {
const eventHandler = this.getOrCreateHandlerForEvent(event);
Expand Down Expand Up @@ -206,7 +206,7 @@ namespace controller {
* Indicates if the button is currently pressed
*/
//% weight=96 blockGap=8
//% help=github:arcadeshield/docs/is-pressed
//% help=github:display-shield/docs/is-pressed
//% blockId=keyispressed block="is $this **button** pressed"
isPressed() {
return this._pressed;
Expand Down
Loading
Loading