Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Commit

Permalink
Merge pull request #14 from precision/platformio
Browse files Browse the repository at this point in the history
Platformio
  • Loading branch information
precision committed Aug 1, 2016
2 parents 85d0f03 + 2e7a87f commit 68b2a37
Show file tree
Hide file tree
Showing 53 changed files with 186 additions and 1,100 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.pioenvs
.clang_complete
.gcc-flags.json
65 changes: 65 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Continuous Integration (CI) is the practice, in software
# engineering, of merging all developer working copies with a shared mainline
# several times a day < http://docs.platformio.org/en/latest/ci/index.html >
#
# Documentation:
#
# * Travis CI Embedded Builds with PlatformIO
# < https://docs.travis-ci.com/user/integration/platformio/ >
#
# * PlatformIO integration with Travis CI
# < http://docs.platformio.org/en/latest/ci/travis.html >
#
# * User Guide for `platformio ci` command
# < http://docs.platformio.org/en/latest/userguide/cmd_ci.html >
#
#
# Please choice one of the following templates (proposed below) and uncomment
# it (remove "# " before each line) or use own configuration according to the
# Travis CI documentation (see above).
#


#
# Template #1: General project. Test it using existing `platformio.ini`.
#

# language: python
# python:
# - "2.7"
#
# sudo: false
# cache:
# directories:
# - "~/.platformio"
#
# install:
# - pip install -U platformio
#
# script:
# - platformio run


#
# Template #2: The project is intended to by used as a library with examples
#

# language: python
# python:
# - "2.7"
#
# sudo: false
# cache:
# directories:
# - "~/.platformio"
#
# env:
# - PLATFORMIO_CI_SRC=path/to/test/file.c
# - PLATFORMIO_CI_SRC=examples/file.ino
# - PLATFORMIO_CI_SRC=path/to/test/directory
#
# install:
# - pip install -U platformio
#
# script:
# - platformio ci --lib="." --board=TYPE_1 --board=TYPE_2 --board=TYPE_N
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
all:
platformio -f -c vim run

upload:
platformio -f -c vim run --target upload

clean:
platformio -f -c vim run --target clean

program:
platformio -f -c vim run --target program

uploadfs:
platformio -f -c vim run --target uploadfs

update:
platformio -f -c vim update
14 changes: 1 addition & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,4 @@ is used to make an Arduino that has Bluetooth Low Energy (BLE) capabilities
(such as the RedBear BLEND board and the Arduino 101) send data from its pins to
Science Journal.

