This commit is contained in:
Imbus 2025-12-26 03:19:09 +01:00
parent d87abd3ec0
commit 92ccea0883
4 changed files with 44 additions and 4 deletions

View file

@ -12,6 +12,18 @@ SRC := $(wildcard *.c)
OBJ := $(SRC:.c=.o)
ELF := $(SRC:.c=.elf)
SUBDIRS += buf
SUBDIRS += cjson
SUBDIRS += dynbuf
SUBDIRS += filters
SUBDIRS += hashmap
SUBDIRS += linalg
SUBDIRS += lua_advanced
SUBDIRS += lua_embed
SUBDIRS += message
SUBDIRS += socket
SUBDIRS += sqlite
%.o: %.c
@echo CC $@
@$(CC) $(CFLAGS) -c -o $@ $<
@ -21,6 +33,9 @@ ELF := $(SRC:.c=.elf)
@$(CC) $(LIBS) -o $@ $<
all: $(ELF)
@for dir in $(SUBDIRS); do \
$(MAKE) -C $$dir; \
done
sub:
@-find . -mindepth 1 -maxdepth 1 -type d -exec make --no-print-directory -C {} \;
@ -35,8 +50,9 @@ format:
clang-format -i $(shell git ls-files '*.c' '*.h')
clean:
@echo "Cleaning up..."
@rm -rf $(OBJ) $(ELF) *.json .cache
@find . -mindepth 1 -maxdepth 1 -type d -exec make --no-print-directory -C {} clean \;
rm -rf $(OBJ) $(ELF) *.json .cache
@for dir in $(SUBDIRS); do \
$(MAKE) -C $$dir clean; \
done
.PHONY: format

View file

@ -2,7 +2,7 @@ CC = gcc
CFLAGS = -Wall -O2
TARGET = main.elf
SRC = main.c
SRC = main.c esc.c
LDFLAGS += -lm
LDFLAGS += -llua

View file

@ -1,3 +1,4 @@
#include "esc.h"
#include <lauxlib.h>
#include <lua.h>
#include <lualib.h>
@ -42,6 +43,7 @@ int main(void) {
lua_State *L = luaL_newstate();
luaL_openlibs(L); // Load Lua standard libraries
register_esc(L);
// luaL_requiref(L, "_G", luaopen_base, 1);
// const lua_Number ver = lua_version(NULL);

View file

@ -11,3 +11,25 @@ function printvec(v) end
vec = { x = 1.0, y = 2.0, z = 3.0 }
printvec(vec)
--- Enumerate symbols in namespace
---@param t
function dir(t)
for k, v in pairs(t) do
print(k, type(v))
end
end
dir(esc)
-- get config
local cfg = esc.get_esc_config()
print(cfg.maxspeed, cfg.odometer, cfg.started)
-- modify
esc.set_maxspeed(200)
esc.set_started(true)
esc.add_odometer(5.5)
-- see changes
cfg = esc.get_esc_config()
print(cfg.maxspeed, cfg.odometer, cfg.started)