1
0
forked from me/IronOS

Track and return Operating Mode with BLE (#1553)

Track and return Operating Mode with BLE
This commit is contained in:
Thomas White
2023-02-04 06:33:43 +08:00
committed by GitHub
parent e19e1a066d
commit 9802a622d5
7 changed files with 33 additions and 3 deletions

View File

@@ -20,6 +20,7 @@
#include "log.h"
#include "uuid.h"
#include "OperatingModes.h"
#include "USBPD.h"
#include "ble_characteristics.h"
#include "ble_handlers.h"
@@ -30,7 +31,8 @@
#include "pd.h"
#endif
extern TickType_t lastMovementTime;
extern TickType_t lastMovementTime;
extern OperatingMode currentMode;
int ble_char_read_status_callback(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, u16_t len, u16_t offset) {
if (attr == NULL || attr->uuid == NULL) {
@@ -123,6 +125,9 @@ int ble_char_read_status_callback(struct bt_conn *conn, const struct bt_gatt_att
case 13:
// Operating mode
// TODO: Needs tracking
temp = currentMode;
memcpy(buf, &temp, sizeof(temp));
return sizeof(temp);
break;
case 14:
// Estimated watts
@@ -237,4 +242,4 @@ 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;
}
}

View File

@@ -2,8 +2,10 @@
extern osThreadId GUITaskHandle;
extern osThreadId MOVTaskHandle;
extern osThreadId PIDTaskHandle;
extern OperatingMode currentMode;
void showDebugMenu(void) {
currentMode = OperatingMode::debug;
uint8_t screen = 0;
ButtonState b;
for (;;) {

View File

@@ -8,6 +8,7 @@
uint8_t buttonAF[sizeof(buttonA)];
uint8_t buttonBF[sizeof(buttonB)];
uint8_t disconnectedTipF[sizeof(disconnectedTip)];
extern OperatingMode currentMode;
void renderHomeScreenAssets(void) {
@@ -29,6 +30,7 @@ void drawHomeScreen(bool buttonLockout) {
renderHomeScreenAssets();
for (;;) {
currentMode = OperatingMode::idle;
ButtonState buttons = getButtonState();
if (buttons != BUTTON_NONE) {
OLED::setDisplayState(OLED::DisplayState::ON);
@@ -63,6 +65,7 @@ void drawHomeScreen(bool buttonLockout) {
}
break;
case BUTTON_B_SHORT:
currentMode = OperatingMode::settings;
enterSettingsMenu(); // enter the settings menu
{
OLED::useSecondaryFramebuffer(true);

View File

@@ -0,0 +1,8 @@
//
// Created by Thomas White on 3/02/2023.
//
#include "OperatingModes.h"
// Global variables
OperatingMode currentMode = OperatingMode::idle;

View File

@@ -24,6 +24,13 @@ extern "C" {
#endif
// Exposed modes
enum OperatingMode {
idle = 0,
soldering = 1,
sleeping = 2,
settings = 3,
debug = 4
};
void performCJCC(void); // Used to calibrate the Cold Junction offset
void gui_solderingTempAdjust(void); // For adjusting the setpoint temperature of the iron

View File

@@ -1,7 +1,10 @@
#include "OperatingModes.h"
extern OperatingMode currentMode;
int gui_SolderingSleepingMode(bool stayOff, bool autoStarted) {
// Drop to sleep temperature and display until movement or button press
currentMode = OperatingMode::sleeping;
for (;;) {
// user moved or pressed a button, go back to soldering

View File

@@ -1,7 +1,8 @@
#include "OperatingModes.h"
extern bool heaterThermalRunaway;
extern bool heaterThermalRunaway;
extern OperatingMode currentMode;
void gui_solderingMode(uint8_t jumpToSleep) {
/*
@@ -20,6 +21,7 @@ void gui_solderingMode(uint8_t jumpToSleep) {
*/
bool boostModeOn = false;
bool buttonsLocked = false;
currentMode = OperatingMode::soldering;
if (jumpToSleep) {
if (gui_SolderingSleepingMode(jumpToSleep == 2, true) == 1) {