Cosa: An Object-Oriented Platform for Arduino programming

Some news on the latest Cosa updates:

  1. Updated RFM69W/HW device driver
    Interface: https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/Wireless/Driver/RFM69.hh

  2. Support for LCD ST7920
    First iteration of support for Graphical and Character based LCD ST7920. Character based (16x4) only in this release.
    Interface: https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/LCD/Driver/ST7920.hh

  3. Support for LowPowerLab Moteino
    Board definition: https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/Board/LowPowerLab/Moteino.hh
    Arduino IDE: https://github.com/mikaelpatel/Cosa/blob/master/boards/lowpowerlab.txt
    The Wireless example sketches work with Moteino and RFM69.

  4. Unsigned integer counter wrap around handling
    Improved support for timer (Watchdog/RTC::since) wrap around handling.
    Example: Cosa/CosaDiff.ino at master · mikaelpatel/Cosa · GitHub
    Interface: Cosa/Watchdog.hh at master · mikaelpatel/Cosa · GitHub, https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/RTC.hh#L84
    Usage pattern:

// Capture start time 
static const uint32_t TIMEOUT = ....; 
uint32_t start = RTC::millis();
...
// Check elapsed time
if (RTC::since(start) < TIMEOUT) {
  ...
}

Example usage: https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/Wireless/Driver/RFM69.cpp#L228

  1. New Wireless example sketches; Ping-Pong
    Demonstrate simple retransmission of messages. CosaWirelessPing will send a sequence number to CosaWirelessPong which increments the received number before sending it back. The message is retransmitted if a reply is not received within a time-limit.
CosaWirelessPing: started

ping:nr=0,pong:nr=1
ping:nr=1,pong:nr=2
ping:nr=2,retry,pong:nr=3
ping:nr=3,pong:nr=4
ping:nr=4,retry,retry,retry,retry,retry,retry,pong:nr=5
ping:nr=5,pong:nr=6
ping:nr=6,pong:nr=7
...

Cheers!

Hi,

first off, thumbs up for all the quality work put into Cosa, this is really impressive!

I wonder if there are some guidelines for people who would want to contribute to the project (e.g. preferred tools and settings for these tools), and possibly some tips about it. Also, I am not completely clear about the way new source files should be organized.

I am currently developing a few classes to manage MAX7219/7221 IC (LED display drivers with a serial interface, like SPI).

I have got inspiration from Cosa LCD and could already reach some success (for the moment, I published my work on arduino-projects/CosaMax7219 at master · jfpoilpret/arduino-projects · GitHub); it integrates well with Cosa IOStream.

jfpoilpret:
Hi, first off, thumbs up for all the quality work put into Cosa, this is really impressive!

@jfpoilpret
Thanks for your kind words. I hope you find the going development inspiring.

jfpoilpret:
I wonder if there are some guidelines for people who would want to contribute to the project (e.g. preferred tools and settings for these tools), and possibly some tips about it. Also, I am not completely clear about the way new source files should be organized.

There are no required tools other than the Arduino IDE for building, upload and testing. I use GNU Emacs and basic Linux tools. Standard C/C++ Emacs mode setting (2 character indent). The only thing extra in my .emacs settings is:

