mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
All Ticks as the right TickType
Update usb-pd
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
#include "settingsGUI.hpp"
|
#include "settingsGUI.hpp"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include <Buttons.hpp>
|
#include <Buttons.hpp>
|
||||||
uint32_t lastButtonTime = 0;
|
TickType_t lastButtonTime = 0;
|
||||||
|
|
||||||
ButtonState getButtonState() {
|
ButtonState getButtonState() {
|
||||||
/*
|
/*
|
||||||
@@ -22,10 +22,10 @@ ButtonState getButtonState() {
|
|||||||
* press (buttons still down), or if release we trigger press
|
* press (buttons still down), or if release we trigger press
|
||||||
* (downtime>filter)
|
* (downtime>filter)
|
||||||
*/
|
*/
|
||||||
static uint8_t previousState = 0;
|
static uint8_t previousState = 0;
|
||||||
static uint32_t previousStateChange = 0;
|
static TickType_t previousStateChange = 0;
|
||||||
const uint16_t timeout = TICKS_100MS * 4;
|
const TickType_t timeout = TICKS_100MS * 4;
|
||||||
uint8_t currentState;
|
uint8_t currentState;
|
||||||
currentState = (getButtonA()) << 0;
|
currentState = (getButtonA()) << 0;
|
||||||
currentState |= (getButtonB()) << 1;
|
currentState |= (getButtonB()) << 1;
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ void waitForButtonPress() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void waitForButtonPressOrTimeout(uint32_t timeout) {
|
void waitForButtonPressOrTimeout(TickType_t timeout) {
|
||||||
timeout += xTaskGetTickCount();
|
timeout += xTaskGetTickCount();
|
||||||
// calculate the exit point
|
// calculate the exit point
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,8 @@
|
|||||||
#include "BSP.h"
|
#include "BSP.h"
|
||||||
#ifndef INC_BUTTONS_H_
|
#ifndef INC_BUTTONS_H_
|
||||||
#define INC_BUTTONS_H_
|
#define INC_BUTTONS_H_
|
||||||
|
#include "portmacro.h"
|
||||||
extern uint32_t lastButtonTime;
|
extern TickType_t lastButtonTime;
|
||||||
|
|
||||||
enum ButtonState {
|
enum ButtonState {
|
||||||
BUTTON_NONE = 0, /* No buttons pressed / < filter time*/
|
BUTTON_NONE = 0, /* No buttons pressed / < filter time*/
|
||||||
@@ -29,7 +29,7 @@ enum ButtonState {
|
|||||||
// Returns what buttons are pressed (if any)
|
// Returns what buttons are pressed (if any)
|
||||||
ButtonState getButtonState();
|
ButtonState getButtonState();
|
||||||
// Helpers
|
// Helpers
|
||||||
void waitForButtonPressOrTimeout(uint32_t timeout);
|
void waitForButtonPressOrTimeout(TickType_t timeout);
|
||||||
void waitForButtonPress();
|
void waitForButtonPress();
|
||||||
|
|
||||||
#endif /* INC_BUTTONS_H_ */
|
#endif /* INC_BUTTONS_H_ */
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ void OLED::maskScrollIndicatorOnOLED() {
|
|||||||
// it from the screen buffer which is updated by `OLED::setRotation`.
|
// it from the screen buffer which is updated by `OLED::setRotation`.
|
||||||
uint8_t rightmostColumn = screenBuffer[7];
|
uint8_t rightmostColumn = screenBuffer[7];
|
||||||
uint8_t maskCommands[] = {
|
uint8_t maskCommands[] = {
|
||||||
// Set column address:
|
// Set column address:
|
||||||
// A[6:0] - Column start address = rightmost column
|
// A[6:0] - Column start address = rightmost column
|
||||||
// B[6:0] - Column end address = rightmost column
|
// B[6:0] - Column end address = rightmost column
|
||||||
0x80,
|
0x80,
|
||||||
@@ -252,10 +252,10 @@ void OLED::transitionSecondaryFramebuffer(bool forwardNavigation) {
|
|||||||
uint8_t *firstBackStripPtr = &secondFrameBuffer[0];
|
uint8_t *firstBackStripPtr = &secondFrameBuffer[0];
|
||||||
uint8_t *secondBackStripPtr = &secondFrameBuffer[OLED_WIDTH];
|
uint8_t *secondBackStripPtr = &secondFrameBuffer[OLED_WIDTH];
|
||||||
|
|
||||||
uint32_t totalDuration = TICKS_100MS * 5; // 500ms
|
TickType_t totalDuration = TICKS_100MS * 5; // 500ms
|
||||||
uint32_t duration = 0;
|
TickType_t duration = 0;
|
||||||
uint32_t start = xTaskGetTickCount();
|
TickType_t start = xTaskGetTickCount();
|
||||||
uint8_t offset = 0;
|
uint8_t offset = 0;
|
||||||
|
|
||||||
while (duration <= totalDuration) {
|
while (duration <= totalDuration) {
|
||||||
duration = xTaskGetTickCount() - start;
|
duration = xTaskGetTickCount() - start;
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
#ifndef SCROLL_MESSAGE_HPP_
|
#ifndef SCROLL_MESSAGE_HPP_
|
||||||
#define SCROLL_MESSAGE_HPP_
|
#define SCROLL_MESSAGE_HPP_
|
||||||
|
|
||||||
|
#include "portmacro.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A helper class for showing a full-screen scrolling message.
|
* A helper class for showing a full-screen scrolling message.
|
||||||
*/
|
*/
|
||||||
class ScrollMessage {
|
class ScrollMessage {
|
||||||
uint32_t messageStart = 0;
|
TickType_t messageStart = 0;
|
||||||
int16_t lastOffset = -1;
|
int16_t lastOffset = -1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calcualte the width in pixels of the message string, in the large
|
* Calcualte the width in pixels of the message string, in the large
|
||||||
@@ -47,7 +47,7 @@ public:
|
|||||||
* @param currentTick The current tick as returned by `xTaskGetTickCount()`.
|
* @param currentTick The current tick as returned by `xTaskGetTickCount()`.
|
||||||
* @return Whether the OLED framebuffer has been modified.
|
* @return Whether the OLED framebuffer has been modified.
|
||||||
*/
|
*/
|
||||||
bool drawUpdate(const char *message, uint32_t currentTick);
|
bool drawUpdate(const char *message, TickType_t currentTick);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SCROLL_MESSAGE_HPP_ */
|
#endif /* SCROLL_MESSAGE_HPP_ */
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ static uint16_t str_display_len(const char *const str) {
|
|||||||
|
|
||||||
uint16_t ScrollMessage::messageWidth(const char *message) { return FONT_12_WIDTH * str_display_len(message); }
|
uint16_t ScrollMessage::messageWidth(const char *message) { return FONT_12_WIDTH * str_display_len(message); }
|
||||||
|
|
||||||
bool ScrollMessage::drawUpdate(const char *message, uint32_t currentTick) {
|
bool ScrollMessage::drawUpdate(const char *message, TickType_t currentTick) {
|
||||||
bool lcdRefresh = false;
|
bool lcdRefresh = false;
|
||||||
|
|
||||||
if (messageStart == 0) {
|
if (messageStart == 0) {
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ void showWarnings();
|
|||||||
#define BUTTON_INACTIVITY_TIME (60 * configTICK_RATE_HZ)
|
#define BUTTON_INACTIVITY_TIME (60 * configTICK_RATE_HZ)
|
||||||
static TickType_t lastHallEffectSleepStart = 0;
|
static TickType_t lastHallEffectSleepStart = 0;
|
||||||
static uint16_t min(uint16_t a, uint16_t b) {
|
static uint16_t min(uint16_t a, uint16_t b) {
|
||||||
if (a > b)
|
if (a > b)
|
||||||
return b;
|
return b;
|
||||||
else
|
else
|
||||||
return a;
|
return a;
|
||||||
@@ -171,9 +171,9 @@ static void gui_drawBatteryIcon() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
static void gui_solderingTempAdjust() {
|
static void gui_solderingTempAdjust() {
|
||||||
uint32_t lastChange = xTaskGetTickCount();
|
TickType_t lastChange = xTaskGetTickCount();
|
||||||
currentTempTargetDegC = 0; // Turn off header while adjusting temp
|
currentTempTargetDegC = 0; // Turn off header while adjusting temp
|
||||||
uint32_t autoRepeatTimer = 0;
|
TickType_t autoRepeatTimer = 0;
|
||||||
uint8_t autoRepeatAcceleration = 0;
|
uint8_t autoRepeatAcceleration = 0;
|
||||||
bool waitForRelease = false;
|
bool waitForRelease = false;
|
||||||
ButtonState buttons = getButtonState();
|
ButtonState buttons = getButtonState();
|
||||||
@@ -370,7 +370,7 @@ static void display_countdown(int sleepThres) {
|
|||||||
* Print seconds or minutes (if > 99 seconds) until sleep
|
* Print seconds or minutes (if > 99 seconds) until sleep
|
||||||
* mode is triggered.
|
* mode is triggered.
|
||||||
*/
|
*/
|
||||||
int lastEventTime = lastButtonTime < lastMovementTime ? lastMovementTime : lastButtonTime;
|
TickType_t lastEventTime = lastButtonTime < lastMovementTime ? lastMovementTime : lastButtonTime;
|
||||||
TickType_t downCount = sleepThres - xTaskGetTickCount() + lastEventTime;
|
TickType_t downCount = sleepThres - xTaskGetTickCount() + lastEventTime;
|
||||||
if (downCount > (99 * TICKS_SECOND)) {
|
if (downCount > (99 * TICKS_SECOND)) {
|
||||||
OLED::printNumber(downCount / 60000 + 1, 2, FontStyle::SMALL);
|
OLED::printNumber(downCount / 60000 + 1, 2, FontStyle::SMALL);
|
||||||
|
|||||||
@@ -17,7 +17,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;
|
||||||
volatile 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;
|
||||||
|
|
||||||
@@ -114,8 +114,8 @@ int32_t getPIDResultX10Watts(int32_t setpointDelta) {
|
|||||||
static TickType_t lastCall = 0;
|
static TickType_t lastCall = 0;
|
||||||
static Integrator<int32_t> powerStore = {0};
|
static Integrator<int32_t> powerStore = {0};
|
||||||
|
|
||||||
const int rate = 1000 / (xTaskGetTickCount() - lastCall);
|
const TickType_t rate = 1000 / (xTaskGetTickCount() - lastCall);
|
||||||
lastCall = xTaskGetTickCount();
|
lastCall = xTaskGetTickCount();
|
||||||
// Sandman note:
|
// Sandman note:
|
||||||
// PID Challenge - we have a small thermal mass that we to want heat up as fast as possible but we don't
|
// PID Challenge - we have a small thermal mass that we to want heat up as fast as possible but we don't
|
||||||
// want to overshot excessively (if at all) the setpoint temperature. In the same time we have 'imprecise'
|
// want to overshot excessively (if at all) the setpoint temperature. In the same time we have 'imprecise'
|
||||||
|
|||||||
Reference in New Issue
Block a user