Using the Lego EV3 LCD involves more than opening and doing simple file operations, as it was the case with other EV3 hardware. The user level program handling the display has to implement several functions being able to draw or write to the LCD. The solution that I found was to use the same functions the LEGO had implemented for this purpose (d_lcd.c file). However, I had to make some slight modifications in order to eliminate some dependences with other files that I believe were unnecessary, resulting in a “library” that can be used independent of the Lego Virtual Machine. Compiling this LCD library involves having several bitmap image files that contain fonts and icons. I only found these extra files in the first release of the Lego EV3 source code. For convenience I copied all the necessary files needed to use the LCD in the RobotNav GitHub repository. Linux users can invoke the make command to compile the test program. For windows users, I recommend reading our tutorial on creating and compiling projects with Bricxcc.

Below is the LCD test program:

* Robot Navigation Program
* (C) Copyright 2013 Lauro Ojeda
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <>.
#include "lms2012.h"
#include "d_lcd.h"

int main()
//Create a structure that will store the LCD information
LCD my_lcd;
//Initialize and clear screen
//Draw and write something
dLcdRect(my_lcd.Lcd, FG_COLOR, 60, 60, 20, 20);
dLcdDrawCircle(my_lcd.Lcd, FG_COLOR, 40, 100, 20);
dLcdFillRect(my_lcd.Lcd, FG_COLOR, 100, 80, 40, 40);
dLcdDrawText(my_lcd.Lcd, FG_COLOR, 1, 10, LARGE_FONT, (signed char *)"Hello World");
dLcdDrawText(my_lcd.Lcd, FG_COLOR, 1, 35, NORMAL_FONT, (signed char *)"BACK BUTTON to exit");
//Update screen with information
//ToDo: I need to figure how to restore the screen once the program ends
return 1;

4 Responses to LCD
  1. Lasse says:

    Thanks for the code, it’s very much appreciated! One small problem: As soon as I use the dLcdInit(my_lcd.Lcd);, my sensors stop working… To read the sensors, I’m using the code I found on your site: sensorvalue = pUart->Raw[PORT][pUart->Actual[PORT]][0];

    • admin says:

      I found a problem with the LCD library (d_lcd.c), it was updating only once. The issue should be fixed now. I tested the LCD while continuously reading an IIC sensor, and it worked fine.

  2. Lasse says:

    Thank you so much for your effort! However, it still seems like there’s some kind of problem. I used your latest d_lcd.c, and rund the below code. On a+b I have the large motors, on 1 I have the IR sensor, on 2 I have the touch.

    But as soon as I use to the dLcdInit(my_lcd.Lcd); statement, the sensors doesnt get read. Am I doing something wrong, maybee I’m using the statements wrongly?

    In any way, thanks again for your efforts!!