wip:
This commit is contained in:
@@ -4,51 +4,16 @@
|
||||
#include "zh_avr_160x_i2c.h"
|
||||
#include "zh_avr_encoder.h"
|
||||
#include "zh_avr_ac_dimmer.h"
|
||||
#include "ate0003.h"
|
||||
|
||||
// #define DEBUG
|
||||
|
||||
#define HIGH true
|
||||
#define LOW false
|
||||
|
||||
#define LED_OFF true
|
||||
#define LED_ON false
|
||||
|
||||
#define BUTTON_I2C_ADDRESS 0x00
|
||||
#define LED1_I2C_ADDRESS 0x00
|
||||
#define LED2_I2C_ADDRESS 0x00
|
||||
#define RELAY_I2C_ADDRESS 0x00
|
||||
#define LCD_I2C_ADDRESS 0x00
|
||||
|
||||
#define GROUND_RELAY 1
|
||||
#define DMM_RELAY 1
|
||||
|
||||
#define POWER_ENCODER 1
|
||||
#define COMPONENT_ENCODER 2
|
||||
|
||||
#define DMM_BUTTON 0 // Connector BT1.
|
||||
#define FIX_BUTTON 1 // Connector BT2.
|
||||
#define NUM1_BUTTON 2
|
||||
#define NUM2_BUTTON 3
|
||||
#define NUM3_BUTTON 4
|
||||
#define NUM4_BUTTON 5
|
||||
|
||||
#define DMM_LED_RED 0 // Connector LE1. 2 PIN.
|
||||
#define DMM_LED_GRN 1 // Connector LE1. 1 PIN.
|
||||
#define FIX_LED_BLUE 2 // Connector LE2. 2 PIN.
|
||||
#define FIX_LED_GRN 3 // Connector LE2. 1 PIN.
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *cmm;
|
||||
uint8_t channel_1;
|
||||
uint8_t channel_2;
|
||||
uint8_t channel_3;
|
||||
uint8_t channel_4;
|
||||
} component_t;
|
||||
|
||||
const component_t component[] = {
|
||||
{"ANY", 1, 1, 1, 1},
|
||||
{"252525", 1, 0, 0, 0},
|
||||
{"ANY", "RED", "GREEN", "BLUE", "WHITE", 0xF},
|
||||
{"334230", "RED", "", "", "", 0x8},
|
||||
{"334303", "RED", "", "", "", 0x8},
|
||||
{"334711", "RED", "", "", "", 0x8},
|
||||
{"334612", "400W", "600W", "", "", 0xC},
|
||||
};
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -82,7 +47,7 @@ zh_avr_encoder_handle_t power_encoder_handle = {0};
|
||||
zh_avr_encoder_handle_t component_encoder_handle = {0};
|
||||
|
||||
volatile bool is_work = false;
|
||||
volatile bool is_dmm = false;
|
||||
volatile bool is_dmm = false; // DMM using status.
|
||||
volatile bool is_fix = false;
|
||||
volatile uint8_t component_num = 0;
|
||||
|
||||
@@ -192,16 +157,16 @@ void zh_avr_pcf8574_event_handler(zh_avr_pcf8574_event_on_isr_t *event)
|
||||
{
|
||||
if (is_dmm == true)
|
||||
{
|
||||
zh_avr_pcf8574_write_gpio(&relay_handle, DMM_RELAY, HIGH);
|
||||
zh_avr_pcf8574_write_gpio(&relay_handle, DMM_RELAY, RELAY_ON);
|
||||
zh_avr_pcf8574_write_gpio(&led1_handle, DMM_LED_RED, LED_ON);
|
||||
zh_avr_pcf8574_write_gpio(&led1_handle, DMM_LED_GRN, LED_OFF);
|
||||
zh_avr_pcf8574_write_gpio(&led1_handle, DMM_LED_GREEN, LED_OFF);
|
||||
is_dmm = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
zh_avr_pcf8574_write_gpio(&relay_handle, DMM_RELAY, LOW);
|
||||
zh_avr_pcf8574_write_gpio(&relay_handle, DMM_RELAY, RELAY_OFF);
|
||||
zh_avr_pcf8574_write_gpio(&led1_handle, DMM_LED_RED, LED_OFF);
|
||||
zh_avr_pcf8574_write_gpio(&led1_handle, DMM_LED_GRN, LED_ON);
|
||||
zh_avr_pcf8574_write_gpio(&led1_handle, DMM_LED_GREEN, LED_ON);
|
||||
is_dmm = true;
|
||||
}
|
||||
}
|
||||
@@ -210,13 +175,13 @@ void zh_avr_pcf8574_event_handler(zh_avr_pcf8574_event_on_isr_t *event)
|
||||
if (event->gpio_level == LOW)
|
||||
{
|
||||
zh_avr_pcf8574_write_gpio(&led1_handle, FIX_LED_BLUE, LED_OFF);
|
||||
zh_avr_pcf8574_write_gpio(&led1_handle, FIX_LED_GRN, LED_ON);
|
||||
zh_avr_pcf8574_write_gpio(&led1_handle, FIX_LED_GREEN, LED_ON);
|
||||
is_fix = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
zh_avr_pcf8574_write_gpio(&led1_handle, FIX_LED_BLUE, LED_ON);
|
||||
zh_avr_pcf8574_write_gpio(&led1_handle, FIX_LED_GRN, LED_OFF);
|
||||
zh_avr_pcf8574_write_gpio(&led1_handle, FIX_LED_GREEN, LED_OFF);
|
||||
is_fix = false;
|
||||
}
|
||||
break;
|
||||
68
src/ate0003.h
Normal file
68
src/ate0003.h
Normal file
@@ -0,0 +1,68 @@
|
||||
#pragma once
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
#define HIGH true
|
||||
#define LOW false
|
||||
|
||||
#define LED_OFF HIGH
|
||||
#define LED_ON LOW
|
||||
|
||||
#define RELAY_OFF LOW
|
||||
#define RELAY_ON HIGH
|
||||
|
||||
#define BUTTON_I2C_ADDRESS 0x00 // U5.
|
||||
#define LED1_I2C_ADDRESS 0x00 // U6.
|
||||
#define LED2_I2C_ADDRESS 0x00 // U7.
|
||||
#define RELAY_I2C_ADDRESS 0x00 // U8.
|
||||
#define LCD_I2C_ADDRESS 0x00 // U4.
|
||||
|
||||
#define GROUND_RELAY 0x00 // Relay K1. RL1 pin on U8.
|
||||
#define DMM_RELAY 0x01 // Relay K2. RL2 pin on U8.
|
||||
#define L1_RELAY 0x03 // Relay K4. RL4 pin on U8.
|
||||
#define L2_RELAY 0x04 // Relay K3. RL3 pin on U8.
|
||||
#define L3_RELAY 0x05 // Relay K6. RL6 pin on U8.
|
||||
#define L4_RELAY 0x02 // Relay K5. RL5 pin on U8.
|
||||
#define L5_RELAY 0x06 // Relay K7. RL7 pin on U8.
|
||||
|
||||
#define POWER_ENCODER 0x01 // Connector EN2.
|
||||
#define COMPONENT_ENCODER 0x02 // Connector EN1.
|
||||
|
||||
#define DMM_BUTTON 0x00 // Connector BT1. BT1-0 on U5.
|
||||
#define FIX_BUTTON 0x01 // Connector BT2. BT2-1 on U5.
|
||||
#define NUM1_BUTTON 0x02 // Connector BT3. BT3-2 on U5.
|
||||
#define NUM2_BUTTON 0x03 // Connector BT4. BT4-3 on U5.
|
||||
#define NUM3_BUTTON 0x04 // Connector BT5. BT5-4 on U5.
|
||||
#define NUM4_BUTTON 0x05 // Connector BT6. BT6-5 on U5.
|
||||
|
||||
#define DMM_LED_RED 0x00 // Connector LE1. 2 PIN. L1-0 pin on U6.
|
||||
#define DMM_LED_GREEN 0x01 // Connector LE1. 1 PIN. L1-1 pin on U6.
|
||||
#define FIX_LED_BLUE 0x02 // Connector LE2. 2 PIN. L2-2 pin on U6.
|
||||
#define FIX_LED_GREEN 0x03 // Connector LE2. 1 PIN. L2-3 pin on U6.
|
||||
#define NUM1_LED_BLUE 0x04 // Connector LE3. 2 PIN. L3-4 pin on U6.
|
||||
#define NUM1_LED_GREEN 0x05 // Connector LE3. 1 PIN. L3-5 pin on U6.
|
||||
#define NUM2_LED_BLUE 0x06 // Connector LE4. 2 PIN. L4-6 pin on U6.
|
||||
#define NUM2_LED_GREEN 0x07 // Connector LE4. 1 PIN. L4-7 pin on U6.
|
||||
#define NUM3_LED_BLUE 0x00 // Connector LE5. 2 PIN. L5-0 pin on U7.
|
||||
#define NUM3_LED_GREEN 0x01 // Connector LE5. 1 PIN. L5-1 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.
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *cmm;
|
||||
char *channel_1;
|
||||
char *channel_2;
|
||||
char *channel_3;
|
||||
char *channel_4;
|
||||
uint8_t button;
|
||||
} component_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user