Commit Graph

13 Commits

Author SHA1 Message Date
Markus Hitter e633222cd3 Make message/text sending aware of the sending destination.
Point of this change is to allow using these functions for
writing to the display, too, without duplicating all the code.

To reduce confusion, functions were renamed (they're no longer
'serial', after all:

  serwrite_xxx() -> write_xxx()
  sersendf_P()   -> sendf_P()

To avoid changing all the existing code, a couple of macros
with the old names are provided. They might even be handy as
convenience macros.

Nicely, this addition costs no additional RAM. Not surprising, it
costs quite some binary size, 278 bytes. Sizes now:

Program:  24058 bytes      168%       79%       38%       19%
   Data:   1525 bytes      149%       75%       38%       19%
 EEPROM:     32 bytes        4%        2%        2%        1%

Regarding USB Serial: code was adjusted without testing on
hardware.
2016-04-26 15:23:15 +02:00
Markus Hitter 6577578051 Display: introduce display_writechar().
You see where the journey is going? This is the equivalent to the
function to write a character to the serial line, so we can
basically swap these two in other functions.
2016-04-26 14:45:59 +02:00
Markus Hitter bb8d6e0ad2 Display: create and use display_set_cursor().
Having this in a seperate function will be helpful later.
2016-04-26 14:31:56 +02:00
Markus Hitter cec45a2fec Display: create infrastructure for distinct displays.
Dropped all the funtions for specific messages because plans on
how to handle this have changed.
2016-04-26 14:31:47 +02:00
Ruslan Popov e3fd9eaea7 Display: first text on OLED.
Note by Traumflug: this code was written by Ruslan Popov a lot
earlier already. I picked it to i2c_test.c to get "something"
visible running. This is the commit finally adjusted to the new
display infrastructure.
2016-04-26 14:29:36 +02:00
Markus Hitter 5f95784c0b Display: introduce font.h, paraphrase handling distinct fonts.
While this could also be done properly now, with a couple of
additional fonts, this would require quite some time. However,
it's more important to have at least one display working now,
rather than having a ton of sophisticated eye-candy, which isn't
even user-visible, because the upper layers are still missing.
2016-04-26 14:13:20 +02:00
Ruslan Popov cb696701f8 Display: add font 8x4 ASCII. 2016-04-26 14:13:20 +02:00
Markus Hitter a97ec8a376 Display: introduce displaybus.h.
This is a broker for mapping display bus calls to the bus actually
in use.
2016-04-26 14:13:15 +02:00
Markus Hitter 8e8946dd37 I2C: remove parameter 'address' from i2c_write().
As we usually talk to one device only, there's not much point in
carrying around the address all the time. Surprise, this saves
only 16 bytes binary size despite of heavy usage.
2016-04-20 21:15:11 +02:00
Markus Hitter aab447567c I2C: rewrite demo to use program memory.
Advantages are apparent: much less RAM usage.

$ avr-size -C --mcu=atmega1284p build/teacup.elf
AVR Memory Usage
----------------
Device: atmega1284p

Program:   23750 bytes (18.1% Full)
(.text + .data + .bootloader)

Data:       2053 bytes (12.5% Full)
(.data + .bss + .noinit)

EEPROM:       32 bytes (0.8% Full)
(.eeprom)

$ avr-size -C --mcu=atmega1284p build/teacup.elf
AVR Memory Usage
----------------
Device: atmega1284p

Program:   23720 bytes (18.1% Full)
(.text + .data + .bootloader)

Data:       1543 bytes (9.4% Full)
(.data + .bss + .noinit)

EEPROM:       32 bytes (0.8% Full)
(.eeprom)

A note about size reports: what 'make size' currently reports is
a bit misleading, because it doesn't count the .data section as
Flash usage. However, this section is actually written there as
it's the section which initialises RAM.
2016-04-20 21:15:11 +02:00
Markus Hitter 2298973343 I2C: distinguish between individual transmissions.
So far calling code had to wait long enough between individual
transmissions to make sure they end up in distinc ones. Now
calling code can stuff as fast as it wants, i2c_write() takes
care of the distinction.
2016-04-20 21:15:11 +02:00
Markus Hitter d088930664 I2C: use ringbuffer for data buffering.
This removes the need to write in full blocks, so data can be
sent from loops and/or program memory.

This capability allows to clear the screen without too much
effort, see i2c_test.c.

Still two weaknesses left:

 - Transmission end is currently detected by ringbuffer becoming
   empty, so delays are needed to make sure a transmission is
   completed before the next one is sent to the buffer.

 - Error handling is still only half existent. Any error on the
   bus will stop I2C entirely. A recovery strategy is required.

Sizes show, taking into account the additional screen clearing
code, no significant change:

    FLASH  : 23216 bytes
    RAM    :  2052 bytes
    EEPROM :    32 bytes
2016-04-20 21:15:11 +02:00
Ruslan Popov 619560c112 I2C: initial support.
This commit squashes in some fixes found after debugging on the
topic branch. Test code by Traumflug, collected from Ruslan's
code on the topic branch.

Before, same as now without I2C:

    FLASH  : 22408 bytes
    RAM    :  1393 bytes
    EEPROM :    32 bytes

Now with I2C:

    FLASH  : 23224 bytes
    RAM    :  2057 bytes
    EEPROM :    32 bytes

This totals to some 800 bytes with a whole lot of test code, so
implementation is pretty small :-)
2016-04-20 21:15:11 +02:00