mirror of
https://github.com/arendst/Tasmota.git
synced 2025-08-01 23:17:43 +00:00
ADS1115: Housekeeping
This commit is contained in:
parent
da3f4bcab7
commit
fd9f66ed6e
@ -161,28 +161,23 @@ int16_t Ads1115GetConversion(uint8_t channel)
|
|||||||
void Ads1115Detect(void)
|
void Ads1115Detect(void)
|
||||||
{
|
{
|
||||||
uint16_t buffer;
|
uint16_t buffer;
|
||||||
uint16_t conf_buffer;
|
|
||||||
|
|
||||||
//if (ads1115_type) {
|
|
||||||
//return;
|
|
||||||
//}
|
|
||||||
|
|
||||||
for (uint8_t i = 0; i < sizeof(ads1115_addresses); i++) {
|
for (uint8_t i = 0; i < sizeof(ads1115_addresses); i++) {
|
||||||
|
if (!ads1115_found[i]) {
|
||||||
ads1115_address = ads1115_addresses[i];
|
ads1115_address = ads1115_addresses[i];
|
||||||
if (I2cValidRead16(&buffer, ads1115_address, ADS1115_REG_POINTER_CONVERT) &&
|
if (I2cValidRead16(&buffer, ads1115_address, ADS1115_REG_POINTER_CONVERT) &&
|
||||||
I2cValidRead16(&conf_buffer, ads1115_address, ADS1115_REG_POINTER_CONFIG)) {
|
I2cValidRead16(&buffer, ads1115_address, ADS1115_REG_POINTER_CONFIG)) {
|
||||||
|
|
||||||
Ads1115StartComparator(i, ADS1115_REG_CONFIG_MODE_CONTIN);
|
Ads1115StartComparator(i, ADS1115_REG_CONFIG_MODE_CONTIN);
|
||||||
ads1115_type = 1;
|
ads1115_type = 1;
|
||||||
ads1115_found[i] = 1;
|
ads1115_found[i] = 1;
|
||||||
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "ADS1115", ads1115_address);
|
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "ADS1115", ads1115_address);
|
||||||
AddLog(LOG_LEVEL_DEBUG);
|
AddLog(LOG_LEVEL_DEBUG);
|
||||||
//break;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ads1115GetValues(uint8_t address) {
|
void Ads1115GetValues(uint8_t address)
|
||||||
|
{
|
||||||
uint8_t old_address = ads1115_address;
|
uint8_t old_address = ads1115_address;
|
||||||
ads1115_address = address;
|
ads1115_address = address;
|
||||||
for (uint8_t i = 0; i < 4; i++) {
|
for (uint8_t i = 0; i < 4; i++) {
|
||||||
@ -193,7 +188,8 @@ void Ads1115GetValues(uint8_t address) {
|
|||||||
ads1115_address = old_address;
|
ads1115_address = old_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ads1115toJSON(char *comma_j) {
|
void Ads1115toJSON(char *comma_j)
|
||||||
|
{
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s%s{"), mqtt_data,comma_j);
|
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s%s{"), mqtt_data,comma_j);
|
||||||
char *comma = (char*)"";
|
char *comma = (char*)"";
|
||||||
for (uint8_t i = 0; i < 4; i++) {
|
for (uint8_t i = 0; i < 4; i++) {
|
||||||
@ -203,7 +199,8 @@ void Ads1115toJSON(char *comma_j) {
|
|||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s}"), mqtt_data);
|
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s}"), mqtt_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ads1115toString(uint8_t address) {
|
void Ads1115toString(uint8_t address)
|
||||||
|
{
|
||||||
char label[15];
|
char label[15];
|
||||||
snprintf_P(label, sizeof(label), "ADS1115(%02x)", address);
|
snprintf_P(label, sizeof(label), "ADS1115(%02x)", address);
|
||||||
|
|
||||||
@ -214,11 +211,11 @@ void Ads1115toString(uint8_t address) {
|
|||||||
|
|
||||||
void Ads1115Show(bool json)
|
void Ads1115Show(bool json)
|
||||||
{
|
{
|
||||||
if (!ads1115_type)
|
if (!ads1115_type) { return; }
|
||||||
return;
|
|
||||||
|
|
||||||
if (json)
|
if (json) {
|
||||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"ADS1115\":["), mqtt_data);
|
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"ADS1115\":["), mqtt_data);
|
||||||
|
}
|
||||||
|
|
||||||
char *comma = (char*)"";
|
char *comma = (char*)"";
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user