mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Scratch out resistance awareness of the tip
This commit is contained in:
@@ -6,10 +6,12 @@
|
|||||||
#include "Pins.h"
|
#include "Pins.h"
|
||||||
#include "Setup.h"
|
#include "Setup.h"
|
||||||
#include "TipThermoModel.h"
|
#include "TipThermoModel.h"
|
||||||
|
#include "USBPD.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "history.hpp"
|
#include "history.hpp"
|
||||||
#include "main.hpp"
|
#include "main.hpp"
|
||||||
|
|
||||||
|
|
||||||
// These control the period's of time used for the PWM
|
// These control the period's of time used for the PWM
|
||||||
const uint16_t powerPWM = 255;
|
const uint16_t powerPWM = 255;
|
||||||
const uint8_t holdoffTicks = 5; // This is the tick delay
|
const uint8_t holdoffTicks = 5; // This is the tick delay
|
||||||
@@ -224,7 +226,7 @@ void setStatusLED(const enum StatusLED state) {
|
|||||||
// Dont have one
|
// Dont have one
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t lastTipResistance = 75; // default safe
|
uint8_t lastTipResistance = 80; // default safe
|
||||||
uint32_t lastTipReadinguV = 0;
|
uint32_t lastTipReadinguV = 0;
|
||||||
uint8_t getTipResitanceX10() {
|
uint8_t getTipResitanceX10() {
|
||||||
// Return tip resistance in x10 ohms
|
// Return tip resistance in x10 ohms
|
||||||
@@ -241,9 +243,10 @@ void startMeasureTipResistance() {
|
|||||||
// If tip is connected, and the tip is cold and the tip is not being heated
|
// If tip is connected, and the tip is cold and the tip is not being heated
|
||||||
// We can use the GPIO to inject a small current into the tip and measure this
|
// We can use the GPIO to inject a small current into the tip and measure this
|
||||||
// The gpio is 5.1k -> diode -> tip -> gnd
|
// The gpio is 5.1k -> diode -> tip -> gnd
|
||||||
// Which is around 0.65mA this will induce:
|
// Source is 3.3V-0.5V
|
||||||
// 6 ohm tip -> 3.9mV (Real world ~= 3320)
|
// Which is around 0.54mA this will induce:
|
||||||
// 8 ohm tip -> 5.2mV (Real world ~= 4500)
|
// 6 ohm tip -> 3.24mV (Real world ~= 3320)
|
||||||
|
// 8 ohm tip -> 4.32mV (Real world ~= 4500)
|
||||||
// Which is definitely measureable
|
// Which is definitely measureable
|
||||||
// Taking shortcuts here as we know we only really have to pick apart 6 and 8 ohm tips
|
// Taking shortcuts here as we know we only really have to pick apart 6 and 8 ohm tips
|
||||||
// These are reported as 60 and 75 respectively
|
// These are reported as 60 and 75 respectively
|
||||||
@@ -263,7 +266,21 @@ void FinishMeasureTipResistance() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// newReading -= lastTipReadinguV;
|
// newReading -= lastTipReadinguV;
|
||||||
MSG("Tip Delta %lu, %lu %lu \r\n", newReading - lastTipReadinguV, newReading, lastTipReadinguV);
|
// MSG("Tip Delta %lu, %lu %lu \r\n", newReading - lastTipReadinguV, newReading, lastTipReadinguV);
|
||||||
newReading -= lastTipReadinguV;
|
newReading -= lastTipReadinguV;
|
||||||
lastTipReadinguV = newReading;
|
// As we are only detecting two resistances; we can split the difference for now
|
||||||
|
uint8_t newRes = 0;
|
||||||
|
if (newReading > 5000) {
|
||||||
|
return; // Change nothing as probably disconnected tip
|
||||||
|
} else if (newReading < 4000) {
|
||||||
|
newRes = 60;
|
||||||
|
} else {
|
||||||
|
newRes = 80;
|
||||||
|
}
|
||||||
|
if (lastTipResistance != newRes) {
|
||||||
|
#ifdef POW_PD
|
||||||
|
USBPowerDelivery::triggerRenegotiation();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
lastTipResistance = newRes;
|
||||||
}
|
}
|
||||||
@@ -66,7 +66,9 @@ bool USBPowerDelivery::fusbPresent() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool USBPowerDelivery::isVBUSConnected() { return fusb.isVBUSConnected(); }
|
bool USBPowerDelivery::isVBUSConnected() { return fusb.isVBUSConnected(); }
|
||||||
|
void USBPowerDelivery::triggerRenegotiation() {
|
||||||
|
|
||||||
|
}
|
||||||
bool pdbs_dpm_evaluate_capability(const pd_msg *capabilities, pd_msg *request) {
|
bool pdbs_dpm_evaluate_capability(const pd_msg *capabilities, pd_msg *request) {
|
||||||
|
|
||||||
/* Get the number of PDOs */
|
/* Get the number of PDOs */
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ public:
|
|||||||
static bool negotiationHasWorked(); // Has PD negotiation worked (are we in a PD contract)
|
static bool negotiationHasWorked(); // Has PD negotiation worked (are we in a PD contract)
|
||||||
static uint8_t getStateNumber(); // Debugging - Get the internal state number
|
static uint8_t getStateNumber(); // Debugging - Get the internal state number
|
||||||
static bool isVBUSConnected(); // Is the VBus pin connected on the FUSB302
|
static bool isVBUSConnected(); // Is the VBus pin connected on the FUSB302
|
||||||
|
static void triggerRenegotiation(); // Trigger a restart of voltage selection
|
||||||
private:
|
private:
|
||||||
//
|
//
|
||||||
static int detectionState;
|
static int detectionState;
|
||||||
|
|||||||
Reference in New Issue
Block a user