56 {
59 ;
60 }
61
63
64
65 remote.bind(
"setLed", [](
int index,
int r,
int g,
int b) {
66 if (index >= 0 && index <
NUM_LEDS) {
68 FL_DBG(
"Set LED " << index <<
" to RGB(" << r <<
", " << g <<
", " << b <<
")");
69 }
70 });
71
72 remote.bind(
"fill", [](
int r,
int g,
int b) {
74 FL_DBG(
"Filled all LEDs with RGB(" << r <<
", " << g <<
", " << b <<
")");
75 });
76
80 });
81
82
83
84 remote.bind(
"millis", []() -> int64_t {
85 return static_cast<int64_t
>(
millis());
86 });
87
88 remote.bind(
"micros", []() -> int64_t {
89 return static_cast<int64_t
>(
micros());
90 });
91
98 });
99
102 if (index >= 0 && index <
NUM_LEDS) {
106 } else {
107 result.set(
"error",
"Index out of range");
108 }
110 });
111
112 Serial.println(
"Remote RPC example ready");
114
115
116 Serial.println(
"=== RPC Schema ===");
119
120 Serial.print(
"Schema size: ");
122 Serial.println(
" bytes (flat tuple format)");
124
125 Serial.println(
"Send JSON over serial, e.g.:");
126 Serial.println(
" Commands (no return):");
127 Serial.println(R
"( {"function":"fill","args":[255,0,0]})");
128 Serial.println(R"( {"timestamp":5000,"function":"setBrightness","args":[64]})");
129 Serial.println(" Queries (with return):");
130 Serial.println(R
"( {"function":"millis","args":[]})");
131 Serial.println(R"( {"function":"getStatus","args":[]})");
132 Serial.println(R"( {"function":"getLed","args":[0]})");
133 Serial.println(" Schema:");
134 Serial.println(R
"raw( {"method":"rpc.discover","id":1})raw" " // Get RPC schema");
135}
fl::UISlider brightness("Brightness", BRIGHTNESS, 0, 255)
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
fl::unique_ptr< fl::Remote > remote
fl::size size() const FL_NO_EXCEPT
fl::string to_string() const FL_NO_EXCEPT
static json object() FL_NO_EXCEPT
void fill_solid(CRGB *targetArray, int numToFill, const CRGB &color) FL_NO_EXCEPT
Fill a range of LEDs with a solid color.
fl::u32 millis() FL_NO_EXCEPT
Universal millisecond timer - returns milliseconds since system startup.
fl::u32 micros() FL_NO_EXCEPT
Universal microsecond timer - returns microseconds since system startup.
expected< T, E > result
Alias for expected (Rust-style naming)