add alarm command

This commit is contained in:
King Kévin 2016-10-03 12:09:24 +02:00
parent 2b7178284e
commit 8708cfd570
2 changed files with 7 additions and 2 deletions

View File

@ -43,7 +43,7 @@
static uint8_t rx_buffer[7] = {0}; /**< buffer for received response */
static volatile uint8_t rx_i = 0; /**< current position of read received data */
static uint8_t tx_buffer[7] = {0}; /**< buffer for request to transmit */
static volatile uint8_t tx_i = 0; /**< current position if transmitted data */
static volatile uint8_t tx_i = 0; /**< current position of transmitted data */
volatile bool sensor_pzem_measurement_received = false;
@ -133,6 +133,9 @@ struct sensor_pzem_measurement_t sensor_pzem_measurement_decode(void)
case SENSOR_PZEM_ENERGY:
measurement.value.power = ((uint32_t)rx_buffer[1]<<16)+((uint16_t)rx_buffer[2]<<8)+rx_buffer[3];
break;
case SENSOR_PZEM_ADDRESS:
case SENSOR_PZEM_ALARM:
break; // no value is returned
default:
measurement.valid = false; // unexpected type
}

View File

@ -23,12 +23,14 @@
/** a measurement response has been received */
extern volatile bool sensor_pzem_measurement_received;
/** measurements offered by electricity meter */
/** measurements (and configurations) offered by electricity meter */
enum sensor_pzem_measurement_type_t {
SENSOR_PZEM_VOLTAGE = 0,
SENSOR_PZEM_CURRENT = 1,
SENSOR_PZEM_POWER = 2,
SENSOR_PZEM_ENERGY = 3,
SENSOR_PZEM_ADDRESS = 4,
SENSOR_PZEM_ALARM = 5,
SENSOR_PZEM_MAX
};