Skip to content

Input and Output Devices

The shell can work with a variety of devices. Below is a class diagram showing the relationship between the shell, terminal, input devices (keyboards), and output devices (displays and printables).

classDiagram

  class Shell {
    +AttachTerminal(Terminal& terminal)
  }
  Shell o-- Terminal

  %% mkdocs-start:[terminal]
  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]

  %% mkdocs-end:[terminal]




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

Input Output Input/Output

A Shell can attach a Terminal by Shell::AttachTerminal().

A Terminal can attach a Keyboard as its input device. There are various types of Keyboard, such as USBHost::Keyboard, GPIO::Keyboard, and GPIO::KeyboardMatrix. Additionally, you can also use the Stdio, USBDevice::CDCSerial, or Telnet::Stream as a keyboard input for the shell.

There are two types of Terminal: Serial::Terminal and Display::Terminal. A Serial::Terminal can attach a Printable (e.g. a Stream) as its output device, while a Display::Terminal can attach a Display as its output device.

A Printable is a class that can be printed to. It has a variety of printing methods, such as Print(), Printf(), and Println(). It includes classes like Stream, which is a base class for Stdio, USBDevice::CDCSerial, and Telnet::Stream.

A Display is a class that can be drawn on. It has methods for drawing images and bitmaps to a display device, such as DrawImage() and DrawBitmap(). It includes classes like ST7789, ST7735, ILI9341, ILI9488, and SSD1306.

Conclusion: The shell works with a variety of input and output devices by creating Keyboard, Printable, and Display::Base objects and attaching them to a Terminal attached to the Shell.