1 Star 0 Fork 5

raymonlee/Arduino_ESP32_LyricBox

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
MusicSpectrum.cpp 2.84 KB
一键复制 编辑 原始数据 按行查看 历史
mingyee 提交于 2022-10-24 02:05 . Arduino_ESP32_LyricBox
#include <Arduino.h>
#include "MusicSpectrum.h"
NS_DT_BEGIN
const uint8_t icon_music[] PROGMEM =
{
0x00,0x3F,0x21,0x21,0x21,0xE7,0xE7,0x00
};
// uint8_t frame_freq_spec[20][32] = {
// {1,2,5,4,7,4,4,1,7,5,1,0,2,1,1,5,7,0,7,4,1,1,2,2,1,0,2,3,1,1,2,0},
// {1,2,2,3,7,1,0,1,4,7,3,3,0,4,3,1,6,2,0,4,2,3,4,3,0,1,3,4,3,2,1,1},
// {3,4,2,4,7,5,1,0,7,3,2,4,0,4,0,3,3,0,2,2,3,2,2,4,2,3,2,4,2,2,3,0},
// {2,1,5,5,0,2,1,1,3,6,3,2,0,4,4,0,2,3,3,1,1,2,1,1,3,2,7,3,4,1,4,2},
// {1,6,3,2,7,3,0,3,2,3,5,1,1,3,3,4,2,3,3,1,2,1,2,0,3,1,0,1,2,0,1,0},
// {4,7,6,5,2,4,5,1,2,3,1,1,1,1,2,4,2,1,3,2,4,1,0,2,2,3,0,1,1,4,1,2},
// {4,6,1,4,7,5,2,4,2,4,4,6,3,5,4,2,3,0,1,3,2,1,2,1,0,1,2,1,2,2,3,1},
// {4,2,4,3,7,2,6,2,1,1,1,1,0,3,2,1,0,1,3,3,1,2,1,2,2,1,1,2,0,2,4,2},
// {4,2,4,0,3,7,1,2,3,5,6,7,3,2,0,1,2,4,1,2,2,1,7,2,0,3,2,2,1,1,1,3},
// {4,1,0,4,3,7,1,1,3,2,4,5,2,5,5,1,2,0,4,4,0,1,1,1,3,7,2,1,1,2,5,3},
// {4,2,1,1,1,6,7,4,3,3,1,3,3,2,1,5,6,3,2,1,1,0,3,3,2,2,2,2,1,3,1,4},
// {4,4,1,3,0,3,7,5,3,5,4,3,0,3,2,2,5,6,4,1,1,3,1,4,1,1,2,2,2,2,2,2},
// {0,3,3,1,1,7,7,2,2,5,1,1,1,0,2,7,3,1,4,1,2,0,5,2,1,1,3,1,2,0,1,0},
// {6,2,4,5,2,6,3,5,3,2,3,3,3,1,3,1,5,2,1,2,2,1,4,2,2,4,3,2,3,4,5,1},
// {2,7,5,0,2,3,5,1,6,4,4,3,4,5,1,2,2,3,2,2,4,0,1,3,1,3,1,0,2,3,1,1},
// {6,2,1,2,2,6,2,2,2,2,3,4,3,5,5,2,5,5,2,3,1,1,2,3,2,1,1,2,1,1,0,5},
// {6,3,3,7,2,3,3,4,2,4,3,2,0,4,5,3,3,0,4,3,2,3,4,0,3,2,0,0,1,3,3,4},
// {4,7,2,3,3,2,1,1,0,3,1,1,1,1,2,1,1,3,2,1,0,2,1,3,0,3,2,3,1,3,3,1},
// {4,6,2,7,5,5,1,3,3,7,2,1,4,4,5,2,1,1,0,4,4,0,1,0,3,1,1,1,2,2,2,1},
// {2,1,3,5,7,0,4,4,5,2,2,4,4,5,4,1,2,3,2,3,4,0,1,1,2,3,0,2,1,4,2,1}
// };
bool MusicSpectrum::init()
{
MusicSpectrumLayer *rootLayer = MusicSpectrumLayer::create();
rootLayer->setContentSize(Size(MATRIX_WIDTH,MATRIX_HEIGHT));
this->addChild(rootLayer);
rootLayer->initLayer();
return true;
}
MusicSpectrumLayer::~MusicSpectrumLayer()
{
}
bool MusicSpectrumLayer::initLayer()
{
Size size = this->getContentSize();
CanvasSprite *canvasSprite = CanvasSprite::create(size.width,size.height);
this->addChild(canvasSprite);
//this->scheduleUpdate();
canvas = canvasSprite->getSpriteCanvas();
canvas->drawPixel(8,0,DTRGB(0xff,0,0));
canvas->drawPixel(8,7,DTRGB(0x00,0xff,0));
canvas->drawPixel(47,15,DTRGB(0x00,0x00,0xff));
// canvas->fillScreen(DTRGB(0xEE,0x6A,0x50));
// MoveBy *move1 = MoveBy::create(6,Vec2(-47,0));
// MoveBy *move2 = MoveBy::create(6,Vec2(47,0));
// Sequence *seq = Sequence::createWithTwoActions(move1,move2);
// RepeatForever *rep = RepeatForever::create(seq);
// canvasSprite->runAction(rep);
// this->scheduleUpdate();
return true;
}
uint8_t peak_height[32];
uint8_t spec_height[32];
void MusicSpectrumLayer::update(float dt)
{
static uint8_t frame = 0;
uint8_t i = 0;
}
NS_DT_END
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/raymonlee/Arduino_ESP32_LyricBox.git
git@gitee.com:raymonlee/Arduino_ESP32_LyricBox.git
raymonlee
Arduino_ESP32_LyricBox
Arduino_ESP32_LyricBox
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385