Merge branch 'dev' into pd-epr
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
#include "settingsGUI.hpp"
|
||||
#include "task.h"
|
||||
#include <Buttons.hpp>
|
||||
uint32_t lastButtonTime = 0;
|
||||
TickType_t lastButtonTime = 0;
|
||||
|
||||
ButtonState getButtonState() {
|
||||
/*
|
||||
@@ -22,10 +22,11 @@ ButtonState getButtonState() {
|
||||
* press (buttons still down), or if release we trigger press
|
||||
* (downtime>filter)
|
||||
*/
|
||||
static uint8_t previousState = 0;
|
||||
static uint32_t previousStateChange = 0;
|
||||
const uint16_t timeout = TICKS_100MS * 4;
|
||||
uint8_t currentState;
|
||||
static uint8_t previousState = 0;
|
||||
static bool longPressed = false;
|
||||
static TickType_t previousStateChange = 0;
|
||||
const TickType_t timeout = TICKS_100MS * 4;
|
||||
uint8_t currentState;
|
||||
currentState = (getButtonA()) << 0;
|
||||
currentState |= (getButtonB()) << 1;
|
||||
|
||||
@@ -34,9 +35,10 @@ ButtonState getButtonState() {
|
||||
if (currentState == previousState) {
|
||||
if (currentState == 0)
|
||||
return BUTTON_NONE;
|
||||
if ((xTaskGetTickCount() - previousStateChange) > timeout) {
|
||||
if ((xTaskGetTickCount() - previousStateChange) >= timeout) {
|
||||
// User has been holding the button down
|
||||
// We want to send a button is held message
|
||||
longPressed = true;
|
||||
if (currentState == 0x01)
|
||||
return BUTTON_F_LONG;
|
||||
else if (currentState == 0x02)
|
||||
@@ -50,19 +52,15 @@ ButtonState getButtonState() {
|
||||
ButtonState retVal = BUTTON_NONE;
|
||||
if (currentState) {
|
||||
// User has pressed a button down (nothing done on down)
|
||||
if (currentState != previousState) {
|
||||
// There has been a change in the button states
|
||||
// If there is a rising edge on one of the buttons from double press we
|
||||
// want to mask that out As users are having issues with not release
|
||||
// both at once
|
||||
if (previousState == 0x03)
|
||||
currentState = 0x03;
|
||||
}
|
||||
// If there is a rising edge on one of the buttons from double press we
|
||||
// want to mask that out As users are having issues with not release
|
||||
// both at once
|
||||
previousState |= currentState;
|
||||
} else {
|
||||
// User has released buttons
|
||||
// If they previously had the buttons down we want to check if they were <
|
||||
// long hold and trigger a press
|
||||
if ((xTaskGetTickCount() - previousStateChange) < timeout) {
|
||||
if (!longPressed) {
|
||||
// The user didn't hold the button for long
|
||||
// So we send button press
|
||||
|
||||
@@ -73,8 +71,9 @@ ButtonState getButtonState() {
|
||||
else
|
||||
retVal = BUTTON_BOTH; // Both being held case
|
||||
}
|
||||
previousState = 0;
|
||||
longPressed = false;
|
||||
}
|
||||
previousState = currentState;
|
||||
previousStateChange = xTaskGetTickCount();
|
||||
return retVal;
|
||||
}
|
||||
@@ -95,7 +94,7 @@ void waitForButtonPress() {
|
||||
}
|
||||
}
|
||||
|
||||
void waitForButtonPressOrTimeout(uint32_t timeout) {
|
||||
void waitForButtonPressOrTimeout(TickType_t timeout) {
|
||||
timeout += xTaskGetTickCount();
|
||||
// calculate the exit point
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#include "BSP.h"
|
||||
#ifndef INC_BUTTONS_H_
|
||||
#define INC_BUTTONS_H_
|
||||
|
||||
extern uint32_t lastButtonTime;
|
||||
#include "portmacro.h"
|
||||
extern TickType_t lastButtonTime;
|
||||
|
||||
enum ButtonState {
|
||||
BUTTON_NONE = 0, /* No buttons pressed / < filter time*/
|
||||
@@ -29,7 +29,7 @@ enum ButtonState {
|
||||
// Returns what buttons are pressed (if any)
|
||||
ButtonState getButtonState();
|
||||
// Helpers
|
||||
void waitForButtonPressOrTimeout(uint32_t timeout);
|
||||
void waitForButtonPressOrTimeout(TickType_t timeout);
|
||||
void waitForButtonPress();
|
||||
|
||||
#endif /* INC_BUTTONS_H_ */
|
||||
|
||||
@@ -221,7 +221,7 @@ void OLED::maskScrollIndicatorOnOLED() {
|
||||
// it from the screen buffer which is updated by `OLED::setRotation`.
|
||||
uint8_t rightmostColumn = screenBuffer[7];
|
||||
uint8_t maskCommands[] = {
|
||||
// Set column address:
|
||||
// Set column address:
|
||||
// A[6:0] - Column start address = rightmost column
|
||||
// B[6:0] - Column end address = rightmost column
|
||||
0x80,
|
||||
@@ -252,10 +252,10 @@ void OLED::transitionSecondaryFramebuffer(bool forwardNavigation) {
|
||||
uint8_t *firstBackStripPtr = &secondFrameBuffer[0];
|
||||
uint8_t *secondBackStripPtr = &secondFrameBuffer[OLED_WIDTH];
|
||||
|
||||
uint32_t totalDuration = TICKS_100MS * 5; // 500ms
|
||||
uint32_t duration = 0;
|
||||
uint32_t start = xTaskGetTickCount();
|
||||
uint8_t offset = 0;
|
||||
TickType_t totalDuration = TICKS_100MS * 5; // 500ms
|
||||
TickType_t duration = 0;
|
||||
TickType_t start = xTaskGetTickCount();
|
||||
uint8_t offset = 0;
|
||||
|
||||
while (duration <= totalDuration) {
|
||||
duration = xTaskGetTickCount() - start;
|
||||
|
||||
Reference in New Issue
Block a user