Remove the scary message before saving mce.ini
[led-pattern-ed] / src / led-pattern.vala
1 /* This file is part of LED Pattern Editor.
2  *
3  * Copyright (C) 2010 Philipp Zabel
4  *
5  * LED Pattern Editor is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * LED Pattern Editor is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with LED Pattern Editor. If not, see <http://www.gnu.org/licenses/>.
17  */
18
19 abstract class LedPattern : Object {
20         enum ScreenOn {
21                 DISPLAY_OFF = 0,
22                 DISPLAY_ON = 1,
23                 DISPLAY_OFF_ACT_DEAD = 2,
24                 DISPLAY_ON_ACT_DEAD = 3,
25                 DISPLAY_OFF_OR_ACT_DEAD = 4,
26                 DISABLED = 5
27         }
28
29         public string name;
30         public int priority;
31         public int screen_on;
32         public int timeout;
33
34         public double duration;
35
36         public abstract string dump ();
37         public abstract bool parse (string line);
38
39         public signal void changed ();
40 }
41
42 enum CommandType {
43         UNKNOWN,
44         RESET_MUX,
45         SET_PWM,
46         RAMP_WAIT,
47         GO_TO_START,
48         BRANCH,
49         END,
50         TRIGGER
51 }
52
53 class LedCommand : Object {
54         public CommandType type;
55         public double time;
56         public double step_time;
57         public double duration;
58         public int level;
59         public int steps;
60
61         public virtual void set_pwm (int _level) {
62                 type = CommandType.SET_PWM;
63                 level = _level;
64                 changed ();
65         }
66
67         public virtual void ramp_wait (double _step_time, int _steps) {
68                 type = CommandType.RAMP_WAIT;
69                 step_time = _step_time;
70                 steps = _steps;
71                 if (steps < 0)
72                         duration = step_time * (1 - steps);
73                 else
74                         duration = step_time * (steps + 1);
75                 changed ();
76         }
77
78         public virtual void go_to_start () {
79                 type = CommandType.GO_TO_START;
80                 changed ();
81         }
82
83         public virtual void end (bool reset) {
84                 type = CommandType.END;
85                 steps = reset ? -255 : 0;
86                 changed ();
87         }
88
89         public signal void changed ();
90 }
91