summaryrefslogtreecommitdiffstats
path: root/radiator-plc/stm32/app/control.c
diff options
context:
space:
mode:
authorfishsoupisgood <github@madingley.org>2021-01-12 16:58:31 +0000
committerfishsoupisgood <github@madingley.org>2021-01-12 16:58:31 +0000
commit7c6887eaaf812b63bab6c5e134f80a2ef36aeb31 (patch)
tree4b4b0d371107ae1b8540ca1618cb9aa796b72616 /radiator-plc/stm32/app/control.c
parentf4b573fe337a436d5e2b20be4be031d77376d609 (diff)
downloadheating-7c6887eaaf812b63bab6c5e134f80a2ef36aeb31.tar.gz
heating-7c6887eaaf812b63bab6c5e134f80a2ef36aeb31.tar.bz2
heating-7c6887eaaf812b63bab6c5e134f80a2ef36aeb31.zip
works
Diffstat (limited to 'radiator-plc/stm32/app/control.c')
-rw-r--r--radiator-plc/stm32/app/control.c114
1 files changed, 0 insertions, 114 deletions
diff --git a/radiator-plc/stm32/app/control.c b/radiator-plc/stm32/app/control.c
deleted file mode 100644
index f3a35c9..0000000
--- a/radiator-plc/stm32/app/control.c
+++ /dev/null
@@ -1,114 +0,0 @@
-#include "project.h"
-
-
-static uint32_t target = 25000;
-static uint32_t value = ~0U;
-
-#define SHORT 200
-#define LONG 1200
-#define REPEAT 400
-
-#define HYST 75UL
-
-
-static void
-show_temp (char t, uint32_t v, int y)
-{
- char buf[16];
- uint32_t i, f;
-
- i = v / 1000;
- f = v / 100 - (i * 10);
-
- if (v == ~0U)
- {
- sprintf (buf, "%c:error ", t);
- }
- else
- {
- sprintf (buf, "%c:%2d.%1d%cC", t, (int) i, (int) f, 0xdf);
- }
-
- lcd_write (buf, 0, y);
-}
-
-void
-control_update (void)
-{
-
- show_temp ('P', value, 0);
- show_temp ('T', target, 1);
-
- if (value == ~0U)
- relay_off ();
- else if (value < (target - HYST))
- relay_on ();
- else if (value > (target + HYST))
- relay_off ();
-
-
-}
-
-void
-control_tick (void)
-{
- static int down, up, update;
-
- if (!gpio_get (GPIOB, GPIO4))
- down++;
- else
- down = 0;
-
- if (!gpio_get (GPIOB, GPIO6))
- up++;
- else
- up = 0;
-
- if ((down == SHORT) || (down == LONG))
- {
- if (target > 100)
- target -= 100;
- if (down == LONG)
- down = LONG - REPEAT;
- control_update ();
- }
-
- if ((up == SHORT) || (up == LONG))
- {
- if (target < 99900)
- target += 100;
- if (up == LONG)
- up = LONG - REPEAT;
- control_update ();
- }
-
- update++;
-
- if (update == 1000)
- {
- control_update ();
- update = 0;
- }
-}
-
-void
-control_report (uint32_t v)
-{
-
- value = v;
- control_update ();
-}
-
-void
-control_init (void)
-{
-
- gpio_set_mode (GPIOB, GPIO_MODE_INPUT, GPIO_CNF_INPUT_PULL_UPDOWN,
- GPIO4 | GPIO6);
- gpio_set_mode (GPIOB, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL,
- GPIO5);
- gpio_set (GPIOB, GPIO4 | GPIO6);
- gpio_clear (GPIOB, GPIO5);
-
-
-}