(setq auto-mode-alist (cons '("\\.\\(pde\\|ino\\)$" . c++-mode) auto-mode-alist))

It is possible to contribute to Cosa as any other Arduino software; as libraries or simply source code. The Cosa repository is not open but you can still clone/fork and do pull requests. Normal git style.

I should add a list of contributed Cosa libraries with links to their repositories on the Cosa github README page. Will put that on the to-do-list.

jfpoilpret:
I am currently developing a few classes to manage MAX7219/7221 IC (LED display drivers with a serial interface, like SPI).
I have got inspiration from Cosa LCD and could already reach some success (for the moment, I published my work on arduino-projects/CosaMax7219 at master · jfpoilpret/arduino-projects · GitHub); it integrates well with Cosa IOStream.

Fun! It is really interesting to see that you have been able to produce a driver with the limited documentation available. And reuse a fair amount of code.

That driver was actually something I have on the summer to-do-list. Waiting for an LCD board from ebay ;-). I was planning to add MAX7219/7221 simply as yet another implementation of the Cosa LCD interface. Looks like you have added an extra class level instead of using LCD::Driver as the base class. The LCD::IO adapters can be used directly. That would make it much simpler, less code, and follows the Cosa design style with an abstract interface and adapter pattern.

Your font handling was an interesting approach. I hadn't come so far to considering this issue.

Cheers!

Thanks for your answer.

There are no required tools other than the Arduino IDE for building, upload and testing. I use GNU Emacs and basic Linux tools. Standard C/C++ Emacs mode setting (2 character indent).

I don't use Arduino IDE / emacs, for development but Eclipse with Arduino plugin from @jantje; I'll have to prepare the setup accordingly.

Looks like you have added an extra class level instead of using LCD::Driver as the base class. The LCD::IO adapters can be used directly. That would make it much simpler, less code, and follows the Cosa design style with an abstract interface and adapter pattern.

The reason why I have used an extra class level for handling MAX7219 is due to the fact that you can chain several of these IC through the same wires (SPI or Serial3W), which means you can potentially use the same SPI for different LED circuits, you can even imagine having one circuit with 8 7-segment digits, one circuit with an 8x8 LED matrix, and 2 circuits for a total of 16 7-segment digits driven as its own IOStream. I felt that the current LCD::Driver/IO design could not work for this special situation.
Note that my current work does not yet allow combining 2 or more chained 7219/7220 in a single IOStream device, I still need to infer about the proper way to implement this.

Your font handling was an interesting approach. I hadn't come so far to considering this issue.

Regarding font handling, I chose the most compact way I could find (in terms of memory usage), since anyway, with 7 segments only, it is just impossible to represent every single ASCII character. So the rationale was to use the best possible representation for each alphabetic character, not caring about its case (you are already glad when you can represent a "t" on 7 segments, why try to represent a "T" that would not look like a "T"?) On top of that I added a few special characters that I found could be easily represented on 7 segments, that is all.

That driver was actually something I have on the summer to-do-list.

Good to know! I was not sure people could still be interested in old style 7-segment LED displays :slight_smile:

By the way, I am new to this forum, so please bear with me if I don't use the post editor perfectly yet, that will come after a while.

Cheers

At work we have a lot of experience with code quality metrics and the relation with software maintenance and software realibility. Maintenance costs are calculated using these code metrics: the better the code, the easier to maintain and the lower the costs.

As Cosa is imho quality wise a step-up compared to most of the libraries out there for Arduino, I wondered what the statistiscal metrics and quality of this package is XD So I downloaded the current Cosa package and ran it through some analysis with the following overall very satisfying result I must say mr. Kowalski!

The most widespread and valuable method but also one of the least understood methods is McCabes' Cyclomatic Complexity.

Cyclomatic complexity is defined as measuring “the amount of decision logic in a source code function” where higher numbers are “bad” and lower numbers are “good”. Simply put the more decisions that have to be made in code, the more complex it is. We use cyclomatic complexity to get a sense of how hard any given code may be to test, maintain, enhance, refactor or troubleshoot as well as an indication of how likely the code will be to produce errors.

The complexity of the source code is described by a number. That number defines the risk of the module and is defined by the the Software Engineering Institute, as follows:

Cyclomatic Complexity Risk Evaluation
1-10 A simple module without much risk
11-20 A more complex module with moderate risk
21-50 A complex module of high risk
51 and greater An untestable program of very high risk

We always strive for any number below 10 as it has proven to be the easiest to maintain and debug. The largest number I have had so far is 85. This software has proven over 1 year maintenance to be very, very, very hard to modify and almost impossible to test.

So how does Cosa 'perform' code metrics wise?

As you can see Cosa contains 163 files with a total of 20.564 lines. Of these lines, 21% is comment (about 4.380 lines), 20% are branch statements (about 4.215 lines) and 9.933 lines contain normal statements.

If I zoom in to the quality metrics, I get the following Kiviat Graph where green = ok and above or below that green band means that that quality metric has a value that should be investigated further:

The general impression is good: 5 of the 7 quality metrics are within the green band, 1 (Max Depth) is just outside this band, and one - Max (Cyclomatic) Complexity - is with a value of 39 far outside the required bandwith which should be investigated further.

The next list shows the modules that are outside the Max Complexity value of 10. It also shows the modules average complexity. What we see is that the number of modules with a higer than wanted complexity is not very high, but that the average complexity of some of these modules is also to high: in other words, it is not just one function that has a high complexity.

I took just 3 different modules to show the metrics for the MQTT, TWI and Menu modules to get an idea what is causing this high complexity and depth.
Menu:


The Menu module is by far the worst module ]:smiley: All metrics are OUTSIDE the green band!
The worst offender is the Menu::Walker::on_key_down() method which scores the highest on both Complexity (39) and block depth (7). The method contains nested switch statements and a lot of decision logic causing these high complexity and depth numbers.

