Generate Arduino code from C code. Patch for limited time functionality.

This commit is contained in:
Don Cross
2024-09-05 13:59:41 -04:00
parent 64149c50c7
commit 3333da128a
2 changed files with 6 additions and 3 deletions

View File

@@ -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"

View File

@@ -4,7 +4,7 @@
MIT License
Copyright (c) 2019-2023 Don Cross <cosinekitty@gmail.com>
Copyright (c) 2019-2024 Don Cross <cosinekitty@gmail.com>
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. */