From 9a40b5a6fb1f44db09ba3a1689ac777e7e0e336a Mon Sep 17 00:00:00 2001
From: hasslesstech <hasslesstech@tutanota.com>
Date: Sun, 9 Mar 2025 14:35:40 +0200
Subject: [PATCH] refactor function and file naming

---
 Core/Inc/24AA02E48.h                |  5 ++++
 Core/Inc/DNI.h                      |  9 +++++++
 Core/Inc/PCA9685.h                  |  5 ++++
 Core/Inc/external_temp.h            | 11 ---------
 Core/Src/{external_temp.c => DNI.c} | 38 ++++++++++++++---------------
 Core/Src/main.c                     |  6 ++---
 Debug/Core/Src/subdir.mk            | 11 ++++++---
 Debug/objects.list                  |  6 ++++-
 8 files changed, 53 insertions(+), 38 deletions(-)
 create mode 100644 Core/Inc/DNI.h
 delete mode 100644 Core/Inc/external_temp.h
 rename Core/Src/{external_temp.c => DNI.c} (58%)

diff --git a/Core/Inc/24AA02E48.h b/Core/Inc/24AA02E48.h
index ed0ba0c..e39d5a4 100644
--- a/Core/Inc/24AA02E48.h
+++ b/Core/Inc/24AA02E48.h
@@ -1 +1,6 @@
+#ifndef __EEPROM_24AA02E48
+#define __EEPROM_24AA02E48
+
 void EEPROM_24AA02E48_run_test(void);
+
+#endif
diff --git a/Core/Inc/DNI.h b/Core/Inc/DNI.h
new file mode 100644
index 0000000..0f9794d
--- /dev/null
+++ b/Core/Inc/DNI.h
@@ -0,0 +1,9 @@
+#ifndef __DNI
+#define __DNI
+
+extern ADC_HandleTypeDef hadc1;
+
+void DNI_show_celsius(void);
+void DNI_show_fahrenheit(void);
+
+#endif
diff --git a/Core/Inc/PCA9685.h b/Core/Inc/PCA9685.h
index 00e8d21..14b9bb8 100644
--- a/Core/Inc/PCA9685.h
+++ b/Core/Inc/PCA9685.h
@@ -1,2 +1,7 @@
+#ifndef __PCA9685
+#define __PCA9685
+
 void PCA9685_run_test(void);
 void PCA9685_cleanup(void);
+
+#endif
diff --git a/Core/Inc/external_temp.h b/Core/Inc/external_temp.h
deleted file mode 100644
index 3ee5e6e..0000000
--- a/Core/Inc/external_temp.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef __EXTERNAL_TEMP
-#define __EXTERNAL_TEMP
-
-extern ADC_HandleTypeDef hadc1;
-
-
-
-void external_temp_show_celsius(void);
-void external_temp_show_fahrenheit(void);
-
-#endif
diff --git a/Core/Src/external_temp.c b/Core/Src/DNI.c
similarity index 58%
rename from Core/Src/external_temp.c
rename to Core/Src/DNI.c
index e9cc7c1..291e73a 100644
--- a/Core/Src/external_temp.c
+++ b/Core/Src/DNI.c
@@ -1,9 +1,9 @@
 #include "main.h"
 #include "generic_macros.h"
 #include "lcd.h"
-#include "external_temp.h"
+#include "DNI.h"
 
-static uint32_t external_temp_read(void)
+static uint32_t DNI_read(void)
 {
 	HAL_ADC_Start(&hadc1);
 	if (HAL_ADC_PollForConversion(&hadc1, 100) != HAL_OK)
@@ -12,17 +12,17 @@ static uint32_t external_temp_read(void)
 	return HAL_ADC_GetValue(&hadc1);
 }
 
-static int external_temp_convert_to_celsius(uint32_t value)
+static int DNI_convert_to_celsius(uint32_t value)
 {
 	return (2512 - value) << 2;
 }
 
-static int external_temp_convert_to_fahrenheit(uint32_t value)
+static int DNI_convert_to_fahrenheit(uint32_t value)
 {
 	return (2953 - value) * 50 / 7;
 }
 
-static void external_temp_print(int temperature)
+static void DNI_print(int temperature)
 {
 	int add_sign = temperature < 0;
 	if (add_sign)
@@ -55,44 +55,44 @@ static void external_temp_print(int temperature)
 	}
 }
 
