Example #1
0
GuiSettingsWidget::GuiSettingsWidget(Device *device, QWidget *parent)
	: StandardWidget(device, parent),
	ui(new Ui::GuiSettingsWidget())
{
	ui->setupUi(this);
	performStandardSetup(tr("GUI Settings"));
	
	connect(ui->colors, SIGNAL(currentIndexChanged(int)), SLOT(colorChanged(int)));
  connect(ui->fullscreen, SIGNAL(stateChanged(int)), SLOT(fullscreenChanged(int)));
	
	SettingsProvider *settings = device->settingsProvider();
	if(!settings) {
		ui->colors->setEnabled(false);
    ui->fullscreen->setEnabled(false);
		return;
	}
	
	QColor currentColor = settings->value(GUI_COLOR_KEY, guiColors[0]).value<QColor>();
	quint16 current = 0;
	for(quint16 i = 0; i < sizeof_array(guiColors); ++i) {
		if(currentColor == guiColors[i]) {
			current = i;
			break;
		}
	}
	ui->colors->setCurrentIndex(current);
  
  const bool currentFullscreen = settings->value(FULLSCREEN_KEY, true).toBool();
  ui->fullscreen->setChecked(currentFullscreen);
}
Example #2
0
ServosWidget::ServosWidget(Device *device, QWidget *parent)
	: StandardWidget(device, parent),
	ui(new Ui::ServosWidget),
	m_provider(new NumpadDialog(QString()))
{
	ui->setupUi(this);
	performStandardSetup(tr("Servos"));
	
	ui->number->setInputProvider(m_provider);
	
	connect(ui->dial, SIGNAL(valueChanged(double)), SLOT(positionChanged(double)));
  connect(ui->number, SIGNAL(textEdited(QString)), SLOT(manualEntry(QString)));
	connect(ui->port_0, SIGNAL(clicked()), SLOT(activeChanged()));
	connect(ui->port_1, SIGNAL(clicked()), SLOT(activeChanged()));
	connect(ui->port_2, SIGNAL(clicked()), SLOT(activeChanged()));
	connect(ui->port_3, SIGNAL(clicked()), SLOT(activeChanged()));
	connect(ui->enable, SIGNAL(clicked()), SLOT(enable()));
	connect(ui->disable, SIGNAL(clicked()), SLOT(disable()));
	
  // Setup ui for port 0 (the default servo)
	ui->dial->setMinimumValue(0);
	ui->dial->setMaximumValue(2047);
	ui->dial->setValue(get_servo_position(0));
	ui->dial->setLabel(0);
	ui->port_0->setEnabled(false);
  
  const bool servoEnabled = get_servo_enabled(0);
	ui->enable->setVisible(!servoEnabled);
	ui->disable->setVisible(servoEnabled);
  
	publish();
}
Example #3
0
KissIdeSettingsWidget::KissIdeSettingsWidget(Device *device, QWidget *parent)
	: StandardWidget(device, parent),
	ui(new Ui::KissIdeSettingsWidget)
{
	ui->setupUi(this);
	performStandardSetup(tr("KISS IDE Settings"));
}
Example #4
0
ProgramWidget::ProgramWidget(Program *program, Device *device, QWidget *parent)
  : StandardWidget(device, parent),
  ui(new Ui::ProgramWidget),
  m_program(program)
{
  ui->setupUi(this);
  performStandardSetup(tr("Program"));
  // QAction *lock = menuBar()->addAction(UiStandards::lockString());
  // connect(lock, SIGNAL(triggered()), SLOT(lock()));
  
  ui->extra->setVisible(false);
  
  connect(m_program, SIGNAL(started()), SLOT(started()));
  connect(m_program,
    SIGNAL(finished(int, QProcess::ExitStatus)),
    SLOT(finished(int, QProcess::ExitStatus)));
  
  ui->console->setProcess(m_program->process());
  
  ButtonProvider *buttonProvider = device->buttonProvider();
  ui->normal->setEnabled(buttonProvider);
  ui->normal->setVisible(buttonProvider);
  ui->extra->setEnabled(buttonProvider);
  ui->extra->setVisible(buttonProvider);

  if(buttonProvider) {
    ui->extra->setVisible(buttonProvider->isExtraShown());
  
    ui->a->setText(buttonProvider->text(ButtonProvider::A));
    ui->b->setText(buttonProvider->text(ButtonProvider::B));
    ui->c->setText(buttonProvider->text(ButtonProvider::C));
    ui->x->setText(buttonProvider->text(ButtonProvider::X));
    ui->y->setText(buttonProvider->text(ButtonProvider::Y));
    ui->z->setText(buttonProvider->text(ButtonProvider::Z));
  
    connect(ui->a, SIGNAL(pressed()), SLOT(aPressed()));
    connect(ui->b, SIGNAL(pressed()), SLOT(bPressed()));
    connect(ui->c, SIGNAL(pressed()), SLOT(cPressed()));
    connect(ui->x, SIGNAL(pressed()), SLOT(xPressed()));
    connect(ui->y, SIGNAL(pressed()), SLOT(yPressed()));
    connect(ui->z, SIGNAL(pressed()), SLOT(zPressed()));
  
    connect(ui->a, SIGNAL(released()), SLOT(aReleased()));
    connect(ui->b, SIGNAL(released()), SLOT(bReleased()));
    connect(ui->c, SIGNAL(released()), SLOT(cReleased()));
    connect(ui->x, SIGNAL(released()), SLOT(xReleased()));
    connect(ui->y, SIGNAL(released()), SLOT(yReleased()));
    connect(ui->z, SIGNAL(released()), SLOT(zReleased()));

    connect(buttonProvider, SIGNAL(buttonTextChanged(ButtonProvider::ButtonId, QString)),
      SLOT(buttonTextChanged(ButtonProvider::ButtonId, QString)));
    connect(buttonProvider, SIGNAL(extraShownChanged(bool)), SLOT(extraShownChanged(bool)));
  
    QTimer *timer = new QTimer(this);
    timer->start(100);
    buttonProvider->connect(timer, SIGNAL(timeout()), SLOT(refresh()));
  
    buttonProvider->reset();
  }
}
Example #5
0
CompilingWidget::CompilingWidget(Device *device, QWidget *parent)
	: StandardWidget(device, parent),
	ui(new Ui::CompilingWidget)
{
	ui->setupUi(this);
	performStandardSetup(tr("Compiling..."));
}
ChannelConfigurationsWidget::ChannelConfigurationsWidget(Device *device, QWidget *parent)
	: StandardWidget(device, parent),
	ui(new Ui::ChannelConfigurationsWidget),
	m_model(new ChannelConfigurationsModel(this)),
	m_import(new QAction(tr("Import"), this)),
	m_defaultPath("")
{
	ui->setupUi(this);
	performStandardSetup(tr("Channel Configurations"));
	menuBar()->addAction(m_import);
	
	ui->configs->setModel(m_model);
	ui->configs->setItemDelegate(new ConfigItemDelegate(this));
	
	ui->configs->setRootIndex(m_model->index(m_model->rootPath()));

	connect(ui->edit, SIGNAL(clicked()), SLOT(edit()));
	connect(ui->rename, SIGNAL(clicked()), SLOT(rename()));
	connect(ui->default_, SIGNAL(clicked()), SLOT(default_()));
	connect(ui->add, SIGNAL(clicked()), SLOT(add()));
	connect(ui->remove, SIGNAL(clicked()), SLOT(remove()));
	connect(ui->configs->selectionModel(),
		SIGNAL(currentChanged(QModelIndex, QModelIndex)),
		SLOT(currentChanged(QModelIndex)));
	
	m_defaultPath = m_model->filePath(m_model->defaultConfiguration());
	
	currentChanged(QModelIndex());
}
Example #7
0
MotorsSensorsWidget::MotorsSensorsWidget(Device *device, QWidget *parent)
	: StandardWidget(device, parent),
	ui(new Ui::MotorsSensorsWidget)
{
	ui->setupUi(this);
	performStandardSetup(tr("Motors and Sensors"));
	
	connect(ui->servos, SIGNAL(clicked()), SLOT(servos()));
	connect(ui->motors, SIGNAL(clicked()), SLOT(motors()));
	connect(ui->sensorGraph, SIGNAL(clicked()), SLOT(sensorGraph()));
	connect(ui->sensorList, SIGNAL(clicked()), SLOT(sensorList()));
	connect(ui->camera, SIGNAL(clicked()), SLOT(camera()));
	connect(ui->pidTuner, SIGNAL(clicked()), SLOT(pidTuner()));
}
Example #8
0
CombinedMotorWidget::CombinedMotorWidget(Device *device, QWidget *parent)
	: StandardWidget(device, parent),
	ui(new Ui::CombinedMotorWidget)
{
	ui->setupUi(this);
	
	performStandardSetup(tr("Motors"), false);
	
	QAction *clearPosition = menuBar()->addAction(tr("Clear Position"));
	connect(clearPosition, SIGNAL(activated()), SLOT(clearPosition()));
	
	ui->pwm->setMinimumValue(-100.0);
	ui->pwm->setMaximumValue(100.0);
	ui->pwm->setValue(0.0);
	
	ui->velocity->setMinimumValue(-1500.0);
	ui->velocity->setMaximumValue(1500.0);
	ui->velocity->setValue(0.0);
	
	connect(ui->pwm, SIGNAL(valueChanged(double)),
		SLOT(pwmChanged(double)));
	connect(ui->velocity, SIGNAL(valueChanged(double)),
		SLOT(velChanged(double)));
	
	connect(ui->pwmStop, SIGNAL(clicked()), SLOT(stop()));
	connect(ui->velocityStop, SIGNAL(clicked()), SLOT(stop()));
	connect(ui->positionStop, SIGNAL(clicked()), SLOT(stop()));
	
	connect(ui->fd, SIGNAL(clicked()), SLOT(forward()));
	connect(ui->bk, SIGNAL(clicked()), SLOT(backward()));
	
	connect(ui->tabs, SIGNAL(currentChanged(int)), SLOT(stop()));
	
	connect(ui->go, SIGNAL(clicked()), SLOT(go()));
	
	QTimer *timer = new QTimer(this);
	connect(timer, SIGNAL(timeout()), SLOT(update()));
	timer->start(100);
	
	ui->goalPos->setInputProvider(new NumpadDialog(tr("Goal Position"), NumpadDialog::Integer,
		std::numeric_limits<double>::min(), std::numeric_limits<double>::max(), this));
	ui->speed->setInputProvider(new NumpadDialog(tr("Speed"), NumpadDialog::Integer,
		-1500, 1500, this));
	
	ao();
#ifdef A_KOVAN
	publish();
#endif
}
Example #9
0
SensorListWidget::SensorListWidget(Device *device, QWidget *parent)
	: StandardWidget(device, parent)
	, ui(new Ui::SensorListWidget())
{
	ui->setupUi(this);
	
	performStandardSetup(tr("Sensor List"));
	
	SensorModel *model = new SensorModel(this);
	ui->sensors->setModel(model);
	
	QTimer *timer = new QTimer(this);
	model->connect(timer, SIGNAL(timeout()), SLOT(update()));
	timer->start(50); // 20 FPS
}
Example #10
0
HomeWidget::HomeWidget(Device *device, QWidget *parent)
	: StandardWidget(device, parent),
	ui(new Ui::HomeWidget)
{
	ui->setupUi(this);
	performStandardSetup(UiStandards::homeString());
	
	connect(ui->programs, SIGNAL(clicked()), SLOT(programs()));
	connect(ui->fileManager, SIGNAL(clicked()), SLOT(fileManager()));
	connect(ui->motorsSensors, SIGNAL(clicked()), SLOT(motorsSensors()));
	connect(ui->settings, SIGNAL(clicked()), SLOT(settings()));
	
	// QAction *lock = menuBar()->addAction(UiStandards::lockString());
	// connect(lock, SIGNAL(triggered()), SLOT(lock()));
	QAction *about = menuBar()->addAction(tr("About"));
	connect(about, SIGNAL(triggered()), SLOT(about()));
}
Example #11
0
SensorListWidget::SensorListWidget(Device *device, QWidget *parent)
	: StandardWidget(device, parent)
	, ui(new Ui::SensorListWidget())
  , _model(new SensorModel(this))
{
	ui->setupUi(this);
	
	performStandardSetup(tr("Sensor List"));
  _togglePullUp = menuBar()->addAction(tr("Toggle Pull-up"));
  connect(_togglePullUp, SIGNAL(triggered()), SLOT(togglePullUp()));
	
	ui->sensors->setModel(_model);
  ui->sensors->setItemDelegate(new SensorItemDelegate(_model, this));
	
  QTimer *timer = new QTimer(this);
  _model->connect(timer, SIGNAL(timeout()), SLOT(update()));
  timer->start(50); // 20 FPS
}
Example #12
0
LanguageWidget::LanguageWidget(Device *device, QWidget *const parent)
  : StandardWidget(device, parent)
  , ui(new Ui::LanguageWidget)
{
  ui->setupUi(this);
  performStandardSetup(tr("Language Widget"));
  
  LocaleModel *localeModel = new LocaleModel(this);
  ui->languages->setModel(localeModel);
  
  const QString currLocale = QSettings().value("locale", "en").toString();
  for(int i = 0; i < ui->languages->count(); ++i) {
    if(localeModel->locale(localeModel->index(i, 0)).bcp47Name() != currLocale) continue;
    ui->languages->setCurrentIndex(i);
    break;
  }
  connect(ui->languages, SIGNAL(currentIndexChanged(int)), SLOT(currentIndexChanged(int)));
}
Example #13
0
MotorsSensorsWidget::MotorsSensorsWidget(Device *device, QWidget *parent)
	: StandardWidget(device, parent),
	ui(new Ui::MotorsSensorsWidget)
{
	ui->setupUi(this);
	performStandardSetup(tr("Motors and Sensors"));
	
	connect(ui->servos, SIGNAL(clicked()), SLOT(servos()));
	connect(ui->motors, SIGNAL(clicked()), SLOT(motors()));
	connect(ui->sensorGraph, SIGNAL(clicked()), SLOT(sensorGraph()));
	connect(ui->sensorList, SIGNAL(clicked()), SLOT(sensorList()));
	connect(ui->camera, SIGNAL(clicked()), SLOT(camera()));
	connect(ui->pidTuner, SIGNAL(clicked()), SLOT(pidTuner()));
	connect(ui->depth, SIGNAL(clicked()), SLOT(depth()));

	// TODO: remove these once the widgets work on the Wallaby
	ui->pidTuner->setVisible(false);
	ui->depth->setVisible(false);
}
Example #14
0
PidTunerWidget::PidTunerWidget(Device *device, QWidget *parent)
	: StandardWidget(device, parent),
	ui(new Ui::PidTunerWidget)
{
	ui->setupUi(this);
	performStandardSetup(tr("PID Tuner"), false);
	connect(ui->p, SIGNAL(textChanged(QString)), SLOT(coeffChanged()));
	connect(ui->i, SIGNAL(textChanged(QString)), SLOT(coeffChanged()));
	connect(ui->d, SIGNAL(textChanged(QString)), SLOT(coeffChanged()));
	connect(ui->motor, SIGNAL(currentIndexChanged(int)), SLOT(motorChanged()));
	//void get_pid_gains(int motor, short *p, short *i, short *d, short *pd, short *id, short *dd)



	NumpadDialog *pProvider = new NumpadDialog(tr("P Value"), NumpadDialog::Decimal, -99.0, 99.0, this);
	NumpadDialog *iProvider = new NumpadDialog(tr("I Value"), NumpadDialog::Decimal, -99.0, 99.0, this);
	NumpadDialog *dProvider = new NumpadDialog(tr("D Value"), NumpadDialog::Decimal, -99.0, 99.0, this);

	ui->p->setInputProvider(pProvider);
	ui->i->setInputProvider(iProvider);
	ui->d->setInputProvider(dProvider);


	m_feedback = ui->plot->addPlot(QColor(0, 0, 200));
	m_setpoint = ui->plot->addPlot(QColor(0, 0, 0));

	updatePids();

	QTimer *updateTimer = new QTimer(this);
	connect(updateTimer, SIGNAL(timeout()), SLOT(update()));
	updateTimer->start(UPDATE_MS);

	connect(ui->plot, SIGNAL(mouseEvent(double)), SLOT(mouseEvent(double)));


	m_setpointVal = 0.0;
	m_feedbackVal = 0.0;
	m_position_1 = 0;
	m_vel_1 = 0;

}
Example #15
0
NetworkSettingsWidget::NetworkSettingsWidget(Device *device, QWidget *parent)
	: StandardWidget(device, parent),
	ui(new Ui::NetworkSettingsWidget)
{
	ui->setupUi(this);
	performStandardSetup(tr("Network Settings"));
	
	ui->turnOn->setVisible(false);
	ui->turnOff->setVisible(false);
	
	QObject::connect(ui->connect, SIGNAL(clicked()), SLOT(connect()));
	QObject::connect(ui->manage, SIGNAL(clicked()), SLOT(manage()));
	NetworkManager::ref().connect(ui->turnOn, SIGNAL(clicked()), SLOT(turnOn()));
	NetworkManager::ref().connect(ui->turnOff, SIGNAL(clicked()), SLOT(turnOff()));
	
	QObject::connect(&NetworkManager::ref(),
		SIGNAL(stateChanged(const NetworkManager::State &, const NetworkManager::State &)),
		SLOT(stateChanged(const NetworkManager::State &, const NetworkManager::State &)));
	
	updateInformation();
}