Skip to content

Commit

Permalink
Improve integration between IDE/PropellerManager
Browse files Browse the repository at this point in the history
- IDE now selects the last connected device as current (IDE-179)
- Device availability / blinky while loading working again
- Devices can be completely disconnected from the IDE
  • Loading branch information
bweir committed Feb 9, 2016
1 parent 7ef2ee6 commit 6d3492e
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 42 deletions.
10 changes: 8 additions & 2 deletions src/propelleride/buildmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void BuildManager::hideStatus()
void BuildManager::waitClose()
{
timer.setSingleShot(true);
timer.start(1000);
timer.start(100);
}

void BuildManager::setFont(const QFont & font)
Expand Down Expand Up @@ -101,9 +101,14 @@ void BuildManager::compilerFinished(int exitCode, QProcess::ExitStatus status)
setText(tr("Build successful!"));

if (config.load)
load();
{
if (!load())
emit finished();
}
else
{
emit finished();
}
}
}

Expand Down Expand Up @@ -227,6 +232,7 @@ bool BuildManager::load(const QByteArray & binary)
}

loader.upload(image, config.write, true, true);
emit finished();

waitClose();
return true;
Expand Down
5 changes: 5 additions & 0 deletions src/propelleride/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,11 @@ void MainWindow::updatePorts()
if(cbPort->count())
{
setEnableBuild(true);
QStringList latest = manager.latestPorts();
if (!latest.isEmpty())
{
cbPort->setCurrentIndex(cbPort->findText(latest.last()));
}
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/propellermanager
Submodule propellermanager updated 54 files
+2 −0 .gitignore
+1 −0 app/propman/.gitignore
+6 −16 app/propman/main.cpp
+1 −0 include/.gitignore
+1 −1 include/PropellerDevice
+1 −1 include/PropellerImage
+1 −1 include/PropellerLoader
+1 −1 include/PropellerManager
+1 −1 include/PropellerSession
+1 −1 include/PropellerTerminal
+0 −8 src/common/include.pri
+0 −0 src/console.h
+60 −0 src/devicemanager.h
+0 −0 src/firmware/miniloader.spin
+0 −0 src/firmware/spin.pro
+1 −1 src/gpio.cpp
+0 −0 src/gpio.h
+0 −0 src/logging.cpp
+0 −0 src/logging.h
+22 −3 src/portmonitor.cpp
+2 −1 src/portmonitor.h
+368 −0 src/propellerdevice.cpp
+13 −5 src/propellerdevice.h
+0 −7 src/propellerdevice/include.pri
+0 −341 src/propellerdevice/propellerdevice.cpp
+1 −1 src/propellerimage.cpp
+0 −0 src/propellerimage.h
+0 −5 src/propellerimage/include.pri
+1 −1 src/propellerloader.cpp
+2 −2 src/propellerloader.h
+0 −7 src/propellerloader/include.pri
+63 −7 src/propellermanager.cpp
+9 −1 src/propellermanager.h
+0 −58 src/propellermanager/deviceinterface.h
+0 −38 src/propellermanager/devicemanager.h
+0 −16 src/propellermanager/include.pri
+0 −0 src/propellersession.cpp
+28 −0 src/propellersession.h
+0 −6 src/propellersession/include.pri
+0 −62 src/propellersession/propellersession.h
+0 −0 src/propellerterminal.cpp
+1 −1 src/propellerterminal.h
+0 −6 src/propellerterminal/include.pri
+0 −0 src/protocol.cpp
+0 −0 src/protocol.h
+0 −0 src/readbuffer.cpp
+0 −0 src/readbuffer.h
+19 −13 src/sessioninterface.h
+3 −3 src/sessionmanager.cpp
+1 −1 src/sessionmanager.h
+33 −7 src/src.pro
+39 −15 src/template/connector.h
+4 −2 src/template/interface.h
+3 −3 src/template/manager.h
109 changes: 71 additions & 38 deletions src/propterm/src/propterm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,29 @@ PropTerm::PropTerm(PropellerManager * manager,
updatePorts();
ui.console->clear();

connect(&rxTimeout, SIGNAL(timeout()), this, SLOT(turnOffRxLight()));
connect(&txTimeout, SIGNAL(timeout()), this, SLOT(turnOffTxLight()));
connect(&busyTimeout, SIGNAL(timeout()), this, SLOT(handleBusy()));
connect(&rxTimeout, SIGNAL(timeout()), this, SLOT(turnOffRxLight()));
connect(&txTimeout, SIGNAL(timeout()), this, SLOT(turnOffTxLight()));
connect(&busyTimeout, SIGNAL(timeout()), this, SLOT(handleBusy()));

connect(manager, SIGNAL(portListChanged()), this, SLOT(updatePorts()));
connect(session, SIGNAL(sendError(const QString &)), this, SLOT(handleError()));
connect(session, SIGNAL(baudRateChanged(qint32)), this, SLOT(setWidgetBaudRate(qint32)));
connect(ui.console, SIGNAL(getData(QByteArray)), this, SLOT(writeData(QByteArray)));
connect(ui.echo, SIGNAL(toggled(bool)), ui.console, SLOT(setEcho(bool)));
connect(manager, SIGNAL(portListChanged()), this, SLOT(updatePorts()));
connect(session, SIGNAL(sendError(const QString &)), this, SLOT(handleError()));
connect(session, SIGNAL(baudRateChanged(qint32)), this, SLOT(setWidgetBaudRate(qint32)));

connect(ui.sendLineEdit,SIGNAL(returnPressed()),this, SLOT(sendDataLine()));
connect(ui.sendButton, SIGNAL(pressed()), this, SLOT(sendDataLine()));
connect(session, SIGNAL(deviceStateChanged(bool)), this, SLOT(handleDeviceStateChanged(bool)));
connect(session, SIGNAL(deviceAvailableChanged(bool)), this, SLOT(handleAvailable(bool)));

connect(ui.port, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(portChanged()));
connect(ui.baudRate, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(setDeviceBaudRate(const QString &)));
connect(ui.console, SIGNAL(getData(QByteArray)), this, SLOT(writeData(QByteArray)));
connect(ui.echo, SIGNAL(toggled(bool)), ui.console, SLOT(setEcho(bool)));

connect(ui.clear, SIGNAL(clicked()), ui.console, SLOT(clear()));
connect(ui.reset, SIGNAL(clicked()), this, SLOT(reset()));
connect(ui.activeButton,SIGNAL(toggled(bool)), this, SLOT(handleEnable(bool)));
connect(ui.sendLineEdit,SIGNAL(returnPressed()), this, SLOT(sendDataLine()));
connect(ui.sendButton, SIGNAL(pressed()), this, SLOT(sendDataLine()));

connect(ui.port, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(portChanged()));
connect(ui.baudRate, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(setDeviceBaudRate(const QString &)));

connect(ui.clear, SIGNAL(clicked()), ui.console, SLOT(clear()));
connect(ui.reset, SIGNAL(clicked()), this, SLOT(reset()));
connect(ui.activeButton,SIGNAL(toggled(bool)), this, SLOT(handleDevicePower(bool)));

title = tr("Terminal");

Expand Down Expand Up @@ -113,39 +117,56 @@ void PropTerm::toggleTxLight(bool enabled)
}
}


