查看: 142|回复: 0

【花雕动手做】ASRPRO语音识别(41)---64位WS2812B点阵屏模块

[复制链接]

64

主题

86

帖子

477

积分

中级会员

Rank: 3Rank: 3

积分
477
发表于 2024-1-16 19:07:33 | 显示全部楼层 |阅读模式
本例实验使用64位WS2812点阵屏模块

0.jpg

知识点:WS2812B
是一个集控制电路与发光电路于一体的智能外控LED光源。其外型与一个5050LED灯珠相同,每个元件即为一个像素点。像素点内部包含了智能数字接口数据锁存信号整形放大驱动电路,还包含有高精度的内部振荡器和12V高压可编程定电流控制部分,有效保证了像素点光的颜色高度一致。

数据协议采用单线归零码的通讯方式,像素点在上电复位以后,DIN端接受从控制器传输过来的数据,首先送过来的24bit数据被第一个像素点提取后,送到像素点内部的数据锁存器,剩余的数据经过内部整形处理电路整形放大后通过DO端口开始转发输出给下一个级联的像素点,每经过一个像素点的传输,信号减少24bit。像素点采用自动整形转发技术,使得该像素点的级联个数不受信号传送的限制,仅仅受限信号传输速度要求。

LED具有低电压驱动,环保节能,亮度高,散射角度大,一致性好,超低功率,超长寿命等优点。将控制电路集成于LED上面,电路变得更加简单,体积小,安装更加简便。

03-.jpg

WS2812B主要特点
1、智能反接保护,电源反接不会损坏IC。
2、IC控制电路与LED点光源公用一个电源。
3、控制电路与RGB芯片集成在一个5050封装的元器件中,构成一个完整的外控像素点。
4、内置信号整形电路,任何一个像素点收到信号后经过波形整形再输出,保证线路波形畸变不会累加。
5、内置上电复位和掉电复位电路。
6、每个像素点的三基色颜色可实现256级亮度显示,完成16777216种颜色的全真色彩显示,扫描频率不低于400Hz/s。
7、串行级联接口,能通过一根信号线完成数据的接收与解码。
8、任意两点传传输距离在不超过5米时无需增加任何电路。
9、当刷新速率30帧/秒时,级联数不小于1024点。
10、数据发送速度可达800Kbps。
11、光的颜色高度一致,性价比高。

07.jpg

