For now this is a square root function which should solve entirely
in the preprocessor. Test results described in the file.
Test code for runtime results, inserted right before the main loop
in mendel.c:
for (uint32_t i = 0; i < 10000000; i++) {
uint32_t mathlib = (uint32_t)(sqrt(i) + .5);
uint32_t preprocessor = (uint32_t)(SQRT(i) + .5);
if (mathlib != preprocessor) {
sersendf_P(PSTR("%lu: %lu %lu\n"), i, mathlib, preprocessor);
break;
}
if ((i & 0x00001fff) == 0)
sersendf_P(PSTR("%lu\n"), i);
}
sersendf_P(PSTR("Square root check done.\n"));
Test code for compile time results:
sersendf_P(PSTR("10000000: %lu\n"), (uint32_t)SQRT(10000000));
sersendf_P(PSTR("10000000: %lu\n"), (uint32_t)sqrt(10000000));
sersendf_P(PSTR("20000000: %lu\n"), (uint32_t)SQRT(20000000));
sersendf_P(PSTR("20000000: %lu\n"), (uint32_t)sqrt(20000000));
sersendf_P(PSTR("30000000: %lu\n"), (uint32_t)SQRT(30000000));
sersendf_P(PSTR("30000000: %lu\n"), (uint32_t)sqrt(30000000));
sersendf_P(PSTR("40000000: %lu\n"), (uint32_t)SQRT(40000000));
sersendf_P(PSTR("40000000: %lu\n"), (uint32_t)sqrt(40000000));
sersendf_P(PSTR("50000000: %lu\n"), (uint32_t)SQRT(50000000));
sersendf_P(PSTR("50000000: %lu\n"), (uint32_t)sqrt(50000000));
sersendf_P(PSTR("60000000: %lu\n"), (uint32_t)SQRT(60000000));
sersendf_P(PSTR("60000000: %lu\n"), (uint32_t)sqrt(60000000));
sersendf_P(PSTR("70000000: %lu\n"), (uint32_t)SQRT(70000000));
sersendf_P(PSTR("70000000: %lu\n"), (uint32_t)sqrt(70000000));
sersendf_P(PSTR("80000000: %lu\n"), (uint32_t)SQRT(80000000));
sersendf_P(PSTR("80000000: %lu\n"), (uint32_t)sqrt(80000000));
sersendf_P(PSTR("90000000: %lu\n"), (uint32_t)SQRT(90000000));
sersendf_P(PSTR("90000000: %lu\n"), (uint32_t)sqrt(90000000));
##############################################################################
# #
# Teacup - lean and efficient firmware for RepRap printers #
# #
# by Triffid Hunter, Traumflug, jakepoz, Markus Hitter, many others #
# #
##############################################################################
For installation instructions, see
http://reprap.org/wiki/Teacup_Firmware#Simple_Installation and/or
http://reprap.org/wiki/Teacup_Firmware#Developer_Installation
For documentation, see
http://reprap.org/wiki/Teacup_Firmware
##############################################################################
# #
# This firmware is Copyright (c) ... #
# 2009 - 2010 Michael Moon aka Triffid_Hunter #
# 2010 - 2013 Markus "Traumflug" Hitter <mah@jump-ing.de> #
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 2 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program; if not, write to the Free Software #
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #
# #
##############################################################################