diff --git a/Makefile b/Makefile index a6049c5..3dc9c35 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,7 @@ endif C_FLAGS += -fpic -C_FLAGS += -O0 -g -Wall +C_FLAGS += -O0 -ggdb3 -Wall CPP_FLAGS += $(addprefix -I, $(INCLUDES)) CHECK_FLAGS = $(addprefix -I,$(filter-out $(PREFIX)/include/,$(INCLUDES))) @@ -116,11 +116,11 @@ check: $(CC_SRCS) $(UNIT_TEST_TARGET): $(UNIT_TEST_OBJS) $(THIS_MAKEFILE) @mkdir -p $(BIN_DIR)/$(UNIT_TEST_SRC_DIR) - $(CC) $(CC_FLAGS) $(LD_FLAGS) $(UNIT_TEST_OBJS) -o $@ + $(CC) $(C_FLAGS) $(LD_FLAGS) $(UNIT_TEST_OBJS) -o $@ $(TARGET): $(OBJS) $(THIS_MAKEFILE) @mkdir -p $(BIN_DIR) - $(CC) $(CC_FLAGS) $(LD_FLAGS) $(OBJS) $(addprefix -l,$(LIBS)) -o $@ + $(CC) $(C_FLAGS) $(LD_FLAGS) $(OBJS) $(addprefix -l,$(LIBS)) -o $@ .PRECIOUS: $(OBJ_DIR)/%.d $(OBJ_DIR)/%.d: $(SRC_DIR)/%.c diff --git a/src/main.c b/src/main.c index 5548ad9..fbb6506 100644 --- a/src/main.c +++ b/src/main.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "board.h" #include "driver.h" @@ -90,28 +91,40 @@ int main(void) double dest_x; double dest_y; + time_t T; + struct tm tm; + while(1) { img_load(image, clock_face, 240 * 240); + // just to shown image orientation + img_draw_line(image, 10, 10, 12, 12, 0x00f8); + img_draw_line(image, 10, 11, 12, 12, 0x00f8); + img_draw_line(image, 10, 12, 12, 12, 0x00f8); + + T = time(NULL); + tm = *localtime(&T); + + min_angle = (360 / 60) * tm.tm_min; + if(min_angle >= 360.0) { + min_angle -= 360.0; + } + dest_x = root_x + min_len * cos(min_angle * M_PI / 180); dest_y = root_y + min_len * sin(min_angle * M_PI / 180); img_draw_line(image, (uint16_t)root_x, (uint16_t)root_y, (uint16_t)dest_x, (uint16_t)dest_y, 0xffff); - min_angle += 360 / 60; + + std_angle = 0.5 * (60 * tm.tm_hour + tm.tm_min); + if(std_angle >= 360.0) { + std_angle -= 360.0; + } dest_x = root_x + std_len * cos(std_angle * M_PI / 180); dest_y = root_y + std_len * sin(std_angle * M_PI / 180); img_draw_line(image, (uint16_t)root_x, (uint16_t)root_y, (uint16_t)dest_x, (uint16_t)dest_y, 0xffff); - std_angle += 360.0 / (60 * 12); drv_write(&lcd_drv, (const char *)image, 240 * 240); sleep(1); - - if(min_angle >= 360.0) { - min_angle -= 360.0; - } - if(std_angle >= 360.0) { - std_angle -= 360.0; - } } drv_close(&lcd_drv);