MQTT:


The MQTT module scores high on statememts per method and on both average and maximum complexity. The worst offender is the MQTT::Client::publish() method that scores the highest on both Complexity (24) and block depth (4). Again a large switch statement seems to be responsible for the high complexity and depth.

TWI:


The last module, TWI, scores good on all metrics except for the maximum complexity. The worst offender is the ISR() method that scores the highest on both Complexity (34) and block depth (4). Again a large switch statement seems to be responsible for the high complexity and depth.

These three examples show that (large) switch statements are responsible for most of the high complexity and depth.
I haven't analysed in depth if these modules could be refactored to increase quality metrics or that these metrics are just the way they are: there is no other choice to implement this functionality! I hope kowalski can shed a light on this issue :zipper_mouth_face:

Summerized: Cosa shows that there is high quality software in the Arduino world. The full object oriented approach and the constant refactoring that kowalski does are no doubt some of the reasons behind these good code metrics results.

I did like Cosa already, but now even more :grin:

@MarsWarrior

Great analysis and fun to see that you are using the same tool as I do for Software Quality Analysis - SourceMonitor, SourceMonitor. This is a great open-source tool.

I also use the data collected from Ohloh, https://www.ohloh.net/p/cosa. Here you can get a picture of the "commitment" behind Cosa also the estimation of the effort and development cost. The Ohloh code browser is just great. http://code.ohloh.net/file?fid=mVgoe27AUP5UxXPqMApmnvc6trQ&cid=a76NbRQjUKM&s=&fp=499294&projSelected=true#L0

As you may see there is a difference in the KLOC count. No big deal but I guess that you have only looked at *.cpp files? If you include *.hh, *.h and *.c the total number of lines and files is somewhat larger :D. Including all the example sketches Cosa is well over 100 KLOC (commented source code).

I use several programming techniques to reduce complexity; basically try to reduce to a "straight block" of code. I use SourceMonitor to keep a list of class/functions that should be refactored due to high complexity. Some complexity is motivated such as the switch/case blocks that give high complexity levels but are kept if the complexity per case is low. Some of them need to be refactored to an additional function level. And others refactored to classes to remove the switch all together.

Small scale embedded systems with low memory resources and moderate processor speed give a very thin line to balance complexity, performance, and memory footprint together with readability and maintainability. At the same time Cosa tries to achieve high variability and support a large number of AVR MCUs (ATtinyX5 up to ATmega2560) and boards both Arduino(TM) and clones (Anarduino, Microduino, Moteino, Pinoccio and Teensy). This is the real challenge!

With 10 years research and teaching at University followed by over 25 years in Industry I have had the opportunity to test and evaluate a number of programming paradigms, languages, and development tools and methods. This gives a slight advantage.

