Skip to content

Commit

Permalink
support setnumber block
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Sep 9, 2022
1 parent b492b10 commit 3b4c32a
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions braille-display/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,29 +50,38 @@ namespace modules {
}

/**
* Sets the patterns displayed as Braille ASCII or Unicode Braille characters.
* Sets the text as Braille ASCII or Unicode Braille characters.
* Enables the display if needed.
* @param text Braille ASCII or Unicode Braille characters to display
*/
//% blockId=jacdac_brailledisplay_set_patterns_text block="set %brailledisplay text to %text"
//% group="Display"
//% weight=100
setText(text: string) {
const length = this.length()
let brailled = brailify(text)
if (length > 0) brailled = brailled.slice(0, length)
const brailled = brailify(text)
this.setPatterns(brailled)
if (text) this.setEnabled(true)
}

/**
* Displays the number.
* Enables the display if needed.
*/
//% blockId=jacdac_brailledisplay_set_patterns_number block="set %brailledisplay number to %text"
//% group="Display"
//% weight=99
setNumber(value: number) {
this.setText(isNaN(value) ? "?" : value.toString())
}

/**
* Determines if the braille display is active.
*/
//% callInDebugger
//% group="Display"
//% block="%brailledisplay enabled"
//% blockId=jacdac_brailledisplay_enabled___get
//% weight=99
//% weight=90
enabled(): boolean {
this.start()
const values = this._enabled.pauseUntilValues() as any[]
Expand All @@ -85,7 +94,7 @@ namespace modules {
//% group="Display"
//% blockId=jacdac_brailledisplay_enabled___set
//% block="set %brailledisplay %value=toggleOnOff"
//% weight=98
//% weight=89
setEnabled(value: boolean) {
this.start()
const values = this._enabled.values as any[]
Expand Down

0 comments on commit 3b4c32a

Please sign in to comment.