MCPcopy Create free account
hub / github.com/Blueforcer/awtrix3 / sendButton

Method sendButton

src/ServerManager.cpp:393–433  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

391}
392
393void ServerManager_::sendButton(byte btn, bool state)
394{
395 if (BUTTON_CALLBACK == "")
396 return;
397 static bool btn0State, btn1State, btn2State;
398 String payload;
399 switch (btn)
400 {
401 case 0:
402 if (btn0State != state)
403 {
404 btn0State = state;
405 payload = "button=left&state=" + String(state);
406 }
407 break;
408 case 1:
409 if (btn1State != state)
410 {
411 btn1State = state;
412 payload = "button=middle&state=" + String(state);
413 }
414 break;
415 case 2:
416 if (btn2State != state)
417 {
418 btn2State = state;
419 payload = "button=right&state=" + String(state);
420 }
421 break;
422 default:
423 return;
424 }
425 if (!payload.isEmpty())
426 {
427 HTTPClient http;
428 http.begin(BUTTON_CALLBACK);
429 http.addHeader("Content-Type", "application/x-www-form-urlencoded");
430 http.POST(payload);
431 http.end();
432 }
433}

Callers

nothing calls this directly

Calls 1

beginMethod · 0.45

Tested by

no test coverage detected