void PropTerm::setEnabled(bool enabled)
{
ui.console->enable(enabled);
ui.console->setEnabled(enabled);
ui.sendButton->setEnabled(enabled);
ui.sendLineEdit->setEnabled(enabled);
ui.baudRate->setEnabled(enabled);
ui.reset->setEnabled(enabled);
ui.clear->setEnabled(enabled);

disconnect(ui.activeButton,SIGNAL(toggled(bool)), this, SLOT(handleDevicePower(bool)));
ui.activeButton->setChecked(enabled);
connect(ui.activeButton,SIGNAL(toggled(bool)), this, SLOT(handleDevicePower(bool)));

session->setPaused(!enabled);
}

void PropTerm::open()
{
ui.console->enable(true);
ui.console->setEnabled(true);
ui.sendButton->setEnabled(true);
ui.sendLineEdit->setEnabled(true);
setEnabled(true);
ui.activeLight->setPixmap(QPixmap(":/icons/propterm/led-green.png"));

portChanged();
session->setPaused(false);
setDeviceBaudRate(ui.baudRate->currentText());

connect(session, SIGNAL(readyRead()), this, SLOT(readData()));
}

void PropTerm::closed()
{
ui.console->enable(false);
ui.console->setEnabled(false);
ui.sendButton->setEnabled(false);
ui.sendLineEdit->setEnabled(false);
setEnabled(false);
ui.activeLight->setPixmap(QPixmap(":/icons/propterm/led-off.png"));

session->setPaused(true);

disconnect(session, SIGNAL(readyRead()), this, SLOT(readData()));
}

void PropTerm::handleAvailable(bool available)
{
if (available)
free();
else
busy();
}

void PropTerm::busy()
{
closed();
ui.activeLight->setPixmap(QPixmap(":/icons/propterm/led-yellow.png"));
busyTimeout.start(125);
busyTimeout.start(75);
}

void PropTerm::free()
Expand All @@ -162,16 +183,19 @@ void PropTerm::reset()

void PropTerm::portChanged()
{
qCDebug(terminal) << "switch to port" << ui.port->currentText();
session->setPortName(ui.port->currentText());
setWidgetBaudRate(session->baudRate());
if (session->portName().isEmpty())
if (ui.port->currentText() != session->portName())
{
setWindowTitle(tr("%1").arg(title));
}
else
{
setWindowTitle(tr("%1 - %2").arg(session->portName()).arg(title));
qCDebug(terminal) << "switch to port" << ui.port->currentText();
session->setPortName(ui.port->currentText());
setWidgetBaudRate(session->baudRate());
if (session->portName().isEmpty())
{
setWindowTitle(tr("%1").arg(title));
}
else
{
setWindowTitle(tr("%1 - %2").arg(session->portName()).arg(title));
}
}
}

Expand Down Expand Up @@ -225,9 +249,17 @@ void PropTerm::handleError()
closed();
}

void PropTerm::handleEnable(bool checked)
void PropTerm::handleDevicePower(bool enabled)
{
if (enabled)
manager->openPort(session->portName());
else
manager->closePort(session->portName());
}

void PropTerm::handleDeviceStateChanged(bool enabled)
{
if (checked)
if (enabled)
open();
else
closed();
Expand All @@ -246,3 +278,4 @@ void PropTerm::handleBusy()
busytoggle = true;
}
}

5 changes: 4 additions & 1 deletion src/propterm/src/propterm.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,21 @@ class PropTerm : public QWidget

public slots:
void setFont(const QFont & font);
void setEnabled(bool enabled);

private slots:
void open();
void closed();
void handleAvailable(bool available);
void free();
void busy();
void reset();
void writeData(const QByteArray & data);
void readData();

void handleError();
void handleEnable(bool checked);
void handleDeviceStateChanged(bool enabled);
void handleDevicePower(bool enabled);
void handleBusy();

void portChanged();
Expand Down

0 comments on commit 6d3492e

Please sign in to comment.