To build and install this sketch,
* [install the Arduino IDE](https://www.arduino.cc/en/Main/Software) on your desktop/laptop computer. The [Getting Started](https://www.arduino.cc/en/Guide/HomePage) page explains how to install the IDE.
* You also need to install the nanopb support library.
- In your browser, open https://github.com/nanopb/nanopb. Click the "Download ZIP" button:
![Download ZIP button highlight](docs/download_nanopb_zip.png "Download ZIP button highlight")
- Inside the Arduino IDE go to Sketch -> Include Library -> Add .ZIP Library:
![Include library add zip highlight](docs/include_library_add_zip.png "Include library add zip highlight")
- Navigate to the Downloads directory for your computer's browser
(this location differs by Operating System) and select the file
"nanopb-master.zip".
![Select nanopb-master.zip highlight](docs/select_nanopb.png "Select nanopb-master.zip highlight")
* If you are using the BLEND board, [follow the BLEND installation instructions](docs/BLEND.md)
* If you are using the Arduino 101 board, [follow the Arduino 101 installation instructions](docs/arduino101.md)
This project uses [Platform IO](http://platformio.org/get-started).
29 changes: 0 additions & 29 deletions docs/BLEND.md

This file was deleted.

Binary file removed docs/add_redbear_arduino_package.png
Binary file not shown.
17 changes: 0 additions & 17 deletions docs/arduino101.md

This file was deleted.

Binary file removed docs/blend_add_ble_sdk.png
Binary file not shown.
Binary file removed docs/board_arduino101.png
Binary file not shown.
Binary file removed docs/board_blend.png
Binary file not shown.
Binary file removed docs/boards_manager_arduino101_search.png
Binary file not shown.
Binary file removed docs/boards_manager_redbear_install.png
Binary file not shown.
Binary file removed docs/boards_manager_redbear_search.png
Binary file not shown.
Binary file removed docs/done_uploading.png
Binary file not shown.
Binary file removed docs/download_nanopb_zip.png
Binary file not shown.
Binary file removed docs/file_boards_manager.png
Binary file not shown.
Binary file removed docs/file_preferences.png
Binary file not shown.
Binary file removed docs/include_library_add_zip.png
Binary file not shown.
Binary file removed docs/port_arduino101.png
Binary file not shown.
Binary file removed docs/port_blend.png
Binary file not shown.
Binary file removed docs/select_nanopb.png
Binary file not shown.
Binary file removed docs/sketch_add_library.png
Binary file not shown.
Binary file removed docs/upload_firmware.png
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ bool GoosciBleGatt::isReadyToSend() {

uint8_t packet[BTLE_BUFFER_SIZE];

bool GoosciBleGatt::sendData(const char *buffer, int size) {
bool GoosciBleGatt::sendData(const char *buffer, int32_t size) {
const uint8_t max_packet_size = BTLE_BUFFER_SIZE - 2;
/* Force size/max_packet_size to round up */
uint8_t num_packets = (size + max_packet_size - 1) / max_packet_size;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class GoosciBleGatt {
void setSensorConfig(const char *config, int size);
bool isInitialized(void);
bool isReadyToSend(void);
bool sendData(const char *buffer, int size);
bool sendData(const char *buffer, int32_t size);
};

#endif
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void wait_for_serial(void) {
#else
Serial.begin(115200);
#endif
#if defined(__ARDUINO_ARC__)
#if defined(__ARDUINO_ARC__)
Serial.begin(115200);
#endif
}
Expand All @@ -40,11 +40,14 @@ uint8_t buffer[BUFFER_LEN];
pb_ostream_t stream;

#define BTLE_BUFFER_SIZE 20

int packets = 0;
uint8_t packet[BTLE_BUFFER_SIZE];

#if defined(__AVR_ATmega32U4__)
void send_data(GoosciBleGatt &goosciBle, unsigned long timestamp_key, int value) {
#elif defined(__ARDUINO_ARC__)
uint8_t packet[BTLE_BUFFER_SIZE];
void send_data(BLECharacteristic& characteristic, unsigned long timestamp_key, int value) {
#endif
stream = pb_ostream_from_buffer(buffer, BUFFER_LEN);

sd.timestamp_key = timestamp_key; // timestamp
Expand Down Expand Up @@ -74,11 +77,14 @@ void send_data(BLECharacteristic& characteristic, unsigned long timestamp_key, i
}
DEBUG_PRINTLN(s.c_str());
*/
#if defined(__AVR_ATmega32U4__)
goosciBle.sendData((const char *)buffer, stream.bytes_written);
#else
uint8_t size = stream.bytes_written;
const uint8_t max_packet_size = BTLE_BUFFER_SIZE - 2;
/* Force size/max_packet_size to round up */
uint8_t num_packets = (size + max_packet_size - 1) / max_packet_size;


for (uint8_t ii = 0; ii < num_packets; ii++) {
bool is_last_packet = ((num_packets - 1) == ii);
Expand All @@ -91,13 +97,14 @@ void send_data(BLECharacteristic& characteristic, unsigned long timestamp_key, i
packet[0] = current_packet_size;
packet[1] = is_last_packet;
memcpy((void*)(packet + 2), buffer + ii * max_packet_size, current_packet_size);

/* If send fails then we give up */
if (!characteristic.setValue(packet, current_packet_size+2)) {
DEBUG_PRINTLN("Send of packet failed.");
break;
}
}
}
#endif
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,19 @@
#ifndef _GOOSCI_UTILITY_H_
#define _GOOSCI_UTILITY_H_

#include "GoosciBleGatt.h"
#if defined(__ARDUINO_ARC__)
#include <CurieBLE.h>
void send_data(BLECharacteristic& characteristic, unsigned long timestamp, int value);
#endif

#if defined(__AVR_ATmega32U4__)
#include "GoosciBleGatt.h"
void send_data(GoosciBleGatt &goosciBle, unsigned long timestamp, int value);
#endif

// The serial port on leonardo will hang (UART buffer full) if the
// serial port is not physically opened on the USB host. This
// function will block until the serial port is open.
void wait_for_serial(void);

void send_data(GoosciBleGatt &goosciBle, unsigned long timestamp, int value);
#endif
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
38 changes: 38 additions & 0 deletions lib/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

This directory is intended for the project specific (private) libraries.
PlatformIO will compile them to static libraries and link to executable file.

The source code of each library should be placed in separate directory, like
"lib/private_lib/[here are source files]".

For example, see how can be organized `Foo` and `Bar` libraries:

|--lib
| |--Bar
| | |--docs
| | |--examples
| | |--src
| | |- Bar.c
| | |- Bar.h
| |--Foo
| | |- Foo.c
| | |- Foo.h
| |- readme.txt --> THIS FILE
|- platformio.ini
|--src
|- main.c

Then in `src/main.c` you should use:

#include <Foo.h>
#include <Bar.h>

// rest H/C/CPP code

PlatformIO will find your libraries automatically, configure preprocessor's
include paths and build them.

See additional options for PlatformIO Library Dependency Finder `lib_*`:

http://docs.platformio.org/en/latest/projectconf.html#lib-install

36 changes: 36 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#
# Project Configuration File
#
# A detailed documentation with the EXAMPLES is located here:
# http://docs.platformio.org/en/latest/projectconf.html
#

# A sign `#` at the beginning of the line indicates a comment
# Comment lines are ignored.

# Simple and base environment
# [env:mybaseenv]
# platform = %INSTALLED_PLATFORM_NAME_HERE%
# framework =
# board =
#
# Automatic targets - enable auto-uploading
# targets = upload

[env:blend]
platform = atmelavr
framework = arduino
board = blend
src_filter = +<blend/>
lib_use = SPI,EEPROM
lib_dfcyclic = True
lib_install = 431,332


[env:101]
platform = intel_arc32
framework = arduino
board = genuino101
src_filter = +<arduino101/>
lib_install = 431
lib_ignore = Nordic_nRF8001,GoosciBleGatt
26 changes: 0 additions & 26 deletions src/arduino101/science-journal-arduino/goosci_utility.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* sends them to Whistlepunk via BLE.
*/

#include "Arduino.h"

#include "GoosciBleGatt.h"
#include "goosci_utility.h"
#include "arduino_nrf_pins.h"
Expand Down
32 changes: 0 additions & 32 deletions src/blend/science-journal-arduino/arduino_nrf_pins.h

This file was deleted.

0 comments on commit 68b2a37

Please sign in to comment.