All atout bottons

Good morning everybody,
I have much free time in this period, so I tried to write some functions about push bottoms. I triedto do everything we can do witch bottoms, and I obtened this’d “library” that I invite you.
I have not Arduino here, so I can’t try it, so if someone that has nothing to do wants try it I’ll be happy.
I accept and search every critics or ideas about it.

//keyboard library of Silente
//everything you can do witch push bottons.
//the buttonpin is treated like a char and its sign is the pressed state. >0=HIGH, <0=LOW

#define START bool pressvalue=pin >0; pin=abs (pin);
#define STARTS START unsigned long tp=millis ();

bool Pressed (char pin, byte time)
{
    //the debounce software function
    //it needs the value of the pin to debounce and the minimum time for debouncing
    //the sign of the pin number is a flag than want the state of pressed level (used for input_pullup bottoms)
    //by this little idea the function CAN'T use pin 0 (serial pin) and CAN'T use more than pin 127 (ofer maximum of MEGA 2560)
    //if pin is positive value preseed is HIGH. Else it il LOW
    STARTS
    while (millis () -tp <time)
        if (digitalRead (pin)!=pressvalue)
            return (0);
    return (1);
}

bool waitdetack (char pin)
{
    //this function waots that a input pin change its status.
    //the function needs the number of pin and the right status.
    //the last information is codified like in the last function, witch the same limitations
    START
    while (digitalRead (pin)==pressvalue);
    return (1);
}

byte numberpressions (char pin, int maxtime, byte mintime)
{
    //this function counts the pressions of a button in a maxtime. it needs also the minimum time to be a pression
    unsigned long tp=millis ();
    byte counter=0;
    while (millis ()-tp <maxtime)
    {
        counter=counter + pressed (pin, mintime);
        waitdetack (pin);
    }
    return (counter);
}

int durationpressure (char pin)
{
    //it returns the duration of a pressure
    unsigned long tp=millis ();
    wautdetach (pin);
    return (millis ()-tp);
}

byte pressedmultibotton (byte pin [], char size, byte time) 
{
    //this is NOT the function for know if more than one botton is pressed at the same time
    //this is a function that controll witch, in an array of botton pins is pressed
    //the function return the index of the pressed botton +1.
    //the function needs the array of pins, its lize SIGNED and the software debounce time
    //the sign of the size is the pressed level. +=HIGH, -=LOW
    bool pressedlevel=size>0;
    size= abs(size);
    for (byte i=0;i <size;i++)
    {
        if (pressed ((pin×(2×pressedlevel-1)), time)
        {
            return (i+1);
        }
    }
    return (0);
}

byte keyboard (byte rows[], byte columns[], byte nr, byte nc)
{
    //this is all the famous Keyboard.h. Is it difficult?
    //it needs arrays of rows and cols pins, and the number of rows and cols
    //it returnes 0 if no button are pressed
    //it returns the index of the row × the number of the rows +the index of the column +1 if a button is pressed
    //rows are input and columns are output
    for (byte i=0;i <nc;i++)
    {
        pinMode (columns [i], OUTPUT);
        digitalWrite (columns [i], HIGH);
    for (byte j=0;j <nr;j++)
    {
        pinMode (rows [j], INPUT);
            if (pressed (rows [j], 100))
            {
                digitalWrite (cols [i], LOW);
                return (1+(j×nr)+i);
            }
    }
        digitalWrite (cols [i], LOW);
        }
    return (0);
}

Thanks
Flavour (18)

too messy to read...(for me)

that's making your code more complicated to read rather than simplifying...

#define START bool pressvalue=pin >0; pin=abs (pin);
#define STARTS START unsigned long tp=millis ();

and I don't know what updates pressvalue or what is actually pin

function names are case sensitive...

Pin is a variable situated in every function about bottom. It is the pin where the bottom is connected, and its sign can be input or input pull up. This is to reduce the variables passed. I put that piece of code in macro because it is repeated more than a time into different functions. I think it is simple to read, and well explicate, I am sorry if it isn't, I'll re see the "code". Thanks you

To be bluntly honest I find your macro totally ugly - use copy paste if you are lazy...

keep pin as they are... and not make things negative just for the sake of passing extra info: //the sign of the pin number is a flag than want the state of pressed level (used for input_pullup bottoms) if you really want to save a byte on the stack when calling the function, then use a structure with bit fields and have 1 bit for PULLUP and 7 bits for pin number. that will make code easier to understand

Using proper type in a program is important. Your function returns a boolean, so return true or false rather that 1 or 0. Technically it's driving a similar behavior but it's semantically more appropriate to return something you described as your returned type rather than depending on integral promotion and conversion doing the right thing for you.

You asked for an honest feedback - so I were you I would get an Arduino and document how you want things wired, study existing button Libraries (see oneButton or that one from @bricoleau - actual class not just functions) and see what value add you can bring. (Different approaches are welcome efforts for self exploration of course as there is no just one way of doing things and it's a good learning opportunity)

(also check your spelling - I know we are not all native speakers here and make spelling / grammar mistakes, but trying to use proper english as much as possible is helpful. for example the title of your post would probably attract more readers if it used the words "buttons" (instead of "push bottoms" or "bottons") or "about" and even better if it were more descriptive - something like "Seeking comments on my button helper functions" )