Thanks for your effort and putting focus on software quality.

Cheers!

Time for some news on the latest Cosa updates:

  1. RFM69W/HW device driver improvements.
    a. New member function for temperature reading.
    b. New member function for RC oscillator calibration.
    https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/Wireless/Driver/RFM69.hh#L182

  2. CC1101 device driver improvements.
    a. SPI burst read and write for send/recv.
    https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/Wireless/Driver/CC1101.cpp

  3. Board support for Anarduino MiniWireless
    Below device drivers for RTCC and Flash to support resources on MiniWireless boards.

    One of the best price-performance-functionality Arduino clone board with Wireless, RTC and Flash support (in micro format). Anarduino MiniWireless Details

  4. New MCP7940N Real-Time Clock/Calendar (RTCC) device driver.
    http://ww1.microchip.com/downloads/en/DeviceDoc/20005010F.pdf
    https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/TWI/Driver/MCP7940N.hh
    NB: This is ongoing work. Will be extended with alarm interrupt handler.

  5. New S25FL127S 128 Mbit (16 Mbyte) SPI Flash device driver.
    Information - Infineon Technologies
    https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/SPI/Driver/S25FL127S.hh
    NB: This is ongoing work. A file/object store system will be needed for the 16 Mbyte available. A possible refactoring to the SD interface to allow FAT16 file system on Flash device.

Cheers!

kowalski:
4. New MCP7940N Real-Time Clock/Calendar (RTCC) device

  1. New S25FL127S 128 Mbit (16 Mbyte) SPI Flash device driver.

Great. I just finished a board with these chips. Are the MCP7941 and MCP7942 also supported?

MarsWarrior:
Great. I just finished a board with these chips. Are the MCP7941 and MCP7942 also supported?

@MarsWarrior

Do you mean MCP7941X (X=0,1,2)? They have an EEPROM. Do you have a link to the Data Sheet?

I am working on support for the devices on the Anarduino MiniWireless board. Don't have any board with those but it looks like the Cosa EEPROM driver could be adapted.

Cheers!

kowalski:

MarsWarrior:
Great. I just finished a board with these chips. Are the MCP7941 and MCP7942 also supported?

@MarsWarrior

Do you mean MCP7941X (X=0,1,2)? They have an EEPROM. Do you have a link to the Data Sheet?

I am working on support for the devices on the Anarduino MiniWireless board. Don't have any board with those but it looks like the Cosa EEPROM driver could be adapted.

Cheers!

Ah yes. My mistake. Always mix those chips... I do mean the MCP79411 with EUI-48 unique id!
See attached datasheet.

FYI:
S25FL dataflash Library:· GitHub - BleepLabs/S25FLx: S25FLx serial flash Arduino library
MCP7941x RTC Library:· GitHub - ichilton/mcp7941x_arduino: Arduino Library for the Microchip MCP7941x Real Time Clock IC's

RTC - MCP7941x (22266A).pdf (417 KB)

@MarsWarrior

Thanks for all the info and especially the links. Always great to have a look at other implementations and approaches.

My guess on the MCP79141X device was not that bad. It is basically a MCP7940N with an EEPROM (128 bytes), an ID and some security register setup sequencing. The Cosa EEPROM driver for AT24CXX has the same I2C address (0x5X) and could be used for the EEPROM part. The security sequencing will need some tweaking.
https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/TWI/Driver/AT24CXX.hh

Cheers!

