refactor function and file naming
This commit is contained in:
@@ -1 +1,6 @@
|
||||
#ifndef __EEPROM_24AA02E48
|
||||
#define __EEPROM_24AA02E48
|
||||
|
||||
void EEPROM_24AA02E48_run_test(void);
|
||||
|
||||
#endif
|
||||
|
||||
9
Core/Inc/DNI.h
Normal file
9
Core/Inc/DNI.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef __DNI
|
||||
#define __DNI
|
||||
|
||||
extern ADC_HandleTypeDef hadc1;
|
||||
|
||||
void DNI_show_celsius(void);
|
||||
void DNI_show_fahrenheit(void);
|
||||
|
||||
#endif
|
||||
@@ -1,2 +1,7 @@
|
||||
#ifndef __PCA9685
|
||||
#define __PCA9685
|
||||
|
||||
void PCA9685_run_test(void);
|
||||
void PCA9685_cleanup(void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user