오토로깅 수식 강화
This commit is contained in:
@@ -267,6 +267,9 @@ TriggerCondition stopTriggers[MAX_TRIGGERS];
|
||||
int startTriggerCount = 0;
|
||||
int stopTriggerCount = 0;
|
||||
|
||||
String startFormula = ""; // Start 조건 수식
|
||||
String stopFormula = ""; // Stop 조건 수식
|
||||
|
||||
bool autoTriggerEnabled = false;
|
||||
char startLogicOp[4] = "OR";
|
||||
char stopLogicOp[4] = "OR";
|
||||
@@ -348,8 +351,8 @@ void resetMCP2515() {
|
||||
mcp2515.setBitrate(currentCanSpeed, MCP_8MHZ);
|
||||
delay(10);
|
||||
mcp2515.setListenOnlyMode();
|
||||
currentMcpMode = MCP_MODE_LISTEN_ONLY;
|
||||
/*
|
||||
//currentMcpMode = MCP_MODE_LISTEN_ONLY;
|
||||
|
||||
|
||||
|
||||
// 5. 모드 설정 (Normal/Loopback/Listen Only)
|
||||
@@ -360,7 +363,7 @@ void resetMCP2515() {
|
||||
} else {
|
||||
mcp2515.setListenOnlyMode();
|
||||
}
|
||||
*/
|
||||
|
||||
// 6. 버퍼 클리어
|
||||
struct can_frame dummyFrame;
|
||||
while (mcp2515.readMessage(&dummyFrame) == MCP2515::ERROR_OK) {
|
||||
@@ -867,6 +870,10 @@ void saveAutoTriggerSettings() {
|
||||
preferences.putBool(key, stopTriggers[i].enabled);
|
||||
}
|
||||
|
||||
// Formula 저장
|
||||
preferences.putString("start_formula", startFormula);
|
||||
preferences.putString("stop_formula", stopFormula);
|
||||
|
||||
preferences.end();
|
||||
Serial.println("💾 Auto Trigger 설정 저장 완료");
|
||||
}
|
||||
@@ -880,6 +887,10 @@ void loadAutoTriggerSettings() {
|
||||
preferences.getString("start_logic", startLogicOp, sizeof(startLogicOp));
|
||||
preferences.getString("stop_logic", stopLogicOp, sizeof(stopLogicOp));
|
||||
|
||||
// Formula 불러오기
|
||||
startFormula = preferences.getString("start_formula", "");
|
||||
stopFormula = preferences.getString("stop_formula", "");
|
||||
|
||||
if (strlen(startLogicOp) == 0) strcpy(startLogicOp, "OR");
|
||||
if (strlen(stopLogicOp) == 0) strcpy(stopLogicOp, "OR");
|
||||
|
||||
@@ -2287,6 +2298,22 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, size_t length)
|
||||
serializeJson(response, json);
|
||||
webSocket.sendTXT(num, json);
|
||||
}
|
||||
else if (strcmp(cmd, "setStartFormula") == 0) {
|
||||
const char* formula = doc["formula"];
|
||||
if (formula) {
|
||||
startFormula = String(formula);
|
||||
saveAutoTriggerSettings();
|
||||
Serial.println("📐 Start Formula 저장: " + startFormula);
|
||||
}
|
||||
}
|
||||
else if (strcmp(cmd, "setStopFormula") == 0) {
|
||||
const char* formula = doc["formula"];
|
||||
if (formula) {
|
||||
stopFormula = String(formula);
|
||||
saveAutoTriggerSettings();
|
||||
Serial.println("📐 Stop Formula 저장: " + stopFormula);
|
||||
}
|
||||
}
|
||||
else if (strcmp(cmd, "getAutoTriggers") == 0) {
|
||||
DynamicJsonDocument response(2048);
|
||||
response["type"] = "autoTriggers";
|
||||
@@ -2294,6 +2321,8 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, size_t length)
|
||||
response["logFormat"] = autoTriggerLogCSV ? "csv" : "bin"; // 🆕 로그 형식 전송
|
||||
response["startLogic"] = startLogicOp;
|
||||
response["stopLogic"] = stopLogicOp;
|
||||
response["startFormula"] = startFormula; // Formula 전송
|
||||
response["stopFormula"] = stopFormula; // Formula 전송
|
||||
|
||||
JsonArray startArray = response.createNestedArray("startTriggers");
|
||||
for (int i = 0; i < startTriggerCount; i++) {
|
||||
@@ -2899,7 +2928,8 @@ void setup() {
|
||||
mcp2515.setBitrate(currentCanSpeed, MCP_8MHZ);
|
||||
delay(10);
|
||||
mcp2515.setListenOnlyMode();
|
||||
currentMcpMode = MCP_MODE_LISTEN_ONLY;
|
||||
//currentMcpMode = MCP_MODE_LISTEN_ONLY;
|
||||
currentMcpMode =(MCP2515Mode)preferences.getInt("mcp_mode", 1);
|
||||
|
||||
delay(50);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user