Skip to content

v2.5.0 - Optimized Memory & High-Efficiency Edition

Choose a tag to compare

@Moaaz-i Moaaz-i released this 22 Jun 13:57

🚀 UMOZ Library v2.5.0

We are excited to announce the release of v2.5.0 of the UMOZ library! This version is focused on ultra-lightweight multitasking, enhanced power saving, and high-efficiency resource management for Arduino microcontrollers.


✨ What's New & Key Features

1. Priority-Based Task Scheduler

  • Introducing a lightweight cooperative scheduler via addTask().
  • Supports task prioritization (UMOZ_LOW, UMOZ_MEDIUM, UMOZ_HIGH). The scheduler automatically resolves timing conflicts by executing higher-priority tasks first.

2. Smart Sleep Mode (Power Saving)

  • When enabled via enableSmartSleep(true), the library calculates the time left until the next scheduled task.
  • If the idle period is greater than 5ms, it automatically puts AVR microcontrollers into SLEEP_MODE_IDLE, significantly reducing current consumption.

3. Real-Time CPU Usage Monitor

  • Track system load effortlessly using getCPUUsage().
  • It uses an optimized idle-counting mechanism (benchTick()) to compute and report precise CPU utilization percentages every second.

4. Expressive Syntax Macros

  • Say goodbye to boilerplate code! Streamline your application layout with innovative macros:
    • UMOZ_START(), UMOZ_RUN(), and UMOZ_END to wrap your setup and execution flow seamlessly.
    • UMOZ_EVERY_MS(ms) and UMOZ_EVERY_HZ(hz) for inline, non-blocking timed executions without manually declaring states.

5. Hardware-Level Fast I/O & Math

  • toggleFast<PIN>(): Leverages direct port manipulation registers (portInputRegister) for blazing-fast pin flipping on AVR architecture.
  • smoothReadFast<ANALOG_PIN>(): A high-efficiency analog noise filter utilizing bitwise shift operations (>> 3) instead of resource-heavy division.

🛠️ Technical Specifications

  • Design Pattern: Implemented using the Singleton Pattern (getInstance()) to prevent multiple instances from wasting precious SRAM. Access it globally via the tool alias.
  • Memory Protection: Deleted Copy Constructor and Assignment Operator to completely safeguard against accidental memory duplication.
  • Debounce Engine: Built-in hardware switch debouncing (isButtonPressed) with a solid 50ms stable window filter.
  • Task Boundary: Defaults to a static allocation of up to 5 concurrent tasks (UMOZ_MAX_TASKS) to guarantee memory predictability.

📦 Quick Start Example

#include <UMOZ.h>

void blinkTask() {
    tool.toggle(LED_BUILTIN);
}

UMOZ_START()
  tool.addTask(blinkTask, 500, UMOZ_HIGH);
  tool.enableSmartSleep(true);
UMOZ_RUN()
  // Your main loop code can go here
UMOZ_END