Skip to content

Commit

Permalink
feat: add missing log and switchTab gridui methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Tasssadar committed Jul 5, 2024
1 parent b31cbd7 commit 78f9379
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
13 changes: 12 additions & 1 deletion main/espFeatures/gridui/gridUiFeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ class GridUiHolder {

void begin(jac::ContextRef context, std::string ownerName, std::string deviceName, jac::Function builderCallback);
void end(jac::ContextRef context);

void log(const std::string& msg) {
if(_protocol) {
_protocol->send_log(msg);
}
}
};

template<class Next>
Expand Down Expand Up @@ -55,7 +61,12 @@ class GridUiFeature : public Next {
griduiModule.addExport("end", ff.newFunction(noal::function([this]() {
_holder.end(this->context());
})));

griduiModule.addExport("changeTab", ff.newFunction(noal::function([](int tab){
UI.changeTab(tab);
})));
griduiModule.addExport("log", ff.newFunction(noal::function([this](std::string message){
_holder.log(message);
})));
griduiModule.addExport("version", ff.newFunction(noal::function([](){
return RB_GRIDUI_VERSION;
})));
Expand Down
10 changes: 10 additions & 0 deletions ts-examples/@types/gridui.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,16 @@ declare module "gridui" {
*/
function end(): void

/**
* Set current tab index
*/
function changeTab(index: number): void

/**
* Send a message to the integrated terminal at the top of the UI.
*/
function log(message: string): void

/**
* Returns included GridUI version as number, to be compared with hex representation of the version.
*
Expand Down

0 comments on commit 78f9379

Please sign in to comment.