FabGL
ESP32 VGA Controller and Graphics Library
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
fabgl::PS2ControllerClass Class Reference

The PS2 device controller class. More...

#include <ps2controller.h>

Public Member Functions

void begin (gpio_num_t port0_clkGPIO, gpio_num_t port0_datGPIO, gpio_num_t port1_clkGPIO=GPIO_NUM_39, gpio_num_t port1_datGPIO=GPIO_NUM_39)
 Initializes PS2 device controller. More...
 
void begin (PS2Preset preset=PS2Preset::KeyboardPort0_MousePort1, KbdMode keyboardMode=KbdMode::CreateVirtualKeysQueue)
 Initializes PS2 device controller using default GPIOs. More...
 
int dataAvailable (int PS2Port)
 Gets the number of scancodes available in the controller buffer. More...
 
int getData (int PS2Port)
 Gets a scancode from the queue. More...
 
void injectInRXBuffer (int value, int PS2Port)
 Injects a byte into the RX buffer. More...
 
void resume ()
 Resumes PS/2 ports operations. More...
 
void sendData (uint8_t data, int PS2Port)
 Sends a command to the device. More...
 
void suspend ()
 Suspends PS/2 ports operations. More...
 

Detailed Description

The PS2 device controller class.

The PS2 controller uses ULP coprocessor and RTC slow memory to communicate with up to two PS2 devices.
The ULP coprocessor continuously monitor CLK and DATA lines for incoming data. Optionally can send commands to the PS2 devices.

Member Function Documentation

◆ begin() [1/2]

void fabgl::PS2ControllerClass::begin ( gpio_num_t  port0_clkGPIO,
gpio_num_t  port0_datGPIO,
gpio_num_t  port1_clkGPIO = GPIO_NUM_39,
gpio_num_t  port1_datGPIO = GPIO_NUM_39 
)

Initializes PS2 device controller.

Initializes the PS2 controller assigning GPIOs to DAT and CLK lines.

Parameters
port0_clkGPIOThe GPIO number of Clock line for PS/2 port 0.
port0_datGPIOThe GPIO number of Data line for PS/2 port 0.
port1_clkGPIOThe GPIO number of Clock line for PS/2 port 1 (GPIO_NUM_39 to disable).
port1_datGPIOThe GPIO number of Data line for PS/2 port 1 (GPIO_NUM_39 to disable).
Examples:
Altair8800/Altair8800.ino, AnsiTerminal/AnsiTerminal.ino, Audio/Audio.ino, GraphicalUserInterface/GraphicalUserInterface.ino, KeyboardStudio/KeyboardStudio.ino, LoopbackTerminal/LoopbackTerminal.ino, MouseOnScreen/MouseOnScreen.ino, MouseStudio/MouseStudio.ino, NetworkTerminal/NetworkTerminal.ino, SpaceInvaders/SpaceInvaders.ino, and VIC20/VIC20.ino.

◆ begin() [2/2]

void fabgl::PS2ControllerClass::begin ( PS2Preset  preset = PS2Preset::KeyboardPort0_MousePort1,
KbdMode  keyboardMode = KbdMode::CreateVirtualKeysQueue 
)

Initializes PS2 device controller using default GPIOs.

Initializes the PS2 controller assigning:

  • GPIO_NUM_33 (CLK) and GPIO_NUM_32 (DATA) as PS/2 Port 0
  • GPIO_NUM_26 (CLK) and GPIO_NUM_27 (DATA) as PS/2 Port 1
Parameters
presetSpecifies what is connected to PS/2 ports (mouse, keyboard or boths).
keyboardModeSpecifies how handle keyboard virtual keys.

Example:

// Keyboard connected to port 0 and mouse to port1
PSController.begin(PS2Preset::KeyboardPort0_MousePort1);

◆ dataAvailable()

int fabgl::PS2ControllerClass::dataAvailable ( int  PS2Port)

Gets the number of scancodes available in the controller buffer.

Parameters
PS2PortPS2 port number (0 = port 0, 1 = port1).
Returns
The number of scancodes available to read.

◆ getData()

int fabgl::PS2ControllerClass::getData ( int  PS2Port)

Gets a scancode from the queue.

Parameters
PS2PortPS2 port number (0 = port 0, 1 = port1).
Returns
The first scancode of the queue (-1 if no data is available).

◆ injectInRXBuffer()

void fabgl::PS2ControllerClass::injectInRXBuffer ( int  value,
int  PS2Port 
)

Injects a byte into the RX buffer.

Injects a byte as if it were actually sent by the device.

Parameters
valueByte to inject.
PS2PortPS2 port number (0 = port 0, 1 = port1).

◆ resume()

void fabgl::PS2ControllerClass::resume ( )

Resumes PS/2 ports operations.

◆ sendData()

void fabgl::PS2ControllerClass::sendData ( uint8_t  data,
int  PS2Port 
)

Sends a command to the device.

Parameters
dataByte to send to the PS2 device.
PS2PortPS2 port number (0 = port 0, 1 = port1).

◆ suspend()

void fabgl::PS2ControllerClass::suspend ( )

Suspends PS/2 ports operations.


The documentation for this class was generated from the following files: