Skip to content

Commit

Permalink
Update Memory Utils
Browse files Browse the repository at this point in the history
  • Loading branch information
AzonInc committed Sep 23, 2024
1 parent 1ddac69 commit 2dae8f9
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 4 deletions.
22 changes: 22 additions & 0 deletions components/tc_bus/memory.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "memory.h"
#include "esphome.h"
#include "esphome/core/helpers.h"

namespace esphome
{
namespace tc_bus
{
const char* setting_type_to_string(SettingType type)
{
switch (type)
{
case SETTING_RINGTONE_FLOOR_CALL: return "ringtone_floor_call";
case SETTING_RINGTONE_DOOR_CALL: return "ringtone_door_call";
case SETTING_RINGTONE_INTERNAL_CALL: return "ringtone_internal_call";
case SETTING_RINGTONE_VOLUME: return "volume_ringtone";
case SETTING_HANDSET_VOLUME: return "volume_handset";
default: return "UNKNOWN";
}
}
} // namespace tc_bus
} // namespace esphome
8 changes: 6 additions & 2 deletions components/tc_bus/tc_bus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,12 @@ namespace esphome
settings_.internal_call_ringtone = (memory_buffer_[6] >> 4) & 0xF;
settings_.floor_call_ringtone = (memory_buffer_[9] >> 4) & 0xF;

ESP_LOGD(TAG, "HVOL %i, RVOL %i, DCRING %i, FCRING %i, ICRING %i", settings_.handset_volume, settings_.ringtone_volume, settings_.door_call_ringtone, settings_.floor_call_ringtone, settings_.internal_call_ringtone);

ESP_LOGD(TAG, "Handset volume %i", settings_.handset_volume);
ESP_LOGD(TAG, "Ringtone volume %i", settings_.ringtone_volume);
ESP_LOGD(TAG, "Door Call Ringtone %i", settings_.door_call_ringtone);
ESP_LOGD(TAG, "Floor Call Ringtone %i", settings_.floor_call_ringtone);
ESP_LOGD(TAG, "Internal Call Ringtone %i", settings_.internal_call_ringtone);

this->read_memory_complete_callback_.call(memory_buffer_);
}
else
Expand Down
28 changes: 26 additions & 2 deletions firmware/addons/memory-utils.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,35 @@ tc_bus:
- logger.log: "Completed memory reading!"
- lambda: |-
std::string hexString = str_upper_case(format_hex(x));
ESP_LOGD("tcs_bus", "Memory: %s", hexString.c_str());
ESP_LOGD("tcs_bus", "Memory Dump: %s", hexString.c_str());
on_read_memory_timeout:
- logger.log: "Failed to read Memory"

number:
- platform: template
name: "Ringtone volume"
optimistic: true
min_value: 0
max_value: 12
step: 1
set_action:
then:
- tc_bus.update_setting:
type: volume_ringtone
value: !lambda "return x;"

- platform: template
name: "Handset volume"
optimistic: true
min_value: 0
max_value: 12
step: 1
set_action:
then:
- tc_bus.update_setting:
type: volume_handset
value: !lambda "return x;"

button:
- platform: template
Expand Down

0 comments on commit 2dae8f9

Please sign in to comment.