代码拉取完成,页面将自动刷新
同步操作将从 mingyee/Arduino_ESP32_LyricBox 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include <Arduino.h>
#include "MusicLyrics.h"
#include "audio_hal.h"
extern char music_lyrics[100];
NS_DT_BEGIN
const uint8_t icon_music_Lyrics[] PROGMEM =
{
0x00,0x3F,0x21,0x21,0x21,0xE7,0xE7,0x00
};
const DTRGB LyricsColor[LYRICS_COLOR_NUM] = {
{0xEE,0x6A,0x50}, //???
{0xC8,0x00,0x00}, //??
{0xF9,0x58,0x00}, //??
{0xFA,0xC5,0x15}, //??
{0x4D,0xEB,0x02}, //??
{0x1A,0xE6,0xE6}, //??
{0x00,0x2D,0xFF}, //??
{0x91,0x2B,0xD5} //??
};
bool MusicLyrics::init()
{
MusicLyricsLayer *rootLayer = MusicLyricsLayer::create();
rootLayer->setContentSize(Size(MATRIX_WIDTH,MATRIX_HEIGHT));
this->addChild(rootLayer);
rootLayer->initLayer();
return true;
}
MusicLyricsLayer::~MusicLyricsLayer()
{
}
bool MusicLyricsLayer::initLayer()
{
Size size = this->getContentSize();
CanvasSprite *canvasSprite = CanvasSprite::create(size.width,size.height);
this->addChild(canvasSprite);
//this->scheduleUpdate();
canvas = canvasSprite->getSpriteCanvas();
canvas->drawSmartStr(0,2,"�������",DTRGB(0xff,0,0xff),DTRGB(0,0,0),12);
this->schedule(DT_SCHEDULE_SELECTOR(MusicLyricsLayer::update),0.025);
return true;
}
void MusicLyricsLayer::update(float dt)
{
uint8_t lyrics_font = 0;
static uint8_t flag_update = 0;
static uint16_t lyrics_len = 0;
static int16_t x_pose = 0;
static char last_lyrics[100] = {0};
if(flag_update==1 && lyrics_len>0){
canvas->canvasReset();
}
if(strncmp(music_lyrics,last_lyrics,strlen(music_lyrics))!=0){
memcpy(last_lyrics,music_lyrics,strlen(music_lyrics));
flag_update = 1;
x_pose = 0;
}
lyrics_len = strlen(music_lyrics)*6;
lyrics_font = app_mode_page_get(MENU_PAGE_LYRICS);
canvas->drawSmartStr(x_pose,2,music_lyrics,LyricsColor[lyrics_font],DTRGB(0,0,0),12);
// lyrics_len = strlen(" Hello I'm ???????? Made by xiaomingst ???????????????????????? ??????~ [PS:??????????????Arduino+ESP32+ES8388 Contact with me: mingle@xiaomingst.tech ]")*6;
// lyrics_font = app_mode_page_get(MENU_PAGE_LYRICS);
// canvas->drawSmartStr(x_pose,2," Hello I'm ???????? Made by xiaomingst ???????????????????????? ??????~ [PS:??????????????Arduino+ESP32+ES8388 Contact with me: mingle@xiaomingst.tech ]",DTRGB(0xff,0,0xff),DTRGB(0,0,0),12);
x_pose--;
if((-(x_pose))>=lyrics_len){
x_pose = 0;
}
}
NS_DT_END
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。