wip:
This commit is contained in:
@@ -47,17 +47,18 @@ zh_avr_pcf8574_handle_t lcd_handle = {0};
|
||||
zh_avr_encoder_handle_t power_encoder_handle = {0};
|
||||
zh_avr_encoder_handle_t component_encoder_handle = {0};
|
||||
|
||||
volatile static bool is_work = false; // Work status.
|
||||
volatile static bool is_dmm = false; // DMM using status.
|
||||
volatile static bool is_fix = false; // FIX button status.
|
||||
static uint8_t used_channels = 0; // Permitted channels status. Depends of the selected component.
|
||||
static bool is_initialized = false; // Normal loading status.
|
||||
volatile static bool is_work = false; // Work status.
|
||||
volatile static bool is_dmm = false; // DMM using status.
|
||||
volatile static bool is_fix = false; // FIX button status.
|
||||
volatile static uint8_t used_channels = 0; // Permitted channels. Depends of the selected component.
|
||||
volatile static bool is_initialized = false; // Normal loading status.
|
||||
|
||||
int main(void)
|
||||
{
|
||||
//** Encoders init **/
|
||||
zh_avr_encoder_init_config_t encoder_init_config = ZH_AVR_ENCODER_INIT_CONFIG_DEFAULT();
|
||||
encoder_init_config.stack_size = 150;
|
||||
encoder_init_config.stack_size = 150; // Check.
|
||||
encoder_init_config.queue_size = 10; // Check.
|
||||
encoder_init_config.gpio_port = AVR_PORTC;
|
||||
encoder_init_config.a_gpio_number = PORTC0;
|
||||
encoder_init_config.b_gpio_number = PORTC1;
|
||||
@@ -89,20 +90,18 @@ int main(void)
|
||||
UCSR0B = (1 << RXEN0) | (1 << TXEN0);
|
||||
UCSR0C = (1 << UCSZ01) | (1 << UCSZ00);
|
||||
stdout = &uart;
|
||||
xTaskCreate(system_setup_task, "system_setup", 120, NULL, 4, &system_setup_task_handle);
|
||||
#else
|
||||
xTaskCreate(system_setup_task, NULL, 150, NULL, tskIDLE_PRIORITY, NULL);
|
||||
#endif
|
||||
xTaskCreate(system_setup_task, "system_setup", 120, NULL, tskIDLE_PRIORITY, &system_setup_task_handle);
|
||||
vTaskStartScheduler();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void system_setup_task(void *pvParameters)
|
||||
{
|
||||
char text_buffer[17];
|
||||
char text_buffer[LCD_TEXT_BUFFER];
|
||||
zh_avr_i2c_master_init(false);
|
||||
zh_avr_pcf8574_init_config_t pcf8574_init_config = ZH_AVR_PCF8574_INIT_CONFIG_DEFAULT();
|
||||
pcf8574_init_config.stack_size = 150;
|
||||
pcf8574_init_config.stack_size = 150; // Check.
|
||||
//** LED 1 extender init. All LED off. DMM red on. FIX blue on. **/
|
||||
pcf8574_init_config.i2c_address = LED1_I2C_ADDRESS;
|
||||
zh_avr_pcf8574_init(&pcf8574_init_config, &led1_handle);
|
||||
@@ -114,7 +113,7 @@ void system_setup_task(void *pvParameters)
|
||||
//** RELAY extender init. All relay off. DMM relay on. **/
|
||||
pcf8574_init_config.i2c_address = RELAY_I2C_ADDRESS;
|
||||
zh_avr_pcf8574_init(&pcf8574_init_config, &relay_handle);
|
||||
zh_avr_pcf8574_write(&relay_handle, 0x02);
|
||||
zh_avr_pcf8574_write(&relay_handle, 0xFD);
|
||||
//** LCD init **/
|
||||
pcf8574_init_config.i2c_address = LCD_I2C_ADDRESS;
|
||||
zh_avr_pcf8574_init(&pcf8574_init_config, &lcd_handle);
|
||||
@@ -163,7 +162,6 @@ void system_setup_task(void *pvParameters)
|
||||
strcpy_P(text_buffer, text_component);
|
||||
zh_avr_160x_print_char(&lcd_handle, text_buffer);
|
||||
//**"ANY" component setup after loading **/
|
||||
used_channels = component_channel[0];
|
||||
component_setup_function(0);
|
||||
is_initialized = true;
|
||||
vTaskDelete(NULL);
|
||||
@@ -172,7 +170,7 @@ void system_setup_task(void *pvParameters)
|
||||
#ifdef DEBUG
|
||||
void vApplicationStackOverflowHook(TaskHandle_t xTask, char *pcTaskName)
|
||||
{
|
||||
printf("Task %s Stack Owerflow.\n", pcTaskName);
|
||||
printf("Task %s Stack Overflow.\n", pcTaskName);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -354,7 +352,8 @@ ISR(PCINT2_vect)
|
||||
|
||||
void component_setup_function(uint8_t component)
|
||||
{
|
||||
char text_buffer[17];
|
||||
char text_buffer[LCD_TEXT_BUFFER];
|
||||
used_channels = component_channel[component];
|
||||
zh_avr_160x_set_cursor(&lcd_handle, 1, 10);
|
||||
strcpy_P(text_buffer, component_cmm[component]);
|
||||
zh_avr_160x_print_char(&lcd_handle, text_buffer);
|
||||
@@ -364,8 +363,8 @@ void component_setup_function(uint8_t component)
|
||||
zh_avr_160x_set_cursor(&lcd_handle, 3, 0);
|
||||
strcpy_P(text_buffer, component_line_2[component]);
|
||||
zh_avr_160x_print_char(&lcd_handle, text_buffer);
|
||||
// zh_avr_pcf8574_write(&led1_handle, 0xF0);
|
||||
// zh_avr_pcf8574_write(&led2_handle, 0x0F);
|
||||
zh_avr_pcf8574_write(&led1_handle, (is_dmm == true) ? (0xF8 & (1 << DMM_LED_GREEN)) : 0xF8 & (1 << DMM_LED_RED));
|
||||
zh_avr_pcf8574_write(&led2_handle, 0x0F);
|
||||
if ((used_channels & (1 << CHANNEL1)) == CHANNEL1)
|
||||
{
|
||||
zh_avr_pcf8574_write_gpio(&led1_handle, NUM1_LED_BLUE, LED_ON);
|
||||
|
||||
@@ -8,8 +8,10 @@
|
||||
#define LED_OFF HIGH
|
||||
#define LED_ON LOW
|
||||
|
||||
#define RELAY_OFF LOW
|
||||
#define RELAY_ON HIGH
|
||||
#define RELAY_OFF HIGH
|
||||
#define RELAY_ON LOW
|
||||
|
||||
#define LCD_TEXT_BUFFER 16
|
||||
|
||||
#define BUTTON_I2C_ADDRESS 0x27 // U5.
|
||||
#define LED1_I2C_ADDRESS 0x25 // U6.
|
||||
|
||||
Reference in New Issue
Block a user