Skip to content

Commit

Permalink
OutputOneLineStatus -->DoMonitoring
Browse files Browse the repository at this point in the history
  • Loading branch information
klaus-liebler committed Sep 1, 2024
1 parent fb17ad1 commit be3b7c3
Show file tree
Hide file tree
Showing 7 changed files with 332 additions and 280 deletions.
2 changes: 1 addition & 1 deletion espidf-component-labathome/builder/gulpfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ exports.speech = async (cb: gulp.TaskFunctionCallback) => {
// Select the language and SSML voice gender (optional)
voice: { name: 'de-DE-Neural2-F', languageCode:"de-DE"},
// select the type of audio encoding
audioConfig: { audioEncoding: google.cloud.texttospeech.v1.AudioEncoding.MP3 },
audioConfig: { audioEncoding: google.cloud.texttospeech.v1.AudioEncoding.MP3, sampleRateHertz: 22050 },
};
const [response] = await client.synthesizeSpeech(request);
// Write the binary audio content to a local file
Expand Down
2 changes: 1 addition & 1 deletion espidf-component-labathome/cpp/HAL.hh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class HAL
virtual ErrorCode GetWifiRssiDb(float *db)=0;
virtual int64_t GetMicros()=0;
virtual uint32_t GetMillis()=0;
virtual ErrorCode OutputOneLineStatus()=0;
virtual void DoMonitoring()=0;
virtual ErrorCode GreetUserOnStartup()=0;

virtual ErrorCode GetAmbientBrightnessAnalog(float *lux)=0;
Expand Down
75 changes: 40 additions & 35 deletions espidf-component-labathome/cpp/HAL_labathomeV10.hh
Original file line number Diff line number Diff line change
Expand Up @@ -239,19 +239,19 @@ private:
// Es wird nicht unterschieden, ob der eingang "nur" zum Messen von analogen Spannung verwendet wird oder ob es sich um den Trigger-Eingang des Zeitrelais handelt. Im zweiten Fall muss einfach eine Zeitrelais-Schaltung basierend auf der Grenzüberschreitung des Analogen Messwertes in der Funktionsblock-Spache realisiert werden
ESP_ERROR_CHECK(adc_oneshot_read(adc1_handle, CHANNEL_ANALOGIN_OR_ROTB, &adc_reading));
ESP_ERROR_CHECK(adc_cali_raw_to_voltage(adc1_cali_handle, adc_reading, &adc_calibrated));
this->AnalogInputVoltage_volts[0] = adc_calibrated/1000.; // die Multiplikation mit 11 wegen dem Spannungsteiler
this->AnalogInputVoltage_volts[0] = adc_calibrated / 1000.; // die Multiplikation mit 11 wegen dem Spannungsteiler

ESP_ERROR_CHECK(adc_oneshot_read(adc1_handle, CHANNEL_MOVEMENT_OR_FAN1SENSE, &adc_reading));
ESP_ERROR_CHECK(adc_cali_raw_to_voltage(adc1_cali_handle, adc_reading, &adc_calibrated));
this->AnalogInputVoltage_volts[1] = adc_calibrated/1000.; // die Multiplikation mit 11 wegen dem Spannungsteiler
this->AnalogInputVoltage_volts[1] = adc_calibrated / 1000.; // die Multiplikation mit 11 wegen dem Spannungsteiler

ESP_ERROR_CHECK(adc_oneshot_read(adc1_handle, CHANNEL_LDR_OR_ROTA, &adc_reading));
ESP_ERROR_CHECK(adc_cali_raw_to_voltage(adc1_cali_handle, adc_reading, &adc_calibrated));
this->AnalogInputVoltage_volts[2] = adc_calibrated/1000.;
this->AnalogInputVoltage_volts[2] = adc_calibrated / 1000.;