-static void external_temp_print_celsius(int temperature)
+static void DNI_print_celsius(int temperature)
 {
 	DISPLAY_SET_CURSOR(1, 7);
 	DISPLAY_SET_DECREMENT;
 	display_write_data_seq("C ");
 
-	external_temp_print(temperature);
+	DNI_print(temperature);
 }
 
-static void external_temp_print_fahrenheit(int temperature)
+static void DNI_print_fahrenheit(int temperature)
 {
 	DISPLAY_SET_CURSOR(1, 7);
 	DISPLAY_SET_DECREMENT;
 	display_write_data_seq("F ");
 
-	external_temp_print(temperature);
+	DNI_print(temperature);
 }
 
-void external_temp_show_celsius(void)
+void DNI_show_celsius(void)
 {
 	DISPLAY_CLEAR;
 	DISPLAY_SET_INCREMENT;
 
-	display_write_data_seq("Temperature");
+	display_write_data_seq("DNI Temperature");
 
-	uint32_t value = external_temp_read();
-	int temp = external_temp_convert_to_celsius(value);
-	external_temp_print_celsius(temp);
+	uint32_t value = DNI_read();
+	int temp = DNI_convert_to_celsius(value);
+	DNI_print_celsius(temp);
 }
 
-void external_temp_show_fahrenheit(void)
+void DNI_show_fahrenheit(void)
 {
 	DISPLAY_CLEAR;
 	DISPLAY_SET_INCREMENT;
 
-	display_write_data_seq("Temperature");
+	display_write_data_seq("DNI Temperature");
 
-	uint32_t value = external_temp_read();
-	int temp = external_temp_convert_to_fahrenheit(value);
-	external_temp_print_fahrenheit(temp);
+	uint32_t value = DNI_read();
+	int temp = DNI_convert_to_fahrenheit(value);
+	DNI_print_fahrenheit(temp);
 }
diff --git a/Core/Src/main.c b/Core/Src/main.c
index cfa61a5..5e256f0 100644
--- a/Core/Src/main.c
+++ b/Core/Src/main.c
@@ -24,7 +24,7 @@
 
 #include "generic_macros.h"
 #include "lcd.h"
-#include "external_temp.h"
+#include "DNI.h"
 #include "PCA9685.h"
 #include "24AA02E48.h"
 
@@ -56,8 +56,8 @@ I2C_HandleTypeDef hi2c1;
 /* USER CODE BEGIN PV */
 
 void ((*executors[])(void)) = {
-		external_temp_show_celsius,
-		external_temp_show_fahrenheit,
+		DNI_show_celsius,
+		DNI_show_fahrenheit,
 		PCA9685_run_test,
 		EEPROM_24AA02E48_run_test
 };
diff --git a/Debug/Core/Src/subdir.mk b/Debug/Core/Src/subdir.mk
index 9a6d474..3037b60 100644
--- a/Debug/Core/Src/subdir.mk
+++ b/Debug/Core/Src/subdir.mk
@@ -5,8 +5,9 @@
 
 # Add inputs and outputs from these tool invocations to the build variables 
 C_SRCS += \
+../Core/Src/24AA02E48.c \
+../Core/Src/DNI.c \
 ../Core/Src/PCA9685.c \
-../Core/Src/external_temp.c \
 ../Core/Src/lcd.c \
 ../Core/Src/main.c \
 ../Core/Src/stm32f4xx_hal_msp.c \
@@ -16,8 +17,9 @@ C_SRCS += \
 ../Core/Src/system_stm32f4xx.c 
 
 OBJS += \
+./Core/Src/24AA02E48.o \
+./Core/Src/DNI.o \
 ./Core/Src/PCA9685.o \
-./Core/Src/external_temp.o \
 ./Core/Src/lcd.o \
 ./Core/Src/main.o \
 ./Core/Src/stm32f4xx_hal_msp.o \
@@ -27,8 +29,9 @@ OBJS += \
 ./Core/Src/system_stm32f4xx.o 
 
 C_DEPS += \
+./Core/Src/24AA02E48.d \
+./Core/Src/DNI.d \
 ./Core/Src/PCA9685.d \
-./Core/Src/external_temp.d \
 ./Core/Src/lcd.d \
 ./Core/Src/main.d \
 ./Core/Src/stm32f4xx_hal_msp.d \
