欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標(biāo)題:
QRcode二維碼生成顯示
[打印本頁]
作者:
roc2
時(shí)間:
2018-7-31 16:39
標(biāo)題:
QRcode二維碼生成顯示
在我們生活中隨處可見二維碼,我們在零知板上使用軟件庫來生成并顯示二維碼。
硬件:零知-標(biāo)準(zhǔn)板、OLED(最好用像素更大的LCD)
連線:連線請參照OLED模塊使用教程進(jìn)行。
程序源碼如下:
/**
* QRCode 零知板-二維碼生成與顯示
* 2018年7月31日16:23:41
* by 零知實(shí)驗(yàn)室
*
*/
#include <qrcode.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
void setup() {
Serial.begin(9600);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
// Start time
uint32_t dt = millis();
// 根據(jù)字符串生成二維碼
QRCode qrcode;
uint8_t qrcodeData[qrcode_getBufferSize(3)];
qrcode_initText(&qrcode, qrcodeData, 3, 0, "http://www.lingzhilab.com");
// Delta time
dt = millis() - dt;
Serial.print("QR Code Generation Time: ");
Serial.print(dt);
Serial.print("\n");
// Top quiet zone
Serial.print("\n\n\n\n");
//顯示到OLED上
for (uint8_t y = 0; y < qrcode.size; y++) {
// Left quiet zone
Serial.print(" ");
// Each horizontal module
for (uint8_t x = 0; x < qrcode.size; x++) {
// Print each module (UTF-8 \u2588 is a solid block)
//Serial.print(qrcode_getModule(&qrcode, x, y) ? "\u2588\u2588": " ");
if(qrcode_getModule(&qrcode,x,y)){
display.drawPixel(x, y, WHITE);
}else{
display.drawPixel(x, y, BLACK);
}
}
Serial.print("\n");
}
display.display();
// Bottom quiet zone
Serial.print("\n\n\n\n");
}
void loop() {
}
復(fù)制代碼
最后在OLED上可以看到我們生成的二維碼:
31.jpg
(282.43 KB, 下載次數(shù): 57)
下載附件
2018-7-31 16:39 上傳
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1