When writing articles using LEGO Mindstorms EV3 (hereafter EV3), images may be inserted. You may want to use the EV3 screen display to explain the situation, such as when connecting the EV3 via Bluetooth. This time, I will describe how to take a screenshot of the LCD screen of such EV3.
Educational version LEGO® MINDSTORMS EV3
PC Windows10 Python 3.7.3 Development environment Visual Studio Code
EV3 ev3dev API Reference
Refer to the following for environment construction, source creation with VS Code, and transfer / execution method to EV3. EV3 x Pyrhon Machine Learning Part 1 Environment Construction Note that VS Code is required to take screenshots.
First, connect the EV3 and PC via Bluetooth. Click here for the connection method (https://qiita.com/Hiroki-Fujimoto/items/6ce278411ca151fee750#pc%E3%81%A8ev3%E3%81%AEbluetooth%E6%8E%A5%E7%B6%9A) reference.
Then access EV3 from VS Code's ev3dev extension.
When access is complete, a green circle will be displayed.
Left-click on the 3 EVs you are accessing to display the menu, so select Take Screenshot
.
Then, the shooting result window will be displayed on VS Code. The path to the folder containing the PNG images is displayed at the top of the window.
The actual PNG file is output as follows. Unlike the black and white screen of LCD, the selected part is displayed in blue.
When you want to take a picture of the LCD screen before wireless connection, such as when explaining the procedure when connecting via Bluetooth By connecting EV3 and PC with a USB cable, you can access from VS Code in the same way.
First, connect the EV3 and PC using a USB cable. No special settings are required when connecting via Bluetooth.
After that, access EV3 from ev3dev of VS Code.
The notation that was Bluetooth network connection
at the time of Bluetooth is changed to Ethernet 7
at the time of USB connection.
You can take a screenshot of the LCD screen when connected via USB by left-clicking on the 3 EVs who are accessing in the same way and selecting Take Screenshot
from the menu.
The actual PNG file is output as follows.
If the above two steps are performed when the program is executed, the characters displayed on the LCD can also be photographed.
This time, create the following program on VS Code and shoot the LCD screen when it is executed on EV3. Click here for how to create and transfer programs (https://qiita.com/Hiroki-Fujimoto/items/6ce278411ca151fee750#%E3%83%97%E3%83%AD%E3%82%B0%E3%83] See% A9% E3% 83% A0% E3% 81% AE% E4% BD% 9C% E6% 88% 90).
from ev3dev2.display import Display
import ev3dev2.fonts as fonts
import time
screen = Display()
screen.clear()
font = fonts.load('luBS12')
def main():
screen.draw.text((10, 10), 'Test1 Display String!', font=font)
screen.draw.text((10, 30), 'Test2!', font=font)
screen.update()
time.sleep(5.0)
screen.clear()
if __name__ == "__main__":
main()
After creating the program, click the mark below on VS Code to transfer the Workspace to EV3.
After the transfer, open an SSH terminal and run cd ev3 workspace /
(cd workspace name /)
Execute python3 display.py
.
When the program is executed, a character string will be displayed on the LCD screen for 5 seconds, so select Take Screenshot
during that time.
The program takes a screenshot of the character string displayed on the LCD screen.
The actual PNG file is output as follows. The background when the program is executed is displayed in yellow.
Recommended Posts