forked from luon/wordclock
Added settings_example.h; user must now copy this to settings.h first!
settings.h contains hardware specific settings and user preferences. settings.h is ignored in git repository.
This commit is contained in:
parent
ff98f561af
commit
6de020aed1
|
@ -12,8 +12,9 @@ the following symlink in the directory where you found this file:
|
|||
|
||||
ln -s /usr/share/arduino/hardware/ hardware
|
||||
|
||||
Next, enter the wordclock directory. Use 'make' to build the source and 'make
|
||||
upload' to upload the source to the clock.
|
||||
Next, enter the wordclock directory. Copy 'settings_example.h' to 'settings.h'
|
||||
and modify it for your hardware and preferences. Use 'make' to build the source
|
||||
and 'make upload' to upload the source to the clock.
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1 +1,3 @@
|
|||
build-cli
|
||||
\.*\.swp
|
||||
settings.h
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
#ifndef SETTINGS_H
|
||||
#define SETTINGS_H
|
||||
|
||||
// specify the language - defines the header to be included
|
||||
// available choices - English, Danish, French, German
|
||||
//#define LANGUAGE "English.h"
|
||||
#define LANGUAGE "Dutch.h"
|
||||
#define PRINT_DEBUG_LEVEL 1
|
||||
|
||||
// set SKIPSELFTEST to 1 to skip selftest
|
||||
#define SKIPSELFTEST 1
|
||||
|
||||
// set USELIGHTSENSOR to 1 to use ambient light sensor connected to ADC0 (pin
|
||||
// 23)
|
||||
#define USELIGHTSENSOR 1
|
||||
// analog input put to which ambiend light sensor is connected
|
||||
#define LIGHTSENSOR_INPUTPIN 0
|
||||
// bottom of light sensor (ambient light values at or lower than this level will
|
||||
// be mapped to MINBRIGHTNESS)
|
||||
#define LIGHTSENSOR_BOTTOM 0
|
||||
// top of light sensor (ambient light values at or higher than this level will
|
||||
// be mapped to MAXBRIGHTNESS)
|
||||
#define LIGHTSENSOR_TOP 150
|
||||
// slope of mapping function at bottom
|
||||
#define LIGHTSENSOR_ALPHA1 0.02
|
||||
// slope of mapping function at top
|
||||
#define LIGHTSENSOR_ALPHA2 0.20
|
||||
|
||||
// weight for exponential decaying averaging (actual weigth is 2 ^
|
||||
// LIGHTSENSOR_WEIGHT)
|
||||
#define LIGHTSENSOR_WEIGHT 4
|
||||
// base of exponential mapping (must be > 1)
|
||||
#define LIGHTSENSOR_BASE 1.40
|
||||
|
||||
// N_PWM_STEPS could be increased to 21, but this causes some visible flickering
|
||||
// at low intensities
|
||||
#define N_PWM_STEPS 11
|
||||
// NIGHT Brightness setting 0 = off, (N_PWM_STEPS - 1) = full
|
||||
#define MINBRIGHTNESS 3
|
||||
// DAY Brightness setting 0 = off, (N_PWM_STEPS - 1) = full
|
||||
#define MAXBRIGHTNESS (N_PWM_STEPS - 1)
|
||||
// start MINBRIGHTNESS at NIGHTLIGHTHOUR (7 pm)
|
||||
#define NIGHTLIGHTHOUR 19
|
||||
// start MAXBRIGHTNESS at DAYLIGHTHOUR (7 am)
|
||||
#define DAYLIGHTHOUR 7
|
||||
|
||||
#endif //SETTINGS_H
|
|
@ -5,6 +5,7 @@
|
|||
#include <avr/io.h>
|
||||
#include <math.h>
|
||||
#include <pt.h>
|
||||
#include "settings.h"
|
||||
|
||||
// uncomment the following to speed up the timer for testing
|
||||
//#define TESTMODE
|
||||
|
@ -14,13 +15,6 @@ void ledsoff(void);
|
|||
void setup(void);
|
||||
void SWversion(void);
|
||||
|
||||
// specify the language - defines the header to be included
|
||||
// available choices - English, Danish, French, German
|
||||
//#define LANGUAGE "English.h"
|
||||
#define LANGUAGE "Dutch.h"
|
||||
#define PRINT_DEBUG_LEVEL 1
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
* *
|
||||
* W O R D C L O C K - A clock that tells the time using words. *
|
||||
|
@ -63,49 +57,12 @@ void SWversion(void);
|
|||
* using an ISR to control the display
|
||||
*/
|
||||
|
||||
// set SKIPSELFTEST to 1 to skip selftest
|
||||
#define SKIPSELFTEST 1
|
||||
|
||||
// set USELIGHTSENSOR to 1 to use ambient light sensor connected to ADC0 (pin
|
||||
// 23)
|
||||
#define USELIGHTSENSOR 1
|
||||
// analog input put to which ambiend light sensor is connected
|
||||
#define LIGHTSENSOR_INPUTPIN 0
|
||||
// bottom of light sensor (ambient light values at or lower than this level will
|
||||
// be mapped to MINBRIGHTNESS)
|
||||
#define LIGHTSENSOR_BOTTOM 0
|
||||
// top of light sensor (ambient light values at or higher than this level will
|
||||
// be mapped to MAXBRIGHTNESS)
|
||||
#define LIGHTSENSOR_TOP 150
|
||||
// slope of mapping function at bottom
|
||||
#define LIGHTSENSOR_ALPHA1 0.02
|
||||
// slope of mapping function at top
|
||||
#define LIGHTSENSOR_ALPHA2 0.20
|
||||
|
||||
// weight for exponential decaying averaging (actual weigth is 2 ^ LIGHTSENSOR_WEIGHT)
|
||||
#define LIGHTSENSOR_WEIGHT 4
|
||||
// base of exponential mapping (must be > 1)
|
||||
#define LIGHTSENSOR_BASE 1.40
|
||||
|
||||
#define N_PWM_STEPS 11
|
||||
// DAY Brightness setting 0 = off, N_PWM_STEPS - 1 = full
|
||||
#define MAXBRIGHTNESS (N_PWM_STEPS - 1)
|
||||
// start MAXBRIGHTNESS at DAYLIGHTHOUR (7 am)
|
||||
#define DAYLIGHTHOUR 7
|
||||
// NIGHT Brightness setting 0 = off, N_PWM_STEPS - 1 = full
|
||||
#define MINBRIGHTNESS 3
|
||||
// start MINBRIGHTNESS at NIGHTLIGHTHOUR (7 pm)
|
||||
#define NIGHTLIGHTHOUR 19
|
||||
|
||||
#define INIT_TIMER_COUNT 6
|
||||
#define RESET_TIMER2 TCNT2 = INIT_TIMER_COUNT
|
||||
|
||||
// there are only 20 brightness levels and 1024 lightsensor levels -> we need to
|
||||
// scale the brightness levels to something closer to avoid having to work with
|
||||
// floating point numbers
|
||||
#define LIGHTSENSOR_SCALE 10
|
||||
unsigned int brightness_per_unit_light = ((1 << LIGHTSENSOR_SCALE) * (MAXBRIGHTNESS -
|
||||
MINBRIGHTNESS)) / (LIGHTSENSOR_TOP - LIGHTSENSOR_BOTTOM);
|
||||
|
||||
int hour=12, minute=0, second=0;
|
||||
// incremented the second counter
|
||||
|
@ -159,12 +116,9 @@ volatile boolean inputBufferComplete = false;
|
|||
// define the language to be used for this project:
|
||||
#include LANGUAGE // The language pack
|
||||
|
||||
|
||||
|
||||
/* Create buffers */
|
||||
char buf[50]; // time output string for debugging
|
||||
|
||||
|
||||
// create an object that talks to the RTC
|
||||
DS1302 rtc(DS1302CEPin, DS1302IOPin, DS1302CLKPin);
|
||||
|
||||
|
@ -187,8 +141,6 @@ void print_DS1302time()
|
|||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
int n;
|
||||
|
@ -421,9 +373,8 @@ ISR(TIMER2_OVF_vect) {
|
|||
timercount = N_PWM_STEPS - 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ledsoff(void) {
|
||||
void ledsoff(void)
|
||||
{
|
||||
Display1=0;
|
||||
Display2=0;
|
||||
Display3=0;
|
||||
|
@ -433,7 +384,8 @@ void ledsoff(void) {
|
|||
Led4=0;
|
||||
}
|
||||
|
||||
void incrementtime(void){
|
||||
void incrementtime(void)
|
||||
{
|
||||
// increment the time counters keeping care to rollover as required
|
||||
second=0;
|
||||
if (++minute >= 60) {
|
||||
|
|
Loading…
Reference in New Issue