<commit_before># mbeddr.arduino

## Background

This is a DSL to write programs for the [Arduino][ar] platform. It is based on the [mbeddr][mbddr] project which is an extensible C implementation in [JetBrains MPS][mps]. 

Currently this project nothing but a playground if offers some really limited support for the Arduino Uno and is likely to change and break stuff so this nothing you want to put you work on right now.

## Installation

### Prerequisites

Obviously you will need a working MPS and mbeddr installation. The current release version (1268) ob mbeddr is **not** supported! You will need to build mbeddr from source.

### Setup

You will need the following tools installed on you machine and available in your path.
These should be available for any platform, though I have only tested it on Mac and Linux

* [avr-gcc][avrgcc]
* [avr-libc][avrlibc]
* [avrdude][avrdude]

On most Linux distributions you will get all these when you install the following packages:

	avr-binutils avrdude avr-gcc avr-libc

You might also want to install 

	avr-gdb

But currently there is no support for direct debugging out of mbeddr.arduino!

### Get it

There is no binary distribution at this time, since changes are likely. So you need to clone this repository to get it via:

	git clone https://github.com/coolya/mbeddr.arduino.git

### Try it

After you have done this, open the `mbeddr.arduino.mpr` from the root of the repository. 
Build the solution, now should open your favorite shell and navigate to `solutions/arduino.samples/source_gen/arduino/samples/Blinker` from the root of the source code.

You will find the generated source code from the sample here which you can build with a simple

	make<commit_msg>new readme<commit_after># mbeddr.arduino

## Background

This is a DSL to write programs for the [Arduino][ar] platform. It is based on the [mbeddr][mbddr] project which is an extensible C implementation in [JetBrains MPS][mps]. 

Currently this project nothing but a playground if offers some really limited support for the Arduino Uno and is likely to change and break stuff so this nothing you want to put you work on right now.

## Installation

### Prerequisites

Obviously you will need a working MPS and mbeddr installation. The current release version (1268) ob mbeddr is **not** supported! You will need to build mbeddr from source.

### Setup

You will need the following tools installed on you machine and available in your path.
These should be available for any platform, though I have only tested it on Mac and Linux

* [avr-gcc][avrgcc]
* [avr-libc][avrlibc]
* [avrdude][avrdude]

On most Linux distributions you will get all these when you install the following packages:

	avr-binutils avrdude avr-gcc avr-libc

You might also want to install 

	avr-gdb

But currently there is no support for direct debugging out of mbeddr.arduino!

### Get it

There is no binary distribution at this time, since changes are likely. So you need to clone this repository to get it via:

	git clone https://github.com/coolya/mbeddr.arduino.git

### Build it

The `mbeddr.arduino` repository contains tow parts:

The first one is `mbeddr.arduino` itself which is a MPS plug-in that is using mbeddr. This plugin can be build two ways, directly from the MPS IDE or with `ant` from the command line. 

#### Building the plug-in with MPS

Open `mbeddr.arduino.mpr` from the root of the repository with MPS. If you are using mbeddr build from source you need to add a extra library to the project. To do so navigate to `File->Settings`, then select `Project Librariess` and add a new library named `mbeddr.core` that point to your mbeddr `code` directory **not** the mbeddr.ardunio directory. 
Now you can build the solution.

#### Building the plug-in with ant

This is the preferred way to build when you are using mbeddr [build from source](http://logv.ws/b/2013/04/27/installing-mbeddr-on-ubuntu-13-04/). First you need the `build.properties` file. You can used the skeleton `build.properties.example` in the root directory of the repository to create your own.

If should look like this:

	mps.home=/path/to/mps
	mps.platform.caches=/path/to/cache
	mbeddr.github.core.home=/path/to/mbeddr.core/root

Once you have done this you can run `ant` in the root of the repository and it should buil fine.

#### Building the support library

The second one is a support library that is used by the generated code to perform operations like accessing the analog inputs. This is done because the code needs some more complexity like loops and dealing with interrupts which would be a pain to express with generator templates. The code for this library is located in the `lib` [subdirectory](https://github.com/coolya/mbeddr.arduino/tree/master/lib).

To build it navigate to the `lib` folder of the repository and run `make` this will build the library for all supported platforms.

### Try it

Now open your favorite shell and navigate to `solutions/arduino.samples/source_gen/arduino/samples/Blinker` from the root of the source code.

You will find the generated source code from the sample here which you can build with a simple

	make
{'fraction_non_alphanumeric': 0.06235431235431235, 'fraction_numerical': 0.003885003885003885, 'mean_word_length': 4.259448416751788, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2292224', 'n_tokens_mistral': 1505, 'n_tokens_neox': 1434, 'n_words': 756}