实验开源代码

  1. #define ASC2_12
  2. #define ST7735_CS_PIN 9
  3. #define ST7735_CS_GPIO_PIN gpio_pin_1
  4. #define ST7735_DC_PIN 1
  5. #define ST7735_DC_GPIO_PIN gpio_pin_1
  6. #define ST7735_RST_PIN 25
  7. #define ST7735_RST_GPIO_PIN gpio_pin_1
  8. #define ST7735_SCK_PIN 3
  9. #define ST7735_SCK_GPIO_PIN gpio_pin_3
  10. #define ST7735_MOSI_PIN 2
  11. #define ST7735_MOSI_GPIO_PIN gpio_pin_2
  12. #define ASC2_32
  13. #define ST7735S_RGB_GBR_ORDER   0

  14. #include "asr.h"
  15. extern "C"{ void * __dso_handle = 0 ;}
  16. #include "setup.h"
  17. #include "myLib/asr_st7735.h"
  18. #include "myLib/asr_ws2812.h"
  19. #include "myLib/asr_event.h"
  20. #include "asr_math.h"

  21. uint32_t snid;
  22. void hardware_init();

  23. SPITFT spi_tft(128, 160);
  24. WS2812 ASR_WS2812_24(24);
  25. //{ID:250,keyword:"命令词",ASR:"最大音量",ASRTO:"音量调整到最大"}
  26. //{ID:251,keyword:"命令词",ASR:"中等音量",ASRTO:"音量调整到中等"}
  27. //{ID:252,keyword:"命令词",ASR:"最小音量",ASRTO:"音量调整到最小"}
  28. void sys_sleep_hook()
  29. {
  30.   digital_write((4),1);
  31.   digital_write((21),0);

  32. }

  33. void ASR_CODE()
  34. {
  35.   //{ID:500,keyword:"命令词",ASR:"随机点灯",ASRTO:""}
  36.   if(snid == 500){
  37.     digital_write((21),1);
  38.     spi_tft.clear((0xF800));
  39.     spi_tft.set_text_color((0xFFFF),(0xF800));
  40.     spi_tft.set_cursor(0,50);
  41.     spi_tft.draw_hanzi_32("随机点灯");
  42.     //{ID:501,keyword:"命令词",ASR:"耍接官",ASRTO:"随机亮灯"}
  43.     play_audio(501);
  44.     ASR_WS2812_24.setBrightness(25);
  45.     ASR_WS2812_24.pixel_set_color((random(0, 63+1)),255,0,0);
  46.     ASR_WS2812_24.setBrightness(25);
  47.     ASR_WS2812_24.pixel_set_color((random(0, 63+1)),0,255,0);
  48.     ASR_WS2812_24.setBrightness(70);
  49.     ASR_WS2812_24.pixel_set_color((random(0, 63+1)),0,0,255);
  50.     ASR_WS2812_24.pixel_show();
  51.     delay(500);
  52.     ASR_WS2812_24.setBrightness(25);
  53.     ASR_WS2812_24.pixel_set_color((random(0, 63+1)),255,0,0);
  54.     ASR_WS2812_24.setBrightness(25);
  55.     ASR_WS2812_24.pixel_set_color((random(0, 63+1)),0,255,0);
  56.     ASR_WS2812_24.setBrightness(70);
  57.     ASR_WS2812_24.pixel_set_color((random(0, 63+1)),0,0,255);
  58.     ASR_WS2812_24.pixel_show();
  59.     delay(500);
  60.     ASR_WS2812_24.setBrightness(25);
  61.     ASR_WS2812_24.pixel_set_color((random(0, 63+1)),255,0,0);
  62.     ASR_WS2812_24.setBrightness(25);
  63.     ASR_WS2812_24.pixel_set_color((random(0, 63+1)),0,255,0);
  64.     ASR_WS2812_24.setBrightness(70);
  65.     ASR_WS2812_24.pixel_set_color((random(0, 63+1)),0,0,255);
  66.     ASR_WS2812_24.pixel_show();
  67.     delay(500);
  68.     ASR_WS2812_24.setBrightness(25);
  69.     ASR_WS2812_24.pixel_set_color((random(0, 63+1)),255,0,0);
  70.     ASR_WS2812_24.setBrightness(25);
  71.     ASR_WS2812_24.pixel_set_color((random(0, 63+1)),0,255,0);
  72.     ASR_WS2812_24.setBrightness(70);
  73.     ASR_WS2812_24.pixel_set_color((random(0, 63+1)),0,0,255);
  74.     ASR_WS2812_24.pixel_show();
  75.     delay(500);
  76.     ASR_WS2812_24.setBrightness(25);
  77.     ASR_WS2812_24.pixel_set_color((random(0, 63+1)),255,0,0);
  78.     ASR_WS2812_24.setBrightness(25);
  79.     ASR_WS2812_24.pixel_set_color((random(0, 63+1)),0,255,0);
  80.     ASR_WS2812_24.setBrightness(70);
  81.     ASR_WS2812_24.pixel_set_color((random(0, 63+1)),0,0,255);
  82.     ASR_WS2812_24.pixel_show();
  83.     delay(500);
  84.     ASR_WS2812_24.setBrightness(25);
  85.     ASR_WS2812_24.pixel_set_color((random(0, 63+1)),255,0,0);
  86.     ASR_WS2812_24.setBrightness(25);
  87.     ASR_WS2812_24.pixel_set_color((random(0, 63+1)),0,255,0);
  88.     ASR_WS2812_24.setBrightness(70);
  89.     ASR_WS2812_24.pixel_set_color((random(0, 63+1)),0,0,255);
  90.     ASR_WS2812_24.pixel_show();
  91.     delay(500);
  92.   }
  93.   //{ID:502,keyword:"命令词",ASR:"反应挺快",ASRTO:"谢谢鼓励"}
  94.   if(snid == 502){

  95.   }
  96.   //{ID:503,keyword:"命令词",ASR:"点亮三个",ASRTO:"语音控制点亮三个灯"}
  97.   if(snid == 503){
  98.     ASR_WS2812_24.setBrightness(30);
  99.     ASR_WS2812_24.pixel_set_color(0,255,0,0);
  100.     ASR_WS2812_24.setBrightness(30);
  101.     ASR_WS2812_24.pixel_set_color(31,0,255,0);
  102.     ASR_WS2812_24.setBrightness(50);
  103.     ASR_WS2812_24.pixel_set_color(63,0,0,255);
  104.     ASR_WS2812_24.pixel_show();
  105.     spi_tft.clear((0x001F));
  106.     spi_tft.set_text_color((0xFFFF),(0x001F));
  107.     spi_tft.set_cursor(0,30);
  108.     spi_tft.draw_hanzi_32("语音控制");
  109.     delay(500);
  110.     spi_tft.set_cursor(5,70);
  111.     spi_tft.draw_hanzi_24("点亮三个灯");
  112.   }
  113.   //{ID:504,keyword:"命令词",ASR:"点亮五个",ASRTO:"语音控制点亮五个灯"}
  114.   if(snid == 504){
  115.     ASR_WS2812_24.setBrightness(30);
  116.     ASR_WS2812_24.pixel_set_color(14,255,0,0);
  117.     ASR_WS2812_24.setBrightness(30);
  118.     ASR_WS2812_24.pixel_set_color(23,0,255,0);
  119.     ASR_WS2812_24.setBrightness(50);
  120.     ASR_WS2812_24.pixel_set_color(60,0,0,255);
  121.     ASR_WS2812_24.setBrightness(30);
  122.     ASR_WS2812_24.pixel_set_color(45,255,255,0);
  123.     ASR_WS2812_24.setBrightness(40);
  124.     ASR_WS2812_24.pixel_set_color(3,136,0,255);
  125.     ASR_WS2812_24.pixel_show();
  126.     spi_tft.clear((0x001F));
  127.     spi_tft.set_text_color((0xFFFF),(0x001F));
  128.     spi_tft.set_cursor(0,30);
  129.     spi_tft.draw_hanzi_32("语音控制");
  130.     delay(500);
  131.     spi_tft.set_cursor(5,70);
  132.     spi_tft.draw_hanzi_24("点亮五个灯");
  133.   }
  134.   //{ID:505,keyword:"唤醒词",ASR:"智能管家",ASRTO:"我在"}
  135.   if(snid == 505){
  136.     ASR_WS2812_24.pixel_set_all_color(0,0,0);
  137.     ASR_WS2812_24.pixel_show();
  138.     digital_write((4),0);
  139.     digital_write((21),1);
  140.     spi_tft.clear((0x07E0));
  141.   }
  142. }

  143. void hardware_init(){
  144.   spi_tft.init();
  145.   spi_tft.set_direction(2);
  146.   spi_tft.set_text_wrap(true);
  147.   spi_tft.set_text_size(32);
  148.   spi_tft.set_bg_mode(1);
  149.   ASR_WS2812_24.pixel_init(64);
  150.   pinMode(4,output);
  151.   pinMode(24,output);
  152.   digital_write((4),1);
  153.   digital_write((21),0);
  154.   vTaskDelete(NULL);
  155. }

  156. void setup()
  157. {
  158.   //{speak:方方-标准女声,vol:14,speed:10,platform:haohaodada}
  159.   //{playid:10001,voice:欢迎使用人工智能AI语音助手,用智能管家唤醒我}
  160.   //{playid:10002,voice:我退下了}
  161.   randomSeed(1);
  162.   ASR_WS2812_24.pixel_set_all_color(0,0,0);
  163.   ASR_WS2812_24.pixel_show();
  164.   xTaskCreate(hardware_init,"hardware_init",256,NULL,100,NULL);
  165. }
复制代码

生成模型与编译烧录

21.jpg

22-.jpg

实验记录视频

【【花雕动手做】ASRPRO语音识别(41)---64位WS2812B点阵屏模块】
https://www.bilibili.com/video/BV1ew411J7d6/?share_source=copy_web&vd_source=371a292a55e5ca9be994cbb4a86cc987




26 (4).jpg

26 (3).jpg

26 (1).jpg

26 (2).jpg




回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|好好搭搭在线 ( © 好好搭搭在线 浙ICP备19030393号-1 )

GMT+8, 2024-4-28 12:08 , Processed in 0.322468 second(s), 26 queries .

Powered by Discuz!

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表