LLEMU (Legacy LCD Emulator)

Note

For a full list of functions for interacting with the LLEMU, see its C API and C++ API.

Initialization

Initialization of the LLEMU is very simple, it’s just a call to its initialization function at whatever point in the program you would like the LLEMU to start displaying (this will most likely be in initialize()).

Initialization is done as such:

initialize.cpp
1
2
3
void initialize() {
  pros::lcd::initialize();
}
initialize.c
1
2
3
void initialize() {
  lcd_initialize();
}

Writing to the LLEMU

Writing to the LLEMU is nearly identical to writing to the LCD with PROS 2. Most writing should be done with the print function, which is analogous to printf.

initialize.cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
void initialize() {
  pros::lcd::initialize();
}

void opcontrol() {
  while (true) {
    pros::lcd::print(0, "Buttons Bitmap: %d\n", pros::lcd::read_buttons());
    delay(20);
  }
}
initialize.c
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
void initialize() {
  lcd_initialize();
}

void opcontrol() {
  while (true) {
    lcd_print(0, "Buttons Bitmap: %d\n", lcd_read_buttons());
    delay(20);
  }
}

Using the Buttons

Using the buttons can be done in a similar method to PROS 2 with the pros::lcd::read_buttons function. See the above example for printing the button readings.

While this is sufficient for most applications, some tasks are easier to perform using the pros::lcd::register_btn#_cb functions (where # is replaced with 0, 1, or 2 for the left, center, and right buttons respectively). With these function you can assign a function to be called each time that the button is pressed.

initialize.cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
void on_center_button() {
  static bool pressed = false;
  pressed = !pressed;
  if (pressed) {
    pros::lcd::set_text(2, "I was pressed!");
  } else {
    pros::lcd::clear_line(2);
  }
}

void initialize() {
  pros::lcd::initialize();
  pros::lcd::register_btn0_cb(on_center_button);
}
initialize.c
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
void on_center_button() {
  static bool pressed = false;
  pressed = !pressed;
  if (pressed) {
    lcd_set_text(2, "I was pressed!");
  } else {
    lcd_clear_line(2);
  }
}

void initialize() {
  lcd_initialize();
  lcd_register_btn0_cb(on_center_button);
}

Note

Custom LVGL code cannot be displayed at the same time as LLEMU.