Skip to content

Terminal

When it comes to displays, people tend to focus on graphics and GUIs, but in real applications, there are many situations where you want to display various text information. If you only have "display text at a specified coordinate on the screen," you can only output a limited amount of information. Terminal functionality, where you just send strings and the drawing position is updated automatically, and the screen scrolls when it overflows, is very convenient.

pico-jxglib's Terminal provides the following natural and expected features:

  1. Draw characters and strings while updating the drawing position
  2. Automatically wrap to the next line when reaching the right edge
  3. Scroll when reaching the bottom of the screen
  4. Record output in a round line buffer and allow rollback
  5. Read back the contents of the round line buffer

Especially, the last feature—reading back the round line buffer—can be combined with storage and communication features (to be implemented in pico-jxglib) to make an effective data logger.

Before we get to actual projects using Terminal, let's explain OLED devices, which are popular display devices for single-board microcontrollers alongside TFT LCDs.

classDiagram

  class Terminal {
    +AttachKeyboard(Keyboard& keyboard)
  }
  class Display_Terminal["Display::Terminal"] {
    +AttachDisplay(Drawable& display, const Rect& rect, Dir dir)
  }
  class Serial_Terminal["Serial::Terminal"] {
    +AttachPrintable(Printable& printable)
  }
  Terminal <|-- Display_Terminal
  Terminal <|-- Serial_Terminal
  Terminal o-- Keyboard
  Display_Terminal o-- Drawable
  Serial_Terminal o-- Printable
  Printable <|-- Stream

  %% mkdocs-start:[display]
  class Drawable
  class Display_Base["Display::Base"]
  class Display_ST7789["Display::ST7789"]:::Class_Output
  class Display_ST7735["Display::ST7735"]:::Class_Output
  class Display_ILI9341["Display::ILI9341"]:::Class_Output
  class Display_ILI9488["Display::ILI9488"]:::Class_Output
  class Display_SSD1306["Display::SSD1306"]:::Class_Output
  Drawable <|-- Display_Base
  Display_Base <|-- Display_ST7789
  Display_Base <|-- Display_ST7735
  Display_Base <|-- Display_ILI9341
  Display_Base <|-- Display_ILI9488
  Display_Base <|-- Display_SSD1306
  %% mkdocs-end:[display]

  %% mkdocs-start:[keyboard]
  class GPIO_Keyboard["GPIO::Keyboard"]:::Class_Input
  class GPIO_KeyboardMatrix["GPIO::KeyboardMatrix"]:::Class_Input
  class Stdio:::Class_Both
  class USBDevice_CDCSerial["USBDevice::CDCSerial"]:::Class_Both
  class Telnet_Stream["Telnet::Stream"]:::Class_Both
  class Keyboard
  class USBHost_Keyboard["USBHost::Keyboard"]:::Class_Input
  class VT100_Keyboard["VT100::Keyboard"]
  Keyboard <|-- USBHost_Keyboard
  Keyboard <|-- GPIO_Keyboard
  Keyboard <|-- GPIO_KeyboardMatrix
  Keyboard <|-- VT100_Keyboard
  VT100_Keyboard o-- Readable
  Readable <|-- Stream
  Stream <|-- Stdio
  Stream <|-- USBDevice_CDCSerial
  Stream <|-- Telnet_Stream
  %% mkdocs-end:[keyboard]




  classDef Class_Input fill:#ffc
  classDef Class_Output fill:#f8c
  classDef Class_Both fill:#fc9