本例实验采用板载三位独立按键,可以搭配实现各种相关的功能。
本例实验的SPI彩色液晶1.77寸显示屏(ST7735驱动)
TFT177-SPI,型号为SX177QQVGA,像素128X160TFT,驱动芯片为ST7735S,这是一款支持SPI接口的1.77寸TFT彩屏,可以显示文字、图形、图片等内容,提高用户互动体验度。
【花雕动手做】实验二十三:使用按键和语音控制1.8寸彩屏转换颜色与汉字
实验开源代码
- #define ASC2_12
- #define ST7735_CS_PIN 9
- #define ST7735_CS_GPIO_PIN gpio_pin_1
- #define ST7735_DC_PIN 1
- #define ST7735_DC_GPIO_PIN gpio_pin_1
- #define ST7735_RST_PIN 25
- #define ST7735_RST_GPIO_PIN gpio_pin_1
- #define ST7735_SCK_PIN 3
- #define ST7735_SCK_GPIO_PIN gpio_pin_3
- #define ST7735_MOSI_PIN 2
- #define ST7735_MOSI_GPIO_PIN gpio_pin_2
- #define ST7735S_RGB_GBR_ORDER 0
-
- #include "asr.h"
- extern "C"{ void * __dso_handle = 0 ;}
- #include "setup.h"
- #include "myLib/asr_st7735.h"
- #include "myLib/asr_event.h"
-
- uint32_t snid;
- void ASR_CODE();
- void hardware_init();
-
- SPITFT spi_tft(128, 160);
- /*描述该功能...
- */
- void ASR_CODE(){
- switch (snid) {
- case 0:
- digitalWrite(21,1);
- spi_tft.clear((0xFFFF));
- break;
- case 1:
- spi_tft.clear((0xF800));
- spi_tft.set_text_color((0xFFFF),(0xF800));
- spi_tft.set_cursor(0,50);
- spi_tft.draw_hanzi_32("红色屏幕");
- break;
- case 2:
- spi_tft.clear((0x001F));
- spi_tft.set_text_color((0xFFFF),(0x001F));
- spi_tft.set_cursor(0,50);
- spi_tft.draw_hanzi_32("蓝色屏幕");
- break;
- case 3:
- spi_tft.clear((0x07E0));
- spi_tft.set_text_color((0xFFFF),(0x07E0));
- spi_tft.set_cursor(0,50);
- spi_tft.draw_hanzi_32("绿色屏幕");
- break;
- }
-
- }
-
- //{ID:250,keyword:"命令词",ASR:"最大音量",ASRTO:"音量调整到最大"}
- //{ID:251,keyword:"命令词",ASR:"中等音量",ASRTO:"音量调整到中等"}
- //{ID:252,keyword:"命令词",ASR:"最小音量",ASRTO:"音量调整到最小"}
- void hardware_init(){
- spi_tft.init();
- digital_write((21),0);
- spi_tft.set_direction(2);
- spi_tft.set_text_wrap(true);
- spi_tft.set_text_size(12);
- spi_tft.set_bg_mode(1);
- pinMode(4,input);
- setPinFun(4,FIRST_FUNCTION);
- pinMode(18,input);
- dpmu_set_adio_reuse(PC2,DIGITAL_MODE);
- dpmu_set_io_pull(pinToFun[18],DPMU_IO_PULL_UP);
- setPinFun(18,SECOND_FUNCTION);
- pinMode(19,input);
- dpmu_set_adio_reuse(PC3,DIGITAL_MODE);
- dpmu_set_io_pull(pinToFun[19],DPMU_IO_PULL_UP);
- setPinFun(19,SECOND_FUNCTION);
- while (1) {
- if(!(digitalRead(4))){
- digitalWrite(21,1);
- spi_tft.clear((0x07E0));
- delay(200);
- enter_wakeup(5000);
- delay(200);
- //{ID:500,keyword:"命令词",ASR:"耍接官",ASRTO:"绿色"}
- play_audio(500);
- }
- if(!(digitalRead(19))){
- digitalWrite(21,1);
- spi_tft.clear((0x001F));
- delay(200);
- enter_wakeup(5000);
- delay(200);
- //{ID:501,keyword:"命令词",ASR:"接耍官",ASRTO:"蓝色"}
- play_audio(501);
- }
- if(!(digitalRead(18))){
- digitalWrite(21,1);
- spi_tft.clear((0xF800));
- delay(200);
- enter_wakeup(5000);
- delay(200);
- //{ID:502,keyword:"命令词",ASR:"官耍接",ASRTO:"红色"}
- play_audio(502);
- }
- delay(100);
- }
- vTaskDelete(NULL);
- }
-
- void setup()
- {
- //{speak:小英-日常,vol:18,speed:10,platform:haohaodada,version:V3}
- //{playid:10001,voice:欢迎使用人工智能AI语音助手,用智能管家唤醒我}
- //{playid:10002,voice:我退下了,用智能管家唤醒我}
- //{ID:0,keyword:"唤醒词",ASR:"智能管家",ASRTO:"我在"}
- //{ID:1,keyword:"命令词",ASR:"屏幕红色",ASRTO:"好的,红了"}
- //{ID:2,keyword:"命令词",ASR:"屏幕蓝色",ASRTO:"好的,蓝了"}
- //{ID:3,keyword:"命令词",ASR:"屏幕绿色",ASRTO:"好的,绿了"}
- //{ID:4,keyword:"命令词",ASR:"不错不错",ASRTO:"谢谢鼓励哦"}
- xTaskCreate(hardware_init,"hardware_init",256,NULL,100,NULL);
- }
复制代码
训练模型与编译烧录
实验记录视频
https://www.bilibili.com/video/BV1CN4y1s7nb/?share_source=copy_web&vd_source=371a292a55e5ca9be994cbb4a86cc987
|