2023年5月29日 星期一

[TFT] 圓形TFT GC9A01指令摘要

本文只是作為暫時的筆記!

想了解 GC9A01 有哪些繪圖指令,可以參考 Adafruit_GC9A01A 的 graphicstest.ino 。



#include "SPI.h"

#include "Adafruit_GFX.h"
#include "Adafruit_GC9A01A.h"

#define TFT_DC 9
#define TFT_CS 10

// Hardware SPI on Feather or other boards
Adafruit_GC9A01A tft(TFT_CS, TFT_DC);

void setup() {

  tft.begin();

}


螢幕屬性

tft.width(); //取得螢幕寬度

tft.height(); //取得螢幕高度

tft.setRotation(uint8_t r); //旋轉螢幕 r=0~3


tft.invertDisplay(bool i); // 螢幕反色
tft.setAddrWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h);


調色

tft.color565(i, i, i);


顏色定義


// Color definitions
#define GC9A01A_BLACK 0x0000 ///< 0, 0, 0
#define GC9A01A_NAVY 0x000F ///< 0, 0, 123
#define GC9A01A_DARKGREEN 0x03E0 ///< 0, 125, 0
#define GC9A01A_DARKCYAN 0x03EF ///< 0, 125, 123
#define GC9A01A_MAROON 0x7800 ///< 123, 0, 0
#define GC9A01A_PURPLE 0x780F ///< 123, 0, 123
#define GC9A01A_OLIVE 0x7BE0 ///< 123, 125, 0
#define GC9A01A_LIGHTGREY 0xC618 ///< 198, 195, 198
#define GC9A01A_DARKGREY 0x7BEF ///< 123, 125, 123
#define GC9A01A_BLUE 0x001F ///< 0, 0, 255
#define GC9A01A_GREEN 0x07E0 ///< 0, 255, 0
#define GC9A01A_CYAN 0x07FF ///< 0, 255, 255
#define GC9A01A_RED 0xF800 ///< 255, 0, 0
#define GC9A01A_MAGENTA 0xF81F ///< 255, 0, 255
#define GC9A01A_YELLOW 0xFFE0 ///< 255, 255, 0
#define GC9A01A_WHITE 0xFFFF ///< 255, 255, 255
#define GC9A01A_ORANGE 0xFD20 ///< 255, 165, 0
#define GC9A01A_GREENYELLOW 0xAFE5 ///< 173, 255, 41
#define GC9A01A_PINK 0xFC18 ///< 255, 130, 198

#define WHITE            0xFFFF
#define BLACK            0x0000  
#define BLUE             0x001F 
#define BRED             0XF81F
#define GRED             0XFFE0
#define GBLUE            0X07FF
#define RED              0xF800
#define MAGENTA          0xF81F
#define GREEN            0x07E0
#define CYAN             0x7FFF
#define YELLOW           0xFFE0
#define BROWN            0XBC40 //棕色
#define BRRED            0XFC07 //棕紅色
#define GRAY             0X8430 //灰色
#define DARKBLUE         0X01CF //深藍色
#define LIGHTBLUE        0X7D7C //淺藍色 
#define GRAYBLUE         0X5458 //灰藍色
#define LIGHTGREEN       0X841F //淺綠色
#define LGRAY            0XC618 //淺灰色(PANNEL),窗體背景色
#define LGRAYBLUE        0XA651 //淺灰藍色(中間層顏色)
#define LBBLUE           0X2B12 //淺棕藍色(選擇條目的反色)

螢幕填色

uint16_t color

tft.fillScreen(GC9A01A_BLACK);  yield();

tft.fillScreen(GC9A01A_WHITE);  yield();

tft.fillScreen(GC9A01A_RED);  yield();

tft.fillScreen(GC9A01A_ORANGE);  yield();

tft.fillScreen(GC9A01A_YELLOW);  yield();

tft.fillScreen(GC9A01A_GREEN);  yield();

tft.fillScreen(GC9A01A_BLUE);  yield();

tft.fillScreen(GC9A01A_CYAN);  yield();
tft.fillScreen(GC9A01A_MAGENTA);  yield();


寫字

tft.setCursor(0, 0); //指定游標位置
tft.setTextColor(GC9A01A_WHITE);  //指定字的顏色
tft.setTextSize(1);  //指定文字尺寸
tft.println("Hello World!");  //寫字
tft.println();  //換行


畫線

tft.drawLine(x1, y1, x2, y2, color);



快速畫線

tft.drawFastHLine(0, y, w, color1);
tft.drawFastVLine(x, 0, h, color2);


畫矩形

tft.drawRect(x, y, i, i, color);


畫矩形色塊

tft.fillRect(x, y, i, i, color);


畫圓

tft.drawCircle(x, y, radius, color);


畫圓形色塊

tft.fillCircle(x, y, radius, color);


畫三角形

tft.drawTriangle(
cx , cy - i, // peak
cx - i, cy + i, // bottom left
cx + i, cy + i, // bottom right
tft.color565(i, i, i));

畫三角形色塊

tft.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
tft.color565(0, i*10, i*10));
t += micros() - start;
tft.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
tft.color565(i*10, i*10, 0));

畫圓角矩形

tft.drawRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(i, 0, 0));


畫圓角矩形色塊

tft.fillRoundRect(cx-i2, cy-i2, i, i, i/8, tft.color565(0, i, 0));
yield();


#include <SPI.h>

#include "LCD_Driver.h"

#include "GUI_Paint.h"

#include "image.h"


void setup()

{

  Config_Init();

  LCD_Init();

  LCD_SetBacklight(1000);

  Paint_NewImage(LCD_WIDTH, LCD_HEIGHT, 0, BLACK);

  Paint_Clear(BLACK);

  Paint_DrawCircle(120,120, 120, BLUE ,DOT_PIXEL_2X2,DRAW_FILL_EMPTY);

  Paint_DrawLine  (120, 0, 120, 12,GREEN ,DOT_PIXEL_4X4,LINE_STYLE_SOLID);

  Paint_DrawLine  (120, 228, 120, 240,GREEN ,DOT_PIXEL_4X4,LINE_STYLE_SOLID);

  Paint_DrawLine  (0, 120, 12, 120,GREEN ,DOT_PIXEL_4X4,LINE_STYLE_SOLID);

  Paint_DrawLine  (228, 120, 240, 120,GREEN ,DOT_PIXEL_4X4,LINE_STYLE_SOLID);

  Paint_DrawImage(gImage_70X70, 85, 25, 70, 70); 

  Paint_DrawString_CN(56,140, "微雪电子",   &Font24CN,BLACK,  WHITE);

  Paint_DrawString_EN(123, 123, "WAVESHARE",&Font16,  BLACK, GREEN);

  Paint_DrawLine  (120, 120, 70, 70,YELLOW ,DOT_PIXEL_3X3,LINE_STYLE_SOLID);

  Paint_DrawLine  (120, 120, 176, 64,BLUE ,DOT_PIXEL_3X3,LINE_STYLE_SOLID);

  Paint_DrawLine  (120, 120, 120, 210,RED ,DOT_PIXEL_2X2,LINE_STYLE_SOLID); 

}

void loop()

{

  

}




/*********************************************************************************************************

  END FILE

*********************************************************************************************************/


Overlay parameters

The overlay support some optional parameters that allow changes in the default behavior and affects only the LCD display. They are key=value pairs, comma separated in no predefined order, as follow:

dtoverlay=gc9a01,speed=40000000,rotate=0,width=240,height=240,fps=50,debug=0
  • speed: max spi frequency to be used
  • rotate: image rotation (in degrees: 0, 90, 180, 270)
  • width: width of the display
  • height: height of the display
  • fps: max fps to be used
  • debug: debug level to be logged on boot process

Additional image orientation and resolution

Since fbcp is making a plain copy from HDMI to LCD, screen resolution may affect the final result. Additional settings can be added on the config.txt in order to adjust the resulting image to your needs. The full set of options can be checked at /boot/overlays/README.

Note that the following settings will be applied both to the HDMI and the LCD.

dtoverlay=gc9a01
hdmi_force_hotplug=1
hdmi_cvt=240 240 60 1 0 0 0
hdmi_group=2
hdmi_mode=87
hdmi_drive=2
display_rotate=2
  • hdmi_force_hotplug: force HDMI output rather than DVI
  • hdmi_cvt: adjusts de resolution, framerate and more. Format: <width> <height> <framerate> <aspect> <margins> <interlace>
  • hdmi_group: set DMT group (Display Monitor Timings: the standard typically used by monitors)
  • hdmi_mode: set DMT mode
  • hdmi_drive: force a HDMI mode rather than DVI
  • display_rotate: rotate screen 180 degrees

