Source für Wochenschaltuhr

Es gibt 1 Antwort in diesem Thema, welches 2.477 mal aufgerufen wurde. Der letzte Beitrag () ist von k4ktus.

  • Hier kommt mal ein Schnippsel vllt. hilft es dem Einen oder Anderen:


    Wer die gesammte Klasse brauchen kann soll sich melden. Feedback freut mich natürlich auch :)


    [code type=diff]/**********************************************************************************************
    * Arduino programmable timer Library - Version 0.1b
    * by Simon Bauer seimen.baua beiundoder gmail.com
    *
    * This Library is licensed under a GPLv3 License
    **********************************************************************************************/


    #include <programmableTimer.h>
    #include <Time/Time.h>
    #include <stdint.h>



    int programmableTimer::status(const int controllTable[7][8], const time_t &myTime, const int &checkIntervallSec)
    //test it for 1 = activated 0=deactivated -1= no intervall found i.e. 0000 0000 intervalls in table
    {
    recentTime = hour(myTime) * 100 + minute(myTime); //Maybe without parameter
    recentWeekDay = weekday(myTime);

    if (recentTime - myOldTime >= checkIntervallSec) //Zero means no pause. Otherwise every x seconds will be check for new status.
    myOldTime = recentTime;
    {
    if ( controllTable[recentWeekDay][NoTimeOn] <= recentTime && controllTable [recentWeekDay][NoTimeOn+1] >= recentTime)
    {
    if (statusBit == 0){ NoTimeOff = NoTimeOn + 1; }
    statusBit = 1;
    return statusBit;
    }
    else if ( controllTable[recentWeekDay][NoTimeOff+1] >= recentTime && controllTable[recentWeekDay][NoTimeOff] <= recentTime )
    {
    if (statusBit == 1){ NoTimeOn = NoTimeOff + 1; }
    statusBit = 0;
    return statusBit;
    }
    else if ( recentTime <= controllTable[recentWeekDay][0]) //day changed
    {
    NoTimeOn=0;
    NoTimeOff = 1;
    statusBit = 0;
    return -1;
    }
    else //the intervall may not fit to the recent time
    {
    NoTimeOn = NoTimeOn + 2;
    NoTimeOff = NoTimeOn + 1;
    }
    if (NoTimeOn == 8) //reset counter
    {
    NoTimeOn=0;
    NoTimeOff = 1;
    }
    }
    }


    programmableTimer::programmableTimer()
    {
    NoTimeOn = 0;
    NoTimeOff = 1;
    }


    programmableTimer::~programmableTimer()
    {

    }[/code]

  • Grr kann den Beitrag leider nicht mehr ändern! War noch ein kleiner Fehler drin.


    In der nächsten Revision werde ich die Klasse dann dynamisch machen d.h es können beliebig viele Schaltintervalle übergeben werden.


    [code type=ini]/**********************************************************************************************
    * Arduino programmable timer Library - Version 0.1b
    * by Simon Bauer seimen.baua atund oder nich gmail.com
    *
    * This Library is licensed under a GPLv3 License
    **********************************************************************************************/


    #include <programmableTimer.h>
    #include <Time/Time.h>
    #include <stdint.h>



    int programmableTimer::status(const int controllTable[7][8], const time_t &myTime, const int &checkIntervallSec)
    //test it for 1 = activated 0=deactivated (-1= no intervall found i.e. 0000 0000 intervalls in table) not used for now
    {
    recentTime = hour(myTime) * 100 + minute(myTime); //Maybe without parameter
    recentWeekDay = weekday(myTime);

    if (recentTime - myOldTime >= checkIntervallSec) //Zero means no pause. Otherwise every x seconds will be check for new status.
    myOldTime = recentTime;
    {
    if ( controllTable[recentWeekDay][NoTimeOn] <= recentTime && controllTable [recentWeekDay][NoTimeOn+1] >= recentTime)
    {
    if (statusBit == 0){ NoTimeOff = NoTimeOn + 1; }
    statusBit = 1;
    return statusBit;
    }
    else if ( controllTable[recentWeekDay][NoTimeOff+1] >= recentTime && controllTable[recentWeekDay][NoTimeOff] <= recentTime )
    {
    if (statusBit == 1){ NoTimeOn = NoTimeOff + 1; }
    statusBit = 0;
    return statusBit;
    }
    else if ( recentTime <= controllTable[recentWeekDay][0]) //day changed
    {
    NoTimeOn=0;
    NoTimeOff = 1;
    statusBit = 0;
    return statusBit;
    }
    else //the intervall may not fit to the recent time
    {
    NoTimeOn = NoTimeOn + 2;
    NoTimeOff = NoTimeOn + 1;
    }
    if (NoTimeOn == 8) //reset counter
    {
    NoTimeOn=0;
    NoTimeOff = 1;
    }
    }
    }


    programmableTimer::programmableTimer()
    {
    NoTimeOn = 0;
    NoTimeOff = 1;
    }


    programmableTimer::~programmableTimer()
    {

    }[/code]

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!