expand bulk data to match individual value data (#1555)
* track and return Operating mode with BLE * move global variable to fix build on other platforms * formatting * expand bulk data to match individual value data * formatting * fix accidental single line if --------- Co-authored-by: Ben V. Brown <5425387+Ralim@users.noreply.github.com>
This commit is contained in:
@@ -70,13 +70,7 @@ int ble_char_read_status_callback(struct bt_conn *conn, const struct bt_gatt_att
|
||||
break;
|
||||
case 6: // power src
|
||||
// Todo return enum for current power source
|
||||
if (getIsPoweredByDCIN()) {
|
||||
temp = 0;
|
||||
} else if (USBPowerDelivery::negotiationComplete()) {
|
||||
temp = 1;
|
||||
} else {
|
||||
temp = 2;
|
||||
}
|
||||
temp = getPowerSrc();
|
||||
memcpy(buf, &temp, sizeof(temp));
|
||||
return sizeof(temp);
|
||||
break;
|
||||
@@ -124,7 +118,6 @@ int ble_char_read_status_callback(struct bt_conn *conn, const struct bt_gatt_att
|
||||
break;
|
||||
case 13:
|
||||
// Operating mode
|
||||
// TODO: Needs tracking
|
||||
temp = currentMode;
|
||||
memcpy(buf, &temp, sizeof(temp));
|
||||
return sizeof(temp);
|
||||
@@ -150,13 +143,20 @@ int ble_char_read_bulk_value_callback(struct bt_conn *conn, const struct bt_gatt
|
||||
// Bulk data
|
||||
{
|
||||
uint32_t bulkData[] = {
|
||||
TipThermoModel::getTipInC(), // Current temp
|
||||
getSettingValue(SettingsOptions::SolderingTemp), // Setpoint
|
||||
getHandleTemperature(0), // Handle X10 Temp in C
|
||||
getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 0), // Input voltage
|
||||
x10WattHistory.average(), // Estimated Wattage
|
||||
X10WattsToPWM(x10WattHistory.average()), // Power as PWM level
|
||||
TipThermoModel::convertTipRawADCTouV(getTipRawTemp(0), true), // Raw tip
|
||||
TipThermoModel::getTipInC(), // 0 - Current temp
|
||||
getSettingValue(SettingsOptions::SolderingTemp), // 1 - Setpoint
|
||||
getInputVoltageX10(getSettingValue(SettingsOptions::VoltageDiv), 0), // 2 - Input voltage
|
||||
getHandleTemperature(0), // 3 - Handle X10 Temp in C
|
||||
X10WattsToPWM(x10WattHistory.average()), // 4 - Power as PWM level
|
||||
getPowerSrc(), // 5 - power src
|
||||
getTipResistanceX10(), // 6 - Tip resistance
|
||||
xTaskGetTickCount() / TICKS_100MS, // 7 - uptime in deciseconds
|
||||
lastMovementTime / TICKS_100MS, // 8 - last movement time (deciseconds)
|
||||
TipThermoModel::getTipMaxInC(), // 9 - max temp
|
||||
TipThermoModel::convertTipRawADCTouV(getTipRawTemp(0), true), // 10 - Raw tip in μV
|
||||
abs(getRawHallEffect()), // 11 - hall sensor
|
||||
currentMode, // 12 - Operating mode
|
||||
x10WattHistory.average(), // 13 - Estimated Wattage *10
|
||||
};
|
||||
int lenToCopy = sizeof(bulkData) - offset;
|
||||
if (lenToCopy > len) {
|
||||
@@ -243,3 +243,37 @@ int ble_char_write_setting_value_callback(struct bt_conn *conn, const struct bt_
|
||||
MSG("Unhandled attr write %d | %d\n", (uint32_t)attr->uuid, uuid_value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t getPowerSrc() {
|
||||
int sourceNumber = 0;
|
||||
if (getIsPoweredByDCIN()) {
|
||||
sourceNumber = 0;
|
||||
} else {
|
||||
// We are not powered via DC, so want to display the appropriate state for PD or QC
|
||||
bool poweredbyPD = false;
|
||||
bool pdHasVBUSConnected = false;
|
||||
#if POW_PD
|
||||
if (USBPowerDelivery::fusbPresent()) {
|
||||
// We are PD capable
|
||||
if (USBPowerDelivery::negotiationComplete()) {
|
||||
// We are powered via PD
|
||||
poweredbyPD = true;
|
||||
#ifdef VBUS_MOD_TEST
|
||||
pdHasVBUSConnected = USBPowerDelivery::isVBUSConnected();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (poweredbyPD) {
|
||||
|
||||
if (pdHasVBUSConnected) {
|
||||
sourceNumber = 2;
|
||||
} else {
|
||||
sourceNumber = 3;
|
||||
}
|
||||
} else {
|
||||
sourceNumber = 1;
|
||||
}
|
||||
}
|
||||
return sourceNumber;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ int ble_char_read_bulk_value_callback(struct bt_conn *conn, const struct bt_gatt
|
||||
|
||||
int ble_char_write_setting_value_callback(struct bt_conn *conn, const struct bt_gatt_attr *attr, const void *buf, u16_t len, u16_t offset, u8_t flags);
|
||||
|
||||
uint32_t getPowerSrc();
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "OperatingModes.h"
|
||||
extern osThreadId GUITaskHandle;
|
||||
extern osThreadId MOVTaskHandle;
|
||||
extern osThreadId PIDTaskHandle;
|
||||
extern osThreadId GUITaskHandle;
|
||||
extern osThreadId MOVTaskHandle;
|
||||
extern osThreadId PIDTaskHandle;
|
||||
extern OperatingMode currentMode;
|
||||
|
||||
void showDebugMenu(void) {
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
#define MOVEMENT_INACTIVITY_TIME (60 * configTICK_RATE_HZ)
|
||||
#define BUTTON_INACTIVITY_TIME (60 * configTICK_RATE_HZ)
|
||||
|
||||
uint8_t buttonAF[sizeof(buttonA)];
|
||||
uint8_t buttonBF[sizeof(buttonB)];
|
||||
uint8_t disconnectedTipF[sizeof(disconnectedTip)];
|
||||
uint8_t buttonAF[sizeof(buttonA)];
|
||||
uint8_t buttonBF[sizeof(buttonB)];
|
||||
uint8_t disconnectedTipF[sizeof(disconnectedTip)];
|
||||
extern OperatingMode currentMode;
|
||||
|
||||
void renderHomeScreenAssets(void) {
|
||||
|
||||
@@ -27,9 +27,10 @@ extern "C" {
|
||||
enum OperatingMode {
|
||||
idle = 0,
|
||||
soldering = 1,
|
||||
sleeping = 2,
|
||||
settings = 3,
|
||||
debug = 4
|
||||
boost = 2,
|
||||
sleeping = 3,
|
||||
settings = 4,
|
||||
debug = 5
|
||||
};
|
||||
|
||||
void performCJCC(void); // Used to calibrate the Cold Junction offset
|
||||
|
||||
@@ -45,6 +45,7 @@ void gui_solderingMode(uint8_t jumpToSleep) {
|
||||
// if boost mode is enabled turn it on
|
||||
if (getSettingValue(SettingsOptions::BoostTemp) && (getSettingValue(SettingsOptions::LockingMode) == 1)) {
|
||||
boostModeOn = true;
|
||||
currentMode = OperatingMode::boost;
|
||||
}
|
||||
break;
|
||||
// fall through
|
||||
@@ -63,14 +64,17 @@ void gui_solderingMode(uint8_t jumpToSleep) {
|
||||
case BUTTON_NONE:
|
||||
// stay
|
||||
boostModeOn = false;
|
||||
currentMode = OperatingMode::soldering;
|
||||
break;
|
||||
case BUTTON_BOTH:
|
||||
case BUTTON_B_LONG:
|
||||
return; // exit on back long hold
|
||||
case BUTTON_F_LONG:
|
||||
// if boost mode is enabled turn it on
|
||||
if (getSettingValue(SettingsOptions::BoostTemp))
|
||||
if (getSettingValue(SettingsOptions::BoostTemp)) {
|
||||
boostModeOn = true;
|
||||
currentMode = OperatingMode::boost;
|
||||
}
|
||||
break;
|
||||
case BUTTON_F_SHORT:
|
||||
case BUTTON_B_SHORT: {
|
||||
|
||||
Reference in New Issue
Block a user