blob: 7189c671231d5d165b55c5d386660a6d7b2286aa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
/*
* Xytronic LF-1600
* Temperature presets
*
* Copyright (c) 2016-2017 Michael Buesch <m@bues.ch>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "presets.h"
#include "settings.h"
#include "controller_temp.h"
#include "ring.h"
#include "menu.h"
#include <string.h>
#if CONF_PRESETS
static void presets_store(void)
{
store_settings();
contrtemp_update_setpoint();
menu_request_display_update();
}
#endif
void presets_next(void)
{
#if CONF_PRESETS
struct settings *settings;
settings = get_settings();
settings->temp_setpoint_active = ring_next(settings->temp_setpoint_active,
NR_PRESETS - 1u);
presets_store();
#endif
}
void presets_prev(void)
{
#if CONF_PRESETS
struct settings *settings;
settings = get_settings();
settings->temp_setpoint_active = ring_prev(settings->temp_setpoint_active,
NR_PRESETS - 1u);
presets_store();
#endif
}
uint8_t presets_get_active_index(void)
{
#if CONF_PRESETS
return get_settings()->temp_setpoint_active;
#else
return 0u;
#endif
}
fixpt_t presets_get_active_value(void)
{
struct settings *settings;
uint8_t active_index;
fixpt_t value;
settings = get_settings();
active_index = settings->temp_setpoint_active;
value = settings->temp_setpoint[active_index];
return value;
}
void presets_set_active_value(fixpt_t value)
{
struct settings *settings;
uint8_t active_index;
settings = get_settings();
active_index = settings->temp_setpoint_active;
settings->temp_setpoint[active_index] = value;
presets_store();
}
void presets_init(void)
{
}
|