Skip to content

Commit

Permalink
Generate Arduino code from C code. Patch for limited time functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
cosinekitty committed Sep 5, 2024
1 parent 64149c5 commit 3333da1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 4 additions & 0 deletions generate/makedoc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 2 additions & 3 deletions source/arduino/astronomy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
MIT License
Copyright (c) 2019-2023 Don Cross <[email protected]>
Copyright (c) 2019-2024 Don Cross <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -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)
{
Expand All @@ -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. */
Expand Down

0 comments on commit 3333da1

Please sign in to comment.