mirror of
https://gitlab.com/zwirbel/illucat.git
synced 2025-12-16 10:04:30 +01:00
optimize printing, add release profile
This commit is contained in:
@@ -90,9 +90,10 @@ class IlluCat : public MeshSprocket {
|
||||
// plugin?
|
||||
dnsServer->setErrorReplyCode(DNSReplyCode::NoError);
|
||||
dnsServer->start(DNS_PORT, "*", WiFi.softAPIP());
|
||||
Serial.println("SoftAP IP: " + WiFi.softAPIP().toString());
|
||||
String softApPrt = "SoftAP IP: " + WiFi.softAPIP().toString();
|
||||
PRINT_MSG(Serial, SPROCKET_TYPE, softApPrt.c_str());
|
||||
|
||||
// TODO plugin
|
||||
// TODO move to plugin
|
||||
// setup web stuff
|
||||
server->serveStatic("/pixelConfig.json", SPIFFS, "pixelConfig.json");
|
||||
server->on("/pixel/api", HTTP_POST, bind(&IlluCat::patternWebRequestHandler, this, _1));
|
||||
@@ -111,30 +112,33 @@ class IlluCat : public MeshSprocket {
|
||||
}
|
||||
|
||||
void patternWebRequestHandler(AsyncWebServerRequest *request) {
|
||||
Serial.println("POST /pixel/state");
|
||||
PRINT_MSG(Serial, SPROCKET_TYPE, "POST /pixel/api");
|
||||
currentMessage.topic = getRequestParameterOrDefault(request, "topic", "");
|
||||
currentMessage.payload = getRequestParameterOrDefault(request, "payload", "");
|
||||
currentMessage.broadcast = atoi(getRequestParameterOrDefault(request, "broadcast", "0").c_str());
|
||||
String msg = currentMessage.toJsonString();
|
||||
net->mesh.sendBroadcast(msg);
|
||||
publish(currentMessage.topic, currentMessage.payload);
|
||||
if(currentMessage.broadcast){
|
||||
net->mesh.sendBroadcast(msg);
|
||||
}
|
||||
request->send(200, "text/plain", msg);
|
||||
}
|
||||
|
||||
virtual void onWsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t *data, size_t len) {
|
||||
if(type == WS_EVT_DATA){
|
||||
String frame = WsUtils::parseFrameAsString(type, arg, data, len, 0);
|
||||
net->mesh.sendBroadcast(frame);
|
||||
dispatch(0, frame);
|
||||
//client->text(String(millis()));
|
||||
}
|
||||
}
|
||||
|
||||
virtual void dispatch( uint32_t from, String &msg ) {
|
||||
//Serial.println(msg);
|
||||
currentMessage.fromJsonString(msg);
|
||||
if(currentMessage.valid){
|
||||
currentMessage.from = from;
|
||||
publish(currentMessage.topic, currentMessage.payload);
|
||||
if(currentMessage.broadcast){
|
||||
net->mesh.sendBroadcast(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,9 +38,9 @@ class PixelPlugin : public Plugin {
|
||||
animation.set(TASK_MILLISECOND * pixelConfig.updateInterval, TASK_FOREVER, bind(&PixelPlugin::animate, this));
|
||||
userScheduler->addTask(animation);
|
||||
animation.enable();
|
||||
Serial.println("NeoPixels activated");
|
||||
PRINT_MSG(Serial, SPROCKET_TYPE, "NeoPixels activated");
|
||||
}
|
||||
void setState(String msg){
|
||||
void setState(String msg) {
|
||||
state.fromJsonString(msg);
|
||||
pixels->setBrightness(state.brightness);
|
||||
pixels->ColorSet(state.color);
|
||||
|
||||
Reference in New Issue
Block a user