Commit graph

11 commits

Author SHA1 Message Date
Marti Bolivar 819a2404ca Assert LeafLabs copyright in wirish/Print.cpp.
This should get replaced with a clean-room MIT licensed version, but
pieces of it are ours (notably the bugfixes to the floating point
printing routines), so might as well do the copyright thing.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-05-31 18:55:44 -04:00
Marti Bolivar 954f9e5065 Move public headers to include directories; related cleanups.
Move libmaple/*.h to (new) libmaple/include/libmaple/. The new
accepted way to include a libmaple header foo.h is with:

    #include <libmaple/foo.h>

This is more polite in terms of the include namespace. It also allows
us to e.g. implement the Arduino SPI library at all (which has header
SPI.h; providing it was previously impossible on case-insensitive
filesystems due to libmaple's spi.h).

Similarly for Wirish.

The old include style (#include "header.h") is now deprecated.

libmaple/*.h:

- Change include guard #defines from _FOO_H_ to _LIBMAPLE_FOO_H_.
- Add license headers where they're missing
- Add conditional extern "C" { ... } blocks where they're missing
  (they aren't always necessary, but we might was well do it against
  the future, while we're at it.).
- Change includes from #include "foo.h" to #include <libmaple/foo.h>.
- Move includes after extern "C".
- Remove extra trailing newlines

Note that this doesn't include the headers under libmaple/usb/ or
libmaple/usb/usb_lib. These will get fixed later.

libmaple/*.c:

- Change includes from #include "foo.h" to #include <libmaple/foo.h>.

Makefile:

- Add I$(LIBMAPLE_PATH)/include/libmaple to GLOBAL_FLAGS.  This allows
  for users (including Wirish) to migrate their code, but should go
  away ASAP, since it slows down compilation.

Wirish:

- Move wirish/**/*.h to (new) wirish/include/wirish/.  This ignores
  the USB headers, which, as usual, are getting handled after
  everything else.

- Similarly generify wirish/boards/ structure. For each supported
  board "foo", move wirish/boards/foo.h and wirish/boards/foo.cpp to
  wirish/boards/foo/include/board/board.h and
  wirish/boards/foo/board.cpp, respectively. Also remove the #ifdef
  hacks around the .cpp files.

- wirish/rules.mk: put wirish/boards/foo/include in the include path
  (and add wirish/boards/foo/board.cpp to the list of sources to be
  compiled). This allows saying:

      #include <board/board.h>

  instead of the hack currently in place. We can allow the user to
  override this setting later to make adding custom board definitions
  easier.

- Disable -Werror in libmaple/rules.mk, as the current USB warnings
  don't let the olimex_stm32_h103 board compile. We can re-enable
  -Werror once we've moved the board-specific bits out of libmaple
  proper.

libraries, examples:

- Update includes accordingly.
- Miscellaneous cosmetic fixups.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:50 -04:00
Marti Bolivar 5c847fda31 Update Print to match Arduino master.
Add base argument to integral Print methods, defaulting to DEC so as
not to break backwards compatibility.  Add precision argument to
floating-point Print methods.

These changes increase compatibility with the Arduino Print
implementation.
2011-06-08 16:39:04 -04:00
Marti Bolivar e7d5f4c167 SerialUSB fixups. 2011-05-04 13:31:53 -04:00
Marti Bolivar 842096ba35 Minor Print cleanups. 2011-04-25 18:02:10 -04:00
Marti Bolivar f72d2948a8 Compromise Print implementation.
The users really hated the code size requirements for an snprintf()-based
Print implementation, but I really hated how bad the old implementation was.

Revised version fixes bugs related to printing 64-bit values and has some
improved behavior when it comes to printing doubles.  Now, instead of
happily printing garbage values when large doubles are printed, we try
printing "<large double>" or "-<large double>" (depending on sign) when
the argument is too big for the old strategy to accommodate.
2011-04-12 17:44:27 -04:00
Marti Bolivar b99df81845 Reverting "Rewrote Print class."
This reverts commit 8bd3cebbee.
2011-04-12 17:25:51 -04:00
Marti Bolivar 8bd3cebbee Rewrote Print class.
The old Print class couldn't print uint64 values, and featured
hand-hacked functionality better handled by snprintf().  Redid it
using snprintf(), using "[u]int[8,16,32,64]" types for more clarity,
and eliminated some private methods in favor of auxiliary functions in
Print.cpp.

Breaking compatibility with original implementation in three ways:

  - Print::print(double) is now accurate to 6 digits, rather
    than 2; this is consistent with the default behavior of the %f
    format specifier, and if you're using floating point, it's slow
    enough that you probably want the increased accuracy.

  - The only bases you can print a number to are 2, 8, 10, and
    16.  8, 10, and 16 already have format specifiers, and 2 is an
    important special case; others complicate matters unnecessarily.

  - Printing numbers in bases other than 10 treats them as
    unsigned quantities (i.e., won't print '-' characters).  This is
    more consistent with C++'s behavior for hexadecimal and octal
    literals (e.g., 0xFFFFFFFF has type uint32).

Updated HardwareSerial and USBSerial class documentation to reflect
the new behavior.
2011-02-24 15:45:41 -05:00
Marti Bolivar 849bc0f8f6 wirish reformatted and code-styled 2010-09-26 21:47:55 -04:00
Perry Hung 88d4b095e4 Preliminary wirish USBSerial implementation.
-updated examples
-removed HardwareUSB
-cleaned up a handful of includes
2010-06-04 00:43:21 -04:00
Perry Hung 62552a6f3f Refactoring:
The 'core' directory has now been renamed to 'wirish.' Wirish is our
version of the Arduino Wiring language.
2010-04-25 18:08:56 -04:00
Renamed from core/Print.cpp (Browse further)