Git Product home page Git Product logo

myarduinosnippets's Introduction

atUtility

  • this library is a collection of useful functions of my Arduino projects combined in one class for easy use.
  • it's partially written with more modern C++ features like templates and lambda functions. I also work with references and pointers. For this reason it's not possible to use the library through the library manager of the Arduino IDE. You have to download the source code and include it in your project.

If you want to use this library you only have to clone this repository into your Arduino library folder. The library is tested with Arduino CLI in combination with VSCode.

Directory structure

  • examples: contains example sketches
  • src: contains the source code of the library
  • wikiMats: contains images for the wiki
  • Workflows: contains code snippets for handling external libaries

myarduinosnippets's People

Contributors

alexandertonn avatar

Watchers

 avatar

myarduinosnippets's Issues

[PERFORMANCE] Use uint32_t and don't use myMillis()

 :rocket: Please describe your feature request

  • don't use the myMillis function because i have to pass for each trigger a uint64_t which needs a lot of variable space

 :pencil2: Describe the solution you'd like

  • this solution makes it possible to use the functionTrigger independent of the myMillis function. it's also saving a lot of SRAM
// Max Targettime: about 65s
auto functionTrigger(uint32_t &uiMillisOld, uint16_t uiTargetTime) -> bool {

  if (millis() - uiMillisOld >= uiTargetTime) {
    uiMillisOld += uiTargetTime;
    return true;
  } else {
    return false;
  }

}

 :pushpin: Describe alternatives you've considered

  • A clear and concise description of any alternative solutions or features you've considered.

Additional context

Saved Flash

- before: 2x uint64_t  & 1x uint16_t == 18 byte
+ now: 1x uint32_t & 1x uint16_t == 6 byte

[BUG] not possible to use a single mills variable for functionTrigger

🐛 Describe the bug

  • it's not possible to use one variable for multiple time triggers

https://github.com/AlexanderTonn/MyArduinoSnippets/blob/main/MyUtilities/myFunctionTrigger/myFunctionTrigger.ino

 :bangbang: To Reproduce**

Steps to reproduce the behavior:

void loop() {
  // StringToChar();
  // using_Strtok();

  // myMillis(uiMillis);
  // Serial.println(int(uiMillis));

  // FUNCTION TRIGGER EXAMPLE
   xFunctionTrigger1 = functionTrigger(uiMillis, 5000);
   xFunctionTrigger2 = functionTrigger(uiMillis, 2000);
  Serial.println("millis = " + String(millis()) + "xFunctionTrigger1: " + String(xFunctionTrigger1));
  Serial.println("millis = " + String(millis()) + "xFunctionTrigger2: " + String(xFunctionTrigger2));
  delay(1000);

}

Terminal output

millis = 0xFunctionTrigger1: 0
millis = 0xFunctionTrigger2: 0
millis = 1000xFunctionTrigger1: 0
millis = 1001xFunctionTrigger2: 0
millis = 2001xFunctionTrigger1: 0
millis = 2001xFunctionTrigger2: 1
millis = 3002xFunctionTrigger1: 0
millis = 3003xFunctionTrigger2: 0
millis = 4003xFunctionTrigger1: 0
millis = 4004xFunctionTrigger2: 1
millis = 5005xFunctionTrigger1: 0
millis = 5005xFunctionTrigger2: 0
millis = 6005xFunctionTrigger1: 0
millis = 6006xFunctionTrigger2: 1
millis = 7007xFunctionTrigger1: 0
millis = 7008xFunctionTrigger2: 0
millis = 8008xFunctionTrigger1: 0
millis = 8008xFunctionTrigger2: 1
millis = 9009xFunctionTrigger1: 0
millis = 9010xFunctionTrigger2: 0
millis = 10010xFunctionTrigger1: 0
millis = 10011xFunctionTrigger2: 1

⁉️ Expected behavior

  • optimize function regarding modern c++ style
  • make sure that it's possible to use one variable for multiple time triggers

📷 Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Add any other context about the problem here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.