@@ -45,7 +48,7 @@ Core/Src/%.o Core/Src/%.su Core/Src/%.cyclo: ../Core/Src/%.c Core/Src/subdir.mk
 clean: clean-Core-2f-Src
 
 clean-Core-2f-Src:
-	-$(RM) ./Core/Src/PCA9685.cyclo ./Core/Src/PCA9685.d ./Core/Src/PCA9685.o ./Core/Src/PCA9685.su ./Core/Src/external_temp.cyclo ./Core/Src/external_temp.d ./Core/Src/external_temp.o ./Core/Src/external_temp.su ./Core/Src/lcd.cyclo ./Core/Src/lcd.d ./Core/Src/lcd.o ./Core/Src/lcd.su ./Core/Src/main.cyclo ./Core/Src/main.d ./Core/Src/main.o ./Core/Src/main.su ./Core/Src/stm32f4xx_hal_msp.cyclo ./Core/Src/stm32f4xx_hal_msp.d ./Core/Src/stm32f4xx_hal_msp.o ./Core/Src/stm32f4xx_hal_msp.su ./Core/Src/stm32f4xx_it.cyclo ./Core/Src/stm32f4xx_it.d ./Core/Src/stm32f4xx_it.o ./Core/Src/stm32f4xx_it.su ./Core/Src/syscalls.cyclo ./Core/Src/syscalls.d ./Core/Src/syscalls.o ./Core/Src/syscalls.su ./Core/Src/sysmem.cyclo ./Core/Src/sysmem.d ./Core/Src/sysmem.o ./Core/Src/sysmem.su ./Core/Src/system_stm32f4xx.cyclo ./Core/Src/system_stm32f4xx.d ./Core/Src/system_stm32f4xx.o ./Core/Src/system_stm32f4xx.su
+	-$(RM) ./Core/Src/24AA02E48.cyclo ./Core/Src/24AA02E48.d ./Core/Src/24AA02E48.o ./Core/Src/24AA02E48.su ./Core/Src/DNI.cyclo ./Core/Src/DNI.d ./Core/Src/DNI.o ./Core/Src/DNI.su ./Core/Src/PCA9685.cyclo ./Core/Src/PCA9685.d ./Core/Src/PCA9685.o ./Core/Src/PCA9685.su ./Core/Src/lcd.cyclo ./Core/Src/lcd.d ./Core/Src/lcd.o ./Core/Src/lcd.su ./Core/Src/main.cyclo ./Core/Src/main.d ./Core/Src/main.o ./Core/Src/main.su ./Core/Src/stm32f4xx_hal_msp.cyclo ./Core/Src/stm32f4xx_hal_msp.d ./Core/Src/stm32f4xx_hal_msp.o ./Core/Src/stm32f4xx_hal_msp.su ./Core/Src/stm32f4xx_it.cyclo ./Core/Src/stm32f4xx_it.d ./Core/Src/stm32f4xx_it.o ./Core/Src/stm32f4xx_it.su ./Core/Src/syscalls.cyclo ./Core/Src/syscalls.d ./Core/Src/syscalls.o ./Core/Src/syscalls.su ./Core/Src/sysmem.cyclo ./Core/Src/sysmem.d ./Core/Src/sysmem.o ./Core/Src/sysmem.su ./Core/Src/system_stm32f4xx.cyclo ./Core/Src/system_stm32f4xx.d ./Core/Src/system_stm32f4xx.o ./Core/Src/system_stm32f4xx.su
 
 .PHONY: clean-Core-2f-Src
 
diff --git a/Debug/objects.list b/Debug/objects.list
index d9eb272..f035123 100644
--- a/Debug/objects.list
+++ b/Debug/objects.list
@@ -1,4 +1,6 @@
-"./Core/Src/external_temp.o"
+"./Core/Src/24AA02E48.o"
+"./Core/Src/DNI.o"
+"./Core/Src/PCA9685.o"
 "./Core/Src/lcd.o"
 "./Core/Src/main.o"
 "./Core/Src/stm32f4xx_hal_msp.o"
@@ -18,6 +20,8 @@
 "./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.o"
 "./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.o"
 "./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.o"
+"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.o"
+"./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.o"
 "./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.o"
 "./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.o"
 "./Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.o"