Big overhaul of the UI framework (#1749)
* Starting GUI render refactor to be more immediate mode Update TemperatureAdjust.cpp . Cleanup Soldering Sleep SolderingProfiles Soldering Rework Rough pass GUI Temp Adjust Cleanup old OperatingMode Debug Menu * Update TemperatureAdjust.cpp * Roughing some transition work * Fixup! Hook in the init starter helper * Better home screen button handler * FIXUP! Fix typo's . * Update SettingsMenu.cpp * More settings rework * More settings rendering * Fixup * Transitions Update SolderingProfile.cpp Hook in transistions * Update TemperatureAdjust.cpp * Update push.yml * Add auto-repeat to settings menu * Miniware: Use IT for I2C writes * Update USBPDDebug_HUSB238.cpp * Force write screen on side animation cancel . * Refactor moving down the settings list * Update settingsGUI.cpp * Update I2C_Wrapper.cpp * Update OLED.cpp * Rework button handling * Fix PD debug at boot * Fixup not showing right menu options * silence some warnings * Style cleanup * Fkit use bit-bang I2C for Miniware * Update GUIRendering.md * Fixup transition on enter soldering mode * Save Settings * Fixes for some animations not running Dont bail on animations if keypress is still held * Fixup settings acceleration * OLED Up animation * Link up/down on debug meny * Make all accelerometers I2C bus aware Update accelerometers_common.h * Make I2C mag optional * Miniware -> Only Bit-Bang I2C * Fixup for scrollbar FIXUP! Debug menu returns to home screen FIXUP! Up oled animation Fix temp exit * Settings menu -> Both buttons return a menu layer * Merge fixup * Update BMA223.cpp * Re-Enable OLED sleep * Save Setting on temp adjust exit * WiP on startup mode * Some autostart working * Add hibernation mode & more autostart fixes * If cant CJC; go to startup * Hibernate in sleep * Cleanup scroll indicator * FIXUP! Ensure startup warnings are linked in * FIXUP! Ensure we render out temp change before timing out * Ensure 100ms delay between CJC samples * Fix not re-calculating menu length on entering menu * Implement NegotiationinProgress for USB-PD * Mask heating until PD finishes negotiation * Fixup staying in hibernate correctly * Warning timeout * Show reset settings warning * Correctly compensate help text start time * Update GUIThread.cpp * Update USBPD.cpp * . * Fixup sleep time * Update printSleepCountdown.cpp * replacing countdown with big plus while in boost mode * bringing back the + 1 since it was missing when not in boost mode * Bail on USB-PD check after 3 seconds incase of DC source * Fix hibernate * Update PIDThread.cpp * did center plus symbol (boost mode) * Big refactor to not make settings increment handler handle the "is last item" return * Fixup boot logo * Fix flashing * Fixup recalculate the menu length on long hold * Fixup missing menu entries * Fix junk left on screen after user confirmation * Re-order button handler to use custom, then default order to allow setting associated setting * Attach setting for settings using custom handler * Fix swap +/- keys * Fix boost temp * Implement last menu option for Language selector * Wait for init before CJC runs * Check last setting via increment value * Update BSP.cpp * removed = from >= Otherwise incrementing would stop and the scroll bar would already flash at the second to last value. * (Hacky) Fix for Settings reset --------- Co-authored-by: discip <53649486+discip@users.noreply.github.com>
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#define CORE_DRIVERS_BMA223_HPP_
|
||||
#include "BMA223_defines.h"
|
||||
#include "BSP.h"
|
||||
#include "accelerometers_common.h"
|
||||
#include "I2C_Wrapper.hpp"
|
||||
#include "accelerometers_common.h"
|
||||
|
||||
|
||||
@@ -10,6 +10,10 @@
|
||||
#include "cmsis_os.h"
|
||||
#include <array>
|
||||
|
||||
#include "MMA8652FC.hpp"
|
||||
#include "accelerometers_common.h"
|
||||
#include "cmsis_os.h"
|
||||
|
||||
static const ACCEL_I2C_CLASS::I2C_REG i2c_registers[] = {
|
||||
{ CTRL_REG2, 0, 0}, // Normal mode
|
||||
{ CTRL_REG2, 0x40, 2}, // Reset all registers to POR values
|
||||
|
||||
@@ -262,7 +262,8 @@ void OLED::maskScrollIndicatorOnOLED() {
|
||||
* If forward is true, this displays a forward navigation to the second framebuffer contents.
|
||||
* Otherwise a rewinding navigation animation is shown to the second framebuffer contents.
|
||||
*/
|
||||
void OLED::transitionSecondaryFramebuffer(bool forwardNavigation) {
|
||||
void OLED::transitionSecondaryFramebuffer(const bool forwardNavigation, const TickType_t viewEnterTime) {
|
||||
bool buttonsReleased = getButtonState() == BUTTON_NONE;
|
||||
uint8_t *stripBackPointers[4];
|
||||
stripBackPointers[0] = &secondFrameBuffer[FRAMEBUFFER_START + 0];
|
||||
stripBackPointers[1] = &secondFrameBuffer[FRAMEBUFFER_START + OLED_WIDTH];
|
||||
@@ -317,10 +318,14 @@ void OLED::transitionSecondaryFramebuffer(bool forwardNavigation) {
|
||||
|
||||
refresh(); // Now refresh to write out the contents to the new page
|
||||
vTaskDelayUntil(&startDraw, TICKS_100MS / 7);
|
||||
if (getButtonState() != BUTTON_NONE) {
|
||||
buttonsReleased |= getButtonState() == BUTTON_NONE;
|
||||
if (getButtonState() != BUTTON_NONE && buttonsReleased) {
|
||||
memcpy(screenBuffer + FRAMEBUFFER_START, secondFrameBuffer + FRAMEBUFFER_START, sizeof(screenBuffer) - FRAMEBUFFER_START);
|
||||
refresh(); // Now refresh to write out the contents to the new page
|
||||
return;
|
||||
}
|
||||
}
|
||||
refresh(); //
|
||||
}
|
||||
|
||||
void OLED::useSecondaryFramebuffer(bool useSecondary) {
|
||||
@@ -330,6 +335,7 @@ void OLED::useSecondaryFramebuffer(bool useSecondary) {
|
||||
setFramebuffer(screenBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This assumes that the current display output buffer has the current on screen contents
|
||||
* Then the secondary buffer has the "new" contents to be slid up onto the screen
|
||||
@@ -337,8 +343,9 @@ void OLED::useSecondaryFramebuffer(bool useSecondary) {
|
||||
*
|
||||
* **This function blocks until the transition has completed or user presses button**
|
||||
*/
|
||||
void OLED::transitionScrollDown() {
|
||||
TickType_t startDraw = xTaskGetTickCount();
|
||||
void OLED::transitionScrollDown(const TickType_t viewEnterTime) {
|
||||
TickType_t startDraw = xTaskGetTickCount();
|
||||
bool buttonsReleased = getButtonState() == BUTTON_NONE;
|
||||
|
||||
for (uint8_t heightPos = 0; heightPos < OLED_HEIGHT; heightPos++) {
|
||||
// For each line, we shuffle all bits up a row
|
||||
@@ -365,9 +372,9 @@ void OLED::transitionScrollDown() {
|
||||
// Finally on the bottom row; we shuffle it up ready
|
||||
secondFrameBuffer[fourthStripPos] >>= 1;
|
||||
#else
|
||||
// Move the MSB off the first strip, and pop MSB from second strip onto the first strip
|
||||
// Move the LSB off the first strip, and pop MSB from second strip onto the first strip
|
||||
screenBuffer[firstStripPos] = (screenBuffer[firstStripPos] >> 1) | ((screenBuffer[secondStripPos] & 0x01) << 7);
|
||||
// Now shuffle off the second strip MSB, and replace it with the MSB of the secondary buffer
|
||||
// Now shuffle off the second strip MSB, and replace it with the LSB of the secondary buffer
|
||||
screenBuffer[secondStripPos] = (screenBuffer[secondStripPos] >> 1) | ((secondFrameBuffer[firstStripPos] & 0x01) << 7);
|
||||
// Finally, do the shuffle on the second frame buffer
|
||||
secondFrameBuffer[firstStripPos] = (secondFrameBuffer[firstStripPos] >> 1) | ((secondFrameBuffer[secondStripPos] & 0x01) << 7);
|
||||
@@ -375,7 +382,62 @@ void OLED::transitionScrollDown() {
|
||||
secondFrameBuffer[secondStripPos] >>= 1;
|
||||
#endif /* OLED_128x32 */
|
||||
}
|
||||
if (getButtonState() != BUTTON_NONE) {
|
||||
buttonsReleased |= getButtonState() == BUTTON_NONE;
|
||||
if (getButtonState() != BUTTON_NONE && buttonsReleased) {
|
||||
// Exit early, but have to transition whole buffer
|
||||
memcpy(screenBuffer + FRAMEBUFFER_START, secondFrameBuffer + FRAMEBUFFER_START, sizeof(screenBuffer) - FRAMEBUFFER_START);
|
||||
refresh(); // Now refresh to write out the contents to the new page
|
||||
return;
|
||||
}
|
||||
refresh(); // Now refresh to write out the contents to the new page
|
||||
vTaskDelayUntil(&startDraw, TICKS_100MS / 7);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* This assumes that the current display output buffer has the current on screen contents
|
||||
* Then the secondary buffer has the "new" contents to be slid down onto the screen
|
||||
* Sadly we cant use the hardware scroll as some devices with the 128x32 screens dont have the GRAM for holding both screens at once
|
||||
*
|
||||
* **This function blocks until the transition has completed or user presses button**
|
||||
*/
|
||||
void OLED::transitionScrollUp(const TickType_t viewEnterTime) {
|
||||
TickType_t startDraw = xTaskGetTickCount();
|
||||
bool buttonsReleased = getButtonState() == BUTTON_NONE;
|
||||
|
||||
for (uint8_t heightPos = 0; heightPos < OLED_HEIGHT; heightPos++) {
|
||||
// For each line, we shuffle all bits down a row
|
||||
for (uint8_t xPos = 0; xPos < OLED_WIDTH; xPos++) {
|
||||
const uint16_t firstStripPos = FRAMEBUFFER_START + xPos;
|
||||
const uint16_t secondStripPos = firstStripPos + OLED_WIDTH;
|
||||
#ifdef OLED_128x32
|
||||
// For 32 pixel high OLED's we have four strips to tailchain
|
||||
const uint16_t thirdStripPos = secondStripPos + OLED_WIDTH;
|
||||
const uint16_t fourthStripPos = thirdStripPos + OLED_WIDTH;
|
||||
// We are shffling LSB's off the end and pushing bits down
|
||||
screenBuffer[fourthStripPos] = (screenBuffer[fourthStripPos] << 1) | ((screenBuffer[thirdStripPos] & 0x80) >> 7);
|
||||
screenBuffer[thirdStripPos] = (screenBuffer[thirdStripPos] << 1) | ((screenBuffer[secondStripPos] & 0x80) >> 7);
|
||||
screenBuffer[secondStripPos] = (screenBuffer[secondStripPos] << 1) | ((screenBuffer[firstStripPos] & 0x80) >> 7);
|
||||
screenBuffer[firstStripPos] = (screenBuffer[firstStripPos] << 1) | ((secondFrameBuffer[fourthStripPos] & 0x80) >> 7);
|
||||
|
||||
secondFrameBuffer[fourthStripPos] = (secondFrameBuffer[fourthStripPos] << 1) | ((secondFrameBuffer[thirdStripPos] & 0x80) >> 7);
|
||||
secondFrameBuffer[thirdStripPos] = (secondFrameBuffer[thirdStripPos] << 1) | ((secondFrameBuffer[secondStripPos] & 0x80) >> 7);
|
||||
secondFrameBuffer[secondStripPos] = (secondFrameBuffer[secondStripPos] << 1) | ((secondFrameBuffer[firstStripPos] & 0x80) >> 7);
|
||||
// Finally on the bottom row; we shuffle it up ready
|
||||
secondFrameBuffer[firstStripPos] <<= 1;
|
||||
#else
|
||||
// We pop the LSB off the bottom row, and replace the MSB in that byte with the LSB of the row above
|
||||
screenBuffer[secondStripPos] = (screenBuffer[secondStripPos] << 1) | ((screenBuffer[firstStripPos] & 0x80) >> 7);
|
||||
// Move the LSB off the first strip, and pop MSB from second strip onto the first strip
|
||||
screenBuffer[firstStripPos] = (screenBuffer[firstStripPos] << 1) | ((secondFrameBuffer[secondStripPos] & 0x80) >> 7);
|
||||
|
||||
// Finally, do the shuffle on the second frame buffer
|
||||
secondFrameBuffer[secondStripPos] = (secondFrameBuffer[secondStripPos] << 1) | ((secondFrameBuffer[firstStripPos] & 0x80) >> 7);
|
||||
// Finally on the bottom row; we shuffle it up ready
|
||||
secondFrameBuffer[firstStripPos] <<= 1;
|
||||
#endif /* OLED_128x32 */
|
||||
}
|
||||
buttonsReleased |= getButtonState() == BUTTON_NONE;
|
||||
if (getButtonState() != BUTTON_NONE && buttonsReleased) {
|
||||
// Exit early, but have to transition whole buffer
|
||||
memcpy(screenBuffer + FRAMEBUFFER_START, secondFrameBuffer + FRAMEBUFFER_START, sizeof(screenBuffer) - FRAMEBUFFER_START);
|
||||
refresh(); // Now refresh to write out the contents to the new page
|
||||
@@ -428,14 +490,18 @@ void OLED::setRotation(bool leftHanded) {
|
||||
}
|
||||
|
||||
void OLED::setBrightness(uint8_t contrast) {
|
||||
OLED_Setup_Array[15].val = contrast;
|
||||
I2C_CLASS::writeRegistersBulk(DEVICEADDR_OLED, &OLED_Setup_Array[14], 2);
|
||||
if (OLED_Setup_Array[15].val != contrast) {
|
||||
OLED_Setup_Array[15].val = contrast;
|
||||
I2C_CLASS::writeRegistersBulk(DEVICEADDR_OLED, &OLED_Setup_Array[14], 2);
|
||||
}
|
||||
}
|
||||
|
||||
void OLED::setInverseDisplay(bool inverse) {
|
||||
uint8_t normalInverseCmd = inverse ? 0xA7 : 0xA6;
|
||||
OLED_Setup_Array[21].val = normalInverseCmd;
|
||||
I2C_CLASS::I2C_RegisterWrite(DEVICEADDR_OLED, 0x80, normalInverseCmd);
|
||||
if (OLED_Setup_Array[21].val != normalInverseCmd) {
|
||||
OLED_Setup_Array[21].val = normalInverseCmd;
|
||||
I2C_CLASS::I2C_RegisterWrite(DEVICEADDR_OLED, 0x80, normalInverseCmd);
|
||||
}
|
||||
}
|
||||
|
||||
// print a string to the current cursor location, len chars MAX
|
||||
|
||||
@@ -149,9 +149,10 @@ public:
|
||||
static void drawHeatSymbol(uint8_t state);
|
||||
static void drawScrollIndicator(uint8_t p, uint8_t h); // Draws a scrolling position indicator
|
||||
static void maskScrollIndicatorOnOLED();
|
||||
static void transitionSecondaryFramebuffer(bool forwardNavigation);
|
||||
static void transitionSecondaryFramebuffer(const bool forwardNavigation, const TickType_t viewEnterTime);
|
||||
static void useSecondaryFramebuffer(bool useSecondary);
|
||||
static void transitionScrollDown();
|
||||
static void transitionScrollDown(const TickType_t viewEnterTime);
|
||||
static void transitionScrollUp(const TickType_t viewEnterTime);
|
||||
|
||||
private:
|
||||
static bool checkDisplayBufferChecksum() {
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
#include "Si7210_defines.h"
|
||||
#include "accelerometers_common.h"
|
||||
#include <Si7210.h>
|
||||
bool Si7210::detect() { return ACCEL_I2C_CLASS::wakePart(SI7210_ADDRESS); }
|
||||
#ifdef MAG_SLEEP_SUPPORT
|
||||
bool Si7210::detect() { return FRToSI2C::wakePart(SI7210_ADDRESS); }
|
||||
|
||||
bool Si7210::init() {
|
||||
// Turn on auto increment and sanity check ID
|
||||
@@ -185,3 +186,4 @@ bool Si7210::set_high_range() {
|
||||
worked &= write_reg(SI7210_A5, 0, val);
|
||||
return worked;
|
||||
}
|
||||
#endif // MAG_SLEEP_SUPPORT
|
||||
@@ -7,7 +7,10 @@
|
||||
|
||||
#ifndef CORE_DRIVERS_SI7210_H_
|
||||
#define CORE_DRIVERS_SI7210_H_
|
||||
#include "configuration.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef MAG_SLEEP_SUPPORT
|
||||
class Si7210 {
|
||||
public:
|
||||
// Return true if present
|
||||
@@ -23,5 +26,5 @@ private:
|
||||
static bool get_field_strength(int16_t *field);
|
||||
static bool set_high_range();
|
||||
};
|
||||
|
||||
#endif // MAG_SLEEP_SUPPORT
|
||||
#endif /* CORE_DRIVERS_SI7210_H_ */
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
* Author: ralim
|
||||
*/
|
||||
|
||||
#ifndef SRC_TIPTHERMOMODEL_H_
|
||||
#define SRC_TIPTHERMOMODEL_H_
|
||||
#include "BSP.h"
|
||||
#include "Types.h"
|
||||
#include "stdint.h"
|
||||
#ifndef SRC_TIPTHERMOMODEL_H_
|
||||
#define SRC_TIPTHERMOMODEL_H_
|
||||
class TipThermoModel {
|
||||
public:
|
||||
// These are the main two functions
|
||||
|
||||
@@ -29,6 +29,7 @@ bool EPREvaluateCapabilityFunc(const epr_pd_msg *capabilities, pd_msg *r
|
||||
FUSB302 fusb((0x22 << 1), fusb_read_buf, fusb_write_buf, ms_delay); // Create FUSB driver
|
||||
PolicyEngine pe(fusb, get_ms_timestamp, ms_delay, pdbs_dpm_get_sink_capability, pdbs_dpm_evaluate_capability, EPREvaluateCapabilityFunc, USB_PD_EPR_WATTAGE);
|
||||
int USBPowerDelivery::detectionState = 0;
|
||||
bool haveSeenCapabilityOffer = false;
|
||||
uint16_t requested_voltage_mv = 0;
|
||||
|
||||
/* The current draw when the output is disabled */
|
||||
@@ -51,6 +52,15 @@ void USBPowerDelivery::step() {
|
||||
}
|
||||
|
||||
void USBPowerDelivery::PPSTimerCallback() { pe.TimersCallback(); }
|
||||
bool USBPowerDelivery::negotiationInProgress() {
|
||||
if (USBPowerDelivery::negotiationComplete()) {
|
||||
return false;
|
||||
}
|
||||
if (haveSeenCapabilityOffer) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool USBPowerDelivery::negotiationComplete() {
|
||||
if (!fusbPresent()) {
|
||||
return true;
|
||||
@@ -268,6 +278,7 @@ bool EPREvaluateCapabilityFunc(const epr_pd_msg *capabilities, pd_msg *request)
|
||||
bool pdbs_dpm_evaluate_capability(const pd_msg *capabilities, pd_msg *request) {
|
||||
memset(lastCapabilities, 0, sizeof(lastCapabilities));
|
||||
memcpy(lastCapabilities, capabilities->obj, sizeof(uint32_t) * 7);
|
||||
haveSeenCapabilityOffer = true;
|
||||
/* Get the number of PDOs */
|
||||
uint8_t numobj = PD_NUMOBJ_GET(capabilities);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user