my first Lua
This commit is contained in:
parent
f55c5d6791
commit
42cddf810f
|
@ -34,17 +34,8 @@ static int lua_readpin(lua_State* l) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int lua_getAuxAnalog(lua_State* l) {
|
static int getSensor(lua_State* l, SensorType type) {
|
||||||
auto sensorIndex = luaL_checkinteger(l, 1);
|
auto result = Sensor::get(type);
|
||||||
|
|
||||||
lua_pushnumber(l, sensorIndex);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int lua_getSensor(lua_State* l) {
|
|
||||||
auto sensorIndex = luaL_checkinteger(l, 1);
|
|
||||||
|
|
||||||
auto result = Sensor::get(static_cast<SensorType>(sensorIndex));
|
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
// return value if valid
|
// return value if valid
|
||||||
|
@ -57,6 +48,20 @@ static int lua_getSensor(lua_State* l) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int lua_getAuxAnalog(lua_State* l) {
|
||||||
|
auto sensorIndex = luaL_checkinteger(l, 1);
|
||||||
|
|
||||||
|
auto type = static_cast<SensorType>(sensorIndex + static_cast<int>(SensorType::Aux1));
|
||||||
|
|
||||||
|
return getSensor(l, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int lua_getSensor(lua_State* l) {
|
||||||
|
auto sensorIndex = luaL_checkinteger(l, 1);
|
||||||
|
|
||||||
|
return getSensor(l, static_cast<SensorType>(sensorIndex));
|
||||||
|
}
|
||||||
|
|
||||||
static int lua_getSensorRaw(lua_State* l) {
|
static int lua_getSensorRaw(lua_State* l) {
|
||||||
auto sensorIndex = luaL_checkinteger(l, 1);
|
auto sensorIndex = luaL_checkinteger(l, 1);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue