mirror of
https://github.com/Derisis13/Shutter.git
synced 2025-12-06 19:32:48 +01:00
Version 1.4.4
Changed function check_timing: now it takes a struct tm* instead of generating one - now the main function gets the current time after initialising the shutter array.
This commit is contained in:
21
main.c
21
main.c
@@ -1,10 +1,10 @@
|
||||
#include "timing.h"
|
||||
#include "moving_debug.h"
|
||||
#include "moving.h"
|
||||
#include <stdio.h>
|
||||
#define FILEPATH "menetrend.txt"
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* SHUTTER AUTOMATA
|
||||
* ---------------
|
||||
* -----------------
|
||||
* C program for automating remote controlled shutters via an openwrt router and a paired remote.
|
||||
* This program needs to be called by Cron in few minute intervals.
|
||||
* Raise and lowering times as well as the desired lowering percentage is read from a local file (menetrend.txt), and is
|
||||
@@ -16,27 +16,30 @@ int main ()
|
||||
{
|
||||
shutter ercsi13[] = {
|
||||
{
|
||||
1, 0, 0, 0, 0, 27, 0 //fiúszoba
|
||||
1, 0, 0, 0, 0, 23, 0 //fiúszoba
|
||||
},
|
||||
{
|
||||
2, 0, 0, 0, 0, 27, 0 //lányszoba
|
||||
2, 0, 0, 0, 0, 23, 0 //lányszoba
|
||||
},
|
||||
{
|
||||
3, 0, 0, 0, 0, 27, 0 //nappali bal
|
||||
3, 0, 0, 0, 0, 23, 0 //nappali bal
|
||||
},
|
||||
{
|
||||
4, 0, 0, 0, 0, 27, 0 //nappali jobb
|
||||
4, 0, 0, 0, 0, 23, 0 //nappali jobb
|
||||
},
|
||||
{
|
||||
5, 0, 0, 0, 0, 27, 0 //szülői szoba
|
||||
5, 0, 0, 0, 0, 16, 0 //konyha
|
||||
},
|
||||
{
|
||||
6, 0, 0, 0, 0, 18, 0 //konyha
|
||||
6, 0, 0, 0, 0, 23, 0 //szülői szoba
|
||||
},
|
||||
{
|
||||
7, 0, 0, 0, 0, 33, 0 //előtető (lehúzás = kieresztés, felhúzás = behúzás)
|
||||
}
|
||||
};
|
||||
//get the time of launch
|
||||
time_t t = time (NULL);
|
||||
struct tm *now = localtime (&t);
|
||||
|
||||
//scan the schedule
|
||||
for (int i = 0; i < 7; ++i)
|
||||
@@ -54,7 +57,7 @@ int main ()
|
||||
for (int i = 0; i < 7; ++i)
|
||||
{
|
||||
set_ch (&ercsi13[i], &ch);
|
||||
switch (check_timing (&ercsi13[i]))
|
||||
switch (check_timing (&ercsi13[i], now))
|
||||
{
|
||||
case up:press_button (up);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user