From 3333da128a54aef450c2bfb806afa286f07aecc9 Mon Sep 17 00:00:00 2001 From: Don Cross Date: Thu, 5 Sep 2024 13:59:41 -0400 Subject: [PATCH] Generate Arduino code from C code. Patch for limited time functionality. --- generate/makedoc | 4 ++++ source/arduino/astronomy.cpp | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/generate/makedoc b/generate/makedoc index b5e78c8f..d973ec3a 100755 --- a/generate/makedoc +++ b/generate/makedoc @@ -20,6 +20,10 @@ for file in ../source/c/astronomy.c ../source/js/astronomy.ts ../source/python/a node trimspace.js ${file} || Fail "Cannot trim whitespace from target file: ${file}" done +echo "Patching C++ code for Arduino." +cp -v ../source/c/astronomy.c ../source/arduino/astronomy.cpp || exit 1 +sed -i '/astro_time_t Astronomy_CurrentTime(void)/i #define ASTRONOMY_ENGINE_WHOLE_SECOND 1' ../source/arduino/astronomy.cpp || exit 1 + # C# is a special case: we have to compile the code to get its documentation. echo "Building C# code to get documentation XML." cd dotnet/csharp_test || "Cannot change to directory dotnet/csharp_test" diff --git a/source/arduino/astronomy.cpp b/source/arduino/astronomy.cpp index 709a559f..f5ecd247 100644 --- a/source/arduino/astronomy.cpp +++ b/source/arduino/astronomy.cpp @@ -4,7 +4,7 @@ MIT License - Copyright (c) 2019-2023 Don Cross + Copyright (c) 2019-2024 Don Cross Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -1000,7 +1000,6 @@ astro_time_t Astronomy_TerrestrialTime(double tt) * define the preprocessor symbol `ASTRONOMY_ENGINE_NO_CURRENT_TIME` to * exclude this function from your code. */ - #define ASTRONOMY_ENGINE_WHOLE_SECOND 1 astro_time_t Astronomy_CurrentTime(void) { @@ -1022,7 +1021,7 @@ astro_time_t Astronomy_CurrentTime(void) #elif defined(ASTRONOMY_ENGINE_WHOLE_SECOND) sec = time(NULL); #else - // #error Microsecond time resolution is not supported on this platform. Define ASTRONOMY_ENGINE_WHOLE_SECOND to use second resolution instead. + #error Microsecond time resolution is not supported on this platform. Define ASTRONOMY_ENGINE_WHOLE_SECOND to use second resolution instead. #endif /* Convert seconds to days, then subtract to get days since noon on January 1, 2000. */