From b2d6cfba0650b65d7baffb04ffa80cfbc9e20a61 Mon Sep 17 00:00:00 2001 From: Jonathan Swoboda Date: Tue, 19 Nov 2024 21:27:30 -0500 Subject: [PATCH] Run image cal manually after configuring radio --- esphome/components/sx127x/sx127x.cpp | 4 ++++ esphome/components/sx127x/sx127x.h | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/esphome/components/sx127x/sx127x.cpp b/esphome/components/sx127x/sx127x.cpp index 0b7de26554..ff22d575fe 100644 --- a/esphome/components/sx127x/sx127x.cpp +++ b/esphome/components/sx127x/sx127x.cpp @@ -205,6 +205,10 @@ void SX127x::configure() { this->set_mode_standby(); delay(1); + // run image cal + this->write_register_(REG_IMAGE_CAL, AUTO_IMAGE_CAL_ON | IMAGE_CAL_START | TEMP_THRESHOLD_10C); + delay(10); + // enable rx mode if (this->rx_start_) { this->set_mode_rx(); diff --git a/esphome/components/sx127x/sx127x.h b/esphome/components/sx127x/sx127x.h index 7f4be737a6..20f00a200f 100644 --- a/esphome/components/sx127x/sx127x.h +++ b/esphome/components/sx127x/sx127x.h @@ -45,6 +45,7 @@ enum SX127xReg : uint8_t { REG_PACKET_CONFIG_2 = 0x31, REG_PAYLOAD_LENGTH = 0x32, REG_FIFO_THRESH = 0x35, + REG_IMAGE_CAL = 0x3B, REG_DIO_MAPPING1 = 0x40, REG_DIO_MAPPING2 = 0x41, REG_VERSION = 0x42, @@ -80,6 +81,18 @@ enum SX127xSyncConfig : uint8_t { SYNC_ON = 0x10, }; +enum SX127xImageCal : uint8_t { + AUTO_IMAGE_CAL_ON = 0x80, + IMAGE_CAL_START = 0x40, + IMAGE_CAL_RUNNING = 0x20, + TEMP_CHANGE = 0x08, + TEMP_THRESHOLD_20C = 0x06, + TEMP_THRESHOLD_15C = 0x04, + TEMP_THRESHOLD_10C = 0x02, + TEMP_THRESHOLD_5C = 0x00, + TEMP_MONITOR_OFF = 0x01, +}; + enum SX127xOpMode : uint8_t { MOD_FSK = 0x00, MOD_OOK = 0x20,