Pages: [1]   Go Down
Author Topic: How about to create an IO API (library) for Arduino?!  (Read 1469 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So I've been working on a project to create an IO API for Arduino. Something like the Java IO.

I was creating some libraries that deal with a sort of streams, like serial, eeprom and so on. And I felt that there is no library to deal with streams in general.

So I created one!

It's called ArduinoIO. I created a site with the documentation and the link to the github source code.

My wish is just share with you my library. Please feel free to comment, help, complain or just use!

The site is: www.arduinoio.com. Please take a look on it.

Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 124
Posts: 6652
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That looks ... rather heavyweight for a microcontoller with 32kbytes of memory.  How big is a sketch that uses your library for serial IO, compared to the normal Arduino serial/"print" driver?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sure, it will spend some extra bytes.

I created 2 sketches right now just to compare.

One just uses  an external eeprom driver, which is a very simple driver using Wire. Another uses an InputStream to read from the such driver.

The first: http://pastebin.com/y5U6y5ez
Uses 5692 bytes

The second one: http://pastebin.com/S6EX4NK7
Uses 6114 bytes

The overhead was 422 bytes.

 Of course, Arduino has only a few bytes of program memory. But my point is: In some projects, it's important to have some "contracts" about what kind of streams we are using.

For ex, I was creating a font format to write in a GLCD module; the "writer" (a driver to print chars on GLCD) needs to read the font bytes from somewhere and use it to print the char to the GLCD module. But the font bytes could be anywhere, like eeprom, external eeprom, memory, etc; so how can the "writer", generically, read it without care the source of the stream?

The IO library solved my problem, I just wrote different input streams, one for each source. And the driver must only know that it will read from a InputStream.

I spent some extra bytes but I won a lot in generality.

Sorry about my English, I'm learning... smiley-wink 

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Let me try to explain this a little better.

A few months ago I was working with a GLCD module.
Originally, I was using PIC microcontroller, cross-compiling with SDCC compiler.
Unfortunately it generates a huge final code.

So I decide to do it with Arduino. I created a little driver to draw
bitmap images and text on that GLCD module.

As you know, there are a lot of bitmap fonts and drivers out there. But
everyone has it's own way to organize such bitmaps, and it's own way to
read it. Usually they store the bitmap in the program memory.

A bitmap font usually is an array of bytes, such bytes are grouped to
represent a charactere in the GLCD display (glyph). Usually the groups
are sequentially stored, corresponding the ASCII table.

Considering this, I thought that my driver could be more generic. So I could
create a font format that works similar to the above approach, but doesn't
require to have all glyphs. The font could has only the used glyphs,
saving some memory.

(My bitmap font format: http://www.itisopensource.com/arduino/library/glcd/doc/html/classGlcdBitmapFont.html)

I started to write the font class and then I realized that I need to store the
font bitmap somewhere, and I also need to read it.

Whereas my goal was to make something generic, my solution about reading the
font bitmap need to be generic too.

So I created the IO library, firstly it had only InputStream and its
subclasses. I got excited and wrote a lot of more classes.
Logged

ottawa, canada
Offline Offline
God Member
*****
Karma: 6
Posts: 990
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can you show some simple examples of code using the library?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, I will write some examples tonight...

but first, just to avoid some mistakes,

is *not* a proposal to replace any of the already existing stream libraries such as Wire, Serial, Ethernet Client, Ethernet Server, SD

but *yes* to work above them.

Best Regards.
Logged

Pages: [1]   Go Up
Jump to: