my first Lua

This commit is contained in:
Andrey 2021-08-22 00:00:20 -04:00
parent daf7bad539
commit 94fcb15506
3 changed files with 13 additions and 1 deletions

View File

@ -7,6 +7,7 @@
#include "airmass.h"
#include "lua_airmass.h"
#include "can_msg_tx.h"
#include "settings.h"
// Some functions lean on existing FSIO implementation
#include "fsio_impl.h"
@ -19,6 +20,14 @@ static int lua_efi_print(lua_State* l) {
return 0;
}
static int lua_readpin(lua_State* l) {
auto msg = luaL_checkstring(l, 1);
#if ! EFI_UNIT_TEST
readPin(msg);
#endif
return 0;
}
static int lua_getSensor(lua_State* l) {
auto sensorIndex = luaL_checkinteger(l, 1);
@ -281,6 +290,7 @@ static int lua_stopEngine(lua_State*) {
void configureRusefiLuaHooks(lua_State* l) {
lua_register(l, "print", lua_efi_print);
lua_register(l, "readpin", lua_readpin);
lua_register(l, "getSensor", lua_getSensor);
lua_register(l, "getSensorRaw", lua_getSensorRaw);
lua_register(l, "hasSensor", lua_hasSensor);

View File

@ -466,7 +466,7 @@ static void setIgnitionPin(const char *indexStr, const char *pinName) {
}
// this method is useful for desperate time debugging
static void readPin(const char *pinName) {
void readPin(const char *pinName) {
brain_pin_e pin = parseBrainPinWithErrorMessage(pinName);
if (pin == GPIO_INVALID) {
return;

View File

@ -17,6 +17,8 @@ void scheduleStopEngine(void);
void setCallFromPitStop(int durationMs);
void printTPSInfo(void);
void setEngineType(int value DECLARE_ENGINE_PARAMETER_SUFFIX);
void readPin(const char *pinName);
/**
* See also getEngine_type_e()
*/