Created
May 11, 2018 10:46
-
-
Save CelliesProjects/1cb40b1914c27404d4ff87de8efd5f95 to your computer and use it in GitHub Desktop.
ESP32 - A simple class with a member that is a freertos task.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* http://www.learncpp.com/cpp-tutorial/812-static-member-functions/ */ | |
| #include "myClass.h" | |
| void setup() { | |
| xTaskCreatePinnedToCore( | |
| myClass::myFunction, /* Task function. */ | |
| "myFunction", /* String with name of task. */ | |
| 10000, /* Stack size in words. */ | |
| NULL, /* Parameter passed as input of the task */ | |
| 1, /* Priority of the task. */ | |
| NULL, /* Task handle. */ | |
| 1); | |
| } | |
| void loop() { | |
| // put your main code here, to run repeatedly: | |
| vTaskDelay( 500 ); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include "myClass.h" | |
| #include "esp32-hal-gpio.h" | |
| #include "esp_log.h" | |
| #include <FreeRTOS.h> | |
| void myClass::myFunction( void * parameter ) | |
| { | |
| const uint8_t builtin_led = 2; | |
| pinMode( builtin_led, OUTPUT ); | |
| while (1) | |
| { | |
| //a function; | |
| const char * TAG = "myFunction"; | |
| ESP_LOGI( TAG, "My function" ); | |
| digitalWrite( builtin_led, !gpio_get_level( gpio_num_t( builtin_led ) ) ); | |
| vTaskDelay( 500 ); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ifndef MyClass_h | |
| #define MyClass_h | |
| class myClass | |
| { | |
| public: | |
| static void myFunction( void * parameter ); | |
| }; | |
| #endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment