mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Correct a few missed time values from the tick rate change (#874)
* Pass over all refs to xTaskGetTickCount()
* That wasn't a second 😓
* Update FreeRTOSConfig.h
* Fix warning in usb code; style; fix slow description
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
|
||||
#ifndef BSP_DEFINES_H_
|
||||
#define BSP_DEFINES_H_
|
||||
|
||||
#include "FreeRTOSConfig.h"
|
||||
enum Orientation { ORIENTATION_LEFT_HAND = 0, ORIENTATION_RIGHT_HAND = 1, ORIENTATION_FLAT = 3 };
|
||||
|
||||
// It is assumed that all hardware implements an 8Hz update period at this time
|
||||
|
||||
@@ -83,7 +83,9 @@
|
||||
*----------------------------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
/* Section where include file can be added */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Ensure stdint is only used by the compiler, and not the assembler. */
|
||||
@@ -172,5 +174,7 @@ extern uint32_t SystemCoreClock;
|
||||
#define configTIMER_QUEUE_LENGTH 8
|
||||
#define configTIMER_TASK_STACK_DEPTH (512 / 4)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* FREERTOS_CONFIG_H */
|
||||
|
||||
@@ -93,7 +93,8 @@ usb_reqsta usbd_class_request(usb_core_driver *udev, usb_req *req) {
|
||||
if (USBD_CONFIGURED == udev->dev.cur_status) {
|
||||
if (BYTE_LOW(req->wIndex) <= USBD_ITF_MAX_NUM) {
|
||||
/* call device class handle function */
|
||||
return (usb_reqsta)udev->dev.class_core->req_proc(udev, req);
|
||||
uint8_t res = udev->dev.class_core->req_proc(udev, req);
|
||||
return (usb_reqsta)res;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -426,7 +427,10 @@ static usb_reqsta _usb_std_getdescriptor(usb_core_driver *udev, usb_req *req) {
|
||||
|
||||
case USB_RECPTYPE_ITF:
|
||||
/* get device class special descriptor */
|
||||
return (usb_reqsta)(udev->dev.class_core->req_proc(udev, req));
|
||||
{
|
||||
uint8_t res = udev->dev.class_core->req_proc(udev, req);
|
||||
return (usb_reqsta)res;
|
||||
}
|
||||
|
||||
case USB_RECPTYPE_EP:
|
||||
break;
|
||||
|
||||
@@ -45,7 +45,6 @@ OF SUCH DAMAGE.
|
||||
static uint32_t usbh_request_submit(usb_core_driver *pudev, uint8_t pp_num) {
|
||||
pudev->host.pipe[pp_num].urb_state = URB_IDLE;
|
||||
pudev->host.pipe[pp_num].xfer_count = 0U;
|
||||
|
||||
return usb_pipe_xfer(pudev, pp_num);
|
||||
}
|
||||
|
||||
@@ -63,8 +62,8 @@ usbh_status usbh_ctlsetup_send(usb_core_driver *pudev, uint8_t *buf, uint8_t pp_
|
||||
pp->DPID = PIPE_DPID_SETUP;
|
||||
pp->xfer_buf = buf;
|
||||
pp->xfer_len = USB_SETUP_PACKET_LEN;
|
||||
|
||||
return (usbh_status)usbh_request_submit(pudev, pp_num);
|
||||
uint32_t res = usbh_request_submit(pudev, pp_num);
|
||||
return (usbh_status)res;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -24,7 +24,7 @@ ButtonState getButtonState() {
|
||||
*/
|
||||
static uint8_t previousState = 0;
|
||||
static uint32_t previousStateChange = 0;
|
||||
const uint16_t timeout = 400;
|
||||
const uint16_t timeout = TICKS_100MS * 4;
|
||||
uint8_t currentState;
|
||||
currentState = (getButtonA()) << 0;
|
||||
currentState |= (getButtonB()) << 1;
|
||||
|
||||
@@ -162,14 +162,14 @@ void OLED::transitionSecondaryFramebuffer(bool forwardNavigation) {
|
||||
uint8_t *firstBackStripPtr = &secondFrameBuffer[0];
|
||||
uint8_t *secondBackStripPtr = &secondFrameBuffer[OLED_WIDTH];
|
||||
|
||||
uint32_t totalDuration = 50; // 500ms
|
||||
uint32_t totalDuration = TICKS_100MS * 5; // 500ms
|
||||
uint32_t duration = 0;
|
||||
uint32_t start = xTaskGetTickCount();
|
||||
uint8_t offset = 0;
|
||||
|
||||
while (duration <= totalDuration) {
|
||||
duration = xTaskGetTickCount() - start;
|
||||
uint8_t progress = duration * TICKS_SECOND / totalDuration;
|
||||
uint8_t progress = ((duration * 100) / totalDuration); // Percentage of the period we are through for animation
|
||||
progress = easeInOutTiming(progress);
|
||||
progress = lerp(0, OLED_WIDTH, progress);
|
||||
if (progress > OLED_WIDTH) {
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
#include "Settings.h"
|
||||
#include "Translation.h"
|
||||
|
||||
#define PRESS_ACCEL_STEP 30
|
||||
#define PRESS_ACCEL_INTERVAL_MIN 100
|
||||
#define PRESS_ACCEL_INTERVAL_MAX 300
|
||||
#define PRESS_ACCEL_STEP (TICKS_100MS / 3)
|
||||
#define PRESS_ACCEL_INTERVAL_MIN TICKS_100MS
|
||||
#define PRESS_ACCEL_INTERVAL_MAX (TICKS_100MS * 3)
|
||||
|
||||
// GUI holds the menu structure and all its methods for the menu itself
|
||||
|
||||
|
||||
@@ -276,7 +276,7 @@ static int userConfirmation(const char *message) {
|
||||
bool lcdRefresh = true;
|
||||
|
||||
for (;;) {
|
||||
int16_t messageOffset = ((xTaskGetTickCount() - messageStart) / (systemSettings.descriptionScrollSpeed == 1 ? 10 : 20));
|
||||
int16_t messageOffset = ((xTaskGetTickCount() - messageStart) / (systemSettings.descriptionScrollSpeed == 1 ? TICKS_100MS : (TICKS_100MS * 2)));
|
||||
messageOffset %= messageWidth; // Roll around at the end
|
||||
|
||||
if (lastOffset != messageOffset) {
|
||||
@@ -1078,7 +1078,7 @@ void gui_Menu(const menuitem *menu) {
|
||||
OLED::setCursor(0, 0);
|
||||
// If the user has hesitated for >=3 seconds, show the long text
|
||||
// Otherwise "draw" the option
|
||||
if ((xTaskGetTickCount() - lastButtonTime < 3000) || menu[currentScreen].description == NULL) {
|
||||
if ((xTaskGetTickCount() - lastButtonTime < (TICKS_SECOND * 3)) || menu[currentScreen].description == NULL) {
|
||||
OLED::clearScreen();
|
||||
menu[currentScreen].draw();
|
||||
uint8_t indicatorHeight = OLED_HEIGHT / scrollContentSize;
|
||||
@@ -1095,7 +1095,7 @@ void gui_Menu(const menuitem *menu) {
|
||||
descriptionStart = xTaskGetTickCount();
|
||||
// lower the value - higher the speed
|
||||
int16_t descriptionWidth = FONT_12_WIDTH * (strlen(menu[currentScreen].description) + 7);
|
||||
int16_t descriptionOffset = ((xTaskGetTickCount() - descriptionStart) / (systemSettings.descriptionScrollSpeed == 1 ? 10 : 20));
|
||||
int16_t descriptionOffset = ((xTaskGetTickCount() - descriptionStart) / (systemSettings.descriptionScrollSpeed == 1 ? (TICKS_100MS / 10) : (TICKS_100MS / 5)));
|
||||
descriptionOffset %= descriptionWidth; // Roll around at the end
|
||||
if (lastOffset != descriptionOffset) {
|
||||
OLED::clearScreen();
|
||||
@@ -1149,7 +1149,7 @@ void gui_Menu(const menuitem *menu) {
|
||||
descriptionStart = 0;
|
||||
break;
|
||||
case BUTTON_F_LONG:
|
||||
if ((int)(xTaskGetTickCount() - autoRepeatTimer + autoRepeatAcceleration) > PRESS_ACCEL_INTERVAL_MAX) {
|
||||
if ((xTaskGetTickCount() - autoRepeatTimer + autoRepeatAcceleration) > PRESS_ACCEL_INTERVAL_MAX) {
|
||||
if ((lastValue = menu[currentScreen].incrementHandler()))
|
||||
autoRepeatTimer = 1000;
|
||||
else
|
||||
@@ -1185,7 +1185,7 @@ void gui_Menu(const menuitem *menu) {
|
||||
osDelay(40);
|
||||
lcdRefresh = false;
|
||||
}
|
||||
if ((xTaskGetTickCount() - lastButtonTime) > (1000 * 30)) {
|
||||
if ((xTaskGetTickCount() - lastButtonTime) > (TICKS_SECOND * 30)) {
|
||||
// If user has not pressed any buttons in 30 seconds, exit back a menu layer
|
||||
// This will trickle the user back to the main screen eventually
|
||||
earlyExit = true;
|
||||
|
||||
@@ -256,7 +256,7 @@ static void gui_solderingTempAdjust() {
|
||||
systemSettings.SolderingTemp = 10;
|
||||
}
|
||||
|
||||
if (xTaskGetTickCount() - lastChange > 2000)
|
||||
if (xTaskGetTickCount() - lastChange > (TICKS_SECOND * 2))
|
||||
return; // exit if user just doesn't press anything for a bit
|
||||
|
||||
#ifdef OLED_FLIP
|
||||
@@ -645,11 +645,11 @@ void showDebugMenu(void) {
|
||||
break;
|
||||
case 4:
|
||||
// system up time stamp
|
||||
OLED::printNumber(xTaskGetTickCount() / 100, 5);
|
||||
OLED::printNumber(xTaskGetTickCount() / TICKS_100MS, 5);
|
||||
break;
|
||||
case 5:
|
||||
// Movement time stamp
|
||||
OLED::printNumber(lastMovementTime / 100, 5);
|
||||
OLED::printNumber(lastMovementTime / TICKS_100MS, 5);
|
||||
break;
|
||||
case 6:
|
||||
// Raw Tip
|
||||
@@ -774,7 +774,7 @@ void startGUITask(void const *argument __unused) {
|
||||
getTipRawTemp(1); // reset filter
|
||||
OLED::setRotation(systemSettings.OrientationMode & 1);
|
||||
uint32_t ticks = xTaskGetTickCount();
|
||||
ticks += 4000; // 4 seconds from now
|
||||
ticks += (TICKS_SECOND * 4); // 4 seconds from now
|
||||
while (xTaskGetTickCount() < ticks) {
|
||||
if (showBootLogoIfavailable() == false)
|
||||
ticks = xTaskGetTickCount();
|
||||
@@ -912,7 +912,7 @@ void startGUITask(void const *argument __unused) {
|
||||
// If we have a tip connected draw the temp, if not we leave it blank
|
||||
if (!tipDisconnectedDisplay) {
|
||||
// draw in the temp
|
||||
if (!(systemSettings.coolingTempBlink && (xTaskGetTickCount() % 26 < 16)))
|
||||
if (!(systemSettings.coolingTempBlink && (xTaskGetTickCount() % 260 < 160)))
|
||||
gui_drawTipTemp(false); // draw in the temp
|
||||
} else {
|
||||
// Draw in missing tip symbol
|
||||
|
||||
@@ -170,6 +170,6 @@ void startMOVTask(void const *argument __unused) {
|
||||
lastMovementTime = xTaskGetTickCount();
|
||||
}
|
||||
|
||||
osDelay(TICKS_100MS); // Slow down update rate
|
||||
vTaskDelay(TICKS_100MS); // Slow down update rate
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
#include "main.hpp"
|
||||
#include "power.hpp"
|
||||
#include "task.h"
|
||||
static TickType_t powerPulseRate = 10000;
|
||||
static TickType_t powerPulseDuration = 250;
|
||||
static TickType_t powerPulseRate = 10 * TICKS_SECOND;
|
||||
static TickType_t powerPulseDuration = 3 * TICKS_100MS;
|
||||
TaskHandle_t pidTaskNotification = NULL;
|
||||
uint32_t currentTempTargetDegC = 0; // Current temperature target in C
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ HEXFILE_DIR=Hexfile
|
||||
OUTPUT_DIR_BASE=Objects
|
||||
OUTPUT_DIR=Objects/$(model)
|
||||
# code optimisation ------------------------------------------------------------
|
||||
OPTIM=-Os -flto -finline-small-functions -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections
|
||||
OPTIM=-Os -flto -finline-small-functions -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections -fshort-enums
|
||||
|
||||
# global defines ---------------------------------------------------------------
|
||||
GLOBAL_DEFINES += $(DEV_GLOBAL_DEFS) -D USE_RTOS_SYSTICK -D MODEL_$(model) -D VECT_TAB_OFFSET=$(bootldr_size)U
|
||||
|
||||
Reference in New Issue
Block a user