哇袄2
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
|||||||
/dist/
|
/dist/
|
||||||
|
/build/
|
||||||
|
|
||||||
*.o
|
*.o
|
||||||
*.out
|
*.out
|
||||||
|
|||||||
26
.vscode/settings.json
vendored
26
.vscode/settings.json
vendored
@ -1,23 +1,11 @@
|
|||||||
{
|
{
|
||||||
"files.associations": {
|
"files.associations": {
|
||||||
"*.py": "python",
|
"*.py": "python",
|
||||||
"types.h": "c",
|
"app.h": "c",
|
||||||
"spidev.h": "c",
|
"time.h": "c"
|
||||||
"fcntl.h": "c",
|
},
|
||||||
"stdlib.h": "c",
|
"C_Cpp.errorSquiggles": "enabled",
|
||||||
"math.h": "c",
|
"C_Cpp.default.includePath": [
|
||||||
"spi_utils.h": "c",
|
"./include"
|
||||||
"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"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
51
Makefile
51
Makefile
@ -1,27 +1,46 @@
|
|||||||
CC = gcc
|
# 编译器设置
|
||||||
CFLAGS = -Wall -Wextra -O2
|
CC := gcc
|
||||||
LDFLAGS = -lm
|
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)
|
SOURCES := $(wildcard $(SRC_DIR)/*.c)
|
||||||
TARGET = $(DIST_DIR)/main
|
OBJECTS := $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(SOURCES))
|
||||||
|
DEPS := $(OBJECTS:.o=.d) # 自动生成的依赖文件
|
||||||
|
|
||||||
MKDIR_P = mkdir -p
|
# 最终可执行文件
|
||||||
|
TARGET := $(DIST_DIR)/main
|
||||||
|
|
||||||
|
# 默认目标
|
||||||
all: $(TARGET)
|
all: $(TARGET)
|
||||||
|
|
||||||
$(TARGET): $(OBJS)
|
# 链接可执行文件
|
||||||
$(MKDIR_P) $(DIST_DIR)
|
$(TARGET): $(OBJECTS) | $(DIST_DIR)
|
||||||
$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
|
$(CC) $(LDFLAGS) $^ -o $@ $(LIBS)
|
||||||
|
|
||||||
$(DIST_DIR)/%.o: $(SRC_DIR)/%.c
|
# 编译源文件并生成依赖
|
||||||
$(MKDIR_P) $(DIST_DIR)
|
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c | $(BUILD_DIR)
|
||||||
$(CC) $(CFLAGS) -c $< -o $@
|
$(CC) $(CFLAGS) -MMD -MP -c $< -o $@
|
||||||
|
|
||||||
|
# 创建必要的目录
|
||||||
|
$(BUILD_DIR):
|
||||||
|
mkdir -p $@
|
||||||
|
|
||||||
|
$(DIST_DIR):
|
||||||
|
mkdir -p $@
|
||||||
|
|
||||||
|
# 包含自动生成的依赖
|
||||||
|
-include $(DEPS)
|
||||||
|
|
||||||
|
# 清理构建
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(DIST_DIR)
|
rm -rf $(BUILD_DIR) $(TARGET)
|
||||||
|
|
||||||
.PHONY: all clean
|
.PHONY: all clean
|
||||||
@ -7,11 +7,15 @@
|
|||||||
|
|
||||||
typedef struct AppContext {
|
typedef struct AppContext {
|
||||||
int stop_flag;
|
int stop_flag;
|
||||||
|
|
||||||
int light_fd;
|
int light_fd;
|
||||||
|
|
||||||
uint8_t* buffer;
|
uint8_t* buffer;
|
||||||
Color* colors;
|
Color* colors;
|
||||||
Status* status;
|
Status* status;
|
||||||
|
|
||||||
struct timeval start_time;
|
struct timeval start_time;
|
||||||
|
|
||||||
int num_leds;
|
int num_leds;
|
||||||
int data_size;
|
int data_size;
|
||||||
} AppContext;
|
} AppContext;
|
||||||
10
src/main.c
10
src/main.c
@ -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"
|
#include "app.h"
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|||||||
Reference in New Issue
Block a user