From b365cfe51dbfc0a65ffb30b159ffb9e9d96a3cc2 Mon Sep 17 00:00:00 2001 From: "Pawel Spychalski (DzikuVx)" Date: Fri, 29 Mar 2019 14:53:12 +0100 Subject: [PATCH] Additional logical operators --- src/main/common/logic_condition.c | 20 ++++++++++++++++++++ src/main/common/logic_condition.h | 5 +++++ 2 files changed, 25 insertions(+) diff --git a/src/main/common/logic_condition.c b/src/main/common/logic_condition.c index 202aa8359e..be1421ace2 100644 --- a/src/main/common/logic_condition.c +++ b/src/main/common/logic_condition.c @@ -108,6 +108,26 @@ int logicConditionCompute( return operandA > 1666; break; + case LOGIC_CONDITION_AND: + return (operandA && operandB); + break; + + case LOGIC_CONDITION_OR: + return (operandA || operandB); + break; + + case LOGIC_CONDITION_XOR: + return (operandA != operandB); + break; + + case LOGIC_CONDITION_NAND: + return !(operandA && operandB); + break; + + case LOGIC_CONDITION_NOR: + return !(operandA || operandB); + break; + default: return false; break; diff --git a/src/main/common/logic_condition.h b/src/main/common/logic_condition.h index c4b6ea222a..e2ddbc6049 100644 --- a/src/main/common/logic_condition.h +++ b/src/main/common/logic_condition.h @@ -36,6 +36,11 @@ typedef enum { LOGIC_CONDITION_LOW, // 4 LOGIC_CONDITION_MID, // 5 LOGIC_CONDITION_HIGH, // 6 + LOGIC_CONDITION_AND, // 7 + LOGIC_CONDITION_OR, // 8 + LOGIC_CONDITION_XOR, // 9 + LOGIC_CONDITION_NAND, // 10 + LOGIC_CONDITION_NOR, // 11 LOGIC_CONDITION_LAST } logicOperation_e;