Some news on the latest Cosa updates:

  1. TCS230 color sensor device driver
    Interface: https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/Driver/TCS230.hh
    Example: https://github.com/mikaelpatel/Cosa/blob/master/examples/Sandbox/CosaTCS230/CosaTCS230.ino

  2. Arduino String class
    Refactoring of the Arduino String class and support for Cosa IOStream output operator with String.
    Interface: https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/String.hh
    Example: Cosa/CosaString.ino at master · mikaelpatel/Cosa · GitHub

  3. Removed offsetof() macro warning
    Older version of AVR GCC will give warnings on usage of offsetof() macro.
    Cosa/Types.h at master · mikaelpatel/Cosa · GitHub

  4. MCP7940N Alarm interrupt handler and example sketch
    The device driver supports alarm interrupts so that the MCU can power-down and wake up on a RTCC alarm. Both device alarms may be used to trigger a wake up. The device driver has been tested on Anarduino MiniWireless. A new example sketch is available. https://github.com/mikaelpatel/Cosa/blob/master/examples/Time/CosaMCP7940N/CosaMCP7940N.ino

  5. Breaking the 30 KLOC barrier
    The Cosa source code repository is 30+ KLOC without comments and 58+ KLOC with comments. This does not include the 150+ example sketches. Please see Ohloh for more details. https://www.ohloh.net/p/cosa

Cheers!

Just a question @kowalski:
As my intention is to base all my nodes on Cosa, some additional chip & functional support should be added to the Cosa eco system :blush:

I guess the best way to make that visible is to add an issue on GitHub for each chip and/or function??

MarsWarrior:
As my intention is to base all my nodes on Cosa, some additional chip & functional support should be added to the Cosa eco system :blush:
I guess the best way to make that visible is to add an issue on GitHub for each chip and/or function??

@MarsWarrior

That sounds like a good idea. The issue list on github is the right place for that.

There are a few things to consider. At this stage Cosa is not a commercial product or project as Arduino. There is no license, no registration, and no release handling with maintenance. The idea is to collaborate and build an industry strength high quality fully OOP alternative to the Arduino codebase. If and when we reach critical mass the next stage will offer release and maintenance.

For now anybody may contribute by building and test, writing code, donating hardware, giving improvement suggestions, etc. Contributing code requires normal open source git handling; clone/fork and pull request. The contributed code should follow the coding standard and must have test and/or example code. Contributed code will follow the normal refactoring of Cosa. The high level of refactoring right now is also part of the current stage.

Easiest way to get new device drivers is to contribute hardware. This is important even when contributing code to the main repository. It is difficult to add code that cannot be tested. This will need a lot of convincing :-).

Cheers!

x iscrizione

The latest Cosa update includes porting and configuration of the Arduino-Makefile GitHub - sudar/Arduino-Makefile: Makefile for Arduino sketches. It defines the workflows for compiling code, flashing it to Arduino and even communicating through Serial.. This allows simple build using "traditional" make files. To get started simply configure the build template with your Arduino installation path (Cosa/Cosa.mk at master · mikaelpatel/Cosa · GitHub) and write a three line makefile in the same directory as the sketch.

COSA_DIR = $(HOME)/Sketchbook/hardware/Cosa
BOARD_TAG = duemilanove
include $(COSA_DIR)/build/Cosa.mk

The COSA_DIR variable is the path of the Cosa installation. The BOARD_TAG is the type of board to build the sketch for. The possible board tags are:

