Tactility.py 3.0.0 and SDK updates for 0.7.0-dev (#19)
- Remove `Libraries/Str` - Replaced usage of `TactilityC` FreeRtos features with `TactilityFreeRtos` library - Update `tactility.py` - Removed redundant code from `TactilityCpp`
This commit is contained in:
committed by
GitHub
parent
3bc1e7a373
commit
b6c27b64d4
@@ -1,15 +1,11 @@
|
||||
file(GLOB_RECURSE SOURCE_FILES
|
||||
Source/*.c*
|
||||
# Library source files must be included directly,
|
||||
# because all regular dependencies get stripped by elf_loader's cmake script
|
||||
../../../Libraries/Str/Source/*.c**
|
||||
)
|
||||
|
||||
idf_component_register(
|
||||
SRCS ${SOURCE_FILES}
|
||||
# Library headers must be included directly,
|
||||
# because all regular dependencies get stripped by elf_loader's cmake script
|
||||
INCLUDE_DIRS ../../../Libraries/Str/Include
|
||||
INCLUDE_DIRS ../../../Libraries/TactilityCpp/Include
|
||||
REQUIRES TactilitySDK
|
||||
)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <ctype.h>
|
||||
#include <tt_lvgl_toolbar.h>
|
||||
#include <stack>
|
||||
#include <cstring>
|
||||
|
||||
constexpr auto* TAG = "Calculator";
|
||||
|
||||
@@ -45,10 +46,10 @@ void Calculator::handleInput(const char* txt) {
|
||||
}
|
||||
}
|
||||
|
||||
std::deque<Str> Calculator::infixToRPN(const Str& infix) {
|
||||
std::deque<std::string> Calculator::infixToRPN(const std::string& infix) {
|
||||
std::stack<char> opStack;
|
||||
std::deque<Str> output;
|
||||
Str token;
|
||||
std::deque<std::string> output;
|
||||
std::string token;
|
||||
size_t i = 0;
|
||||
|
||||
while (i < infix.length()) {
|
||||
@@ -56,20 +57,20 @@ std::deque<Str> Calculator::infixToRPN(const Str& infix) {
|
||||
|
||||
if (isdigit(ch)) {
|
||||
token.clear();
|
||||
while (i < infix.length() && (isdigit(infix[i]) || infix[i] == '.')) { token.append(infix[i++]); }
|
||||
while (i < infix.length() && (isdigit(infix[i]) || infix[i] == '.')) { token += infix[i++]; }
|
||||
output.push_back(token);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ch == '(') { opStack.push(ch); } else if (ch == ')') {
|
||||
while (!opStack.empty() && opStack.top() != '(') {
|
||||
output.push_back(Str(1, opStack.top()));
|
||||
output.push_back(std::string(1, opStack.top()));
|
||||
opStack.pop();
|
||||
}
|
||||
opStack.pop();
|
||||
} else if (strchr("+-*/", ch)) {
|
||||
while (!opStack.empty() && precedence(opStack.top()) >= precedence(ch)) {
|
||||
output.push_back(Str(1, opStack.top()));
|
||||
output.push_back(std::string(1, opStack.top()));
|
||||
opStack.pop();
|
||||
}
|
||||
opStack.push(ch);
|
||||
@@ -79,18 +80,18 @@ std::deque<Str> Calculator::infixToRPN(const Str& infix) {
|
||||
}
|
||||
|
||||
while (!opStack.empty()) {
|
||||
output.push_back(Str(1, opStack.top()));
|
||||
output.push_back(std::string(1, opStack.top()));
|
||||
opStack.pop();
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
double Calculator::evaluateRPN(std::deque<Str> rpnQueue) {
|
||||
double Calculator::evaluateRPN(std::deque<std::string> rpnQueue) {
|
||||
std::stack<double> values;
|
||||
|
||||
while (!rpnQueue.empty()) {
|
||||
Str token = rpnQueue.front();
|
||||
std::string token = rpnQueue.front();
|
||||
rpnQueue.pop_front();
|
||||
|
||||
if (isdigit(token[0])) {
|
||||
@@ -132,7 +133,7 @@ void Calculator::evaluateExpression() {
|
||||
}
|
||||
|
||||
double Calculator::computeFormula() {
|
||||
return evaluateRPN(infixToRPN(Str(formulaBuffer)));
|
||||
return evaluateRPN(infixToRPN(std::string(formulaBuffer)));
|
||||
}
|
||||
|
||||
void Calculator::resetCalculator() {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <lvgl.h>
|
||||
#include <deque>
|
||||
#include <Str.h>
|
||||
#include <string>
|
||||
#include <TactilityCpp/App.h>
|
||||
|
||||
class Calculator final : public App {
|
||||
@@ -18,8 +18,8 @@ class Calculator final : public App {
|
||||
void handleInput(const char* txt);
|
||||
void evaluateExpression();
|
||||
double computeFormula();
|
||||
static std::deque<Str> infixToRPN(const Str& infix);
|
||||
static double evaluateRPN(std::deque<Str> rpnQueue);
|
||||
static std::deque<std::string> infixToRPN(const std::string& infix);
|
||||
static double evaluateRPN(std::deque<std::string> rpnQueue);
|
||||
void resetCalculator();
|
||||
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user