Controls the central heating system and the lights.

Dependencies:   1-wire clock crypto fram log lpc1768 net web wiz mbed

Committer:
andrewboyson
Date:
Sat Nov 12 10:03:38 2022 +0000
Revision:
8:8ac076ce51af
Parent:
0:22b158d3c76f
Updated LPC1768 library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andrewboyson 0:22b158d3c76f 1 #include <stdbool.h>
andrewboyson 0:22b158d3c76f 2
andrewboyson 0:22b158d3c76f 3
andrewboyson 0:22b158d3c76f 4 #include "gpio.h"
andrewboyson 0:22b158d3c76f 5 #include "radiator.h"
andrewboyson 0:22b158d3c76f 6 #include "program.h"
andrewboyson 0:22b158d3c76f 7 #include "mstimer.h"
andrewboyson 0:22b158d3c76f 8 #include "hall-pb.h"
andrewboyson 0:22b158d3c76f 9
andrewboyson 0:22b158d3c76f 10 #define HALL_LED_DIR FIO0DIR(10) // P0.10 == p28;
andrewboyson 0:22b158d3c76f 11 #define HALL_LED_PIN FIO0PIN(10)
andrewboyson 0:22b158d3c76f 12 #define HALL_LED_SET FIO0SET(10)
andrewboyson 0:22b158d3c76f 13 #define HALL_LED_CLR FIO0CLR(10)
andrewboyson 0:22b158d3c76f 14
andrewboyson 8:8ac076ce51af 15 #define POSITIVE_FLASH_MS 100
andrewboyson 8:8ac076ce51af 16 #define NEGATIVE_FLASH_MS 500
andrewboyson 0:22b158d3c76f 17
andrewboyson 0:22b158d3c76f 18 void HallLedInit()
andrewboyson 0:22b158d3c76f 19 {
andrewboyson 0:22b158d3c76f 20 HALL_LED_DIR = 1; //Set the direction to 1 == output
andrewboyson 0:22b158d3c76f 21 }
andrewboyson 0:22b158d3c76f 22 void HallLedMain()
andrewboyson 0:22b158d3c76f 23 {
andrewboyson 0:22b158d3c76f 24 static uint32_t hallLedFlashMsTimer = 0;
andrewboyson 0:22b158d3c76f 25 if (HallPbOverrideMode)
andrewboyson 0:22b158d3c76f 26 {
andrewboyson 8:8ac076ce51af 27 if (RadiatorsOn) HALL_LED_SET; else HALL_LED_CLR;
andrewboyson 0:22b158d3c76f 28 hallLedFlashMsTimer = MsTimerCount;
andrewboyson 0:22b158d3c76f 29 }
andrewboyson 0:22b158d3c76f 30 else
andrewboyson 0:22b158d3c76f 31 {
andrewboyson 8:8ac076ce51af 32 int flashRate = RadiatorGetHotWaterProtectOn() ? POSITIVE_FLASH_MS : NEGATIVE_FLASH_MS;
andrewboyson 0:22b158d3c76f 33 if (MsTimerRepetitive(&hallLedFlashMsTimer, flashRate))
andrewboyson 0:22b158d3c76f 34 {
andrewboyson 0:22b158d3c76f 35 static bool flash = false;
andrewboyson 0:22b158d3c76f 36 flash = !flash;
andrewboyson 0:22b158d3c76f 37 if (flash) HALL_LED_SET; else HALL_LED_CLR;
andrewboyson 0:22b158d3c76f 38 }
andrewboyson 0:22b158d3c76f 39 }
andrewboyson 0:22b158d3c76f 40 }