BOARD_TAG		DESCRIPTION
================================================================================
miniwireless		Cosa Anarduino MiniWireless (ATmega328/BOOT_168)
duemilanove		Cosa Arduino Duemilanove (ATmega328/BOOT_168)
leonardo		Cosa Arduino Leonardo (ATmega32U4/Caterina)
mega			Cosa Arduino Mega (ATmega2560/STK500v2)
nano			Cosa Arduino Nano (ATmega328/BOOT_168)
pro-micro		Cosa Arduino Pro Micro (ATmega32U4/Caterina)
pro-mini		Cosa Arduino Pro Mini (ATmega328/BOOT_168)
pro-mini-8		Cosa Arduino Pro Mini (ATmega328/BOOT_168, 3.3V, 8 MHz)
uno			Cosa Arduino Uno (ATmega328/Optiboot)
attiny84-8		Cosa Breadboard (ATtiny84, 8 MHz internal clock)
attiny85-8		Cosa Breadboard (ATtiny85, 8 MHz internal clock)
attiny861-8		Cosa Breadboard (ATtiny861, 8 MHz internal clock)
atmega328-8		Cosa Breadboard (ATmega328, 8 MHz internal clock)
mighty			Cosa Breadboard (ATmega1284/BOOT_1284P)
mighty-opt		Cosa Breadboard (ATmega1284/Optiboot)
lilypad			Cosa LilyPad Arduino (ATmega328/BOOT_168, 8 MHz)
lilypad-usb		Cosa LilyPad Arduino USB (ATmega32U4/Caterina, 8 MHz)
moteino			Cosa LowPowerLab Moteino (ATmega328/DualOptiboot)
microduino-core		Cosa Microduino-Core (ATmega328/Optiboot)
microduino-core32u4	Cosa Microduino-Core32u4 (ATmega32U4/Caterina)
microduino-core-plus	Cosa Microduino-Core+ (ATmega644P/Optiboot)
pinoccio		Cosa Pinoccio Scout (ATmega256RFR2/STK500v2)
teensy-2_0		Cosa Teensy 2.0 (ATmega32U4/halfkay)
teensypp-2_0		Cosa Teensy++ 2.0 (AT90USB1286/halfkay)

Build, upload and monitor the sketch with the following command.

make upload monitor

The Cosa Arduino-Makefile uses miniterm.py as serial monitor. The exit command is CTRL-ALT GR ]

Build for another board by either changing the BOARD_TAG in the Makefile or simply giving the command:

make "BOARD_TAG=uno"

More details in the Cosa/build directory and on the original Arduino-Makefile site. Please see the example makefiles in the CosaBlink and CosaBenchmarkPins directories.

Cheers!

Command line build of Cosa based sketches is now as easy as it gets. A new shell script (cosa) eliminates the need for makefiles. Used as follows:

cosa BOARD COMMAND

Where BOARD is one of the BOARD_TAGs and COMMAND is what is passed to make (Arduino-Makefile). Typical usage are:

  1. Some basic instructions on how to use the tool and make targets.
user@host:~/Sketchbook/hardware/Cosa/examples/Blink/CosaBlink$ cosa help
Available targets (default is compile the code):
  upload            - upload
  ispload           - upload using an ISP
  raw_upload        - upload without first resetting
  eeprom            - upload the eep file
  raw_eeprom        - upload the eep file without first resetting
  clean             - remove all our dependencies
  depends           - update dependencies
  reset             - reset the Arduino by tickling DTR or changing baud
                      rate on the serial port.
  boards            - list all the boards defined in boards.txt
  config            - list configuration
  monitor           - connect to the Arduino's serial port
  size              - show the size of the compiled output (relative to
                      resources, if you have a patched avr-size).
  verify_size       - verify that the size of the final file is less than
                      the capacity of the micro controller.
  symbol_sizes      - generate a .sym file containing symbols and their
                      sizes.
  disasm            - generate a .lss file that contains disassembly
                      of the compiled file interspersed with your
                      original source code.
  generate_assembly - generate a .s file containing the compiler
                      generated assembly of the main sketch.
  burn_bootloader   - burn bootloader and fuses
  set_fuses         - set fuses without burning bootloader
  help_vars         - print all variables that can be overridden
  avanti            - short cut for upload and monitor
  help              - show this help
More details in:
/home/user/Sketchbook/hardware/Cosa/build/Arduino-Makefile/Arduino.mk
/home/user/Sketchbook/hardware/Cosa/build/Cosa.mk
  1. Get the current configuration.
