Skip to main content

IndexedScreen

caution

This service is rc and may change in the future.

A screen with indexed colors from a palette.

This is often run over an SPI connection or directly on the MCU, not regular single-wire Jacdac.

import { IndexedScreen } from "@devicescript/core"

const indexedScreen = new IndexedScreen()

Commands

startUpdate

Sets the update window for subsequent set_pixels commands.

indexedScreen.startUpdate(x: number, y: number, width: number, height: number): Promise<void>

setPixels

Set pixels in current window, according to current palette. Each "line" of data is aligned to a byte.

indexedScreen.setPixels(pixels: Buffer): Promise<void>

Registers

intensity

Set backlight brightness. If set to 0 the display may go to sleep.

  • type: Register<number> (packing format u0.8)

  • read and write

import { IndexedScreen } from "@devicescript/core"

const indexedScreen = new IndexedScreen()
// ...
const value = await indexedScreen.intensity.read()
await indexedScreen.intensity.write(value)
  • track incoming values
import { IndexedScreen } from "@devicescript/core"

const indexedScreen = new IndexedScreen()
// ...
indexedScreen.intensity.subscribe(async (value) => {
...
})
note

write and read will block until a server is bound to the client.

palette

The current palette. The colors are [r,g,b, padding] 32bit color entries. The color entry repeats 1 << bits_per_pixel times. This register may be write-only.

  • type: Register<Buffer> (packing format b)

  • track incoming values

import { IndexedScreen } from "@devicescript/core"

const indexedScreen = new IndexedScreen()
// ...
indexedScreen.palette.subscribe(async (value) => {
...
})
note

write and read will block until a server is bound to the client.

bitsPerPixel

Determines the number of palette entries. Typical values are 1 or 4.

  • type: Register<number> (packing format u8)

  • constant: the register value will not change (until the next reset)

  • read only

import { IndexedScreen } from "@devicescript/core"

const indexedScreen = new IndexedScreen()
// ...
const value = await indexedScreen.bitsPerPixel.read()
note

write and read will block until a server is bound to the client.

width

Screen width in "natural" orientation.

  • type: Register<number> (packing format u16)

  • constant: the register value will not change (until the next reset)

  • read only

import { IndexedScreen } from "@devicescript/core"

const indexedScreen = new IndexedScreen()
// ...
const value = await indexedScreen.width.read()
note

write and read will block until a server is bound to the client.

height

Screen height in "natural" orientation.

  • type: Register<number> (packing format u16)

  • constant: the register value will not change (until the next reset)

  • read only

import { IndexedScreen } from "@devicescript/core"

const indexedScreen = new IndexedScreen()
// ...
const value = await indexedScreen.height.read()
note

write and read will block until a server is bound to the client.

widthMajor

If true, consecutive pixels in the "width" direction are sent next to each other (this is typical for graphics cards). If false, consecutive pixels in the "height" direction are sent next to each other. For embedded screen controllers, this is typically true iff width < height (in other words, it's only true for portrait orientation screens). Some controllers may allow the user to change this (though the refresh order may not be optimal then). This is independent of the rotation register.

  • type: Register<boolean> (packing format u8)

  • optional: this register may not be implemented

  • read and write

import { IndexedScreen } from "@devicescript/core"

const indexedScreen = new IndexedScreen()
// ...
const value = await indexedScreen.widthMajor.read()
await indexedScreen.widthMajor.write(value)
  • track incoming values
import { IndexedScreen } from "@devicescript/core"

const indexedScreen = new IndexedScreen()
// ...
indexedScreen.widthMajor.subscribe(async (value) => {
...
})
note

write and read will block until a server is bound to the client.

upSampling

Every pixel sent over wire is represented by up_sampling x up_sampling square of physical pixels. Some displays may allow changing this (which will also result in changes to width and height). Typical values are 1 and 2.

  • type: Register<number> (packing format u8)

  • optional: this register may not be implemented

  • read and write

import { IndexedScreen } from "@devicescript/core"

const indexedScreen = new IndexedScreen()
// ...
const value = await indexedScreen.upSampling.read()
await indexedScreen.upSampling.write(value)
  • track incoming values
import { IndexedScreen } from "@devicescript/core"

const indexedScreen = new IndexedScreen()
// ...
indexedScreen.upSampling.subscribe(async (value) => {
...
})
note

write and read will block until a server is bound to the client.

rotation

Possible values are 0, 90, 180 and 270 only. Write to this register do not affect width and height registers, and may be ignored by some screens.

  • type: Register<number> (packing format u16)

  • optional: this register may not be implemented

  • read and write

import { IndexedScreen } from "@devicescript/core"

const indexedScreen = new IndexedScreen()
// ...
const value = await indexedScreen.rotation.read()
await indexedScreen.rotation.write(value)
  • track incoming values
import { IndexedScreen } from "@devicescript/core"

const indexedScreen = new IndexedScreen()
// ...
indexedScreen.rotation.subscribe(async (value) => {
...
})
note

write and read will block until a server is bound to the client.