SysBee v1
Dependencies: C027_Support mbed
Fork of App_Pese_Ruche_SYSBEE by
Revision 9:4c09643fbfb9, committed 2018-09-13
- Comitter:
- Cosi
- Date:
- Thu Sep 13 09:03:46 2018 +0000
- Parent:
- 8:3af661bcfcec
- Commit message:
- Version with get_season function
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 3af661bcfcec -r 4c09643fbfb9 main.cpp --- a/main.cpp Thu Sep 13 08:54:00 2018 +0000 +++ b/main.cpp Thu Sep 13 09:03:46 2018 +0000 @@ -45,6 +45,12 @@ // weight difference needed to send sms #define DIFF_THRESHOLD 0.4f +// Season constants - used in the get_season function +#define SPRING 1 +#define SUMMER 2 +#define AUTUMN 3 +#define WINTER 4 + // states of the hive typedef enum E_HIVE_STATE { HIVE_STATE_INIT = 0, @@ -122,6 +128,22 @@ pc.printf("Woke up !\n\r"); } +// Returns integer representing the season : Spring 1, Summer 2, Autumn 3, Winter 4 +int get_season (char month[4]) +{ + time_t seconds = time(NULL); + sscanf(ctime(&seconds), "%*s %s %*s", month); + + if (!strcmp(month, "Mar") || !strcmp(month, "Apr") || !strcmp(month, "May")) + return SPRING; + else if (!strcmp(month, "Jun") || !strcmp(month, "Jul") || !strcmp(month, "Aug")) + return SUMMER; + else if (!strcmp(month, "Sep") || !strcmp(month, "Oct") || !strcmp(month, "Nov")) + return AUTUMN; + else if (!strcmp(month, "Dec") || !strcmp(month, "Jan") || !strcmp(month, "Feb")) + return WINTER; +} + // send a sms to the phone number void send_message(char msg[]) {