Display commands control the LCD screen of your Sphero BOLT+. Whereas BOLT has an 8x8 LED matrix, BOLT+ has a 128x128 LCD screen. With BOLT, animation and image data for the matrix is stored in the application and sent to the robot when a program is run. This means every time a program starts, the user has to wait while matrix data is transferred over Bluetooth. This is fast enough for matrix assets since there are 8x8 (or 64) "pixels" of data to send per frame. But with the BOLT+ display, that would be 128x128 (or 16,384) "pixels" of data to send per frame. Sending these display assets over Bluetooth would take more time, so all image and animation assets are stored in memory on the BOLT+ robot itself for quick access. As a result, there is no asset "transfer" step when running a program that uses BOLT+ display commands.
Displays an image on the Sphero BOLT+ LCD screen. Set a specific asset on the display by using an asset string, DisplayImage value, or integer firmware ID.
Use the following to display a smiling emoji on the screen with the asset string:
JavaScript: await setDisplayImage("slightly-smiling")
Python: await set_display_image("slightly-smiling")
Use the following to display a smiling emoji on the screen with the DisplayImage value:
JavaScript: await setDisplayImage(DisplayImage.SlightlySmiling)
Python: await set_display_image(DisplayImage.slightly_smiling)
Use the following to display the same smiling emoji image on the screen with the firmware ID:
JavaScript: await setDisplayImage(287)
Python: await set_display_image(287)
Parameters:
imageID {DisplayImage} - The image to display, specified as a DisplayImage value, an asset string, or an integer firmware ID
The library of all supported image assets can be found below:
Displays an animation on the Sphero BOLT+ LCD screen. Set a specific asset on the display by using an asset string, DisplayAnimation value, or integer firmware ID. If the looping parameter is set to true then the animation will loop and the program will proceed to the next line of code. This allows you to loop an animation while sending additional commands to your robot . If false is set, the program will wait to run the animation once before your code proceeds.
Use the following to display a looping fireworks animation on the screen with the asset string:
JavaScript: await setDisplayAnimation("fireworks", true)
Python: await set_display_animation("fireworks", True)
Use the following to display a looping fireworks animation on the screen with the asset ID:
JavaScript: await setDisplayAnimation(DisplayAnimation.Fireworks, true)
Python: await set_display_animation(DisplayAnimation.fireworks, True)
Use the following to display the same looping fireworks animation on the screen with the firmware ID:
JavaScript: await setDisplayAnimation(1029, true)
Python: await set_display_animation(1029, True)
Parameters:
animationID {DisplayAnimation} - The animation to display, specified as a DisplayAnimation value, an asset string, or an integer firmware ID
looping {boolean} - Whether the animation should loop (true) or play once before proceeding (false)
The library of all supported animation assets can be found below:
Displays user selected text on the Sphero BOLT+ LCD screen. Users can set:
Font size
Text string
Text color
Background color
Use the examples below to display "Hello World" in white across on a black background, using two lines and the normal font size:
JavaScript: setDisplayText('Hello\\nWorld!', { r: 255, g: 255, b: 255 }, { r: 0, g: 0, b: 0 }, 0)
Python: set_display_text('Hello\\nWorld!', {'r': 255, 'g': 255, 'b': 255}, {'r': 0, 'g': 0, 'b': 0}, 0)
Parameters:
text {string} - The text string to display (use ` for escaping and \\n for line breaks)
textColor {{ r: number; g: number; b: number }} - An object containing the RGB color values for the text (0 to 255 per color channel)
backgroundColor {{ r: number; g: number; b: number }} - An object containing the RGB color values for the background (0 to 255 per color channel)
font {number} - The font size (0 = normal, 1 = large)
To better understand how a display text command works, let's break the above example down.
Text:
'Hello\\nWorld!' is the text string. This the text you want to display on the the screen itself. All text must start and end with either a `, ', or " character to ensure it escapes properly. Unlike other commands with strings, the Display Text block will generate code with ` instead of ' or " since ' or " are valid characters to use in the text string itself. If ' and " are not used in the string itself, then they can also effectively be used to escape the string.
\\n is used to set a line break. In this example, \\n ensures that Hello will appear on the first row of the display, and World! will appear on the second row of the display. If this is not properly set, text will run "off" the right side of the screen. Since the BOLT+ firmware does not automatically wrap characters, these line breaks are needed to ensure all characters are visibly on the display.
Text Color and Background Color:
RGB values are used to set the text color and the background color. In the example above, the text will be white on a black background. If both the text color and background color are the same, the displayed text will not be legible. The first RGB value is the text color and the second RGB value is the background color.
Font:
You can use either 0 or 1 for the font parameter to set the font size. There are two font sizes that you can set, and each will impact the number of characters per line and the number of total lines per display that can be seen.
The normal font size allows for 6 lines and 10 characters per line. The large font size allows for 5 lines and 7 characters per line. Make sure you factor in your chosen font size when you manually set line breaks in your text string.
Supported Characters:
Both the normal and large fonts are stored in BOLT+ memory. As a result, there are limitations on which characters are supported. Both fonts support Extended ASCII characters as defined in the ISO/IEC 8859-1 standard. Below is a table of the ISO/IEC 8859-1 standard characters that are supported:
BOLT+ also supports many Cyrillic characters, as defined in the ISO/IEC 8859-5 standard. Below is a table of the ISO/IEC 8859-5 standard characters that are supported:
Any entered characters that are not part of the character sets above will display as a Sphero error character on the BOLT+ screen.
Clears the Sphero BOLT+ LCD screen of any images, animations, and text, resulting in it being "off".
JavaScript: clearDisplay()
Python: clear_display()
This function will also clear any matrix images, animations, or text strings that are used with BOLT+. The BOLT+ firmware simulates the behavior of the BOLT LED matrix by displaying an 8x8 grid of colored circles on the display. In this sense, all matrix commands are a subset of display commands, which means matrix images and animations can be cleared with the "clear display" function as well as the "clear matrix" function.
Rotates the display direction of the Sphero BOLT+ LCD screen for all subsequent images, animations, and text. 0° is the default, forward facing direction. 90° is right, 270° is left, and 180° is upside down.
Use the example below to rotate the display to the right (90º):
JavaScript: setDisplayRotation(90)
Python: set_display_rotation(90)
Parameters:
Rotation {number} - The rotation angle in degrees (0° = default, 90° = right, 180° = upside down, 270° = left)
This function will also rotate any matrix images, animations, or text strings that are used with BOLT+. The BOLT+ firmware simulates the behavior of the BOLT LED matrix by displaying an 8x8 grid of colored circles on the display. In this sense, all matrix commands are a subset of display commands, which means matrix images and animations can be controlled by the "display rotation" function as well as the "matrix rotation" function.
Displays live sensor data on the Sphero BOLT+ LCD screen. Displaying data directly to the screen means it isn't first streamed over Bluetooth to the Sphero Edu application before it's ready for review. Since streaming is bypassed, there is lower latency and and the sample rate for the data is higher. The specific sensor type to display is set with a SensorDataType value or with the respective bitmask*.
Use the example below to display the live velocity data with the SensorDataType value:
JavaScript: setLiveSensorData(SensorDataType.Velocity)
Python: set_live_sensor_data(SensorDataType.VELOCITY)
Use the example below to display the live velocity data with the bitmask value:
JavaScript: setLiveSensorData(16)
Python: set_live_sensor_data(16)
Parameters:
sensor {SensorDataType} - The sensor data type to display
*A bitmask is a simple, efficient way to tell a robot which of a few options to choose from. A robot only understands binary numbers, or bits ( a portmanteau of binary digit). Binary is a way of doing math where you only have two digits instead of ten by using multiples of two. So 1 in binary is 00000001, 2 in binary is 00000010, and 64 is 01000000. A bit mask is a way of using binary to send a series of yes-no options. In this case, we are stating which sensor we want to show. The table below provides the available sensor options and their respective bitmask numbers, which can be used as the parameter values for the live sensor data function. The binary is also provided for reference, though it is not used for the function parameter in the editor.
Sets the Sphero BOLT+ LCD screen to a color.
Use the following examples to set the display to a green color:
JavaScript: setDisplayColor({ r: 0, g: 255, b: 0 })
Python: set_display_color({ 'r': 0, 'g': 255, 'b': 0 })
Use the following examples to randomize the color of the display:
JavaScript: setDisplayColor(getRandomColor())
Python: set_display_color(get_random_color())
Parameters:
color {{ r: number; g: number; b: number }} - An object containing the RGB color values (0 to 255 per color channel)
The display color function does not have a respective block in the block canvas. As a result, it is only useable in the text canvas.