Skip to content

Commit

Permalink
Arduino - Updated libraries
Browse files Browse the repository at this point in the history
Tests - Updated ShowTest, added PointTest
Updated README
  • Loading branch information
8bitbuddhist committed Jul 28, 2018
1 parent 19b745f commit 9e6e66c
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 19 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ PixelMaestro is a graphics library for LED displays. It lets you create dynamic,

## Getting Started

These instructions will walk you through downloading PixelMaestro, adding it to your project, and including it in your code.
To get started with PixelMaestro, [click here](https://github.com/8bitbuddhist/PixelMaestro/wiki/Tutorial) for an introductory tutorial or refer to the [documentation](https://github.com/8bitbuddhist/PixelMaestro/wiki).

This repository also includes example sketches for running PixelMaestro on an Arduino. You can run these on either the [Arduino IDE](https://www.arduino.cc/en/Main/Software) or [PlatformIO](https://platformio.org/). For detailed instructions, look in the [examples folder](examples/arduino).

To learn how to use PixelMaestro, [click here](https://github.com/8bitbuddhist/PixelMaestro/wiki/Tutorial) for an introductory tutorial or refer to the [documentation](https://github.com/8bitbuddhist/PixelMaestro/wiki).
If you want to run PixelMaestro on an Arduino, you can do so via the [Arduino IDE](https://www.arduino.cc/en/Main/Software) or [PlatformIO](https://platformio.org/). For detailed instructions, see the [examples folder](examples/arduino).

## Running Tests

Expand Down
20 changes: 8 additions & 12 deletions examples/arduino/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,21 @@ This folder contains sample sketches for running PixelMaestro on an Arduino.

## Arduino IDE Installation

1. Download the latest version of PixelMaestro from https://github.com/8bitbuddhist/PixelMaestro/releases by clicking the **Source Code (zip)** link.
2. In the Arduino IDE, click **Sketch > Include Library > Add .ZIP Library...** and select the downloaded ZIP file
3. Click **OK**.
1. In the Arduino IDE, click **Sketch > Include Library > Manage Libraries...**
2. Once the download is finished, click the **Filter your search...** box and enter **pixelmaestro**.
3. Select **PixelMaestro** and click **Install**.
4. After the installation is finished, click **Close**.

You will now find example sketches demonstrating the use of PixelMaestro in the **File > Examples > PixelMaestro** menu.
You can find example sketches demonstrating the use of PixelMaestro in the **File > Examples > PixelMaestro** menu.

### Installing Library Dependencies

The examples in the **NeoPixel** folder require the [Adafruit NeoPixel](https://github.com/adafruit/Adafruit_NeoPixel) library.

1. In the Arduino IDE, click **Sketch > Include Library > Manage Libraries...**
2. Once the download is finished, click the **Filter your search...** box and enter **adafruit neopixel single-wire**.
3. Select **Adafruit NeoPixel** and click **Install**.
4. After the installation is finished, click **Close**.
The examples in the **NeoPixel** folder require the [Adafruit NeoPixel](https://github.com/adafruit/Adafruit_NeoPixel) library. Repeat steps 1-4 above, but search for **adafruit neopixel single-wire** instead.

The examples in the **WS2812** folder require the [light_ws2812](https://github.com/cpldcpu/light_ws2812) library. Repeat steps 1-4 above, but search for **light_ws2812** instead.
The examples in the **WS2812** folder require the [light_ws2812](https://github.com/cpldcpu/light_ws2812) library. Repeat the same steps as with the NeoPixel library, but search for **light_ws2812**.

## PlatformIO Installation

1. In PlatformIO, click **File > Open Folder...** and select this folder.
2. Copy the sketch that you want to upload to the **src/** folder.
3. Build and upload the project to your board. PlatformIO will automatically download dependencies during the build.
3. Build and upload the project to your board. PlatformIO will automatically download dependencies during the build.
4 changes: 2 additions & 2 deletions examples/arduino/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ lib_dir = ../../.
; framework = arduino
; lib_deps =
; Adafruit NeoPixel
; https://github.com/8bitbuddhist/light_ws2812/raw/pixelmaestro/light_ws2812_Arduino/light_WS2812.zip
; LightWS2812

[env:uno]
platform = atmelavr
board = uno
framework = arduino
lib_deps =
Adafruit NeoPixel
LightWS2812
LightWS2812
39 changes: 39 additions & 0 deletions tests/tests/pointtest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include "../catch/single_include/catch.hpp"
#include "../../src/core/point.h"
#include "pointtest.h"

using namespace PixelMaestro;

TEST_CASE("Create and manipulate a Point.", "[Point]") {
int x = 40;
int y = 60;
Point point(x, y);

SECTION("Verify coordinates are stored correctly.") {
REQUIRE(point.x == x);
REQUIRE(point.y == y);
}

SECTION("Verify coordinates can be resized.") {
int new_x = 90;
int new_y = 180;

point.set(new_x, new_y);

REQUIRE(point.x == new_x);
REQUIRE(point.y == new_y);
}

SECTION("Verify inline index calculates correctly.") {
int target_x = 15;
int target_y = 30;

int inline_index = (target_y * point.x) + target_x;

REQUIRE(point.get_inline_index(target_x, target_y) == inline_index);
}

SECTION("Verify size.") {
REQUIRE(point.size() == x * y);
}
}
9 changes: 9 additions & 0 deletions tests/tests/pointtest.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef POINTTEST_H
#define POINTTEST_H

class PointTest {
public:
PointTest();
};

#endif // POINTTEST_H
24 changes: 23 additions & 1 deletion tests/tests/showtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,26 @@ TEST_CASE("Create and manipulate a Show.", "[Show]") {
REQUIRE(cue[index] == event.get_cue()[index]);
}
}
}

SECTION("Verify Events can be assigned to a Show.") {
Event events[] = {
Event(1000, section_handler->set_animation(0, 0, AnimationType::Solid))
};
show->set_events(events, 1);

REQUIRE(show->get_events() == events);
REQUIRE(show->get_num_events() == 1);
}

SECTION("Verify Event processing works.") {
Event events[] = {
Event(0, section_handler->set_animation(0, 0, AnimationType::Solid)),
Event(2, section_handler->set_animation(0, 0, AnimationType::Solid))
};
show->set_events(events, 2);
maestro.update(0);

REQUIRE(show->get_current_index() == 1);
REQUIRE(show->get_last_time() == 1);
}
}

0 comments on commit 9e6e66c

Please sign in to comment.