Last active
January 12, 2023 13:36
-
-
Save 3110/93607be110adc78d6cd2f1cfd68acda8 to your computer and use it in GitHub Desktop.
ATOMS3のMACアドレスをQRコードと文字列で表示する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <M5AtomS3.h> | |
const size_t ETH_ALEN = 6; | |
const uint16_t SPACING = 4; | |
const uint8_t FONT = 1; | |
const uint8_t FONT_HEIGHT = 8; | |
const uint8_t QR_VERSION = 1; | |
uint8_t macAddr[ETH_ALEN] = {0}; | |
char macStr[ETH_ALEN * 3 + 1] = {0}; | |
void setup(void) { | |
esp_read_mac(macAddr, ESP_MAC_WIFI_STA); | |
snprintf(macStr, sizeof(macStr), "%02X:%02X:%02X:%02X:%02X:%02X", | |
macAddr[0], macAddr[1], macAddr[2], macAddr[3], macAddr[4], | |
macAddr[5]); | |
M5.begin(); | |
M5.Lcd.setRotation(2); | |
M5.Lcd.fillScreen(TFT_WHITE); | |
M5.Lcd.setTextColor(TFT_BLACK); | |
M5.Lcd.qrcode(macStr, SPACING, SPACING / 2, M5.Lcd.width() - SPACING * 2, | |
QR_VERSION); | |
M5.Lcd.drawCentreString(macStr, M5.Lcd.width() / 2, | |
M5.Lcd.height() - (FONT_HEIGHT + SPACING / 2), | |
FONT); | |
} | |
void loop(void) { | |
M5.update(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment