From e33119b1194dea8521053ebc383377de442dc801 Mon Sep 17 00:00:00 2001 From: fengbh <1953356163@qq.com> Date: Sun, 14 Jan 2024 23:11:38 +0800 Subject: [PATCH] detect os and lsb release --- Makefile | 30 ++++++++++++------------------ src/main.c | 12 ++++++------ 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 0ee3263..1f7f12d 100644 --- a/Makefile +++ b/Makefile @@ -1,28 +1,22 @@ # detect OS ifeq ($(OS),Windows_NT) - RM = del /q + RM := del /q + COM := COM3 else - UNAME_S := $(shell uname -s) - ifeq ($(UNAME_S),Linux) - RM = rm -rf + RM =: rm -rf + + UNAME_S := $(shell cat /etc/*-release | grep 'DISTRIB_ID' | sed 's/DISTRIB_ID=\(\w*\)/\1/g') + ifeq ($(UNAME_S),Ubuntu) + CC := sdcc + COM := /dev/ttyUSB0 endif - ifeq ($(UNAME_S),Darwin) - RM = rm -rf + ifeq ($(UNAME_S),Deepin) + CC := ablrun sdcc + COM := /dev/ttyUSB0 endif - # UNAME_P := $(shell uname -p) - # ifeq ($(UNAME_P),x86_64) - # CCFLAGS += -D AMD64 - # endif - # ifneq ($(filter %86,$(UNAME_P)),) - # CCFLAGS += -D IA32 - # endif - # ifneq ($(filter arm%,$(UNAME_P)),) - # CCFLAGS += -D ARM - # endif endif # set CC TOOL -CC := sdcc PACKIHX := packihx CFLAGS := -DUSE_FLOATS=1 @@ -54,7 +48,7 @@ uart_temp.hex: $(TARGET) -$(PACKIHX) $(TARGET) > uart_temp.hex flash: - -stcgal -P stc89 -p COM3 .\uart_temp.hex + -stcgal -P stc89 -p $(COM) -d uart_temp.hex #led.bin:led.hex # objcopy -I ihex -O binary led.hex led.bin diff --git a/src/main.c b/src/main.c index f9506ac..f8b392e 100644 --- a/src/main.c +++ b/src/main.c @@ -53,14 +53,14 @@ void main(void) smg_display(temp_buf,4); // 串口打印 - if(pre_temp_value != temp_value){ - pre_temp_value = temp_value; - printf("temp = %.1f\n", temp_value/10.0); - } + // if(pre_temp_value != temp_value){ + // pre_temp_value = temp_value; + // printf("temp = %.1f\n", temp_value/10.0); + // } // delay - // delay_ms(10); - // printf("temp = %.1f\n", temp_value/10.0); + delay_ms(1000); + printf("temp = %.1f\r\n", temp_value/10.0); } }