Giter Site home page Giter Site logo

c-helpers's Introduction

What are these?

A series of C macro headers for easier debug or development of prototypes on Arduino devices.

These “dynamic module”s are mostly simple macro functions coupled with some global definitions.

These are just test modules developed for my personal use. I just use them to make testing Arduino devices easier. There are bugs and the codes is not conventional (yes, *.h does more than defining signiture, I wrote the body of the functions and a thousand more sins).

Morever, these files are really old and I haven’t looked at them for a while because they seem to work just fine as of 2022 (tested with ESP-32, ESP-8266, Arduino Nano(?) or maybe not… cannot exactly remember, it was early 2022).

The files have should have documentation themselves.

These are the original files of the repository worth checking out:

  1. debug.h: Serial.print, but conditionally
  2. network.h: enables WiFi OR Ethernet connections without a need to change the code. The basic setup is 3 lines with some macro assignments.
  3. request.h: enables connection with MQTT OR HTTP server without a need to change the code. The basic setup is 3 lines with some macro assignments.

TODO?

As I rarely write C, I may or may not add to these helpers or improve on them. One that I am especially interested in is header for “multi-dimensional homogeneous array” manipulation. I even have the formula down here in one of my early notes, but I never finished it.

For a homogenous C array to be indexed like a $|D|$ (the size of $D$) dimensional list in modern languages, the index must be calculated with the following formula. In the formula below:

  • $i$ and $j$ both start from 0
  • $D$ is another array holding the dimension status of which we aim to simulate
  • $|I| = |D|$.

As an example, $D$ for List[2][3][4], is $[2, 3, 4]$ and $I$ for the element at [1, 2, 3] is $[1, 2, 3]$.

i=0|D|(IiΠj=i+1|D|Dj)

If implemented as I have in mind, this can help the developer represent a single homogenous array in any dimensions (by using various $D$) and indexed in a pretty modern fashion (using different $I$). Note that an array can be represented with multiple $D$s with one initial definition of the array.

Using this formula and a couple of well written macroes, one can define such arrays with 0 overhead, meaning $D$ and $I$ don’t have to be real arrays, they can be baked inside some macroes or eliminated depending on the implementation. Moreover, the calculation of the formula can be passed to the compile-time in most of the cases.

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.