]> mj.ucw.cz Git - ursary.git/blob - ursaryd.h
Better IR control of lights
[ursary.git] / ursaryd.h
1 /*
2  *      The Ursary Control Panel
3  *
4  *      (c) 2014--2022 Martin Mares <mj@ucw.cz>
5  */
6
7 #include <pulse/pulseaudio.h>
8
9 #define SET_STRING(_field, _val) do { if (!_field || strcmp(_field, _val)) { xfree(_field); _field = xstrdup(_val); } } while (0)
10
11 /* ursary.c */
12
13 void schedule_update(void);
14
15 void notify_rotary(int rotary, int delta);
16 void notify_touch(int rotary, int on);
17 void notify_button(int button, int on);
18 void notify_mqtt(const char *topic, const char *val);
19
20 /* nocturn.c */
21
22 void noct_init(void);
23 bool noct_is_ready(void);
24 void noct_set_ring(int ring, int mode, int val);
25 void noct_set_button(int button, int val);
26 void noct_clear(void);
27
28 extern char noct_rotary_touched[10];    // 8=center, 9=slider
29 extern char noct_button_pressed[16];
30
31 enum ring_mode {
32   RING_MODE_LEFT,
33   RING_MODE_RIGHT,
34   RING_MODE_MID_RIGHT,
35   RING_MODE_MID_SYM,
36   RING_MODE_SINGLE_ON,
37   RING_MODE_SINGLE_OFF,
38 };
39
40 /* dmx.c */
41
42 void dmx_init(void);
43 void dmx_set_pwm(uint index, uint val);
44 bool dmx_is_ready(void);
45
46 /* pulse.c */
47
48 extern char *pulse_default_sink_name;
49
50 struct pulse_client {
51   cnode n;
52   int idx;
53   char *name;
54   char *host;
55 };
56
57 struct pulse_source {
58   cnode n;
59   int idx;
60   char *name;
61   uint channels;
62   uint volume;
63   uint base_volume;
64   bool mute;
65   bool suspended;
66   char *active_port;
67 };
68
69 struct pulse_sink {
70   cnode n;
71   int idx;
72   char *name;
73   uint channels;
74   uint volume;
75   uint base_volume;
76   bool mute;
77   bool suspended;
78   char *active_port;
79 };
80
81 struct pulse_sink_input {
82   cnode n;
83   int idx;
84   char *name;
85   int client_idx;
86   int sink_idx;
87   uint channels;
88   uint volume;
89   bool mute;
90   int noct_group_idx;           // Used by the high-level logic below
91 };
92
93 extern clist pulse_client_list, pulse_source_list, pulse_sink_list, pulse_sink_input_list;
94
95 void pulse_init(void);
96 void pulse_dump(void);
97 bool pulse_is_ready(void);
98 struct pulse_source *pulse_source_by_name(const char *name);
99 struct pulse_source *pulse_source_by_idx(int idx);
100 void pulse_source_set_volume(int idx, pa_cvolume *cvol);
101 void pulse_source_set_mute(int idx, bool mute);
102 void pulse_source_set_port(int idx, const char *port);
103 struct pulse_sink *pulse_sink_by_name(const char *name);
104 struct pulse_sink *pulse_sink_by_idx(int idx);
105 void pulse_sink_set_volume(int idx, pa_cvolume *cvol);
106 void pulse_sink_set_mute(int idx, bool mute);
107 void pulse_sink_set_port(int idx, const char *port);
108 void pulse_sink_input_set_volume(int idx, pa_cvolume *cvol);
109 void pulse_sink_input_set_mute(int idx, bool mute);
110 void pulse_sink_input_move(int input_idx, int sink_idx);
111 struct pulse_client *pulse_client_by_idx(int idx);
112 void pulse_server_set_default_sink(const char *name);
113
114 /* pulse-ucw.c */
115
116 extern struct pa_mainloop_api pmain_api;
117
118 void pmain_init(void);
119
120 /* mpd.c */
121
122 enum mpd_state {
123   MPD_OFFLINE,
124   MPD_CONNECTING,
125   MPD_WAIT_GREETING,
126   MPD_ONLINE,
127 };
128
129 extern enum mpd_state mpd_state;
130
131 void mpd_init(void);
132 const char *mpd_get_player_state(void);
133 void mpd_play(void);
134 void mpd_stop(void);
135 void mpd_pause(int arg);
136 void mpd_next(void);
137 void mpd_prev(void);
138
139 /* mqtt.c */
140
141 void mqtt_init(void);
142 void mqtt_publish(const char *topic, const char *fmt, ...);