mirror of
https://github.com/esphome/esphome.git
synced 2025-09-10 23:32:23 +01:00
add required option for available outputs
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "esphome/core/log.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "dynamic_lamp.h"
|
||||
|
||||
namespace esphome {
|
||||
@@ -21,10 +22,38 @@ void DynamicLamp::setup() {
|
||||
}
|
||||
|
||||
void DynamicLamp::loop() {
|
||||
|
||||
uint8_t i = 0;
|
||||
for (i = 0; i < this->lamp_count_; i++) {
|
||||
if (this->active_lamps_[i].active) {
|
||||
uint8_t j = 0;
|
||||
for (j = 0; j < 16; j++) {
|
||||
if (this->active_lamps_[i].used_outputs[j].active) {
|
||||
if (this->active_lamps_[i].used_outputs[j].update_level) {
|
||||
// Update level
|
||||
switch (this->active_lamps_[i].used_outputs[j].mode) {
|
||||
case MODE_EQUAL:
|
||||
// Equal
|
||||
break;
|
||||
case MODE_STATIC:
|
||||
// Static
|
||||
break;
|
||||
case MODE_PERCENT:
|
||||
// Percent
|
||||
break;
|
||||
case MODE_FUNCTION:
|
||||
// Function
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicLamp::dump_config(){
|
||||
void DynamicLamp::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "Dynamic Lamp feature loaded");
|
||||
switch(this->save_mode_) {
|
||||
case SAVE_MODE_NONE:
|
||||
@@ -37,12 +66,25 @@ void DynamicLamp::dump_config(){
|
||||
ESP_LOGCONFIG(TAG, "Currently only NONE(0) && FRAM(1) save modes supported, ignoring value %" PRIu8 " and defaulting to NONE!", this->save_mode_);
|
||||
this->save_mode_ = 0;
|
||||
}
|
||||
for (uint8_t i = 0; i < 16; i++) {
|
||||
if (this->available_outputs_[i] != "") {
|
||||
ESP_LOGCONFIG(TAG, "Using output with id %s as output number %" PRIu8 "", &this->available_outputs_[i], i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicLamp::set_save_mode(uint8_t save_mode) {
|
||||
this->save_mode_ = save_mode;
|
||||
}
|
||||
|
||||
void DynamicLamp::set_available_outputs(std::list<std::string> output_list) {
|
||||
uint8_t i = 0;
|
||||
for (std::list<std::string>::iterator it = output_list.begin(); it != output_list.end(); ++it) {
|
||||
this->available_outputs_[i] = *it;
|
||||
i++;
|
||||
}
|
||||
|
||||
}
|
||||
void DynamicLamp::set_lamp_count(uint8_t lamp_count) {
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user