This commit is contained in:
2025-09-29 15:45:54 +03:00
parent 5158538e29
commit a3b23eeeba
2 changed files with 97 additions and 56 deletions

View File

@@ -8,45 +8,11 @@
#define DEBUG #define DEBUG
// const component_t component[] = {
// {"ANY ", "1:RED 2:GREEN", "3:BLUE 4:WHITE", 0b0001111},
// {"334230", "RED", "", 0x8},
// {"334303", "RED", "", 0x8},
// {"334711", "RED", "", 0x8},
// {"334612", "1:400W 2:600W ", " ", 0xC},
// };
const char component_1_cmm[] PROGMEM = "ANY ";
const char component_2_cmm[] PROGMEM = "334230";
const char component_3_cmm[] PROGMEM = "334303";
const char component_4_cmm[] PROGMEM = "334711";
const char component_5_cmm[] PROGMEM = "334612";
const char *component_cmm[] = {component_1_cmm, component_2_cmm, component_3_cmm, component_4_cmm, component_5_cmm}; const char *component_cmm[] = {component_1_cmm, component_2_cmm, component_3_cmm, component_4_cmm, component_5_cmm};
const char component_1_line_1[] PROGMEM = "1:RED 2:GREEN";
const char component_1_line_2[] PROGMEM = "3:BLUE 4:WHITE";
const char component_2_line_1[] PROGMEM = "1:RED 2: ";
const char component_2_line_2[] PROGMEM = "3: 4: ";
const char component_3_line_1[] PROGMEM = "1:RED 2: ";
const char component_3_line_2[] PROGMEM = "3: 4: ";
const char component_4_line_1[] PROGMEM = "1:RED 2: ";
const char component_4_line_2[] PROGMEM = "3: 4: ";
const char component_5_line_1[] PROGMEM = "1:400W 2:600W ";
const char component_5_line_2[] PROGMEM = "3: 4: ";
const char *component_line_1[] = {component_1_line_1, component_2_line_1, component_3_line_1, component_4_line_1, component_5_line_1}; const char *component_line_1[] = {component_1_line_1, component_2_line_1, component_3_line_1, component_4_line_1, component_5_line_1};
const char *component_line_2[] = {component_1_line_2, component_2_line_2, component_3_line_2, component_4_line_2, component_5_line_2}; const char *component_line_2[] = {component_1_line_2, component_2_line_2, component_3_line_2, component_4_line_2, component_5_line_2};
const uint8_t component_channel[] = {0x0F, 0x08, 0x08, 0x08, 0x0C}; const uint8_t component_channel[] = {0x0F, 0x08, 0x08, 0x08, 0x0C};
const char text_company[] PROGMEM = "LLC AEROTECH";
const char text_model[] PROGMEM = "ATE0003.000.000";
const char text_firmware[] PROGMEM = "Firmware v1.0.0";
const char text_loading[] PROGMEM = "Loading:";
const char text_ac_power[] PROGMEM = "AC POWER: ";
const char text_component[] PROGMEM = "COMPONENT: ";
#ifdef DEBUG #ifdef DEBUG
#define BAUD_RATE 9600 #define BAUD_RATE 9600
#define BAUD_PRESCALE (F_CPU / 16 / BAUD_RATE - 1) #define BAUD_PRESCALE (F_CPU / 16 / BAUD_RATE - 1)
@@ -81,7 +47,7 @@ zh_avr_encoder_handle_t component_encoder_handle = {0};
volatile static bool is_work = false; // Work status. volatile static bool is_work = false; // Work status.
volatile static bool is_dmm = false; // DMM using status. volatile static bool is_dmm = false; // DMM using status.
volatile static bool is_fix = false; // FIX button status. volatile static bool is_fix = false; // FIX button status.
static uint8_t current_channels = 0; // Permitted channels status. Depends of the selected component. static uint8_t used_channels = 0; // Permitted channels status. Depends of the selected component.
static bool is_initialized = false; // Normal loading status. static bool is_initialized = false; // Normal loading status.
int main(void) int main(void)
@@ -118,7 +84,7 @@ int main(void)
UCSR0B = (1 << RXEN0) | (1 << TXEN0); UCSR0B = (1 << RXEN0) | (1 << TXEN0);
UCSR0C = (1 << UCSZ01) | (1 << UCSZ00); UCSR0C = (1 << UCSZ01) | (1 << UCSZ00);
stdout = &uart; stdout = &uart;
xTaskCreate(system_setup_task, "system_setup", 107, NULL, tskIDLE_PRIORITY, &system_setup_task_handle); xTaskCreate(system_setup_task, "system_setup", 150, NULL, tskIDLE_PRIORITY, &system_setup_task_handle);
#else #else
xTaskCreate(system_setup_task, NULL, 150, NULL, tskIDLE_PRIORITY, NULL); xTaskCreate(system_setup_task, NULL, 150, NULL, tskIDLE_PRIORITY, NULL);
#endif #endif
@@ -184,7 +150,7 @@ void system_setup_task(void *pvParameters)
zh_avr_160x_set_cursor(&lcd_handle, 1, 0); zh_avr_160x_set_cursor(&lcd_handle, 1, 0);
zh_avr_160x_print_char(&lcd_handle, pgm_read_ptr(text_component)); zh_avr_160x_print_char(&lcd_handle, pgm_read_ptr(text_component));
//**"ANY" component setup after loading **/ //**"ANY" component setup after loading **/
current_channels = component_channel[0]; used_channels = component_channel[0];
component_setup_function(0); component_setup_function(0);
is_initialized = true; is_initialized = true;
vTaskDelete(NULL); vTaskDelete(NULL);
@@ -235,12 +201,76 @@ void zh_avr_pcf8574_event_handler(zh_avr_pcf8574_event_on_isr_t *event)
} }
break; break;
case NUM1_BUTTON: case NUM1_BUTTON:
if ((used_channels & (1 << CHANNEL1)) == 0)
{
break;
}
if (event->gpio_level == LOW)
{
zh_avr_pcf8574_write_gpio(&led1_handle, NUM1_LED_BLUE, LED_OFF);
zh_avr_pcf8574_write_gpio(&led1_handle, NUM1_LED_GREEN, LED_ON);
zh_avr_pcf8574_write_gpio(&relay_handle, L1_RELAY, RELAY_ON);
}
else
{
zh_avr_pcf8574_write_gpio(&led1_handle, NUM1_LED_BLUE, LED_ON);
zh_avr_pcf8574_write_gpio(&led1_handle, NUM1_LED_GREEN, LED_OFF);
zh_avr_pcf8574_write_gpio(&relay_handle, L1_RELAY, RELAY_OFF);
}
break; break;
case NUM2_BUTTON: case NUM2_BUTTON:
if ((used_channels & (1 << CHANNEL2)) == 0)
{
break;
}
if (event->gpio_level == LOW)
{
zh_avr_pcf8574_write_gpio(&led1_handle, NUM2_LED_BLUE, LED_OFF);
zh_avr_pcf8574_write_gpio(&led1_handle, NUM2_LED_GREEN, LED_ON);
zh_avr_pcf8574_write_gpio(&relay_handle, L2_RELAY, RELAY_ON);
}
else
{
zh_avr_pcf8574_write_gpio(&led1_handle, NUM2_LED_BLUE, LED_ON);
zh_avr_pcf8574_write_gpio(&led1_handle, NUM2_LED_GREEN, LED_OFF);
zh_avr_pcf8574_write_gpio(&relay_handle, L2_RELAY, RELAY_OFF);
}
break; break;
case NUM3_BUTTON: case NUM3_BUTTON:
if ((used_channels & (1 << CHANNEL3)) == 0)
{
break;
}
if (event->gpio_level == LOW)
{
zh_avr_pcf8574_write_gpio(&led2_handle, NUM3_LED_BLUE, LED_OFF);
zh_avr_pcf8574_write_gpio(&led2_handle, NUM3_LED_GREEN, LED_ON);
zh_avr_pcf8574_write_gpio(&relay_handle, L3_RELAY, RELAY_ON);
}
else
{
zh_avr_pcf8574_write_gpio(&led2_handle, NUM3_LED_BLUE, LED_ON);
zh_avr_pcf8574_write_gpio(&led2_handle, NUM3_LED_GREEN, LED_OFF);
zh_avr_pcf8574_write_gpio(&relay_handle, L3_RELAY, RELAY_OFF);
}
break; break;
case NUM4_BUTTON: case NUM4_BUTTON:
if ((used_channels & (1 << CHANNEL4)) == 0)
{
break;
}
if (event->gpio_level == LOW)
{
zh_avr_pcf8574_write_gpio(&led2_handle, NUM4_LED_BLUE, LED_OFF);
zh_avr_pcf8574_write_gpio(&led2_handle, NUM4_LED_GREEN, LED_ON);
zh_avr_pcf8574_write_gpio(&relay_handle, L4_RELAY, RELAY_ON);
}
else
{
zh_avr_pcf8574_write_gpio(&led2_handle, NUM4_LED_BLUE, LED_ON);
zh_avr_pcf8574_write_gpio(&led2_handle, NUM4_LED_GREEN, LED_OFF);
zh_avr_pcf8574_write_gpio(&relay_handle, L4_RELAY, RELAY_OFF);
}
break; break;
default: default:
break; break;
@@ -323,19 +353,19 @@ void component_setup_function(uint8_t component)
zh_avr_160x_print_char(&lcd_handle, pgm_read_ptr(component_line_2[component])); zh_avr_160x_print_char(&lcd_handle, pgm_read_ptr(component_line_2[component]));
zh_avr_pcf8574_write(&led1_handle, 0x0F); zh_avr_pcf8574_write(&led1_handle, 0x0F);
zh_avr_pcf8574_write(&led2_handle, 0x0F); zh_avr_pcf8574_write(&led2_handle, 0x0F);
if ((current_channels & (1 << CHANNEL_1)) == CHANNEL_1) if ((used_channels & (1 << CHANNEL1)) == CHANNEL1)
{ {
zh_avr_pcf8574_write_gpio(&led1_handle, NUM1_LED_BLUE, LED_ON); zh_avr_pcf8574_write_gpio(&led1_handle, NUM1_LED_BLUE, LED_ON);
} }
if ((current_channels & (1 << CHANNEL_2)) == CHANNEL_2) if ((used_channels & (1 << CHANNEL2)) == CHANNEL2)
{ {
zh_avr_pcf8574_write_gpio(&led1_handle, NUM2_LED_BLUE, LED_ON); zh_avr_pcf8574_write_gpio(&led1_handle, NUM2_LED_BLUE, LED_ON);
} }
if ((current_channels & (1 << CHANNEL_3)) == CHANNEL_3) if ((used_channels & (1 << CHANNEL3)) == CHANNEL3)
{ {
zh_avr_pcf8574_write_gpio(&led2_handle, NUM3_LED_BLUE, LED_ON); zh_avr_pcf8574_write_gpio(&led2_handle, NUM3_LED_BLUE, LED_ON);
} }
if ((current_channels & (1 << CHANNEL_4)) == CHANNEL_4) if ((used_channels & (1 << CHANNEL4)) == CHANNEL4)
{ {
zh_avr_pcf8574_write_gpio(&led2_handle, NUM4_LED_BLUE, LED_ON); zh_avr_pcf8574_write_gpio(&led2_handle, NUM4_LED_BLUE, LED_ON);
} }

