Allows my home wiz lights to be timed on and off according to a schedule.

Dependents:   heating

Committer:
andrewboyson
Date:
Tue May 18 16:23:57 2021 +0000
Revision:
5:ec0498d7d2c1
Parent:
0:9af80a39adcc
Made a number of changes to better handle local times. The problem seen was between 00h00 and 01h00 BST which corresponded to 23h00 and 00h00 UTC caused negative numbers.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andrewboyson 0:9af80a39adcc 1 #include <stdint.h>
andrewboyson 0:9af80a39adcc 2 #include <stdio.h>
andrewboyson 0:9af80a39adcc 3 #include <time.h>
andrewboyson 0:9af80a39adcc 4
andrewboyson 0:9af80a39adcc 5 #include "http.h"
andrewboyson 0:9af80a39adcc 6 #include "wiz.h"
andrewboyson 0:9af80a39adcc 7 #include "wiz-sun.h"
andrewboyson 0:9af80a39adcc 8 #include "wiz-sched.h"
andrewboyson 0:9af80a39adcc 9 #include "wiz-list.h"
andrewboyson 0:9af80a39adcc 10 #include "clk.h"
andrewboyson 0:9af80a39adcc 11
andrewboyson 0:9af80a39adcc 12 void WebWizAjax()
andrewboyson 0:9af80a39adcc 13 {
andrewboyson 0:9af80a39adcc 14 HttpOk("text/plain; charset=UTF-8", "no-cache", NULL, NULL);
andrewboyson 0:9af80a39adcc 15
andrewboyson 0:9af80a39adcc 16 HttpAddNibbleAsHex(WizTrace);
andrewboyson 0:9af80a39adcc 17 HttpAddChar('\n');
andrewboyson 0:9af80a39adcc 18 HttpAddChar('\f');
andrewboyson 0:9af80a39adcc 19 WizListHttp();
andrewboyson 0:9af80a39adcc 20 HttpAddChar('\f');
andrewboyson 0:9af80a39adcc 21
andrewboyson 0:9af80a39adcc 22 struct tm tmUtc;
andrewboyson 0:9af80a39adcc 23 ClkNowTmUtc (&tmUtc);
andrewboyson 0:9af80a39adcc 24
andrewboyson 0:9af80a39adcc 25 int minutesTodayUtc = tmUtc.tm_hour * 60 + tmUtc.tm_min;
andrewboyson 0:9af80a39adcc 26
andrewboyson 5:ec0498d7d2c1 27 HttpAddInt32AsHex(WizSchedMinutesUtcToLocal(minutesTodayUtc));
andrewboyson 0:9af80a39adcc 28 HttpAddChar('\n');
andrewboyson 0:9af80a39adcc 29 HttpAddInt32AsHex(minutesTodayUtc);
andrewboyson 0:9af80a39adcc 30 HttpAddChar('\n');
andrewboyson 5:ec0498d7d2c1 31 HttpAddInt32AsHex(WizSchedMinutesUtcToLocal(WizSunRiseMinutes()));
andrewboyson 0:9af80a39adcc 32 HttpAddChar('\n');
andrewboyson 5:ec0498d7d2c1 33 HttpAddInt32AsHex(WizSchedMinutesUtcToLocal(WizSunSetMinutes()));
andrewboyson 0:9af80a39adcc 34 HttpAddChar('\n');
andrewboyson 0:9af80a39adcc 35 HttpAddChar('\f');
andrewboyson 0:9af80a39adcc 36
andrewboyson 0:9af80a39adcc 37 WizSchedHttp();
andrewboyson 0:9af80a39adcc 38 }
andrewboyson 0:9af80a39adcc 39