Skip to content

Commit

Permalink
Sync PR with dev branch
Browse files Browse the repository at this point in the history
  • Loading branch information
ia committed Mar 6, 2025
2 parents 31e3851 + 5e8ab27 commit f564fa1
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Translations/translations_definitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
"id": "PowerMenu",
"maxLen": 5,
"maxLen2": 11,
"include": ["POW_DC", "POW_QC"],
"include": ["POW_DC", "POW_PD", "POW_QC"],
"description": "Menu for settings related to power. Main settings to do with the input voltage."
},
{
Expand Down
5 changes: 5 additions & 0 deletions source/Core/BSP/MHP30/stm32f1xx_hal_msp.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "Pins.h"
#include "Setup.h"
#include "stm32f1xx_hal.h"
#include "string.h"
/**
* Initializes the Global MSP.
*/
Expand Down Expand Up @@ -29,6 +30,7 @@ void HAL_MspInit(void) {
void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc) {

GPIO_InitTypeDef GPIO_InitStruct;
memset(&GPIO_InitStruct, 0, sizeof(GPIO_InitStruct));
if (hadc->Instance == ADC1) {
__HAL_RCC_ADC1_CLK_ENABLE();

Expand All @@ -51,6 +53,7 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc) {
HAL_NVIC_EnableIRQ(ADC1_2_IRQn);
} else {
__HAL_RCC_ADC2_CLK_ENABLE();
GPIO_InitStruct.Pull = GPIO_NOPULL;

/**ADC2 GPIO Configuration
PB0 ------> ADC2_IN8
Expand All @@ -59,9 +62,11 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc) {
GPIO_InitStruct.Pin = TIP_TEMP_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
HAL_GPIO_Init(TIP_TEMP_GPIO_Port, &GPIO_InitStruct);

GPIO_InitStruct.Pin = TMP36_INPUT_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
HAL_GPIO_Init(TMP36_INPUT_GPIO_Port, &GPIO_InitStruct);

GPIO_InitStruct.Pin = VIN_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
HAL_GPIO_Init(VIN_GPIO_Port, &GPIO_InitStruct);
Expand Down
51 changes: 34 additions & 17 deletions source/Core/Drivers/OLED.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,28 +760,33 @@ void OLED::fillArea(int16_t x, int8_t y, uint8_t wide, uint8_t height, const uin
}

void OLED::drawFilledRect(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1, bool clear) {
//!! LSB is at the top of the screen !!

// Draw this in 3 sections
uint8_t remainingHeight = y1 - y0;
for (uint8_t currentRow = y0 / 8; (currentRow < (OLED_HEIGHT / 8)) && remainingHeight; currentRow++) {
uint8_t maskTop = (0xFF) << (y0 % 8); // Shift off the mask
y0 = 0; // Blank out any start offset for future iterations
// If we are terminating the bottom of the rectangle in this row, we mask the bottom side of things too
if (remainingHeight <= 8) {
uint8_t maskBottom = ~((0xFF) << y1 % 8); // Create mask for
maskTop = maskTop & maskBottom; // AND the two masks together for final write mask
// Ensure coordinates are within bounds
if (x0 >= OLED_WIDTH || y0 >= OLED_HEIGHT || x1 >= OLED_WIDTH || y1 >= OLED_HEIGHT) {
return;
}

// Calculate the height in rows
uint8_t startRow = y0 / 8;
uint8_t endRow = y1 / 8;
uint8_t startMask = 0xFF << (y0 % 8);
uint8_t endMask = 0xFF >> (7 - (y1 % 8));

for (uint8_t row = startRow; row <= endRow; row++) {
uint8_t mask = 0xFF;
if (row == startRow) {
mask &= startMask;
}
if (row == endRow) {
mask &= endMask;
}

for (uint8_t xpos = x0; xpos < x1; xpos++) {
for (uint8_t x = x0; x <= x1; x++) {
if (clear) {
stripPointers[currentRow][xpos] &= ~maskTop;
stripPointers[row][x] &= ~mask;
} else {
stripPointers[currentRow][xpos] |= maskTop;
stripPointers[row][x] |= mask;
}
}

remainingHeight -= 8; // Reduce remaining height but the row stripe height
}
}

Expand All @@ -791,8 +796,20 @@ void OLED::drawHeatSymbol(uint8_t state) {
// the levels masks the symbol nicely
state /= 31; // 0-> 8 range
// Then we want to draw down (16-(5+state)
uint8_t cursor_x_temp = cursor_x;
uint16_t cursor_x_temp = cursor_x;
drawSymbol(14);
/*
/ / / / /
/ / / / /
+---------+
| |
+---------+
<- 14 px ->
What we are doing is aiming to clear a section of the screen, down to the base depending on how much PWM we are using.
Larger numbers mean more heat, so we clear less of the screen.
*/
drawFilledRect(cursor_x_temp, 0, cursor_x_temp + 12, 2 + (8 - state), true);
}

Expand Down
3 changes: 3 additions & 0 deletions source/Core/Threads/GUIThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ OperatingMode guiHandleDraw(void) {
setStatusLED(LED_OFF);
} else {
OLED::setDisplayState(OLED::DisplayState::ON);
}
if (currentOperatingMode != OperatingMode::Soldering && currentOperatingMode != OperatingMode::SolderingProfile) {
// Not in soldering mode, so set this based on temp
if (tipTemp > 55) {
setStatusLED(LED_COOLING_STILL_HOT);
} else {
Expand Down

0 comments on commit f564fa1

Please sign in to comment.