Skip to content

Commit

Permalink
fix bug with namespace-scoped includes
Browse files Browse the repository at this point in the history
  • Loading branch information
ardnew committed Jan 22, 2024
1 parent 72ed876 commit 7af9d21
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"url": "https://github.com/ardnew/cronos.git"
},
"license": "MIT",
"version": "0.1.5",
"version": "0.1.6",
"headers": [
"cronos.hpp"
],
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=cronos
version=0.1.5
version=0.1.6
author=ardnew
maintainer=ardnew (andrew@ardnew.com)
sentence=A std::chrono wrapper for target system's native tick count.
Expand Down
10 changes: 8 additions & 2 deletions src/cronos.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,27 @@
#include <functional>
#include <iostream>

#if defined(ESP_PLATFORM)
#include <esp_timer.h>
#elif defined(ARDUINO)
#include <Arduino.h>
#endif

namespace native {
class ticker {
public:
#if defined(ESP_PLATFORM)
#include <esp_timer.h> // ESP32 (FreeRTOS) ticks are in microseconds.
#define fastcode IRAM_ATTR /* __attribute__((section(".iram1.text"))) */
// ESP32 (FreeRTOS) ticks are in microseconds.
static constexpr auto fastcode count = esp_timer_get_time;
using period = std::micro;

#elif defined(ARDUINO)
// It's likely there are many generic platforms that will have ARDUINO
// defined. So be sure to check it last (but before the default C++
// implementation).
#include <Arduino.h> // Arduino ticks are in milliseconds.
#define fastcode
// Arduino ticks are in milliseconds.
static constexpr auto fastcode count = millis;
using period = std::milli;

Expand Down

0 comments on commit 7af9d21

Please sign in to comment.