Add microbit font
This commit is contained in:
parent
0d6e6a7c96
commit
574fdb3473
@ -23,6 +23,10 @@ namespace screen {
|
||||
}
|
||||
let currFont: Font
|
||||
|
||||
export function setFont(f: Font) {
|
||||
currFont = f
|
||||
}
|
||||
|
||||
export const heart = hex`f007 367f7f3e1c08`
|
||||
|
||||
export function defaultFont(): Font {
|
||||
@ -52,6 +56,28 @@ namespace screen {
|
||||
}
|
||||
}
|
||||
|
||||
export function microbitFont() {
|
||||
return {
|
||||
charWidth: 6,
|
||||
charHeight: 5,
|
||||
firstChar: 32,
|
||||
// source https://github.com/lancaster-university/microbit-dal/blob/master/source/core/MicroBitFont.cpp
|
||||
data: hex`
|
||||
0000000000 0202020002 0a0a000000 0a1f0a1f0a 0e130e190e 1309041219 0609060916 0202000000 0402020204
|
||||
0204040402 000a040a00 00040e0400 0000000402 00000e0000 0000000200 1008040201 0609090906 040604040e
|
||||
070806010f 0f08040906 0c0a091f08 1f010f100f 08040e110e 1f08040201 0e110e110e 0e110e0402 0002000200
|
||||
0004000402 0804020408 000e000e00 0204080402 0e110c0004 0e11151906 06090f0909 0709070907 0e0101010e
|
||||
0709090907 0f0107010f 0f01070101 0e0119110e 09090f0909 0702020207 1f08080906 0905030509 010101010f
|
||||
111b151111 1113151911 0609090906 0709070101 060909060c 0709070911 0e01060807 1f04040404 0909090906
|
||||
1111110a04 1111151b11 0909060909 110a040404 0f0402010f 0e0202020e 0102040810 0e0808080e 040a000000
|
||||
000000001f 0204000000 000e09091e 0101070907 000e01010e 08080e090e 060907010e 0c02070202 0e090e0806
|
||||
0101070909 0200020202 0800080806 0105030509 020202020c 001b151111 0007090909 0006090906 0007090701
|
||||
000e090e08 000e010101 000c020403 02020e021c 000909091e 0011110a04 001111151b 0009060609 00110a0403
|
||||
000f04020f 0c0406040c 0202020202 0302060203 0000061800
|
||||
`
|
||||
}
|
||||
}
|
||||
|
||||
export function setPixel(x: number, y: number, mode = Draw.Normal) {
|
||||
x |= 0
|
||||
y |= 0
|
||||
|
@ -13,6 +13,7 @@ input.buttonEnter.onEvent(ButtonEvent.Click, () => {
|
||||
input.buttonLeft.onEvent(ButtonEvent.Click, () => {
|
||||
screen.drawRect(10, 70, 20, 10, Draw.Fill)
|
||||
output.setLights(LightsPattern.Red)
|
||||
screen.setFont(screen.microbitFont())
|
||||
})
|
||||
|
||||
input.buttonRight.onEvent(ButtonEvent.Click, () => {
|
||||
|
Loading…
Reference in New Issue
Block a user