Merge branch 'dev' of https://github.com/Ralim/IronOS into magic

This commit is contained in:
Ben V. Brown
2022-06-16 21:44:24 +10:00
20 changed files with 267 additions and 162 deletions

View File

@@ -6,7 +6,7 @@ jobs:
build: build:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
container: container:
image: alpine:3.15 image: alpine:3.16
strategy: strategy:
matrix: matrix:
model: ["TS100", "TS80", "TS80P", "Pinecil", "MHP30"] model: ["TS100", "TS80", "TS80P", "Pinecil", "MHP30"]
@@ -57,7 +57,7 @@ jobs:
build_multi-lang: build_multi-lang:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
container: container:
image: alpine:3.15 image: alpine:3.16
strategy: strategy:
matrix: matrix:
model: ["Pinecil"] model: ["Pinecil"]
@@ -107,7 +107,7 @@ jobs:
tests: tests:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
container: container:
image: alpine:3.15 image: alpine:3.16
steps: steps:
- name: deps - name: deps
@@ -134,7 +134,7 @@ jobs:
check_formatting: check_formatting:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
container: container:
image: alpine:3.15 image: alpine:3.16
steps: steps:
- name: deps - name: deps

View File

@@ -14,7 +14,7 @@ RUN apk add --no-cache gcc-riscv-none-elf gcc-arm-none-eabi newlib-riscv-none-el
# Install Python3 packages # Install Python3 packages
RUN python3 -m pip install bdflib black RUN python3 -m pip install bdflib black
# Mark main dir as trusted by git # Git trust
RUN git config --global --add safe.directory /build/source RUN git config --global --add safe.directory /build/source
COPY . /build/source COPY . /build/source

View File

@@ -120,9 +120,6 @@ def get_constants(build_version: str) -> List[Tuple[str, str]]:
def get_debug_menu() -> List[str]: def get_debug_menu() -> List[str]:
return [ return [
datetime.today().strftime("%d-%m-%y"), datetime.today().strftime("%d-%m-%y"),
"HW G ",
"HW M ",
"HW P ",
"Time ", "Time ",
"Move ", "Move ",
"RTip ", "RTip ",
@@ -131,7 +128,11 @@ def get_debug_menu() -> List[str]:
"Vin ", "Vin ",
"ACC ", "ACC ",
"PWR ", "PWR ",
"ID ",
"Max ", "Max ",
"HW G ",
"HW M ",
"HW P ",
"Hall ", "Hall ",
] ]
@@ -429,7 +430,24 @@ def get_font_map_per_font(text_list: List[str], fonts: List[str]) -> FontMapsPer
def get_forced_first_symbols() -> List[str]: def get_forced_first_symbols() -> List[str]:
forced_first_symbols = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] forced_first_symbols = [
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"a",
"b",
"c",
"d",
"e",
"f",
]
return forced_first_symbols return forced_first_symbols

View File

