You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
The text was updated successfully, but these errors were encountered:
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:
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
where
n
is the line number, andstring
is the user-string to display.eg. the following code would print three strings across three lines.
Under the hood,
print()
will just wraptext()
, where the line number is translated into the appropriate co-ordinate(0, n*height)
wheren
is the line number andheight
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 toprint()
This is a cute stretch-goal, but probably beyond requirements.
The text was updated successfully, but these errors were encountered: