Skip to content

Commit f8b278e

Browse files
committed
1.0.1
Corrected a bug occuring on Arduino nano clones Added a new module to all disable lights effects
1 parent 7431516 commit f8b278e

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

Config.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ static const uint8_t rgbFactor = 100;
7676
************************************/
7777
#define MAX_BRIGHTNESS 200
7878

79+
/* LIGHT_EFFECTS
80+
*
81+
* Enable / disable all light and
82+
* color effects of the blade
83+
* If you a device with a CPU wich is not
84+
* an Atmega328 : COMMENT THIS
85+
************************************/
86+
#define LIGHT_EFFECTS
7987

8088

8189
#define BLASTER_FLASH_TIME 3
@@ -93,6 +101,8 @@ static const uint8_t rgbFactor = 100;
93101
/* DEEP_SLEEP
94102
* If you want to enable/disable
95103
* deep sleep capabalities
104+
* If you a device with a CPU wich is not
105+
* an Atmega328 : COMMENT THIS
96106
*************************************/
97107
#define DEEP_SLEEP
98108
#ifdef DEEP_SLEEP

Light.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ void lightRetract(uint8_t ledPins[], uint16_t time, uint8_t type) {
241241
switch (type) {
242242
case 0:
243243
// Light off the ledstrings Movie Like
244-
for (uint8_t i = 5; i >= 0; i--) {
244+
for (int8_t i = 5; i >= 0; i--) {
245245
digitalWrite(ledPins[i], LOW);
246246
delay(time / 5);
247247
}

Lightsaber.ino

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,10 @@ void setup() {
388388
/***** LED SEGMENT INITIALISATION *****/
389389

390390
/***** BUTTONS INITIALISATION *****/
391-
PCMSK0 |= (1 << PCINT4); // set PCINT4 (PIN 12) to trigger an interrupt on state change
392-
PCMSK2 |= (1 << PCINT20); // set PCINT20 (PIN 4) to trigger an interrupt on state change
391+
#ifdef DEEP_SLEEP
392+
PCMSK0 = (1 << PCINT4); // set PCINT4 (PIN 12) to trigger an interrupt on state change
393+
PCMSK2 = (1 << PCINT20); // set PCINT20 (PIN 4) to trigger an interrupt on state change
394+
#endif
393395

394396
// link the Main button functions.
395397
mainButton.setClickTicks(CLICK);
@@ -443,7 +445,9 @@ void loop() {
443445
if (actionMode) {
444446
delay(500);
445447
actionMode = false;
448+
#ifdef LIGHT_EFFECTS
446449
TIMSK2 = 0;
450+
#endif
447451
dfplayer.playPhysicalTrack(soundFont.getPowerOff());
448452
changeMenu = false;
449453
ignition = false;
@@ -544,7 +548,7 @@ void loop() {
544548
#endif
545549

546550
sndSuppress = millis();
547-
551+
#ifdef LIGHT_EFFECTS
548552
/*
549553
* Interrupt Timer2 configuration
550554
*/
@@ -554,6 +558,7 @@ void loop() {
554558
TCCR2B |= (1 << CS21) | (1 << CS22);
555559
// start timer2 compare interrupt:
556560
TIMSK2 |= (1 << OCIE2A);
561+
#endif
557562

558563
// Get the initial position of the motion detector
559564
motionEngine();
@@ -943,7 +948,9 @@ void loop() {
943948

944949
if (ignition) { // we just leaved Action Mode
945950
detachInterrupt(0);
946-
TIMSK2 = 0;
951+
#ifdef LIGHT_EFFECTS
952+
TIMSK2 &= ~(1<<OCIE2A);
953+
#endif
947954
dfplayer.playPhysicalTrack(soundFont.getPowerOff());
948955
changeMenu = false;
949956
ignition = false;
@@ -1287,6 +1294,7 @@ void fadeAccent() {
12871294
* each 22 µs this method is called and modifies the blade brightness
12881295
* The parameter is defined in ignition block
12891296
*/
1297+
#ifdef LIGHT_EFFECTS
12901298
ISR(TIMER2_COMPA_vect, ISR_NOBLOCK) {
12911299

12921300
#ifdef LEDSTRINGS
@@ -1421,7 +1429,8 @@ ISR(TIMER2_COMPA_vect, ISR_NOBLOCK) {
14211429
FoCOff(FoCSTRING);
14221430
#endif
14231431
blink++;
1424-
} else if (blink == 24) {
1432+
}
1433+
else if (blink == 24) {
14251434
#ifdef LUXEON
14261435
getColor(currentColor, storage.mainColor);
14271436
lightOn(ledPins, currentColor);
@@ -1436,6 +1445,7 @@ ISR(TIMER2_COMPA_vect, ISR_NOBLOCK) {
14361445
blink = 0;
14371446
blaster--;
14381447
}
1448+
14391449
} else if (lowBattery) {
14401450
uint8_t brightness;
14411451
if (blink == 0) {
@@ -1461,3 +1471,4 @@ ISR(TIMER2_COMPA_vect, ISR_NOBLOCK) {
14611471

14621472
}
14631473

1474+
#endif //LIGHT_EFFECTS

0 commit comments

Comments
 (0)