Arduino Open Source Library u8glib2 icon shows "original"

Source: Internet
Author: User

Arduino Open Source Library u8glib2 research icon display
-----------------on the use of DRAWXBM drawxbmp function


Because of whim, recently want to do a snake game, the hand has Arduino and our own development of Newbit OLED Shield, hardware completely satisfied, so in the online search, found a lot of people in use U8glib, now has a second version of U8GLIB2, The first version has stopped maintenance, but two version of the source code can be downloaded in github.com, the specific URL is

This library is very powerful, display text (multiple fonts optional), scratch the geometry, the drawing is no problem.



In the Arduino 1.6.12 environment, you can download the library directly (non-source), download the available, download the method is
1. Select Menu "Project" in Arduino
2. Click "Load Library", "Manage Library"
3. Enter U8G2 in the search box,
4. Install the latest version, such as 2.8.5
However, this library does not seem to be a perfect document, or to see the source code to know how to use the library. Fortunately, there is a reference document that is barely available.
Http://www.docin.com/p-1011581730.html
To make a snake game, show the cell of the snake, so first understand how to use U8GLIB2 to display the icon.

There are several functions in the library to display bitmaps (which is what we call icons), which are irregular, usually not geometric, such as the block representing the snake body, a chess and so on.
The following two are more useful. Two functions are similar, but the former input is the data in RAM, the latter input as ROM data, when used to choose their own
void Drawxbm (u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t W, u8g2_uint_t H, const uint8_t *bitmap)
void Drawxbmp (u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t W, u8g2_uint_t H, const uint8_t *bitmap)

For example, how does this function work?

Data is
Const uint8_t ele3x3[] Progmem = {
0X07,
0X06,
0X04,
};
This represents a lack of the lower left corner of the square, is actually a right triangle. Ele3x3[0] = 7 = 0b0000 0111, take 3 bits lower, and D2 corresponds to the rightmost side of the screen.
The 3 points it represents are
.  . .
likewise ele3x3[1] = 6, which means
X. .
ELE3X3[2] = 4, indicating
x x.
(x) indicates that no content is displayed on the screen

The entire array is displayed as
. . .
. .
.
When the left and right up and down spacing is the same, it is a right triangle.

Suppose we want to show in the rectangular area (30,30) (33,33).

After you know the object to be displayed, see how to call the function drawxbmp ()
Drawxbmp (30,30, 3, 3, ele3x3);


All right, let's see what it looks.






---------------------------------------------------
Code download

Https://pan.baidu.com/s/1c1Vru3Q


"Newbit Studio" Respecting the original, reproduced please specify from www.newbitstudio.com




Arduino Open Source Library u8glib2 icon shows "original"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.