diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..a1e37cb
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "Middlewares/eez-framework"]
+ path = Middlewares/eez-framework
+ url = https://github.com/eez-open/eez-framework.git
diff --git a/Middlewares/eez-framework b/Middlewares/eez-framework
new file mode 160000
index 0000000..d317ba7
--- /dev/null
+++ b/Middlewares/eez-framework
@@ -0,0 +1 @@
+Subproject commit d317ba7f91a27ac03b20dedb4d2584c61d2f11ae
diff --git a/Middlewares/eez/README.md b/Middlewares/eez/README.md
deleted file mode 100644
index e69de29..0000000
diff --git a/Middlewares/eez/core/alloc.cpp b/Middlewares/eez/core/alloc.cpp
deleted file mode 100644
index 0bd3301..0000000
--- a/Middlewares/eez/core/alloc.cpp
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-
-namespace eez {
-
-static const size_t ALIGNMENT = 8;
-static const size_t MIN_BLOCK_SIZE = 8;
-
-struct AllocBlock {
- AllocBlock *next;
- int free;
- size_t size;
- uint32_t id;
-};
-
-static uint8_t *g_heap;
-
-#if defined(EEZ_PLATFORM_STM32)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wparentheses"
-#endif
-
-EEZ_MUTEX_DECLARE(alloc);
-
-#if defined(EEZ_PLATFORM_STM32)
-#pragma GCC diagnostic pop
-#endif
-
-void initAllocHeap(uint8_t *heap, size_t heapSize) {
- g_heap = heap;
-
- AllocBlock *first = (AllocBlock *)g_heap;
- first->next = 0;
- first->free = 1;
- first->size = heapSize - sizeof(AllocBlock);
-
- EEZ_MUTEX_CREATE(alloc);
-}
-
-void *alloc(size_t size, uint32_t id) {
- if (size == 0) {
- return nullptr;
- }
-
- if (EEZ_MUTEX_WAIT(alloc, 0)) {
- AllocBlock *firstBlock = (AllocBlock *)g_heap;
-
- AllocBlock *block = firstBlock;
- size = ((size + ALIGNMENT - 1) / ALIGNMENT) * ALIGNMENT;
-
- // find free block with enough size
- // TODO merge multiple free consecutive blocks into one that has enough size
- while (block) {
- if (block->free && block->size >= size) {
- break;
- }
- block = block->next;
- }
-
- if (!block) {
- EEZ_MUTEX_RELEASE(alloc);
- return nullptr;
- }
-
- int remainingSize = block->size - size - sizeof(AllocBlock);
- if (remainingSize >= (int)MIN_BLOCK_SIZE) {
- // remainingSize is enough to create a new block
- auto newBlock = (AllocBlock *)((uint8_t *)block + sizeof(AllocBlock) + size);
- newBlock->next = block->next;
- newBlock->free = 1;
- newBlock->size = remainingSize;
-
- block->next = newBlock;
- block->size = size;
- }
-
- block->free = 0;
- block->id = id;
-
- EEZ_MUTEX_RELEASE(alloc);
-
- return block + 1;
- }
-
- return nullptr;
-}
-
-void free(void *ptr) {
- if (ptr == 0) {
- return;
- }
-
- if (EEZ_MUTEX_WAIT(alloc, 0)) {
- AllocBlock *firstBlock = (AllocBlock *)g_heap;
-
- AllocBlock *prevBlock = nullptr;
- AllocBlock *block = firstBlock;
-
- while (block && block + 1 < ptr) {
- prevBlock = block;
- block = block->next;
- }
-
- if (!block || block + 1 != ptr || block->free) {
- assert(false);
- EEZ_MUTEX_RELEASE(alloc);
- return;
- }
-
- // reset memory to catch errors when memory is used after free is called
- memset(ptr, 0xCC, block->size);
-
- auto nextBlock = block->next;
- if (nextBlock && nextBlock->free) {
- if (prevBlock && prevBlock->free) {
- // both next and prev blocks are free, merge 3 blocks into one
- prevBlock->next = nextBlock->next;
- prevBlock->size += sizeof(AllocBlock) + block->size + sizeof(AllocBlock) + nextBlock->size;
- } else {
- // next block is free, merge 2 blocks into one
- block->next = nextBlock->next;
- block->size += sizeof(AllocBlock) + nextBlock->size;
- block->free = 1;
- }
- } else if (prevBlock && prevBlock->free) {
- // prev block is free, merge 2 blocks into one
- prevBlock->next = nextBlock;
- prevBlock->size += sizeof(AllocBlock) + block->size;
- } else {
- // just free
- block->free = 1;
- }
-
- EEZ_MUTEX_RELEASE(alloc);
- }
-}
-
-template void freeObject(T *ptr) {
- ptr->~T();
- free(ptr);
-}
-
-#if OPTION_SCPI
-void dumpAlloc(scpi_t *context) {
- AllocBlock *first = (AllocBlock *)g_heap;
- AllocBlock *block = first;
- while (block) {
- char buffer[100];
- if (block->free) {
- snprintf(buffer, sizeof(buffer), "FREE: %d", (int)block->size);
- } else {
- snprintf(buffer, sizeof(buffer), "ALOC (0x%08x): %d", (unsigned int)block->id, (int)block->size);
- }
- SCPI_ResultText(context, buffer);
- block = block->next;
- }
-}
-#endif
-
-void getAllocInfo(uint32_t &free, uint32_t &alloc) {
- free = 0;
- alloc = 0;
- if (EEZ_MUTEX_WAIT(alloc, 0)) {
- AllocBlock *first = (AllocBlock *)g_heap;
- AllocBlock *block = first;
- while (block) {
- if (block->free) {
- free += block->size;
- } else {
- alloc += block->size;
- }
- block = block->next;
- }
- EEZ_MUTEX_RELEASE(alloc);
- }
-}
-
-} // eez
diff --git a/Middlewares/eez/core/alloc.h b/Middlewares/eez/core/alloc.h
deleted file mode 100644
index bd36383..0000000
--- a/Middlewares/eez/core/alloc.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
-* EEZ Generic Firmware
-* Copyright (C) 2021-present, Envox d.o.o.
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#pragma once
-
-#include
-#include
-#include
-
-#if OPTION_SCPI
-#include
-#endif
-
-namespace eez {
-
-void initAllocHeap(uint8_t *heap, size_t heapSize);
-
-void *alloc(size_t size, uint32_t id);
-void free(void *ptr);
-
-template struct ObjectAllocator {
- static T *allocate(uint32_t id) {
- auto ptr = alloc(sizeof(T), id);
- return new (ptr) T;
- }
- static void deallocate(T* ptr) {
- ptr->~T();
- free(ptr);
- }
-};
-
-#if OPTION_SCPI
-void dumpAlloc(scpi_t *context);
-#endif
-
-void getAllocInfo(uint32_t &free, uint32_t &alloc);
-
-} // eez
\ No newline at end of file
diff --git a/Middlewares/eez/core/debug.cpp b/Middlewares/eez/core/debug.cpp
deleted file mode 100644
index 47cd0ee..0000000
--- a/Middlewares/eez/core/debug.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
-* EEZ Generic Firmware
-* Copyright (C) 2018-present, Envox d.o.o.
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#ifdef DEBUG
-
-#include
-#include
-#include
-
-#include
-
-namespace eez {
-namespace debug {
-
-void Trace(TraceType traceType, const char *format, ...) {
- va_list args;
- va_start(args, format);
-
- static const size_t BUFFER_SIZE = 256;
- char buffer[BUFFER_SIZE + 1];
-
- vsnprintf(buffer, BUFFER_SIZE, format, args);
- buffer[BUFFER_SIZE] = 0;
-
- va_end(args);
-
- if (traceType == TRACE_TYPE_DEBUG) {
- pushDebugTraceHook(buffer, strlen(buffer));
- } else if (traceType == TRACE_TYPE_INFO) {
- pushInfoTraceHook(buffer, strlen(buffer));
- } else {
- pushErrorTraceHook(buffer, strlen(buffer));
- }
-}
-
-} // namespace debug
-} // namespace eez
-
-extern "C" void debug_trace(const char *str, size_t len) {
- eez::debug::pushDebugTraceHook(str, len);
-}
-
-#endif // DEBUG
diff --git a/Middlewares/eez/core/debug.h b/Middlewares/eez/core/debug.h
deleted file mode 100644
index 3a8485d..0000000
--- a/Middlewares/eez/core/debug.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
-* EEZ Generic Firmware
-* Copyright (C) 2018-present, Envox d.o.o.
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#pragma once
-
-#ifdef DEBUG
-
-#include
-#include
-
-namespace eez {
-namespace debug {
-
-void pushDebugTraceHook(const char *message, size_t messageLength);
-void pushInfoTraceHook(const char *message, size_t messageLength);
-void pushErrorTraceHook(const char *message, size_t messageLength);
-
-enum TraceType {
- TRACE_TYPE_DEBUG,
- TRACE_TYPE_INFO,
- TRACE_TYPE_ERROR
-};
-
-void Trace(TraceType traceType, const char *format, ...);
-
-} // namespace debug
-} // namespace eez
-
-#define InfoTrace(...) ::eez::debug::Trace(::eez::debug::TRACE_TYPE_INFO, __VA_ARGS__)
-#define ErrorTrace(...) ::eez::debug::Trace(::eez::debug::TRACE_TYPE_ERROR, __VA_ARGS__)
-#define DebugTrace(...) ::eez::debug::Trace(::eez::debug::TRACE_TYPE_DEBUG, __VA_ARGS__)
-
-#else // NO DEBUG
-
-#define InfoTrace(...) 0
-#define ErrorTrace(...) 0
-#define DebugTrace(...) 0
-
-#endif
diff --git a/Middlewares/eez/core/eeprom.cpp b/Middlewares/eez/core/eeprom.cpp
deleted file mode 100644
index 4212588..0000000
--- a/Middlewares/eez/core/eeprom.cpp
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2015-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-
-#include
-#include
-#include
-
-//#include
-//#include
-
-#if defined(EEZ_PLATFORM_STM32) && !CONF_SURVIVE_MODE
-#define USE_EEPROM 1
-#else
-#define USE_EEPROM 0
-#endif
-
-#if defined(EEZ_PLATFORM_STM32)
-#ifdef EEZ_PLATFORM_STM32F469I_DISCO
-#else
-#include
-#endif
-#endif
-
-#if !USE_EEPROM
-#include
-#endif
-
-#if OPTION_SCPI
-#include
-#endif
-
-namespace eez {
-namespace eeprom {
-
-#if defined(EEZ_PLATFORM_STM32)
-// opcodes
-static const uint8_t WREN = 6;
-static const uint8_t WRDI = 4;
-static const uint8_t RDSR = 5;
-static const uint8_t WRSR = 1;
-static const uint8_t READ = 3;
-static const uint8_t WRITE = 2;
-
-// EEPROM AT24C256C
-// I2C-Compatible (2-Wire) Serial EEPROM
-// 256-Kbit (32,768 x 8)
-// http://ww1.microchip.com/downloads/en/devicedoc/atmel-8568-seeprom-at24c256c-datasheet.pdf
-static const uint16_t EEPROM_ADDRESS = 0b10100000;
-#endif
-
-TestResult g_testResult = TEST_FAILED;
-
-////////////////////////////////////////////////////////////////////////////////
-
-#if defined(EEZ_PLATFORM_STM32)
-
-const int MAX_READ_CHUNK_SIZE = 16;
-const int MAX_WRITE_CHUNK_SIZE = 16;
-
-bool readFromEEPROM(uint8_t *buffer, uint16_t bufferSize, uint16_t address) {
-#ifdef EEZ_PLATFORM_STM32F469I_DISCO
- return false;
-#else
- for (uint16_t i = 0; i < bufferSize; i += MAX_READ_CHUNK_SIZE) {
- uint16_t chunkAddress = address + i;
-
- uint16_t chunkSize = MIN(MAX_READ_CHUNK_SIZE, bufferSize - i);
-
- uint8_t data[2] = {
- I2C_MEM_ADD_MSB(chunkAddress),
- I2C_MEM_ADD_LSB(chunkAddress)
- };
-
- HAL_StatusTypeDef returnValue;
-
- taskENTER_CRITICAL();
- returnValue = HAL_I2C_Master_Transmit(&hi2c1, EEPROM_ADDRESS, data, 2, HAL_MAX_DELAY);
- if (returnValue != HAL_OK) {
- taskEXIT_CRITICAL();
- return false;
- }
- returnValue = HAL_I2C_Master_Receive(&hi2c1, EEPROM_ADDRESS, buffer + i, chunkSize, HAL_MAX_DELAY);
- taskEXIT_CRITICAL();
- if (returnValue != HAL_OK) {
- return false;
- }
- }
-
- return true;
-#endif
-}
-
-bool writeToEEPROM(const uint8_t *buffer, uint16_t bufferSize, uint16_t address) {
-#ifdef EEZ_PLATFORM_STM32F469I_DISCO
- return false;
-#else
- for (uint16_t i = 0; i < bufferSize; i += MAX_WRITE_CHUNK_SIZE) {
- uint16_t chunkAddress = address + i;
-
- uint16_t chunkSize = MIN(MAX_WRITE_CHUNK_SIZE, bufferSize - i);
-
- HAL_StatusTypeDef returnValue;
-
- taskENTER_CRITICAL();
- returnValue = HAL_I2C_Mem_Write(&hi2c1, EEPROM_ADDRESS, chunkAddress, I2C_MEMADD_SIZE_16BIT, (uint8_t *)buffer + i, chunkSize, HAL_MAX_DELAY);
- taskEXIT_CRITICAL();
-
- if (returnValue != HAL_OK) {
- return false;
- }
-
- osDelay(5);
-
- // verify
- uint8_t verify[MAX_WRITE_CHUNK_SIZE];
-
- uint8_t data[2] = {
- I2C_MEM_ADD_MSB(chunkAddress),
- I2C_MEM_ADD_LSB(chunkAddress)
- };
-
- taskENTER_CRITICAL();
- returnValue = HAL_I2C_Master_Transmit(&hi2c1, EEPROM_ADDRESS, data, 2, HAL_MAX_DELAY);
- if (returnValue != HAL_OK) {
- taskEXIT_CRITICAL();
- return false;
- }
- returnValue = HAL_I2C_Master_Receive(&hi2c1, EEPROM_ADDRESS, verify, chunkSize, HAL_MAX_DELAY);
- taskEXIT_CRITICAL();
- if (returnValue != HAL_OK) {
- return false;
- }
-
- for (int j = 0; j < chunkSize; ++j) {
- if (buffer[i+j] != verify[j]) {
- return false;
- }
- }
- }
-
- return true;
-#endif
-}
-
-#endif
-
-#if !USE_EEPROM
-const char *EEPROM_FILE_PATH = "/EEPROM.state";
-#endif
-
-bool read(uint8_t *buffer, uint16_t bufferSize, uint16_t address) {
-#if USE_EEPROM
- return readFromEEPROM(buffer, bufferSize, address);
-#else
- File file;
- if (!file.open(EEPROM_FILE_PATH, FILE_READ)) {
- return false;
- }
- file.seek(address);
- size_t readBytes = file.read(buffer, bufferSize);
- if (readBytes < bufferSize) {
- memset(buffer + readBytes, 0xFF, bufferSize - readBytes);
- }
- file.close();
- return true;
-#endif
-}
-
-bool write(const uint8_t *buffer, uint16_t bufferSize, uint16_t address) {
-#if USE_EEPROM
- return writeToEEPROM(buffer, bufferSize, address);
-#else
- File file;
- if (!file.open(EEPROM_FILE_PATH, FILE_OPEN_ALWAYS | FILE_WRITE)) {
- return false;
- }
- file.seek(address);
- file.write(buffer, bufferSize);
- file.close();
- return true;
-#endif
-}
-
-void init() {
- g_testResult = TEST_OK;
-}
-
-bool test() {
- // TODO add test
- return g_testResult == TEST_OK;
-}
-
-} // namespace eeprom
-} // namespace eez
diff --git a/Middlewares/eez/core/eeprom.h b/Middlewares/eez/core/eeprom.h
deleted file mode 100644
index 403ea84..0000000
--- a/Middlewares/eez/core/eeprom.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2015-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#pragma once
-
-#include
-
-#include
-
-namespace eez {
-namespace eeprom {
-
-static const uint16_t EEPROM_SIZE = 32768;
-
-void init();
-bool test();
-
-extern TestResult g_testResult;
-
-bool read(uint8_t *buffer, uint16_t buffer_size, uint16_t address);
-bool write(const uint8_t *buffer, uint16_t buffer_size, uint16_t address);
-
-} // namespace eeprom
-} // namespace eez
diff --git a/Middlewares/eez/core/encoder.h b/Middlewares/eez/core/encoder.h
deleted file mode 100644
index 7c3429d..0000000
--- a/Middlewares/eez/core/encoder.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#pragma once
-
-namespace eez {
-namespace mcu {
-namespace encoder {
-
-#if defined(EEZ_PLATFORM_SIMULATOR)
-void write(int counter, bool clicked);
-void setButtonState(bool pressed);
-#endif
-
-} // namespace encoder
-} // namespace mcu
-} // namespace eez
diff --git a/Middlewares/eez/core/hmi.cpp b/Middlewares/eez/core/hmi.cpp
deleted file mode 100644
index acd817b..0000000
--- a/Middlewares/eez/core/hmi.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
-* EEZ PSU Firmware
-* Copyright (C) 2015-present, Envox d.o.o.
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#include
-#include
-
-namespace eez {
-namespace hmi {
-
-#define MAX_GUI_OR_ENCODER_INACTIVITY_TIME_MS 60 * 1000
-
-static uint32_t g_timeOfLastActivity;
-static bool g_inactivityTimeMaxed = true;
-
-void tick() {
- if (!g_inactivityTimeMaxed) {
- uint32_t inactivityPeriod = getInactivityPeriodMs();
- if (inactivityPeriod >= MAX_GUI_OR_ENCODER_INACTIVITY_TIME_MS) {
- g_inactivityTimeMaxed = true;
- }
- }
-}
-
-void noteActivity() {
- g_timeOfLastActivity = millis();
- g_inactivityTimeMaxed = false;
-}
-
-uint32_t getInactivityPeriodMs() {
- if (g_inactivityTimeMaxed) {
- return MAX_GUI_OR_ENCODER_INACTIVITY_TIME_MS;
- } else {
- return millis() - g_timeOfLastActivity;
- }
-}
-
-uint32_t getTimeOfLastActivity() {
- if (g_inactivityTimeMaxed) {
- return millis() - MAX_GUI_OR_ENCODER_INACTIVITY_TIME_MS;
- } else {
- return g_timeOfLastActivity;
- }
-}
-
-} // namespace hmi
-} // namespace eez
\ No newline at end of file
diff --git a/Middlewares/eez/core/hmi.h b/Middlewares/eez/core/hmi.h
deleted file mode 100644
index 1b4e78a..0000000
--- a/Middlewares/eez/core/hmi.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
-* EEZ PSU Firmware
-* Copyright (C) 2017-present, Envox d.o.o.
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#pragma once
-
-#include
-
-namespace eez {
-namespace hmi {
-
-void tick();
-
-void noteActivity();
-uint32_t getInactivityPeriodMs();
-uint32_t getTimeOfLastActivity();
-
-}
-} // namespace eez::hmi
diff --git a/Middlewares/eez/core/keyboard.h b/Middlewares/eez/core/keyboard.h
deleted file mode 100644
index 59d3c98..0000000
--- a/Middlewares/eez/core/keyboard.h
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
-* EEZ Generic Firmware
-* Copyright (C) 2020-present, Envox d.o.o.
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#pragma once
-
-#include
-
-#include
-
-#if defined(EEZ_PLATFORM_STM32)
-#if OPTION_KEYBOARD
-#include
-#endif
-#endif
-
-#if defined(EEZ_PLATFORM_SIMULATOR) && !defined(__EMSCRIPTEN__)
-#include
-#endif
-
-namespace eez {
-namespace keyboard {
-
-#if defined(EEZ_PLATFORM_STM32)
-#if OPTION_KEYBOARD
-void onKeyboardEvent(USBH_HandleTypeDef *phost);
-#endif
-#endif
-
-#if defined(EEZ_PLATFORM_SIMULATOR) && !defined(__EMSCRIPTEN__)
-void onKeyboardEvent(SDL_KeyboardEvent *key);
-#endif
-
-bool isDisplayDirty();
-void updateDisplay();
-
-void onPageChanged();
-
-static const uint8_t KEY_MOD_LCTRL = 1 << 0;
-static const uint8_t KEY_MOD_LSHIFT = 1 << 1;
-static const uint8_t KEY_MOD_LALT = 1 << 2;
-static const uint8_t KEY_MOD_LGUI = 1 << 3;
-static const uint8_t KEY_MOD_RCTRL = 1 << 4;
-static const uint8_t KEY_MOD_RSHIFT = 1 << 5;
-static const uint8_t KEY_MOD_RALT = 1 << 6;
-static const uint8_t KEY_MOD_RGUI = 1 << 7;
-
-#if defined(EEZ_PLATFORM_SIMULATOR)
-#define KEY_NONE 0x00
-#define KEY_ERRORROLLOVER 0x01
-#define KEY_POSTFAIL 0x02
-#define KEY_ERRORUNDEFINED 0x03
-#define KEY_A 0x04
-#define KEY_B 0x05
-#define KEY_C 0x06
-#define KEY_D 0x07
-#define KEY_E 0x08
-#define KEY_F 0x09
-#define KEY_G 0x0A
-#define KEY_H 0x0B
-#define KEY_I 0x0C
-#define KEY_J 0x0D
-#define KEY_K 0x0E
-#define KEY_L 0x0F
-#define KEY_M 0x10
-#define KEY_N 0x11
-#define KEY_O 0x12
-#define KEY_P 0x13
-#define KEY_Q 0x14
-#define KEY_R 0x15
-#define KEY_S 0x16
-#define KEY_T 0x17
-#define KEY_U 0x18
-#define KEY_V 0x19
-#define KEY_W 0x1A
-#define KEY_X 0x1B
-#define KEY_Y 0x1C
-#define KEY_Z 0x1D
-#define KEY_1_EXCLAMATION_MARK 0x1E
-#define KEY_2_AT 0x1F
-#define KEY_3_NUMBER_SIGN 0x20
-#define KEY_4_DOLLAR 0x21
-#define KEY_5_PERCENT 0x22
-#define KEY_6_CARET 0x23
-#define KEY_7_AMPERSAND 0x24
-#define KEY_8_ASTERISK 0x25
-#define KEY_9_OPARENTHESIS 0x26
-#define KEY_0_CPARENTHESIS 0x27
-#define KEY_ENTER 0x28
-#define KEY_ESCAPE 0x29
-#define KEY_BACKSPACE 0x2A
-#define KEY_TAB 0x2B
-#define KEY_SPACEBAR 0x2C
-#define KEY_MINUS_UNDERSCORE 0x2D
-#define KEY_EQUAL_PLUS 0x2E
-#define KEY_OBRACKET_AND_OBRACE 0x2F
-#define KEY_CBRACKET_AND_CBRACE 0x30
-#define KEY_BACKSLASH_VERTICAL_BAR 0x31
-#define KEY_NONUS_NUMBER_SIGN_TILDE 0x32
-#define KEY_SEMICOLON_COLON 0x33
-#define KEY_SINGLE_AND_DOUBLE_QUOTE 0x34
-#define KEY_GRAVE ACCENT AND TILDE 0x35
-#define KEY_COMMA_AND_LESS 0x36
-#define KEY_DOT_GREATER 0x37
-#define KEY_SLASH_QUESTION 0x38
-#define KEY_CAPS LOCK 0x39
-#define KEY_F1 0x3A
-#define KEY_F2 0x3B
-#define KEY_F3 0x3C
-#define KEY_F4 0x3D
-#define KEY_F5 0x3E
-#define KEY_F6 0x3F
-#define KEY_F7 0x40
-#define KEY_F8 0x41
-#define KEY_F9 0x42
-#define KEY_F10 0x43
-#define KEY_F11 0x44
-#define KEY_F12 0x45
-#define KEY_PRINTSCREEN 0x46
-#define KEY_SCROLL LOCK 0x47
-#define KEY_PAUSE 0x48
-#define KEY_INSERT 0x49
-#define KEY_HOME 0x4A
-#define KEY_PAGEUP 0x4B
-#define KEY_DELETE 0x4C
-#define KEY_END1 0x4D
-#define KEY_PAGEDOWN 0x4E
-#define KEY_RIGHTARROW 0x4F
-#define KEY_LEFTARROW 0x50
-#define KEY_DOWNARROW 0x51
-#define KEY_UPARROW 0x52
-#define KEY_KEYPAD_NUM_LOCK_AND_CLEAR 0x53
-#define KEY_KEYPAD_SLASH 0x54
-#define KEY_KEYPAD_ASTERIKS 0x55
-#define KEY_KEYPAD_MINUS 0x56
-#define KEY_KEYPAD_PLUS 0x57
-#define KEY_KEYPAD_ENTER 0x58
-#define KEY_KEYPAD_1_END 0x59
-#define KEY_KEYPAD_2_DOWN_ARROW 0x5A
-#define KEY_KEYPAD_3_PAGEDN 0x5B
-#define KEY_KEYPAD_4_LEFT_ARROW 0x5C
-#define KEY_KEYPAD_5 0x5D
-#define KEY_KEYPAD_6_RIGHT_ARROW 0x5E
-#define KEY_KEYPAD_7_HOME 0x5F
-#define KEY_KEYPAD_8_UP_ARROW 0x60
-#define KEY_KEYPAD_9_PAGEUP 0x61
-#define KEY_KEYPAD_0_INSERT 0x62
-#define KEY_KEYPAD_DECIMAL_SEPARATOR_DELETE 0x63
-#define KEY_NONUS_BACK_SLASH_VERTICAL_BAR 0x64
-#define KEY_APPLICATION 0x65
-#define KEY_POWER 0x66
-#define KEY_KEYPAD_EQUAL 0x67
-#define KEY_F13 0x68
-#define KEY_F14 0x69
-#define KEY_F15 0x6A
-#define KEY_F16 0x6B
-#define KEY_F17 0x6C
-#define KEY_F18 0x6D
-#define KEY_F19 0x6E
-#define KEY_F20 0x6F
-#define KEY_F21 0x70
-#define KEY_F22 0x71
-#define KEY_F23 0x72
-#define KEY_F24 0x73
-// #define KEY_EXECUTE 0x74
-#define KEY_HELP 0x75
-#define KEY_MENU 0x76
-#define KEY_SELECT 0x77
-#define KEY_STOP 0x78
-#define KEY_AGAIN 0x79
-#define KEY_UNDO 0x7A
-#define KEY_CUT 0x7B
-#define KEY_COPY 0x7C
-#define KEY_PASTE 0x7D
-#define KEY_FIND 0x7E
-#define KEY_MUTE 0x7F
-#define KEY_VOLUME_UP 0x80
-#define KEY_VOLUME_DOWN 0x81
-#define KEY_LOCKING_CAPS_LOCK 0x82
-#define KEY_LOCKING_NUM_LOCK 0x83
-#define KEY_LOCKING_SCROLL_LOCK 0x84
-#define KEY_KEYPAD_COMMA 0x85
-#define KEY_KEYPAD_EQUAL_SIGN 0x86
-#define KEY_INTERNATIONAL1 0x87
-#define KEY_INTERNATIONAL2 0x88
-#define KEY_INTERNATIONAL3 0x89
-#define KEY_INTERNATIONAL4 0x8A
-#define KEY_INTERNATIONAL5 0x8B
-#define KEY_INTERNATIONAL6 0x8C
-#define KEY_INTERNATIONAL7 0x8D
-#define KEY_INTERNATIONAL8 0x8E
-#define KEY_INTERNATIONAL9 0x8F
-#define KEY_LANG1 0x90
-#define KEY_LANG2 0x91
-#define KEY_LANG3 0x92
-#define KEY_LANG4 0x93
-#define KEY_LANG5 0x94
-#define KEY_LANG6 0x95
-#define KEY_LANG7 0x96
-#define KEY_LANG8 0x97
-#define KEY_LANG9 0x98
-#define KEY_ALTERNATE_ERASE 0x99
-#define KEY_SYSREQ 0x9A
-#define KEY_CANCEL 0x9B
-#define KEY_CLEAR 0x9C
-#define KEY_PRIOR 0x9D
-#define KEY_RETURN 0x9E
-#define KEY_SEPARATOR 0x9F
-#define KEY_OUT 0xA0
-#define KEY_OPER 0xA1
-#define KEY_CLEAR_AGAIN 0xA2
-#define KEY_CRSEL 0xA3
-#define KEY_EXSEL 0xA4
-#define KEY_KEYPAD_00 0xB0
-#define KEY_KEYPAD_000 0xB1
-#define KEY_THOUSANDS_SEPARATOR 0xB2
-#define KEY_DECIMAL_SEPARATOR 0xB3
-#define KEY_CURRENCY_UNIT 0xB4
-#define KEY_CURRENCY_SUB_UNIT 0xB5
-#define KEY_KEYPAD_OPARENTHESIS 0xB6
-#define KEY_KEYPAD_CPARENTHESIS 0xB7
-#define KEY_KEYPAD_OBRACE 0xB8
-#define KEY_KEYPAD_CBRACE 0xB9
-#define KEY_KEYPAD_TAB 0xBA
-#define KEY_KEYPAD_BACKSPACE 0xBB
-#define KEY_KEYPAD_A 0xBC
-#define KEY_KEYPAD_B 0xBD
-#define KEY_KEYPAD_C 0xBE
-#define KEY_KEYPAD_D 0xBF
-#define KEY_KEYPAD_E 0xC0
-#define KEY_KEYPAD_F 0xC1
-#define KEY_KEYPAD_XOR 0xC2
-#define KEY_KEYPAD_CARET 0xC3
-#define KEY_KEYPAD_PERCENT 0xC4
-#define KEY_KEYPAD_LESS 0xC5
-#define KEY_KEYPAD_GREATER 0xC6
-#define KEY_KEYPAD_AMPERSAND 0xC7
-#define KEY_KEYPAD_LOGICAL_AND 0xC8
-#define KEY_KEYPAD_VERTICAL_BAR 0xC9
-#define KEY_KEYPAD_LOGIACL_OR 0xCA
-#define KEY_KEYPAD_COLON 0xCB
-#define KEY_KEYPAD_NUMBER_SIGN 0xCC
-#define KEY_KEYPAD_SPACE 0xCD
-#define KEY_KEYPAD_AT 0xCE
-#define KEY_KEYPAD_EXCLAMATION_MARK 0xCF
-#define KEY_KEYPAD_MEMORY_STORE 0xD0
-#define KEY_KEYPAD_MEMORY_RECALL 0xD1
-#define KEY_KEYPAD_MEMORY_CLEAR 0xD2
-#define KEY_KEYPAD_MEMORY_ADD 0xD3
-#define KEY_KEYPAD_MEMORY_SUBTRACT 0xD4
-#define KEY_KEYPAD_MEMORY_MULTIPLY 0xD5
-#define KEY_KEYPAD_MEMORY_DIVIDE 0xD6
-#define KEY_KEYPAD_PLUSMINUS 0xD7
-#define KEY_KEYPAD_CLEAR 0xD8
-#define KEY_KEYPAD_CLEAR_ENTRY 0xD9
-#define KEY_KEYPAD_BINARY 0xDA
-#define KEY_KEYPAD_OCTAL 0xDB
-#define KEY_KEYPAD_DECIMAL 0xDC
-#define KEY_KEYPAD_HEXADECIMAL 0xDD
-#define KEY_LEFTCONTROL 0xE0
-#define KEY_LEFTSHIFT 0xE1
-#define KEY_LEFTALT 0xE2
-#define KEY_LEFT_GUI 0xE3
-#define KEY_RIGHTCONTROL 0xE4
-#define KEY_RIGHTSHIFT 0xE5
-#define KEY_RIGHTALT 0xE6
-#define KEY_RIGHT_GUI 0xE7
-#endif // EEZ_PLATFORM_STM32
-
-} // keyboard
-} // eez
diff --git a/Middlewares/eez/core/memory.cpp b/Middlewares/eez/core/memory.cpp
deleted file mode 100644
index 4175834..0000000
--- a/Middlewares/eez/core/memory.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2015-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-
-#include
-
-namespace eez {
-
-#if defined(EEZ_PLATFORM_SIMULATOR)
-uint8_t g_memory[MEMORY_SIZE] = { 0 };
-#endif
-
-uint8_t *DECOMPRESSED_ASSETS_START_ADDRESS;
-uint8_t *FLOW_TO_DEBUGGER_MESSAGE_BUFFER;
-
-uint8_t *VRAM_BUFFER1_START_ADDRESS;
-uint8_t *VRAM_BUFFER2_START_ADDRESS;
-
-uint8_t *VRAM_ANIMATION_BUFFER1_START_ADDRESS;
-uint8_t *VRAM_ANIMATION_BUFFER2_START_ADDRESS;
-
-uint8_t *VRAM_AUX_BUFFER1_START_ADDRESS;
-uint8_t *VRAM_AUX_BUFFER2_START_ADDRESS;
-uint8_t *VRAM_AUX_BUFFER3_START_ADDRESS;
-uint8_t *VRAM_AUX_BUFFER4_START_ADDRESS;
-uint8_t *VRAM_AUX_BUFFER5_START_ADDRESS;
-uint8_t *VRAM_AUX_BUFFER6_START_ADDRESS;
-
-uint8_t *SCREENSHOOT_BUFFER_START_ADDRESS;
-
-uint8_t *GUI_STATE_BUFFER;
-
-uint8_t *ALLOC_BUFFER;
-uint32_t ALLOC_BUFFER_SIZE;
-
-void initMemory() {
- initAssetsMemory();
- initOtherMemory();
-}
-
-void initAssetsMemory() {
- ALLOC_BUFFER = MEMORY_BEGIN;
- ALLOC_BUFFER_SIZE = MEMORY_SIZE;
-
- DECOMPRESSED_ASSETS_START_ADDRESS = allocBuffer(MAX_DECOMPRESSED_ASSETS_SIZE);
-}
-
-void initOtherMemory() {
- FLOW_TO_DEBUGGER_MESSAGE_BUFFER = allocBuffer(FLOW_TO_DEBUGGER_MESSAGE_BUFFER_SIZE);
-
- uint32_t VRAM_BUFFER_SIZE = DISPLAY_WIDTH * DISPLAY_HEIGHT * DISPLAY_BPP / 8;
-
- VRAM_BUFFER1_START_ADDRESS = allocBuffer(VRAM_BUFFER_SIZE);
- VRAM_BUFFER2_START_ADDRESS = allocBuffer(VRAM_BUFFER_SIZE);
-
- VRAM_ANIMATION_BUFFER1_START_ADDRESS = allocBuffer(VRAM_BUFFER_SIZE);
- VRAM_ANIMATION_BUFFER2_START_ADDRESS = allocBuffer(VRAM_BUFFER_SIZE);
-
- VRAM_AUX_BUFFER1_START_ADDRESS = allocBuffer(VRAM_BUFFER_SIZE);
- VRAM_AUX_BUFFER2_START_ADDRESS = allocBuffer(VRAM_BUFFER_SIZE);
- VRAM_AUX_BUFFER3_START_ADDRESS = allocBuffer(VRAM_BUFFER_SIZE);
- VRAM_AUX_BUFFER4_START_ADDRESS = allocBuffer(VRAM_BUFFER_SIZE);
- VRAM_AUX_BUFFER5_START_ADDRESS = allocBuffer(VRAM_BUFFER_SIZE);
- VRAM_AUX_BUFFER6_START_ADDRESS = allocBuffer(VRAM_BUFFER_SIZE);
-
- GUI_STATE_BUFFER = allocBuffer(GUI_STATE_BUFFER_SIZE);
-
- SCREENSHOOT_BUFFER_START_ADDRESS = VRAM_ANIMATION_BUFFER1_START_ADDRESS;
-}
-
-uint8_t *allocBuffer(uint32_t size) {
- size = ((size + 1023) / 1024) * 1024;
-
- auto buffer = ALLOC_BUFFER;
-
- assert(ALLOC_BUFFER_SIZE > size);
- ALLOC_BUFFER += size;
- ALLOC_BUFFER_SIZE -= size;
-
- return buffer;
-}
-
-} // eez
diff --git a/Middlewares/eez/core/memory.h b/Middlewares/eez/core/memory.h
deleted file mode 100644
index 2cc7948..0000000
--- a/Middlewares/eez/core/memory.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2015-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#pragma once
-
-#include
-#include
-
-namespace eez {
-
-#if defined(EEZ_PLATFORM_STM32)
-static uint8_t * const MEMORY_BEGIN = (uint8_t *)0xc0000000u;
-#if CONF_OPTION_FPGA
-static const uint32_t MEMORY_SIZE = 32 * 1024 * 1024;
-#elif defined(EEZ_PLATFORM_STM32F469I_DISCO)
-static const uint32_t MEMORY_SIZE = 8 * 1024 * 1024;
-#else
-static const uint32_t MEMORY_SIZE = 8 * 1024 * 1024;
-#endif
-#endif
-
-#if defined(EEZ_PLATFORM_SIMULATOR)
-extern uint8_t g_memory[];
-static uint8_t * const MEMORY_BEGIN = g_memory;
-static const uint32_t MEMORY_SIZE = 64 * 1024 * 1024;
-#endif
-
-extern uint8_t *ALLOC_BUFFER;
-extern uint32_t ALLOC_BUFFER_SIZE;
-
-extern uint8_t *DECOMPRESSED_ASSETS_START_ADDRESS;
-#if defined(EEZ_PLATFORM_STM32)
-static const uint32_t MAX_DECOMPRESSED_ASSETS_SIZE = 2 * 1024 * 1024;
-#endif
-#if defined(EEZ_PLATFORM_SIMULATOR)
-static const uint32_t MAX_DECOMPRESSED_ASSETS_SIZE = 8 * 1024 * 1024;
-#endif
-
-extern uint8_t *FLOW_TO_DEBUGGER_MESSAGE_BUFFER;
-#if defined(EEZ_PLATFORM_STM32)
-static const uint32_t FLOW_TO_DEBUGGER_MESSAGE_BUFFER_SIZE = 32 * 1024;
-#endif
-#if defined(EEZ_PLATFORM_SIMULATOR)
-static const uint32_t FLOW_TO_DEBUGGER_MESSAGE_BUFFER_SIZE = 1024 * 1024;
-#endif
-
-extern uint8_t *VRAM_BUFFER1_START_ADDRESS;
-extern uint8_t *VRAM_BUFFER2_START_ADDRESS;
-
-extern uint8_t *VRAM_ANIMATION_BUFFER1_START_ADDRESS;
-extern uint8_t *VRAM_ANIMATION_BUFFER2_START_ADDRESS;
-
-extern uint8_t *VRAM_AUX_BUFFER1_START_ADDRESS;
-extern uint8_t *VRAM_AUX_BUFFER2_START_ADDRESS;
-extern uint8_t *VRAM_AUX_BUFFER3_START_ADDRESS;
-extern uint8_t *VRAM_AUX_BUFFER4_START_ADDRESS;
-extern uint8_t *VRAM_AUX_BUFFER5_START_ADDRESS;
-extern uint8_t *VRAM_AUX_BUFFER6_START_ADDRESS;
-
-extern uint8_t* SCREENSHOOT_BUFFER_START_ADDRESS;
-
-extern uint8_t* GUI_STATE_BUFFER;
-
-void initMemory();
-void initAssetsMemory();
-void initOtherMemory();
-uint8_t *allocBuffer(uint32_t size);
-
-} // eez
diff --git a/Middlewares/eez/core/mouse.h b/Middlewares/eez/core/mouse.h
deleted file mode 100644
index 6c38e5e..0000000
--- a/Middlewares/eez/core/mouse.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
-* EEZ Generic Firmware
-* Copyright (C) 2020-present, Envox d.o.o.
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#pragma once
-
-#include
-
-namespace eez {
-namespace mouse {
-
-bool isMouseEnabled();
-
-bool isDisplayDirty();
-void updateDisplay();
-
-void onPageChanged();
-
-#if defined(EEZ_PLATFORM_SIMULATOR)
-void onMouseEvent(bool mouseButton1IsPressed, int mouseX, int mouseY);
-#endif
-
-} // mouse
-} // eez
diff --git a/Middlewares/eez/core/os.cpp b/Middlewares/eez/core/os.cpp
deleted file mode 100644
index 3ed285f..0000000
--- a/Middlewares/eez/core/os.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
-* EEZ Generic Firmware
-* Copyright (C) 2018-present, Envox d.o.o.
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#if defined(EEZ_PLATFORM_STM32)
-#include
-#endif
-
-#include
-
-namespace eez {
-
-uint32_t millis() {
-#if defined(EEZ_PLATFORM_STM32)
- return HAL_GetTick();
-#endif
-
-#if defined(EEZ_PLATFORM_SIMULATOR)
- return osKernelGetTickCount();
-#endif
-}
-
-} // namespace eez
diff --git a/Middlewares/eez/core/os.h b/Middlewares/eez/core/os.h
deleted file mode 100644
index ae5a16e..0000000
--- a/Middlewares/eez/core/os.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#pragma once
-
-#include
-
-#include "cmsis_os2.h"
-
-#if defined(EEZ_PLATFORM_STM32)
-#include "FreeRTOS.h"
-#include "task.h"
-#endif
-
-#define EEZ_THREAD_DECLARE(NAME, PRIORITY, STACK_SIZE) \
- osThreadId_t g_##NAME##TaskHandle; \
- const osThreadAttr_t g_##NAME##TaskAttributes = { \
- #NAME, \
- 0, \
- 0, \
- 0, \
- 0, \
- STACK_SIZE, \
- osPriority##PRIORITY, \
- 0, \
- 0, \
- }
-#define EEZ_THREAD_CREATE(NAME, THREAD_FUNC) g_##NAME##TaskHandle = osThreadNew(THREAD_FUNC, nullptr, &g_##NAME##TaskAttributes);
-#define EEZ_THREAD_TERMINATE(NAME) osThreadTerminate(g_##NAME##TaskHandle)
-
-#define EEZ_MESSAGE_QUEUE_DECLARE(NAME, OBJECT_DEF) \
- struct NAME##MessageQueueObject OBJECT_DEF; \
- osMessageQueueId_t g_##NAME##MessageQueueId
-#define EEZ_MESSAGE_QUEUE_CREATE(NAME, QUEUE_SIZE) g_##NAME##MessageQueueId = osMessageQueueNew(QUEUE_SIZE, sizeof(NAME##MessageQueueObject), nullptr)
-#define EEZ_MESSAGE_QUEUE_GET(NAME, OBJ, TIMEOUT) (osMessageQueueGet(g_##NAME##MessageQueueId, &OBJ, nullptr, TIMEOUT) == osOK)
-#define EEZ_MESSAGE_QUEUE_PUT(NAME, OBJ, TIMEOUT) osMessageQueuePut(g_##NAME##MessageQueueId, &OBJ, 0, TIMEOUT)
-
-#define EEZ_MUTEX_DECLARE(NAME) \
- osMutexId_t g_##NAME##mutexId;\
- const osMutexAttr_t g_##NAME##mutexAttr = { \
- #NAME, \
- osMutexRecursive | osMutexPrioInherit, \
- NULL, \
- 0U \
- }
-#define EEZ_MUTEX_CREATE(NAME) g_##NAME##mutexId = osMutexNew(&g_##NAME##mutexAttr)
-#define EEZ_MUTEX_WAIT(NAME, TIMEOUT) osMutexAcquire(g_##NAME##mutexId, TIMEOUT) == osOK
-#define EEZ_MUTEX_RELEASE(NAME) osMutexRelease(g_##NAME##mutexId)
-
-#if defined(__EMSCRIPTEN__)
-#ifndef EM_PORT_API
-# if defined(__EMSCRIPTEN__)
-# include
-# if defined(__cplusplus)
-# define EM_PORT_API(rettype) extern "C" rettype EMSCRIPTEN_KEEPALIVE
-# else
-# define EM_PORT_API(rettype) rettype EMSCRIPTEN_KEEPALIVE
-# endif
-# else
-# if defined(__cplusplus)
-# define EM_PORT_API(rettype) extern "C" rettype
-# else
-# define EM_PORT_API(rettype) rettype
-# endif
-# endif
-#endif
-#else
-# define EM_PORT_API(rettype) rettype
-#endif
-
-namespace eez {
-
-enum TestResult {
- TEST_NONE,
- TEST_FAILED,
- TEST_OK,
- TEST_CONNECTING,
- TEST_SKIPPED,
- TEST_WARNING
-};
-
-uint32_t millis();
-
-extern bool g_shutdown;
-void shutdown();
-
-} // namespace eez
diff --git a/Middlewares/eez/core/sound.h b/Middlewares/eez/core/sound.h
deleted file mode 100644
index 74ea996..0000000
--- a/Middlewares/eez/core/sound.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2015-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#pragma once
-
-#include
-
-namespace eez {
-namespace sound {
-
-void init();
-void tick();
-
-/// Play power up tune.
-enum PlayPowerUpCondition {
- PLAY_POWER_UP_CONDITION_NONE,
- PLAY_POWER_UP_CONDITION_TEST_SUCCESSFUL,
- PLAY_POWER_UP_CONDITION_WELCOME_PAGE_IS_ACTIVE
-};
-
-void playPowerUp(PlayPowerUpCondition condition);
-
-/// Play power down tune.
-void playPowerDown();
-
-/// Play beep sound.
-void playBeep(bool force = false);
-
-/// Play click sound
-void playClick();
-
-/// Play shutter sound
-void playShutter();
-
-} // namespace sound
-} // namespace eez
diff --git a/Middlewares/eez/core/step_values.h b/Middlewares/eez/core/step_values.h
deleted file mode 100644
index 780a303..0000000
--- a/Middlewares/eez/core/step_values.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#pragma once
-
-#include
-
-namespace eez {
-
-enum EncoderMode {
- ENCODER_MODE_MIN,
- ENCODER_MODE_AUTO = ENCODER_MODE_MIN,
- ENCODER_MODE_STEP1,
- ENCODER_MODE_STEP2,
- ENCODER_MODE_STEP3,
- ENCODER_MODE_STEP4,
- ENCODER_MODE_STEP5,
- ENCODER_MODE_MAX = ENCODER_MODE_STEP5
-};
-
-struct StepValues {
- int count;
- const float *values;
- Unit unit;
- struct {
- bool accelerationEnabled;
- float range;
- float step;
- EncoderMode mode;
- } encoderSettings;
-};
-
-} // namespace eez
\ No newline at end of file
diff --git a/Middlewares/eez/core/unit.cpp b/Middlewares/eez/core/unit.cpp
deleted file mode 100644
index 3be5fc9..0000000
--- a/Middlewares/eez/core/unit.cpp
+++ /dev/null
@@ -1,309 +0,0 @@
- /*
-* EEZ Generic Firmware
-* Copyright (C) 2018-present, Envox d.o.o.
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#include
-
-#include
-
-#if OPTION_SCPI
-#include
-#endif
-
-namespace eez {
-
-const char *g_unitNames[] = {
- "", // UNIT_NONE
- "V", // UNIT_VOLT
- "mV", // UNIT_MILLI_VOLT
- "A", // UNIT_AMPER
- "mA", // UNIT_MILLI_AMPER
- "uA", // UNIT_MICRO_AMPER
- "W", // UNIT_WATT
- "mW", // UNIT_MILLI_WATT
- "s", // UNIT_SECOND
- "ms", // UNIT_MILLI_SECOND
- DEGREE_SYMBOL"C", // UNIT_CELSIUS
- "rpm", // UNIT_RPM
- "\xb4", // UNIT_OHM
- "K\xb4", // UNIT_KOHM
- "M\xb4", // UNIT_MOHM
- "%", // UNIT_PERCENT
- "Hz", // UNIT_HERTZ
- "mHz", // UNIT_MILLI_HERTZ
- "KHz", // UNIT_KHERTZ
- "MHz", // UNIT_MHERTZ
- "J", // UNIT_JOULE
- "F", // UNIT_FARAD
- "mF", // UNIT_MILLI_FARAD
- "uF", // UNIT_MICRO_FARAD
- "nF", // UNIT_NANO_FARAD
- "pF", // UNIT_PICO_FARAD
- "minutes", // UNIT_MINUTE
- "VA", // UNIT_VOLT_AMPERE
- "VAR", // UNIT_VOLT_AMPERE_REACTIVE
- DEGREE_SYMBOL, // UNIT_DEGREE
- "Vpp", // UNIT_VOLT_PP
- "mVpp", // UNIT_MILLI_VOLT_PP
- "App", // UNIT_AMPER_PP
- "mApp", // UNIT_MILLI_AMPER_PP
- "uApp", // UNIT_MICRO_AMPER_PP
-};
-
-const Unit g_baseUnit[] = {
- UNIT_NONE, // UNIT_NONE
- UNIT_VOLT, // UNIT_VOLT
- UNIT_VOLT, // UNIT_MILLI_VOLT
- UNIT_AMPER, // UNIT_AMPER
- UNIT_AMPER, // UNIT_MILLI_AMPER
- UNIT_AMPER, // UNIT_MICRO_AMPER
- UNIT_WATT, // UNIT_WATT
- UNIT_WATT, // UNIT_MILLI_WATT
- UNIT_SECOND, // UNIT_SECOND
- UNIT_SECOND, // UNIT_MILLI_SECOND
- UNIT_CELSIUS, // UNIT_CELSIUS
- UNIT_RPM, // UNIT_RPM
- UNIT_OHM, // UNIT_OHM
- UNIT_OHM, // UNIT_KOHM
- UNIT_OHM, // UNIT_MOHM
- UNIT_PERCENT, // UNIT_PERCENT
- UNIT_HERTZ, // UNIT_HERTZ
- UNIT_HERTZ, // UNIT_MILLI_HERTZ
- UNIT_HERTZ, // UNIT_KHERTZ
- UNIT_HERTZ, // UNIT_MHERTZ
- UNIT_JOULE, // UNIT_JOULE
- UNIT_FARAD, // UNIT_FARAD
- UNIT_FARAD, // UNIT_MILLI_FARAD
- UNIT_FARAD, // UNIT_MICRO_FARAD
- UNIT_FARAD, // UNIT_NANO_FARAD
- UNIT_FARAD, // UNIT_PICO_FARAD
- UNIT_SECOND, // UNIT_MINUTE
- UNIT_VOLT_AMPERE, // UNIT_VOLT_AMPERE
- UNIT_VOLT_AMPERE, //UNIT_VOLT_AMPERE_REACTIVE
- UNIT_DEGREE, // UNIT_DEGREE
- UNIT_VOLT_PP, // UNIT_VOLT_PP
- UNIT_VOLT_PP, // UNIT_MILLI_VOLT_PP
- UNIT_AMPER_PP, // UNIT_AMPER_PP
- UNIT_AMPER_PP, // UNIT_MILLI_AMPER_PP
- UNIT_AMPER_PP, // UNIT_MICRO_AMPER_PP
-};
-
-const float g_unitFactor[] = {
- 1.0f, // UNIT_NONE
- 1.0f, // UNIT_VOLT
- 1E-3f, // UNIT_MILLI_VOLT
- 1.0f, // UNIT_AMPER
- 1E-3f, // UNIT_MILLI_AMPER
- 1E-6f, // UNIT_MICRO_AMPER
- 1.0f, // UNIT_WATT
- 1E-3f, // UNIT_MILLI_WATT
- 1.0f, // UNIT_SECOND
- 1E-3f, // UNIT_MILLI_SECOND
- 1.0f, // UNIT_CELSIUS
- 1.0f, // UNIT_RPM
- 1.0f, // UNIT_OHM
- 1E3f, // UNIT_KOHM
- 1E6f, // UNIT_MOHM
- 1.0f, // UNIT_PERCENT
- 1.0f, // UNIT_HERTZ
- 1E-3f, // UNIT_MILLI_HERTZ
- 1E3f, // UNIT_KHERTZ
- 1E6f, // UNIT_MHERTZ
- 1.0f, // UNIT_JOULE
- 1.0f, // UNIT_FARAD
- 1E-3f, // UNIT_MILLI_FARAD
- 1E-6f, // UNIT_MICRO_FARAD
- 1E-9f, // UNIT_NANO_FARAD
- 1E-12f, // UNIT_PICO_FARAD
- 60.0f, // UNIT_MINUTE
- 1.0f, // UNIT_VOLT_AMPERE
- 1.0f, //UNIT_VOLT_AMPERE_REACTIVE
- 1.0f, // UNIT_DEGREE
- 1.0f, // UNIT_VOLT_PP
- 1E-3f, // UNIT_MILLI_VOLT_PP
- 1.0f, // UNIT_AMPER_PP
- 1E-3f, // UNIT_MILLI_AMPER_PP
- 1E-6f, // UNIT_MICRO_AMPER_PP
-};
-
-#if OPTION_SCPI
-static const int g_scpiUnits[] = {
- SCPI_UNIT_NONE, // UNIT_NONE
- SCPI_UNIT_VOLT, // UNIT_VOLT
- SCPI_UNIT_VOLT, // UNIT_MILLI_VOLT
- SCPI_UNIT_AMPER, // UNIT_AMPER
- SCPI_UNIT_AMPER, // UNIT_MILLI_AMPER
- SCPI_UNIT_AMPER, // UNIT_MICRO_AMPER
- SCPI_UNIT_WATT, // UNIT_WATT
- SCPI_UNIT_WATT, // UNIT_MILLI_WATT
- SCPI_UNIT_SECOND, // UNIT_SECOND
- SCPI_UNIT_SECOND, // UNIT_MILLI_SECOND
- SCPI_UNIT_CELSIUS, // UNIT_CELSIUS
- SCPI_UNIT_NONE, // UNIT_RPM
- SCPI_UNIT_OHM, // UNIT_OHM
- SCPI_UNIT_OHM, // UNIT_KOHM
- SCPI_UNIT_OHM, // UNIT_MOHM
- SCPI_UNIT_NONE, // UNIT_PERCENT
- SCPI_UNIT_HERTZ, // UNIT_HERTZ
- SCPI_UNIT_HERTZ, // UNIT_MILLI_HERTZ
- SCPI_UNIT_HERTZ, // UNIT_KHERTZ
- SCPI_UNIT_HERTZ, // UNIT_MHERTZ
- SCPI_UNIT_JOULE, // UNIT_JOULE
- SCPI_UNIT_FARAD, // UNIT_FARAD
- SCPI_UNIT_FARAD, // UNIT_MILLI_FARAD
- SCPI_UNIT_FARAD, // UNIT_MICRO_FARAD
- SCPI_UNIT_FARAD, // UNIT_NANO_FARAD
- SCPI_UNIT_FARAD, // UNIT_PICO_FARAD
- SCPI_UNIT_SECOND, // UNIT_MINUTE
- SCPI_UNIT_WATT, // UNIT_VOLT_AMPERE
- SCPI_UNIT_WATT, // UNIT_VOLT_AMPERE_REACTIVE
- SCPI_UNIT_DEGREE, // UNIT_DEGREE
- SCPI_UNIT_VOLT, // UNIT_VOLT_PP
- SCPI_UNIT_VOLT, // UNIT_MILLI_VOLT_PP
- SCPI_UNIT_AMPER, // UNIT_AMPER_PP
- SCPI_UNIT_AMPER, // UNIT_MILLI_AMPER_PP
- SCPI_UNIT_AMPER, // UNIT_MICRO_AMPER_PP
-};
-#endif
-
-Unit getUnitFromName(const char *unitName) {
- if (unitName) {
- for (unsigned i = 0; i < sizeof(g_unitNames) / sizeof(const char *); i++) {
- if (strcmp(g_unitNames[i], unitName) == 0) {
- return (Unit)i;
- }
- }
- }
- return UNIT_NONE;
-}
-
-#if OPTION_SCPI
-int getScpiUnit(Unit unit) {
- if (unit == UNIT_UNKNOWN) {
- return SCPI_UNIT_NONE;
- }
- return g_scpiUnits[unit];
-}
-#endif
-
-Unit getBaseUnit(Unit unit) {
- if (unit == UNIT_UNKNOWN) {
- return UNIT_UNKNOWN;
- }
- return g_baseUnit[unit];
-}
-
-float getUnitFactor(Unit unit) {
- if (unit == UNIT_UNKNOWN) {
- return 1.0f;
- }
- return g_unitFactor[unit];
-}
-
-static Unit getDerivedUnit(Unit unit, float factor) {
- if (unit == UNIT_UNKNOWN) {
- return UNIT_UNKNOWN;
- }
-
- for (size_t i = 0; i < sizeof(g_baseUnit); i++) {
- if (g_baseUnit[i] == g_baseUnit[unit] && g_unitFactor[i] == factor) {
- return (Unit)i;
- }
- }
-
- return UNIT_UNKNOWN;
-}
-
-static const float FACTORS[] = { 1E-12F, 1E-9F, 1E-6F, 1E-3F, 1E0F, 1E3F, 1E6F, 1E9F, 1E12F };
-
-Unit findDerivedUnit(float value, Unit unit) {
- Unit result;
-
- for (int factorIndex = 1; ; factorIndex++) {
- float factor = FACTORS[factorIndex];
- if (factor > 1.0F) {
- break;
- }
- if (value < factor) {
- result = getDerivedUnit(unit, FACTORS[factorIndex - 1]);
- if (result != UNIT_UNKNOWN) {
- return result;
- }
- }
- }
-
- for (int factorIndex = sizeof(FACTORS) / sizeof(float) - 1; factorIndex >= 0; factorIndex--) {
- float factor = FACTORS[factorIndex];
- if (factor == 1.0F) {
- break;
- }
- if (value >= factor) {
- result = getDerivedUnit(unit, factor);
- if (result != UNIT_UNKNOWN) {
- return result;
- }
- }
- }
-
- return unit;
-}
-
-float getSmallerFactor(float factor) {
- for (int factorIndex = sizeof(FACTORS) / sizeof(float) - 1; factorIndex > 0; factorIndex--) {
- float itFactor = FACTORS[factorIndex];
- if (itFactor < factor) {
- return itFactor;
- }
- }
- return FACTORS[0];
-}
-
-Unit getSmallerUnit(Unit unit, float min, float precision) {
- float factor = getUnitFactor(unit);
- if (precision <= factor || min <= factor) {
- return getDerivedUnit(unit, getSmallerFactor(factor));
- }
- return UNIT_UNKNOWN;
-}
-
-Unit getBiggestUnit(Unit unit, float max) {
- for (int factorIndex = sizeof(FACTORS) / sizeof(float) - 1; factorIndex >= 0; factorIndex--) {
- float factor = FACTORS[factorIndex];
- if (max >= factor) {
- auto result = getDerivedUnit(unit, factor);
- if (result != UNIT_UNKNOWN) {
- return result;
- }
- }
- }
- return UNIT_UNKNOWN;
-}
-
-Unit getSmallestUnit(Unit unit, float min, float precision) {
- for (int factorIndex = 0; factorIndex < int(sizeof(FACTORS) / sizeof(float)); factorIndex++) {
- float factor = FACTORS[factorIndex];
- if (precision <= factor || min <= factor) {
- auto result = getDerivedUnit(unit, factor);
- if (result != UNIT_UNKNOWN) {
- return result;
- }
- }
- }
- return UNIT_UNKNOWN;
-}
-
-} // namespace eez
diff --git a/Middlewares/eez/core/unit.h b/Middlewares/eez/core/unit.h
deleted file mode 100644
index cb287fd..0000000
--- a/Middlewares/eez/core/unit.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
-* EEZ Generic Firmware
-* Copyright (C) 2018-present, Envox d.o.o.
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#pragma once
-
-#define INFINITY_SYMBOL "\x91"
-#define DEGREE_SYMBOL "\x8a"
-
-namespace eez {
-
-// order of units should not be changed since it is used in DLOG files
-enum Unit {
- UNIT_UNKNOWN = 255,
- UNIT_NONE = 0,
- UNIT_VOLT,
- UNIT_MILLI_VOLT,
- UNIT_AMPER,
- UNIT_MILLI_AMPER,
- UNIT_MICRO_AMPER,
- UNIT_WATT,
- UNIT_MILLI_WATT,
- UNIT_SECOND,
- UNIT_MILLI_SECOND,
- UNIT_CELSIUS,
- UNIT_RPM,
- UNIT_OHM,
- UNIT_KOHM,
- UNIT_MOHM,
- UNIT_PERCENT,
- UNIT_HERTZ,
- UNIT_MILLI_HERTZ,
- UNIT_KHERTZ,
- UNIT_MHERTZ,
- UNIT_JOULE,
- UNIT_FARAD,
- UNIT_MILLI_FARAD,
- UNIT_MICRO_FARAD,
- UNIT_NANO_FARAD,
- UNIT_PICO_FARAD,
- UNIT_MINUTE,
- UNIT_VOLT_AMPERE,
- UNIT_VOLT_AMPERE_REACTIVE,
- UNIT_DEGREE,
- UNIT_VOLT_PP,
- UNIT_MILLI_VOLT_PP,
- UNIT_AMPER_PP,
- UNIT_MILLI_AMPER_PP,
- UNIT_MICRO_AMPER_PP,
-};
-
-extern const char *g_unitNames[];
-
-inline const char *getUnitName(Unit unit) {
- if (unit == UNIT_UNKNOWN) {
- return "";
- }
- return g_unitNames[unit];
-}
-
-Unit getUnitFromName(const char *unitName);
-
-#if OPTION_SCPI
-int getScpiUnit(Unit unit);
-#endif
-
-// for UNIT_MILLI_VOLT returns UNIT_VOLT, etc...
-Unit getBaseUnit(Unit unit);
-
-// returns 1.0 form UNIT_VOLT, returns 1E-3 for UNIT_MILLI_VOLT, 1E-6 for UNIT_MICRO_AMPER, 1E3 for UNIT_KOHM, etc
-float getUnitFactor(Unit unit);
-
-// if value is 0.01 and unit is UNIT_VOLT returns UNIT_MILLI_VOLT, etc
-Unit findDerivedUnit(float value, Unit unit);
-
-Unit getSmallerUnit(Unit unit, float min, float precision);
-Unit getBiggestUnit(Unit unit, float max);
-Unit getSmallestUnit(Unit unit, float min, float precision);
-
-} // namespace eez
\ No newline at end of file
diff --git a/Middlewares/eez/core/utf8.h b/Middlewares/eez/core/utf8.h
deleted file mode 100644
index 114d7c2..0000000
--- a/Middlewares/eez/core/utf8.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
-* EEZ Generic Firmware
-* Copyright (C) 2018-present, Envox d.o.o.
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#pragma once
-
-#include
-
-#ifndef UTF8_SUPPORT
-#define UTF8_SUPPORT 1
-#endif
-
-#if UTF8_SUPPORT
-
-#include
-
-#else
-
-typedef char utf8_int8_t;
-typedef int32_t utf8_int32_t;
-
-inline const utf8_int8_t* utf8codepoint(const utf8_int8_t *str, utf8_int32_t *out_codepoint) {
- *out_codepoint = *((uint8_t *)str);
- return str + 1;
-}
-
-#define utf8len strlen
-
-#endif
diff --git a/Middlewares/eez/core/util.cpp b/Middlewares/eez/core/util.cpp
deleted file mode 100644
index 1699111..0000000
--- a/Middlewares/eez/core/util.cpp
+++ /dev/null
@@ -1,921 +0,0 @@
-/*
-* EEZ Generic Firmware
-* Copyright (C) 2018-present, Envox d.o.o.
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#include
-
-#define _USE_MATH_DEFINES
-#include
-#include
-#include
-#include
-
-#if defined(EEZ_PLATFORM_STM32)
-#include
-#endif
-
-namespace eez {
-
-float remap(float x, float x1, float y1, float x2, float y2) {
- return y1 + (x - x1) * (y2 - y1) / (x2 - x1);
-}
-
-float remapQuad(float x, float x1, float y1, float x2, float y2) {
- float t = remap(x, x1, 0, x2, 1);
- t = t * t;
- x = remap(t, 0, x1, 1, x2);
- return remap(x, x1, y1, x2, y2);
-}
-
-float remapOutQuad(float x, float x1, float y1, float x2, float y2) {
- float t = remap(x, x1, 0, x2, 1);
- t = t * (2 - t);
- x = remap(t, 0, x1, 1, x2);
- return remap(x, x1, y1, x2, y2);
-}
-
-float remapInOutQuad(float x, float x1, float y1, float x2, float y2) {
- float t = remap(x, x1, 0, x2, 1);
- t = t < .5 ? 2 * t*t : -1 + (4 - 2 * t)*t;
- x = remap(t, 0, x1, 1, x2);
- return remap(x, x1, y1, x2, y2);
-}
-
-float remapCubic(float x, float x1, float y1, float x2, float y2) {
- float t = remap(x, x1, 0, x2, 1);
- t = t * t * t;
- x = remap(t, 0, x1, 1, x2);
- return remap(x, x1, y1, x2, y2);
-}
-
-float remapOutCubic(float x, float x1, float y1, float x2, float y2) {
- float t = remap(x, x1, 0, x2, 1);
- t = t - 1;
- t = 1 + t * t * t;
- x = remap(t, 0, x1, 1, x2);
- return remap(x, x1, y1, x2, y2);
-}
-
-float remapExp(float x, float x1, float y1, float x2, float y2) {
- float t = remap(x, x1, 0, x2, 1);
- t = t == 0 ? 0 : float(pow(2, 10 * (t - 1)));
- x = remap(t, 0, x1, 1, x2);
- return remap(x, x1, y1, x2, y2);
-}
-
-float remapOutExp(float x, float x1, float y1, float x2, float y2) {
- float t = remap(x, x1, 0, x2, 1);
- t = t == 1 ? 1 : float(1 - pow(2, -10 * t));
- x = remap(t, 0, x1, 1, x2);
- return remap(x, x1, y1, x2, y2);
-}
-
-float clamp(float x, float min, float max) {
- if (x < min) {
- return min;
- }
- if (x > max) {
- return max;
- }
- return x;
-}
-
-void stringCopy(char *dst, size_t maxStrLength, const char *src) {
- strncpy(dst, src, maxStrLength);
- dst[maxStrLength - 1] = 0;
-}
-
-void stringCopyLength(char *dst, size_t maxStrLength, const char *src, size_t length) {
- size_t n = MIN(length, maxStrLength);
- strncpy(dst, src, n);
- dst[n] = 0;
-}
-
-void stringAppendString(char *str, size_t maxStrLength, const char *value) {
- int n = maxStrLength - strlen(str) - 1;
- if (n >= 0) {
- strncat(str, value, n);
- }
-}
-
-void stringAppendStringLength(char *str, size_t maxStrLength, const char *value, size_t length) {
- int n = MIN(maxStrLength - strlen(str) - 1, length);
- if (n >= 0) {
- strncat(str, value, n);
- }
-}
-
-void stringAppendInt(char *str, size_t maxStrLength, int value) {
- auto n = strlen(str);
- snprintf(str + n, maxStrLength - n, "%d", value);
-}
-
-void stringAppendUInt32(char *str, size_t maxStrLength, uint32_t value) {
- auto n = strlen(str);
- snprintf(str + n, maxStrLength - n, "%lu", (unsigned long)value);
-}
-
-void stringAppendInt64(char *str, size_t maxStrLength, int64_t value) {
- auto n = strlen(str);
- snprintf(str + n, maxStrLength - n, "%jd", value);
-}
-
-void stringAppendUInt64(char *str, size_t maxStrLength, uint64_t value) {
- auto n = strlen(str);
- snprintf(str + n, maxStrLength - n, "%ju", value);
-}
-
-void stringAppendFloat(char *str, size_t maxStrLength, float value) {
- auto n = strlen(str);
- snprintf(str + n, maxStrLength - n, "%g", value);
-}
-
-void stringAppendFloat(char *str, size_t maxStrLength, float value, int numDecimalPlaces) {
- auto n = strlen(str);
- snprintf(str + n, maxStrLength - n, "%.*f", numDecimalPlaces, value);
-}
-
-void stringAppendDouble(char *str, size_t maxStrLength, double value) {
- auto n = strlen(str);
- snprintf(str + n, maxStrLength - n, "%g", value);
-}
-
-void stringAppendDouble(char *str, size_t maxStrLength, double value, int numDecimalPlaces) {
- auto n = strlen(str);
- snprintf(str + n, maxStrLength - n, "%.*f", numDecimalPlaces, value);
-}
-
-void stringAppendVoltage(char *str, size_t maxStrLength, float value) {
- auto n = strlen(str);
- snprintf(str + n, maxStrLength - n, "%g V", value);
-}
-
-void stringAppendCurrent(char *str, size_t maxStrLength, float value) {
- auto n = strlen(str);
- snprintf(str + n, maxStrLength - n, "%g A", value);
-}
-
-void stringAppendPower(char *str, size_t maxStrLength, float value) {
- auto n = strlen(str);
- snprintf(str + n, maxStrLength - n, "%g W", value);
-}
-
-void stringAppendDuration(char *str, size_t maxStrLength, float value) {
- auto n = strlen(str);
- if (value > 0.1) {
- snprintf(str + n, maxStrLength - n, "%g s", value);
- } else {
- snprintf(str + n, maxStrLength - n, "%g ms", value * 1000);
- }
-}
-
-void stringAppendLoad(char *str, size_t maxStrLength, float value) {
- auto n = strlen(str);
- if (value < 1000) {
- snprintf(str + n, maxStrLength - n, "%g ohm", value);
- } else if (value < 1000000) {
- snprintf(str + n, maxStrLength - n, "%g Kohm", value / 1000);
- } else {
- snprintf(str + n, maxStrLength - n, "%g Mohm", value / 1000000);
- }
-}
-
-#if defined(EEZ_PLATFORM_STM32)
-uint32_t crc32(const uint8_t *mem_block, size_t block_size) {
- return HAL_CRC_Calculate(&hcrc, (uint32_t *)mem_block, block_size);
-}
-#else
-/*
-From http://www.hackersdelight.org/hdcodetxt/crc.c.txt:
-
-This is the basic CRC-32 calculation with some optimization but no
-table lookup. The the byte reversal is avoided by shifting the crc reg
-right instead of left and by using a reversed 32-bit word to represent
-the polynomial.
-When compiled to Cyclops with GCC, this function executes in 8 + 72n
-instructions, where n is the number of bytes in the input message. It
-should be doable in 4 + 61n instructions.
-If the inner loop is strung out (approx. 5*8 = 40 instructions),
-it would take about 6 + 46n instructions.
-*/
-
-uint32_t crc32(const uint8_t *mem_block, size_t block_size) {
- uint32_t crc = 0xFFFFFFFF;
- for (size_t i = 0; i < block_size; ++i) {
- uint32_t byte = mem_block[i]; // Get next byte.
- crc = crc ^ byte;
- for (int j = 0; j < 8; ++j) { // Do eight times.
- uint32_t mask = -((int32_t)crc & 1);
- crc = (crc >> 1) ^ (0xEDB88320 & mask);
- }
- }
- return ~crc;
-}
-#endif
-
-uint8_t toBCD(uint8_t bin) {
- return ((bin / 10) << 4) | (bin % 10);
-}
-
-uint8_t fromBCD(uint8_t bcd) {
- return ((bcd >> 4) & 0xF) * 10 + (bcd & 0xF);
-}
-
-float roundPrec(float a, float prec) {
- float r = 1 / prec;
- return roundf(a * r) / r;
-}
-
-float floorPrec(float a, float prec) {
- float r = 1 / prec;
- return floorf(a * r) / r;
-}
-
-float ceilPrec(float a, float prec) {
- float r = 1 / prec;
- return ceilf(a * r) / r;
-}
-
-bool isNaN(float x) {
- return x != x;
-}
-
-bool isNaN(double x) {
- return x != x;
-}
-
-bool isDigit(char ch) {
- return ch >= '0' && ch <= '9';
-}
-
-bool isHexDigit(char ch) {
- return (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F');
-}
-
-bool isUperCaseLetter(char ch) {
- return ch >= 'A' && ch <= 'Z';
-}
-
-char toHexDigit(int num) {
- if (num >= 0 && num <= 9) {
- return '0' + num;
- } else {
- return 'A' + (num - 10);
- }
-}
-
-int fromHexDigit(char ch) {
- if (ch >= '0' && ch <= '9') {
- return ch - '0';
- }
-
- if (ch >= 'a' && ch <= 'f') {
- return 10 + (ch - 'a');
- }
-
- return 10 + (ch - 'A');
-}
-
-bool pointInsideRect(int xPoint, int yPoint, int xRect, int yRect, int wRect, int hRect) {
- return xPoint >= xRect && xPoint < xRect + wRect && yPoint >= yRect && yPoint < yRect + hRect;
-}
-
-void getParentDir(const char *path, char *parentDirPath) {
- int lastPathSeparatorIndex;
-
- for (lastPathSeparatorIndex = strlen(path) - 1;
- lastPathSeparatorIndex >= 0 && path[lastPathSeparatorIndex] != PATH_SEPARATOR[0];
- --lastPathSeparatorIndex)
- ;
-
- int i;
- for (i = 0; i < lastPathSeparatorIndex; ++i) {
- parentDirPath[i] = path[i];
- }
- parentDirPath[i] = 0;
-}
-
-bool parseMacAddress(const char *macAddressStr, size_t macAddressStrLength, uint8_t *macAddress) {
- int state = 0;
- int a = 0;
- int i = 0;
- uint8_t resultMacAddress[6];
-
- const char *end = macAddressStr + macAddressStrLength;
- for (const char *p = macAddressStr; p < end; ++p) {
- if (state == 0) {
- if (*p == '-' || *p == ' ') {
- continue;
- } else if (isHexDigit(*p)) {
- a = fromHexDigit(*p);
- state = 1;
- } else {
- return false;
- }
- } else if (state == 1) {
- if (isHexDigit(*p)) {
- if (i < 6) {
- resultMacAddress[i++] = (a << 4) | fromHexDigit(*p);
- state = 0;
- } else {
- return false;
- }
- } else {
- return false;
- }
- }
- }
-
- if (state != 0 || i != 6) {
- return false;
- }
-
- memcpy(macAddress, resultMacAddress, 6);
-
- return true;
-}
-
-bool parseIpAddress(const char *ipAddressStr, size_t ipAddressStrLength, uint32_t &ipAddress) {
- const char *p = ipAddressStr;
- const char *q = ipAddressStr + ipAddressStrLength;
-
- uint8_t ipAddressArray[4];
-
- for (int i = 0; i < 4; ++i) {
- if (p == q) {
- return false;
- }
-
- uint32_t part = 0;
- for (int j = 0; j < 3; ++j) {
- if (p == q) {
- if (j > 0 && i == 3) {
- break;
- } else {
- return false;
- }
- } else if (isDigit(*p)) {
- part = part * 10 + (*p++ - '0');
- } else if (j > 0 && *p == '.') {
- break;
- } else {
- return false;
- }
- }
-
- if (part > 255) {
- return false;
- }
-
- if ((i < 3 && *p++ != '.') || (i == 3 && p != q)) {
- return false;
- }
-
- ipAddressArray[i] = part;
- }
-
- ipAddress = arrayToIpAddress(ipAddressArray);
-
- return true;
-}
-
-int getIpAddressPartA(uint32_t ipAddress) {
- return ((uint8_t *)&ipAddress)[0];
-}
-
-void setIpAddressPartA(uint32_t *ipAddress, uint8_t value) {
- ((uint8_t *)ipAddress)[0] = value;
-}
-
-int getIpAddressPartB(uint32_t ipAddress) {
- return ((uint8_t *)&ipAddress)[1];
-}
-
-void setIpAddressPartB(uint32_t *ipAddress, uint8_t value) {
- ((uint8_t *)ipAddress)[1] = value;
-}
-
-int getIpAddressPartC(uint32_t ipAddress) {
- return ((uint8_t *)&ipAddress)[2];
-}
-
-void setIpAddressPartC(uint32_t *ipAddress, uint8_t value) {
- ((uint8_t *)ipAddress)[2] = value;
-}
-
-int getIpAddressPartD(uint32_t ipAddress) {
- return ((uint8_t *)&ipAddress)[3];
-}
-
-void setIpAddressPartD(uint32_t *ipAddress, uint8_t value) {
- ((uint8_t *)ipAddress)[3] = value;
-}
-
-void ipAddressToArray(uint32_t ipAddress, uint8_t *ipAddressArray) {
- ipAddressArray[0] = getIpAddressPartA(ipAddress);
- ipAddressArray[1] = getIpAddressPartB(ipAddress);
- ipAddressArray[2] = getIpAddressPartC(ipAddress);
- ipAddressArray[3] = getIpAddressPartD(ipAddress);
-}
-
-uint32_t arrayToIpAddress(uint8_t *ipAddressArray) {
- return getIpAddress(ipAddressArray[0], ipAddressArray[1], ipAddressArray[2], ipAddressArray[3]);
-}
-
-uint32_t getIpAddress(uint8_t a, uint8_t b, uint8_t c, uint8_t d) {
- uint32_t ipAddress;
-
- setIpAddressPartA(&ipAddress, a);
- setIpAddressPartB(&ipAddress, b);
- setIpAddressPartC(&ipAddress, c);
- setIpAddressPartD(&ipAddress, d);
-
- return ipAddress;
-}
-
-void ipAddressToString(uint32_t ipAddress, char *ipAddressStr, size_t maxIpAddressStrLength) {
- snprintf(ipAddressStr, maxIpAddressStrLength, "%d.%d.%d.%d",
- getIpAddressPartA(ipAddress), getIpAddressPartB(ipAddress),
- getIpAddressPartC(ipAddress), getIpAddressPartD(ipAddress));
-}
-
-void macAddressToString(const uint8_t *macAddress, char *macAddressStr) {
- for (int i = 0; i < 6; ++i) {
- macAddressStr[3 * i] = toHexDigit((macAddress[i] & 0xF0) >> 4);
- macAddressStr[3 * i + 1] = toHexDigit(macAddress[i] & 0xF);
- macAddressStr[3 * i + 2] = i < 5 ? '-' : 0;
- }
-}
-
-void formatTimeZone(int16_t timeZone, char *text, int count) {
- if (timeZone == 0) {
- stringCopy(text, count, "GMT");
- } else {
- char sign;
- int16_t value;
- if (timeZone > 0) {
- sign = '+';
- value = timeZone;
- } else {
- sign = '-';
- value = -timeZone;
- }
- snprintf(text, count, "%c%02d:%02d GMT", sign, value / 100, value % 100);
- }
-}
-
-bool parseTimeZone(const char *timeZoneStr, size_t timeZoneLength, int16_t &timeZone) {
- int state = 0;
-
- int sign = 1;
- int integerPart = 0;
- int fractionPart = 0;
-
- const char *end = timeZoneStr + timeZoneLength;
- for (const char *p = timeZoneStr; p < end; ++p) {
- if (*p == ' ') {
- continue;
- }
-
- if (state == 0) {
- if (*p == '+') {
- state = 1;
- } else if (*p == '-') {
- sign = -1;
- state = 1;
- } else if (isDigit(*p)) {
- integerPart = *p - '0';
- state = 2;
- } else {
- return false;
- }
- } else if (state == 1) {
- if (isDigit(*p)) {
- integerPart = (*p - '0');
- state = 2;
- } else {
- return false;
- }
- } else if (state == 2) {
- if (*p == ':') {
- state = 4;
- } else if (isDigit(*p)) {
- integerPart = integerPart * 10 + (*p - '0');
- state = 3;
- } else {
- return false;
- }
- } else if (state == 3) {
- if (*p == ':') {
- state = 4;
- } else {
- return false;
- }
- } else if (state == 4) {
- if (isDigit(*p)) {
- fractionPart = (*p - '0');
- state = 5;
- } else {
- return false;
- }
- } else if (state == 5) {
- if (isDigit(*p)) {
- fractionPart = fractionPart * 10 + (*p - '0');
- state = 6;
- } else {
- return false;
- }
- } else {
- return false;
- }
- }
-
- if (state != 2 && state != 3 && state != 6) {
- return false;
- }
-
- int value = sign * (integerPart * 100 + fractionPart);
-
- if (value < -1200 || value > 1400) {
- return false;
- }
-
- timeZone = (int16_t)value;
-
- return true;
-}
-
-void replaceCharacter(char *str, char ch, char repl) {
- while (*str) {
- if (*str == ch) {
- *str = repl;
- }
- ++str;
- }
-}
-
-int strcicmp(char const *a, char const *b) {
- for (;; a++, b++) {
- int d = tolower((unsigned char)*a) - tolower((unsigned char)*b);
- if (d != 0 || !*a)
- return d;
- }
-}
-
-int strncicmp(char const *a, char const *b, int n) {
- for (; n--; a++, b++) {
- int d = tolower((unsigned char)*a) - tolower((unsigned char)*b);
- if (d != 0 || !*a)
- return d;
- }
- return 0;
-}
-
-bool isStringEmpty(char const *s) {
- for (; *s; s++) {
- if (!isspace(*s)) {
- return false;
- }
- }
- return true;
-}
-
-bool startsWith(const char *str, const char *prefix) {
- if (!str || !prefix)
- return false;
- size_t strLen = strlen(str);
- size_t prefixLen = strlen(prefix);
- if (prefixLen > strLen)
- return false;
- return strncmp(str, prefix, prefixLen) == 0;
-}
-
-bool startsWithNoCase(const char *str, const char *prefix) {
- if (!str || !prefix)
- return false;
- size_t strLen = strlen(str);
- size_t prefixLen = strlen(prefix);
- if (prefixLen > strLen)
- return false;
- return strncicmp(str, prefix, prefixLen) == 0;
-}
-
-bool endsWith(const char *str, const char *suffix) {
- if (!str || !suffix)
- return false;
- size_t strLen = strlen(str);
- size_t suffixLen = strlen(suffix);
- if (suffixLen > strLen)
- return false;
- return strncmp(str + strLen - suffixLen, suffix, suffixLen) == 0;
-}
-
-bool endsWithNoCase(const char *str, const char *suffix) {
- if (!str || !suffix)
- return false;
- size_t strLen = strlen(str);
- size_t suffixLen = strlen(suffix);
- if (suffixLen > strLen)
- return false;
- return strncicmp(str + strLen - suffixLen, suffix, suffixLen) == 0;
-}
-
-void formatBytes(uint64_t bytes, char *text, int count) {
- if (bytes == 0) {
- stringCopy(text, count, "0 Bytes");
- } else {
- double c = 1024.0;
- const char *e[] = { "Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" };
- uint64_t f = (uint64_t)floor(log((double)bytes) / log(c));
- double g = round((bytes / pow(c, (double)f)) * 100) / 100;
- snprintf(text, count, "%g %s", g, e[f]);
- }
-}
-
-void getFileName(const char *path, char *fileName, unsigned fileNameSize) {
- const char *a = strrchr(path, '/');
- if (a) {
- a++;
- } else {
- a = path;
- }
-
- const char *b = path + strlen(path);
-
- unsigned n = b - a;
- n = MIN(fileNameSize - 1, n);
- if (n > 0) {
- memcpy(fileName, a, n);
- }
- fileName[n] = 0;
-}
-
-void getBaseFileName(const char *path, char *baseName, unsigned baseNameSize) {
- const char *a = strrchr(path, '/');
- if (a) {
- a++;
- } else {
- a = path;
- }
-
- const char *b = strrchr(path, '.');
- if (!b || !(b >= a)) {
- b = path + strlen(path);
- }
-
- unsigned n = b - a;
- n = MIN(baseNameSize - 1, n);
- if (n > 0) {
- memcpy(baseName, a, n);
- }
- baseName[n] = 0;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
-static const float PI = (float)M_PI;
-static const float c1 = 1.70158f;
-static const float c2 = c1 * 1.525f;
-static const float c3 = c1 + 1.0f;
-static const float c4 = (2 * PI) / 3;
-static const float c5 = (2 * PI) / 4.5f;
-
-float linear(float x) {
- return x;
-}
-
-float easeInQuad(float x) {
- return x * x;
-}
-
-float easeOutQuad(float x) {
- return 1 - (1 - x) * (1 - x);
-}
-
-float easeInOutQuad(float x) {
- return x < 0.5f ? 2 * x * x : 1 - powf(-2 * x + 2, 2) / 2;
-}
-
-float easeInCubic(float x) {
- return x * x * x;
-}
-
-float easeOutCubic(float x) {
- return 1 - pow(1 - x, 3);
-}
-
-float easeInOutCubic(float x) {
- return x < 0.5f ? 4 * x * x * x : 1 - powf(-2 * x + 2, 3) / 2;
-}
-
-float easeInQuart(float x) {
- return x * x * x * x;
-}
-
-float easeOutQuart(float x) {
- return 1 - powf(1 - x, 4);
-}
-
-float easeInOutQuart(float x) {
- return x < 0.5 ? 8 * x * x * x * x : 1 - powf(-2 * x + 2, 4) / 2;
-}
-
-float easeInQuint(float x) {
- return x * x * x * x * x;
-}
-
-float easeOutQuint(float x) {
- return 1 - powf(1 - x, 5);
-}
-
-float easeInOutQuint(float x) {
- return x < 0.5f ? 16 * x * x * x * x * x : 1 - powf(-2 * x + 2, 5) / 2;
-}
-
-float easeInSine(float x) {
- return 1 - cosf((x * PI) / 2);
-}
-
-float easeOutSine(float x) {
- return sinf((x * PI) / 2);
-}
-
-float easeInOutSine(float x) {
- return -(cosf(PI * x) - 1) / 2;
-}
-
-float easeInExpo(float x) {
- return x == 0 ? 0 : powf(2, 10 * x - 10);
-}
-
-float easeOutExpo(float x) {
- return x == 1 ? 1 : 1 - powf(2, -10 * x);
-}
-
-float easeInOutExpo(float x) {
- return x == 0
- ? 0
- : x == 1
- ? 1
- : x < 0.5
- ? powf(2, 20 * x - 10) / 2
- : (2 - powf(2, -20 * x + 10)) / 2;
-}
-
-float easeInCirc(float x) {
- return 1 - sqrtf(1 - powf(x, 2));
-}
-
-float easeOutCirc(float x) {
- return sqrtf(1 - powf(x - 1, 2));
-}
-
-float easeInOutCirc(float x) {
- return x < 0.5
- ? (1 - sqrtf(1 - pow(2 * x, 2))) / 2
- : (sqrtf(1 - powf(-2 * x + 2, 2)) + 1) / 2;
-}
-
-float easeInBack(float x) {
- return c3 * x * x * x - c1 * x * x;
-}
-
-float easeOutBack(float x) {
- return 1 + c3 * powf(x - 1, 3) + c1 * powf(x - 1, 2);
-}
-
-float easeInOutBack(float x) {
- return x < 0.5
- ? (powf(2 * x, 2) * ((c2 + 1) * 2 * x - c2)) / 2
- : (powf(2 * x - 2, 2) * ((c2 + 1) * (x * 2 - 2) + c2) + 2) / 2;
-}
-
-float easeInElastic(float x) {
- return x == 0
- ? 0
- : x == 1
- ? 1
- : -powf(2, 10 * x - 10) * sinf((x * 10 - 10.75f) * c4);
-}
-
-float easeOutElastic(float x) {
- return x == 0
- ? 0
- : x == 1
- ? 1
- : powf(2, -10 * x) * sinf((x * 10 - 0.75f) * c4) + 1;
-}
-
-float easeInOutElastic(float x) {
- return x == 0
- ? 0
- : x == 1
- ? 1
- : x < 0.5
- ? -(powf(2, 20 * x - 10) * sinf((20 * x - 11.125f) * c5)) / 2
- : (powf(2, -20 * x + 10) * sinf((20 * x - 11.125f) * c5)) / 2 + 1;
-}
-
-float easeOutBounce(float x);
-
-float easeInBounce(float x) {
- return 1 -easeOutBounce(1 - x);
-}
-
-float easeOutBounce(float x) {
- static const float n1 = 7.5625f;
- static const float d1 = 2.75f;
-
- if (x < 1 / d1) {
- return n1 * x * x;
- } else if (x < 2 / d1) {
- x -= 1.5f / d1;
- return n1 * x * x + 0.75f;
- } else if (x < 2.5f / d1) {
- x -= 2.25f / d1;
- return n1 * x * x + 0.9375f;
- } else {
- x -= 2.625f / d1;
- return n1 * x * x + 0.984375f;
- }
-};
-
-float easeInOutBounce(float x) {
- return x < 0.5
- ? (1 - easeOutBounce(1 - 2 * x)) / 2
- : (1 + easeOutBounce(2 * x - 1)) / 2;
-}
-
-EasingFuncType g_easingFuncs[] = {
- linear,
- easeInQuad,
- easeOutQuad,
- easeInOutQuad,
- easeInCubic,
- easeOutCubic,
- easeInOutCubic,
- easeInQuart,
- easeOutQuart,
- easeInOutQuart,
- easeInQuint,
- easeOutQuint,
- easeInOutQuint,
- easeInSine,
- easeOutSine,
- easeInOutSine,
- easeInExpo,
- easeOutExpo,
- easeInOutExpo,
- easeInCirc,
- easeOutCirc,
- easeInOutCirc,
- easeInBack,
- easeOutBack,
- easeInOutBack,
- easeInElastic,
- easeOutElastic,
- easeInOutElastic,
- easeInBounce,
- easeOutBounce,
- easeInOutBounce,
-};
-
-} // namespace eez
-
-#ifdef EEZ_PLATFORM_SIMULATOR_WIN32
-char *strnstr(const char *s1, const char *s2, size_t n) {
- char c = *s2;
-
- if (c == '\0')
- return (char *)s1;
-
- for (size_t len = strlen(s2); len <= n; n--, s1++) {
- if (*s1 == c) {
- for (size_t i = 1;; i++) {
- if (i == len) {
- return (char *)s1;
- }
- if (s1[i] != s2[i]) {
- break;
- }
- }
- }
- }
-
- return NULL;
-}
-#endif
diff --git a/Middlewares/eez/core/util.h b/Middlewares/eez/core/util.h
deleted file mode 100644
index d561697..0000000
--- a/Middlewares/eez/core/util.h
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
-* EEZ Generic Firmware
-* Copyright (C) 2018-present, Envox d.o.o.
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#pragma once
-
-#include
-#include
-
-#include
-#include
-
-#define clear_bit(reg, bitmask) *reg &= ~bitmask
-#define set_bit(reg, bitmask) *reg |= bitmask
-#define util_swap(type, i, j) \
- { \
- type t = i; \
- i = j; \
- j = t; \
- }
-
-#ifndef MIN
-#define MIN(a, b) ((a) < (b) ? (a) : (b))
-#endif
-
-#ifndef MAX
-#define MAX(a, b) ((a) > (b) ? (a) : (b))
-#endif
-
-#define PATH_SEPARATOR "/"
-
-namespace eez {
-
-float remap(float x, float x1, float y1, float x2, float y2);
-float remapQuad(float x, float x1, float y1, float x2, float y2);
-float remapOutQuad(float x, float x1, float y1, float x2, float y2);
-float remapInOutQuad(float x, float x1, float y1, float x2, float y2);
-float remapCubic(float x, float x1, float y1, float x2, float y2);
-float remapOutCubic(float x, float x1, float y1, float x2, float y2);
-float remapExp(float x, float x1, float y1, float x2, float y2);
-float remapOutExp(float x, float x1, float y1, float x2, float y2);
-float clamp(float x, float min, float max);
-
-void stringCopy(char *dst, size_t maxStrLength, const char *src);
-void stringCopyLength(char *dst, size_t maxStrLength, const char *src, size_t length);
-
-void stringAppendString(char *str, size_t maxStrLength, const char *value);
-void stringAppendStringLength(char *str, size_t maxStrLength, const char *value, size_t length);
-
-void stringAppendInt(char *str, size_t maxStrLength, int value);
-void stringAppendUInt32(char *str, size_t maxStrLength, uint32_t value);
-void stringAppendInt64(char *str, size_t maxStrLength, int64_t value);
-void stringAppendUInt64(char *str, size_t maxStrLength, uint64_t value);
-void stringAppendFloat(char *str, size_t maxStrLength, float value);
-void stringAppendFloat(char *str, size_t maxStrLength, float value, int numDecimalPlaces);
-void stringAppendDouble(char *str, size_t maxStrLength, double value);
-void stringAppendDouble(char *str, size_t maxStrLength, double value, int numDecimalPlaces);
-
-void stringAppendVoltage(char *str, size_t maxStrLength, float value);
-void stringAppendCurrent(char *str, size_t maxStrLength, float value);
-void stringAppendPower(char *str, size_t maxStrLength, float value);
-void stringAppendDuration(char *str, size_t maxStrLength, float value);
-void stringAppendLoad(char *str, size_t maxStrLength, float value);
-
-uint32_t crc32(const uint8_t *message, size_t size);
-
-uint8_t toBCD(uint8_t bin);
-uint8_t fromBCD(uint8_t bcd);
-
-float roundPrec(float a, float prec);
-float floorPrec(float a, float prec);
-float ceilPrec(float a, float prec);
-
-bool isNaN(float x);
-bool isNaN(double x);
-
-bool isDigit(char ch);
-bool isHexDigit(char ch);
-bool isUperCaseLetter(char ch);
-
-char toHexDigit(int num);
-int fromHexDigit(char ch);
-
-bool pointInsideRect(int xPoint, int yPoint, int xRect, int yRect, int wRect, int hRect);
-
-void getParentDir(const char *path, char *parentDirPath);
-
-bool parseMacAddress(const char *macAddressStr, size_t macAddressStrLength, uint8_t *macAddress);
-
-int getIpAddressPartA(uint32_t ipAddress);
-void setIpAddressPartA(uint32_t *ipAddress, uint8_t value);
-
-int getIpAddressPartB(uint32_t ipAddress);
-void setIpAddressPartB(uint32_t *ipAddress, uint8_t value);
-
-int getIpAddressPartC(uint32_t ipAddress);
-void setIpAddressPartC(uint32_t *ipAddress, uint8_t value);
-
-int getIpAddressPartD(uint32_t ipAddress);
-void setIpAddressPartD(uint32_t *ipAddress, uint8_t value);
-
-void ipAddressToArray(uint32_t ipAddress, uint8_t *ipAddressArray);
-uint32_t arrayToIpAddress(uint8_t *ipAddressArray);
-
-uint32_t getIpAddress(uint8_t a, uint8_t b, uint8_t c, uint8_t d);
-
-bool parseIpAddress(const char *ipAddressStr, size_t ipAddressStrLength, uint32_t &ipAddress);
-void ipAddressToString(uint32_t ipAddress, char *ipAddressStr, size_t maxIpAddressStrLength);
-
-void macAddressToString(const uint8_t *macAddress, char *macAddressStr);
-
-void formatTimeZone(int16_t timeZone, char *text, int count);
-bool parseTimeZone(const char *timeZoneStr, size_t timeZoneLength, int16_t &timeZone);
-
-void replaceCharacter(char *str, char ch, char repl);
-
-int strcicmp(char const *a, char const *b);
-int strncicmp(char const *a, char const *b, int n);
-bool isStringEmpty(char const *a);
-bool startsWith(const char *str, const char *prefix);
-bool startsWithNoCase(const char *str, const char *prefix);
-bool endsWith(const char *str, const char *suffix);
-bool endsWithNoCase(const char *str, const char *suffix);
-
-void formatBytes(uint64_t bytes, char *text, int count);
-
-void getFileName(const char *path, char *fileName, unsigned fileNameSize);
-void getBaseFileName(const char *path, char *baseName, unsigned baseNameSize);
-
-typedef float (*EasingFuncType)(float x);
-extern EasingFuncType g_easingFuncs[];
-
-class Interval {
-public:
- // Returns true when called for the first time,
- // and later returns true after interval, interval * 2, interval * 3, ...
- // Interval is in milliseconds.
- bool test(uint32_t interval) {
- auto time = millis();
-
- if (lastTime == 0) {
- lastTime = time == 0 ? 1 : time;
- return true;
- }
-
- if (time >= lastTime + interval) {
- lastTime += ((uint32_t)(time - lastTime) / interval) * interval;
- return true;
- }
-
- return false;
- }
-
-private:
- uint32_t lastTime = 0;
-};
-
-template
-class MovingAverage {
-public:
- void operator()(T sample) {
- if (m_numSamples < N) {
- m_samples[m_numSamples++] = sample;
- m_total += sample;
- } else {
- T& oldest = m_samples[m_numSamples++ % N];
- m_total += sample - oldest;
- oldest = sample;
- }
- }
-
- operator T() const {
- if (m_numSamples < N) {
- return m_total / m_numSamples;
- } else {
- return m_total / N;
- }
- }
-
- void reset() {
- m_numSamples = 0;
- m_total = 0;
- }
-
-private:
- T m_samples[N];
- uint64_t m_numSamples{0};
- Total m_total{0};
-};
-
-} // namespace eez
-
-#ifdef EEZ_PLATFORM_SIMULATOR_WIN32
-char *strnstr(const char *s1, const char *s2, size_t n);
-#endif
diff --git a/Middlewares/eez/core/value_types.h b/Middlewares/eez/core/value_types.h
deleted file mode 100644
index c097440..0000000
--- a/Middlewares/eez/core/value_types.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2020-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#pragma once
-
-#include
-#include
-
-#define VALUE_TYPES \
- VALUE_TYPE(UNDEFINED) /* 0 */ \
- VALUE_TYPE(NULL) /* 1 */ \
- VALUE_TYPE(BOOLEAN) /* 2 */ \
- VALUE_TYPE(INT8) /* 3 */ \
- VALUE_TYPE(UINT8) /* 4 */ \
- VALUE_TYPE(INT16) /* 5 */ \
- VALUE_TYPE(UINT16) /* 6 */ \
- VALUE_TYPE(INT32) /* 7 */ \
- VALUE_TYPE(UINT32) /* 8 */ \
- VALUE_TYPE(INT64) /* 9 */ \
- VALUE_TYPE(UINT64) /* 10 */ \
- VALUE_TYPE(FLOAT) /* 11 */ \
- VALUE_TYPE(DOUBLE) /* 12 */ \
- VALUE_TYPE(STRING) /* 13 */ \
- VALUE_TYPE(ARRAY) /* 14 */ \
- VALUE_TYPE(STRING_REF) /* 15 */ \
- VALUE_TYPE(ARRAY_REF) /* 16 */ \
- VALUE_TYPE(BLOB_REF) /* 17 */ \
- VALUE_TYPE(STREAM) /* 18 */ \
- VALUE_TYPE(DATE) /* 19 */ \
- VALUE_TYPE(VERSIONED_STRING) /* 20 */ \
- VALUE_TYPE(VALUE_PTR) /* 21 */ \
- VALUE_TYPE(ARRAY_ELEMENT_VALUE) /* 22 */ \
- VALUE_TYPE(FLOW_OUTPUT) /* 23 */ \
- VALUE_TYPE(NATIVE_VARIABLE) /* 24 */ \
- VALUE_TYPE(RANGE) /* 25 */ \
- VALUE_TYPE(POINTER) /* 26 */ \
- VALUE_TYPE(ENUM) /* 27 */ \
- VALUE_TYPE(IP_ADDRESS) /* 28 */ \
- VALUE_TYPE(TIME_ZONE) /* 29 */ \
- VALUE_TYPE(YT_DATA_GET_VALUE_FUNCTION_POINTER) /* 30 */ \
- CUSTOM_VALUE_TYPES
-
-namespace eez {
-
-#define VALUE_TYPE(NAME) VALUE_TYPE_##NAME,
-enum ValueType {
- VALUE_TYPES
-};
-#undef VALUE_TYPE
-
-}
diff --git a/Middlewares/eez/flow/components.cpp b/Middlewares/eez/flow/components.cpp
deleted file mode 100644
index aa27e0c..0000000
--- a/Middlewares/eez/flow/components.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-#include
-
-#include
-
-#include
-#include
-#include
-#include
-#include
-
-#if defined(__EMSCRIPTEN__)
-#include
-#endif
-
-using namespace eez::gui;
-
-namespace eez {
-namespace flow {
-
-void executeStartComponent(FlowState *flowState, unsigned componentIndex);
-void executeEndComponent(FlowState *flowState, unsigned componentIndex);
-void executeInputComponent(FlowState *flowState, unsigned componentIndex);
-void executeOutputComponent(FlowState *flowState, unsigned componentIndex);
-void executeWatchVariableComponent(FlowState *flowState, unsigned componentIndex);
-void executeEvalExprComponent(FlowState *flowState, unsigned componentIndex);
-void executeSetVariableComponent(FlowState *flowState, unsigned componentIndex);
-void executeSwitchComponent(FlowState *flowState, unsigned componentIndex);
-void executeCompareComponent(FlowState *flowState, unsigned componentIndex);
-void executeIsTrueComponent(FlowState *flowState, unsigned componentIndex);
-void executeConstantComponent(FlowState *flowState, unsigned componentIndex);
-void executeLogComponent(FlowState *flowState, unsigned componentIndex);
-void executeCallActionComponent(FlowState *flowState, unsigned componentIndex);
-void executeDelayComponent(FlowState *flowState, unsigned componentIndex);
-void executeErrorComponent(FlowState *flowState, unsigned componentIndex);
-void executeCatchErrorComponent(FlowState *flowState, unsigned componentIndex);
-void executeCounterComponent(FlowState *flowState, unsigned componentIndex);
-void executeLoopComponent(FlowState *flowState, unsigned componentIndex);
-void executeShowPageComponent(FlowState *flowState, unsigned componentIndex);
-void executeShowMessageBoxComponent(FlowState *flowState, unsigned componentIndex);
-void executeShowKeyboardComponent(FlowState *flowState, unsigned componentIndex);
-void executeShowKeypadComponent(FlowState *flowState, unsigned componentIndex);
-void executeSelectLanguageComponent(FlowState *flowState, unsigned componentIndex);
-void executeSetPageDirectionComponent(FlowState *flowState, unsigned componentIndex);
-void executeAnimateComponent(FlowState *flowState, unsigned componentIndex);
-void executeNoopComponent(FlowState *flowState, unsigned componentIndex);
-void executeOnEventComponent(FlowState *flowState, unsigned componentIndex);
-
-void executeLayoutViewWidgetComponent(FlowState *flowState, unsigned componentIndex);
-void executeRollerWidgetComponent(FlowState *flowState, unsigned componentIndex);
-
-typedef void (*ExecuteComponentFunctionType)(FlowState *flowState, unsigned componentIndex);
-
-static ExecuteComponentFunctionType g_executeComponentFunctions[] = {
- executeStartComponent,
- executeEndComponent,
- executeInputComponent,
- executeOutputComponent,
- executeWatchVariableComponent,
- executeEvalExprComponent,
- executeSetVariableComponent,
- executeSwitchComponent,
- executeCompareComponent,
- executeIsTrueComponent,
- executeConstantComponent,
- executeLogComponent,
- executeCallActionComponent,
- executeDelayComponent,
- executeErrorComponent,
- executeCatchErrorComponent,
- executeCounterComponent, // COMPONENT_TYPE_COUNTER_ACTION
- executeLoopComponent,
- executeShowPageComponent,
- nullptr, // COMPONENT_TYPE_SCPIACTION
- executeShowMessageBoxComponent,
- executeShowKeyboardComponent,
- executeShowKeypadComponent,
- executeNoopComponent, // COMPONENT_TYPE_NOOP_ACTION
- nullptr, // COMPONENT_TYPE_COMMENT_ACTION
- executeSelectLanguageComponent, // COMPONENT_TYPE_SELECT_LANGUAGE_ACTION
- executeSetPageDirectionComponent, // COMPONENT_TYPE_SET_PAGE_DIRECTION_ACTION
- executeAnimateComponent, // COMPONENT_TYPE_ANIMATE_ACTION
- executeOnEventComponent, // COMPONENT_TYPE_ON_EVENT_ACTION
-};
-
-void registerComponent(ComponentTypes componentType, ExecuteComponentFunctionType executeComponentFunction) {
- if (componentType >= defs_v3::COMPONENT_TYPE_START_ACTION) {
- g_executeComponentFunctions[componentType - defs_v3::COMPONENT_TYPE_START_ACTION] = executeComponentFunction;
- }
-}
-
-void executeComponent(FlowState *flowState, unsigned componentIndex) {
- auto component = flowState->flow->components[componentIndex];
-
-#if defined(__EMSCRIPTEN__)
- if (component->type >= defs_v3::FIRST_DASHBOARD_COMPONENT_TYPE) {
- if (executeDashboardComponentHook) {
- executeDashboardComponentHook(component->type, getFlowStateIndex(flowState), componentIndex);
- return;
- }
- } else
-#endif // __EMSCRIPTEN__
- if (component->type >= defs_v3::COMPONENT_TYPE_START_ACTION) {
- auto executeComponentFunction = g_executeComponentFunctions[component->type - defs_v3::COMPONENT_TYPE_START_ACTION];
- if (executeComponentFunction != nullptr) {
- executeComponentFunction(flowState, componentIndex);
- return;
- }
- } else if (component->type < 1000) {
- if (component->type == defs_v3::COMPONENT_TYPE_LAYOUT_VIEW_WIDGET) {
- executeLayoutViewWidgetComponent(flowState, componentIndex);
- } else if (component->type == defs_v3::COMPONENT_TYPE_ROLLER_WIDGET) {
- executeRollerWidgetComponent(flowState, componentIndex);
- }
- return;
- }
-
- char errorMessage[100];
- snprintf(errorMessage, sizeof(errorMessage), "Unknown component at index = %d, type = %d\n", componentIndex, component->type);
- throwError(flowState, componentIndex, errorMessage);
-}
-
-} // namespace flow
-} // namespace eez
diff --git a/Middlewares/eez/flow/components.h b/Middlewares/eez/flow/components.h
deleted file mode 100644
index e7a18b1..0000000
--- a/Middlewares/eez/flow/components.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
-* EEZ Generic Firmware
-* Copyright (C) 2021-present, Envox d.o.o.
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#pragma once
-
-#include
-#include
-
-namespace eez {
-namespace flow {
-
-using defs_v3::ComponentTypes;
-
-typedef void (*ExecuteComponentFunctionType)(FlowState *flowState, unsigned componentIndex);
-void registerComponent(ComponentTypes componentType, ExecuteComponentFunctionType executeComponentFunction);
-
-void executeComponent(FlowState *flowState, unsigned componentIndex);
-
-} // flow
-} // eez
\ No newline at end of file
diff --git a/Middlewares/eez/flow/components/animate.cpp b/Middlewares/eez/flow/components/animate.cpp
deleted file mode 100644
index 41968a2..0000000
--- a/Middlewares/eez/flow/components/animate.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-#include
-#include
-#include
-#include
-
-#include
-
-using namespace eez::gui;
-
-namespace eez {
-namespace flow {
-
-struct AnimateComponenentExecutionState : public ComponenentExecutionState {
- float startPosition;
- float endPosition;
- float speed;
- uint32_t startTimestamp;
-};
-
-void executeAnimateComponent(FlowState *flowState, unsigned componentIndex) {
- auto state = (AnimateComponenentExecutionState *)flowState->componenentExecutionStates[componentIndex];
- if (!state) {
- Value fromValue;
- if (!evalProperty(flowState, componentIndex, defs_v3::ANIMATE_ACTION_COMPONENT_PROPERTY_FROM, fromValue, "Failed to evaluate From in Animate")) {
- return;
- }
-
- Value toValue;
- if (!evalProperty(flowState, componentIndex, defs_v3::ANIMATE_ACTION_COMPONENT_PROPERTY_TO, toValue, "Failed to evaluate To in Animate")) {
- return;
- }
-
- Value speedValue;
- if (!evalProperty(flowState, componentIndex, defs_v3::ANIMATE_ACTION_COMPONENT_PROPERTY_SPEED, speedValue, "Failed to evaluate Speed in Animate")) {
- return;
- }
-
- float from = fromValue.toFloat();
- float to = toValue.toFloat();
- float speed = speedValue.toFloat();
-
- if (speed == 0) {
- flowState->timelinePosition = to;
- onFlowStateTimelineChanged(flowState);
-
- propagateValueThroughSeqout(flowState, componentIndex);
- } else {
- state = allocateComponentExecutionState(flowState, componentIndex);
-
- state->startPosition = from;
- state->endPosition = to;
- state->speed = speed;
- state->startTimestamp = millis();
-
- if (!addToQueue(flowState, componentIndex, -1, -1, -1, true)) {
- throwError(flowState, componentIndex, "Execution queue is full\n");
- return;
- }
- }
- } else {
- float currentTime;
-
- if (state->startPosition < state->endPosition) {
- currentTime = state->startPosition + state->speed * (millis() - state->startTimestamp) / 1000.0f;
- if (currentTime >= state->endPosition) {
- currentTime = state->endPosition;
- }
- } else {
- currentTime = state->startPosition - state->speed * (millis() - state->startTimestamp) / 1000.0f;
- if (currentTime <= state->endPosition) {
- currentTime = state->endPosition;
- }
- }
-
- flowState->timelinePosition = currentTime;
- onFlowStateTimelineChanged(flowState);
-
- if (currentTime == state->endPosition) {
- deallocateComponentExecutionState(flowState, componentIndex);
- propagateValueThroughSeqout(flowState, componentIndex);
- } else {
- if (!addToQueue(flowState, componentIndex, -1, -1, -1, true)) {
- throwError(flowState, componentIndex, "Execution queue is full\n");
- return;
- }
- }
- }
-}
-
-} // namespace flow
-} // namespace eez
diff --git a/Middlewares/eez/flow/components/call_action.cpp b/Middlewares/eez/flow/components/call_action.cpp
deleted file mode 100644
index c1cd127..0000000
--- a/Middlewares/eez/flow/components/call_action.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-
-#include
-
-#include
-#include
-#include
-
-using namespace eez::gui;
-
-namespace eez {
-namespace flow {
-
-CallActionComponenentExecutionState::~CallActionComponenentExecutionState() {
- freeFlowState(flowState);
-}
-
-void executeCallAction(FlowState *flowState, unsigned componentIndex, int flowIndex) {
- if (flowIndex >= (int)flowState->flowDefinition->flows.count) {
- executeActionFunction(flowIndex - flowState->flowDefinition->flows.count);
- propagateValueThroughSeqout(flowState, componentIndex);
- return;
- }
-
- auto callActionComponenentExecutionState = (CallActionComponenentExecutionState *)flowState->componenentExecutionStates[componentIndex];
- if (callActionComponenentExecutionState) {
- if (canFreeFlowState(callActionComponenentExecutionState->flowState)) {
- freeFlowState(callActionComponenentExecutionState->flowState);
- } else {
- throwError(flowState, componentIndex, "CallAction is already running\n");
- return;
- }
- }
-
- FlowState *actionFlowState = initActionFlowState(flowIndex, flowState, componentIndex);
-
- if (canFreeFlowState(actionFlowState)) {
- freeFlowState(actionFlowState);
- propagateValueThroughSeqout(flowState, componentIndex);
- } else {
- callActionComponenentExecutionState = allocateComponentExecutionState(flowState, componentIndex);
- callActionComponenentExecutionState->flowState = actionFlowState;
- }
-}
-
-void executeCallActionComponent(FlowState *flowState, unsigned componentIndex) {
- auto component = (CallActionActionComponent *)flowState->flow->components[componentIndex];
-
- auto flowIndex = component->flowIndex;
- if (flowIndex < 0) {
- throwError(flowState, componentIndex, "Invalid action flow index in CallAction\n");
- return;
- }
-
- executeCallAction(flowState, componentIndex, flowIndex);
-}
-
-} // namespace flow
-} // namespace eez
diff --git a/Middlewares/eez/flow/components/call_action.h b/Middlewares/eez/flow/components/call_action.h
deleted file mode 100644
index 11c6cc6..0000000
--- a/Middlewares/eez/flow/components/call_action.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
-* EEZ Generic Firmware
-* Copyright (C) 2021-present, Envox d.o.o.
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#pragma once
-
-#include
-
-namespace eez {
-namespace flow {
-
-struct CallActionActionComponent : public Component {
- int16_t flowIndex;
- uint8_t inputsStartIndex;
- uint8_t outputsStartIndex;
-};
-
-typedef CallActionActionComponent LayoutViewWidgetComponent;
-
-struct CallActionComponenentExecutionState : public ComponenentExecutionState {
- FlowState *flowState;
-
- ~CallActionComponenentExecutionState();
-};
-
-} // flow
-} // eez
diff --git a/Middlewares/eez/flow/components/catch_error.cpp b/Middlewares/eez/flow/components/catch_error.cpp
deleted file mode 100644
index 2aacde3..0000000
--- a/Middlewares/eez/flow/components/catch_error.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-#include
-#include
-
-using namespace eez::gui;
-
-namespace eez {
-namespace flow {
-
-void executeCatchErrorComponent(FlowState *flowState, unsigned componentIndex) {
- auto catchErrorComponentExecutionState = (CatchErrorComponenentExecutionState *)flowState->componenentExecutionStates[componentIndex];
- propagateValue(flowState, componentIndex, 1, catchErrorComponentExecutionState->message);
- deallocateComponentExecutionState(flowState, componentIndex);
- propagateValueThroughSeqout(flowState, componentIndex);
-}
-
-} // namespace flow
-} // namespace eez
diff --git a/Middlewares/eez/flow/components/compare.cpp b/Middlewares/eez/flow/components/compare.cpp
deleted file mode 100644
index a815d7b..0000000
--- a/Middlewares/eez/flow/components/compare.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-#include
-#include
-
-using namespace eez::gui;
-
-namespace eez {
-namespace flow {
-
-struct CompareActionComponent : public Component {
- uint8_t conditionInstructions[1];
-};
-
-void executeCompareComponent(FlowState *flowState, unsigned componentIndex) {
- auto component = (CompareActionComponent *)flowState->flow->components[componentIndex];
-
- Value conditionValue;
- if (!evalExpression(flowState, componentIndex, component->conditionInstructions, conditionValue, "Failed to evaluate Condition in Compare")) {
- return;
- }
-
- int err;
- bool result = conditionValue.toBool(&err);
- if (err == 0) {
- if (result) {
- propagateValue(flowState, componentIndex, 1, Value(true, VALUE_TYPE_BOOLEAN));
- } else {
- propagateValue(flowState, componentIndex, 2, Value(false, VALUE_TYPE_BOOLEAN));
- }
- } else {
- throwError(flowState, componentIndex, "Failed to convert Value to boolean in IsTrue\n");
- return;
- }
-
- propagateValueThroughSeqout(flowState, componentIndex);
-}
-
-} // namespace flow
-} // namespace eez
diff --git a/Middlewares/eez/flow/components/constant.cpp b/Middlewares/eez/flow/components/constant.cpp
deleted file mode 100644
index 58fbb8a..0000000
--- a/Middlewares/eez/flow/components/constant.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-
-using namespace eez::gui;
-
-namespace eez {
-namespace flow {
-
-struct ConstantActionComponent : public Component {
- uint16_t valueIndex;
-};
-
-void executeConstantComponent(FlowState *flowState, unsigned componentIndex) {
- auto component = (ConstantActionComponent *)flowState->flow->components[componentIndex];
-
- auto &sourceValue = *flowState->flowDefinition->constants[component->valueIndex];
-
- propagateValue(flowState, componentIndex, 1, sourceValue);
-
- propagateValueThroughSeqout(flowState, componentIndex);
-}
-
-} // namespace flow
-} // namespace eez
diff --git a/Middlewares/eez/flow/components/counter.cpp b/Middlewares/eez/flow/components/counter.cpp
deleted file mode 100644
index 5b2e1fe..0000000
--- a/Middlewares/eez/flow/components/counter.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-#include
-#include
-#include
-
-using namespace eez::gui;
-
-namespace eez {
-namespace flow {
-
-struct CounterComponenentExecutionState : public ComponenentExecutionState {
- int counter;
-};
-
-void executeCounterComponent(FlowState *flowState, unsigned componentIndex) {
- auto counterComponenentExecutionState = (CounterComponenentExecutionState *)flowState->componenentExecutionStates[componentIndex];
-
- if (!counterComponenentExecutionState) {
- Value counterValue;
- if (!evalProperty(flowState, componentIndex, defs_v3::COUNTER_ACTION_COMPONENT_PROPERTY_COUNT_VALUE, counterValue, "Failed to evaluate countValue in Counter")) {
- return;
- }
-
- counterComponenentExecutionState = allocateComponentExecutionState(flowState, componentIndex);
- counterComponenentExecutionState->counter = counterValue.getInt();
- }
-
- if (counterComponenentExecutionState->counter > 0) {
- counterComponenentExecutionState->counter--;
- propagateValueThroughSeqout(flowState, componentIndex);
- } else {
- // done
- deallocateComponentExecutionState(flowState, componentIndex);
- propagateValue(flowState, componentIndex, 1);
- }
-}
-
-} // namespace flow
-} // namespace eez
diff --git a/Middlewares/eez/flow/components/delay.cpp b/Middlewares/eez/flow/components/delay.cpp
deleted file mode 100644
index f8b1b78..0000000
--- a/Middlewares/eez/flow/components/delay.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-#include
-
-#include
-#include
-#include
-#include
-
-using namespace eez::gui;
-
-namespace eez {
-namespace flow {
-
-struct DelayComponenentExecutionState : public ComponenentExecutionState {
- uint32_t waitUntil;
-};
-
-void executeDelayComponent(FlowState *flowState, unsigned componentIndex) {
- auto delayComponentExecutionState = (DelayComponenentExecutionState *)flowState->componenentExecutionStates[componentIndex];
-
- if (!delayComponentExecutionState) {
- Value value;
- if (!evalProperty(flowState, componentIndex, defs_v3::DELAY_ACTION_COMPONENT_PROPERTY_MILLISECONDS, value, "Failed to evaluate Milliseconds in Delay")) {
- return;
- }
-
- double milliseconds = value.toDouble();
- if (!isNaN(milliseconds)) {
- delayComponentExecutionState = allocateComponentExecutionState(flowState, componentIndex);
- delayComponentExecutionState->waitUntil = millis() + (uint32_t)floor(milliseconds);
- } else {
- throwError(flowState, componentIndex, "Invalid Milliseconds value in Delay\n");
- return;
- }
-
- if (!addToQueue(flowState, componentIndex, -1, -1, -1, true)) {
- throwError(flowState, componentIndex, "Execution queue is full\n");
- return;
- }
- } else {
- if (millis() >= delayComponentExecutionState->waitUntil) {
- deallocateComponentExecutionState(flowState, componentIndex);
- propagateValueThroughSeqout(flowState, componentIndex);
- } else {
- if (!addToQueue(flowState, componentIndex, -1, -1, -1, true)) {
- throwError(flowState, componentIndex, "Execution queue is full\n");
- return;
- }
- }
- }
-}
-
-} // namespace flow
-} // namespace eez
diff --git a/Middlewares/eez/flow/components/end.cpp b/Middlewares/eez/flow/components/end.cpp
deleted file mode 100644
index ccde926..0000000
--- a/Middlewares/eez/flow/components/end.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-#include
-#include
-
-using namespace eez::gui;
-
-namespace eez {
-namespace flow {
-
-void executeEndComponent(FlowState *flowState, unsigned componentIndex) {
- if (flowState->parentFlowState && flowState->isAction) {
- propagateValueThroughSeqout(flowState->parentFlowState, flowState->parentComponentIndex);
- } else {
- stopScriptHook();
- }
-}
-
-} // namespace flow
-} // namespace eez
diff --git a/Middlewares/eez/flow/components/error.cpp b/Middlewares/eez/flow/components/error.cpp
deleted file mode 100644
index 7f67e5f..0000000
--- a/Middlewares/eez/flow/components/error.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-#include
-#include
-
-using namespace eez::gui;
-
-namespace eez {
-namespace flow {
-
-void executeErrorComponent(FlowState *flowState, unsigned componentIndex) {
- Value expressionValue;
- if (!evalProperty(flowState, componentIndex, defs_v3::EVAL_EXPR_ACTION_COMPONENT_PROPERTY_EXPRESSION, expressionValue, "Failed to evaluate Message in Error")) {
- return;
- }
-
- throwError(flowState, componentIndex, expressionValue.getString());
-}
-
-} // namespace flow
-} // namespace eez
diff --git a/Middlewares/eez/flow/components/expr_eval.cpp b/Middlewares/eez/flow/components/expr_eval.cpp
deleted file mode 100644
index 523fc66..0000000
--- a/Middlewares/eez/flow/components/expr_eval.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-#include
-#include
-
-using namespace eez::gui;
-
-namespace eez {
-namespace flow {
-
-void executeEvalExprComponent(FlowState *flowState, unsigned componentIndex) {
- Value expressionValue;
- if (!evalProperty(flowState, componentIndex, defs_v3::EVAL_EXPR_ACTION_COMPONENT_PROPERTY_EXPRESSION, expressionValue, "Failed to evaluate Expression in EvalExpr")) {
- return;
- }
-
- propagateValue(flowState, componentIndex, 1, expressionValue);
-
- propagateValueThroughSeqout(flowState, componentIndex);
-}
-
-} // namespace flow
-} // namespace eez
diff --git a/Middlewares/eez/flow/components/input.cpp b/Middlewares/eez/flow/components/input.cpp
deleted file mode 100644
index c1241e2..0000000
--- a/Middlewares/eez/flow/components/input.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-
-#include
-#include
-#include
-
-using namespace eez::gui;
-
-namespace eez {
-namespace flow {
-
-bool getCallActionValue(FlowState *flowState, unsigned componentIndex, Value &value) {
- auto component = (InputActionComponent *)flowState->flow->components[componentIndex];
-
- if (!flowState->parentFlowState) {
- throwError(flowState, componentIndex, "No parentFlowState in Input\n");
- return false;
- }
-
- if (!flowState->parentComponent) {
- throwError(flowState, componentIndex, "No parentComponent in Input\n");
- return false;
- }
-
- auto callActionComponent = (CallActionActionComponent *)flowState->parentComponent;
-
- uint8_t parentComponentInputIndex = callActionComponent->inputsStartIndex + component->inputIndex;
- if (component->type == defs_v3::COMPONENT_TYPE_INPUT_ACTION) {
- parentComponentInputIndex = callActionComponent->inputsStartIndex + component->inputIndex;
- } else {
- parentComponentInputIndex = 0;
- }
-
- if (parentComponentInputIndex >= flowState->parentComponent->inputs.count) {
- throwError(flowState, componentIndex, "Invalid input index in Input\n");
- return false;
- }
-
- auto parentComponentInputs = flowState->parentComponent->inputs;
- auto flowInputIndex = parentComponentInputs[parentComponentInputIndex];
-
- auto parentFlow = flowState->flowDefinition->flows[flowState->parentFlowState->flowIndex];
- if (flowInputIndex >= parentFlow->componentInputs.count) {
- throwError(flowState, componentIndex, "Invalid input index of parent component in Input\n");
- return false;
- }
-
- value = flowState->parentFlowState->values[flowInputIndex];
- return true;
-}
-
-void executeInputComponent(FlowState *flowState, unsigned componentIndex) {
- Value value;
- if (getCallActionValue(flowState, componentIndex, value)) {
- auto inputActionComponentExecutionState = (InputActionComponentExecutionState *)flowState->componenentExecutionStates[componentIndex];
- if (!inputActionComponentExecutionState) {
- inputActionComponentExecutionState = allocateComponentExecutionState(flowState, componentIndex);
- }
-
- propagateValue(flowState, componentIndex, 0, value);
- inputActionComponentExecutionState->value = value;
- }
-}
-
-} // namespace flow
-} // namespace eez
diff --git a/Middlewares/eez/flow/components/input.h b/Middlewares/eez/flow/components/input.h
deleted file mode 100644
index deaa52e..0000000
--- a/Middlewares/eez/flow/components/input.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
-* EEZ Generic Firmware
-* Copyright (C) 2021-present, Envox d.o.o.
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#pragma once
-
-#include
-
-namespace eez {
-namespace flow {
-
-struct InputActionComponent : public Component {
- uint8_t inputIndex;
-};
-
-struct InputActionComponentExecutionState : public ComponenentExecutionState {
- Value value;
-};
-
-
-bool getCallActionValue(FlowState *flowState, unsigned componentIndex, Value &value);
-
-} // flow
-} // eez
diff --git a/Middlewares/eez/flow/components/is_true.cpp b/Middlewares/eez/flow/components/is_true.cpp
deleted file mode 100644
index eb26cc0..0000000
--- a/Middlewares/eez/flow/components/is_true.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-#include
-#include
-
-using namespace eez::gui;
-
-namespace eez {
-namespace flow {
-
-void executeIsTrueComponent(FlowState *flowState, unsigned componentIndex) {
- Value srcValue;
- if (!evalProperty(flowState, componentIndex, defs_v3::IS_TRUE_ACTION_COMPONENT_PROPERTY_VALUE, srcValue, "Failed to evaluate Value in IsTrue")) {
- return;
- }
-
- int err;
- bool result = srcValue.toBool(&err);
- if (err == 0) {
- if (result) {
- propagateValue(flowState, componentIndex, 1, Value(true, VALUE_TYPE_BOOLEAN));
- } else {
- propagateValue(flowState, componentIndex, 2, Value(false, VALUE_TYPE_BOOLEAN));
- }
- } else {
- throwError(flowState, componentIndex, "Failed to convert Value to boolean in IsTrue\n");
- return;
- }
-
- propagateValueThroughSeqout(flowState, componentIndex);
-}
-
-} // namespace flow
-} // namespace eez
diff --git a/Middlewares/eez/flow/components/layout_view_widget.cpp b/Middlewares/eez/flow/components/layout_view_widget.cpp
deleted file mode 100644
index f7c800c..0000000
--- a/Middlewares/eez/flow/components/layout_view_widget.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-using namespace eez::gui;
-
-namespace eez {
-namespace flow {
-
-struct LayoutViewWidgetExecutionState : public ComponenentExecutionState {
- FlowState *flowState;
-
- ~LayoutViewWidgetExecutionState() {
- freeFlowState(flowState);
- }
-};
-
-static LayoutViewWidgetExecutionState *createLayoutViewFlowState(FlowState *flowState, uint16_t layoutViewWidgetComponentIndex, int16_t pageId) {
- auto layoutViewFlowState = initPageFlowState(flowState->assets, pageId, flowState, layoutViewWidgetComponentIndex);
- auto layoutViewWidgetExecutionState = allocateComponentExecutionState(flowState, layoutViewWidgetComponentIndex);
- layoutViewWidgetExecutionState->flowState = layoutViewFlowState;
- return layoutViewWidgetExecutionState;
-}
-
-FlowState *getLayoutViewFlowState(FlowState *flowState, uint16_t layoutViewWidgetComponentIndex, int16_t pageId) {
- auto layoutViewWidgetExecutionState = (LayoutViewWidgetExecutionState *)flowState->componenentExecutionStates[layoutViewWidgetComponentIndex];
- if (!layoutViewWidgetExecutionState) {
- layoutViewWidgetExecutionState = createLayoutViewFlowState(flowState, layoutViewWidgetComponentIndex, pageId);
- }
-
- return layoutViewWidgetExecutionState->flowState;
-}
-
-void executeLayoutViewWidgetComponent(FlowState *flowState, unsigned componentIndex) {
- auto component = (CallActionActionComponent *)flowState->flow->components[componentIndex];
-
- auto layoutViewWidgetExecutionState = (LayoutViewWidgetExecutionState *)flowState->componenentExecutionStates[componentIndex];
- if (!layoutViewWidgetExecutionState) {
- createLayoutViewFlowState(flowState, componentIndex, component->flowIndex);
- } else {
- auto layoutViewFlowState = layoutViewWidgetExecutionState->flowState;
- for (
- unsigned layoutViewComponentIndex = 0;
- layoutViewComponentIndex < layoutViewFlowState->flow->components.count;
- layoutViewComponentIndex++
- ) {
- auto layoutViewComponent = layoutViewFlowState->flow->components[layoutViewComponentIndex];
- if (layoutViewComponent->type == defs_v3::COMPONENT_TYPE_INPUT_ACTION) {
- auto inputActionComponentExecutionState = (InputActionComponentExecutionState *)layoutViewFlowState->componenentExecutionStates[layoutViewComponentIndex];
- if (inputActionComponentExecutionState) {
- Value value;
- if (getCallActionValue(layoutViewFlowState, layoutViewComponentIndex, value)) {
- if (inputActionComponentExecutionState->value != value) {
- addToQueue(layoutViewWidgetExecutionState->flowState, layoutViewComponentIndex);
- inputActionComponentExecutionState->value = value;
- }
- } else {
- return;
- }
- }
- } else if (layoutViewComponent->type == defs_v3::COMPONENT_TYPE_START_ACTION) {
- Value value;
- if (getCallActionValue(layoutViewFlowState, layoutViewComponentIndex, value)) {
- if (value.getType() != VALUE_TYPE_UNDEFINED) {
- addToQueue(layoutViewWidgetExecutionState->flowState, layoutViewComponentIndex);
- }
- } else {
- return;
- }
- }
- }
- }
-}
-
-} // namespace flow
-} // namespace eez
diff --git a/Middlewares/eez/flow/components/log.cpp b/Middlewares/eez/flow/components/log.cpp
deleted file mode 100644
index cece2a0..0000000
--- a/Middlewares/eez/flow/components/log.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-
-#include
-#include
-#include
-#include
-
-using namespace eez::gui;
-
-namespace eez {
-namespace flow {
-
-void executeLogComponent(FlowState *flowState, unsigned componentIndex) {
- Value value;
- if (!evalProperty(flowState, componentIndex, defs_v3::LOG_ACTION_COMPONENT_PROPERTY_VALUE, value, "Failed to evaluate Message in Log")) {
- return;
- }
-
- Value strValue = value.toString(0x0f9812ee);
- const char *valueStr = strValue.getString();
- if (valueStr && *valueStr) {
- logInfo(flowState, componentIndex, valueStr);
- }
-
- propagateValueThroughSeqout(flowState, componentIndex);
-}
-
-} // namespace flow
-} // namespace eez
diff --git a/Middlewares/eez/flow/components/loop.cpp b/Middlewares/eez/flow/components/loop.cpp
deleted file mode 100644
index b7f941e..0000000
--- a/Middlewares/eez/flow/components/loop.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-#include
-#include
-#include
-
-using namespace eez::gui;
-
-namespace eez {
-namespace flow {
-
-struct LoopComponenentExecutionState : public ComponenentExecutionState {
- Value dstValue;
- Value toValue;
- Value currentValue;
-};
-
-void executeLoopComponent(FlowState *flowState, unsigned componentIndex) {
- auto component = flowState->flow->components[componentIndex];
-
- auto loopComponentExecutionState = (LoopComponenentExecutionState *)flowState->componenentExecutionStates[componentIndex];
-
- // restart loop if entered through "start" input
- static const unsigned START_INPUT_INDEX = 0;
- auto startInputIndex = component->inputs[START_INPUT_INDEX];
- if (flowState->values[startInputIndex].type != VALUE_TYPE_UNDEFINED) {
- if (loopComponentExecutionState) {
- deallocateComponentExecutionState(flowState, componentIndex);
- loopComponentExecutionState = nullptr;
- }
- } else {
- if (!loopComponentExecutionState) {
- return;
- }
- }
-
- Value stepValue;
- if (!evalProperty(flowState, componentIndex, defs_v3::LOOP_ACTION_COMPONENT_PROPERTY_STEP, stepValue, "Failed to evaluate Step in Loop")) {
- return;
- }
-
- if (!loopComponentExecutionState) {
- Value dstValue;
- if (!evalAssignableProperty(flowState, componentIndex, defs_v3::LOOP_ACTION_COMPONENT_PROPERTY_VARIABLE, dstValue, "Failed to evaluate Variable in Loop")) {
- return;
- }
-
- Value fromValue;
- if (!evalProperty(flowState, componentIndex, defs_v3::LOOP_ACTION_COMPONENT_PROPERTY_FROM, fromValue, "Failed to evaluate From in Loop")) {
- return;
- }
-
- Value toValue;
- if (!evalProperty(flowState, componentIndex, defs_v3::LOOP_ACTION_COMPONENT_PROPERTY_TO, toValue, "Failed to evaluate To in Loop")) {
- return;
- }
-
- loopComponentExecutionState = allocateComponentExecutionState(flowState, componentIndex);
- loopComponentExecutionState->dstValue = dstValue;
- loopComponentExecutionState->toValue = toValue;
-
- loopComponentExecutionState->currentValue = fromValue;
- } else {
- loopComponentExecutionState->currentValue = op_add(loopComponentExecutionState->currentValue, stepValue);
- }
-
- bool condition;
- if (stepValue.getInt() > 0) {
- condition = op_great(loopComponentExecutionState->currentValue, loopComponentExecutionState->toValue).toBool();
- } else {
- condition = op_less(loopComponentExecutionState->currentValue, loopComponentExecutionState->toValue).toBool();
- }
-
- if (condition) {
- // done
- deallocateComponentExecutionState(flowState, componentIndex);
- propagateValue(flowState, componentIndex, component->outputs.count - 1);
- } else {
- assignValue(flowState, componentIndex, loopComponentExecutionState->dstValue, loopComponentExecutionState->currentValue);
- propagateValueThroughSeqout(flowState, componentIndex);
- }
-}
-
-} // namespace flow
-} // namespace eez
diff --git a/Middlewares/eez/flow/components/noop.cpp b/Middlewares/eez/flow/components/noop.cpp
deleted file mode 100644
index a5bde41..0000000
--- a/Middlewares/eez/flow/components/noop.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-
-#include
-#include
-#include
-#include
-
-using namespace eez::gui;
-
-namespace eez {
-namespace flow {
-
-void executeNoopComponent(FlowState *flowState, unsigned componentIndex) {
- propagateValueThroughSeqout(flowState, componentIndex);
-}
-
-} // namespace flow
-} // namespace eez
diff --git a/Middlewares/eez/flow/components/on_event.cpp b/Middlewares/eez/flow/components/on_event.cpp
deleted file mode 100644
index 484453c..0000000
--- a/Middlewares/eez/flow/components/on_event.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-
-using namespace eez::gui;
-
-namespace eez {
-namespace flow {
-
-void executeOnEventComponent(FlowState *flowState, unsigned componentIndex) {
- propagateValueThroughSeqout(flowState, componentIndex);
-}
-
-} // namespace flow
-} // namespace eez
diff --git a/Middlewares/eez/flow/components/output.cpp b/Middlewares/eez/flow/components/output.cpp
deleted file mode 100644
index 1786de1..0000000
--- a/Middlewares/eez/flow/components/output.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-#include
-using namespace eez::gui;
-
-namespace eez {
-namespace flow {
-
-struct OutputActionComponent : public Component {
- uint8_t outputIndex;
-};
-
-void executeOutputComponent(FlowState *flowState, unsigned componentIndex) {
- auto component = (OutputActionComponent *)flowState->flow->components[componentIndex];
-
- if (!flowState->parentFlowState) {
- throwError(flowState, componentIndex, "No parentFlowState in Output\n");
- return;
- }
-
- if (!flowState->parentComponent) {
- throwError(flowState, componentIndex, "No parentComponent in Output\n");
- return;
- }
-
- auto inputIndex = component->inputs[0];
- if (inputIndex >= flowState->flow->componentInputs.count) {
- throwError(flowState, componentIndex, "Invalid input index in Output\n");
- return;
- }
-
- auto value = flowState->values[inputIndex];
-
- auto callActionComponent = (CallActionActionComponent *)flowState->parentComponent;
-
- uint8_t parentComponentOutputIndex = callActionComponent->outputsStartIndex + component->outputIndex;
-
- if (parentComponentOutputIndex >= flowState->parentComponent->outputs.count) {
- throwError(flowState, componentIndex, "Output action component, invalid output index\n");
- return;
- }
-
- propagateValue(flowState->parentFlowState, flowState->parentComponentIndex, parentComponentOutputIndex, value);
-}
-
-} // namespace flow
-} // namespace eez
diff --git a/Middlewares/eez/flow/components/roller_widget.cpp b/Middlewares/eez/flow/components/roller_widget.cpp
deleted file mode 100644
index afba520..0000000
--- a/Middlewares/eez/flow/components/roller_widget.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-#include
-#include
-
-using namespace eez::gui;
-
-namespace eez {
-namespace flow {
-
-void executeRollerWidgetComponent(FlowState *flowState, unsigned componentIndex) {
- auto component = flowState->flow->components[componentIndex];
-
- static const unsigned START_INPUT_INDEX = 0;
- auto startInputIndex = component->inputs[START_INPUT_INDEX];
- if (flowState->values[startInputIndex].type != VALUE_TYPE_UNDEFINED) {
- auto executionState = (RollerWidgetComponenentExecutionState *)flowState->componenentExecutionStates[componentIndex];
- if (!executionState) {
- executionState = allocateComponentExecutionState(flowState, componentIndex);
- }
- executionState->clear = true;
- }
-}
-
-} // namespace flow
-} // namespace eez
diff --git a/Middlewares/eez/flow/components/roller_widget.h b/Middlewares/eez/flow/components/roller_widget.h
deleted file mode 100644
index 65ae3e2..0000000
--- a/Middlewares/eez/flow/components/roller_widget.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
-* EEZ Generic Firmware
-* Copyright (C) 2021-present, Envox d.o.o.
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#pragma once
-
-#include
-
-namespace eez {
-namespace flow {
-
-struct RollerWidgetComponenentExecutionState : public ComponenentExecutionState {
- bool clear;
-};
-
-} // flow
-} // eez
\ No newline at end of file
diff --git a/Middlewares/eez/flow/components/select_language.cpp b/Middlewares/eez/flow/components/select_language.cpp
deleted file mode 100644
index 4132f6a..0000000
--- a/Middlewares/eez/flow/components/select_language.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-#include
-#include
-#include
-
-using namespace eez::gui;
-
-namespace eez {
-namespace flow {
-
-void executeSelectLanguageComponent(FlowState *flowState, unsigned componentIndex) {
- Value languageValue;
- if (!evalProperty(flowState, componentIndex, defs_v3::SELECT_LANGUAGE_ACTION_COMPONENT_PROPERTY_LANGUAGE, languageValue, "Failed to evaluate Language in SelectLanguage")) {
- return;
- }
-
- const char *language = languageValue.getString();
-
- auto languages = flowState->assets->languages;
-
- for (uint32_t languageIndex = 0; languageIndex < languages.count; languageIndex++) {
- if (strcmp(languages[languageIndex]->languageID, language) == 0) {
- g_selectedLanguage = languageIndex;
- propagateValueThroughSeqout(flowState, componentIndex);
- return;
- }
- }
-
- char message[256];
- snprintf(message, sizeof(message), "Unknown language %s", language);
- throwError(flowState, componentIndex, message);
-}
-
-} // namespace flow
-} // namespace eez
diff --git a/Middlewares/eez/flow/components/set_page_direction.cpp b/Middlewares/eez/flow/components/set_page_direction.cpp
deleted file mode 100644
index f292072..0000000
--- a/Middlewares/eez/flow/components/set_page_direction.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-#include
-#include
-#include
-
-#include
-
-using namespace eez::gui;
-
-namespace eez {
-namespace flow {
-
-#define PAGE_DIRECTION_LTR 0
-#define PAGE_DIRECTION_RTL 1
-
-struct SetPageDirectionComponent : public Component {
- uint8_t direction;
-};
-
-void executeSetPageDirectionComponent(FlowState *flowState, unsigned componentIndex) {
- auto component = (SetPageDirectionComponent *)flowState->flow->components[componentIndex];
-
- gui::g_isRTL = component->direction == PAGE_DIRECTION_RTL;
-
- gui::refreshScreen();
-
- propagateValueThroughSeqout(flowState, componentIndex);
-}
-
-} // namespace flow
-} // namespace eez
diff --git a/Middlewares/eez/flow/components/set_variable.cpp b/Middlewares/eez/flow/components/set_variable.cpp
deleted file mode 100644
index 3dfaeef..0000000
--- a/Middlewares/eez/flow/components/set_variable.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-#include
-#include
-#include
-
-using namespace eez::gui;
-
-namespace eez {
-namespace flow {
-
-void executeSetVariableComponent(FlowState *flowState, unsigned componentIndex) {
- auto component = (SetVariableActionComponent *)flowState->flow->components[componentIndex];
-
- for (uint32_t entryIndex = 0; entryIndex < component->entries.count; entryIndex++) {
- auto entry = component->entries[entryIndex];
-
- char strErrorMessage[256];
- snprintf(strErrorMessage, sizeof(strErrorMessage), "Failed to evaluate Variable no. %d in SetVariable", (int)(entryIndex + 1));
-
- Value dstValue;
- if (!evalAssignableExpression(flowState, componentIndex, entry->variable, dstValue, strErrorMessage)) {
- return;
- }
-
- snprintf(strErrorMessage, sizeof(strErrorMessage), "Failed to evaluate Value no. %d in SetVariable", (int)(entryIndex + 1));
-
- Value srcValue;
- if (!evalExpression(flowState, componentIndex, entry->value, srcValue, strErrorMessage)) {
- return;
- }
-
- assignValue(flowState, componentIndex, dstValue, srcValue);
- }
-
- propagateValueThroughSeqout(flowState, componentIndex);
-}
-
-} // namespace flow
-} // namespace eez
diff --git a/Middlewares/eez/flow/components/set_variable.h b/Middlewares/eez/flow/components/set_variable.h
deleted file mode 100644
index 70f7deb..0000000
--- a/Middlewares/eez/flow/components/set_variable.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
-* EEZ Generic Firmware
-* Copyright (C) 2022-present, Envox d.o.o.
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#pragma once
-
-#include
-
-namespace eez {
-namespace flow {
-
-struct SetVariableEntry {
- eez::gui::AssetsPtr variable;
- eez::gui::AssetsPtr value;
-};
-
-struct SetVariableActionComponent : public Component {
- eez::gui::ListOfAssetsPtr entries;
-};
-
-} // flow
-} // eez
diff --git a/Middlewares/eez/flow/components/show_keyboard.cpp b/Middlewares/eez/flow/components/show_keyboard.cpp
deleted file mode 100644
index 85a8aa8..0000000
--- a/Middlewares/eez/flow/components/show_keyboard.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-
-namespace eez {
-namespace flow {
-
-struct ShowKeyboardActionComponent : public Component {
- uint8_t password;
-};
-
-void executeShowKeyboardComponent(FlowState *flowState, unsigned componentIndex) {
- auto component = (ShowKeyboardActionComponent *)flowState->flow->components[componentIndex];
-
- Value labelValue;
- if (!evalProperty(flowState, componentIndex, defs_v3::SHOW_KEYBOARD_ACTION_COMPONENT_PROPERTY_LABEL, labelValue, "Failed to evaluate Label in ShowKeyboard")) {
- return;
- }
-
- Value initialTextValue;
- if (!evalProperty(flowState, componentIndex, defs_v3::SHOW_KEYBOARD_ACTION_COMPONENT_PROPERTY_INITAL_TEXT, initialTextValue, "Failed to evaluate InitialText in ShowKeyboard")) {
- return;
- }
-
- Value minCharsValue;
- if (!evalProperty(flowState, componentIndex, defs_v3::SHOW_KEYBOARD_ACTION_COMPONENT_PROPERTY_MIN_CHARS, minCharsValue, "Failed to evaluate MinChars in ShowKeyboard")) {
- return;
- }
-
- Value maxCharsValue;
- if (!evalProperty(flowState, componentIndex, defs_v3::SHOW_KEYBOARD_ACTION_COMPONENT_PROPERTY_MAX_CHARS, maxCharsValue, "Failed to evaluate MaxChars in ShowKeyboard")) {
- return;
- }
-
- static FlowState *g_showKeyboardFlowState;
- static unsigned g_showKeyboardComponentIndex;
-
- g_showKeyboardFlowState = flowState;
- g_showKeyboardComponentIndex = componentIndex;
-
- startAsyncExecution(flowState, componentIndex);
-
- auto onOk = [](char *value) {
- propagateValue(g_showKeyboardFlowState, g_showKeyboardComponentIndex, 0, Value::makeStringRef(value, -1, 0x87d32fe2));
- getAppContextFromId(APP_CONTEXT_ID_DEVICE)->popPage();
- endAsyncExecution(g_showKeyboardFlowState, g_showKeyboardComponentIndex);
- };
-
- auto onCancel = []() {
- propagateValue(g_showKeyboardFlowState, g_showKeyboardComponentIndex, 1, Value());
- getAppContextFromId(APP_CONTEXT_ID_DEVICE)->popPage();
- endAsyncExecution(g_showKeyboardFlowState, g_showKeyboardComponentIndex);
- };
-
- const char *label = labelValue.getString();
- if (label && *label) {
- labelValue = op_add(labelValue, Value(": "));
- }
-
- showKeyboardHook(labelValue, initialTextValue, minCharsValue, maxCharsValue, component->password, onOk, onCancel);
-}
-
-} // namespace flow
-} // namespace eez
diff --git a/Middlewares/eez/flow/components/show_keypad.cpp b/Middlewares/eez/flow/components/show_keypad.cpp
deleted file mode 100644
index 6224440..0000000
--- a/Middlewares/eez/flow/components/show_keypad.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-
-namespace eez {
-namespace flow {
-
-struct ShowKeyboardActionComponent : public Component {
- uint8_t password;
-};
-
-void executeShowKeypadComponent(FlowState *flowState, unsigned componentIndex) {
- Value labelValue;
- if (!evalProperty(flowState, componentIndex, defs_v3::SHOW_KEYBOARD_ACTION_COMPONENT_PROPERTY_LABEL, labelValue, "Failed to evaluate Label in ShowKeypad")) {
- return;
- }
-
- Value initialValue;
- if (!evalProperty(flowState, componentIndex, defs_v3::SHOW_KEYPAD_ACTION_COMPONENT_PROPERTY_INITAL_VALUE, initialValue, "Failed to evaluate InitialValue in ShowKeypad")) {
- return;
- }
-
- Value minValue;
- if (!evalProperty(flowState, componentIndex, defs_v3::SHOW_KEYPAD_ACTION_COMPONENT_PROPERTY_MIN, minValue, "Failed to evaluate Min in ShowKeypad")) {
- return;
- }
-
- Value maxValue;
- if (!evalProperty(flowState, componentIndex, defs_v3::SHOW_KEYPAD_ACTION_COMPONENT_PROPERTY_MAX, maxValue, "Failed to evaluate Max in ShowKeypad")) {
- return;
- }
-
- Value unitValue;
- if (!evalProperty(flowState, componentIndex, defs_v3::SHOW_KEYPAD_ACTION_COMPONENT_PROPERTY_UNIT, unitValue, "Failed to evaluate Unit in ShowKeypad")) {
- return;
- }
-
- static FlowState *g_showKeyboardFlowState;
- static unsigned g_showKeyboardComponentIndex;
-
- g_showKeyboardFlowState = flowState;
- g_showKeyboardComponentIndex = componentIndex;
-
- startAsyncExecution(flowState, componentIndex);
-
- auto onOk = [](float value) {
- Value precisionValue;
- if (!evalProperty(g_showKeyboardFlowState, g_showKeyboardComponentIndex, defs_v3::SHOW_KEYPAD_ACTION_COMPONENT_PROPERTY_PRECISION, precisionValue, "Failed to evaluate Precision in ShowKeypad")) {
- return;
- }
-
- float precision = precisionValue.toFloat();
-
- Value unitValue;
- if (!evalProperty(g_showKeyboardFlowState, g_showKeyboardComponentIndex, defs_v3::SHOW_KEYPAD_ACTION_COMPONENT_PROPERTY_UNIT, unitValue, "Failed to evaluate Unit in ShowKeypad")) {
- return;
- }
-
- Unit unit = getUnitFromName(unitValue.getString());
-
- value = roundPrec(value, precision) / getUnitFactor(unit);
-
- propagateValue(g_showKeyboardFlowState, g_showKeyboardComponentIndex, 0, Value(value, VALUE_TYPE_FLOAT));
- getAppContextFromId(APP_CONTEXT_ID_DEVICE)->popPage();
- endAsyncExecution(g_showKeyboardFlowState, g_showKeyboardComponentIndex);
- };
-
- auto onCancel = []() {
- propagateValue(g_showKeyboardFlowState, g_showKeyboardComponentIndex, 1, Value());
- getAppContextFromId(APP_CONTEXT_ID_DEVICE)->popPage();
- endAsyncExecution(g_showKeyboardFlowState, g_showKeyboardComponentIndex);
- };
-
- const char *label = labelValue.getString();
- if (label && *label) {
- labelValue = op_add(labelValue, Value(": "));
- }
-
- Unit unit = getUnitFromName(unitValue.getString());
-
- showKeypadHook(labelValue, initialValue, minValue, maxValue, unit, onOk, onCancel);
-}
-
-} // namespace flow
-} // namespace eez
diff --git a/Middlewares/eez/flow/components/show_message_box.cpp b/Middlewares/eez/flow/components/show_message_box.cpp
deleted file mode 100644
index dfc0446..0000000
--- a/Middlewares/eez/flow/components/show_message_box.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-#include
-#include
-#include
-
-#include
-
-namespace eez {
-namespace flow {
-
-const uint8_t MESSAGE_BOX_TYPE_INFO = 1;
-const uint8_t MESSAGE_BOX_TYPE_ERROR = 2;
-
-struct ShowMessagePageActionComponent : public Component {
- uint8_t type;
-};
-
-void executeShowMessageBoxComponent(FlowState *flowState, unsigned componentIndex) {
- auto component = (ShowMessagePageActionComponent *)flowState->flow->components[componentIndex];
-
- Value messageValue;
- if (!evalProperty(flowState, componentIndex, defs_v3::SHOW_MESSAGE_BOX_ACTION_COMPONENT_PROPERTY_MESSAGE, messageValue, "Failed to evaluate Message in ShowMessageBox")) {
- return;
- }
-
- if (component->type == MESSAGE_BOX_TYPE_INFO) {
- getAppContextFromId(APP_CONTEXT_ID_DEVICE)->infoMessage(messageValue);
- } else if (component->type == MESSAGE_BOX_TYPE_ERROR) {
- getAppContextFromId(APP_CONTEXT_ID_DEVICE)->errorMessage(messageValue);
- }
-}
-
-} // namespace flow
-} // namespace eez
diff --git a/Middlewares/eez/flow/components/show_page.cpp b/Middlewares/eez/flow/components/show_page.cpp
deleted file mode 100644
index b291525..0000000
--- a/Middlewares/eez/flow/components/show_page.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-#include
-#include
-#include
-
-namespace eez {
-namespace flow {
-
-struct ShowPageActionComponent : public Component {
- int16_t page;
-};
-
-void executeShowPageComponent(FlowState *flowState, unsigned componentIndex) {
- auto component = (ShowPageActionComponent *)flowState->flow->components[componentIndex];
-
- replacePageHook(component->page);
-
- propagateValueThroughSeqout(flowState, componentIndex);
-}
-
-} // namespace flow
-} // namespace eez
diff --git a/Middlewares/eez/flow/components/start.cpp b/Middlewares/eez/flow/components/start.cpp
deleted file mode 100644
index c31fb00..0000000
--- a/Middlewares/eez/flow/components/start.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-
-using namespace eez::gui;
-
-namespace eez {
-namespace flow {
-
-void executeStartComponent(FlowState *flowState, unsigned componentIndex) {
- propagateValueThroughSeqout(flowState, componentIndex);
-}
-
-} // namespace flow
-} // namespace eez
diff --git a/Middlewares/eez/flow/components/switch.cpp b/Middlewares/eez/flow/components/switch.cpp
deleted file mode 100644
index 5614dbd..0000000
--- a/Middlewares/eez/flow/components/switch.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-#include
-#include
-
-#include
-
-namespace eez {
-namespace flow {
-
-void executeSwitchComponent(FlowState *flowState, unsigned componentIndex) {
- auto component = (SwitchActionComponent *)flowState->flow->components[componentIndex];
-
- for (uint32_t testIndex = 0; testIndex < component->tests.count; testIndex++) {
- auto test = component->tests[testIndex];
-
- char strMessage[256];
- snprintf(strMessage, sizeof(strMessage), "Failed to evaluate test condition no. %d in Switch", (int)(testIndex + 1));
-
- Value conditionValue;
- if (!evalExpression(flowState, componentIndex, test->conditionInstructions, conditionValue, strMessage)) {
- return;
- }
-
- int err;
- bool result = conditionValue.toBool(&err);
- if (err == 0) {
- if (result) {
- propagateValue(flowState, componentIndex, test->outputIndex);
- break;
- }
- } else {
- char strMessage[256];
- snprintf(strMessage, sizeof(strMessage), "Failed to convert Value no. %d to boolean in Switch\n", (int)(testIndex + 1));
- throwError(flowState, componentIndex, strMessage);
- return;
- }
- }
-
- propagateValueThroughSeqout(flowState, componentIndex);
-}
-
-} // namespace flow
-} // namespace eez
diff --git a/Middlewares/eez/flow/components/switch.h b/Middlewares/eez/flow/components/switch.h
deleted file mode 100644
index 1a30767..0000000
--- a/Middlewares/eez/flow/components/switch.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
-* EEZ Generic Firmware
-* Copyright (C) 2022-present, Envox d.o.o.
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#pragma once
-
-#include
-
-namespace eez {
-namespace flow {
-
-struct SwitchTest {
- uint8_t outputIndex;
- uint8_t conditionInstructions[1];
-};
-
-struct SwitchActionComponent : public Component {
- eez::gui::ListOfAssetsPtr tests;
-};
-
-} // flow
-} // eez
\ No newline at end of file
diff --git a/Middlewares/eez/flow/components/watch_variable.cpp b/Middlewares/eez/flow/components/watch_variable.cpp
deleted file mode 100644
index d700c51..0000000
--- a/Middlewares/eez/flow/components/watch_variable.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-
-#include
-#include
-
-#include
-#include
-#include
-#include
-
-using namespace eez::gui;
-
-namespace eez {
-namespace flow {
-
-struct WatchVariableComponenentExecutionState : public ComponenentExecutionState {
- Value value;
-};
-
-void executeWatchVariableComponent(FlowState *flowState, unsigned componentIndex) {
- auto watchVariableComponentExecutionState = (WatchVariableComponenentExecutionState *)flowState->componenentExecutionStates[componentIndex];
-
- Value value;
- if (!evalProperty(flowState, componentIndex, defs_v3::WATCH_VARIABLE_ACTION_COMPONENT_PROPERTY_VARIABLE, value, "Failed to evaluate Variable in WatchVariable")) {
- return;
- }
-
- if (!watchVariableComponentExecutionState) {
- watchVariableComponentExecutionState = allocateComponentExecutionState(flowState, componentIndex);
- watchVariableComponentExecutionState->value = value;
-
- propagateValue(flowState, componentIndex, 1, value);
-
- if (!addToQueue(flowState, componentIndex, -1, -1, -1, true)) {
- throwError(flowState, componentIndex, "Execution queue is full\n");
- return;
- }
- } else {
- if (value != watchVariableComponentExecutionState->value) {
- watchVariableComponentExecutionState->value = value;
- propagateValue(flowState, componentIndex, 1, value);
- }
-
- if (canFreeFlowState(flowState, false)) {
- deallocateComponentExecutionState(flowState, componentIndex);
- } else {
- if (!addToQueue(flowState, componentIndex, -1, -1, -1, true)) {
- throwError(flowState, componentIndex, "Execution queue is full\n");
- return;
- }
- }
- }
-}
-
-} // namespace flow
-} // namespace eez
diff --git a/Middlewares/eez/flow/dashboard_api.cpp b/Middlewares/eez/flow/dashboard_api.cpp
deleted file mode 100644
index d6d12a1..0000000
--- a/Middlewares/eez/flow/dashboard_api.cpp
+++ /dev/null
@@ -1,378 +0,0 @@
-
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#if defined(__EMSCRIPTEN__)
-
-#include
-
-#include
-#include
-
-#include
-#include
-#include
-
-using namespace eez;
-using namespace eez::gui;
-using namespace eez::flow;
-
-namespace eez {
-namespace flow {
-
-int getFlowStateIndex(FlowState *flowState) {
- return (int)((uint8_t *)flowState - ALLOC_BUFFER);
-}
-
-struct DashboardComponentExecutionState : public ComponenentExecutionState {
- ~DashboardComponentExecutionState() {
- EM_ASM({
- freeComponentExecutionState($0, $1);
- }, g_wasmModuleId, state);
- }
- int32_t state;
-};
-
-} // flow
-} // eez
-
-static inline FlowState *getFlowState(int flowStateIndex) {
- return (FlowState *)(ALLOC_BUFFER + flowStateIndex);
-}
-
-static void updateArrayValue(ArrayValue *arrayValue1, ArrayValue *arrayValue2) {
- for (uint32_t i = 0; i < arrayValue1->arraySize; i++) {
- if (arrayValue1->values[i].getType() == VALUE_TYPE_ARRAY || arrayValue1->values[i].getType() == VALUE_TYPE_ARRAY_REF) {
- updateArrayValue(arrayValue1->values[i].getArray(), arrayValue2->values[i].getArray());
- } else {
- arrayValue1->values[i] = arrayValue2->values[i];
- }
- }
-}
-
-EM_PORT_API(Value *) createUndefinedValue() {
- auto pValue = ObjectAllocator::allocate(0x2e821285);
- *pValue = Value(0, VALUE_TYPE_UNDEFINED);
- return pValue;
-}
-
-EM_PORT_API(Value *) createNullValue() {
- auto pValue = ObjectAllocator::allocate(0x69debded);
- *pValue = Value(0, VALUE_TYPE_NULL);
- return pValue;
-}
-
-EM_PORT_API(Value *) createIntValue(int value) {
- auto pValue = ObjectAllocator::allocate(0x20ea356c);
- *pValue = Value(value, VALUE_TYPE_INT32);
- return pValue;
-}
-
-EM_PORT_API(Value *) createDoubleValue(double value) {
- auto pValue = ObjectAllocator::allocate(0xecfb69a9);
- *pValue = Value(value, VALUE_TYPE_DOUBLE);
- return pValue;
-}
-
-EM_PORT_API(Value *) createBooleanValue(int value) {
- auto pValue = ObjectAllocator::allocate(0x76071378);
- *pValue = Value(value, VALUE_TYPE_BOOLEAN);
- return pValue;
-}
-
-EM_PORT_API(Value *) createStringValue(const char *value) {
- auto pValue = ObjectAllocator::allocate(0x0a8a7ed1);
- Value stringValue = Value::makeStringRef(value, strlen(value), 0x5b1e51d7);
- *pValue = stringValue;
- return pValue;
-}
-
-EM_PORT_API(Value *) createArrayValue(int arraySize, int arrayType) {
- Value value = Value::makeArrayRef(arraySize, arrayType, 0xeabb7edc);
- auto pValue = ObjectAllocator::allocate(0xbab14c6a);
- if (pValue) {
- *pValue = value;
- }
- return pValue;
-}
-
-EM_PORT_API(Value *) createStreamValue(double value) {
- auto pValue = ObjectAllocator::allocate(0x53a2e660);
- *pValue = Value(value, VALUE_TYPE_STREAM);
- return pValue;
-}
-
-EM_PORT_API(Value *) createDateValue(double value) {
- auto pValue = ObjectAllocator::allocate(0x90b7ce70);
- *pValue = Value(value, VALUE_TYPE_DATE);
- return pValue;
-}
-
-EM_PORT_API(void) arrayValueSetElementValue(Value *arrayValuePtr, int elementIndex, Value *valuePtr) {
- auto array = arrayValuePtr->getArray();
- array->values[elementIndex] = *valuePtr;
-}
-
-EM_PORT_API(void) valueFree(Value *valuePtr) {
- ObjectAllocator::deallocate(valuePtr);
-}
-
-EM_PORT_API(void) setGlobalVariable(int globalVariableIndex, Value *valuePtr) {
- auto flowDefinition = static_cast(g_mainAssets->flowDefinition);
- Value *globalVariableValuePtr = flowDefinition->globalVariables[globalVariableIndex];
- *globalVariableValuePtr = *valuePtr;
-}
-
-EM_PORT_API(void) updateGlobalVariable(int globalVariableIndex, Value *valuePtr) {
- auto flowDefinition = static_cast(g_mainAssets->flowDefinition);
- Value *globalVariableValuePtr = flowDefinition->globalVariables[globalVariableIndex];
- updateArrayValue(globalVariableValuePtr->getArray(), valuePtr->getArray());
-}
-
-EM_PORT_API(int) getFlowIndex(int flowStateIndex) {
- auto flowState = getFlowState(flowStateIndex);
- return flowState->flowIndex;
-}
-
-EM_PORT_API(int) getComponentExecutionState(int flowStateIndex, int componentIndex) {
- auto flowState = getFlowState(flowStateIndex);
- auto component = flowState->flow->components[componentIndex];
- auto executionState = (DashboardComponentExecutionState *)flowState->componenentExecutionStates[componentIndex];
- if (executionState) {
- return executionState->state;
- }
- return -1;
-}
-
-EM_PORT_API(void) setComponentExecutionState(int flowStateIndex, int componentIndex, int state) {
- auto flowState = getFlowState(flowStateIndex);
- auto component = flowState->flow->components[componentIndex];
- auto executionState = (DashboardComponentExecutionState *)flowState->componenentExecutionStates[componentIndex];
- if (executionState) {
- if (state != -1) {
- executionState->state = state;
- } else {
- deallocateComponentExecutionState(flowState, componentIndex);
- }
- } else {
- if (state != -1) {
- executionState = allocateComponentExecutionState(flowState, componentIndex);
- executionState->state = state;
- }
- }
-}
-
-EM_PORT_API(const char *) getStringParam(int flowStateIndex, int componentIndex, int offset) {
- auto flowState = getFlowState(flowStateIndex);
- auto component = flowState->flow->components[componentIndex];
- auto ptr = (const uint32_t *)((const uint8_t *)component + sizeof(Component) + offset);
- return (const char *)(MEMORY_BEGIN + 4 + *ptr);
-}
-
-struct ExpressionList {
- uint32_t count;
- Value values[1];
-};
-
-EM_PORT_API(void *) getExpressionListParam(int flowStateIndex, int componentIndex, int offset) {
- auto flowState = getFlowState(flowStateIndex);
- auto component = flowState->flow->components[componentIndex];
-
- struct List {
- uint32_t count;
- uint32_t items;
- };
- auto list = (const List *)((const uint8_t *)component + sizeof(Component) + offset);
-
- auto expressionList = (ExpressionList *)::malloc((list->count + 1) * sizeof(Value));
-
- expressionList->count = list->count;
-
- auto items = (const uint32_t *)(MEMORY_BEGIN + 4 + list->items);
-
- for (uint32_t i = 0; i < list->count; i++) {
- // call Value constructor
- new (expressionList->values + i) Value();
-
- auto valueExpression = (const uint8_t *)(MEMORY_BEGIN + 4 + items[i]);
- if (!evalExpression(flowState, componentIndex, valueExpression, expressionList->values[i], "Failed to evaluate expression")) {
- return nullptr;
- }
- }
-
- return expressionList;
-}
-
-EM_PORT_API(void) freeExpressionListParam(void *ptr) {
- auto expressionList = (ExpressionList*)ptr;
-
- for (uint32_t i = 0; i < expressionList->count; i++) {
- // call Value desctructor
- (expressionList->values + i)->~Value();
- }
-
- ::free(ptr);
-}
-
-EM_PORT_API(Value*) getInputValue(int flowStateIndex, int inputIndex) {
- auto flowState = getFlowState(g_mainAssets, flowStateIndex);
- return flowState->values + inputIndex;
-}
-
-EM_PORT_API(void) clearInputValue(int flowStateIndex, int inputIndex) {
- auto flowState = getFlowState(g_mainAssets, flowStateIndex);
- flowState->values[inputIndex] = Value();
- onValueChanged(flowState->values + inputIndex);
-}
-
-EM_PORT_API(Value *) evalProperty(int flowStateIndex, int componentIndex, int propertyIndex, int32_t *iterators) {
- auto flowState = getFlowState(g_mainAssets, flowStateIndex);
-
- Value result;
- if (!eez::flow::evalProperty(flowState, componentIndex, propertyIndex, result, "Failed to evaluate property", nullptr, iterators)) {
- return nullptr;
- }
-
- auto pValue = ObjectAllocator::allocate(0xb7e697b8);
- if (!pValue) {
- throwError(flowState, componentIndex, "Out of memory\n");
- return nullptr;
- }
-
- *pValue = result;
-
- return pValue;
-}
-
-EM_PORT_API(void) assignProperty(int flowStateIndex, int componentIndex, int propertyIndex, int32_t *iterators, Value *srcValuePtr) {
- auto flowState = getFlowState(g_mainAssets, flowStateIndex);
-
- Value dstValue;
- if (evalAssignableProperty(flowState, componentIndex, propertyIndex, dstValue, nullptr, nullptr, iterators)) {
- assignValue(flowState, componentIndex, dstValue, *srcValuePtr);
- }
-}
-
-EM_PORT_API(void) setPropertyField(int flowStateIndex, int componentIndex, int propertyIndex, int fieldIndex, Value *valuePtr) {
- auto flowState = getFlowState(g_mainAssets, flowStateIndex);
-
- Value result;
- if (!eez::flow::evalProperty(flowState, componentIndex, propertyIndex, result, "Failed to evaluate property")) {
- return;
- }
-
- if (result.getType() == VALUE_TYPE_VALUE_PTR) {
- result = *result.pValueValue;
- }
-
- if (result.getType() != VALUE_TYPE_ARRAY && result.getType() != VALUE_TYPE_ARRAY_REF) {
- throwError(flowState, componentIndex, "Property is not an array");
- return;
- }
-
- auto array = result.getArray();
-
- if (fieldIndex < 0 || fieldIndex >= array->arraySize) {
- throwError(flowState, componentIndex, "Invalid field index");
- return;
- }
-
- array->values[fieldIndex] = *valuePtr;
- onValueChanged(array->values + fieldIndex);
-}
-
-EM_PORT_API(void) propagateValue(int flowStateIndex, int componentIndex, int outputIndex, Value *valuePtr) {
- auto flowState = getFlowState(g_mainAssets, flowStateIndex);
- eez::flow::propagateValue(flowState, componentIndex, outputIndex, *valuePtr);
-}
-
-EM_PORT_API(void) propagateValueThroughSeqout(int flowStateIndex, int componentIndex) {
- auto flowState = getFlowState(flowStateIndex);
- eez::flow::propagateValueThroughSeqout(flowState, componentIndex);
-}
-
-EM_PORT_API(void) startAsyncExecution(int flowStateIndex, int componentIndex) {
- auto flowState = getFlowState(flowStateIndex);
- eez::flow::startAsyncExecution(flowState, componentIndex);
-}
-
-EM_PORT_API(void) endAsyncExecution(int flowStateIndex, int componentIndex) {
- auto flowState = getFlowState(flowStateIndex);
- eez::flow::endAsyncExecution(flowState, componentIndex);
-}
-
-EM_PORT_API(void) executeCallAction(int flowStateIndex, int componentIndex, int flowIndex) {
- auto flowState = getFlowState(flowStateIndex);
- eez::flow::executeCallAction(flowState, componentIndex, flowIndex);
-}
-
-EM_PORT_API(void) logInfo(int flowStateIndex, int componentIndex, const char *infoMessage) {
- auto flowState = getFlowState(flowStateIndex);
- eez::flow::logInfo(flowState, componentIndex, infoMessage);
-}
-
-EM_PORT_API(void) throwError(int flowStateIndex, int componentIndex, const char *errorMessage) {
- auto flowState = getFlowState(flowStateIndex);
- eez::flow::throwError(flowState, componentIndex, errorMessage);
-}
-
-EM_PORT_API(int) getFirstRootFlowState() {
- if (!g_firstFlowState) {
- return -1;
- }
- return getFlowStateIndex(g_firstFlowState);
-}
-
-EM_PORT_API(int) getFirstChildFlowState(int flowStateIndex) {
- if (flowStateIndex == -1) {
- return -1;
- }
- auto flowState = getFlowState(flowStateIndex);
- auto firstChildFlowState = flowState->firstChild;
- if (!firstChildFlowState) {
- return -1;
- }
- return getFlowStateIndex(firstChildFlowState);
-}
-
-EM_PORT_API(int) getNextSiblingFlowState(int flowStateIndex) {
- if (flowStateIndex == -1) {
- return -1;
- }
- auto flowState = getFlowState(flowStateIndex);
- auto nextSiblingFlowState = flowState->nextSibling;
- if (!nextSiblingFlowState) {
- return -1;
- }
- return getFlowStateIndex(nextSiblingFlowState);
-}
-
-EM_PORT_API(int) getFlowStateFlowIndex(int flowStateIndex) {
- if (flowStateIndex == -1) {
- return -1;
- }
- auto flowState = getFlowState(flowStateIndex);
- return flowState->flowIndex;
-}
-
-EM_PORT_API(bool) isRTL() {
- return g_isRTL;
-}
-
-
-#endif // __EMSCRIPTEN__
diff --git a/Middlewares/eez/flow/dashboard_api.h b/Middlewares/eez/flow/dashboard_api.h
deleted file mode 100644
index c92c655..0000000
--- a/Middlewares/eez/flow/dashboard_api.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
-* EEZ Framework
-* Copyright (C) 2022-present, Envox d.o.o.
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#pragma once
-
-#include
-
-namespace eez {
-namespace flow {
-
-int getFlowStateIndex(FlowState *flowState);
-
-} // flow
-} // eez
diff --git a/Middlewares/eez/flow/debugger.cpp b/Middlewares/eez/flow/debugger.cpp
deleted file mode 100644
index d0ef12b..0000000
--- a/Middlewares/eez/flow/debugger.cpp
+++ /dev/null
@@ -1,760 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-#include
-#include
-#include
-
-#include
-#include
-
-#include
-
-#include
-#include
-#include
-#include
-
-namespace eez {
-namespace flow {
-
-enum MessagesToDebugger {
- MESSAGE_TO_DEBUGGER_STATE_CHANGED, // STATE
-
- MESSAGE_TO_DEBUGGER_ADD_TO_QUEUE, // FLOW_STATE_INDEX, SOURCE_COMPONENT_INDEX, SOURCE_OUTPUT_INDEX, TARGET_COMPONENT_INDEX, TARGET_INPUT_INDEX, FREE_MEMORT, ALLOC_MEMORY
- MESSAGE_TO_DEBUGGER_REMOVE_FROM_QUEUE, // no params
-
- MESSAGE_TO_DEBUGGER_GLOBAL_VARIABLE_INIT, // GLOBAL_VARIABLE_INDEX, VALUE_ADDR, VALUE
- MESSAGE_TO_DEBUGGER_LOCAL_VARIABLE_INIT, // FLOW_STATE_INDEX, LOCAL_VARIABLE_INDEX, VALUE_ADDR, VALUE
- MESSAGE_TO_DEBUGGER_COMPONENT_INPUT_INIT, // FLOW_STATE_INDEX, COMPONENT_INPUT_INDEX, VALUE_ADDR, VALUE
-
- MESSAGE_TO_DEBUGGER_VALUE_CHANGED, // VALUE_ADDR, VALUE
-
- MESSAGE_TO_DEBUGGER_FLOW_STATE_CREATED, // FLOW_STATE_INDEX, FLOW_INDEX, PARENT_FLOW_STATE_INDEX (-1 - NO PARENT), PARENT_COMPONENT_INDEX (-1 - NO PARENT COMPONENT)
- MESSAGE_TO_DEBUGGER_FLOW_STATE_TIMELINE_CHANGED, // FLOW_STATE_INDEX, TIMELINE_POSITION
- MESSAGE_TO_DEBUGGER_FLOW_STATE_DESTROYED, // FLOW_STATE_INDEX
-
- MESSAGE_TO_DEBUGGER_FLOW_STATE_ERROR, // FLOW_STATE_INDEX, COMPONENT_INDEX, ERROR_MESSAGE
-
- MESSAGE_TO_DEBUGGER_LOG, // LOG_ITEM_TYPE, FLOW_STATE_INDEX, COMPONENT_INDEX, MESSAGE
-
- MESSAGE_TO_DEBUGGER_PAGE_CHANGED, // PAGE_ID
-
- MESSAGE_TO_DEBUGGER_COMPONENT_EXECUTION_STATE_CHANGED, // FLOW_STATE_INDEX, COMPONENT_INDEX, STATE
- MESSAGE_TO_DEBUGGER_COMPONENT_ASYNC_STATE_CHANGED // FLOW_STATE_INDEX, COMPONENT_INDEX, STATE
-};
-
-enum MessagesFromDebugger {
- MESSAGE_FROM_DEBUGGER_RESUME, // no params
- MESSAGE_FROM_DEBUGGER_PAUSE, // no params
- MESSAGE_FROM_DEBUGGER_SINGLE_STEP, // no params
-
- MESSAGE_FROM_DEBUGGER_ADD_BREAKPOINT, // FLOW_INDEX, COMPONENT_INDEX
- MESSAGE_FROM_DEBUGGER_REMOVE_BREAKPOINT, // FLOW_INDEX, COMPONENT_INDEX
- MESSAGE_FROM_DEBUGGER_ENABLE_BREAKPOINT, // FLOW_INDEX, COMPONENT_INDEX
- MESSAGE_FROM_DEBUGGER_DISABLE_BREAKPOINT, // FLOW_INDEX, COMPONENT_INDEX
-
- MESSAGE_FROM_DEBUGGER_MODE // MODE (0:RUN | 1:DEBUG)
-};
-
-enum LogItemType {
- LOG_ITEM_TYPE_FATAL,
- LOG_ITEM_TYPE_ERROR,
- LOG_ITEM_TYPE_WARNING ,
- LOG_ITEM_TYPE_SCPI,
- LOG_ITEM_TYPE_INFO,
- LOG_ITEM_TYPE_DEBUG
-};
-
-enum DebuggerState {
- DEBUGGER_STATE_RESUMED,
- DEBUGGER_STATE_PAUSED,
- DEBUGGER_STATE_SINGLE_STEP,
- DEBUGGER_STATE_STOPPED,
-};
-
-bool g_debuggerIsConnected;
-static DebuggerState g_debuggerState;
-static bool g_skipNextBreakpoint;
-
-static char g_inputFromDebugger[64];
-static unsigned g_inputFromDebuggerPosition;
-
-int g_debuggerMode = DEBUGGER_MODE_RUN;
-
-////////////////////////////////////////////////////////////////////////////////
-
-static void setDebuggerState(DebuggerState newState) {
- if (newState != g_debuggerState) {
- g_debuggerState = newState;
-
- if (g_debuggerIsConnected) {
- startToDebuggerMessageHook();
-
- char buffer[256];
- snprintf(buffer, sizeof(buffer), "%d\t%d\n",
- MESSAGE_TO_DEBUGGER_STATE_CHANGED,
- g_debuggerState
- );
- writeDebuggerBufferHook(buffer, strlen(buffer));
- }
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
-void onDebuggerClientConnected() {
- g_debuggerIsConnected = true;
-
- g_skipNextBreakpoint = false;
- g_inputFromDebuggerPosition = 0;
-
- setDebuggerState(DEBUGGER_STATE_PAUSED);
-}
-
-void onDebuggerClientDisconnected() {
- g_debuggerIsConnected = false;
- setDebuggerState(DEBUGGER_STATE_RESUMED);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
-void processDebuggerInput(char *buffer, uint32_t length) {
- for (uint32_t i = 0; i < length; i++) {
- if (buffer[i] == '\n') {
- int messageFromDebugger = g_inputFromDebugger[0] - '0';
-
- if (messageFromDebugger == MESSAGE_FROM_DEBUGGER_RESUME) {
- setDebuggerState(DEBUGGER_STATE_RESUMED);
- } else if (messageFromDebugger == MESSAGE_FROM_DEBUGGER_PAUSE) {
- setDebuggerState(DEBUGGER_STATE_PAUSED);
- } else if (messageFromDebugger == MESSAGE_FROM_DEBUGGER_SINGLE_STEP) {
- setDebuggerState(DEBUGGER_STATE_SINGLE_STEP);
- } else if (
- messageFromDebugger >= MESSAGE_FROM_DEBUGGER_ADD_BREAKPOINT &&
- messageFromDebugger <= MESSAGE_FROM_DEBUGGER_DISABLE_BREAKPOINT
- ) {
- char *p;
- auto flowIndex = (uint32_t)strtol(g_inputFromDebugger + 2, &p, 10);
- auto componentIndex = (uint32_t)strtol(p + 1, nullptr, 10);
-
- auto assets = g_firstFlowState->assets;
- auto flowDefinition = static_cast(assets->flowDefinition);
- if (flowIndex >= 0 && flowIndex < flowDefinition->flows.count) {
- auto flow = flowDefinition->flows[flowIndex];
- if (componentIndex >= 0 && componentIndex < flow->components.count) {
- auto component = flow->components[componentIndex];
-
- component->breakpoint = messageFromDebugger == MESSAGE_FROM_DEBUGGER_ADD_BREAKPOINT ||
- messageFromDebugger == MESSAGE_FROM_DEBUGGER_ENABLE_BREAKPOINT ? 1 : 0;
- } else {
- ErrorTrace("Invalid breakpoint component index\n");
- }
- } else {
- ErrorTrace("Invalid breakpoint flow index\n");
- }
- } else if (messageFromDebugger == MESSAGE_FROM_DEBUGGER_MODE) {
- g_debuggerMode = strtol(g_inputFromDebugger + 2, nullptr, 10);
- gui::refreshScreen();
- }
-
- g_inputFromDebuggerPosition = 0;
- } else {
- if (g_inputFromDebuggerPosition < sizeof(g_inputFromDebugger)) {
- g_inputFromDebugger[g_inputFromDebuggerPosition++] = buffer[i];
- } else if (g_inputFromDebuggerPosition == sizeof(g_inputFromDebugger)) {
- ErrorTrace("Input from debugger buffer overflow\n");
- }
- }
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
-bool canExecuteStep(FlowState *&flowState, unsigned &componentIndex) {
- if (!g_debuggerIsConnected) {
- return true;
- }
-
- if (g_debuggerState == DEBUGGER_STATE_PAUSED) {
- return false;
- }
-
- if (g_debuggerState == DEBUGGER_STATE_SINGLE_STEP) {
- g_skipNextBreakpoint = false;
- setDebuggerState(DEBUGGER_STATE_PAUSED);
- return true;
- }
-
- // g_debuggerState == DEBUGGER_STATE_RESUMED
-
- if (g_skipNextBreakpoint) {
- g_skipNextBreakpoint = false;
- } else {
- auto component = flowState->flow->components[componentIndex];
- if (component->breakpoint) {
- g_skipNextBreakpoint = true;
- setDebuggerState(DEBUGGER_STATE_PAUSED);
- return false;
- }
- }
-
- return true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
-#if defined(__EMSCRIPTEN__)
-char outputBuffer[1024 * 1024];
-#else
-char outputBuffer[64];
-#endif
-int outputBufferPosition = 0;
-
-#define WRITE_TO_OUTPUT_BUFFER(ch) \
- outputBuffer[outputBufferPosition++] = ch; \
- if (outputBufferPosition == sizeof(outputBuffer)) { \
- writeDebuggerBufferHook(outputBuffer, outputBufferPosition); \
- outputBufferPosition = 0; \
- }
-
-#define FLUSH_OUTPUT_BUFFER() \
- if (outputBufferPosition > 0) { \
- writeDebuggerBufferHook(outputBuffer, outputBufferPosition); \
- outputBufferPosition = 0; \
- }
-
-void writeValueAddr(const void *pValue) {
- char tmpStr[32];
- snprintf(tmpStr, sizeof(tmpStr), "%p", pValue);
- auto len = strlen(tmpStr);
- for (size_t i = 0; i < len; i++) {
- WRITE_TO_OUTPUT_BUFFER(tmpStr[i]);
- }
-}
-
-void writeString(const char *str) {
- WRITE_TO_OUTPUT_BUFFER('"');
-
- for (const char *p = str; *p; p++) {
- if (*p == '"') {
- WRITE_TO_OUTPUT_BUFFER('\\');
- WRITE_TO_OUTPUT_BUFFER('"');
- } else if (*p == '\t') {
- WRITE_TO_OUTPUT_BUFFER('\\');
- WRITE_TO_OUTPUT_BUFFER('t');
- } else if (*p == '\n') {
- WRITE_TO_OUTPUT_BUFFER('\\');
- WRITE_TO_OUTPUT_BUFFER('n');
- } else {
- WRITE_TO_OUTPUT_BUFFER(*p);
- }
- }
-
- WRITE_TO_OUTPUT_BUFFER('"');
- WRITE_TO_OUTPUT_BUFFER('\n');
- FLUSH_OUTPUT_BUFFER();
-}
-
-void writeArrayType(uint32_t arrayType) {
- char tmpStr[32];
- snprintf(tmpStr, sizeof(tmpStr), "%x", (int)arrayType);
- auto len = strlen(tmpStr);
- for (size_t i = 0; i < len; i++) {
- WRITE_TO_OUTPUT_BUFFER(tmpStr[i]);
- }
-}
-
-void writeArray(const ArrayValue *arrayValue) {
- WRITE_TO_OUTPUT_BUFFER('{');
-
- writeValueAddr(arrayValue);
-
- WRITE_TO_OUTPUT_BUFFER(',');
- writeArrayType(arrayValue->arrayType);
-
- for (uint32_t i = 0; i < arrayValue->arraySize; i++) {
- WRITE_TO_OUTPUT_BUFFER(',');
- writeValueAddr(&arrayValue->values[i]);
- }
-
- WRITE_TO_OUTPUT_BUFFER('}');
- WRITE_TO_OUTPUT_BUFFER('\n');
- FLUSH_OUTPUT_BUFFER();
-
- for (uint32_t i = 0; i < arrayValue->arraySize; i++) {
- onValueChanged(&arrayValue->values[i]);
- }
-}
-
-void writeHex(char *dst, uint8_t *src, size_t srcLength) {
- *dst++ = 'H';
- for (size_t i = 0; i < srcLength; i++) {
- *dst++ = toHexDigit(src[i] / 16);
- *dst++ = toHexDigit(src[i] % 16);
- }
- *dst++ = 0;
-}
-
-void writeValue(const Value &value) {
- char tempStr[64];
-
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable : 4474)
-#endif
-
- switch (value.getType()) {
- case VALUE_TYPE_UNDEFINED:
- stringCopy(tempStr, sizeof(tempStr) - 1, "undefined\n");
- break;
-
- case VALUE_TYPE_NULL:
- stringCopy(tempStr, sizeof(tempStr) - 1, "null\n");
- break;
-
- case VALUE_TYPE_BOOLEAN:
- stringCopy(tempStr, sizeof(tempStr) - 1, value.getBoolean() ? "true" : "false");
- break;
-
- case VALUE_TYPE_INT8:
- snprintf(tempStr, sizeof(tempStr) - 1, "%" PRId8 "", value.int8Value);
- break;
-
- case VALUE_TYPE_UINT8:
- snprintf(tempStr, sizeof(tempStr) - 1, "%" PRIu8 "", value.uint8Value);
- break;
-
- case VALUE_TYPE_INT16:
- snprintf(tempStr, sizeof(tempStr) - 1, "%" PRId16 "", value.int16Value);
- break;
-
- case VALUE_TYPE_UINT16:
- snprintf(tempStr, sizeof(tempStr) - 1, "%" PRIu16 "", value.uint16Value);
- break;
-
- case VALUE_TYPE_INT32:
- snprintf(tempStr, sizeof(tempStr) - 1, "%" PRId32 "", value.int32Value);
- break;
-
- case VALUE_TYPE_UINT32:
- snprintf(tempStr, sizeof(tempStr) - 1, "%" PRIu32 "", value.uint32Value);
- break;
-
- case VALUE_TYPE_INT64:
- snprintf(tempStr, sizeof(tempStr) - 1, "%" PRId64 "", value.int64Value);
- break;
-
- case VALUE_TYPE_UINT64:
- snprintf(tempStr, sizeof(tempStr) - 1, "%" PRIu64 "", value.uint64Value);
- break;
-
- case VALUE_TYPE_DOUBLE:
- writeHex(tempStr, (uint8_t *)&value.doubleValue, sizeof(double));
- break;
-
- case VALUE_TYPE_FLOAT:
- writeHex(tempStr, (uint8_t *)&value.floatValue, sizeof(float));
- break;
-
- case VALUE_TYPE_STRING:
- case VALUE_TYPE_STRING_REF:
- writeString(value.getString());
- return;
-
- case VALUE_TYPE_ARRAY:
- case VALUE_TYPE_ARRAY_REF:
- writeArray(value.getArray());
- return;
-
- case VALUE_TYPE_BLOB_REF:
- snprintf(tempStr, sizeof(tempStr) - 1, "@%d", (int)((BlobRef *)value.refValue)->len);
- break;
-
- case VALUE_TYPE_STREAM:
- snprintf(tempStr, sizeof(tempStr) - 1, ">%d", (int)(value.int32Value));
- break;
-
- case VALUE_TYPE_DATE:
- tempStr[0] = '!';
- writeHex(tempStr + 1, (uint8_t *)&value.doubleValue, sizeof(double));
- break;
-
- default:
- tempStr[0] = 0;
- break;
- }
-
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
-
- stringAppendString(tempStr, sizeof(tempStr), "\n");
-
- writeDebuggerBufferHook(tempStr, strlen(tempStr));
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
-void onStarted(Assets *assets) {
- if (g_debuggerIsConnected) {
- startToDebuggerMessageHook();
-
- auto flowDefinition = static_cast(assets->flowDefinition);
-
- for (uint32_t i = 0; i < flowDefinition->globalVariables.count; i++) {
- auto pValue = flowDefinition->globalVariables[i];
-
- char buffer[256];
- snprintf(buffer, sizeof(buffer), "%d\t%d\t%p\t",
- MESSAGE_TO_DEBUGGER_GLOBAL_VARIABLE_INIT,
- (int)i,
- (const void *)pValue
- );
- writeDebuggerBufferHook(buffer, strlen(buffer));
-
- writeValue(*pValue);
- }
- }
-}
-
-void onStopped() {
- setDebuggerState(DEBUGGER_STATE_STOPPED);
-}
-
-void onAddToQueue(FlowState *flowState, int sourceComponentIndex, int sourceOutputIndex, unsigned targetComponentIndex, int targetInputIndex) {
- if (g_debuggerIsConnected) {
- startToDebuggerMessageHook();
-
- uint32_t free;
- uint32_t alloc;
- getAllocInfo(free, alloc);
-
- char buffer[256];
- snprintf(buffer, sizeof(buffer), "%d\t%d\t%d\t%d\t%d\t%d\t%d\t%d\n",
- MESSAGE_TO_DEBUGGER_ADD_TO_QUEUE,
- (int)flowState->flowStateIndex,
- sourceComponentIndex,
- sourceOutputIndex,
- targetComponentIndex,
- targetInputIndex,
- (int)free,
- (int)ALLOC_BUFFER_SIZE
- );
- writeDebuggerBufferHook(buffer, strlen(buffer));
- }
-}
-
-void onRemoveFromQueue() {
- if (g_debuggerIsConnected) {
- startToDebuggerMessageHook();
-
- char buffer[256];
- snprintf(buffer, sizeof(buffer), "%d\n",
- MESSAGE_TO_DEBUGGER_REMOVE_FROM_QUEUE
- );
- writeDebuggerBufferHook(buffer, strlen(buffer));
- }
-}
-
-void onValueChanged(const Value *pValue) {
- if (g_debuggerIsConnected) {
- startToDebuggerMessageHook();
-
- char buffer[256];
- snprintf(buffer, sizeof(buffer), "%d\t%p\t",
- MESSAGE_TO_DEBUGGER_VALUE_CHANGED,
- (const void *)pValue
- );
- writeDebuggerBufferHook(buffer, strlen(buffer));
-
- writeValue(*pValue);
- }
-}
-
-void onFlowStateCreated(FlowState *flowState) {
- if (g_debuggerIsConnected) {
- startToDebuggerMessageHook();
-
- char buffer[256];
- snprintf(buffer, sizeof(buffer), "%d\t%d\t%d\t%d\t%d\n",
- MESSAGE_TO_DEBUGGER_FLOW_STATE_CREATED,
- (int)flowState->flowStateIndex,
- flowState->flowIndex,
- (int)(flowState->parentFlowState ? flowState->parentFlowState->flowStateIndex : -1),
- flowState->parentComponentIndex
- );
- writeDebuggerBufferHook(buffer, strlen(buffer));
-
- auto flow = flowState->flow;
-
- for (uint32_t i = 0; i < flow->localVariables.count; i++) {
- auto pValue = &flowState->values[flow->componentInputs.count + i];
-
- char buffer[256];
- snprintf(buffer, sizeof(buffer), "%d\t%d\t%d\t%p\t",
- MESSAGE_TO_DEBUGGER_LOCAL_VARIABLE_INIT,
- (int)flowState->flowStateIndex,
- (int)i,
- (const void *)pValue
- );
- writeDebuggerBufferHook(buffer, strlen(buffer));
-
- writeValue(*pValue);
- }
-
- for (uint32_t i = 0; i < flow->componentInputs.count; i++) {
- //auto &input = flow->componentInputs[i];
- //if (!(input & COMPONENT_INPUT_FLAG_IS_SEQ_INPUT)) {
- auto pValue = &flowState->values[i];
-
- char buffer[256];
- snprintf(buffer, sizeof(buffer), "%d\t%d\t%d\t%p\t",
- MESSAGE_TO_DEBUGGER_COMPONENT_INPUT_INIT,
- (int)flowState->flowStateIndex,
- (int)i,
- (const void *)pValue
- );
- writeDebuggerBufferHook(buffer, strlen(buffer));
-
- writeValue(*pValue);
- //}
- }
- }
-}
-
-void onFlowStateDestroyed(FlowState *flowState) {
- if (g_debuggerIsConnected) {
- startToDebuggerMessageHook();
-
- char buffer[256];
- snprintf(buffer, sizeof(buffer), "%d\t%d\n",
- MESSAGE_TO_DEBUGGER_FLOW_STATE_DESTROYED,
- (int)flowState->flowStateIndex
- );
- writeDebuggerBufferHook(buffer, strlen(buffer));
- }
-}
-
-void onFlowStateTimelineChanged(FlowState *flowState) {
- if (g_debuggerIsConnected) {
- startToDebuggerMessageHook();
-
- char buffer[256];
- snprintf(buffer, sizeof(buffer), "%d\t%d\t%g\n",
- MESSAGE_TO_DEBUGGER_FLOW_STATE_TIMELINE_CHANGED,
- (int)flowState->flowStateIndex,
- flowState->timelinePosition
- );
- writeDebuggerBufferHook(buffer, strlen(buffer));
- }
-}
-
-void onFlowError(FlowState *flowState, int componentIndex, const char *errorMessage) {
- if (g_debuggerIsConnected) {
- startToDebuggerMessageHook();
-
- char buffer[256];
- snprintf(buffer, sizeof(buffer), "%d\t%d\t%d\t",
- MESSAGE_TO_DEBUGGER_FLOW_STATE_ERROR,
- (int)flowState->flowStateIndex,
- componentIndex
- );
- writeDebuggerBufferHook(buffer, strlen(buffer));
- writeString(errorMessage);
- }
-}
-
-void onComponentExecutionStateChanged(FlowState *flowState, int componentIndex) {
- if (g_debuggerIsConnected) {
- startToDebuggerMessageHook();
-
- char buffer[256];
- snprintf(buffer, sizeof(buffer), "%d\t%d\t%d\t%d\n",
- MESSAGE_TO_DEBUGGER_COMPONENT_EXECUTION_STATE_CHANGED,
- (int)flowState->flowStateIndex,
- componentIndex,
- flowState->componenentExecutionStates[componentIndex] ? 1 : 0
- );
-
- writeDebuggerBufferHook(buffer, strlen(buffer));
- }
-}
-
-void onComponentAsyncStateChanged(FlowState *flowState, int componentIndex) {
- if (g_debuggerIsConnected) {
- startToDebuggerMessageHook();
-
- char buffer[256];
- snprintf(buffer, sizeof(buffer), "%d\t%d\t%d\t%d\n",
- MESSAGE_TO_DEBUGGER_COMPONENT_ASYNC_STATE_CHANGED,
- (int)flowState->flowStateIndex,
- componentIndex,
- flowState->componenentAsyncStates[componentIndex] ? 1 : 0
- );
-
- writeDebuggerBufferHook(buffer, strlen(buffer));
- }
-}
-
-void writeLogMessage(const char *str) {
- for (const char *p = str; *p; p++) {
- if (*p == '\t') {
- WRITE_TO_OUTPUT_BUFFER('\\');
- WRITE_TO_OUTPUT_BUFFER('t');
- } if (*p == '\n') {
- WRITE_TO_OUTPUT_BUFFER('\\');
- WRITE_TO_OUTPUT_BUFFER('n');
- } else {
- WRITE_TO_OUTPUT_BUFFER(*p);
- }
- }
-
- WRITE_TO_OUTPUT_BUFFER('\n');
- FLUSH_OUTPUT_BUFFER();
-}
-
-void writeLogMessage(const char *str, size_t len) {
- for (size_t i = 0; i < len; i++) {
- if (str[i] == '\t') {
- WRITE_TO_OUTPUT_BUFFER('\\');
- WRITE_TO_OUTPUT_BUFFER('t');
- } if (str[i] == '\n') {
- WRITE_TO_OUTPUT_BUFFER('\\');
- WRITE_TO_OUTPUT_BUFFER('n');
- } else {
- WRITE_TO_OUTPUT_BUFFER(str[i]);
- }
- }
-
- WRITE_TO_OUTPUT_BUFFER('\n');
- FLUSH_OUTPUT_BUFFER();
-}
-
-void logInfo(FlowState *flowState, unsigned componentIndex, const char *message) {
- if (g_debuggerIsConnected) {
- startToDebuggerMessageHook();
-
- char buffer[256];
- snprintf(buffer, sizeof(buffer), "%d\t%d\t%d\t%d\t",
- MESSAGE_TO_DEBUGGER_LOG,
- LOG_ITEM_TYPE_INFO,
- (int)flowState->flowStateIndex,
- componentIndex
- );
- writeDebuggerBufferHook(buffer, strlen(buffer));
- writeLogMessage(message);
- }
-}
-
-void logScpiCommand(FlowState *flowState, unsigned componentIndex, const char *cmd) {
- if (g_debuggerIsConnected) {
- startToDebuggerMessageHook();
-
- char buffer[256];
- snprintf(buffer, sizeof(buffer), "%d\t%d\t%d\t%d\tSCPI COMMAND: ",
- MESSAGE_TO_DEBUGGER_LOG,
- LOG_ITEM_TYPE_SCPI,
- (int)flowState->flowStateIndex,
- componentIndex
- );
- writeDebuggerBufferHook(buffer, strlen(buffer));
- writeLogMessage(cmd);
- }
-}
-
-void logScpiQuery(FlowState *flowState, unsigned componentIndex, const char *query) {
- if (g_debuggerIsConnected) {
- startToDebuggerMessageHook();
-
- char buffer[256];
- snprintf(buffer, sizeof(buffer), "%d\t%d\t%d\t%d\tSCPI QUERY: ",
- MESSAGE_TO_DEBUGGER_LOG,
- LOG_ITEM_TYPE_SCPI,
- (int)flowState->flowStateIndex,
- componentIndex
- );
- writeDebuggerBufferHook(buffer, strlen(buffer));
- writeLogMessage(query);
- }
-}
-
-void logScpiQueryResult(FlowState *flowState, unsigned componentIndex, const char *resultText, size_t resultTextLen) {
- if (g_debuggerIsConnected) {
- startToDebuggerMessageHook();
-
- char buffer[256];
- snprintf(buffer, sizeof(buffer) - 1, "%d\t%d\t%d\t%d\tSCPI QUERY RESULT: ",
- MESSAGE_TO_DEBUGGER_LOG,
- LOG_ITEM_TYPE_SCPI,
- (int)flowState->flowStateIndex,
- componentIndex
- );
- writeDebuggerBufferHook(buffer, strlen(buffer));
- writeLogMessage(resultText, resultTextLen);
- }
-}
-
-void onPageChanged(int previousPageId, int activePageId) {
- if (flow::isFlowStopped()) {
- return;
- }
-
- if (previousPageId == activePageId) {
- return;
- }
-
- if (previousPageId > 0 && previousPageId < FIRST_INTERNAL_PAGE_ID) {
- auto flowState = getFlowState(g_mainAssets, previousPageId - 1, WidgetCursor());
- if (flowState) {
- onEvent(flowState, FLOW_EVENT_CLOSE_PAGE);
- }
- } else if (previousPageId < 0) {
- auto flowState = getFlowState(g_externalAssets, -previousPageId - 1, WidgetCursor());
- if (flowState) {
- onEvent(flowState, FLOW_EVENT_CLOSE_PAGE);
- }
- }
-
- if (activePageId > 0 && activePageId < FIRST_INTERNAL_PAGE_ID) {
- auto flowState = getFlowState(g_mainAssets, activePageId - 1, WidgetCursor());
- if (flowState) {
- onEvent(flowState, FLOW_EVENT_OPEN_PAGE);
- }
- } else if (activePageId < 0) {
- auto flowState = getFlowState(g_externalAssets, -activePageId - 1, WidgetCursor());
- if (flowState) {
- onEvent(flowState, FLOW_EVENT_OPEN_PAGE);
- }
- }
-
- if (g_debuggerIsConnected) {
- startToDebuggerMessageHook();
-
- char buffer[256];
- snprintf(buffer, sizeof(buffer), "%d\t%d\n",
- MESSAGE_TO_DEBUGGER_PAGE_CHANGED,
- activePageId
- );
- writeDebuggerBufferHook(buffer, strlen(buffer));
- }
-}
-
-} // namespace flow
-} // namespace eez
diff --git a/Middlewares/eez/flow/debugger.h b/Middlewares/eez/flow/debugger.h
deleted file mode 100644
index f8a0c37..0000000
--- a/Middlewares/eez/flow/debugger.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
-* EEZ Generic Firmware
-* Copyright (C) 2021-present, Envox d.o.o.
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see .
-*/
-
-#pragma once
-
-namespace eez {
-namespace flow {
-
-extern bool g_debuggerIsConnected;
-
-enum {
- DEBUGGER_MODE_RUN,
- DEBUGGER_MODE_DEBUG,
-};
-extern int g_debuggerMode;
-
-bool canExecuteStep(FlowState *&flowState, unsigned &componentIndex);
-
-void onStarted(gui::Assets *assets);
-void onStopped();
-
-void onAddToQueue(FlowState *flowState, int sourceComponentIndex, int sourceOutputIndex, unsigned targetComponentIndex, int targetInputIndex);
-void onRemoveFromQueue();
-
-void onValueChanged(const gui::Value *pValue);
-
-void onFlowStateCreated(FlowState *flowState);
-void onFlowStateDestroyed(FlowState *flowState);
-void onFlowStateTimelineChanged(FlowState *flowState);
-
-void onFlowError(FlowState *flowState, int componentIndex, const char *errorMessage);
-
-void onComponentExecutionStateChanged(FlowState *flowState, int componentIndex);
-void onComponentAsyncStateChanged(FlowState *flowState, int componentIndex);
-
-void logInfo(FlowState *flowState, unsigned componentIndex, const char *message);
-
-void logScpiCommand(FlowState *flowState, unsigned componentIndex, const char *cmd);
-void logScpiQuery(FlowState *flowState, unsigned componentIndex, const char *query);
-void logScpiQueryResult(FlowState *flowState, unsigned componentIndex, const char *resultText, size_t resultTextLen);
-
-void onPageChanged(int previousPageId, int activePageId);
-
-void processDebuggerInput(char *buffer, uint32_t length);
-
-} // flow
-} // eez
diff --git a/Middlewares/eez/flow/expression.cpp b/Middlewares/eez/flow/expression.cpp
deleted file mode 100644
index fed70a3..0000000
--- a/Middlewares/eez/flow/expression.cpp
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * EEZ Modular Firmware
- * Copyright (C) 2021-present, Envox d.o.o.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-#include
-
-#include
-#include
-
-#include