Skip to content

Commit

Permalink
Lisp repl support
Browse files Browse the repository at this point in the history
  • Loading branch information
vedderb committed Mar 1, 2022
1 parent c77a17b commit 40b8871
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 9 deletions.
8 changes: 8 additions & 0 deletions commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2048,6 +2048,14 @@ void Commands::lispGetStats()
emitData(vb);
}

void Commands::lispSendReplCmd(QString str)
{
VByteArray vb;
vb.vbAppendUint8(COMM_LISP_REPL_CMD);
vb.vbAppendString(str);
emitData(vb);
}

void Commands::setBleName(QString name)
{
VByteArray vb;
Expand Down
1 change: 1 addition & 0 deletions commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ public slots:
void lispEraseCode();
void lispSetRunning(bool running);
void lispGetStats();
void lispSendReplCmd(QString str);

void setBleName(QString name);
void setBlePin(QString pin);
Expand Down
7 changes: 6 additions & 1 deletion datatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,12 @@ typedef enum {
COMM_LISP_ERASE_CODE,
COMM_LISP_SET_RUNNING,
COMM_LISP_GET_STATS,
COMM_LISP_PRINT
COMM_LISP_PRINT,

COMM_BMS_SET_BATT_TYPE,
COMM_BMS_GET_BATT_TYPE,

COMM_LISP_REPL_CMD,
} COMM_PACKET_ID;

// CAN commands
Expand Down
13 changes: 12 additions & 1 deletion pages/pagelisp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ PageLisp::PageLisp(QWidget *parent) :
ui->uploadButton->setIcon(QIcon(theme +"icons/Download-96.png"));
ui->readExistingButton->setIcon(QIcon(theme +"icons/Upload-96.png"));
ui->eraseButton->setIcon(QIcon(theme +"icons/Delete-96.png"));
ui->rescaleButton->setIcon(QPixmap(theme + "icons/expand_off.png"));
ui->replHelpButton->setIcon(QPixmap(theme + "icons/Help-96.png"));

QIcon mycon = QIcon(theme + "icons/expand_off.png");
mycon.addPixmap(QPixmap(theme + "icons/expand_on.png"), QIcon::Normal, QIcon::On);
Expand Down Expand Up @@ -798,3 +798,14 @@ void PageLisp::on_helpButton_clicked()

HelpDialog::showHelpMonospace(this, "VESC Tool Script Editor", html.replace(" "," "));
}

void PageLisp::on_replEdit_returnPressed()
{
mVesc->commands()->lispSendReplCmd(ui->replEdit->text());
ui->replEdit->clear();
}

void PageLisp::on_replHelpButton_clicked()
{
mVesc->commands()->lispSendReplCmd(":help");
}
2 changes: 2 additions & 0 deletions pages/pagelisp.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ private slots:
void on_eraseButton_clicked();
void on_rescaleButton_clicked();
void on_helpButton_clicked();
void on_replEdit_returnPressed();
void on_replHelpButton_clicked();

private:
Ui::PageLisp *ui;
Expand Down
60 changes: 53 additions & 7 deletions pages/pagelisp.ui
Original file line number Diff line number Diff line change
Expand Up @@ -317,15 +317,56 @@
<attribute name="title">
<string>Console</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="VTextBrowser" name="debugEdit">
<property name="font">
<font>
<family>DejaVu Sans Mono</family>
</font>
<layout class="QVBoxLayout" name="verticalLayout_8">
<property name="spacing">
<number>3</number>
</property>
</widget>
<item>
<widget class="VTextBrowser" name="debugEdit">
<property name="font">
<font>
<family>DejaVu Sans Mono</family>
</font>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Repl</string>
</property>
</widget>
</item>
<item>
<widget class="HistoryLineEdit" name="replEdit"/>
</item>
<item>
<widget class="QPushButton" name="replHelpButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Print available commands</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../res.qrc">
<normaloff>:/res/+theme_light/icons/Help-96.png</normaloff>:/res/+theme_light/icons/Help-96.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
Expand Down Expand Up @@ -680,6 +721,11 @@
<header>widgets/qcustomplot.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>HistoryLineEdit</class>
<extends>QLineEdit</extends>
<header>widgets/historylineedit.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../res.qrc"/>
Expand Down

0 comments on commit 40b8871

Please sign in to comment.