Bump to latest simapi for unix timestamp ticks. Push unix timestamp ticks to lua variable. Update test logic to test on 8000 rpms. Update example lua scripts with examples of led rpm blink.

This commit is contained in:
Paul Dino Jones
2025-07-15 16:39:41 -04:00
parent d2fa72f47c
commit 0abd5e9b68
5 changed files with 130 additions and 4 deletions
@@ -3,14 +3,29 @@
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <sys/time.h>
#include "arduinoledlua.h"
#include "arduino.h"
#include "../../slog/slog.h"
long long ledTimeInMilliseconds(void) {
struct timeval tv;
gettimeofday(&tv,NULL);
return (((long long)tv.tv_sec)*1000)+(tv.tv_usec/1000);
}
int simdata_to_lua(lua_State *L, SimData* simdata) {
// make the time up now if we are running in test mode
if(simdata->mtick == 0)
{
simdata->mtick = ledTimeInMilliseconds();
}
lua_newtable(L);
lua_pushinteger(L, simdata->playerflag);
@@ -19,6 +34,9 @@ int simdata_to_lua(lua_State *L, SimData* simdata) {
lua_pushinteger(L, simdata->rpms);
lua_setfield(L, -2, "rpm");
lua_pushinteger(L, simdata->mtick);
lua_setfield(L, -2, "mtick");
lua_pushinteger(L, simdata->maxrpm);
lua_setfield(L, -2, "maxrpm");
+10
View File
@@ -878,6 +878,16 @@ int tester(SimDevice* devices, int numdevices)
devices[x].update(&devices[x], simdata);
}
}
for(int x = 0; x < 100; x++)
{
for (int x = 0; x < numdevices; x++)
{
if (devices[x].initialized == true)
{
devices[x].update(&devices[x], simdata);
}
}
}
sleep(3);
simdata->velocity = 0;