Skip to content

User-experience improvements #2

@CoreProduction

Description

@CoreProduction

Presently, printing text to the OLED module requires an understanding of the (x,y) co-ordinate system to anchor the text, and requires an argument for text-colour (1=white, 0=black) eg:

display.text("Hello, World!", 0,0, 1) # print literal string at (0,0) with white colour

To remove the assumed-knowledge and make code less intimidating we can abstract to the concept of line numbers, and print in white by default. The new function could be

display.print(n, string)

where n is the line number, and string is the user-string to display.

eg. the following code would print three strings across three lines.

display.print(0, "hello world")
display.print(1, "second line")
display.print(2, "third line")

Under the hood, print() will just wrap text(), where the line number is translated into the appropriate co-ordinate (0, n*height) where n is the line number and height is the height of a letter, plus line-spacing.

There's scope for print() to auto-increment the line number, so that text flows up the screen on each successive call to print()
This is a cute stretch-goal, but probably beyond requirements.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions