Update debug info
Change pin configs Clean up some code
This commit is contained in:
@@ -7,7 +7,10 @@ endif
|
|||||||
# Discover the source files to build
|
# Discover the source files to build
|
||||||
SOURCE := $(shell find . -type f -name '*.c')
|
SOURCE := $(shell find . -type f -name '*.c')
|
||||||
SOURCE_CPP := $(shell find . -type f -name '*.cpp')
|
SOURCE_CPP := $(shell find . -type f -name '*.cpp')
|
||||||
|
SOURCES := $(shell find . -type f -name '*.c*')
|
||||||
S_SRCS := $(shell find . -type f -name '*.s')
|
S_SRCS := $(shell find . -type f -name '*.s')
|
||||||
|
CPPCHECK := cppcheck
|
||||||
|
CHECKFLAGS := -q --error-exitcode=1
|
||||||
|
|
||||||
APP_INC_DIR = ./inc
|
APP_INC_DIR = ./inc
|
||||||
CMSIS_DEVICE_INC_DIR = ./CMSIS/device
|
CMSIS_DEVICE_INC_DIR = ./CMSIS/device
|
||||||
@@ -172,8 +175,8 @@ OUT_OBJS_CPP=$(addprefix $(OUTPUT_DIR)/,$(OBJS_CPP))
|
|||||||
OUT_OBJS_S=$(addprefix $(OUTPUT_DIR)/,$(OBJS_S))
|
OUT_OBJS_S=$(addprefix $(OUTPUT_DIR)/,$(OBJS_S))
|
||||||
OUT_HEXFILE=$(addprefix $(HEXFILE_DIR)/,$(OUTPUT_EXE))
|
OUT_HEXFILE=$(addprefix $(HEXFILE_DIR)/,$(OUTPUT_EXE))
|
||||||
|
|
||||||
all: $(OUT_HEXFILE).hex
|
all: cppcheck.out.xml $(OUT_HEXFILE).hex
|
||||||
|
|
||||||
#
|
#
|
||||||
# The rule to create the target directory
|
# The rule to create the target directory
|
||||||
#
|
#
|
||||||
@@ -209,6 +212,8 @@ $(OUT_OBJS_S): $(OUTPUT_DIR)/%.o: %.s Makefile
|
|||||||
@echo 'Finished building: $<'
|
@echo 'Finished building: $<'
|
||||||
@echo ' '
|
@echo ' '
|
||||||
|
|
||||||
|
cppcheck.out.xml: $(SOURCES)
|
||||||
|
$(CPPCHECK) $(CHECKFLAGS) $^ -xml >$@
|
||||||
|
|
||||||
clean :
|
clean :
|
||||||
rm -Rf $(OUTPUT_DIR)
|
rm -Rf $(OUTPUT_DIR)
|
||||||
|
|||||||
@@ -101,12 +101,14 @@
|
|||||||
#define configTICK_RATE_HZ ((TickType_t)100)
|
#define configTICK_RATE_HZ ((TickType_t)100)
|
||||||
#define configMAX_PRIORITIES ( 4 )
|
#define configMAX_PRIORITIES ( 4 )
|
||||||
#define configMINIMAL_STACK_SIZE ((uint16_t)256)
|
#define configMINIMAL_STACK_SIZE ((uint16_t)256)
|
||||||
#define configTOTAL_HEAP_SIZE ((size_t)10240)
|
#define configTOTAL_HEAP_SIZE ((size_t)10240) /*Currently use about 9000*/
|
||||||
#define configMAX_TASK_NAME_LEN ( 16 )
|
#define configMAX_TASK_NAME_LEN ( 48 )
|
||||||
#define configUSE_16_BIT_TICKS 0
|
#define configUSE_16_BIT_TICKS 0
|
||||||
#define configUSE_MUTEXES 1
|
#define configUSE_MUTEXES 1
|
||||||
#define configQUEUE_REGISTRY_SIZE 8
|
#define configQUEUE_REGISTRY_SIZE 8
|
||||||
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
|
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1
|
||||||
|
#define configCHECK_FOR_STACK_OVERFLOW 2
|
||||||
|
|
||||||
|
|
||||||
/* Co-routine definitions. */
|
/* Co-routine definitions. */
|
||||||
#define configUSE_CO_ROUTINES 0
|
#define configUSE_CO_ROUTINES 0
|
||||||
@@ -122,6 +124,7 @@ to exclude the API function. */
|
|||||||
#define INCLUDE_vTaskDelayUntil 0
|
#define INCLUDE_vTaskDelayUntil 0
|
||||||
#define INCLUDE_vTaskDelay 1
|
#define INCLUDE_vTaskDelay 1
|
||||||
#define INCLUDE_xTaskGetSchedulerState 1
|
#define INCLUDE_xTaskGetSchedulerState 1
|
||||||
|
#define INCLUDE_uxTaskGetStackHighWaterMark 1
|
||||||
|
|
||||||
/* Cortex-M specific definitions. */
|
/* Cortex-M specific definitions. */
|
||||||
#ifdef __NVIC_PRIO_BITS
|
#ifdef __NVIC_PRIO_BITS
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *hi2c);
|
|||||||
void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c);
|
void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c);
|
||||||
void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c);
|
void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c);
|
||||||
void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c);
|
void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c);
|
||||||
|
void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed portCHAR *pcTaskName );
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ FRToSI2C::FRToSI2C(I2C_HandleTypeDef* i2chandle) {
|
|||||||
|
|
||||||
void FRToSI2C::CpltCallback() {
|
void FRToSI2C::CpltCallback() {
|
||||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||||
|
|
||||||
if (I2CSemaphore) {
|
if (I2CSemaphore) {
|
||||||
xSemaphoreGiveFromISR(I2CSemaphore, &xHigherPriorityTaskWoken);
|
xSemaphoreGiveFromISR(I2CSemaphore, &xHigherPriorityTaskWoken);
|
||||||
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||||
@@ -34,10 +33,13 @@ void FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t MemAddress,
|
|||||||
//Get the mutex so we can use the I2C port
|
//Get the mutex so we can use the I2C port
|
||||||
//Wait up to 1 second for the mutex
|
//Wait up to 1 second for the mutex
|
||||||
if ( xSemaphoreTake( I2CSemaphore, ( TickType_t ) 1000 ) == pdTRUE) {
|
if ( xSemaphoreTake( I2CSemaphore, ( TickType_t ) 1000 ) == pdTRUE) {
|
||||||
HAL_I2C_Mem_Read(i2c, DevAddress, MemAddress, MemAddSize, pData,
|
if (HAL_I2C_Mem_Read(i2c, DevAddress, MemAddress, MemAddSize, pData,
|
||||||
Size, 5000);
|
Size, 5000) != HAL_OK) {
|
||||||
|
NVIC_SystemReset();
|
||||||
|
}
|
||||||
xSemaphoreGive(I2CSemaphore);
|
xSemaphoreGive(I2CSemaphore);
|
||||||
|
} else {
|
||||||
|
NVIC_SystemReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -56,10 +58,14 @@ void FRToSI2C::Mem_Write(uint16_t DevAddress, uint16_t MemAddress,
|
|||||||
//Get the mutex so we can use the I2C port
|
//Get the mutex so we can use the I2C port
|
||||||
//Wait up to 1 second for the mutex
|
//Wait up to 1 second for the mutex
|
||||||
if ( xSemaphoreTake( I2CSemaphore, ( TickType_t ) 1000 ) == pdTRUE) {
|
if ( xSemaphoreTake( I2CSemaphore, ( TickType_t ) 1000 ) == pdTRUE) {
|
||||||
HAL_I2C_Mem_Write(i2c, DevAddress, MemAddress, MemAddSize, pData,
|
if (HAL_I2C_Mem_Write(i2c, DevAddress, MemAddress, MemAddSize,
|
||||||
Size, 5000);
|
pData, Size, 5000) != HAL_OK) {
|
||||||
|
NVIC_SystemReset();
|
||||||
|
}
|
||||||
xSemaphoreGive(I2CSemaphore);
|
xSemaphoreGive(I2CSemaphore);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
NVIC_SystemReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -81,8 +87,13 @@ void FRToSI2C::Transmit(uint16_t DevAddress, uint8_t* pData, uint16_t Size) {
|
|||||||
//Get the mutex so we can use the I2C port
|
//Get the mutex so we can use the I2C port
|
||||||
//Wait up to 1 second for the mutex
|
//Wait up to 1 second for the mutex
|
||||||
if ( xSemaphoreTake( I2CSemaphore, ( TickType_t ) 1000 ) == pdTRUE) {
|
if ( xSemaphoreTake( I2CSemaphore, ( TickType_t ) 1000 ) == pdTRUE) {
|
||||||
HAL_I2C_Master_Transmit(i2c, DevAddress, pData, Size, 5000);
|
if (HAL_I2C_Master_Transmit(i2c, DevAddress, pData, Size, 5000)
|
||||||
|
!= HAL_OK) {
|
||||||
|
NVIC_SystemReset();
|
||||||
|
}
|
||||||
xSemaphoreGive(I2CSemaphore);
|
xSemaphoreGive(I2CSemaphore);
|
||||||
|
} else {
|
||||||
|
NVIC_SystemReset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ void MMA8652FC::initalize() {
|
|||||||
I2C_RegisterWrite(PL_COUNT_REG, 200); //200 count debounce
|
I2C_RegisterWrite(PL_COUNT_REG, 200); //200 count debounce
|
||||||
I2C_RegisterWrite(PL_BF_ZCOMP_REG, 0b01000111); //Set the threshold to 42 degrees
|
I2C_RegisterWrite(PL_BF_ZCOMP_REG, 0b01000111); //Set the threshold to 42 degrees
|
||||||
I2C_RegisterWrite(P_L_THS_REG, 0b10011100); //Up the trip angles
|
I2C_RegisterWrite(P_L_THS_REG, 0b10011100); //Up the trip angles
|
||||||
I2C_RegisterWrite( CTRL_REG4, 0x01 | (1 << 4)); // Enable dataready interrupt & orientation interrupt
|
I2C_RegisterWrite( CTRL_REG4, 0); // Disable IRQ's
|
||||||
I2C_RegisterWrite( CTRL_REG5, 0x01); // Route data ready interrupts to INT1 ->PB5 ->EXTI5, leaving orientation routed to INT2
|
I2C_RegisterWrite( CTRL_REG5, 0x01); // Route data ready interrupts to INT1 ->PB5 ->EXTI5, leaving orientation routed to INT2
|
||||||
I2C_RegisterWrite( CTRL_REG2, 0x12); //Set maximum resolution oversampling
|
I2C_RegisterWrite( CTRL_REG2, 0x12); //Set maximum resolution oversampling
|
||||||
I2C_RegisterWrite( XYZ_DATA_CFG_REG, (1 << 4)); //select high pass filtered data
|
I2C_RegisterWrite( XYZ_DATA_CFG_REG, (1 << 4)); //select high pass filtered data
|
||||||
|
|||||||
@@ -60,13 +60,11 @@ OLED::OLED(FRToSI2C* i2cHandle) {
|
|||||||
|
|
||||||
void OLED::initialize() {
|
void OLED::initialize() {
|
||||||
HAL_Delay(5);
|
HAL_Delay(5);
|
||||||
|
|
||||||
HAL_GPIO_WritePin(OLED_RESET_GPIO_Port, OLED_RESET_Pin, GPIO_PIN_SET);
|
HAL_GPIO_WritePin(OLED_RESET_GPIO_Port, OLED_RESET_Pin, GPIO_PIN_SET);
|
||||||
HAL_Delay(5);
|
HAL_Delay(10);
|
||||||
//Send the setup settings
|
//Send the setup settings
|
||||||
i2c->Transmit( DEVICEADDR_OLED, (uint8_t*) OLED_Setup_Array, configLength);
|
i2c->Transmit( DEVICEADDR_OLED, (uint8_t*) OLED_Setup_Array, configLength);
|
||||||
//displayOnOff(true);
|
displayOnOff(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Write out the buffer to the OLEd & call any rendering objects
|
//Write out the buffer to the OLEd & call any rendering objects
|
||||||
@@ -174,7 +172,7 @@ void OLED::setRotation(bool leftHanded) {
|
|||||||
OLED_Setup_Array[11] = 0xC0;
|
OLED_Setup_Array[11] = 0xC0;
|
||||||
OLED_Setup_Array[19] = 0xA0;
|
OLED_Setup_Array[19] = 0xA0;
|
||||||
}
|
}
|
||||||
i2c->Transmit( DEVICEADDR_OLED, (uint8_t*) OLED_Setup_Array, 50);
|
i2c->Transmit( DEVICEADDR_OLED, (uint8_t*) OLED_Setup_Array, configLength);
|
||||||
inLeftHandedMode = leftHanded;
|
inLeftHandedMode = leftHanded;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ void Setup_HAL() {
|
|||||||
MX_TIM2_Init();
|
MX_TIM2_Init();
|
||||||
MX_IWDG_Init();
|
MX_IWDG_Init();
|
||||||
|
|
||||||
HAL_ADC_Start_DMA(&hadc1, (uint32_t*) ADCReadings, 64);//start DMA of normal readings
|
HAL_ADC_Start_DMA(&hadc1, (uint32_t*) ADCReadings, 64); //start DMA of normal readings
|
||||||
HAL_ADCEx_InjectedStart(&hadc1); //enable injected readings
|
HAL_ADCEx_InjectedStart(&hadc1); //enable injected readings
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,7 +131,9 @@ static void MX_ADC1_Init(void) {
|
|||||||
//F in = 10.66 MHz
|
//F in = 10.66 MHz
|
||||||
/*
|
/*
|
||||||
* Injected time is 1 delay clock + (12 adc cycles*4)+4*sampletime =~217 clocks = 0.2ms
|
* Injected time is 1 delay clock + (12 adc cycles*4)+4*sampletime =~217 clocks = 0.2ms
|
||||||
*
|
* Charge time is 0.016 uS ideally
|
||||||
|
* So Sampling time must be >= 0.016uS
|
||||||
|
* 1/10.66MHz is 0.09uS, so 1 CLK is *should* be enough
|
||||||
* */
|
* */
|
||||||
sConfigInjected.InjectedChannel = ADC_CHANNEL_8;
|
sConfigInjected.InjectedChannel = ADC_CHANNEL_8;
|
||||||
sConfigInjected.InjectedRank = 1;
|
sConfigInjected.InjectedRank = 1;
|
||||||
@@ -143,13 +145,16 @@ static void MX_ADC1_Init(void) {
|
|||||||
sConfigInjected.InjectedOffset = 0;
|
sConfigInjected.InjectedOffset = 0;
|
||||||
|
|
||||||
HAL_ADCEx_InjectedConfigChannel(&hadc1, &sConfigInjected);
|
HAL_ADCEx_InjectedConfigChannel(&hadc1, &sConfigInjected);
|
||||||
|
|
||||||
|
sConfigInjected.InjectedSamplingTime = ADC_SAMPLETIME_1CYCLE_5;
|
||||||
sConfigInjected.InjectedRank = 2;
|
sConfigInjected.InjectedRank = 2;
|
||||||
HAL_ADCEx_InjectedConfigChannel(&hadc1, &sConfigInjected);
|
HAL_ADCEx_InjectedConfigChannel(&hadc1, &sConfigInjected);
|
||||||
sConfigInjected.InjectedRank = 3;
|
sConfigInjected.InjectedRank = 3;
|
||||||
HAL_ADCEx_InjectedConfigChannel(&hadc1, &sConfigInjected);
|
HAL_ADCEx_InjectedConfigChannel(&hadc1, &sConfigInjected);
|
||||||
sConfigInjected.InjectedRank = 4;
|
sConfigInjected.InjectedRank = 4;
|
||||||
HAL_ADCEx_InjectedConfigChannel(&hadc1, &sConfigInjected);
|
HAL_ADCEx_InjectedConfigChannel(&hadc1, &sConfigInjected);
|
||||||
SET_BIT(hadc1.Instance->CR1, ( ADC_CR1_JEOCIE ));//Enable end of injected conv irq
|
SET_BIT(hadc1.Instance->CR1, ( ADC_CR1_JEOCIE )); //Enable end of injected conv irq
|
||||||
|
while(HAL_ADCEx_Calibration_Start(&hadc1) != HAL_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* I2C1 init function */
|
/* I2C1 init function */
|
||||||
@@ -288,13 +293,13 @@ static void MX_DMA_Init(void) {
|
|||||||
|
|
||||||
/* DMA interrupt init */
|
/* DMA interrupt init */
|
||||||
/* DMA1_Channel1_IRQn interrupt configuration */
|
/* DMA1_Channel1_IRQn interrupt configuration */
|
||||||
HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 5, 0);
|
HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 15, 0);
|
||||||
HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn);
|
HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn);
|
||||||
/* DMA1_Channel6_IRQn interrupt configuration */
|
/* DMA1_Channel6_IRQn interrupt configuration */
|
||||||
HAL_NVIC_SetPriority(DMA1_Channel6_IRQn, 5, 0);
|
HAL_NVIC_SetPriority(DMA1_Channel6_IRQn, 15, 0);
|
||||||
HAL_NVIC_EnableIRQ(DMA1_Channel6_IRQn);
|
HAL_NVIC_EnableIRQ(DMA1_Channel6_IRQn);
|
||||||
/* DMA1_Channel7_IRQn interrupt configuration */
|
/* DMA1_Channel7_IRQn interrupt configuration */
|
||||||
HAL_NVIC_SetPriority(DMA1_Channel7_IRQn, 5, 0);
|
HAL_NVIC_SetPriority(DMA1_Channel7_IRQn, 15, 0);
|
||||||
HAL_NVIC_EnableIRQ(DMA1_Channel7_IRQn);
|
HAL_NVIC_EnableIRQ(DMA1_Channel7_IRQn);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -336,13 +341,16 @@ static void MX_GPIO_Init(void) {
|
|||||||
| GPIO_PIN_15;
|
| GPIO_PIN_15;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
//Set PA 11 and PA 12 to GND to stop usb detection, 14 re-rused for debug
|
|
||||||
|
//Set PA 11 and PA 12 to GND to stop usb detection, 13/14 re-rused for debug
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_14 | GPIO_PIN_13;
|
GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_14 | GPIO_PIN_13;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_11, GPIO_PIN_RESET);
|
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_11, GPIO_PIN_RESET);
|
||||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_12, GPIO_PIN_RESET);
|
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_12, GPIO_PIN_RESET);
|
||||||
|
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_13, GPIO_PIN_RESET);
|
||||||
|
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_14, GPIO_PIN_RESET);
|
||||||
|
|
||||||
/*Configure GPIO pins : KEY_B_Pin KEY_A_Pin */
|
/*Configure GPIO pins : KEY_B_Pin KEY_A_Pin */
|
||||||
GPIO_InitStruct.Pin = KEY_B_Pin | KEY_A_Pin;
|
GPIO_InitStruct.Pin = KEY_B_Pin | KEY_A_Pin;
|
||||||
@@ -361,10 +369,11 @@ static void MX_GPIO_Init(void) {
|
|||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
HAL_GPIO_Init(OLED_RESET_GPIO_Port, &GPIO_InitStruct);
|
HAL_GPIO_Init(OLED_RESET_GPIO_Port, &GPIO_InitStruct);
|
||||||
|
|
||||||
/*Configure GPIO pins : INT_Orientation_Pin INT_Movement_Pin */
|
/* Configure GPIO pins : INT_Orientation_Pin INT_Movement_Pin */
|
||||||
|
/* Not used anymore*/
|
||||||
GPIO_InitStruct.Pin = INT_Orientation_Pin | INT_Movement_Pin;
|
GPIO_InitStruct.Pin = INT_Orientation_Pin | INT_Movement_Pin;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
|
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
||||||
GPIO_InitStruct.Pull = GPIO_PULLUP; //Technically the IMU is P-P but safer to pullup (very tiny current cost)
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||||
|
|
||||||
/*Configure peripheral I/O remapping */
|
/*Configure peripheral I/O remapping */
|
||||||
|
|||||||
@@ -231,33 +231,33 @@ const char* SettingsDescriptions[17] = {
|
|||||||
/* Shutdown timeout */ "Время до отключения <Доступно отключение>.",
|
/* Shutdown timeout */ "Время до отключения <Доступно отключение>.",
|
||||||
/* Motion sensitivity level */ "Акселерометр <0 - Выкл., 1 - Мин. чувствительность, 9 - Макс. чувствительность>.",
|
/* Motion sensitivity level */ "Акселерометр <0 - Выкл., 1 - Мин. чувствительность, 9 - Макс. чувствительность>.",
|
||||||
/* Temperature in F and C */ "Единица измерения температуры. < C - Цельсий, F - Фаренгейт >",
|
/* Temperature in F and C */ "Единица измерения температуры. < C - Цельсий, F - Фаренгейт >",
|
||||||
/* Advanced idle display mode enabled */ "Показывать детальную информацию в режиме настроек <Вместо картинки>.",
|
/* Advanced idle display mode enabled */ "Показывать детальную в режиме настроек <Вместо картинки>.",
|
||||||
/* Display rotation mode */ "Ориентация дисплея. <A - Автоповорот, L - Левша, R - Правша>",
|
/* Display rotation mode */ "Ориентация дисплея. <A - Автоповорот, L - Левша, R - Правша>",
|
||||||
/* Boost enabled */ "Повышение температуры при удержании кнопки А в режиме пайки.",
|
/* Boost enabled */ "Турбо-режим при удержании кнопки А в режиме пайки.",
|
||||||
/* Boost temperature */ "Температура в Турбо-режиме.",
|
/* Boost temperature */ "Температура в Турбо-режиме.",
|
||||||
/* Automatic start mode */ "Автоматический переход в режим пайки при включении питания.",
|
/* Automatic start mode */ "Автоматический переход в режим пайки при включении питания.",
|
||||||
/* Cooldown blink */ "Показывать изменение температуры на мигающем экране в процессе охлаждения.",
|
/* Cooldown blink */ "Показывать изменение температуры в процессе охлаждения, мигая экраном.",
|
||||||
/* Temperature calibration enter menu */ "Калибровка температурного датчика.",
|
/* Temperature calibration enter menu */ "Калибровка температурного датчика.",
|
||||||
/* Settings reset command */ "Сброс всех настроек к исходным значениям.",
|
/* Settings reset command */ "Сброс всех настроек к исходным значения.",
|
||||||
/* Calibrate input voltage */ "Калибровка напряжения. Настройка кнопками, длительное нажатие для завершения.",
|
/* Calibrate input voltage */ "Калибровка напряжения входа. Настройка кнопками, нажать и удержать чтобы завершить.",
|
||||||
/* Advanced soldering screen enabled */ "Показывать детальную информацию при пайке.",
|
/* Advanced soldering screen enabled */ "Показывать детальную информацию при пайке.",
|
||||||
/* Description Scroll Speed */ "Скорость прокрутки текста.",
|
/* Description Scroll Speed */ "Скорость прокрутки текста.",
|
||||||
};
|
};
|
||||||
|
|
||||||
const char* SettingsCalibrationWarning = "Убедитесь, что жало остыло до комнатной температуры, прежде чем продолжать!";
|
const char* SettingsCalibrationWarning = "Убедитесь, что жало остыло до комнатной температуры, прежде чем продолжать!";
|
||||||
const char* SettingsResetWarning = "Вы действительно хотите сбросить настройки до значений по умолчанию?";
|
const char* SettingsResetWarning = "Вы действительно хотите сбросить настройки до значений по умолчанию?";
|
||||||
const char* UVLOWarningString = "АККУМ--!"; // <=8 chars
|
const char* UVLOWarningString = "АККУМ--"; // <=8 chars
|
||||||
const char* UndervoltageString = "Низ. напряжение!"; // <=16 chars
|
const char* UndervoltageString = "Под питанием"; // <=16 chars
|
||||||
const char* InputVoltageString = "Питание(B):"; // <=11 chars, preferably end with a space
|
const char* InputVoltageString = "Питание(B):"; // <=11 chars, preferably end with a space
|
||||||
const char* WarningTipTempString = "Жало t°: "; // <=12 chars, preferably end with a space
|
const char* WarningTipTempString = "Жало t°: "; // <=12 chars, preferably end with a space
|
||||||
const char* BadTipString = "ПлохЖало"; // <=8 chars
|
const char* BadTipString = "Жало--"; // <=8 chars
|
||||||
const char* SleepingSimpleString = "Сон "; // Must be <= 4 chars
|
const char* SleepingSimpleString = "Сон "; // Must be <= 4 chars
|
||||||
const char* SleepingAdvancedString = "Ожидание..."; // <=16 chars
|
const char* SleepingAdvancedString = "Ожидание..."; // <=16 chars
|
||||||
const char* WarningSimpleString = " АЙ!"; // Must be <= 4 chars
|
const char* WarningSimpleString = " АЙ!"; // Must be <= 4 chars
|
||||||
const char* WarningAdvancedString = "ВНИМАНИЕ ГОРЯЧО!"; // <=16 chars
|
const char* WarningAdvancedString = "ВНИМАНИЕ ГОРЯЧО!"; // <=16 chars
|
||||||
const char* SleepingTipAdvancedString = "Жало:"; // <=6 chars
|
const char* SleepingTipAdvancedString = "Жало:"; // <=6 chars
|
||||||
const char* IdleTipString = "Жало:"; // IdleTipString+IdleSetString <= 10
|
const char* IdleTipString = "Жало:"; // IdleTipString+IdleSetString <= 10
|
||||||
const char* IdleSetString = " ->"; // preferably start with a space; IdleTipString+IdleSetString <= 10
|
const char* IdleSetString = " ->"; // preferably start with a space; IdleTipString+IdleSetString <= 10
|
||||||
const char* TipDisconnectedString = "Жало отключено!"; // <=16 chars
|
const char* TipDisconnectedString = "Жало отключено!"; // <=16 chars
|
||||||
const char* SolderingAdvancedPowerPrompt = "Питание: "; // <=12 chars
|
const char* SolderingAdvancedPowerPrompt = "Питание: "; // <=12 chars
|
||||||
const char* OffString ="Off"; // 3 chars max
|
const char* OffString ="Off"; // 3 chars max
|
||||||
@@ -296,17 +296,16 @@ const char* SettingsShortNames[17][2] = {
|
|||||||
/* (<= 11) Message Scroll Speed */ {"Скорость","текста"}, //8,6
|
/* (<= 11) Message Scroll Speed */ {"Скорость","текста"}, //8,6
|
||||||
};
|
};
|
||||||
|
|
||||||
// SettingsMenuEntries lengths <= 13 per line (\n starts second line)
|
|
||||||
const char* SettingsMenuEntries[4] = {
|
const char* SettingsMenuEntries[4] = {
|
||||||
/* Soldering Menu */ "Настройки\nрежима пайки",
|
/*Soldering Menu*/"Пайка",
|
||||||
/* Power Saving Menu */ "Сон и энерго-\nсбережение",
|
/* Power Saving Menu*/"Сон",
|
||||||
/* UI Menu */ "Настройки\nинтерфейса",
|
/* UI Menu*/"Интерфейс",
|
||||||
/* Advanced Menu */ "Расширенные\nнастройки", };
|
/* Advanced Menu*/"Другие", };
|
||||||
const char* SettingsMenuEntriesDescriptions[4] = {
|
const char* SettingsMenuEntriesDescriptions[4] ={
|
||||||
"Режим пайки. Настройки действуют при включенном жале.",
|
"Настройки для режима пайки. Действуют при включенном жале.",
|
||||||
"Поведение при простое для экономии энергии и безопасности использования.",
|
"Настройки при бездействии. Полезно чтобы не обжечься и случайно не сжечь жилище.",
|
||||||
"Настройки отображения данных на экране.",
|
"Пользовательский интерфейс.",
|
||||||
"Расширенные настройки, вывод дополнительной информации."
|
"Расширенные настройки. Дополнительные удобства."
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -164,23 +164,23 @@ const menuitem advancedMenu[] = {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Detailed IDLE
|
* Detailed IDLE
|
||||||
* Detailed Soldering
|
* Detailed Soldering
|
||||||
* Logo Time
|
* Logo Time
|
||||||
* Calibrate Temperature
|
* Calibrate Temperature
|
||||||
* Calibrate Input V
|
* Calibrate Input V
|
||||||
* Reset Settings
|
* Reset Settings
|
||||||
*/
|
*/
|
||||||
{ (const char*) SettingsDescriptions[6], { settings_setAdvancedIDLEScreens }, {
|
{ (const char*) SettingsDescriptions[6], { settings_setAdvancedIDLEScreens }, {
|
||||||
settings_displayAdvancedIDLEScreens } }, /* Advanced idle screen*/
|
settings_displayAdvancedIDLEScreens } }, /* Advanced idle screen*/
|
||||||
{ (const char*) SettingsDescriptions[15],
|
{ (const char*) SettingsDescriptions[15],
|
||||||
{ settings_setAdvancedSolderingScreens }, {
|
{ settings_setAdvancedSolderingScreens }, {
|
||||||
settings_displayAdvancedSolderingScreens } }, /* Advanced soldering screen*/
|
settings_displayAdvancedSolderingScreens } }, /* Advanced soldering screen*/
|
||||||
|
{ (const char*) SettingsDescriptions[13], { settings_setResetSettings }, {
|
||||||
|
settings_displayResetSettings } }, /*Resets settings*/
|
||||||
{ (const char*) SettingsDescriptions[12], { settings_setCalibrate }, {
|
{ (const char*) SettingsDescriptions[12], { settings_setCalibrate }, {
|
||||||
settings_displayCalibrate } }, /*Calibrate tip*/
|
settings_displayCalibrate } }, /*Calibrate tip*/
|
||||||
{ (const char*) SettingsDescriptions[14], { settings_setCalibrateVIN }, {
|
{ (const char*) SettingsDescriptions[14], { settings_setCalibrateVIN }, {
|
||||||
settings_displayCalibrateVIN } }, /*Voltage input cal*/
|
settings_displayCalibrateVIN } }, /*Voltage input cal*/
|
||||||
{ (const char*) SettingsDescriptions[13], { settings_setResetSettings }, {
|
|
||||||
settings_displayResetSettings } }, /*Resets settings - KEEP LAST*/
|
|
||||||
{ NULL, { NULL }, { NULL } } // end of menu marker. DO NOT REMOVE
|
{ NULL, { NULL }, { NULL } } // end of menu marker. DO NOT REMOVE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ uint32_t lastButtonTime = 0;
|
|||||||
// FreeRTOS variables
|
// FreeRTOS variables
|
||||||
osThreadId GUITaskHandle;
|
osThreadId GUITaskHandle;
|
||||||
osThreadId PIDTaskHandle;
|
osThreadId PIDTaskHandle;
|
||||||
osThreadId ROTTaskHandle;
|
|
||||||
osThreadId MOVTaskHandle;
|
osThreadId MOVTaskHandle;
|
||||||
|
|
||||||
static TaskHandle_t pidTaskNotification = NULL;
|
static TaskHandle_t pidTaskNotification = NULL;
|
||||||
@@ -35,7 +34,6 @@ static TaskHandle_t pidTaskNotification = NULL;
|
|||||||
void startGUITask(void const *argument);
|
void startGUITask(void const *argument);
|
||||||
void startPIDTask(void const *argument);
|
void startPIDTask(void const *argument);
|
||||||
void startMOVTask(void const *argument);
|
void startMOVTask(void const *argument);
|
||||||
void startRotationTask(void const *argument);
|
|
||||||
// End FreeRTOS
|
// End FreeRTOS
|
||||||
|
|
||||||
// Main sets up the hardware then hands over to the FreeRTOS kernel
|
// Main sets up the hardware then hands over to the FreeRTOS kernel
|
||||||
@@ -81,9 +79,6 @@ int main(void) {
|
|||||||
osThreadDef(PIDTask, startPIDTask, osPriorityRealtime, 0, 512); //2k
|
osThreadDef(PIDTask, startPIDTask, osPriorityRealtime, 0, 512); //2k
|
||||||
PIDTaskHandle = osThreadCreate(osThread(PIDTask), NULL);
|
PIDTaskHandle = osThreadCreate(osThread(PIDTask), NULL);
|
||||||
if (PCBVersion != 3) {
|
if (PCBVersion != 3) {
|
||||||
/* definition and creation of ROTTask */
|
|
||||||
osThreadDef(ROTTask, startRotationTask, osPriorityLow, 0, 256); //1k
|
|
||||||
ROTTaskHandle = osThreadCreate(osThread(ROTTask), NULL);
|
|
||||||
/* definition and creation of MOVTask */
|
/* definition and creation of MOVTask */
|
||||||
osThreadDef(MOVTask, startMOVTask, osPriorityNormal, 0, 512); //2k
|
osThreadDef(MOVTask, startMOVTask, osPriorityNormal, 0, 512); //2k
|
||||||
MOVTaskHandle = osThreadCreate(osThread(MOVTask), NULL);
|
MOVTaskHandle = osThreadCreate(osThread(MOVTask), NULL);
|
||||||
@@ -96,6 +91,11 @@ int main(void) {
|
|||||||
while (1) {
|
while (1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void printVoltage() {
|
||||||
|
lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) / 10, 2);
|
||||||
|
lcd.drawChar('.');
|
||||||
|
lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) % 10, 1);
|
||||||
|
}
|
||||||
void GUIDelay() {
|
void GUIDelay() {
|
||||||
osDelay(66); // 15Hz
|
osDelay(66); // 15Hz
|
||||||
}
|
}
|
||||||
@@ -221,11 +221,7 @@ static bool checkVoltageForExit() {
|
|||||||
lcd.print(UndervoltageString);
|
lcd.print(UndervoltageString);
|
||||||
lcd.setCursor(0, 8);
|
lcd.setCursor(0, 8);
|
||||||
lcd.print(InputVoltageString);
|
lcd.print(InputVoltageString);
|
||||||
lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) / 10,
|
printVoltage();
|
||||||
2);
|
|
||||||
lcd.drawChar('.');
|
|
||||||
lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) % 10,
|
|
||||||
1);
|
|
||||||
lcd.print("V");
|
lcd.print("V");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -332,56 +328,6 @@ static void gui_solderingTempAdjust() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int gui_showTipTempWarning() {
|
|
||||||
for (;;) {
|
|
||||||
uint16_t tipTemp = tipMeasurementToC(getTipRawTemp(0));
|
|
||||||
lcd.clearScreen();
|
|
||||||
lcd.setCursor(0, 0);
|
|
||||||
if (systemSettings.detailedSoldering) {
|
|
||||||
lcd.setFont(1);
|
|
||||||
lcd.print(WarningAdvancedString);
|
|
||||||
lcd.setCursor(0, 8);
|
|
||||||
lcd.print(WarningTipTempString);
|
|
||||||
|
|
||||||
if (systemSettings.temperatureInF) {
|
|
||||||
lcd.printNumber(tipMeasurementToF(getTipRawTemp(0)), 3);
|
|
||||||
lcd.print("F");
|
|
||||||
} else {
|
|
||||||
lcd.printNumber(tipMeasurementToC(getTipRawTemp(0)), 3);
|
|
||||||
lcd.print("C");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
lcd.setFont(0);
|
|
||||||
lcd.drawArea(0, 0, 24, 16, WarningBlock24);
|
|
||||||
lcd.setCursor(24, 0);
|
|
||||||
// lcd.print(WarningSimpleString);
|
|
||||||
lcd.print(" ");
|
|
||||||
if (systemSettings.temperatureInF) {
|
|
||||||
lcd.printNumber(tipMeasurementToF(getTipRawTemp(0)), 3);
|
|
||||||
lcd.drawSymbol(0);
|
|
||||||
} else {
|
|
||||||
lcd.printNumber(tipMeasurementToC(getTipRawTemp(0)), 3);
|
|
||||||
lcd.drawSymbol(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (systemSettings.coolingTempBlink && tipTemp > 70) {
|
|
||||||
if (xTaskGetTickCount() % 50 < 25)
|
|
||||||
lcd.clearScreen();
|
|
||||||
}
|
|
||||||
lcd.refresh();
|
|
||||||
ButtonState buttons = getButtonState();
|
|
||||||
if (buttons == BUTTON_F_SHORT)
|
|
||||||
return 1;
|
|
||||||
else if (buttons == BUTTON_B_SHORT || buttons == BUTTON_BOTH)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (tipTemp < 50)
|
|
||||||
return 0; //Exit the warning screen
|
|
||||||
|
|
||||||
GUIDelay();
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
static uint16_t min(uint16_t a, uint16_t b) {
|
static uint16_t min(uint16_t a, uint16_t b) {
|
||||||
if (a > b)
|
if (a > b)
|
||||||
return b;
|
return b;
|
||||||
@@ -401,14 +347,15 @@ static int gui_SolderingSleepingMode() {
|
|||||||
if (checkVoltageForExit())
|
if (checkVoltageForExit())
|
||||||
return 1; // return non-zero on error
|
return 1; // return non-zero on error
|
||||||
|
|
||||||
if (systemSettings.temperatureInF)
|
if (systemSettings.temperatureInF) {
|
||||||
currentlyActiveTemperatureTarget = ftoTipMeasurement(
|
currentlyActiveTemperatureTarget = ftoTipMeasurement(
|
||||||
min(systemSettings.SleepTemp,
|
min(systemSettings.SleepTemp,
|
||||||
systemSettings.SolderingTemp));
|
systemSettings.SolderingTemp));
|
||||||
else
|
} else {
|
||||||
currentlyActiveTemperatureTarget = ctoTipMeasurement(
|
currentlyActiveTemperatureTarget = ctoTipMeasurement(
|
||||||
min(systemSettings.SleepTemp,
|
min(systemSettings.SleepTemp,
|
||||||
systemSettings.SolderingTemp));
|
systemSettings.SolderingTemp));
|
||||||
|
}
|
||||||
// draw the lcd
|
// draw the lcd
|
||||||
uint16_t tipTemp;
|
uint16_t tipTemp;
|
||||||
if (systemSettings.temperatureInF)
|
if (systemSettings.temperatureInF)
|
||||||
@@ -430,11 +377,7 @@ static int gui_SolderingSleepingMode() {
|
|||||||
lcd.print("C");
|
lcd.print("C");
|
||||||
|
|
||||||
lcd.print(" ");
|
lcd.print(" ");
|
||||||
lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) / 10,
|
printVoltage();
|
||||||
2);
|
|
||||||
lcd.drawChar('.');
|
|
||||||
lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) % 10,
|
|
||||||
1);
|
|
||||||
lcd.drawChar('V');
|
lcd.drawChar('V');
|
||||||
} else {
|
} else {
|
||||||
lcd.setFont(0);
|
lcd.setFont(0);
|
||||||
@@ -543,11 +486,7 @@ static void gui_solderingMode() {
|
|||||||
lcd.print("C");
|
lcd.print("C");
|
||||||
|
|
||||||
lcd.print(" ");
|
lcd.print(" ");
|
||||||
lcd.printNumber(
|
printVoltage();
|
||||||
getInputVoltageX10(systemSettings.voltageDiv) / 10, 2);
|
|
||||||
lcd.drawChar('.');
|
|
||||||
lcd.printNumber(
|
|
||||||
getInputVoltageX10(systemSettings.voltageDiv) % 10, 1);
|
|
||||||
lcd.drawChar('V');
|
lcd.drawChar('V');
|
||||||
} else {
|
} else {
|
||||||
// We switch the layout direction depending on the orientation of the lcd.
|
// We switch the layout direction depending on the orientation of the lcd.
|
||||||
@@ -632,6 +571,55 @@ static void gui_solderingMode() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void showVersion(void) {
|
||||||
|
uint8_t screen = 0;
|
||||||
|
ButtonState b;
|
||||||
|
for (;;) {
|
||||||
|
lcd.clearScreen(); // Ensure the buffer starts clean
|
||||||
|
lcd.setCursor(0, 0); // Position the cursor at the 0,0 (top left)
|
||||||
|
lcd.setFont(1); // small font
|
||||||
|
lcd.print((char *) "V2.05 PCB"); // Print version number
|
||||||
|
lcd.printNumber(PCBVersion, 1); //Print PCB ID number
|
||||||
|
lcd.setCursor(0, 8); // second line
|
||||||
|
switch (screen) {
|
||||||
|
case 0:
|
||||||
|
lcd.print(__DATE__); // print the compile date
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
lcd.print("Heap: ");
|
||||||
|
lcd.printNumber(xPortGetFreeHeapSize(), 5);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
lcd.print("HWMG: ");
|
||||||
|
lcd.printNumber(uxTaskGetStackHighWaterMark(GUITaskHandle), 5);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
lcd.print("HWMP: ");
|
||||||
|
lcd.printNumber(uxTaskGetStackHighWaterMark(PIDTaskHandle), 5);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
lcd.print("HWMM: ");
|
||||||
|
lcd.printNumber(uxTaskGetStackHighWaterMark(MOVTaskHandle), 5);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 5:
|
||||||
|
lcd.print("Time: ");
|
||||||
|
lcd.printNumber(xTaskGetTickCount() / 100, 5);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
lcd.refresh();
|
||||||
|
b = getButtonState();
|
||||||
|
if (b == BUTTON_B_SHORT)
|
||||||
|
return;
|
||||||
|
else if (b == BUTTON_F_SHORT) {
|
||||||
|
screen++;
|
||||||
|
screen = screen % 6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* StartGUITask function */
|
/* StartGUITask function */
|
||||||
void startGUITask(void const *argument) {
|
void startGUITask(void const *argument) {
|
||||||
i2cDev.FRToSInit();
|
i2cDev.FRToSInit();
|
||||||
@@ -661,7 +649,6 @@ void startGUITask(void const *argument) {
|
|||||||
uint8_t tempWarningState = 0;
|
uint8_t tempWarningState = 0;
|
||||||
bool buttonLockout = false;
|
bool buttonLockout = false;
|
||||||
|
|
||||||
HAL_IWDG_Refresh(&hiwdg);
|
|
||||||
switch (systemSettings.OrientationMode) {
|
switch (systemSettings.OrientationMode) {
|
||||||
case 0:
|
case 0:
|
||||||
lcd.setRotation(false);
|
lcd.setRotation(false);
|
||||||
@@ -685,8 +672,6 @@ void startGUITask(void const *argument) {
|
|||||||
ticks = xTaskGetTickCount(); //make timeout now so we will exit
|
ticks = xTaskGetTickCount(); //make timeout now so we will exit
|
||||||
GUIDelay();
|
GUIDelay();
|
||||||
}
|
}
|
||||||
|
|
||||||
HAL_IWDG_Refresh(&hiwdg);
|
|
||||||
if (systemSettings.autoStartMode) {
|
if (systemSettings.autoStartMode) {
|
||||||
// jump directly to the autostart mode
|
// jump directly to the autostart mode
|
||||||
if (systemSettings.autoStartMode == 1)
|
if (systemSettings.autoStartMode == 1)
|
||||||
@@ -723,18 +708,7 @@ void startGUITask(void const *argument) {
|
|||||||
|
|
||||||
case BUTTON_B_LONG:
|
case BUTTON_B_LONG:
|
||||||
// Show the version information
|
// Show the version information
|
||||||
{
|
showVersion();
|
||||||
lcd.clearScreen(); // Ensure the buffer starts clean
|
|
||||||
lcd.setCursor(0, 0); // Position the cursor at the 0,0 (top left)
|
|
||||||
lcd.setFont(1); // small font
|
|
||||||
lcd.print((char *) "V2.04 PCB"); // Print version number
|
|
||||||
lcd.printNumber(PCBVersion, 1); //Print PCB ID number
|
|
||||||
lcd.setCursor(0, 8); // second line
|
|
||||||
lcd.print(__DATE__); // print the compile date
|
|
||||||
lcd.refresh();
|
|
||||||
waitForButtonPress();
|
|
||||||
lcd.setFont(0); // reset font
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case BUTTON_F_LONG:
|
case BUTTON_F_LONG:
|
||||||
gui_solderingTempAdjust();
|
gui_solderingTempAdjust();
|
||||||
@@ -771,6 +745,7 @@ void startGUITask(void const *argument) {
|
|||||||
lcd.displayOnOff(false); // turn lcd off when no movement
|
lcd.displayOnOff(false); // turn lcd off when no movement
|
||||||
} else
|
} else
|
||||||
lcd.displayOnOff(true); // turn lcd on
|
lcd.displayOnOff(true); // turn lcd on
|
||||||
|
|
||||||
} else
|
} else
|
||||||
lcd.displayOnOff(true); // turn lcd on - disabled motion sleep
|
lcd.displayOnOff(true); // turn lcd on - disabled motion sleep
|
||||||
} else
|
} else
|
||||||
@@ -797,11 +772,7 @@ void startGUITask(void const *argument) {
|
|||||||
}
|
}
|
||||||
lcd.setCursor(0, 8);
|
lcd.setCursor(0, 8);
|
||||||
lcd.print(InputVoltageString);
|
lcd.print(InputVoltageString);
|
||||||
lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) / 10,
|
printVoltage();
|
||||||
2);
|
|
||||||
lcd.drawChar('.');
|
|
||||||
lcd.printNumber(getInputVoltageX10(systemSettings.voltageDiv) % 10,
|
|
||||||
1);
|
|
||||||
lcd.print("V");
|
lcd.print("V");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -858,9 +829,9 @@ void startPIDTask(void const *argument) {
|
|||||||
int32_t kp, ki, kd;
|
int32_t kp, ki, kd;
|
||||||
ki = 50;
|
ki = 50;
|
||||||
kd = 15;
|
kd = 15;
|
||||||
// REMEBER ^^^^ These constants are backwards
|
// REMEBER ^^^^ These constants are backwards
|
||||||
// They act as dividers, so to 'increase' a P term, you make the number
|
// They act as dividers, so to 'increase' a P term, you make the number
|
||||||
// smaller.
|
// smaller.
|
||||||
if (getInputVoltageX10(systemSettings.voltageDiv) < 150) {
|
if (getInputVoltageX10(systemSettings.voltageDiv) < 150) {
|
||||||
//Boot P term if < 15 Volts
|
//Boot P term if < 15 Volts
|
||||||
kp = 30;
|
kp = 30;
|
||||||
@@ -869,62 +840,77 @@ void startPIDTask(void const *argument) {
|
|||||||
const int32_t itermMax = 100;
|
const int32_t itermMax = 100;
|
||||||
pidTaskNotification = xTaskGetCurrentTaskHandle();
|
pidTaskNotification = xTaskGetCurrentTaskHandle();
|
||||||
for (;;) {
|
for (;;) {
|
||||||
ulTaskNotifyTake( pdTRUE, 50); //Wait a max of 50ms
|
if (ulTaskNotifyTake( pdTRUE, 50)) {
|
||||||
//This is a call to block this thread until the ADC does its samples
|
//Wait a max of 50ms
|
||||||
uint16_t rawTemp = getTipRawTemp(1); // get instantaneous reading
|
//This is a call to block this thread until the ADC does its samples
|
||||||
if (currentlyActiveTemperatureTarget) {
|
uint16_t rawTemp = getTipRawTemp(1); // get instantaneous reading
|
||||||
// Compute the PID loop in here
|
if (currentlyActiveTemperatureTarget) {
|
||||||
// Because our values here are quite large for all measurements (0-16k ~=
|
// Compute the PID loop in here
|
||||||
// 33 counts per C)
|
// Because our values here are quite large for all measurements (0-16k ~=
|
||||||
// P I & D are divisors, so inverse logic applies (beware)
|
// 33 counts per C)
|
||||||
|
// P I & D are divisors, so inverse logic applies (beware)
|
||||||
|
|
||||||
// Cap the max set point to 450C
|
// Cap the max set point to 450C
|
||||||
if (currentlyActiveTemperatureTarget > ctoTipMeasurement(450)) {
|
if (currentlyActiveTemperatureTarget > ctoTipMeasurement(450)) {
|
||||||
currentlyActiveTemperatureTarget = ctoTipMeasurement(450);
|
currentlyActiveTemperatureTarget = ctoTipMeasurement(450);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t rawTempError = currentlyActiveTemperatureTarget
|
||||||
|
- rawTemp;
|
||||||
|
int32_t ierror = (rawTempError / ki);
|
||||||
|
integralCount += ierror;
|
||||||
|
if (integralCount > (itermMax / 2))
|
||||||
|
integralCount = itermMax / 2; // prevent too much lead
|
||||||
|
else if (integralCount < -itermMax)
|
||||||
|
integralCount = itermMax;
|
||||||
|
|
||||||
|
int32_t dInput = (rawTemp - derivativeLastValue);
|
||||||
|
|
||||||
|
/*Compute PID Output*/
|
||||||
|
int32_t output = (rawTempError / kp);
|
||||||
|
if (ki)
|
||||||
|
output += integralCount;
|
||||||
|
if (kd)
|
||||||
|
output -= (dInput / kd);
|
||||||
|
|
||||||
|
if (output > 100) {
|
||||||
|
output = 100; // saturate
|
||||||
|
} else if (output < 0) {
|
||||||
|
output = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*if (currentlyActiveTemperatureTarget < rawTemp) {
|
||||||
|
output = 0;
|
||||||
|
}*/
|
||||||
|
setTipPWM(output);
|
||||||
|
derivativeLastValue = rawTemp; // store for next loop
|
||||||
|
|
||||||
|
} else {
|
||||||
|
setTipPWM(0); // disable the output driver if the output is set to be off
|
||||||
|
integralCount = 0;
|
||||||
|
derivativeLastValue = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t rawTempError = currentlyActiveTemperatureTarget - rawTemp;
|
HAL_IWDG_Refresh(&hiwdg);
|
||||||
int32_t ierror = (rawTempError / ki);
|
|
||||||
integralCount += ierror;
|
|
||||||
if (integralCount > (itermMax / 2))
|
|
||||||
integralCount = itermMax / 2; // prevent too much lead
|
|
||||||
else if (integralCount < -itermMax)
|
|
||||||
integralCount = itermMax;
|
|
||||||
|
|
||||||
int32_t dInput = (rawTemp - derivativeLastValue);
|
|
||||||
|
|
||||||
/*Compute PID Output*/
|
|
||||||
int32_t output = (rawTempError / kp);
|
|
||||||
if (ki)
|
|
||||||
output += integralCount;
|
|
||||||
if (kd)
|
|
||||||
output -= (dInput / kd);
|
|
||||||
|
|
||||||
if (output > 100) {
|
|
||||||
output = 100; // saturate
|
|
||||||
} else if (output < 0) {
|
|
||||||
output = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*if (currentlyActiveTemperatureTarget < rawTemp) {
|
|
||||||
output = 0;
|
|
||||||
}*/
|
|
||||||
setTipPWM(output);
|
|
||||||
derivativeLastValue = rawTemp; // store for next loop
|
|
||||||
|
|
||||||
} else {
|
|
||||||
setTipPWM(0); // disable the output driver if the output is set to be off
|
|
||||||
integralCount = 0;
|
|
||||||
derivativeLastValue = 0;
|
|
||||||
osDelay(100); //sleep for a bit longer
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HAL_IWDG_Refresh(&hiwdg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#define MOVFilter 8
|
#define MOVFilter 8
|
||||||
void startMOVTask(void const *argument) {
|
void startMOVTask(void const *argument) {
|
||||||
osDelay(250); // wait for accelerometer to stabilize
|
osDelay(250); // wait for accelerometer to stabilize
|
||||||
|
switch (systemSettings.OrientationMode) {
|
||||||
|
case 0:
|
||||||
|
lcd.setRotation(false);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
lcd.setRotation(true);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
lcd.setRotation(false);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
lastMovementTime = 0;
|
lastMovementTime = 0;
|
||||||
int16_t datax[MOVFilter];
|
int16_t datax[MOVFilter];
|
||||||
int16_t datay[MOVFilter];
|
int16_t datay[MOVFilter];
|
||||||
@@ -940,20 +926,29 @@ void startMOVTask(void const *argument) {
|
|||||||
#if ACCELDEBUG
|
#if ACCELDEBUG
|
||||||
uint32_t max = 0;
|
uint32_t max = 0;
|
||||||
#endif
|
#endif
|
||||||
|
uint8_t rotation = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int32_t threshold = 1500 + (9 * 200);
|
int32_t threshold = 1500 + (9 * 200);
|
||||||
threshold -= systemSettings.sensitivity * 200; // 200 is the step size
|
threshold -= systemSettings.sensitivity * 200; // 200 is the step size
|
||||||
if (PCBVersion == 2)
|
|
||||||
accel2.getAxisReadings(&tx, &ty, &tz);
|
|
||||||
else if (PCBVersion == 1)
|
|
||||||
accel.getAxisReadings(&tx, &ty, &tz);
|
|
||||||
|
|
||||||
|
if (PCBVersion == 2) {
|
||||||
|
accel2.getAxisReadings(&tx, &ty, &tz);
|
||||||
|
rotation = accel2.getOrientation();
|
||||||
|
} else if (PCBVersion == 1) {
|
||||||
|
accel.getAxisReadings(&tx, &ty, &tz);
|
||||||
|
rotation = accel.getOrientation();
|
||||||
|
}
|
||||||
|
if (systemSettings.OrientationMode == 2) {
|
||||||
|
if (rotation != 0) {
|
||||||
|
lcd.setRotation(rotation == 2); // link the data through
|
||||||
|
}
|
||||||
|
}
|
||||||
datax[currentPointer] = (int32_t) tx;
|
datax[currentPointer] = (int32_t) tx;
|
||||||
datay[currentPointer] = (int32_t) ty;
|
datay[currentPointer] = (int32_t) ty;
|
||||||
dataz[currentPointer] = (int32_t) tz;
|
dataz[currentPointer] = (int32_t) tz;
|
||||||
currentPointer = (currentPointer + 1) % MOVFilter;
|
currentPointer = (currentPointer + 1) % MOVFilter;
|
||||||
#if ACCELDEBUG
|
#if ACCELDEBUG
|
||||||
|
|
||||||
// Debug for Accel
|
// Debug for Accel
|
||||||
|
|
||||||
avgx = avgy = avgz = 0;
|
avgx = avgy = avgz = 0;
|
||||||
@@ -995,6 +990,7 @@ void startMOVTask(void const *argument) {
|
|||||||
|
|
||||||
// So now we have averages, we want to look if these are different by more
|
// So now we have averages, we want to look if these are different by more
|
||||||
// than the threshold
|
// than the threshold
|
||||||
|
//Sum the deltas
|
||||||
int32_t error = (abs(avgx - tx) + abs(avgy - ty) + abs(avgz - tz));
|
int32_t error = (abs(avgx - tx) + abs(avgy - ty) + abs(avgz - tz));
|
||||||
// If error has occurred then we update the tick timer
|
// If error has occurred then we update the tick timer
|
||||||
if (error > threshold) {
|
if (error > threshold) {
|
||||||
@@ -1004,52 +1000,13 @@ void startMOVTask(void const *argument) {
|
|||||||
osDelay(100); // Slow down update rate
|
osDelay(100); // Slow down update rate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* StartRotationTask function */
|
|
||||||
void startRotationTask(void const *argument) {
|
|
||||||
/*
|
|
||||||
* This task is used to manage rotation of the LCD screen & button re-mapping
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
switch (systemSettings.OrientationMode) {
|
|
||||||
case 0:
|
|
||||||
lcd.setRotation(false);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
lcd.setRotation(true);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
lcd.setRotation(false);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
osDelay(250); // wait for accel to stabilize
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
|
|
||||||
// a rotation event has occurred
|
|
||||||
uint8_t rotation = 0;
|
|
||||||
if (PCBVersion == 2) {
|
|
||||||
rotation = accel2.getOrientation();
|
|
||||||
} else if (PCBVersion == 1) {
|
|
||||||
rotation = accel.getOrientation();
|
|
||||||
}
|
|
||||||
if (systemSettings.OrientationMode == 2) {
|
|
||||||
if (rotation != 0) {
|
|
||||||
lcd.setRotation(rotation == 2); // link the data through
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
osDelay(500);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#define FLASH_LOGOADDR \
|
#define FLASH_LOGOADDR \
|
||||||
(0x8000000 | 0xF800) /*second last page of flash set aside for logo image*/
|
(0x8000000 | 0xF800) /*second last page of flash set aside for logo image*/
|
||||||
|
|
||||||
bool showBootLogoIfavailable() {
|
bool showBootLogoIfavailable() {
|
||||||
// check if the header is there (0xAA,0x55,0xF0,0x0D)
|
// check if the header is there (0xAA,0x55,0xF0,0x0D)
|
||||||
// If so display logo
|
// If so display logo
|
||||||
uint16_t temp[98];
|
uint16_t temp[98];
|
||||||
|
|
||||||
for (uint8_t i = 0; i < (98); i++) {
|
for (uint8_t i = 0; i < (98); i++) {
|
||||||
@@ -1109,3 +1066,9 @@ void HAL_I2C_AbortCpltCallback(I2C_HandleTypeDef *hi2c) {
|
|||||||
void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c) {
|
void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c) {
|
||||||
i2cDev.CpltCallback();
|
i2cDev.CpltCallback();
|
||||||
}
|
}
|
||||||
|
void vApplicationStackOverflowHook( xTaskHandle *pxTask,
|
||||||
|
signed portCHAR *pcTaskName) {
|
||||||
|
//We dont have a good way to handle a stack overflow at this point in time
|
||||||
|
NVIC_SystemReset();
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -28,9 +28,9 @@ void HAL_MspInit(void) {
|
|||||||
|
|
||||||
/**NOJTAG: JTAG-DP Disabled and SW-DP Enabled
|
/**NOJTAG: JTAG-DP Disabled and SW-DP Enabled
|
||||||
*/
|
*/
|
||||||
__HAL_AFIO_REMAP_SWJ_NOJTAG()
|
//__HAL_AFIO_REMAP_SWJ_NOJTAG()
|
||||||
;
|
//;
|
||||||
// __HAL_AFIO_REMAP_SWJ_DISABLE(); /*Disable swd for debug io use*/
|
__HAL_AFIO_REMAP_SWJ_DISABLE(); /*Disable swd for debug io use*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) {
|
|||||||
__HAL_LINKDMA(hadc, DMA_Handle, hdma_adc1);
|
__HAL_LINKDMA(hadc, DMA_Handle, hdma_adc1);
|
||||||
|
|
||||||
/* ADC1 interrupt Init */
|
/* ADC1 interrupt Init */
|
||||||
HAL_NVIC_SetPriority(ADC1_2_IRQn, 5, 0);
|
HAL_NVIC_SetPriority(ADC1_2_IRQn, 15, 0);
|
||||||
HAL_NVIC_EnableIRQ(ADC1_2_IRQn);
|
HAL_NVIC_EnableIRQ(ADC1_2_IRQn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,9 +118,9 @@ void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c) {
|
|||||||
__HAL_LINKDMA(hi2c, hdmatx, hdma_i2c1_tx);
|
__HAL_LINKDMA(hi2c, hdmatx, hdma_i2c1_tx);
|
||||||
|
|
||||||
/* I2C1 interrupt Init */
|
/* I2C1 interrupt Init */
|
||||||
HAL_NVIC_SetPriority(I2C1_EV_IRQn, 5, 0);
|
HAL_NVIC_SetPriority(I2C1_EV_IRQn, 15, 0);
|
||||||
HAL_NVIC_EnableIRQ(I2C1_EV_IRQn);
|
HAL_NVIC_EnableIRQ(I2C1_EV_IRQn);
|
||||||
HAL_NVIC_SetPriority(I2C1_ER_IRQn, 5, 0);
|
HAL_NVIC_SetPriority(I2C1_ER_IRQn, 15, 0);
|
||||||
HAL_NVIC_EnableIRQ(I2C1_ER_IRQn);
|
HAL_NVIC_EnableIRQ(I2C1_ER_IRQn);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
extern TIM_HandleTypeDef htim1; //used for the systick
|
extern TIM_HandleTypeDef htim1; //used for the systick
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/* Cortex-M3 Processor Interruption and Exception Handlers */
|
/* Cortex-M3 Processor Interruption and Exception Handlers */
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
@@ -55,8 +54,6 @@ void SysTick_Handler(void) {
|
|||||||
void DMA1_Channel1_IRQHandler(void) {
|
void DMA1_Channel1_IRQHandler(void) {
|
||||||
HAL_DMA_IRQHandler(&hdma_adc1);
|
HAL_DMA_IRQHandler(&hdma_adc1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//ADC interrupt used for DMA
|
//ADC interrupt used for DMA
|
||||||
void ADC1_2_IRQHandler(void) {
|
void ADC1_2_IRQHandler(void) {
|
||||||
HAL_ADC_IRQHandler(&hadc1);
|
HAL_ADC_IRQHandler(&hadc1);
|
||||||
@@ -65,7 +62,6 @@ void ADC1_2_IRQHandler(void) {
|
|||||||
//Timer 1 has overflowed, used for HAL ticks
|
//Timer 1 has overflowed, used for HAL ticks
|
||||||
void TIM1_UP_IRQHandler(void) {
|
void TIM1_UP_IRQHandler(void) {
|
||||||
HAL_TIM_IRQHandler(&htim1);
|
HAL_TIM_IRQHandler(&htim1);
|
||||||
|
|
||||||
}
|
}
|
||||||
//Timer 3 is used for the PWM output to the tip
|
//Timer 3 is used for the PWM output to the tip
|
||||||
void TIM3_IRQHandler(void) {
|
void TIM3_IRQHandler(void) {
|
||||||
@@ -76,15 +72,6 @@ void TIM3_IRQHandler(void) {
|
|||||||
void TIM2_IRQHandler(void) {
|
void TIM2_IRQHandler(void) {
|
||||||
HAL_TIM_IRQHandler(&htim2);
|
HAL_TIM_IRQHandler(&htim2);
|
||||||
}
|
}
|
||||||
//EXTI 3 is triggered via the accelerometer on orientation change
|
|
||||||
void EXTI3_IRQHandler(void) {
|
|
||||||
|
|
||||||
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_3);
|
|
||||||
}
|
|
||||||
//EXTI 5 is triggered via the accelerometer on movement
|
|
||||||
void EXTI9_5_IRQHandler(void) {
|
|
||||||
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_5);
|
|
||||||
}
|
|
||||||
|
|
||||||
void I2C1_EV_IRQHandler(void) {
|
void I2C1_EV_IRQHandler(void) {
|
||||||
HAL_I2C_EV_IRQHandler(&hi2c1);
|
HAL_I2C_EV_IRQHandler(&hi2c1);
|
||||||
@@ -93,12 +80,10 @@ void I2C1_ER_IRQHandler(void) {
|
|||||||
HAL_I2C_ER_IRQHandler(&hi2c1);
|
HAL_I2C_ER_IRQHandler(&hi2c1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DMA1_Channel6_IRQHandler(void)
|
void DMA1_Channel6_IRQHandler(void) {
|
||||||
{
|
HAL_DMA_IRQHandler(&hdma_i2c1_tx);
|
||||||
HAL_DMA_IRQHandler(&hdma_i2c1_tx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DMA1_Channel7_IRQHandler(void)
|
void DMA1_Channel7_IRQHandler(void) {
|
||||||
{
|
HAL_DMA_IRQHandler(&hdma_i2c1_rx);
|
||||||
HAL_DMA_IRQHandler(&hdma_i2c1_rx);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user