From 6bc23c92fe6df6672a37370d6eea1177f9cde26c Mon Sep 17 00:00:00 2001 From: Derisis13 Date: Mon, 30 Aug 2021 18:47:21 +0200 Subject: [PATCH] Version 1.4 Reworked channel changing: now it tracks the current ch. and resets only once. This makes the program to finish faster. Added rolltime_down and percentage values to shutter structure: now the schedule file needs to contain a percentage column after the timestamp for lowering, and a rolltime needs to be defined for each shutter in the beginning of the program. When lowering shutters, there's a calculation to sleep until the desired percentage is reached, when the shutter is stopped The way to deactivate shutters has changed: now you need to set the percentage to 0. --- redony.h => shutter.h | 10 +++++++--- idozites.c => timing.c | 4 ++-- idozites.h => timing.h | 6 +++--- 3 files changed, 12 insertions(+), 8 deletions(-) rename redony.h => shutter.h (62%) rename idozites.c => timing.c (96%) rename idozites.h => timing.h (60%) diff --git a/redony.h b/shutter.h similarity index 62% rename from redony.h rename to shutter.h index 0427cef..3517608 100644 --- a/redony.h +++ b/shutter.h @@ -7,16 +7,20 @@ #include +typedef char byte; typedef struct ido { - int tm_hour; - int tm_min; + byte tm_hour; + byte tm_min; } ido; typedef struct redony { - int ch; + byte ch; ido up; ido down; + byte rolltime_up; //measured in seconds + byte rolltime_down; //measured in seconds + byte percentage; } redony; typedef enum buttons { diff --git a/idozites.c b/timing.c similarity index 96% rename from idozites.c rename to timing.c index 7981971..12b83e3 100644 --- a/idozites.c +++ b/timing.c @@ -60,7 +60,7 @@ int find_next_day (FILE *f) return 0; } -void get_timing (redony *r, FILE *schedule) +void get_timing (shutter *r, FILE *schedule) { int channel = 0; while (channel != r->ch) @@ -81,7 +81,7 @@ void get_timing (redony *r, FILE *schedule) } -buttons check_timing (redony *r) +buttons check_timing (shutter *r) { if ((r->up.tm_hour == r->down.tm_hour) && (r->up.tm_min == r->down.tm_min)) return stop; diff --git a/idozites.h b/timing.h similarity index 60% rename from idozites.h rename to timing.h index 222ded5..af5de06 100644 --- a/idozites.h +++ b/timing.h @@ -4,13 +4,13 @@ #ifndef _IDOZITES_H_ #define _IDOZITES_H_ -#include "redony.h" +#include "shutter.h" #include #include -void get_timing (redony *r, FILE *schedule); +void get_timing (shutter *r, FILE *schedule); -buttons check_timing (redony *r); +buttons check_timing (shutter *r); int find_today (FILE *schedule);