--- /dev/null
+/* This file is part of LED Pattern Editor.
+ *
+ * Copyright (C) 2010 Philipp Zabel
+ *
+ * LED Pattern Editor 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * LED Pattern Editor 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 LED Pattern Editor. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+class LedCommandWidget : Gtk.HBox {
+ LedCommand command;
+
+ public LedCommandWidget (LedCommand _command) {
+ homogeneous = true;
+ command = _command;
+
+ string text = "";
+ switch (command.type) {
+ case CommandType.UNKNOWN:
+ LedCommandRX51 cmd = command as LedCommandRX51;
+ if (cmd != null)
+ text = "??? (0x%04x)".printf (cmd.code);
+ else
+ text = "???";
+ break;
+ case CommandType.RAMP_WAIT:
+ text = "Ramp / Wait";
+ break;
+ case CommandType.SET_PWM:
+ text = "Set PWM";
+ break;
+ case CommandType.RESET_MUX:
+ text = "Reset mux";
+ break;
+ case CommandType.REPEAT:
+ text = "Repeat";
+ break;
+ case CommandType.STOP:
+ text = "Stop";
+ break;
+ }
+
+ var label = new Gtk.Label (text);
+ label.set_alignment (0.0f, 0.5f);
+ pack_start (label, true, true, 0);
+
+ switch (command.type) {
+ case CommandType.RAMP_WAIT:
+ var selector = new Hildon.TouchSelector.text ();
+ for (int i = 1; i <= 31; i++)
+ selector.append_text ("%.2f ms".printf (i * 0.49));
+ for (int i = 1; i <= 31; i++)
+ selector.append_text ("%.1f ms".printf (i * 15.6));
+ var picker = new Hildon.PickerButton (Hildon.SizeType.FINGER_HEIGHT,
+ Hildon.ButtonArrangement.VERTICAL);
+ picker.set_title ("Step time");
+ picker.set_selector (selector);
+ int j;
+ if (command.step_time <= 31*0.49)
+ j = (int) ((command.step_time + 0.001) / 0.49) - 1;
+ else
+ j = (int) ((command.step_time + 0.01) / 15.6) + 30;
+ picker.set_active (j);
+ picker.value_changed.connect ((s) => {
+ double step_time;
+ int i = s.get_active ();
+ if (i < 31)
+ step_time = (i + 1) * 0.49;
+ else
+ step_time = (i - 30) * 15.6;
+ command.ramp_wait (step_time, command.steps);
+ });
+ pack_start (picker, true, true, 0);
+
+ selector = new Hildon.TouchSelector.text ();
+ for (int i = -255; i < 256; i++)
+ selector.append_text ("%+d".printf (i));
+ picker = new Hildon.PickerButton (Hildon.SizeType.FINGER_HEIGHT,
+ Hildon.ButtonArrangement.VERTICAL);
+ picker.set_title ("Steps");
+ picker.set_selector (selector);
+ picker.set_active (command.steps + 255);
+ picker.value_changed.connect ((s) => {
+ int steps = s.get_active () - 255;
+ command.ramp_wait (command.step_time, steps);
+ });
+ pack_start (picker, true, true, 0);
+ break;
+ case CommandType.SET_PWM:
+ label = new Gtk.Label ("");
+ pack_start (label, true, true, 0);
+ var selector = new Hildon.TouchSelector.text ();
+ for (int i = 0; i < 256; i++)
+ selector.append_text ("%d".printf (i));
+ var picker = new Hildon.PickerButton (Hildon.SizeType.FINGER_HEIGHT,
+ Hildon.ButtonArrangement.VERTICAL);
+ picker.set_title ("Level");
+ picker.set_selector (selector);
+ picker.set_active (command.level);
+ picker.value_changed.connect ((s) => {
+ int level = s.get_active ();
+ command.set_pwm (level);
+ });
+ pack_start (picker, true, true, 0);
+ break;
+ case CommandType.UNKNOWN:
+ case CommandType.RESET_MUX:
+ case CommandType.REPEAT:
+ case CommandType.STOP:
+ label = new Gtk.Label ("");
+ pack_start (label, true, true, 0);
+ label = new Gtk.Label ("");
+ pack_start (label, true, true, 0);
+ break;
+ }
+ }
+}