This commit is contained in:
Passthem
2025-04-14 16:02:39 +08:00
parent d9c6c1b4b7
commit f23f7b05b2
9 changed files with 47 additions and 45 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
/dist/
/build/
*.o
*.out

26
.vscode/settings.json vendored
View File

@ -1,23 +1,11 @@
{
"files.associations": {
"*.py": "python",
"types.h": "c",
"spidev.h": "c",
"fcntl.h": "c",
"stdlib.h": "c",
"math.h": "c",
"spi_utils.h": "c",
"cstdint": "c",
"color_utils.h": "c",
"data_sban_period2.h": "c",
"shader.h": "c",
"signal.h": "c",
"ioctl.h": "c",
"stdio.h": "c",
"ostream": "c",
"system_error": "c",
"variant": "c",
"string.h": "c",
"cstdlib": "c"
}
"app.h": "c",
"time.h": "c"
},
"C_Cpp.errorSquiggles": "enabled",
"C_Cpp.default.includePath": [
"./include"
]
}

View File

@ -1,27 +1,46 @@
CC = gcc
CFLAGS = -Wall -Wextra -O2
LDFLAGS = -lm
# 编译器设置
CC := gcc
CFLAGS := -Wall -Wextra -O2 -I./include
LDFLAGS := -lm
LIBS :=
SRC_DIR = src
DIST_DIR = dist
# 目录设置
SRC_DIR := src
BUILD_DIR := build
DIST_DIR := dist
INCLUDE_DIR := include
SRCS = $(wildcard $(SRC_DIR)/*.c)
OBJS = $(SRCS:$(SRC_DIR)/%.c=$(DIST_DIR)/%.o)
TARGET = $(DIST_DIR)/main
# 获取源文件和目标文件
SOURCES := $(wildcard $(SRC_DIR)/*.c)
OBJECTS := $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(SOURCES))
DEPS := $(OBJECTS:.o=.d) # 自动生成的依赖文件
MKDIR_P = mkdir -p
# 最终可执行文件
TARGET := $(DIST_DIR)/main
# 默认目标
all: $(TARGET)
$(TARGET): $(OBJS)
$(MKDIR_P) $(DIST_DIR)
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
# 链接可执行文件
$(TARGET): $(OBJECTS) | $(DIST_DIR)
$(CC) $(LDFLAGS) $^ -o $@ $(LIBS)
$(DIST_DIR)/%.o: $(SRC_DIR)/%.c
$(MKDIR_P) $(DIST_DIR)
$(CC) $(CFLAGS) -c $< -o $@
# 编译源文件并生成依赖
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c | $(BUILD_DIR)
$(CC) $(CFLAGS) -MMD -MP -c $< -o $@
# 创建必要的目录
$(BUILD_DIR):
mkdir -p $@
$(DIST_DIR):
mkdir -p $@
# 包含自动生成的依赖
-include $(DEPS)
# 清理构建
clean:
rm -rf $(DIST_DIR)
rm -rf $(BUILD_DIR) $(TARGET)
.PHONY: all clean

View File

@ -7,11 +7,15 @@
typedef struct AppContext {
int stop_flag;
int light_fd;
uint8_t* buffer;
Color* colors;
Status* status;
struct timeval start_time;
int num_leds;
int data_size;
} AppContext;

View File

@ -1,13 +1,3 @@
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <unistd.h>
#include "color_utils.h"
#include "shader.h"
#include "spi_utils.h"
#include "app.h"
int main() {