Definition at line 55 of file Remote.ino.
55 {
58 ;
59 }
60
62
63
64 remote.bind(
"setLed", [](
int index,
int r,
int g,
int b) {
65 if (index >= 0 && index <
NUM_LEDS) {
67 FL_DBG(
"Set LED " << index <<
" to RGB(" << r <<
", " << g <<
", " << b <<
")");
68 }
69 });
70
71 remote.bind(
"fill", [](
int r,
int g,
int b) {
73 FL_DBG(
"Filled all LEDs with RGB(" << r <<
", " << g <<
", " << b <<
")");
74 });
75
79 });
80
81
82
83 remote.bind(
"millis", []() -> int64_t {
84 return static_cast<int64_t
>(
millis());
85 });
86
87 remote.bind(
"micros", []() -> int64_t {
88 return static_cast<int64_t
>(
micros());
89 });
90
97 });
98
101 if (index >= 0 && index <
NUM_LEDS) {
105 } else {
106 result.set(
"error",
"Index out of range");
107 }
109 });
110
111 Serial.println(
"Remote RPC example ready");
113
114
115 Serial.println(
"=== RPC Schema ===");
118
119 Serial.print(
"Schema size: ");
121 Serial.println(
" bytes (flat tuple format)");
123
124 Serial.println(
"Send JSON over serial, e.g.:");
125 Serial.println(
" Commands (no return):");
126 Serial.println(R
"( {"function":"fill","args":[255,0,0]})");
127 Serial.println(R"( {"timestamp":5000,"function":"setBrightness","args":[64]})");
128 Serial.println(" Queries (with return):");
129 Serial.println(R
"( {"function":"millis","args":[]})");
130 Serial.println(R"( {"function":"getStatus","args":[]})");
131 Serial.println(R"( {"function":"getLed","args":[0]})");
132 Serial.println(" Schema:");
133 Serial.println(R
"raw( {"method":"rpc.discover","id":1})raw" " // Get RPC schema");
134}
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_NOEXCEPT
fl::string to_string() const FL_NOEXCEPT
static json object() FL_NOEXCEPT
void fill_solid(CRGB *targetArray, int numToFill, const CRGB &color) FL_NOEXCEPT
Fill a range of LEDs with a solid color.
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.
expected< T, E > result
Alias for expected (Rust-style naming)
fl::u32 micros()
Universal microsecond timer - returns microseconds since system startup.
References brightness, DATA_PIN, FastLED, fill_solid(), FL_DBG, GRB, leds, NUM_LEDS, fl::json::object(), remote, Serial, fl::basic_string::size(), and fl::json::to_string().