Chapter 7 Physical Computing with the Sense HAT 161
THE OFFICIAL RASPBERRY PI BEGINNER’S GUIDE
5 Figure 7-7: Scrolling a message across the LED matrix
The show_message() function has more tricks up its sleeve than that, though. Go back to
your program and edit the last line so it says:
sense.show_message("Hello, World!", text_colour=( 255 , 255 , 0 ),
back_colour=( 0 , 0 , 255 ), scroll_speed=(0.05))
These extra instructions, separated by commas, are known as parameters, and they control
various aspects of the show_message() function. The simplest is scroll_speed=(),
which changes how quickly the message scrolls across the screen. A value of 0.05 in here
scrolls at roughly twice the usual speed. The bigger the number, the lower the speed.
The text_colour=() and back_colour=() parameters – spelled in the British English
way, unlike most Python instructions – set the colour of the writing and the background
respectively. They don’t accept names of colours, though; you have to state the colour you
want as a trio of numbers. The first number represents the amount of red in the colour, from 0
for no red at all to 255 for as much red as possible; the second number is the amount of green
in the colour; and the third number the amount of blue. Together, these are known as RGB – for
red, green, and blue.
Click on the Run icon and watch the Sense HAT: this time, the message will scroll
considerably more quickly, and be in a bright yellow on a blue background (Figure 7-8,
overleaf). Try changing the parameters to find a speed and colour combination that works
for you.