user@host:~/Sketchbook/hardware/Cosa/examples/Blink/CosaBlink$ cosa uno config
-------------------------
Arduino.mk Configuration:
- [AUTODETECTED]       CURRENT_OS = LINUX 
- [USER]               ARDMK_DIR = /home/user/Sketchbook/hardware/Cosa/build/Arduino-Makefile 
- [USER]               ARDUINO_DIR = /home/user/opt/arduino-1.0.5 
- [AUTODETECTED]       ARDUINO_VERSION = 105 
- [AUTODETECTED]       ARDUINO_PREFERENCES_PATH = /home/user/.arduino/preferences.txt 
- [AUTODETECTED]       ARDUINO_SKETCHBOOK = /home/user/Sketchbook (from arduino preferences file)
- [BUNDLED]            AVR_TOOLS_DIR = /home/user/opt/arduino-1.0.5/hardware/tools/avr (in Arduino distribution)
- [COMPUTED]           ARDUINO_LIB_PATH = /home/user/opt/arduino-1.0.5/libraries (from ARDUINO_DIR)
- [USER]               ARDUINO_CORE_PATH = /home/user/Sketchbook/hardware/Cosa/cores/cosa 
- [USER]               ARDUINO_VAR_PATH = /home/user/Sketchbook/hardware/Cosa/variants 
- [USER]               BOARDS_TXT = /home/user/Sketchbook/hardware/Cosa/boards.txt 
- [DEFAULT]            USER_LIB_PATH = /home/user/Sketchbook/libraries (in user sketchbook)
- [DEFAULT]            PRE_BUILD_HOOK = pre-build-hook.sh 
- [USER]               BOARD_TAG = uno 
- [COMPUTED]           OBJDIR = build-uno (from BOARD_TAG)
- [ASSUMED]            MONITOR_BAUDRATE = 9600 
- [DEFAULT]            OPTIMIZATION_LEVEL = s 
- [DEFAULT]            MCU_FLAG_NAME = mmcu 
- [DEFAULT]            CFLAGS_STD = -std=gnu99 
- [AUTODETECTED]       DEVICE_PATH =  
- [AUTODETECTED]       Size utility: AVR-aware for enhanced output
- [COMPUTED]           BOOTLOADER_PARENT = /home/user/opt/arduino-1.0.5/hardware/arduino/bootloaders (from ARDUINO_DIR)
-------------------------
Please refer to /home/user/Sketchbook/hardware/Cosa/build/Arduino-Makefile/Arduino.mk for more details.
  1. Get a list of the available boards.
user@host:~/Sketchbook/hardware/Cosa/examples/Blink/CosaBlink$ cosa boards
atmega328-8           Cosa Breadboard (ATmega328, 8 MHz internal clock)
attiny84-8            Cosa Breadboard (ATtiny84, 8 MHz internal clock)
attiny85-8            Cosa Breadboard (ATtiny85, 8 MHz internal clock)
attiny861-8           Cosa Breadboard (ATtiny861, 8 MHz internal clock)
duemilanove           Cosa Arduino Duemilanove (ATmega328/BOOT_168)
leonardo              Cosa Arduino Leonardo (ATmega32U4/Caterina)
lilypad               Cosa LilyPad Arduino (ATmega328/BOOT_168, 8 MHz)
lilypad-usb           Cosa LilyPad Arduino USB (ATmega32U4/Caterina, 8 MHz)
mega                  Cosa Arduino Mega (ATmega2560/STK500v2)
microduino-core32u4   Cosa Microduino-Core32u4 (ATmega32U4/Caterina)
microduino-core       Cosa Microduino-Core (ATmega328/Optiboot)
microduino-core-plus  Cosa Microduino-Core+ (ATmega644P/Optiboot)
mighty                Cosa Breadboard (ATmega1284/BOOT_1284P)
mighty-opt            Cosa Breadboard (ATmega1284/Optiboot)
miniwireless          Cosa Anarduino MiniWireless (ATmega328/BOOT_168)
moteino               Cosa LowPowerLab Moteino (ATmega328/DualOptiboot)
nano                  Cosa Arduino Nano (ATmega328/BOOT_168)
pinoccio              Cosa Pinoccio Scout (ATmega256RFR2/STK500v2)
pro-micro             Cosa Arduino Pro Micro (ATmega32U4/Caterina)
pro-mini-8            Cosa Arduino Pro Mini (ATmega328/BOOT_168, 3.3V, 8 MHz)
pro-mini              Cosa Arduino Pro Mini (ATmega328/BOOT_168)
uno                   Cosa Arduino Uno (ATmega328/Optiboot)
  1. Build the CosaBenchmarkPins sketch for Arduino Uno, upload and start the serial monitor.
