kopia lustrzana https://github.com/espressif/esp-idf
fix[cxx]: improve experimental cxx examples
* use std::this_thread::sleep_for instead of FreeRTOS sleep functions * adjusted/added lincense headers in examplespull/6365/head
rodzic
d4a6c911e4
commit
5b15f37458
|
@ -6,6 +6,7 @@
|
|||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include "esp_event_cxx.hpp"
|
||||
#include "esp_event.h"
|
||||
|
|
|
@ -1,20 +1,15 @@
|
|||
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
/* ESP Timer C++ Example
|
||||
|
||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, this
|
||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
|
||||
#include "esp_timer_cxx.hpp"
|
||||
#include "esp_exception.hpp"
|
||||
|
@ -30,14 +25,13 @@ extern "C" void app_main(void)
|
|||
ESPTimer timer([]() { cout << "timeout" << endl; });
|
||||
timer.start(chrono::microseconds(200 * 1000));
|
||||
|
||||
vTaskDelay(550 / portTICK_PERIOD_MS);
|
||||
this_thread::sleep_for(std::chrono::milliseconds(550));
|
||||
|
||||
cout << "Setting up timer to trigger periodically every 200ms" << endl;
|
||||
ESPTimer timer2([]() { cout << "periodic timeout" << endl; });
|
||||
timer2.start_periodic(chrono::microseconds(200 * 1000));
|
||||
|
||||
vTaskDelay(1050 / portTICK_PERIOD_MS);
|
||||
|
||||
this_thread::sleep_for(std::chrono::milliseconds(1050));
|
||||
} catch (const ESPException &e) {
|
||||
cout << "Exception with error: " << e.error << endl;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,12 @@
|
|||
/* ESP MCP9808 Sensor/I2C C++ Example
|
||||
|
||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, this
|
||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include "i2c_cxx.hpp"
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue