Difference between revisions of "1. Panel scrolling text"
(→Character color) |
(→sample code) |
||
Line 57: | Line 57: | ||
::The default color of the board is red, as long as the string (that is, "Hello, World! ) to modify the color of the characters displayed. As you can see from the figure above, the color of our characters has changed to yellow. | ::The default color of the board is red, as long as the string (that is, "Hello, World! ) to modify the color of the characters displayed. As you can see from the figure above, the color of our characters has changed to yellow. | ||
− | + | ||
+ | *Some of you may have questions here, right? So how do you make each character appear a different color? Let's look at the following operation | ||
+ | |||
+ | from display import* | ||
+ | display=Display() | ||
+ | color=[Red,Orange,Yellow,Green,Blue,Indigo,Purple] | ||
+ | display.scroll("ROYGBIP",color) | ||
+ | |||
+ | [[File:Color.gif]] |
Revision as of 00:17, 18 February 2019
Contents
Panel scrolling text
This is a qualitative change from the original hello word!
Prepare the required tools
- BPI:bit newest firmware. Bin
- Windows - Mpfshell. Exe
you can download from :https://github.com/BPI-STEAM/BPI-BIT-MicroPython/releases
easy to use MicroPython
from microbit import * display.scroll("Hello, World!")
- Each line also has special semantics.
- The form microbit import *
- If you have been exposed to c before, you can understand by the library. All modules are existing code libraries. These libraries are imported from microbit. The second row
- display.scroll("Hello, World!")
- This also makes sense, telling microPython to use the display command to scroll the "helloworld" character number of the string. This display is a module in the microbit that represents the physical display of the device, with the display in quotes.
- Now copy the code directly to your editor and burn it to your device. Can you change the character information? Give it a try!
- The form microbit import *
- testing effect:
Character color
Compared with microbit, bpibit's led panel USES programmable RGB light (ws2812b). Click here for more details on WS2812B
RGB lights can be programmed to display 255 *255 *255 colors, which is 16 million colors. It's hard to believe, so let's start our color show.
- It's easy to change the color of the font. We preset 8 colors in our firmware
black = [0, 0, 0] Red = [2, 0, 0] Orange = [2, 1, 0] Yellow = [2, 2, 0] Green = [0, 2, 0] Blue = [0, 0, 2] Indigo = [0, 2, 2] Purple = [2, 0, 2]
They are black (light out), red, orange, yellow, green, blue, indigo and purple. With these basic colors you can modify the font color.
sample code
from display import* display=Display() display.scroll("Hello, World!",Yellow)
- The default color of the board is red, as long as the string (that is, "Hello, World! ) to modify the color of the characters displayed. As you can see from the figure above, the color of our characters has changed to yellow.
- Some of you may have questions here, right? So how do you make each character appear a different color? Let's look at the following operation
from display import* display=Display() color=[Red,Orange,Yellow,Green,Blue,Indigo,Purple] display.scroll("ROYGBIP",color)