Pixart提供基礎的鼠標和鍵盤代碼, 開發者可以基於此快速的建置自己的firmware, application, 以下介紹代碼中用來控制LED的API函式.
- 常亮模式 (Always on)
常亮模式, 調用API "pwm_led_set_always_on" 及 channel 來設置對應LED常亮.
![](https://edit.wpgdadawant.com/uploads/news_file/blog/2024/15072/tinymce/pwm_led_set_always_on.png)
![](https://edit.wpgdadawant.com/uploads/news_file/blog/2024/15072/tinymce/pwm_led_set_always_on.png)
- 閃爍模式 (Flash mode)
閃爍模式, 調用API "pwm_led_set_flash" 及 設定LED channel, on/off的時間, 閃爍次數...等參數, 使LED達到閃爍效果. 下圖Figure 1. 為設定參數所對應之timing.
![](https://edit.wpgdadawant.com/uploads/news_file/blog/2024/15072/tinymce/pwm_led_set_flash_.png)
![](https://edit.wpgdadawant.com/uploads/news_file/blog/2024/15072/tinymce/flash_timing_diagram_new.png)
![](https://edit.wpgdadawant.com/uploads/news_file/blog/2024/15072/tinymce/pwm_led_set_flash_.png)
![](https://edit.wpgdadawant.com/uploads/news_file/blog/2024/15072/tinymce/flash_timing_diagram_new.png)
- 呼吸模式 (Breath mode)
呼吸模式, 調用API "pwm_led_set_breath" 及 設定LED channel, 亮起時的最小/最大時間, 間格時間....等參數, 使LED達到呼吸效果. 下圖Figure 2. 為設定參數所對應之timing.
![](https://edit.wpgdadawant.com/uploads/news_file/blog/2024/15072/tinymce/pwm_led_set_breath_.png)
![](https://edit.wpgdadawant.com/uploads/news_file/blog/2024/15072/tinymce/breath_timing_diagram_new.png)
- 脈寬調變模式 (PWM mode)
脈寬調變模式, 調用API "pwm_led_set_pwm" 和 設定LED channel, on/off時間參數, 來調整LED亮與滅的效果. 下圖Figure 3. 為設定參數所對應之timing.
![](https://edit.wpgdadawant.com/uploads/news_file/blog/2024/15072/tinymce/pwm_led_set_pwm_.png)
![](https://edit.wpgdadawant.com/uploads/news_file/blog/2024/15072/tinymce/pwm_timing_diagram_new.png)
![](https://edit.wpgdadawant.com/uploads/news_file/blog/2024/15072/tinymce/pwm_led_set_pwm_.png)
![](https://edit.wpgdadawant.com/uploads/news_file/blog/2024/15072/tinymce/pwm_timing_diagram_new.png)
Pixart 提供的基礎代碼已包含許多初始化設定和基本函示, 開發者透過調用LED API的函式, 不僅能實現基本的燈效, 經由調變還能實現其他燈效, 如流光, 霓虹, 混彩.....等, 下回有機會再深入介紹, 謝謝.
評論