Skip to content

Commit

Permalink
increases stability
Browse files Browse the repository at this point in the history
  • Loading branch information
myTonino committed Sep 30, 2017
1 parent 1a58352 commit 4b58f2e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 34 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Tonino Resources
Version History
---------------

- v1.1.7 Increases stability
- v1.1.6 Adds automatic averaging
- v1.1.5 Calibration stability improved
- v1.1.4 App alignment
Expand Down
11 changes: 2 additions & 9 deletions Tonino.ino
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//
// *** BSD License ***
// ------------------------------------------------------------------------------------------
// Copyright (c) 2016, Paul Holleis, Marko Luther
// Copyright (c) 2017, Paul Holleis, Marko Luther
// All rights reserved.
//
// Author: Paul Holleis, Marko Luther
Expand Down Expand Up @@ -44,7 +44,7 @@
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// ------------------------------------------------------------------------------------------

#define VERSION "1 1 6"
#define VERSION "1 1 7"

#include <tonino.h>
#include <tonino_lcd.h>
Expand All @@ -63,10 +63,3 @@
#include <FreqCount.h>
// lib to access EEPROM, built-in, see http://arduino.cc/en/Reference/EEPROM
#include <EEPROM.h>

// low power library, built-in, see http://playground.arduino.cc/Learning/arduinoSleepCode
#include <avr/power.h>
// watchdog timer
#include <avr/wdt.h>
// low power library, https://github.com/rocketscream/Low-Power, Version 1.30
#include <LowPower.h>
28 changes: 3 additions & 25 deletions sketch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//
// *** BSD License ***
// ------------------------------------------------------------------------------------------
// Copyright (c) 2016, Paul Holleis, Marko Luther
// Copyright (c) 2017, Paul Holleis, Marko Luther
// All rights reserved.
//
// Author: Paul Holleis, Marko Luther
Expand Down Expand Up @@ -45,7 +45,7 @@
// ------------------------------------------------------------------------------------------


#define VERSION "1 1 6"
#define VERSION "1 1 7"

#include <Arduino.h>

Expand All @@ -69,8 +69,6 @@

// low power library, built-in, see http://playground.arduino.cc/Learning/arduinoSleepCode
#include <avr/power.h>
// watchdog timer
#include <avr/wdt.h>
// low power library, https://github.com/rocketscream/Low-Power, Version 1.30
#include <LowPower.h>

Expand All @@ -93,18 +91,7 @@ ToninoSerial tSerial = ToninoSerial(&colorSense, &display, &tConfig, VERSION);
int8_t origBrightness = -1;


void watchdogSetup(void) {
cli(); // disable all interrupts
wdt_reset(); // reset the WDT timer
// Enter Watchdog Configuration mode:
WDTCSR |= (1<<WDCE) | (1<<WDE);
// Set Watchdog settings:
WDTCSR = (1<<WDIE) | (1<<WDE) | (1<<WDP3) | (1<<WDP2) | (1<<WDP1) | (1<<WDP0);
sei();
}

boolean checkCommands() {
wdt_reset();
return tSerial.checkCommands();
}

Expand Down Expand Up @@ -288,16 +275,8 @@ void setup() {
power_adc_disable(); // disable unused analog digital converter needed only for analogRead()
power_spi_disable(); // disable unused Serial Peripheral Interface
SPCR = 0;

// turn off brown-out enable in software
MCUCR = _BV (BODS) | _BV (BODSE); // turn on brown-out enable select
MCUCR = _BV (BODS); // this must be done within 4 clock cycles of above
// ---- end low energy configuration

// setup and start watchdog timer; will reset by calls
// to wdt_reset and checkCommands
watchdogSetup();


// to visualize that the Arduino is running
pinMode (13, OUTPUT); // changed as per below
digitalWrite(13, HIGH);
Expand Down Expand Up @@ -375,7 +354,6 @@ void loop() {
delay(1000);
display.circle(2, 500);
display.clear();
wdt_reset();
delay(100);

if ((millis() - lastTimestamp) > AVERAGE_TIME_SPAN) {
Expand Down

0 comments on commit 4b58f2e

Please sign in to comment.