Skip to content

Commit

Permalink
fixed issue 2 and 3
Browse files Browse the repository at this point in the history
  • Loading branch information
dekuNukem committed Apr 3, 2018
1 parent c341378 commit 5467197
Show file tree
Hide file tree
Showing 17 changed files with 160 additions and 42 deletions.
5 changes: 3 additions & 2 deletions arduino_examples/1_LED_test/1_LED_test.ino
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ exixe my_tube = exixe(cs_pin);

void setup()
{
my_tube.set_led(127, 0, 127); // purple
my_tube.spi_init();
}

void loop()
{

my_tube.set_led(127, 0, 127); // purple
delay(500);
}
3 changes: 2 additions & 1 deletion arduino_examples/2_loop_digit_simple/2_loop_digit_simple.ino
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ exixe my_tube = exixe(cs_pin);

void setup()
{
my_tube.spi_init();
my_tube.clear();
my_tube.set_led(127, 0, 127); // purple
}

void loop()
Expand All @@ -30,6 +30,7 @@ void loop()
2nd arg: Digit brightness, 0 to 127
3rd arg: Overdrive, 0 disable 1 enable
*/
my_tube.set_led(127, 0, 127); // purple
my_tube.show_digit(count, 127, 0);
delay(500);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ exixe my_tube = exixe(cs_pin);

void setup()
{
my_tube.spi_init();
my_tube.clear();
my_tube.set_led(32, 127, 127); // purple
}

void loop()
Expand All @@ -40,5 +40,7 @@ void loop()
// check its return value to see if the animation is finished
while(my_tube.crossfade_run() == EXIXE_ANIMATION_IN_PROGRESS)
;

my_tube.set_led(127, 64, 0); // orange
delay(250);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
Demo 4: Loop digits on two tubes
*/


#include "exixe.h"

// change those to the cs pins you're using
Expand All @@ -21,16 +20,20 @@ exixe my_tube2 = exixe(cs2);

void setup()
{
// ONLY CALL THIS ONCE
my_tube1.spi_init();

my_tube1.clear();
my_tube2.clear();
my_tube1.set_led(127, 0, 127); // purple;
my_tube2.set_led(127, 127, 0); // yellow;
}

void loop()
{
count = (count + 1) % 10; // keep count between 0 to 9
my_tube1.show_digit(count, 127, 0);
my_tube2.show_digit(10 - count, 127, 0);

my_tube1.set_led(127, 0, 127); // purple;
my_tube2.set_led(127, 127, 0); // yellow;
delay(500);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
Demo 5: Loop digits on two tubes with crossfade animation
*/


#include "exixe.h"

// change those to the cs pins you're using
Expand All @@ -21,10 +20,11 @@ exixe my_tube2 = exixe(cs2);

void setup()
{
// ONLY CALL THIS ONCE
my_tube1.spi_init();

my_tube1.clear();
my_tube2.clear();
my_tube1.set_led(127, 0, 127); // purple;
my_tube2.set_led(127, 127, 0); // yellow;
}

void loop()
Expand All @@ -49,5 +49,7 @@ void loop()
break;
}

my_tube1.set_led(127, 0, 127); // purple;
my_tube2.set_led(127, 127, 0); // yellow;
delay(250);
}
4 changes: 4 additions & 0 deletions arduino_library/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Select the `exixe.zip` you just downloaded, and it should install automatically.

A number of examples are [provided here](../arduino_examples). Take a look at the [getting started guide](../getting_started.md) to see how to use them.

#### `spi_init()`

* Initializes SPI peripheral, only call this once(even if you use multiple tubes) at the beginning of the sketch.

#### `show_digit(uint8_t digit, uint8_t brightness, uint8_t overdrive)`

* This sets `digit` in the tube to `brightness`.
Expand Down
Binary file modified arduino_library/exixe.zip
Binary file not shown.
5 changes: 3 additions & 2 deletions arduino_library/exixe/examples/1_LED_test/1_LED_test.ino
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ exixe my_tube = exixe(cs_pin);

void setup()
{
my_tube.set_led(127, 0, 127); // purple
my_tube.spi_init();
}