@@ -74,6 +74,9 @@ void log_system_state(int32_t PWMWattsx10);
// Returns true if the tip is disconnected // Returns true if the tip is disconnected
bool isTipDisconnected(); bool isTipDisconnected();
// Return hardware unique ID if possible
uint64_t getDeviceID();
// Status LED controls // Status LED controls
enum StatusLED { enum StatusLED {
@@ -86,6 +89,10 @@ enum StatusLED {
}; };
void setStatusLED(const enum StatusLED state); void setStatusLED(const enum StatusLED state);
// preStartChecks are run until they return 0
// By the PID, after each ADC sample comes in
// For example, on the MHP30 this is used to figure out the resistance of the hotplate
uint8_t preStartChecks();
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@@ -17,8 +17,10 @@ volatile uint16_t PWMSafetyTimer = 0;
volatile uint8_t pendingPWM = 0; volatile uint8_t pendingPWM = 0;
uint16_t totalPWM = 255; uint16_t totalPWM = 255;
const uint16_t powerPWM = 255; const uint16_t powerPWM = 255;
uint16_t tipSenseResistancex10Ohms = 0;
volatile bool tipMeasurementOccuring = false;
history<uint16_t, PID_TIM_HZ> rawTempFilter = {{0}, 0, 0}; history<uint16_t, PID_TIM_HZ> rawTempFilter = {{0}, 0, 0};
void resetWatchdog() { HAL_IWDG_Refresh(&hiwdg); } void resetWatchdog() { HAL_IWDG_Refresh(&hiwdg); }
#ifdef TEMP_NTC #ifdef TEMP_NTC
@@ -208,7 +210,8 @@ uint16_t getHandleTemperature(uint8_t sample) {
uint16_t getTipInstantTemperature() { return getADC(2); } uint16_t getTipInstantTemperature() { return getADC(2); }
uint16_t getTipRawTemp(uint8_t refresh) { uint16_t getTipRawTemp(uint8_t refresh) {
if (refresh) { if (refresh && (tipMeasurementOccuring == false)) {
uint16_t lastSample = getTipInstantTemperature(); uint16_t lastSample = getTipInstantTemperature();
rawTempFilter.update(lastSample); rawTempFilter.update(lastSample);
return lastSample; return lastSample;
@@ -348,47 +351,38 @@ void setPlatePullup(bool pullingUp) {
HAL_GPIO_Init(PLATE_SENSOR_PULLUP_GPIO_Port, &GPIO_InitStruct); HAL_GPIO_Init(PLATE_SENSOR_PULLUP_GPIO_Port, &GPIO_InitStruct);
} }
uint16_t tipSenseResistancex10Ohms = 0; void performTipMeasurementStep(bool start) {
bool isTipDisconnected() {
static bool lastTipDisconnectedState = true;
static uint16_t adcReadingPD1Set = 0; static uint16_t adcReadingPD1Set = 0;
static TickType_t lastMeas = 0; static TickType_t lastMeas = 0;
// For the MHP30 we want to include a little extra logic in here // Inter state that performs the steps to measure the resistor on the tip
// As when the tip is first connected we want to measure the ~100 ohm resistor on the base of the tip // Return 1 if a measurement is ongoing
// And likewise if its removed we want to clear that measurement
/*
* plate_sensor_res = ((adc5_value_PD1_set - adc5_value_PD1_cleared) / (adc5_value_PD1_cleared + 4096 - adc5_value_PD1_set)) * 1000.0;
* */
bool tipDisconnected = getADC(2) > (4090 * 8); // We want to perform our startup measurements of the tip resistance until we detect one fitted
// We have to handle here that this ^ will trip while measuring the gain resistor
if (xTaskGetTickCount() - lastMeas < (TICKS_100MS * 2 + (TICKS_100MS / 2))) {
tipDisconnected = false;
}
if (tipDisconnected != lastTipDisconnectedState) { // Step 1; if not setup, we turn on pullup and then wait
if (tipDisconnected) { if (tipMeasurementOccuring == false && (start || tipSenseResistancex10Ohms == 0 || lastMeas == 0)) {
// Tip is now disconnected tipMeasurementOccuring = true;
tipSenseResistancex10Ohms = 0; // zero out the resistance tipSenseResistancex10Ohms = 0;
adcReadingPD1Set = 0;
lastMeas = 0;
}
lastTipDisconnectedState = tipDisconnected;
}
if (!tipDisconnected) {
if (tipSenseResistancex10Ohms == 0) {
if (lastMeas == 0) {
lastMeas = xTaskGetTickCount(); lastMeas = xTaskGetTickCount();
adcReadingPD1Set = 0;
setPlatePullup(true); setPlatePullup(true);
} else if (xTaskGetTickCount() - lastMeas > (TICKS_100MS)) { return;
}
// Wait 100ms for settle time
if ((xTaskGetTickCount() - lastMeas) < (TICKS_100MS)) {
return;
}
lastMeas = xTaskGetTickCount(); lastMeas = xTaskGetTickCount();
// We are sensing the resistance // We are sensing the resistance
if (adcReadingPD1Set == 0) { if (adcReadingPD1Set == 0) {
// We will record the reading for PD1 being set // We will record the reading for PD1 being set
adcReadingPD1Set = getADC(3); adcReadingPD1Set = getADC(3);
setPlatePullup(false); setPlatePullup(false);
} else { return;
// We have taken reading one }
// Taking reading two
uint16_t adcReadingPD1Cleared = getADC(3); uint16_t adcReadingPD1Cleared = getADC(3);
uint32_t a = ((int)adcReadingPD1Set - (int)adcReadingPD1Cleared); uint32_t a = ((int)adcReadingPD1Set - (int)adcReadingPD1Cleared);
a *= 10000; a *= 10000;
@@ -402,15 +396,37 @@ bool isTipDisconnected() {
tipSenseResistancex10Ohms = 0; // out of range tipSenseResistancex10Ohms = 0; // out of range
adcReadingPD1Set = 0; adcReadingPD1Set = 0;
lastMeas = 0; lastMeas = 0;
return;
} }
tipMeasurementOccuring = false;
} }
} bool isTipDisconnected() {
return true; // we fake tip being disconnected until this is measured static bool lastDisconnectedState = false;
} // For the MHP30 we want to include a little extra logic in here
// As when the tip is first connected we want to measure the ~100 ohm resistor on the base of the tip
// And likewise if its removed we want to clear that measurement
/*
* plate_sensor_res = ((adc5_value_PD1_set - adc5_value_PD1_cleared) / (adc5_value_PD1_cleared + 4096 - adc5_value_PD1_set)) * 1000.0;
* */
if (tipMeasurementOccuring) {
performTipMeasurementStep(false);
return true; // We fake no tip disconnection during the measurement cycle to mask it
} }
// If we are too close to the top, most likely disconnected tip
bool tipDisconnected = getTipInstantTemperature() > (4090 * 8);
if (tipDisconnected == false && lastDisconnectedState == true) {
// Tip is now disconnected
performTipMeasurementStep(true);
}
lastDisconnectedState = tipDisconnected;
return tipDisconnected; return tipDisconnected;
} }
uint8_t preStartChecks() {
performTipMeasurementStep(false);
return tipMeasurementOccuring ? 1 : 0;
}
void setBuzzer(bool on) { void setBuzzer(bool on) {
if (on) { if (on) {
htim3.Instance->CCR2 = 128; htim3.Instance->CCR2 = 128;
@@ -455,3 +471,7 @@ void setStatusLED(const enum StatusLED state) {
setBuzzer(false); setBuzzer(false);
} }
} }
uint64_t getDeviceID() {
//
return HAL_GetUIDw0() | ((uint64_t)HAL_GetUIDw1() << 32);
}

View File

@@ -10,7 +10,8 @@
#include "configuration.h" #include "configuration.h"
extern uint16_t tipSenseResistancex10Ohms; extern uint16_t tipSenseResistancex10Ohms;
uint32_t TipThermoModel::convertuVToDegC(uint32_t tipuVDelta) { uint32_t TipThermoModel::convertuVToDegC(uint32_t tipuVDelta) {
// For the MHP30, we are mimicing the original code and using the resistor fitted to the base of the heater head, this is measured in the isTipDisconnected() function // For the MHP30, we are mimicing the original code and using the resistor fitted to the base of the heater head,
// this is measured at boot in pid task and in the disconnected tip check if tip is removed
if (tipSenseResistancex10Ohms > 900 && tipSenseResistancex10Ohms <= 1100) { if (tipSenseResistancex10Ohms > 900 && tipSenseResistancex10Ohms <= 1100) {
int32_t a = ((tipSenseResistancex10Ohms / 10) + 300) * (3300000 - tipuVDelta); int32_t a = ((tipSenseResistancex10Ohms / 10) + 300) * (3300000 - tipuVDelta);
int32_t b = a / 1000000; int32_t b = a / 1000000;

View File

@@ -283,3 +283,8 @@ bool isTipDisconnected() {
} }
void setStatusLED(const enum StatusLED state) {} void setStatusLED(const enum StatusLED state) {}
uint8_t preStartChecks() { return 0; }
uint64_t getDeviceID() {
//
return HAL_GetUIDw0() | ((uint64_t)HAL_GetUIDw1() << 32);
}

View File

@@ -310,6 +310,9 @@ void HAL_ResumeTick(void);
uint32_t HAL_GetHalVersion(void); uint32_t HAL_GetHalVersion(void);
uint32_t HAL_GetREVID(void); uint32_t HAL_GetREVID(void);
uint32_t HAL_GetDEVID(void); uint32_t HAL_GetDEVID(void);
uint32_t HAL_GetUIDw0(void);
uint32_t HAL_GetUIDw1(void);
uint32_t HAL_GetUIDw2(void);
void HAL_DBGMCU_EnableDBGSleepMode(void); void HAL_DBGMCU_EnableDBGSleepMode(void);
void HAL_DBGMCU_DisableDBGSleepMode(void); void HAL_DBGMCU_DisableDBGSleepMode(void);
void HAL_DBGMCU_EnableDBGStopMode(void); void HAL_DBGMCU_EnableDBGStopMode(void);

View File

@@ -513,6 +513,24 @@ void HAL_GetUID(uint32_t *UID) {
UID[2] = (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE + 8U)))); UID[2] = (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE + 8U))));
} }
/**
* @brief Returns first word of the unique device identifier (UID based on 96 bits)
* @retval Device identifier
*/
uint32_t HAL_GetUIDw0(void) { return (READ_REG(*((uint32_t *)UID_BASE))); }
/**
* @brief Returns second word of the unique device identifier (UID based on 96 bits)
* @retval Device identifier
*/
uint32_t HAL_GetUIDw1(void) { return (READ_REG(*((uint32_t *)(UID_BASE + 4U)))); }
/**
* @brief Returns third word of the unique device identifier (UID based on 96 bits)
* @retval Device identifier
*/
uint32_t HAL_GetUIDw2(void) { return (READ_REG(*((uint32_t *)(UID_BASE + 8U)))); }
/** /**
* @} * @}
*/ */

View File

@@ -90,3 +90,6 @@ bool isTipDisconnected() {
} }
void setStatusLED(const enum StatusLED state) {} void setStatusLED(const enum StatusLED state) {}
uint8_t preStartChecks() { return 0; }
uint64_t getDeviceID() { return dbg_id_get(); }

View File

@@ -124,7 +124,7 @@
#define POWER_LIMIT_STEPS 5 // #define POWER_LIMIT_STEPS 5 //
#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_PINECIL // Uses TS100 resistors #define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_PINECIL // Uses TS100 resistors
#define TEMP_uV_LOOKUP_HAKKO // Use Hakko lookup table #define TEMP_uV_LOOKUP_HAKKO // Use Hakko lookup table
#define USB_PD_VMAX 21 // Maximum voltage for PD to negotiate #define USB_PD_VMAX 20 // Maximum voltage for PD to negotiate
#define PID_TIM_HZ (8) // Tick rate of the PID loop #define PID_TIM_HZ (8) // Tick rate of the PID loop
#define MAX_TEMP_C 450 // Max soldering temp selectable °C #define MAX_TEMP_C 450 // Max soldering temp selectable °C
#define MAX_TEMP_F 850 // Max soldering temp selectable °F #define MAX_TEMP_F 850 // Max soldering temp selectable °F

View File

@@ -4,6 +4,15 @@
#include "OLED.hpp" #include "OLED.hpp"
#include "cmsis_os.h" #include "cmsis_os.h"
#define LOGO_PAGE_LENGTH 1024 #define LOGO_PAGE_LENGTH 1024
void delay() {
if (getSettingValue(SettingsOptions::LOGOTime) == 5) {
waitForButtonPress();
} else {
waitForButtonPressOrTimeout(TICKS_SECOND * getSettingValue(SettingsOptions::LOGOTime));
}
}
void BootLogo::handleShowingLogo(const uint8_t *ptrLogoArea) { void BootLogo::handleShowingLogo(const uint8_t *ptrLogoArea) {
// Read the first few bytes and figure out what format we are looking at // Read the first few bytes and figure out what format we are looking at
if (OLD_LOGO_HEADER_VALUE == *(reinterpret_cast<const uint32_t *>(ptrLogoArea))) { if (OLD_LOGO_HEADER_VALUE == *(reinterpret_cast<const uint32_t *>(ptrLogoArea))) {
@@ -21,7 +30,7 @@ void BootLogo::showOldFormat(const uint8_t *ptrLogoArea) {
OLED::refresh(); OLED::refresh();
// Delay here until button is pressed or its been the amount of seconds set by the user // Delay here until button is pressed or its been the amount of seconds set by the user
waitForButtonPressOrTimeout(TICKS_SECOND * getSettingValue(SettingsOptions::LOGOTime)); delay();
} }
void BootLogo::showNewFormat(const uint8_t *ptrLogoArea) { void BootLogo::showNewFormat(const uint8_t *ptrLogoArea) {
@@ -46,9 +55,9 @@ void BootLogo::showNewFormat(const uint8_t *ptrLogoArea) {
osDelay(interFrameDelay * 5); osDelay(interFrameDelay * 5);
} }
// 1024 less the header type byte and the inter-frame-delay // 1024 less the header type byte and the inter-frame-delay
if (getSettingValue(SettingsOptions::LOGOTime) < 5 && (position == 1022 || len == 0)) { if (getSettingValue(SettingsOptions::LOGOTime) > 0 && (position == 1022 || len == 0)) {
// Delay here until button is pressed or its been the amount of seconds set by the user // Delay here until button is pressed or its been the amount of seconds set by the user
waitForButtonPressOrTimeout(TICKS_SECOND * getSettingValue(SettingsOptions::LOGOTime)); delay();
return; return;
} }
} while (buttons == BUTTON_NONE); } while (buttons == BUTTON_NONE);

View File

@@ -423,6 +423,13 @@ inline void stripLeaderZeros(char *buffer, uint8_t places) {
} }
} }
} }
void OLED::drawHex(uint32_t x, FontStyle fontStyle) {
// print number to hex
for (uint_fast8_t i = 0; i < 8; i++) {
uint16_t value = (x >> (4 * (7 - i))) & 0b1111;
drawChar(value + 2, fontStyle);
}
}
// maximum places is 5 // maximum places is 5
void OLED::printNumber(uint16_t number, uint8_t places, FontStyle fontStyle, bool noLeaderZeros) { void OLED::printNumber(uint16_t number, uint8_t places, FontStyle fontStyle, bool noLeaderZeros) {
char buffer[7] = {0}; char buffer[7] = {0};

View File

@@ -89,6 +89,7 @@ public:
// Draws a checkbox // Draws a checkbox
static void drawCheckbox(bool state) { drawSymbol((state) ? 16 : 17); } static void drawCheckbox(bool state) { drawSymbol((state) ? 16 : 17); }
static void debugNumber(int32_t val, FontStyle fontStyle); static void debugNumber(int32_t val, FontStyle fontStyle);
static void drawHex(uint32_t x, FontStyle fontStyle);
static void drawSymbol(uint8_t symbolID); // Used for drawing symbols of a predictable width static void drawSymbol(uint8_t symbolID); // Used for drawing symbols of a predictable width
static void drawArea(int16_t x, int8_t y, uint8_t wide, uint8_t height, const uint8_t *ptr); // Draw an area, but y must be aligned on 0/8 offset static void drawArea(int16_t x, int8_t y, uint8_t wide, uint8_t height, const uint8_t *ptr); // Draw an area, but y must be aligned on 0/8 offset
static void drawAreaSwapped(int16_t x, int8_t y, uint8_t wide, uint8_t height, const uint8_t *ptr); // Draw an area, but y must be aligned on 0/8 offset static void drawAreaSwapped(int16_t x, int8_t y, uint8_t wide, uint8_t height, const uint8_t *ptr); // Draw an area, but y must be aligned on 0/8 offset

View File

@@ -3,7 +3,7 @@
#include <stdint.h> #include <stdint.h>
#include "OLED.hpp" #include "OLED.hpp"
#include "Setup.h" #include "Setup.h"
extern uint32_t currentTempTargetDegC; extern volatile uint32_t currentTempTargetDegC;
extern bool settingsWereReset; extern bool settingsWereReset;
extern bool usb_pd_available; extern bool usb_pd_available;
#ifdef __cplusplus #ifdef __cplusplus

View File

@@ -27,13 +27,13 @@ static void settings_displayQCInputV(void);
#if POW_PD #if POW_PD
static void settings_displayPDNegTimeout(void); static void settings_displayPDNegTimeout(void);
#endif #endif
#ifndef NO_SLEEP_MODE
static void settings_displaySensitivity(void); static void settings_displaySensitivity(void);
static void settings_displayShutdownTime(void);
static bool settings_showSleepOptions(void); static bool settings_showSleepOptions(void);
#ifndef NO_SLEEP_MODE
static bool settings_setSleepTemp(void); static bool settings_setSleepTemp(void);
static void settings_displaySleepTemp(void); static void settings_displaySleepTemp(void);
static void settings_displaySleepTime(void); static void settings_displaySleepTime(void);
static void settings_displayShutdownTime(void);
#endif #endif
static bool settings_setTempF(void); static bool settings_setTempF(void);
static void settings_displayTempF(void); static void settings_displayTempF(void);
@@ -201,12 +201,12 @@ const menuitem PowerSavingMenu[] = {
* -Sleep Time * -Sleep Time
* -Shutdown Time * -Shutdown Time
*/ */
#ifndef NO_SLEEP_MODE
{SETTINGS_DESC(SettingsItemIndex::MotionSensitivity), nullptr, settings_displaySensitivity, nullptr, SettingsOptions::Sensitivity}, /* Motion Sensitivity*/ {SETTINGS_DESC(SettingsItemIndex::MotionSensitivity), nullptr, settings_displaySensitivity, nullptr, SettingsOptions::Sensitivity}, /* Motion Sensitivity*/
#ifndef NO_SLEEP_MODE
{SETTINGS_DESC(SettingsItemIndex::SleepTemperature), settings_setSleepTemp, settings_displaySleepTemp, settings_showSleepOptions, SettingsOptions::SettingsOptionsLength}, /*Sleep Temp*/ {SETTINGS_DESC(SettingsItemIndex::SleepTemperature), settings_setSleepTemp, settings_displaySleepTemp, settings_showSleepOptions, SettingsOptions::SettingsOptionsLength}, /*Sleep Temp*/
{SETTINGS_DESC(SettingsItemIndex::SleepTimeout), nullptr, settings_displaySleepTime, settings_showSleepOptions, SettingsOptions::SleepTime}, /*Sleep Time*/ {SETTINGS_DESC(SettingsItemIndex::SleepTimeout), nullptr, settings_displaySleepTime, settings_showSleepOptions, SettingsOptions::SleepTime}, /*Sleep Time*/
{SETTINGS_DESC(SettingsItemIndex::ShutdownTimeout), nullptr, settings_displayShutdownTime, settings_showSleepOptions, SettingsOptions::ShutdownTime}, /*Shutdown Time*/
#endif #endif
{SETTINGS_DESC(SettingsItemIndex::ShutdownTimeout), nullptr, settings_displayShutdownTime, settings_showSleepOptions, SettingsOptions::ShutdownTime}, /*Shutdown Time*/
#ifdef HALL_SENSOR #ifdef HALL_SENSOR
{SETTINGS_DESC(SettingsItemIndex::HallEffSensitivity), nullptr, settings_displayHallEffect, settings_showHallEffect, SettingsOptions::HallEffectSensitivity}, /* HallEffect Sensitivity*/ {SETTINGS_DESC(SettingsItemIndex::HallEffSensitivity), nullptr, settings_displayHallEffect, settings_showHallEffect, SettingsOptions::HallEffectSensitivity}, /* HallEffect Sensitivity*/
#endif #endif
@@ -362,8 +362,6 @@ static void settings_displayPDNegTimeout(void) {
} }
#endif #endif
#ifndef NO_SLEEP_MODE
static void settings_displayShutdownTime(void) { static void settings_displayShutdownTime(void) {
printShortDescription(SettingsItemIndex::ShutdownTimeout, 5); printShortDescription(SettingsItemIndex::ShutdownTimeout, 5);
if (getSettingValue(SettingsOptions::ShutdownTime) == 0) { if (getSettingValue(SettingsOptions::ShutdownTime) == 0) {
@@ -374,6 +372,14 @@ static void settings_displayShutdownTime(void) {
} }
} }
static void settings_displaySensitivity(void) {
printShortDescription(SettingsItemIndex::MotionSensitivity, 7);
OLED::printNumber(getSettingValue(SettingsOptions::Sensitivity), 1, FontStyle::LARGE, false);
}
static bool settings_showSleepOptions(void) { return getSettingValue(SettingsOptions::Sensitivity) > 0; }
#ifndef NO_SLEEP_MODE
static bool settings_setSleepTemp(void) { static bool settings_setSleepTemp(void) {
// If in C, 10 deg, if in F 20 deg // If in C, 10 deg, if in F 20 deg
uint16_t temp = getSettingValue(SettingsOptions::SleepTemp); uint16_t temp = getSettingValue(SettingsOptions::SleepTemp);
@@ -392,12 +398,6 @@ static bool settings_setSleepTemp(void) {
} }
} }
static void settings_displaySensitivity(void) {
printShortDescription(SettingsItemIndex::MotionSensitivity, 7);
OLED::printNumber(getSettingValue(SettingsOptions::Sensitivity), 1, FontStyle::LARGE, false);
}
static bool settings_showSleepOptions(void) { return getSettingValue(SettingsOptions::Sensitivity) > 0; }
static void settings_displaySleepTemp(void) { static void settings_displaySleepTemp(void) {
printShortDescription(SettingsItemIndex::SleepTemperature, 5); printShortDescription(SettingsItemIndex::SleepTemperature, 5);
OLED::printNumber(getSettingValue(SettingsOptions::SleepTemp), 3, FontStyle::LARGE); OLED::printNumber(getSettingValue(SettingsOptions::SleepTemp), 3, FontStyle::LARGE);

View File

@@ -29,7 +29,7 @@ extern "C" {
#include "pd.h" #include "pd.h"
#endif #endif
// File local variables // File local variables
extern uint32_t currentTempTargetDegC;
extern TickType_t lastMovementTime; extern TickType_t lastMovementTime;
extern bool heaterThermalRunaway; extern bool heaterThermalRunaway;
extern osThreadId GUITaskHandle; extern osThreadId GUITaskHandle;
@@ -172,7 +172,7 @@ static void gui_drawBatteryIcon() {
} }
static void gui_solderingTempAdjust() { static void gui_solderingTempAdjust() {
uint32_t lastChange = xTaskGetTickCount(); uint32_t lastChange = xTaskGetTickCount();
currentTempTargetDegC = 0; currentTempTargetDegC = 0; // Turn off header while adjusting temp
uint32_t autoRepeatTimer = 0; uint32_t autoRepeatTimer = 0;
uint8_t autoRepeatAcceleration = 0; uint8_t autoRepeatAcceleration = 0;
bool waitForRelease = false; bool waitForRelease = false;
@@ -350,28 +350,11 @@ static int gui_SolderingSleepingMode(bool stayOff, bool autoStarted) {
OLED::refresh(); OLED::refresh();
GUIDelay(); GUIDelay();
#ifdef ACCEL_EXITS_ON_MOVEMENT
// If the accel works in reverse where movement will cause exiting the soldering mode
if (getSettingValue(SettingsOptions::Sensitivity)) {
if (lastMovementTime) {
if (lastMovementTime > TICKS_SECOND * 10) {
// If we have moved recently; in the last second
// Then exit soldering mode
if (((TickType_t)(xTaskGetTickCount() - lastMovementTime)) < (TickType_t)(TICKS_SECOND)) {
currentTempTargetDegC = 0;
return 1;
}
}
}
}
#else
if (!shouldBeSleeping(autoStarted)) { if (!shouldBeSleeping(autoStarted)) {
return 0; return 0;
} }
#endif
if (shouldShutdown()) { if (shouldShutdown()) {
// shutdown // shutdown
currentTempTargetDegC = 0; currentTempTargetDegC = 0;
@@ -511,12 +494,8 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
boostModeOn = false; boostModeOn = false;
break; break;
case BUTTON_BOTH: case BUTTON_BOTH:
// exit
return;
break;
case BUTTON_B_LONG: case BUTTON_B_LONG:
return; // exit on back long hold return; // exit on back long hold
break;
case BUTTON_F_LONG: case BUTTON_F_LONG:
// if boost mode is enabled turn it on // if boost mode is enabled turn it on
if (getSettingValue(SettingsOptions::BoostTemp)) if (getSettingValue(SettingsOptions::BoostTemp))
@@ -649,6 +628,31 @@ static void gui_solderingMode(uint8_t jumpToSleep) {
} }
#endif #endif
#ifdef ACCEL_EXITS_ON_MOVEMENT
// If the accel works in reverse where movement will cause exiting the soldering mode
if (getSettingValue(SettingsOptions::Sensitivity)) {
if (lastMovementTime) {
if (lastMovementTime > TICKS_SECOND * 10) {
// If we have moved recently; in the last second
// Then exit soldering mode
if (((TickType_t)(xTaskGetTickCount() - lastMovementTime)) < (TickType_t)(TICKS_SECOND)) {
currentTempTargetDegC = 0;
return;
}
}
}
}
#endif
#ifdef NO_SLEEP_MODE
// No sleep mode, but still want shutdown timeout
if (shouldShutdown()) {
// shutdown
currentTempTargetDegC = 0;
return; // we want to exit soldering mode
}
#endif
if (shouldBeSleeping()) { if (shouldBeSleeping()) {
if (gui_SolderingSleepingMode(false, false)) { if (gui_SolderingSleepingMode(false, false)) {
return; // If the function returns non-0 then exit return; // If the function returns non-0 then exit
@@ -687,46 +691,34 @@ void showDebugMenu(void) {
case 0: // Just prints date case 0: // Just prints date
break; break;
case 1: case 1:
// High water mark for GUI
OLED::printNumber(uxTaskGetStackHighWaterMark(GUITaskHandle), 5, FontStyle::SMALL);
break;
case 2:
// High water mark for the Movement task
OLED::printNumber(uxTaskGetStackHighWaterMark(MOVTaskHandle), 5, FontStyle::SMALL);
break;
case 3:
// High water mark for the PID task
OLED::printNumber(uxTaskGetStackHighWaterMark(PIDTaskHandle), 5, FontStyle::SMALL);
break;
case 4:
// system up time stamp // system up time stamp
OLED::printNumber(xTaskGetTickCount() / TICKS_100MS, 5, FontStyle::SMALL); OLED::printNumber(xTaskGetTickCount() / TICKS_100MS, 5, FontStyle::SMALL);
break; break;
case 5: case 2:
// Movement time stamp // Movement time stamp
OLED::printNumber(lastMovementTime / TICKS_100MS, 5, FontStyle::SMALL); OLED::printNumber(lastMovementTime / TICKS_100MS, 5, FontStyle::SMALL);
break; break;
case 6: case 3:
// Raw Tip // Raw Tip
{ OLED::printNumber(TipThermoModel::convertTipRawADCTouV(getTipRawTemp(0), true), 6, FontStyle::SMALL); } { OLED::printNumber(TipThermoModel::convertTipRawADCTouV(getTipRawTemp(0), true), 6, FontStyle::SMALL); }
break; break;
case 7: case 4:
// Temp in C // Temp in C
OLED::printNumber(TipThermoModel::getTipInC(), 5, FontStyle::SMALL); OLED::printNumber(TipThermoModel::getTipInC(), 5, FontStyle::SMALL);
break; break;
case 8: case 5:
// Handle Temp // Handle Temp
OLED::printNumber(getHandleTemperature(0), 6, FontStyle::SMALL); OLED::printNumber(getHandleTemperature(0), 6, FontStyle::SMALL);
break; break;
case 9: case 6:
// Voltage input // Voltage input
printVoltage(); printVoltage();
break; break;
case 10: case 7:
// Print ACC type // Print ACC type
OLED::print(AccelTypeNames[(int)DetectedAccelerometerVersion], FontStyle::SMALL); OLED::print(AccelTypeNames[(int)DetectedAccelerometerVersion], FontStyle::SMALL);
break; break;
case 11: case 8:
// Power negotiation status // Power negotiation status
{ {
int sourceNumber = 0; int sourceNumber = 0;
@@ -762,12 +754,32 @@ void showDebugMenu(void) {
OLED::print(PowerSourceNames[sourceNumber], FontStyle::SMALL); OLED::print(PowerSourceNames[sourceNumber], FontStyle::SMALL);
} }
break; break;
case 12: case 9:
// Print device ID Numbers
{
uint64_t id = getDeviceID();
OLED::drawHex((uint32_t)(id >> 32), FontStyle::SMALL);
OLED::drawHex((uint32_t)(id & 0xFFFFFFFF), FontStyle::SMALL);
}
break;
case 10:
// Max deg C limit // Max deg C limit
OLED::printNumber(TipThermoModel::getTipMaxInC(), 3, FontStyle::SMALL); OLED::printNumber(TipThermoModel::getTipMaxInC(), 3, FontStyle::SMALL);
break; break;
#ifdef HALL_SENSOR case 11:
// High water mark for GUI
OLED::printNumber(uxTaskGetStackHighWaterMark(GUITaskHandle), 5, FontStyle::SMALL);
break;
case 12:
// High water mark for the Movement task
OLED::printNumber(uxTaskGetStackHighWaterMark(MOVTaskHandle), 5, FontStyle::SMALL);
break;
case 13: case 13:
// High water mark for the PID task
OLED::printNumber(uxTaskGetStackHighWaterMark(PIDTaskHandle), 5, FontStyle::SMALL);
break;
#ifdef HALL_SENSOR
case 14:
// Print raw hall effect value if availabe, none if hall effect disabled. // Print raw hall effect value if availabe, none if hall effect disabled.
{ {
int16_t hallEffectStrength = getRawHallEffect(); int16_t hallEffectStrength = getRawHallEffect();
@@ -777,6 +789,7 @@ void showDebugMenu(void) {
} }
break; break;
#endif #endif
default: default:
break; break;
} }
@@ -788,9 +801,9 @@ void showDebugMenu(void) {
else if (b == BUTTON_F_SHORT) { else if (b == BUTTON_F_SHORT) {
screen++; screen++;
#ifdef HALL_SENSOR #ifdef HALL_SENSOR
screen = screen % 14; screen = screen % 15;
#else #else
screen = screen % 13; screen = screen % 14;
#endif #endif
} }
GUIDelay(); GUIDelay();

View File

@@ -18,7 +18,7 @@
static TickType_t powerPulseWaitUnit = 25 * TICKS_100MS; // 2.5 s static TickType_t powerPulseWaitUnit = 25 * TICKS_100MS; // 2.5 s
static TickType_t powerPulseDurationUnit = (5 * TICKS_100MS) / 2; // 250 ms static TickType_t powerPulseDurationUnit = (5 * TICKS_100MS) / 2; // 250 ms
TaskHandle_t pidTaskNotification = NULL; TaskHandle_t pidTaskNotification = NULL;
uint32_t currentTempTargetDegC = 0; // Current temperature target in C volatile uint32_t currentTempTargetDegC = 0; // Current temperature target in C
int32_t powerSupplyWattageLimit = 0; int32_t powerSupplyWattageLimit = 0;
bool heaterThermalRunaway = false; bool heaterThermalRunaway = false;
@@ -40,24 +40,26 @@ void startPIDTask(void const *argument __unused) {
pidTaskNotification = xTaskGetCurrentTaskHandle(); pidTaskNotification = xTaskGetCurrentTaskHandle();
uint32_t PIDTempTarget = 0; uint32_t PIDTempTarget = 0;
// Pre-seed the adc filters // Pre-seed the adc filters
for (int i = 0; i < 128; i++) { for (int i = 0; i < 32; i++) {
osDelay(5); ulTaskNotifyTake(pdTRUE, 5);
TipThermoModel::getTipInC(true); TipThermoModel::getTipInC(true);
getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 1); getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 1);
} }
while (preStartChecks() != 0) {
ulTaskNotifyTake(pdTRUE, 2000);
}
int32_t x10WattsOut = 0; int32_t x10WattsOut = 0;
bool measuringTipResistance = false;
for (;;) { for (;;) {
x10WattsOut = 0; x10WattsOut = 0;
// This is a call to block this thread until the ADC does its samples // This is a call to block this thread until the ADC does its samples
if (ulTaskNotifyTake(pdTRUE, 2000)) { if (ulTaskNotifyTake(pdTRUE, TICKS_SECOND * 2)) {
if (measuringTipResistance) {
FinishMeasureTipResistance();
}
// Do the reading here to keep the temp calculations churning along // Do the reading here to keep the temp calculations churning along
uint32_t currentTipTempInC = TipThermoModel::getTipInC(true); uint32_t currentTipTempInC = TipThermoModel::getTipInC(true);
PIDTempTarget = currentTempTargetDegC; PIDTempTarget = currentTempTargetDegC;
if (PIDTempTarget) { if (PIDTempTarget > 0) {
// Cap the max set point to 450C // Cap the max set point to 450C
if (PIDTempTarget > (450)) { if (PIDTempTarget > (450)) {
// Maximum allowed output // Maximum allowed output

View File

@@ -1,5 +1,5 @@
ifndef model ifndef model
model:=TS100 model:=Pinecil
endif endif
ALL_MINIWARE_MODELS=TS100 TS80 TS80P ALL_MINIWARE_MODELS=TS100 TS80 TS80P
@@ -211,7 +211,7 @@ bootldr_size=0x0
CPUFLAGS= -march=rv32imac \ CPUFLAGS= -march=rv32imac \
-mabi=ilp32 \ -mabi=ilp32 \
-mcmodel=medany -fsigned-char -fno-builtin -nostartfiles -mcmodel=medany -fsigned-char -fno-builtin -nostartfiles
DEV_LDFLAGS=-nostartfiles --specs=patch.specs DEV_LDFLAGS=-nostartfiles
DEV_AFLAGS= DEV_AFLAGS=
DEV_GLOBAL_DEFS= -DRTOS_FREERTOS -DDOWNLOAD_MODE=DOWNLOAD_MODE_FLASHXIP DEV_GLOBAL_DEFS= -DRTOS_FREERTOS -DDOWNLOAD_MODE=DOWNLOAD_MODE_FLASHXIP
DEV_CFLAGS= -D VECT_TAB_OFFSET=$(bootldr_size)U DEV_CFLAGS= -D VECT_TAB_OFFSET=$(bootldr_size)U
@@ -313,10 +313,10 @@ $(shell find $(DEVICE_BSP_DIR) -type d \( $(EXCLUDED_DIRS) \) -prune -false -o
$(shell find $(SOURCE_MIDDLEWARES_DIR) -type f -name '*.cpp') $(shell find $(SOURCE_MIDDLEWARES_DIR) -type f -name '*.cpp')
# code optimisation ------------------------------------------------------------ # code optimisation ------------------------------------------------------------
OPTIM=-Os -flto -finline-small-functions -fshort-wchar -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections -fshort-enums -fsingle-precision-constant -fno-common OPTIM=-Os -flto -finline-small-functions -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections -fshort-enums -fsingle-precision-constant -fno-common
# global defines --------------------------------------------------------------- # global defines ---------------------------------------------------------------
GLOBAL_DEFINES += $(DEV_GLOBAL_DEFS) -D USE_RTOS_SYSTICK -D MODEL_$(model) GLOBAL_DEFINES += $(DEV_GLOBAL_DEFS) -D USE_RTOS_SYSTICK -D MODEL_$(model) -D VECT_TAB_OFFSET=$(bootldr_size)U -fshort-wchar
DEBUG=-g3 DEBUG=-g3
ifdef swd_enable ifdef swd_enable

View File

@@ -1,2 +0,0 @@
*link:
%(nano_link) %:replace-outfile(-lm_nano -lm)