関数プロトタイプ:
void setLedInstance(std::shared_ptr<LED_Base> instance); 機能説明:
入力パラメータ:
戻り値:
関数プロトタイプ:
LED_Base* getLedInstancePtr(void); 機能説明:
入力パラメータ:
戻り値:
関数プロトタイプ:
bool begin(void); 機能説明:
入力パラメータ:
戻り値:
関数プロトタイプ:
void display(void); 機能説明:
入力パラメータ:
戻り値:
関数プロトタイプ:
void setAutoDisplay(bool enable); 機能説明:
入力パラメータ:
戻り値:
関数プロトタイプ:
size_t getCount(void); 機能説明:
入力パラメータ:
戻り値:
関数プロトタイプ:
RGBColor* getBuffer(void); 機能説明:
入力パラメータ:
戻り値:
関数プロトタイプ:
void setBrightness(uint8_t brightness); 機能説明:
入力パラメータ:
戻り値:
関数プロトタイプ1:
void setColor(size_t index, const RGBColor& color); 関数プロトタイプ2:
void setColor(size_t index, uint8_t red, uint8_t green, uint8_t blue); 関数プロトタイプ3:
void setColor(size_t index, T c); 機能説明:
入力パラメータ:
戻り値:
関数プロトタイプ:
void setColors(const T* values, size_t index = 0, size_t length = INT32_MAX); 機能説明:
入力パラメータ:
戻り値:
関数プロトタイプ:
void setAllColor(T c); 機能説明:
入力パラメータ:
戻り値:
関数プロトタイプ:
bool isEnabled(void); 機能説明:
入力パラメータ:
戻り値:
#include "M5Unified.h"
#include "utility/led/LED_Strip_Class.hpp"
#include "utility/led/LED_Base.hpp"
RGBColor colors[10] = {
{ 255, 0, 0 }, // Red
{ 0, 255, 0 }, // Green
{ 0, 0, 255 }, // Blue
{ 255, 255, 0 }, // Yellow
{ 0, 255, 255 }, // Cyan
{ 255, 0, 255 }, // Magenta
{ 128, 128, 128 }, // Gray
{ 255, 128, 0 }, // Orange
{ 0, 128, 255 }, // Sky Blue
{ 128, 0, 255 } // Purple-Blue
};
void setup() {
M5.begin();
// Configure RMT bus for LED strip (data pin: GPIO26)
auto busled = std::make_shared<m5::LedBus_RMT>();
auto buscfg = busled->getConfig();
buscfg.pin_data = 26;
busled->setConfig(buscfg);
// Configure LED strip (30 LEDs, 3 bytes/LED, GRB order)
auto led_strip = std::make_shared<m5::LED_Strip_Class>();
auto ledcfg = led_strip->getConfig();
ledcfg.led_count = 30;
ledcfg.byte_per_led = 3;
ledcfg.color_order = m5::LED_Strip_Class::config_t::color_order_grb;
led_strip->setConfig(ledcfg);
led_strip->setBus(busled); // Link bus to LED strip
M5.Led.setLedInstance(led_strip); // Register to M5 system
M5.Led.begin(); // Initialize LED strip
M5.Display.clear();
M5.Display.setFont(&fonts::FreeMonoBoldOblique12pt7b);
M5.Display.setCursor(20, 50);
M5.Display.printf("LED Cnt: %d", M5.Led.getCount());
M5.Display.setCursor(20, 70);
M5.Display.printf("LED Status: %s", M5.Led.isEnabled() ? "Enabled" : "Disabled");
M5.Led.setBrightness(100);
}
void loop() {
static int offset = 0; // Scrolling offset (persists between loops)
RGBColor* buf = M5.Led.getBuffer(); // Get LED color buffer
// Assign colors to each LED with offset (cyclic scrolling)
for (int i = 0; i < 30; ++i) {
buf[i] = colors[(i + offset) % 10];
}
M5.Led.setColors(buf, 0, 30); // Update LED strip with buffer data
offset = (offset + 1) % 10; // Increment offset (cycle 0-9)
}M5GO を使用して上記のコードを実行し、PORT.B に 30 個の RGB LED ストリップを接続すると、以下のような効果が得られます: