forked from ctdo/blitzer
32 lines
790 B
C++
32 lines
790 B
C++
|
#include <fluroclock.h>
|
||
|
#include <ESP8266HTTPClient.h>
|
||
|
#include <WiFiClient.h>
|
||
|
#include <string>
|
||
|
|
||
|
String url = "http://151.217.19.22/api/panel/numeric";
|
||
|
WiFiClient client;
|
||
|
HTTPClient http;
|
||
|
|
||
|
void setPanel(int, char);
|
||
|
|
||
|
void displaySpeed(float speed) {
|
||
|
char buffer[6];
|
||
|
dtostrf(speed, 6, 2, buffer);
|
||
|
setPanel(4, buffer[1]);
|
||
|
setPanel(3, buffer[2]);
|
||
|
setPanel(2, buffer[4]);
|
||
|
setPanel(1, buffer[5]);
|
||
|
}
|
||
|
|
||
|
void setPanel(int panel_id, char value) {
|
||
|
http.begin(client, url.c_str());
|
||
|
http.addHeader("Content-Type", "application/json");
|
||
|
String request = "{\"panel_id\":\"";
|
||
|
request.concat(panel_id);
|
||
|
request.concat("\", \"value\": \"");
|
||
|
request.concat(value);
|
||
|
request.concat("\"}");
|
||
|
Serial.println(request);
|
||
|
http.POST(request);
|
||
|
http.end();
|
||
|
}
|