View File

@@ -48,28 +48,39 @@
#define NUM4_LED_BLUE 0x02 // Connector LE6. 2 PIN. L6-2 pin on U7. #define NUM4_LED_BLUE 0x02 // Connector LE6. 2 PIN. L6-2 pin on U7.
#define NUM4_LED_GREEN 0x03 // Connector LE6. 1 PIN. L6-3 pin on U7. #define NUM4_LED_GREEN 0x03 // Connector LE6. 1 PIN. L6-3 pin on U7.
#define CHANNEL_1 0x08 #define CHANNEL1 0x08
#define CHANNEL_2 0x04 #define CHANNEL2 0x04
#define CHANNEL_3 0x02 #define CHANNEL3 0x02
#define CHANNEL_4 0x01 #define CHANNEL4 0x01
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
{ {
#endif #endif
// typedef struct const char text_company[] PROGMEM = "LLC AEROTECH";
// { const char text_model[] PROGMEM = "ATE0003.000.000";
// char *cmm; const char text_firmware[] PROGMEM = "Firmware v1.0.0";
// char *channel_1; const char text_loading[] PROGMEM = "Loading:";
// char *channel_2; const char text_ac_power[] PROGMEM = "AC POWER: ";
// // char *channel_3; const char text_component[] PROGMEM = "COMPONENT: ";
// // char *channel_4;
// uint8_t button;
// } component_t;
// void system_setup_task(void *pvParameters); const char component_1_cmm[] PROGMEM = "ANY ";
// void component_setup_function(zh_avr_encoder_event_on_isr_t *event); const char component_2_cmm[] PROGMEM = "334230";
const char component_3_cmm[] PROGMEM = "334303";
const char component_4_cmm[] PROGMEM = "334711";
const char component_5_cmm[] PROGMEM = "334612";
const char component_1_line_1[] PROGMEM = "1:RED 2:GREEN";
const char component_1_line_2[] PROGMEM = "3:BLUE 4:WHITE";
const char component_2_line_1[] PROGMEM = "1:RED 2: ";
const char component_2_line_2[] PROGMEM = "3: 4: ";
const char component_3_line_1[] PROGMEM = "1:RED 2: ";
const char component_3_line_2[] PROGMEM = "3: 4: ";
const char component_4_line_1[] PROGMEM = "1:RED 2: ";
const char component_4_line_2[] PROGMEM = "3: 4: ";
const char component_5_line_1[] PROGMEM = "1:400W 2:600W ";
const char component_5_line_2[] PROGMEM = "3: 4: ";
#ifdef __cplusplus #ifdef __cplusplus
} }