1 /* This file is part of LED Pattern Editor.
3 * Copyright (C) 2010 Philipp Zabel
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.
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.
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/>.
19 class LedCommandWidget : Gtk.HBox {
22 public LedCommandWidget (LedCommand _command) {
27 switch (command.type) {
28 case CommandType.UNKNOWN:
29 LedCommandRX51 cmd = command as LedCommandRX51;
31 text = "??? (0x%04x)".printf (cmd.code);
35 case CommandType.RAMP_WAIT:
38 case CommandType.SET_PWM:
41 case CommandType.RESET_MUX:
44 case CommandType.REPEAT:
47 case CommandType.STOP:
52 var label = new Gtk.Label (text);
53 label.set_alignment (0.0f, 0.5f);
54 pack_start (label, true, true, 0);
56 switch (command.type) {
57 case CommandType.RAMP_WAIT:
58 var selector = new Hildon.TouchSelector.text ();
59 for (int i = 1; i <= 31; i++)
60 selector.append_text ("%.2f ms".printf (i * 0.49));
61 for (int i = 1; i <= 31; i++)
62 selector.append_text ("%.1f ms".printf (i * 15.6));
63 var picker = new Hildon.PickerButton (Hildon.SizeType.FINGER_HEIGHT,
64 Hildon.ButtonArrangement.VERTICAL);
65 picker.set_title ("Step time");
66 picker.set_selector (selector);
68 if (command.step_time <= 31*0.49)
69 j = (int) ((command.step_time + 0.001) / 0.49) - 1;
71 j = (int) ((command.step_time + 0.01) / 15.6) + 30;
72 picker.set_active (j);
73 picker.value_changed.connect ((s) => {
75 int i = s.get_active ();
77 step_time = (i + 1) * 0.49;
79 step_time = (i - 30) * 15.6;
80 command.ramp_wait (step_time, command.steps);
82 pack_start (picker, true, true, 0);
84 selector = new Hildon.TouchSelector.text ();
85 for (int i = -255; i < 256; i++)
86 selector.append_text ("%+d".printf (i));
87 picker = new Hildon.PickerButton (Hildon.SizeType.FINGER_HEIGHT,
88 Hildon.ButtonArrangement.VERTICAL);
89 picker.set_title ("Steps");
90 picker.set_selector (selector);
91 picker.set_active (command.steps + 255);
92 picker.value_changed.connect ((s) => {
93 int steps = s.get_active () - 255;
94 command.ramp_wait (command.step_time, steps);
96 pack_start (picker, true, true, 0);
98 case CommandType.SET_PWM:
99 label = new Gtk.Label ("");
100 pack_start (label, true, true, 0);
101 var selector = new Hildon.TouchSelector.text ();
102 for (int i = 0; i < 256; i++)
103 selector.append_text ("%d".printf (i));
104 var picker = new Hildon.PickerButton (Hildon.SizeType.FINGER_HEIGHT,
105 Hildon.ButtonArrangement.VERTICAL);
106 picker.set_title ("Level");
107 picker.set_selector (selector);
108 picker.set_active (command.level);
109 picker.value_changed.connect ((s) => {
110 int level = s.get_active ();
111 command.set_pwm (level);
113 pack_start (picker, true, true, 0);
115 case CommandType.UNKNOWN:
116 case CommandType.RESET_MUX:
117 case CommandType.REPEAT:
118 case CommandType.STOP:
119 label = new Gtk.Label ("");
120 pack_start (label, true, true, 0);
121 label = new Gtk.Label ("");
122 pack_start (label, true, true, 0);