mirror of
https://github.com/Ralim/IronOS.git
synced 2025-07-23 12:23:06 +02:00
Mhp 30 fixes (#2094)
* Fix LED control for MHP30 * Refactor the draw rect function to fix heating * FIXUP to include correct menu title for MHP30 Closes #2036 * Fixes for ADC mode init Fixes #2043
This commit is contained in:
@@ -172,7 +172,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."
|
||||
},
|
||||
{
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#include "Pins.h"
|
||||
#include "Setup.h"
|
||||
#include "stm32f1xx_hal.h"
|
||||
#include "string.h"
|
||||
/**
|
||||
* Initializes the Global MSP.
|
||||
*/
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
@@ -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);
|
||||
|
@@ -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 !!
|
||||
// Ensure coordinates are within bounds
|
||||
if (x0 >= OLED_WIDTH || y0 >= OLED_HEIGHT || x1 >= OLED_WIDTH || y1 >= OLED_HEIGHT) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 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
|
||||
// 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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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 {
|
||||
|
Reference in New Issue
Block a user