mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Style
This commit is contained in:
@@ -3,9 +3,9 @@
|
|||||||
#include "BSP.h"
|
#include "BSP.h"
|
||||||
#include "I2C_Wrapper.hpp"
|
#include "I2C_Wrapper.hpp"
|
||||||
#include "Model_Config.h"
|
#include "Model_Config.h"
|
||||||
#include "Utils.h"
|
|
||||||
#include "Pins.h"
|
#include "Pins.h"
|
||||||
#include "Setup.h"
|
#include "Setup.h"
|
||||||
|
#include "Utils.h"
|
||||||
#include "history.hpp"
|
#include "history.hpp"
|
||||||
#include "main.hpp"
|
#include "main.hpp"
|
||||||
#include <IRQ.h>
|
#include <IRQ.h>
|
||||||
@@ -15,9 +15,7 @@ uint16_t totalPWM = 255;
|
|||||||
const uint16_t powerPWM = 255;
|
const uint16_t powerPWM = 255;
|
||||||
|
|
||||||
history<uint16_t, PID_TIM_HZ> rawTempFilter = {{0}, 0, 0};
|
history<uint16_t, PID_TIM_HZ> rawTempFilter = {{0}, 0, 0};
|
||||||
void resetWatchdog() {
|
void resetWatchdog() { HAL_IWDG_Refresh(&hiwdg); }
|
||||||
HAL_IWDG_Refresh(&hiwdg);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef TEMP_NTC
|
#ifdef TEMP_NTC
|
||||||
// Lookup table for the NTC
|
// Lookup table for the NTC
|
||||||
@@ -56,9 +54,7 @@ uint16_t getHandleTemperature() {
|
|||||||
return Utils::InterpolateLookupTable(NTCHandleLookup, NTCHandleLookupItems, result);
|
return Utils::InterpolateLookupTable(NTCHandleLookup, NTCHandleLookupItems, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t getTipInstantTemperature() {
|
uint16_t getTipInstantTemperature() { return getADC(2); }
|
||||||
return getADC(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t getTipRawTemp(uint8_t refresh) {
|
uint16_t getTipRawTemp(uint8_t refresh) {
|
||||||
if (refresh) {
|
if (refresh) {
|
||||||
@@ -176,22 +172,11 @@ void unstick_I2C() {
|
|||||||
HAL_I2C_Init(&hi2c1);
|
HAL_I2C_Init(&hi2c1);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t getButtonA() {
|
uint8_t getButtonA() { return HAL_GPIO_ReadPin(KEY_A_GPIO_Port, KEY_A_Pin) == GPIO_PIN_RESET ? 1 : 0; }
|
||||||
return HAL_GPIO_ReadPin(KEY_A_GPIO_Port, KEY_A_Pin) == GPIO_PIN_RESET ?
|
uint8_t getButtonB() { return HAL_GPIO_ReadPin(KEY_B_GPIO_Port, KEY_B_Pin) == GPIO_PIN_RESET ? 1 : 0; }
|
||||||
1 : 0;
|
|
||||||
}
|
|
||||||
uint8_t getButtonB() {
|
|
||||||
return HAL_GPIO_ReadPin(KEY_B_GPIO_Port, KEY_B_Pin) == GPIO_PIN_RESET ?
|
|
||||||
1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BSPInit(void) {
|
void BSPInit(void) {}
|
||||||
}
|
|
||||||
|
|
||||||
void reboot() {
|
void reboot() { NVIC_SystemReset(); }
|
||||||
NVIC_SystemReset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void delay_ms(uint16_t count) {
|
void delay_ms(uint16_t count) { HAL_Delay(count); }
|
||||||
HAL_Delay(count);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -8,9 +8,9 @@
|
|||||||
#include "TipThermoModel.h"
|
#include "TipThermoModel.h"
|
||||||
#include "BSP.h"
|
#include "BSP.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
#include "Utils.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "main.hpp"
|
#include "main.hpp"
|
||||||
#include "Utils.h"
|
|
||||||
#include "power.hpp"
|
#include "power.hpp"
|
||||||
/*
|
/*
|
||||||
* The hardware is laid out as a non-inverting op-amp
|
* The hardware is laid out as a non-inverting op-amp
|
||||||
@@ -218,9 +218,7 @@ const uint16_t uVtoDegC[] = {
|
|||||||
#endif
|
#endif
|
||||||
const int uVtoDegCItems = sizeof(uVtoDegC) / (2 * sizeof(uint16_t));
|
const int uVtoDegCItems = sizeof(uVtoDegC) / (2 * sizeof(uint16_t));
|
||||||
|
|
||||||
uint32_t TipThermoModel::convertuVToDegC(uint32_t tipuVDelta) {
|
uint32_t TipThermoModel::convertuVToDegC(uint32_t tipuVDelta) { return Utils::InterpolateLookupTable(uVtoDegC, uVtoDegCItems, tipuVDelta); }
|
||||||
return Utils::InterpolateLookupTable(uVtoDegC,uVtoDegCItems,tipuVDelta);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t TipThermoModel::convertuVToDegF(uint32_t tipuVDelta) { return convertCtoF(convertuVToDegC(tipuVDelta)); }
|
uint32_t TipThermoModel::convertuVToDegF(uint32_t tipuVDelta) { return convertCtoF(convertuVToDegC(tipuVDelta)); }
|
||||||
|
|
||||||
|
|||||||
@@ -7,26 +7,17 @@
|
|||||||
|
|
||||||
#include <Utils.h>
|
#include <Utils.h>
|
||||||
|
|
||||||
int32_t Utils::InterpolateLookupTable(const uint16_t *lookupTable,
|
int32_t Utils::InterpolateLookupTable(const uint16_t *lookupTable, const int noItems, const uint16_t value) {
|
||||||
const int noItems, const uint16_t value) {
|
|
||||||
if (value) {
|
if (value) {
|
||||||
for (int i = 1; i < (noItems - 1); i++) {
|
for (int i = 1; i < (noItems - 1); i++) {
|
||||||
// If current tip temp is less than current lookup, then this current lookup is the higher point to interpolate
|
// If current tip temp is less than current lookup, then this current lookup is the higher point to interpolate
|
||||||
if (value < lookupTable[i * 2]) {
|
if (value < lookupTable[i * 2]) {
|
||||||
return LinearInterpolate(lookupTable[(i - 1) * 2],
|
return LinearInterpolate(lookupTable[(i - 1) * 2], lookupTable[((i - 1) * 2) + 1], lookupTable[i * 2], lookupTable[(i * 2) + 1], value);
|
||||||
lookupTable[((i - 1) * 2) + 1], lookupTable[i * 2],
|
|
||||||
lookupTable[(i * 2) + 1], value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return LinearInterpolate(lookupTable[(noItems - 2) * 2],
|
return LinearInterpolate(lookupTable[(noItems - 2) * 2], lookupTable[((noItems - 2) * 2) + 1], lookupTable[(noItems - 1) * 2], lookupTable[((noItems - 1) * 2) + 1], value);
|
||||||
lookupTable[((noItems - 2) * 2) + 1],
|
|
||||||
lookupTable[(noItems - 1) * 2],
|
|
||||||
lookupTable[((noItems - 1) * 2) + 1], value);
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t Utils::LinearInterpolate(int32_t x1, int32_t y1, int32_t x2, int32_t y2,
|
int32_t Utils::LinearInterpolate(int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t x) { return y1 + (((((x - x1) * 1000) / (x2 - x1)) * (y2 - y1))) / 1000; }
|
||||||
int32_t x) {
|
|
||||||
return y1 + (((((x - x1) * 1000) / (x2 - x1)) * (y2 - y1))) / 1000;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -10,11 +10,8 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
class Utils {
|
class Utils {
|
||||||
public:
|
public:
|
||||||
static int32_t InterpolateLookupTable(const uint16_t *lookupTable,
|
static int32_t InterpolateLookupTable(const uint16_t *lookupTable, const int noItems, const uint16_t value);
|
||||||
const int noItems, const uint16_t value);
|
static int32_t LinearInterpolate(int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t x);
|
||||||
static int32_t LinearInterpolate(int32_t x1, int32_t y1, int32_t x2,
|
|
||||||
int32_t y2, int32_t x);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* CORE_DRIVERS_UTILS_H_ */
|
#endif /* CORE_DRIVERS_UTILS_H_ */
|
||||||
|
|||||||
Reference in New Issue
Block a user