The display_rotate setting allows to rotate or flip the screen orientation to fit your needs. The default value is 0, possible values are:

  • 0 no rotation
  • 1 rotate 90 degrees clockwise
  • 2 rotate 180 degrees clockwise
  • 3 rotate 270 degrees clockwise
  • 0x10000 horizontal flip
  • 0x20000 vertical flip

This setting is a bitmask. So you can both flip and rotate the display at the same time. Example:

  • 0x10001 both do a horizontal flip and rotate 90 degrees clockwise (0x10000 + 1).
  • 0x20003 both do a vertical flip and rotate 270 degrees clockwise (0x20000 + 3).




2023年5月10日 星期三

[語音辨識] SU-03T 語音辨識模組周邊配件組裝說明

SU-03T 是一款可以離線運作的智能語音辨識模組,但是如果只購買 SU-03T 核心模組是無法運作的,此模組還需要搭配咪頭(麥克風)、喇叭...等配件。

本文旨在說明如何將配件安裝到 SU-03T 核心模組。


準備工具

1. 剝線鉗

2. 烙鐵、焊錫


組裝步驟

Step1 取出配件,檢查品項數量是否短缺。



Step2 取出 2支 9P排針焊到 SU-03T模組。
取出 4P排針焊到 USB 插頭。
取出長 10cm 杜邦線,剝除尾端之膠皮後分別焊到咪頭和喇叭。
提醒您:
1. 咪頭有正負極性,建議將顏色鮮豔的杜邦線焊到正極。
2. 有些喇叭也有正負極性,但此處沒有區別。




Step3 取出長 20cm 杜邦線連接 USB 插頭和 SU-03T 模組的 VCC 和 GND,此處須注意電源之正負極性,如果錯接將會損壞模組。
將咪頭之杜邦線插到模組的 MIC+ 和 MIC-,此處須注意咪頭正負極性,如果錯接將會損壞咪頭。
將喇叭之杜邦線插到模組的 SPK+ 和 SPK-,此處無須注意喇叭正負極性。




Step4 將 USB 插頭插入行動電源,稍後即可從喇叭傳出歡迎語音。


接著您可以說出下列詞句去控制模組作動:

你好小智

打開燈光

關閉燈光

打開插座

關閉插座

打開空調

關閉空調


觀看影片 https://youtu.be/nQBQvuCe3R8


採購資訊

露天[S&R] https://www.ruten.com.tw/item/show?22319665338637

露天[RWG] https://www.ruten.com.tw/item/show?22319665314697

蝦皮 https://shopee.tw/-RWG-SU-03T-%E6%99%BA%E8%83%BD%E8%AA%9E%E9%9F%B3%E8%BE%A8%E8%AD%98%E6%A8%A1%E7%B5%84-%E5%91%A8%E9%82%8A%E9%85%8D%E4%BB%B6-i.14363185.22242023257?sp_atk=8269e8d1-23ab-4fe3-b988-be7e5695fef6&xptdk=8269e8d1-23ab-4fe3-b988-be7e5695fef6





2022年12月28日 星期三

[Robot] 使用手機透過 ESP32-CAM Wifi 視訊遙控 T10 履帶車

本文旨在說明如何使用手機透過 ESP32-CAM Wifi 視訊遙控 T10 履帶車。

如何組裝履帶車,可參考 「履帶車組裝說明」。






電路接線圖

開啟履帶車電源

Step1 翻轉履帶車並查看底部,小心抽出紅圈處之絕緣塑膠片。


Step2 按一下履帶車正面下層板之船型開關,就可以打開電源。此時 ESP32-CAM 開發板和 L298N 馬達驅動板上的電源指示燈都會亮起。


如果想要取下 18650 鋰電池,可以藉由拉動紅圈處的塑膠帶即可輕易讓鋰電池脫出。


將手機 Wifi 連上 ESP32-CAM

Step1 手機選擇「設定」> 「Wifi」,再點擊「RobotWolfGroup」或是「MyWifiCar」。




Step2 輸入登入密碼「12345678」。



Step3   在手機上開啟瀏覽器,在網址列輸入「192.168.4.1」。


Step4 點擊手機上的方向鍵可以讓履帶車行走。



Step5 在方向鍵下方有速度控制條和燈光強弱控制條。
建議將速度控制條調整到最右側,此時車速最快。如果將車速調得太慢,因 PWM 值太小電壓太低會讓馬達無法轉動。
燈光強弱控制條調整到最右側時燈光最亮,調整到最左側則會關閉燈光。