8 Commits

Author SHA1 Message Date
hasslesstech 368c530602 [main] fix: cast wrongly converted integer back into the pointer to remove warning 2025-04-14 20:20:57 +03:00
hasslesstech cad8fe1186 [main] enhancement: remove delay between running tests 2025-04-14 20:18:06 +03:00
hasslesstech 3e38106f3d [PCA9685] remove OUT ENABLED label as it is no longer used in interactive tests 2025-04-14 20:17:07 +03:00
hasslesstech 8d119b4c14 add new UI for testing phase, update modules to indicate success or failure in the return value 2025-04-14 19:33:13 +03:00
hasslesstech ae050ce8c1 record change in .cproject which seems impossible to revert 2025-04-14 18:31:36 +03:00
hasslesstech 7bae3f0989 [main] add simple navigation between test reports 2025-04-14 18:31:36 +03:00
hasslesstech ab263f7948 [lcd] fix: add display_load prototype 2025-04-14 18:31:36 +03:00
hasslesstech 1ac6300e02 [lcd] add support for operating on virtual framebuffers
Current implementation contains full support for:
- transparent switching between direct and framebuffer rendering modes
- writing characters to framebuffers
- loading frame from memory to physical display

As well as partial support for instruction writes including:
- resetting the display (clears memory, sets cursor at 0:0, switches to increment mode)
- switching between increment/decrement modes
- setting cursor position
2025-04-14 18:31:36 +03:00
4 changed files with 164 additions and 47 deletions
-2
View File
@@ -40,8 +40,6 @@ int PCA9685_run_test(void)
display_write_data_seq("/5 ");
switch (op_result) {
case HAL_OK:
break;
case HAL_ERROR:
display_write_data_seq("ERROR");
break;
-6
View File
@@ -136,12 +136,6 @@ static void display_write_data_byte_direct(uint8_t code)
static void display_write_data_byte_framebuffer(uint8_t code)
{
if (display_current_frame >= DISPLAY_FRAMES_AVAILABLE)
return;
if (((int) des.cursor_offset >= 32) || ((int) des.cursor_offset < 0))
return;
display_framebuffer[16*2*display_current_frame + des.cursor_offset] = (char) code;
des.cursor_offset += des.next ? -1 : 1;
}
+162 -37
View File
@@ -46,17 +46,6 @@
#define WAIT_UNTIL_CB_PRESSED while (!HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_0) && HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_8))
#define WAIT_UNTIL_CB_RELEASED while (HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_0) || !HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_8))
#define UB (GPIOA->IDR & GPIO_PIN_0)
#define SWT1 !(GPIOC->IDR & GPIO_PIN_11)
#define SWT2 !(GPIOA->IDR & GPIO_PIN_15)
#define SWT3 !(GPIOC->IDR & GPIO_PIN_9)
#define SWT4 !(GPIOC->IDR & GPIO_PIN_6)
#define SWT5 !(GPIOC->IDR & GPIO_PIN_8)
#define WAIT_UNTIL_ALL_BUTTONS_RELEASED do {} while ( UB || SWT1 || SWT2 || SWT3 || SWT4 || SWT5 )
#define LEN(x) ( sizeof(x) / sizeof((x)[0]) )
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
@@ -79,19 +68,22 @@ extern size_t display_current_frame;
/* USER CODE BEGIN PV */
static const int ((*executors[])(void)) = {
int ((*executors[])(void)) = {
DNI_show_celsius,
DNI_show_fahrenheit,
PCA9685_run_test,
EEPROM_24AA02E48_run_test,
CS43L22_run_test,
SST25VF016B_run_test,
LIS302DL_run_test,
LIS302DL_run_test_dynamic,
MP45DT02_run_test,
LSM9DS1_test_accel,
LSM9DS1_test_magnet
};
static const void ((*cleanup_functions[])(void)) = {
void ((*cleanup_functions[])(void)) = {
NULL,
NULL,
PCA9685_cleanup,
NULL,
@@ -99,10 +91,29 @@ static const void ((*cleanup_functions[])(void)) = {
NULL,
NULL,
NULL,
NULL,
LSM9DS1_cleanup_accel,
NULL
};
int delay_between_runs[] = {
250,
250,
-1,
-1,
-1,
-1,
-1,
200,
-1,
-1,
-1
};
size_t current_executor_id = 0;
size_t buttons_interrupt_enabled;
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
@@ -120,7 +131,67 @@ static void MX_I2S2_Init(void);
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
static void button_init_and_test(void)
void switch_to_next_test(void)
{
current_executor_id += 1;
current_executor_id %= 11;
}
void buttons_switch_to_interrupt(void)
{
// save current executor ID
size_t tmp = current_executor_id;
// configure user button
GPIO_InitTypeDef GPIO_InitStruct = {0};
GPIO_InitStruct.Pin = GPIO_PIN_0;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
HAL_NVIC_SetPriority(EXTI0_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(EXTI0_IRQn);
// configure SW5 (alternative advancing method)
GPIO_InitStruct.Pin = GPIO_PIN_8;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
HAL_NVIC_SetPriority(EXTI9_5_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(EXTI9_5_IRQn);
// restore current executor ID
current_executor_id = tmp;
// set interrupt mode flag
buttons_interrupt_enabled = 1;
}
void buttons_switch_to_input(void)
{
// configure user button
GPIO_InitTypeDef GPIO_InitStruct = {0};
GPIO_InitStruct.Pin = GPIO_PIN_0;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
HAL_NVIC_DisableIRQ(EXTI0_IRQn);
// configure SW5 (alternative input method)
GPIO_InitStruct.Pin = GPIO_PIN_8;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
HAL_NVIC_DisableIRQ(EXTI9_5_IRQn);
// clear interrupt mode flag
buttons_interrupt_enabled = 0;
}
void button_init_and_test(void)
{
// letting the buttons be tested
display_write_data_seq("Fill any bar:");
@@ -130,11 +201,11 @@ static void button_init_and_test(void)
size_t pressed_elements;
uint32_t sw_button_locations[5][2] = {
{(uint32_t) GPIOC, (uint32_t) GPIO_PIN_11},
{(uint32_t) GPIOA, (uint32_t) GPIO_PIN_15},
{(uint32_t) GPIOC, (uint32_t) GPIO_PIN_9},
{(uint32_t) GPIOC, (uint32_t) GPIO_PIN_6},
{(uint32_t) GPIOC, (uint32_t) GPIO_PIN_8}
{GPIOC, GPIO_PIN_11},
{GPIOA, GPIO_PIN_15},
{GPIOC, GPIO_PIN_9},
{GPIOC, GPIO_PIN_6},
{GPIOC, GPIO_PIN_8}
};
do {
@@ -172,16 +243,16 @@ static void button_init_and_test(void)
display_write_data_seq("Release buttons");
GPIOD->ODR = 0x1000;
HAL_Delay(300);
HAL_Delay(500);
GPIOD->ODR = 0x2000;
HAL_Delay(300);
HAL_Delay(500);
GPIOD->ODR = 0x4000;
HAL_Delay(300);
HAL_Delay(500);
GPIOD->ODR = 0x8000;
HAL_Delay(300);
HAL_Delay(500);
// waiting for all buttons to be released
WAIT_UNTIL_ALL_BUTTONS_RELEASED;
// waiting for control buttons to be released
WAIT_UNTIL_CB_RELEASED;
GPIOD->ODR = 0x0000;
HAL_Delay(200);
}
@@ -223,6 +294,7 @@ int main(void)
MX_TIM2_Init();
MX_I2S2_Init();
/* USER CODE BEGIN 2 */
buttons_interrupt_enabled = 0;
HAL_TIM_Base_Start(&htim2);
TIM2->CNT = 0;
@@ -238,7 +310,9 @@ int main(void)
size_t successful_tests = 0;
size_t failed_tests = 0;
for (display_current_frame = 1; display_current_frame < LEN(executors)+1; display_current_frame++)
//display_to_framebuffer();
for (display_current_frame = 1; display_current_frame < 12; display_current_frame++)
{
DISPLAY_CLEAR;
display_write_data_seq("Testing...");
@@ -287,43 +361,94 @@ int main(void)
display_to_direct();
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
if (buttons_interrupt_enabled)
buttons_switch_to_input();
while (1) {
WAIT_UNTIL_ALL_BUTTONS_RELEASED;
// wait until all buttons are released
while (
(GPIOA->IDR & GPIO_PIN_0) ||
!(GPIOC->IDR & GPIO_PIN_11) ||
!(GPIOC->IDR & GPIO_PIN_8) ||
!(GPIOC->IDR & GPIO_PIN_9) ||
!(GPIOC->IDR & GPIO_PIN_6) ||
!(GPIOA->IDR & GPIO_PIN_15)
) { asm("nop"); }
display_load(display_current_frame);
while (1) {
// go to next report
if (UB || SWT1 || SWT5) {
if (
(GPIOA->IDR & GPIO_PIN_0) ||
!(GPIOC->IDR & GPIO_PIN_11) ||
!(GPIOC->IDR & GPIO_PIN_8)
) {
display_current_frame += 1;
display_current_frame %= LEN(executors)+1;
display_current_frame %= 12;
break;
}
// go to previous report
else if (SWT3 || SWT4) {
else if (
!(GPIOC->IDR & GPIO_PIN_9) ||
!(GPIOC->IDR & GPIO_PIN_6)
) {
display_current_frame -= 1;
if ((int) display_current_frame == -1)
display_current_frame = LEN(executors);
if (display_current_frame == 0xFFFFFFFFU)
display_current_frame = 11;
break;
}
// return to summary frame
else if (SWT2) {
else if (
!(GPIOA->IDR & GPIO_PIN_15)
) {
display_current_frame = 0;
break;
}
}
}
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
/*
while (1)
{
if (delay_between_runs[current_executor_id] == -1 && buttons_interrupt_enabled)
buttons_switch_to_input();
else if (delay_between_runs[current_executor_id] != -1 && !buttons_interrupt_enabled)
buttons_switch_to_interrupt();
executors[current_executor_id]();
if (delay_between_runs[current_executor_id] == -1) {
WAIT_UNTIL_CB_PRESSED;
HAL_Delay(150);
GPIOD->BSRR = 0x1000;
WAIT_UNTIL_CB_RELEASED;
HAL_Delay(150);
GPIOD->BSRR = 0x1000 << 16;
if (cleanup_functions[current_executor_id])
cleanup_functions[current_executor_id]();
switch_to_next_test();
} else {
HAL_Delay(delay_between_runs[current_executor_id]);
}
*/
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
//}
/* USER CODE END 3 */
}
+2 -2
View File
@@ -204,7 +204,7 @@ void EXTI0_IRQHandler(void)
{
GPIOD->ODR = 0x1000;
//switch_to_next_test();
switch_to_next_test();
for (int i = 300000; i > 0; i--) asm("nop");
@@ -217,7 +217,7 @@ void EXTI9_5_IRQHandler(void)
{
GPIOD->ODR = 0x1000;
//switch_to_next_test();
switch_to_next_test();
for (int i = 300000; i > 0; i--) asm("nop");