user@host:~/Sketchbook/hardware/Cosa/examples/Benchmarks/CosaBenchmarkPins$ cosa uno avanti

To install this new build feature please either add Cosa/build to your PATH or symbolic link from you local bin directory to the build script $COSA_DIR/build/cosa. The default path for COSA_DIR is $HOME/Sketchbook/hardware/Cosa. You can set COSA_DIR as an exported environment variable.

To use GNU Emacs as the Cosa IDE simply use the command M-X compile with "cosa BOARD upload" (only needed the first time per session). You can directly move to any compile error with M-X goto-next-locus. Add the following to your .emacs file to allow bind compile-upload to F2 and goto-next-error to F3. The first line below will make GNU Emacs recognize .pde/.ino files as C++ and automatically switch to the correct mode.

(setq auto-mode-alist (cons '("\\.\\(pde\\|ino\\)$" . c++-mode) auto-mode-alist))
(global-set-key (quote [f2]) (quote compile))
(global-set-key (quote [f3]) (quote goto-next-locus))

Below is an example of compiling the CosaBlink example sketch with a bad modification and stepping to the error line (F2 and F3).

GNU Emacs will help you with indentation, quick incremental search, color coding comments, etc. Together with the new Cosa build script GNU Emacs gives a productive IDE for Arduino programming that is easy to customize.

The Arduino version is configured in the file Cosa/build/Cosa.mk. There is support for the following Arduino versions; 1.0.5, 1.5.6-r2 and the nightly build with GCC 4.8.1.

Cheers!

The latest update of Cosa includes a device driver for MAX7219/MAX7221 Serially Interfaced, 8-digit LED Display Drivers.

The device driver implements the Cosa LCD/IOStream::Driver interface. It handles carriage-return-line-feed, backspace, alert, horizontal tab and form-feed. The period character is translated to the 7-segment LED decimal point of the previous written character. The example sketch (https://github.com/mikaelpatel/Cosa/blob/master/examples/LCD/CosaMAX72XX/CosaMAX72XX.ino) shows how to output floating-point numbers to a Cosa IOStream.

Cheers!

Ref.
Interface: https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/LCD/Driver/MAX72XX.hh
Source: https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/LCD/Driver/MAX72XX.cpp

The latest update of the Cosa command line build script adds support for attiny devices. The below example command line will build the CosaBlink sketch for an ATtiny84 (internal clock 8 MHz) and upload with ISP device on the given port.

user@host:~/Sketchbook/hardware/Cosa/examples/Blink/CosaBlink$ cosa attiny84-8 ispload ISP_PORT=/dev/ttyACM0

The command "cosa boards" lists the devices that require ISP device upload as "Cosa Breadboard" with the MCU and clock type/frequency. The default ISP device is defined as "arduino:arduinoisp" in the Cosa/boards.txt file.

The latest update also includes an updated version of miniterm.py (serial monitor) so that 1) the board may signal shutdown of the serial monitor and 2) LF/CR is handled correctly both for RX and TX to the board. The shutdown signal is used by the Cosa ASSERT macro and the Trace::fatal_P() member function on error detect. The ASSERT error message uses the same format as GCC compiler errors and warnings so that the M-X goto-next-locus (F3) command can be used in GNU Emacs to directly step to the ASSERT code line.

Cheers!

Hello, I hope this is right place to ask the question. I have Mega1280 board and I don't know what should I choose in tools/boards. In the arduino ide there is mega1280, what would be equivalent in cosa?
Kind Regards,
Adam