void loop()
{

my_tube.set_led(127, 0, 127); // purple
delay(500);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ exixe my_tube = exixe(cs_pin);

void setup()
{
my_tube.spi_init();
my_tube.clear();
my_tube.set_led(127, 0, 127); // purple
}

void loop()
Expand All @@ -30,6 +30,7 @@ void loop()
2nd arg: Digit brightness, 0 to 127
3rd arg: Overdrive, 0 disable 1 enable
*/
my_tube.set_led(127, 0, 127); // purple
my_tube.show_digit(count, 127, 0);
delay(500);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ exixe my_tube = exixe(cs_pin);

void setup()
{
my_tube.spi_init();
my_tube.clear();
my_tube.set_led(127, 0, 127); // purple
}

void loop()
Expand All @@ -40,5 +40,7 @@ void loop()
// check its return value to see if the animation is finished
while(my_tube.crossfade_run() == EXIXE_ANIMATION_IN_PROGRESS)
;

my_tube.set_led(127, 64, 0); // orange
delay(250);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
Demo 4: Loop digits on two tubes
*/


#include "exixe.h"

// change those to the cs pins you're using
Expand All @@ -21,16 +20,20 @@ exixe my_tube2 = exixe(cs2);

void setup()
{
// ONLY CALL THIS ONCE
my_tube1.spi_init();

my_tube1.clear();
my_tube2.clear();
my_tube1.set_led(127, 0, 127); // purple;
my_tube2.set_led(127, 127, 0); // yellow;
}

void loop()
{
count = (count + 1) % 10; // keep count between 0 to 9
my_tube1.show_digit(count, 127, 0);
my_tube2.show_digit(10 - count, 127, 0);

my_tube1.set_led(127, 0, 127); // purple;
my_tube2.set_led(127, 127, 0); // yellow;
delay(500);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
Demo 5: Loop digits on two tubes with crossfade animation
*/


#include "exixe.h"

// change those to the cs pins you're using
Expand All @@ -21,10 +20,11 @@ exixe my_tube2 = exixe(cs2);

void setup()
{
// ONLY CALL THIS ONCE
my_tube1.spi_init();

my_tube1.clear();
my_tube2.clear();
my_tube1.set_led(127, 0, 127); // purple;
my_tube2.set_led(127, 127, 0); // yellow;
}

void loop()
Expand All @@ -49,5 +49,7 @@ void loop()
break;
}

my_tube1.set_led(127, 0, 127); // purple;
my_tube2.set_led(127, 127, 0); // yellow;
delay(250);
}
44 changes: 44 additions & 0 deletions arduino_library/exixe/examples/barebone/0_LED_test/0_LED_test.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
Demo for exixe modules
https://github.com/dekuNukem/exixe
exixe "Getting Started" guide
https://github.com/dekuNukem/exixe/blob/master/getting_started.md
Demo 0: Show a purple LED
*/

#include <SPI.h>
#define SPI_BUF_SIZE 16

uint8_t spi_buf[SPI_BUF_SIZE];
// change this to the cs pin you're using
const int slaveSelectPin = 10;

void setup()
{
pinMode(slaveSelectPin, OUTPUT);
digitalWrite(slaveSelectPin, HIGH);

SPI.begin();
// 8MHz SCLK, MSB first, SPI mode 0
SPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0));

spi_buf[0] = 0xaa; // first byte, header
spi_buf[13] = 0x80 | 127; // red LED full brightness
spi_buf[14] = 0x80 | 0; // green LED off
spi_buf[15] = 0x80 | 127; // blue LED full brightness
}

void loop()
{
// cs low
digitalWrite(slaveSelectPin, LOW);
// send 16 byte command
for (int i = 0; i < SPI_BUF_SIZE; ++i)
SPI.transfer(spi_buf[i]);
// cs high
digitalWrite(slaveSelectPin, HIGH);

delay(200);
}
45 changes: 45 additions & 0 deletions arduino_library/exixe/examples/barebone/1_show4/1_show4.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
Demo for exixe modules
https://github.com/dekuNukem/exixe
exixe "Getting Started" guide
https://github.com/dekuNukem/exixe/blob/master/getting_started.md
Demo 1: Show digit 4 with orange backlight
*/

#include <SPI.h>
#define SPI_BUF_SIZE 16

uint8_t spi_buf[SPI_BUF_SIZE];
// change this to the cs pin you're using
const int slaveSelectPin = 10;

void setup()
{
pinMode(slaveSelectPin, OUTPUT);
digitalWrite(slaveSelectPin, HIGH);

SPI.begin();
// 8MHz SCLK, MSB first, SPI mode 0
SPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0));

spi_buf[0] = 0xaa; // first byte, header
spi_buf[4] = 0x80 | 127; // digit 4 full brightness
spi_buf[13] = 0x80 | 127; // red LED full brightness
spi_buf[14] = 0x80 | 28; // green LED brightness 28
spi_buf[15] = 0x80 | 0; // blue LED fully off
}

void loop()
{
// cs low
digitalWrite(slaveSelectPin, LOW);
// send 16 byte command
for (int i = 0; i < SPI_BUF_SIZE; ++i)
SPI.transfer(spi_buf[i]);
// cs high
digitalWrite(slaveSelectPin, HIGH);

delay(200);
}
6 changes: 5 additions & 1 deletion arduino_library/exixe/exixe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ exixe::exixe(int my_cs)
memset(spi_buf, 0, EXIXE_SPI_BUF_SIZE);
pinMode(cs_pin, OUTPUT);
digitalWrite(cs_pin, HIGH);
animation_src_digit = 0;
}

void exixe::spi_init()
{
SPI.begin();
SPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0));
show_digit(0, 0, 0);
}

void exixe::spi_write()
Expand Down
3 changes: 3 additions & 0 deletions arduino_library/exixe/exixe.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef exixe_h
#define exixe_h

#include "Arduino.h"

#define EXIXE_SPI_BUF_SIZE (16)
#define EXIXE_SPI_HEADER (0xaa)
#define EXIXE_SPI_HEADER_OD (0xab)
Expand All @@ -12,6 +14,7 @@ class exixe
{
public:
exixe(int my_cs);
void spi_init();
void show_digit(unsigned char digit, unsigned char brightness, unsigned char overdrive);
void set_led(unsigned char red, unsigned char green, unsigned char blue);
void set_dots(unsigned char left_brightness, unsigned char right_brightness);
Expand Down
Loading

0 comments on commit 5467197

Please sign in to comment.