Permalink
Browse files

Tweaked photosensor

  • Loading branch information...
bikeNomad committed Feb 26, 2012
1 parent fcccc88 commit ccd0d9a5f0c855f0268799fed805169d0f411950
Showing with 3,018 additions and 2,596 deletions.
  1. +14 −6 config.h
  2. +5 −5 firefly.c
  3. BIN firefly.elf
  4. +35 −35 firefly.elf.map
  5. +2 −3 firefly.h
  6. +120 −120 firefly.hex
  7. +2,422 −2,427 firefly.lst
  8. 0 grep
  9. +420 −0 tags
View
@@ -1,11 +1,19 @@
#define RANDOM_SEED 0x74ce
#define SONG2 1
-// non-zero to use a phototransistor for dark detection
-#define USE_PHOTOTRANSISTOR 1
-
-// the photocell is connected to the reset/ADC0 pin
-#define PHOTOTRANSISTOR_ON_RESET_PIN 1
+// Define USE_PHOTOTRANSISTOR as non-zero to use a phototransistor for dark
+// detection. The photocell is connected between the reset/ADC0 pin and
+// ground. The pull-up resistor on the /RESET pin is only enabled if the
+// RSTDISBL fuse is not set, so defining USE_PHOTOTRANSISTOR as 1 will
+// represent a continuous load of up to due to the (approximately 60K) pull-up
+// resistor on that pin.
+// But the load is still minimal: 25uA or so at 1.5V (at which the part will
+// be held in reset anyway). That would be over a year of operation on a
+// 240mAH CR2032 cell.
+
+#ifndef USE_PHOTOTRANSISTOR
+#define USE_PHOTOTRANSISTOR 0
+#endif
// TODO
// non-zero to use the internal temperature for blink speed
@@ -15,7 +23,7 @@
#define DARK_DEBOUNCE 10
// minimum level at ADC before darkness is detected
-#define DARK_MINIMUM 256*9/10
+#define DARK_MINIMUM 256*8/10
#define PHOTOSHOOT 0
View
@@ -193,6 +193,11 @@ ioinit(void)
PRR |= _BV(PRUSI); // Turn off USI clock
PRR |= _BV(PRADC); // Turn off ADC
+#if USE_PHOTOTRANSISTOR
+ // disable digital input buffer on ADC pin to reduce power consumption
+ DIDR0 = _BV(ADC0D);
+#endif
+
/*
* Set up the 8-bit timer 0.
*
@@ -396,14 +401,9 @@ static void still_dark(void)
{
static uint8_t debounce = DARK_DEBOUNCE;
- // set up I/O pins
- PORTB = LEDS_OFF | _BV(PIN_F); // turn ON pullup on PIN_F
// read state
uint8_t photocell = read_adc(PHOTOTRANSISTOR_ADC); // Vcc as VRef, no conn to AREF.
- // turn off pullup
- PORTB = LEDS_OFF; // turn OFF pullup on PIN_F
-
if ((photocell > DARK_MINIMUM) || force_dark)
{
if (!debounce--)
View
Binary file not shown.
View
@@ -135,7 +135,7 @@ LOAD /usr/local/CrossPack-AVR-20100115/lib/gcc/avr/4.3.3/avr25/libgcc.a
.rela.plt
*(.rela.plt)
-.text 0x00000000 0xb4e
+.text 0x00000000 0xb4a
*(.vectors)
.vectors 0x00000000 0x1e /usr/local/CrossPack-AVR-20100115/lib/gcc/avr/4.3.3/../../../../avr/lib/avr25/crttn45.o
0x00000000 __vectors
@@ -217,34 +217,34 @@ LOAD /usr/local/CrossPack-AVR-20100115/lib/gcc/avr/4.3.3/avr25/libgcc.a
0x0000044e __vector_2
0x0000044e __vector_8
0x0000044e __vector_14
- .text 0x00000450 0x6d6 firefly.o
- 0x000007a6 randwaitval
+ .text 0x00000450 0x6d2 firefly.o
+ 0x0000079e randwaitval
0x00000450 __vector_12
- 0x000006c6 randbits
- 0x0000076e randscaleval
- 0x0000072e pickapin
- 0x00000708 pickmaster
- 0x00000a4c main
- 0x00000814 lighted_fireflies
- 0x000007f4 pickasong
- 0x00000606 showbootup
- 0x00000512 __vector_10
- .text 0x00000b26 0x0 /usr/local/CrossPack-AVR-20100115/lib/gcc/avr/4.3.3/avr25/libgcc.a(_mulhi3.o)
- .text 0x00000b26 0x0 /usr/local/CrossPack-AVR-20100115/lib/gcc/avr/4.3.3/avr25/libgcc.a(_exit.o)
- .text 0x00000b26 0x0 /usr/local/CrossPack-AVR-20100115/lib/gcc/avr/4.3.3/avr25/libgcc.a(_copy_data.o)
- .text 0x00000b26 0x0 /usr/local/CrossPack-AVR-20100115/lib/gcc/avr/4.3.3/avr25/libgcc.a(_clear_bss.o)
- 0x00000b26 . = ALIGN (0x2)
+ 0x000006be randbits
+ 0x00000766 randscaleval
+ 0x00000726 pickapin
+ 0x00000700 pickmaster
+ 0x00000a44 main
+ 0x0000080c lighted_fireflies
+ 0x000007ec pickasong
+ 0x000005fe showbootup
+ 0x0000050a __vector_10
+ .text 0x00000b22 0x0 /usr/local/CrossPack-AVR-20100115/lib/gcc/avr/4.3.3/avr25/libgcc.a(_mulhi3.o)
+ .text 0x00000b22 0x0 /usr/local/CrossPack-AVR-20100115/lib/gcc/avr/4.3.3/avr25/libgcc.a(_exit.o)
+ .text 0x00000b22 0x0 /usr/local/CrossPack-AVR-20100115/lib/gcc/avr/4.3.3/avr25/libgcc.a(_copy_data.o)
+ .text 0x00000b22 0x0 /usr/local/CrossPack-AVR-20100115/lib/gcc/avr/4.3.3/avr25/libgcc.a(_clear_bss.o)
+ 0x00000b22 . = ALIGN (0x2)
*(.text.*)
- .text.libgcc 0x00000b26 0x24 /usr/local/CrossPack-AVR-20100115/lib/gcc/avr/4.3.3/avr25/libgcc.a(_mulhi3.o)
- 0x00000b26 __mulhi3
- .text.libgcc 0x00000b4a 0x0 /usr/local/CrossPack-AVR-20100115/lib/gcc/avr/4.3.3/avr25/libgcc.a(_exit.o)
- .text.libgcc 0x00000b4a 0x0 /usr/local/CrossPack-AVR-20100115/lib/gcc/avr/4.3.3/avr25/libgcc.a(_copy_data.o)
- .text.libgcc 0x00000b4a 0x0 /usr/local/CrossPack-AVR-20100115/lib/gcc/avr/4.3.3/avr25/libgcc.a(_clear_bss.o)
- 0x00000b4a . = ALIGN (0x2)
+ .text.libgcc 0x00000b22 0x24 /usr/local/CrossPack-AVR-20100115/lib/gcc/avr/4.3.3/avr25/libgcc.a(_mulhi3.o)
+ 0x00000b22 __mulhi3
+ .text.libgcc 0x00000b46 0x0 /usr/local/CrossPack-AVR-20100115/lib/gcc/avr/4.3.3/avr25/libgcc.a(_exit.o)
+ .text.libgcc 0x00000b46 0x0 /usr/local/CrossPack-AVR-20100115/lib/gcc/avr/4.3.3/avr25/libgcc.a(_copy_data.o)
+ .text.libgcc 0x00000b46 0x0 /usr/local/CrossPack-AVR-20100115/lib/gcc/avr/4.3.3/avr25/libgcc.a(_clear_bss.o)
+ 0x00000b46 . = ALIGN (0x2)
*(.fini9)
- .fini9 0x00000b4a 0x0 /usr/local/CrossPack-AVR-20100115/lib/gcc/avr/4.3.3/avr25/libgcc.a(_exit.o)
- 0x00000b4a exit
- 0x00000b4a _exit
+ .fini9 0x00000b46 0x0 /usr/local/CrossPack-AVR-20100115/lib/gcc/avr/4.3.3/avr25/libgcc.a(_exit.o)
+ 0x00000b46 exit
+ 0x00000b46 _exit
*(.fini9)
*(.fini8)
*(.fini8)
@@ -263,11 +263,11 @@ LOAD /usr/local/CrossPack-AVR-20100115/lib/gcc/avr/4.3.3/avr25/libgcc.a
*(.fini1)
*(.fini1)
*(.fini0)
- .fini0 0x00000b4a 0x4 /usr/local/CrossPack-AVR-20100115/lib/gcc/avr/4.3.3/avr25/libgcc.a(_exit.o)
+ .fini0 0x00000b46 0x4 /usr/local/CrossPack-AVR-20100115/lib/gcc/avr/4.3.3/avr25/libgcc.a(_exit.o)
*(.fini0)
- 0x00000b4e _etext = .
+ 0x00000b4a _etext = .
-.data 0x00800060 0x4e load address 0x00000b4e
+.data 0x00800060 0x4e load address 0x00000b4a
0x00800060 PROVIDE (__data_start, .)
*(.data)
.data 0x00800060 0x0 /usr/local/CrossPack-AVR-20100115/lib/gcc/avr/4.3.3/../../../../avr/lib/avr25/crttn45.o
@@ -322,8 +322,8 @@ LOAD /usr/local/CrossPack-AVR-20100115/lib/gcc/avr/4.3.3/avr25/libgcc.a
0x008000c3 ch1scale
0x008000c4 masterpinmask
0x008000c5 PROVIDE (__bss_end, .)
- 0x00000b4e __data_load_start = LOADADDR (.data)
- 0x00000b9c __data_load_end = (__data_load_start + SIZEOF (.data))
+ 0x00000b4a __data_load_start = LOADADDR (.data)
+ 0x00000b98 __data_load_end = (__data_load_start + SIZEOF (.data))
.noinit 0x008000c5 0x0
0x008000c5 PROVIDE (__noinit_start, .)
@@ -403,9 +403,9 @@ LOAD /usr/local/CrossPack-AVR-20100115/lib/gcc/avr/4.3.3/avr25/libgcc.a
*(.debug_abbrev)
.debug_abbrev 0x00000000 0x275 firefly.o
-.debug_line 0x00000000 0x883
+.debug_line 0x00000000 0x879
*(.debug_line)
- .debug_line 0x00000000 0x883 firefly.o
+ .debug_line 0x00000000 0x879 firefly.o
.debug_frame 0x00000000 0xc0
*(.debug_frame)
@@ -416,9 +416,9 @@ LOAD /usr/local/CrossPack-AVR-20100115/lib/gcc/avr/4.3.3/avr25/libgcc.a
.debug_str 0x00000000 0x3c6 firefly.o
0x420 (size before relaxing)
-.debug_loc 0x00000000 0x247
+.debug_loc 0x00000000 0x23c
*(.debug_loc)
- .debug_loc 0x00000000 0x247 firefly.o
+ .debug_loc 0x00000000 0x23c firefly.o
.debug_macinfo
*(.debug_macinfo)
View
@@ -100,10 +100,9 @@ typedef struct {
#define PIN_F 5
#define PIN_F_ADC 0
-#if PHOTOTRANSISTOR_ON_RESET_PIN
+#if USE_PHOTOTRANSISTOR
+# define PHOTOTRANSISTOR_PIN PIN_F
# define PHOTOTRANSISTOR_ADC PIN_F_ADC
-#else
-# define PHOTOTRANSISTOR_ADC PIN_A_ADC
#endif
#define FLAGS0 GPIOR0
Oops, something went wrong.

0 comments on commit ccd0d9a

Please sign in to comment.