Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
build-*/
.vscode/
46 changes: 30 additions & 16 deletions AudioFX.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ AudioFX::AudioFX(JQ6500_Serial *jref) {
}

void AudioFX::start_tone(int hz) {
serial_print("Tone");
// serial_print_val("Tone", TONE_DROP_HZ);
tone(PIN_SPEAKER, TONE_DROP_HZ);
}

void AudioFX::stop_tone() {
// serial_print("Tone Stop");
noTone(PIN_SPEAKER);
}

Expand All @@ -49,23 +50,26 @@ void AudioFX::play_sound_samples() {
return;
}

serial_print("Play Sample1");
play_sample(SFX_PREP,2013);
serial_print("Play 1.mp3");
play_sample(SFX_PREP); // try this first. If use below
// play_sample(SFX_PREP,2013); // file_number, play_time
delay(1750);
serial_print("Play Sample2");
play_sample(SFX_WATCH_GATE,2330);
serial_print("SFX Done");
serial_print("Play 2.mp3");
play_sample(SFX_WATCH_GATE);
//play_sample(SFX_WATCH_GATE,2330); // file_number, play_time
serial_print("SFX mp3 play Done");
}

void AudioFX::play_abort() {
serial_print("playing abort tones");
tone(PIN_SPEAKER, TONE_ABORT_1_HZ, DELAY_ABORT_TONE_1_MS);
delay(DELAY_ABORT_TONE_1_MS);
tone(PIN_SPEAKER, TONE_ABORT_2_HZ, DELAY_ABORT_TONE_2_MS);
}

void AudioFX::play_sample(uint8_t track) {
if (SFX_ADAFRUIT) {
serial_print("SFX playing on Adafruit device");
serial_print("a. SFX playing on Adafruit device");
sfx->playTrack(track);
delay(50);
while (digitalRead(PIN_SFX_ACT) == LOW) {
Expand All @@ -79,33 +83,43 @@ void AudioFX::play_sample(uint8_t track) {
// We need to use the method below (passing in playtime) to
// finish playing when the track finishes. It is a crap way to do
// it, but for $3 for a JQ6500, I can live with it.
serial_print("SFX playing on QJ6500 device");
serial_print("a. SFX playing on JQ6500 device");
jfx->playFileByIndexNumber(track);
delay(50);
while(jfx->getStatus() == MP3_STATUS_PLAYING)
delay(150);
byte stat =jfx->getStatus(); //0x00 , 0x01, 0x02 Stopped/Playing/Paused
serial_print_val("SFX getStatus()",stat);
while(stat != MP3_STATUS_STOPPED)
{
// wait for sample to finish
// waiting for mp3 to finish
// debug
//serial_print_val("SFX Status",jfx->getStatus());
delay(150);
serial_print_val("SFX getStatus()",stat);
}
serial_print("SFX done");
}
return;
// return;
}

// needed for JQ6500, because cheap crap.
void AudioFX::play_sample(uint8_t track, int playTime) {
if (SFX_ADAFRUIT) {
serial_print("SFX playing on Adafruit device");
serial_print("b. SFX playing on Adafruit device");
sfx->playTrack(track);
delay(playTime);
}
else
{
serial_print("SFX playing on QJ6500 device");
serial_print("b. SFX playing on JQ6500 device");
jfx->playFileByIndexNumber(track);
delay(playTime);
}
serial_print("SFX done");
return;
// return;
}

void AudioFX::stop_play() {
// may need to test status first
serial_print("Pausing JQ6500 device");
jfx->pause();

}
3 changes: 2 additions & 1 deletion AudioFX.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class AudioFX {
void play_sound_samples();
void play_abort();
void play_power_on();
void stop_play();

private:
Adafruit_Soundboard *sfx;
Expand All @@ -28,4 +29,4 @@ class AudioFX {
void play_sample(uint8_t track, int playTime);
};

#endif
#endif
76 changes: 39 additions & 37 deletions CHANGELOG.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
# Change Log

## 0.7.5
- fixed gate abort interrupt

## 0.7.4
- fixed spelling error in function name

## 0.7.3
- Added mode for controlling relay based light trees

## 0.7.2
- Fixed light tree sequence for cheap NeoPixel stick clones (they seem to use reverse order addressing)

## 0.7.1
- Changed pin assignments to improve circuit board layout

## 0.7.0
- Removed Volume library entirely, added trim pot to design
- switched from relay board to MOSFET

## 0.6.0
- Changed Volume library for Volume3
- Fixed issues with JCQ500 library support
- Added schematic

## 0.5.1
- Added JQ6500 sound module support
- Added RGB light tree support

## 0.5.0
- Fixed C++ bug around object declarations

## 0.4.0
- Refactored from C to C++
- Added makefile
- Released to git hub
# Change Log
## 0.8.0b
- timing support

## 0.7.5
- fixed gate abort interrupt

## 0.7.4
- fixed spelling error in function name

## 0.7.3
- Added mode for controlling relay based light trees

## 0.7.2
- Fixed light tree sequence for cheap NeoPixel stick clones (they seem to use reverse order addressing)

## 0.7.1
- Changed pin assignments to improve circuit board layout

## 0.7.0
- Removed Volume library entirely, added trim pot to design
- switched from relay board to MOSFET

## 0.6.0
- Changed Volume library for Volume3
- Fixed issues with JCQ500 library support
- Added schematic

## 0.5.1
- Added JQ6500 sound module support
- Added RGB light tree support

## 0.5.0
- Fixed C++ bug around object declarations

## 0.4.0
- Refactored from C to C++
- Added makefile
- Released to git hub
14 changes: 7 additions & 7 deletions Gate.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ void Gate::random_wait() {
int rand_delay = random(DELAY_RAND_MIN,DELAY_RAND_MAX+1);
unsigned long wait_timer = millis() + rand_delay;
serial_print_val("Gate sequence random wait time",rand_delay);
serial_print_val("Wait timer",wait_timer);
serial_print_val("Millis",millis());
// serial_print_val("Wait timer",wait_timer);
// serial_print_val("Millis",millis());
while((millis() < wait_timer) && (!FLAG_ABORT_PENDING)) {
// waiting for random wait to finish
}
Expand All @@ -33,17 +33,17 @@ void Gate::ready(){
}

void Gate::arm() {
// set LED to red
// turn on electro magnet
// beep
serial_print("Gate Deactivate");
digitalWrite(PIN_RELAY, LOW);
}

void Gate::abort() {
FLAG_ABORT_PENDING = 1;
}

void Gate::drop() {
digitalWrite(PIN_RELAY, LOW);
serial_print("Gate Activate");
digitalWrite(PIN_RELAY, HIGH);
}

bool Gate::is_sequence_running() {
Expand All @@ -65,4 +65,4 @@ void Gate::set_sequence_running(bool running) {

void Gate::set_abortable(bool abortable) {
FLAG_IS_ABORTABLE = abortable;
}
}
52 changes: 17 additions & 35 deletions LightTree.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -38,32 +38,17 @@ void LightTree::initialise(bool useRelays, int pin) {
}
}

void LightTree::light_set(int step, Gate* gate) {
serial_print_val("Set LED", step);
switch (step) {
case 1:
led_reset();
modeRelay ? light_set_relay(step) : light_set_pixel(step);
break;
case 2:
case 3:
modeRelay ? light_set_relay(step) : light_set_pixel(step);
break;
case 4:
gate->drop();
modeRelay ? light_set_relay(step) : light_set_pixel(step);
break;
default:
led_reset();
}
void LightTree::light_set(int step) {
serial_print_val("Set LED ", step);
modeRelay ? light_set_relay(step) : light_set_pixel(step);
}

void LightTree::led_reset() {
if (modeRelay) {
digitalWrite(PIN_LIGHT_TREE_RELAY_1, HIGH);
digitalWrite(PIN_LIGHT_TREE_RELAY_2, HIGH);
digitalWrite(PIN_LIGHT_TREE_RELAY_3, HIGH);
digitalWrite(PIN_LIGHT_TREE_RELAY_4, HIGH);
digitalWrite(PIN_LIGHT_TREE_RELAY_1, LOW);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a new configuration option to reverse relay states.

digitalWrite(PIN_LIGHT_TREE_RELAY_2, LOW);
digitalWrite(PIN_LIGHT_TREE_RELAY_3, LOW);
digitalWrite(PIN_LIGHT_TREE_RELAY_4, LOW);
} else {
for(int i=0;i<8;i++) {
_strip.setPixelColor(i,0,0,0,0);
Expand All @@ -74,12 +59,10 @@ void LightTree::led_reset() {

void LightTree::abort() {
if (modeRelay) {
//digitalWrite(PIN_LIGHT_TREE_RELAY_1, HIGH);
//led_reset();
digitalWrite(PIN_LIGHT_TREE_RELAY_1, HIGH);
digitalWrite(PIN_LIGHT_TREE_RELAY_2, LOW);
digitalWrite(PIN_LIGHT_TREE_RELAY_3, LOW);
digitalWrite(PIN_LIGHT_TREE_RELAY_4, HIGH);
digitalWrite(PIN_LIGHT_TREE_RELAY_1, LOW);
digitalWrite(PIN_LIGHT_TREE_RELAY_2, HIGH);
digitalWrite(PIN_LIGHT_TREE_RELAY_3, HIGH);
digitalWrite(PIN_LIGHT_TREE_RELAY_4, LOW);
} else {
led_reset();
for(int i=0;i<8;i++) {
Expand All @@ -105,7 +88,6 @@ void LightTree::set_status(uint32_t color) {
_strip.show();
}


void LightTree::light_set_pixel(int step) {
switch (step) {
case 1:
Expand Down Expand Up @@ -154,18 +136,18 @@ void LightTree::light_set_pixel(int step) {
void LightTree::light_set_relay(int step) {
switch (step) {
case 1:
digitalWrite(PIN_LIGHT_TREE_RELAY_1, LOW);
digitalWrite(PIN_LIGHT_TREE_RELAY_1, HIGH);
break;
case 2:
digitalWrite(PIN_LIGHT_TREE_RELAY_2, LOW);
digitalWrite(PIN_LIGHT_TREE_RELAY_2, HIGH);
break;
case 3:
digitalWrite(PIN_LIGHT_TREE_RELAY_3, LOW);
digitalWrite(PIN_LIGHT_TREE_RELAY_3, HIGH);
break;
case 4:
digitalWrite(PIN_LIGHT_TREE_RELAY_4, LOW);
digitalWrite(PIN_LIGHT_TREE_RELAY_4, HIGH);
break;
default:
default:
led_reset();
}
}
}
9 changes: 4 additions & 5 deletions LightTree.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#include <Adafruit_NeoPixel.h>
#include "utility.h"
#include "Gate.h"

#ifndef _LIGHTREE_H
#define _LIGHTREE_H
Expand All @@ -17,17 +16,17 @@ class LightTree {
LightTree();

void initialise(bool useRelays, int pin);
void light_set(int step, Gate* gate);
void light_set(int step);
void led_reset();
void abort();
void ready();
void set_status(uint32_t color);

private:
Adafruit_NeoPixel _strip;
void light_set_pixel(int step);
void light_set_relay(int step);

};

#endif
#endif
Empty file modified Makefile
100644 → 100755
Empty file.
Loading