精品导航

Controlling the display

Scrolling colors

Now we're going to use the loop() part of the code.
See that mp.update() function? It's probably the most important function of all and it's located under the I/O section.
Its mission is to read everything that has happened between the last time it was called and now and to transfer those changes to the hardware.
For example, fillScreen() function would not change anything if the mp.update() isn't called.
Besides the screen, it also refreshes buttons, the speaker, LEDs and pretty much every other component on the phone.

random image



One mp.update() is there by default but for this program, we've added two more.
We've also used another new block called wait().
It translates to the delay() function which stops everything for a certain amount of milliseconds.
The number value block can be found in the Math section and its value can be changed to suit our needs.
Since the loop() function is really fast, sometimes we need this delay to actually see what is going on on the screen.
Using delay when expecting a fast and responsive program, however, is not the way to go, especially when we're using buttons. More about that in the next lesson.

What we're actually doing in this program is alternating the screen color between three values.
Firstly we change it to white, then wait 500 milliseconds or 0.5 seconds.
Then, we change it to cyan and wait another 500 milliseconds.
Lastly, we change it to yellow, wait 500 milliseconds and return back to the beginning of the loop, where the screen is again changed to white.
Notice that we're calling the mp.update() function after each color change in order to transfer that color to the screen.
Update function
Be careful when using mp.update() since it is not the fastest function.Calling it too many times in one loop will slow down the program significantly - USE IT WELL!

Writing out some text

Now that we know how to change the background color, it's time to start writing something on that canvas.
Ringo library offers three different fonts that can be re-sized and re-colored as we like.
Functions for that are rather simple and should not be a problem to understand for anyone.

random image



With this program, we're writing some words out on the screen in different fonts, sizes, and colors.
The font type is easily changed with the drop-down menu of the set font type block. The font size, however, multiplies the size of the selected font by the desired value. By default, both of those values are 1, so setting them at the beginning of the program to that same value actually made no difference.
Later both of those values have been changed. In the last example, we're printing out two words "And SIZE!" in a different font that is twice the size.
The print() function here is something that we're going to use quite often. The first empty slot is a string of characters that are meant to be written out.
You can find an empty one in the Text section.
The second and third slot are the location of the first letter. Setting both of those values to 0 will print out words in the upper left corner of the screen.
With these numbers, we're actually referencing pixel locations. Our screen is 128x160 pixels and we can manipulate each and every one of them.
Everything that we write/draw between the x values of 0 and 127 and y values of 0 and 159 will be visible on the screen.
If any of those values is out of that range, we will not see the component.

友情链接:永久地址 | 蘑菇影视 | zhuoyemall.com | mogu视频 | 伊人色 | 蘑菇视频ios | 蘑菇视频入口 | mogu | 宅男影院 | mogutv | 亚洲精品 | 天天综合 | 蘑菇网页版入口 | fltou.com | 蘑菇視頻 | tsxhyq.com | 欧美午夜 | btupic.com | mogus.cc | 协和影院 | 五月丁香 | 番号网 | 蘑菇传媒在线观看 | 酒色世界 | 四虎影视 | 资源导航 | 蘑菇在线观看网页版 | 六月婷婷 | 久久爱 | 青青伊人 | 第一福利 | zpzb2008.com | dk99999.com | 超碰视频 | 红桃视频 | gzdksw.com | bt搜索 | 小草社区 | 午夜在线观看 | 蓝色导航 | 福利精品 | 无名网 | rencai98.com | 最新av | 摩天轮社区 | 导航大全 | 蘑菇短视频入口 | 在线午夜 | 樱花视频 | lf397.com | 秋霞网 | p站视频 | 精品免费 | 亚洲网 | 在线亚洲 | 汤姆影院 | 青草青青 | 老司机视频 | 玖玖资源站 | 青草草 | 久久视频 | 色婷婷 | 色妞 | sanzhucare-zhpg.com | 福利盒子 | 综合影院 | 色啪 | 屁屁影院 | 秋霞影院 | tissu-premier.com | 性知音 | 迷妹网 | 龙物视频 | 永久网站 | 久久香蕉 | 老王影院 | 蜜芽视频 | 日本高清 | 蘑菇tv网页版 | 琳琅导航 | 青娱 | 扒哥黑料 | 天堂在线 | 琵琶妞 | hebeijiaoyuwang.com | dna0126.com | jxty00.com | 4008108885.com | 小蓝视频 | 蘑菇网 | 五福影院 | 草莓视 | 看片神器 | woqidz.com | 久久久久久 | 蘑菇app | 蘑菇传媒 | 蘑菇视频网站 | 玖玖爱