ESP_ERROR_CHECK(adc_oneshot_read(adc1_handle, CHANNEL_SWITCHES, &adc_reading));
ESP_ERROR_CHECK(adc_cali_raw_to_voltage(adc1_cali_handle, adc_reading, &adc_calibrated));
this->AnalogInputVoltage_volts[3] = adc_calibrated/1000.;
this->AnalogInputVoltage_volts[3] = adc_calibrated / 1000.;
int i = 0;
for (i = 0; i < sizeof(sw_limits) / sizeof(uint16_t); i++)
{
Expand Down Expand Up @@ -324,37 +324,42 @@ public:
{
}

ErrorCode OutputOneLineStatus() override
void DoMonitoring() override
{
uint32_t heap = esp_get_free_heap_size();
bool red = GetButtonRedIsPressed();
bool yel = GetButtonEncoderIsPressed();
bool grn = GetButtonGreenIsPressed();
bool mov = IsMovementDetected();
float htrTemp{0.f};
int enc{0};
GetEncoderValue(&enc);
int32_t sound{0};
GetSound(&sound);
float spply = GetUSBCVoltage();

float bright{0};
GetAmbientBrightness(&bright);

GetHeaterTemperature(&htrTemp);
float airTemp{0.f};
GetAirTemperature(&airTemp);
float airPres{0};
GetAirPressure(&airPres);
float airHumid{0.f};
GetAirRelHumidity(&airHumid);
float co2{0};
GetCO2PPM(&co2);
float *analogVolt{nullptr};
GetAnalogInputs(&analogVolt);
ESP_LOGI(TAG, "Heap %6lu RED %d YEL %d GRN %d MOV %d ENC %i SOUND %ld SUPPLY %4.1f BRGHT %4f HEAT %4.1f AIRT %4.1f AIRPRS %5f AIRHUM %3.0f CO2 %5f, ANALOGIN [%4.1f %4.1f]",
heap, red, yel, grn, mov, enc, sound, spply, bright, htrTemp, airTemp, airPres, airHumid, co2, analogVolt[0], analogVolt[1]);
return ErrorCode::OK;
static int64_t nextOneLineStatus{0};
int64_t now = millis();
if (now > nextOneLineStatus)
{
uint32_t heap = esp_get_free_heap_size();
bool red = GetButtonRedIsPressed();
bool yel = GetButtonEncoderIsPressed();
bool grn = GetButtonGreenIsPressed();
bool mov = IsMovementDetected();
float htrTemp{0.f};
int enc{0};
GetEncoderValue(&enc);
int32_t sound{0};
GetSound(&sound);
float spply = GetUSBCVoltage();

float bright{0};
GetAmbientBrightness(&bright);

GetHeaterTemperature(&htrTemp);
float airTemp{0.f};
GetAirTemperature(&airTemp);
float airPres{0};
GetAirPressure(&airPres);
float airHumid{0.f};
GetAirRelHumidity(&airHumid);
float co2{0};
GetCO2PPM(&co2);
float *analogVolt{nullptr};
GetAnalogInputs(&analogVolt);
ESP_LOGI(TAG, "Heap %6lu RED %d YEL %d GRN %d MOV %d ENC %i SOUND %ld SUPPLY %4.1f BRGHT %4f HEAT %4.1f AIRT %4.1f AIRPRS %5f AIRHUM %3.0f CO2 %5f, ANALOGIN [%4.1f %4.1f]",
heap, red, yel, grn, mov, enc, sound, spply, bright, htrTemp, airTemp, airPres, airHumid, co2, analogVolt[0], analogVolt[1]);
nextOneLineStatus += 5000;
}
}

int64_t IRAM_ATTR GetMicros()
Expand Down Expand Up @@ -768,7 +773,7 @@ public:
}
else
{
*dutyInPercent = mcpwm_get_duty(MCPWM_UNIT_0, MCPWM_TIMER_FAN, MCPWM_GEN_FAN2);
*dutyInPercent = mcpwm_get_duty(MCPWM_UNIT_0, MCPWM_TIMER_FAN, MCPWM_GEN_FAN2);
return ErrorCode::OK;
}
}
Expand Down
Loading

0 comments on commit be3b7c3

Please sign in to comment.