COSA
An Object-Oriented Platform for Arduino Programming
|
Cosa is an object-oriented platform for Arduino. It replaces the Arduino and Wiring library with a large set of integrated classes that support the full range of AVR/ATmega/ATtiny internal hardware modules; all pin modes, Digital, and Analog Pins, External and Pin Change Interrupts, Analog Comparator, PWM, Watchdog, Timer0/Timer2 (RTT), Timer1 (Servo/Tone), UART, USI, SPI, TWI and EEPROM.
Cosa is implemented as an Arduino IDE core. The Cosa platform can be used with almost all Arduino boards and ATtiny/ATmega processors. All classes may be compiled for all variants.
Though object-oriented with optional operator overloading syntax, Cosa is between 2-10X faster than Arduino with regard to digital pin functions. This comes with a small price-tag; memory, 4 bytes per digital pin and 9 bytes per analog pin. Cosa analog pin objects holds the latest sample, and allows an event and interrupt handler. See the benchmarks in the examples directory for further details.
Cosa contains several data streaming formats for message passing and data streaming. Google Protocol Buffers are supported together with a data streaming format (Ciao) for encoding of C/C++ language data types such as strings, integer and floating pointer numbers into a binary format. It may be used for a number of applications; tracing, remote procedure calls, data exchange between Arduino devices, etc. The format allows user data types to be defined and values exchanged without additional encoding. The stream header itself is a pre-defined serializable data type. Ciao is used to define an Arduino monitoring and control language (Cosa fai) which has much in common with Firmata.
The primary programming paradigm is object-oriented and state-machine/event driven with proto-threads or multi-tasking. There is a large number of device drivers available for SPI, I2C (TWI) and 1-Wire (OWI). A strict directory structure is used to organize the Cosa/driver source code. Sub-directories are used for each driver type. This allows a foundation for scaling and configuration.
Cosa uses the Arduino IDE and build system. Cosa classes are included with prefix, e.g. "Cosa/FileName.hh". It is possible to use both Arduino and Cosa functions together, though in some cases the Cosa objects may become inconsistent.
To improve debugging and testing there is assert/trace/syslog style support. The IOStream class allows output to both serial wire/wireless communication (UART/VWIO) and small TFT displays (such as the ST7735, ST7565, HD44780, and PCD8544). The Cosa LCD class extends IOStream::Device with additional common LCD functions. The Cosa LCD Menu class adds a simple framework for creating menu systems with program state such as integer ranges, bitsets and enumeration variables. All menu data structures are stored in program memory and the SRAM requirement is minimum. A macro set hides the details of creating the data structures in program memory.
The drawing Canvas class supports basic drawing operation and scripting to reduce program memory footprint. The Canvas class also supports drawing of icons and multiple fonts (GLCD and UTFT).
The popular VirtualWire library has been refactored to the object-oriented style of Cosa (VWI) and extended with three additional codecs; Manchester, 4B5B and Bitstuffing. This allows basic ultra cheap wireless nodes with RF315/433 receiver and transmitter. For more advanced wireless connections there is also drivers for the Nordic Semiconductor NRF24L01+ chip, the TI CC1101 Low-Power Sub-1 GHz RF Transceiver, and RFM69.
The goal of this project is to provide an efficient programming platform for rapid prototyping of "Internet-of-things"-devices. There is an Ethernet/Socket with W5100 Ethernet controller device driver. This implementation allows streaming direct to the device buffers. Cosa also implements a number of IP protocols; DNS, DHCP, NTP, HTTP, SNMP and MQTT.
Unfortunately Cosa is not a beginners entry level programming platform, though following some of the design patterns in Cosa will help beginners build more complex small scale embedded systems with richer concurrency and low power consumption.
Please follow the development of this project on the blog http://cosa-arduino.blogspot.se and on the Arduino forum, http://arduino.cc/forum/index.php/topic,150299.0.html.
"Ciao"; interjection hello!, goodbye!.
"Che cosa"; pronoun; what.
"Cosa"; noun thing, matter; pronoun; what?, what!.
"Cosa fai"; what do you do?
"Nucleo"; kernel.
"Rifare"; remake.
"Rete"; network.
"Tutto"; all.
ATtinyX4/X5/X61, Atmega328P, Atmega1284P, Atmega2560 and Atmega32u4 based Arduino boards (Uno, Mini, Mini Pro, Micro, Nano, Leonardo, LilyPad, LilyPad USB, Mighty, Mega, etc) are all supported.
Copyright (C) 2012-2015, Mikael Patel
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
This library 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA