Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial commit.

  • Loading branch information...
commit 82f32cebdffbf895be1652504e1c40d6fec053f0 1 parent c7cc032
@ericbarch authored
Showing with 31,486 additions and 0 deletions.
  1. BIN  Archived/AirsoftBoard.png
  2. BIN  Archived/Airsoft_PCB_v0.1.bmp
  3. BIN  Archived/ExpressPCB.pdf
  4. +1 −0  Archived/Fuses_Command.txt
  5. +29 −0 Archived/KeyMap.txt
  6. +12 −0 Archived/Keypad.txt
  7. +388 −0 Archived/Makefile
  8. +74 −0 Archived/SparkFun_Keypad.txt
  9. +5 −0 Archived/attiny2313-8mhz.txt
  10. +388 −0 Archived/esmokebomb_v01/Makefile
  11. +403 −0 Archived/esmokebomb_v01/esmokebomb_v01.c
  12. +388 −0 Archived/esmokebomb_v02/Makefile
  13. +45 −0 Archived/esmokebomb_v02/eSmoke_PinOut.txt
  14. +403 −0 Archived/esmokebomb_v02/esmokebomb_v02.c
  15. BIN  Datasheets/36.pdf
  16. BIN  Datasheets/37312.pdf
  17. BIN  Datasheets/FQP4N20L.pdf
  18. BIN  Datasheets/KT-400377.pdf
  19. BIN  Datasheets/LITEON_7SEG.pdf
  20. +5 −0 Guidelines.txt
  21. +595 −0 MockTimer_v3/MockTimer_v3.pde
  22. BIN  PCB/Mainboard.b##
  23. BIN  PCB/Mainboard.b#1
  24. BIN  PCB/Mainboard.b#2
  25. BIN  PCB/Mainboard.b#3
  26. BIN  PCB/Mainboard.b#4
  27. BIN  PCB/Mainboard.b#5
  28. BIN  PCB/Mainboard.b#6
  29. BIN  PCB/Mainboard.b#7
  30. BIN  PCB/Mainboard.b#8
  31. BIN  PCB/Mainboard.b#9
  32. BIN  PCB/Mainboard.brd
  33. +6,532 −0 PCB/Mainboard.cmp
  34. +119 −0 PCB/Mainboard.drd
  35. +43 −0 PCB/Mainboard.dri
  36. +47 −0 PCB/Mainboard.gpi
  37. +1,600 −0 PCB/Mainboard.plc
  38. +10 −0 PCB/Mainboard.pls
  39. +25 −0 PCB/Mainboard.pro
  40. BIN  PCB/Mainboard.s#1
  41. BIN  PCB/Mainboard.s#2
  42. BIN  PCB/Mainboard.s#3
  43. BIN  PCB/Mainboard.s#4
  44. BIN  PCB/Mainboard.s#5
  45. BIN  PCB/Mainboard.s#6
  46. BIN  PCB/Mainboard.s#7
  47. BIN  PCB/Mainboard.s#8
  48. BIN  PCB/Mainboard.s#9
  49. BIN  PCB/Mainboard.sch
  50. +20 −0 PCB/Mainboard.silk
  51. +5,486 −0 PCB/Mainboard.sol
  52. +179 −0 PCB/Mainboard.stc
  53. +179 −0 PCB/Mainboard.sts
  54. +415 −0 PCB/eagle.epf
  55. BIN  PCB/timerboard_111010/Archive.zip
  56. +6,532 −0 PCB/timerboard_111010/Mainboard.cmp
  57. +119 −0 PCB/timerboard_111010/Mainboard.drd
  58. +1,600 −0 PCB/timerboard_111010/Mainboard.plc
  59. +5,486 −0 PCB/timerboard_111010/Mainboard.sol
  60. +179 −0 PCB/timerboard_111010/Mainboard.stc
  61. +179 −0 PCB/timerboard_111010/Mainboard.sts
  62. BIN  PartsList.xls
View
BIN  Archived/AirsoftBoard.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  Archived/Airsoft_PCB_v0.1.bmp
Binary file not shown
View
BIN  Archived/ExpressPCB.pdf
Binary file not shown
View
1  Archived/Fuses_Command.txt
@@ -0,0 +1 @@
+avrdude -p m328p -c usbtiny -V -e -U lfuse:w:0xff:m -U hfuse:w:0xd9:m -U efuse:w:0x07:m
View
29 Archived/KeyMap.txt
@@ -0,0 +1,29 @@
+1 - NO CONNECTION
+2 - LCD D4
+3 - LCD D5
+4 - LCD D6
+5 - BUZZER
+6 - LCD D7
+7 - 5V
+8 - GND
+9 - CLOCK 1
+10 - CLOCK 2
+11 - LCD ENABLE
+12 - LCD RS
+13 - KEYPAD 7
+14 - KEYPAD 1
+--------------
+15 - KEYPAD 2
+16 - KEYPAD 3
+17 - KEYPAD 4
+18 - KEYPAD 5
+19 - KEYPAD 6
+20 - 5V
+21 - NO CONNECTION
+22 - GND
+23 - MOSFET
+24 - DIG IN 1
+25 - DIG IN 2
+26 - DIG IN 3
+27 - ANA IN 4
+28 - ANA IN 5
View
12 Archived/Keypad.txt
@@ -0,0 +1,12 @@
+Ard - Keypad
+2 - dig in 8
+3 - dig in 9
+4 - dig in 10
+5 - dig in 11
+6 - dig in 12
+7 - dig in 13
+8 - dig in 7
+
+Looking Key Side Up (Left to Right)
+
+http://www.arduino.cc/playground/Code/Keypad
View
388 Archived/Makefile
@@ -0,0 +1,388 @@
+# WinAVR Sample makefile written by Eric B. Weddington, Jörg Wunsch, et al.
+# Modified (bringing often-changed options to the top) by Elliot Williams
+
+# make all = Make software and program
+# make clean = Clean out built project files.
+# make coff = Convert ELF to AVR COFF (for use with AVR Studio 3.x or VMLAB).
+# make extcoff = Convert ELF to AVR Extended COFF (for use with AVR Studio
+# 4.07 or greater).
+# make program = Download the hex file to the device, using avrdude. Please
+# customize the avrdude settings below first!
+# make filename.s = Just compile filename.c into the assembler code only
+# To rebuild project do "make clean" then "make all".
+
+# Microcontroller Type
+# MCU = attiny13
+MCU = attiny2313
+# MCU = atmega8
+
+# Target file name (without extension).
+TARGET = airsoft_bomb_v03
+
+# Programming hardware: type avrdude -c ?
+# to get a full listing.
+AVRDUDE_PROGRAMMER = usbtiny # official name of
+
+# AVRDUDE_PORT = /dev/parport0 # linux
+AVRDUDE_PORT = com1 # windows
+
+############# Don't need to change below here for most purposes (Elliot)
+
+# Optimization level, can be [0, 1, 2, 3, s]. 0 turns off optimization.
+# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
+OPT = s
+
+# Output format. (can be srec, ihex, binary)
+FORMAT = ihex
+
+# List C source files here. (C dependencies are automatically generated.)
+SRC = $(TARGET).c
+
+# If there is more than one source file, append them above, or modify and
+# uncomment the following:
+#SRC += foo.c bar.c
+
+# You can also wrap lines by appending a backslash to the end of the line:
+#SRC += baz.c \
+#xyzzy.c
+
+
+
+# List Assembler source files here.
+# Make them always end in a capital .S. Files ending in a lowercase .s
+# will not be considered source files but generated files (assembler
+# output from the compiler), and will be deleted upon "make clean"!
+# Even though the DOS/Win* filesystem matches both .s and .S the same,
+# it will preserve the spelling of the filenames, and gcc itself does
+# care about how the name is spelled on its command-line.
+ASRC =
+
+
+# List any extra directories to look for include files here.
+# Each directory must be seperated by a space.
+EXTRAINCDIRS =
+
+
+# Optional compiler flags.
+# -g: generate debugging information (for GDB, or for COFF conversion)
+# -O*: optimization level
+# -f...: tuning, see gcc manual and avr-libc documentation
+# -Wall...: warning level
+# -Wa,...: tell GCC to pass this to the assembler.
+# -ahlms: create assembler listing
+CFLAGS = -g -O$(OPT) \
+-funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums \
+-Wall -Wstrict-prototypes \
+-Wa,-adhlns=$(<:.c=.lst) \
+$(patsubst %,-I%,$(EXTRAINCDIRS))
+
+
+# Set a "language standard" compiler flag.
+# Unremark just one line below to set the language standard to use.
+# gnu99 = C99 + GNU extensions. See GCC manual for more information.
+#CFLAGS += -std=c89
+#CFLAGS += -std=gnu89
+#CFLAGS += -std=c99
+CFLAGS += -std=gnu99
+
+
+
+# Optional assembler flags.
+# -Wa,...: tell GCC to pass this to the assembler.
+# -ahlms: create listing
+# -gstabs: have the assembler create line number information; note that
+# for use in COFF files, additional information about filenames
+# and function names needs to be present in the assembler source
+# files -- see avr-libc docs [FIXME: not yet described there]
+ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
+
+
+
+# Optional linker flags.
+# -Wl,...: tell GCC to pass this to linker.
+# -Map: create map file
+# --cref: add cross reference to map file
+LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
+
+
+
+# Additional libraries
+
+# Minimalistic printf version
+#LDFLAGS += -Wl,-u,vfprintf -lprintf_min
+
+# Floating point printf version (requires -lm below)
+#LDFLAGS += -Wl,-u,vfprintf -lprintf_flt
+
+# -lm = math library
+LDFLAGS += -lm
+
+
+# Programming support using avrdude. Settings and variables.
+
+
+AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
+#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
+
+AVRDUDE_FLAGS = -p $(MCU) -c $(AVRDUDE_PROGRAMMER)
+
+# Uncomment the following if you want avrdude's erase cycle counter.
+# Note that this counter needs to be initialized first using -Yn,
+# see avrdude manual.
+#AVRDUDE_ERASE += -y
+
+# Uncomment the following if you do /not/ wish a verification to be
+# performed after programming the device.
+#AVRDUDE_FLAGS += -V
+
+# Increase verbosity level. Please use this when submitting bug
+# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
+# to submit bug reports.
+#AVRDUDE_FLAGS += -v -v
+
+#Run while cable attached or don't
+#AVRDUDE_FLAGS += -E reset #keep chip disabled while cable attached
+#AVRDUDE_FLAGS += -E noreset
+
+#AVRDUDE_WRITE_FLASH = -U lfuse:w:0x04:m #run with 8 Mhz clock
+
+#AVRDUDE_WRITE_FLASH = -U lfuse:w:0x21:m #run with 1 Mhz clock #default clock mode
+
+#AVRDUDE_WRITE_FLASH = -U lfuse:w:0x01:m #run with 1 Mhz clock no start up time
+
+# ---------------------------------------------------------------------------
+
+# Define directories, if needed.
+DIRAVR = c:/winavr
+DIRAVRBIN = $(DIRAVR)/bin
+DIRAVRUTILS = $(DIRAVR)/utils/bin
+DIRINC = .
+DIRLIB = $(DIRAVR)/avr/lib
+
+
+# Define programs and commands.
+SHELL = sh
+
+CC = avr-gcc
+
+OBJCOPY = avr-objcopy
+OBJDUMP = avr-objdump
+SIZE = avr-size
+
+
+# Programming support using avrdude.
+AVRDUDE = avrdude
+
+
+REMOVE = rm -f
+COPY = cp
+
+HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
+ELFSIZE = $(SIZE) -A $(TARGET).elf
+
+
+
+# Define Messages
+# English
+MSG_ERRORS_NONE = Errors: none
+MSG_BEGIN = -------- begin --------
+MSG_END = -------- end --------
+MSG_SIZE_BEFORE = Size before:
+MSG_SIZE_AFTER = Size after:
+MSG_COFF = Converting to AVR COFF:
+MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
+MSG_FLASH = Creating load file for Flash:
+MSG_EEPROM = Creating load file for EEPROM:
+MSG_EXTENDED_LISTING = Creating Extended Listing:
+MSG_SYMBOL_TABLE = Creating Symbol Table:
+MSG_LINKING = Linking:
+MSG_COMPILING = Compiling:
+MSG_ASSEMBLING = Assembling:
+MSG_CLEANING = Cleaning project:
+
+
+
+
+# Define all object files.
+OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
+
+# Define all listing files.
+LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)
+
+# Combine all necessary flags and optional flags.
+# Add target processor to flags.
+ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
+ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
+
+
+
+# Default target: make program!
+all: begin gccversion sizebefore $(TARGET).elf $(TARGET).hex $(TARGET).eep \
+ $(TARGET).lss $(TARGET).sym sizeafter finished end
+ $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
+
+# Eye candy.
+# AVR Studio 3.x does not check make's exit code but relies on
+# the following magic strings to be generated by the compile job.
+begin:
+ @echo
+ @echo $(MSG_BEGIN)
+
+finished:
+ @echo $(MSG_ERRORS_NONE)
+
+end:
+ @echo $(MSG_END)
+ @echo
+
+
+# Display size of file.
+sizebefore:
+ @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
+
+sizeafter:
+ @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
+
+
+
+# Display compiler version information.
+gccversion :
+ @$(CC) --version
+
+
+
+
+# Convert ELF to COFF for use in debugging / simulating in
+# AVR Studio or VMLAB.
+COFFCONVERT=$(OBJCOPY) --debugging \
+ --change-section-address .data-0x800000 \
+ --change-section-address .bss-0x800000 \
+ --change-section-address .noinit-0x800000 \
+ --change-section-address .eeprom-0x810000
+
+
+coff: $(TARGET).elf
+ @echo
+ @echo $(MSG_COFF) $(TARGET).cof
+ $(COFFCONVERT) -O coff-avr $< $(TARGET).cof
+
+
+extcoff: $(TARGET).elf
+ @echo
+ @echo $(MSG_EXTENDED_COFF) $(TARGET).cof
+ $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
+
+
+
+
+# Program the device.
+program: $(TARGET).hex $(TARGET).eep
+ $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
+
+
+
+
+# Create final output files (.hex, .eep) from ELF output file.
+%.hex: %.elf
+ @echo
+ @echo $(MSG_FLASH) $@
+ $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
+
+%.eep: %.elf
+ @echo
+ @echo $(MSG_EEPROM) $@
+ -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
+ --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
+
+# Create extended listing file from ELF output file.
+%.lss: %.elf
+ @echo
+ @echo $(MSG_EXTENDED_LISTING) $@
+ $(OBJDUMP) -h -S $< > $@
+
+# Create a symbol table from ELF output file.
+%.sym: %.elf
+ @echo
+ @echo $(MSG_SYMBOL_TABLE) $@
+ avr-nm -n $< > $@
+
+
+
+# Link: create ELF output file from object files.
+.SECONDARY : $(TARGET).elf
+.PRECIOUS : $(OBJ)
+%.elf: $(OBJ)
+ @echo
+ @echo $(MSG_LINKING) $@
+ $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)
+
+
+# Compile: create object files from C source files.
+%.o : %.c
+ @echo
+ @echo $(MSG_COMPILING) $<
+ $(CC) -c $(ALL_CFLAGS) $< -o $@
+
+
+# Compile: create assembler files from C source files.
+%.s : %.c
+ $(CC) -S $(ALL_CFLAGS) $< -o $@
+
+
+# Assemble: create object files from assembler source files.
+%.o : %.S
+ @echo
+ @echo $(MSG_ASSEMBLING) $<
+ $(CC) -c $(ALL_ASFLAGS) $< -o $@
+
+
+
+
+
+
+# Target: clean project.
+clean: begin clean_list finished end
+
+clean_list :
+ @echo
+ @echo $(MSG_CLEANING)
+ $(REMOVE) $(TARGET).hex
+ $(REMOVE) $(TARGET).eep
+ $(REMOVE) $(TARGET).obj
+ $(REMOVE) $(TARGET).cof
+ $(REMOVE) $(TARGET).elf
+ $(REMOVE) $(TARGET).map
+ $(REMOVE) $(TARGET).obj
+ $(REMOVE) $(TARGET).a90
+ $(REMOVE) $(TARGET).sym
+ $(REMOVE) $(TARGET).lnk
+ $(REMOVE) $(TARGET).lss
+ $(REMOVE) $(OBJ)
+ $(REMOVE) $(LST)
+ $(REMOVE) $(SRC:.c=.s)
+ $(REMOVE) $(SRC:.c=.d)
+ $(REMOVE) *~
+
+# Automatically generate C source code dependencies.
+# (Code originally taken from the GNU make user manual and modified
+# (See README.txt Credits).)
+#
+# Note that this will work with sh (bash) and sed that is shipped with WinAVR
+# (see the SHELL variable defined above).
+# This may not work with other shells or other seds.
+#
+%.d: %.c
+ set -e; $(CC) -MM $(ALL_CFLAGS) $< \
+ | sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > $@; \
+ [ -s $@ ] || rm -f $@
+
+
+# Remove the '-' if you want to see the dependency files generated.
+-include $(SRC:.c=.d)
+
+
+
+# Listing of phony targets.
+.PHONY : all begin finish end sizebefore sizeafter gccversion coff extcoff \
+ clean clean_list program
+
View
74 Archived/SparkFun_Keypad.txt
@@ -0,0 +1,74 @@
+//SparkFun Matrix KeyPad Decode
+
+#define COL0 3
+#define COL1 1
+#define COL2 5
+
+#define ROW0 2
+#define ROW1 7
+#define ROW2 6
+#define ROW3 4
+
+#define C0R0 1
+#define C0R1 4
+#define C0R2 7
+#define C0R3 10 //*
+#define C1R0 2
+#define C1R1 5
+#define C1R2 8
+#define C1R3 0
+#define C2R0 3
+#define C2R1 6
+#define C2R2 9
+#define C2R3 11 //#
+
+int debouncePin(int input) {
+ delay(25);
+
+ if (pin(input) == HIGH) {
+ while (pin(input) == HIGH){}
+ return 1;
+ }
+
+ return 0;
+}
+
+void scanKeyPad() {
+ //Drive COL1 Low
+ //Drive COL2 Low
+ //Drive COL0 High
+ if (debouncePin(ROW0))
+ return C0R0;
+ else if (debouncePin(ROW1))
+ return C0R1;
+ else if (debouncePin(ROW2))
+ return C0R2;
+ else if (debouncePin(ROW3))
+ return C0R3;
+ else {
+ //Drive COL0 Low
+ //Drive COL1 High
+ }
+ if (debouncePin(ROW0))
+ return C1R0;
+ else if (debouncePin(ROW1))
+ return C1R1;
+ else if (debouncePin(ROW2))
+ return C1R2;
+ else if (debouncePin(ROW3))
+ return C1R3;
+ else {
+ //Drive COL1 Low
+ //Drive COL2 High
+ }
+ if (debouncePin(ROW0))
+ return C2R0;
+ else if (debouncePin(ROW1))
+ return C2R1;
+ else if (debouncePin(ROW2))
+ return C2R2;
+ else if (debouncePin(ROW3))
+ return C2R3;
+ else
+ return 13;
+}
View
5 Archived/attiny2313-8mhz.txt
@@ -0,0 +1,5 @@
+avrdude -c usbtiny -p t2313 -v -U lfuse:w:0xE4:m
+
+VS the original of:
+
+0x64
View
388 Archived/esmokebomb_v01/Makefile
@@ -0,0 +1,388 @@
+# WinAVR Sample makefile written by Eric B. Weddington, Jörg Wunsch, et al.
+# Modified (bringing often-changed options to the top) by Elliot Williams
+
+# make all = Make software and program
+# make clean = Clean out built project files.
+# make coff = Convert ELF to AVR COFF (for use with AVR Studio 3.x or VMLAB).
+# make extcoff = Convert ELF to AVR Extended COFF (for use with AVR Studio
+# 4.07 or greater).
+# make program = Download the hex file to the device, using avrdude. Please
+# customize the avrdude settings below first!
+# make filename.s = Just compile filename.c into the assembler code only
+# To rebuild project do "make clean" then "make all".
+
+# Microcontroller Type
+# MCU = attiny13
+MCU = attiny2313
+# MCU = atmega8
+
+# Target file name (without extension).
+TARGET = esmokebomb_v01
+
+# Programming hardware: type avrdude -c ?
+# to get a full listing.
+AVRDUDE_PROGRAMMER = dapa # official name of
+
+# AVRDUDE_PORT = /dev/parport0 # linux
+AVRDUDE_PORT = lpt1 # windows
+
+############# Don't need to change below here for most purposes (Elliot)
+
+# Optimization level, can be [0, 1, 2, 3, s]. 0 turns off optimization.
+# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
+OPT = s
+
+# Output format. (can be srec, ihex, binary)
+FORMAT = ihex
+
+# List C source files here. (C dependencies are automatically generated.)
+SRC = $(TARGET).c
+
+# If there is more than one source file, append them above, or modify and
+# uncomment the following:
+#SRC += foo.c bar.c
+
+# You can also wrap lines by appending a backslash to the end of the line:
+#SRC += baz.c \
+#xyzzy.c
+
+
+
+# List Assembler source files here.
+# Make them always end in a capital .S. Files ending in a lowercase .s
+# will not be considered source files but generated files (assembler
+# output from the compiler), and will be deleted upon "make clean"!
+# Even though the DOS/Win* filesystem matches both .s and .S the same,
+# it will preserve the spelling of the filenames, and gcc itself does
+# care about how the name is spelled on its command-line.
+ASRC =
+
+
+# List any extra directories to look for include files here.
+# Each directory must be seperated by a space.
+EXTRAINCDIRS =
+
+
+# Optional compiler flags.
+# -g: generate debugging information (for GDB, or for COFF conversion)
+# -O*: optimization level
+# -f...: tuning, see gcc manual and avr-libc documentation
+# -Wall...: warning level
+# -Wa,...: tell GCC to pass this to the assembler.
+# -ahlms: create assembler listing
+CFLAGS = -g -O$(OPT) \
+-funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums \
+-Wall -Wstrict-prototypes \
+-Wa,-adhlns=$(<:.c=.lst) \
+$(patsubst %,-I%,$(EXTRAINCDIRS))
+
+
+# Set a "language standard" compiler flag.
+# Unremark just one line below to set the language standard to use.
+# gnu99 = C99 + GNU extensions. See GCC manual for more information.
+#CFLAGS += -std=c89
+#CFLAGS += -std=gnu89
+#CFLAGS += -std=c99
+CFLAGS += -std=gnu99
+
+
+
+# Optional assembler flags.
+# -Wa,...: tell GCC to pass this to the assembler.
+# -ahlms: create listing
+# -gstabs: have the assembler create line number information; note that
+# for use in COFF files, additional information about filenames
+# and function names needs to be present in the assembler source
+# files -- see avr-libc docs [FIXME: not yet described there]
+ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
+
+
+
+# Optional linker flags.
+# -Wl,...: tell GCC to pass this to linker.
+# -Map: create map file
+# --cref: add cross reference to map file
+LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
+
+
+
+# Additional libraries
+
+# Minimalistic printf version
+#LDFLAGS += -Wl,-u,vfprintf -lprintf_min
+
+# Floating point printf version (requires -lm below)
+#LDFLAGS += -Wl,-u,vfprintf -lprintf_flt
+
+# -lm = math library
+LDFLAGS += -lm
+
+
+# Programming support using avrdude. Settings and variables.
+
+
+AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
+#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
+
+AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
+
+# Uncomment the following if you want avrdude's erase cycle counter.
+# Note that this counter needs to be initialized first using -Yn,
+# see avrdude manual.
+#AVRDUDE_ERASE += -y
+
+# Uncomment the following if you do /not/ wish a verification to be
+# performed after programming the device.
+#AVRDUDE_FLAGS += -V
+
+# Increase verbosity level. Please use this when submitting bug
+# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
+# to submit bug reports.
+#AVRDUDE_FLAGS += -v -v
+
+#Run while cable attached or don't
+AVRDUDE_FLAGS += -E reset #keep chip disabled while cable attached
+#AVRDUDE_FLAGS += -E noreset
+
+#AVRDUDE_WRITE_FLASH = -U lfuse:w:0x04:m #run with 8 Mhz clock
+
+#AVRDUDE_WRITE_FLASH = -U lfuse:w:0x21:m #run with 1 Mhz clock #default clock mode
+
+#AVRDUDE_WRITE_FLASH = -U lfuse:w:0x01:m #run with 1 Mhz clock no start up time
+
+# ---------------------------------------------------------------------------
+
+# Define directories, if needed.
+DIRAVR = c:/winavr
+DIRAVRBIN = $(DIRAVR)/bin
+DIRAVRUTILS = $(DIRAVR)/utils/bin
+DIRINC = .
+DIRLIB = $(DIRAVR)/avr/lib
+
+
+# Define programs and commands.
+SHELL = sh
+
+CC = avr-gcc
+
+OBJCOPY = avr-objcopy
+OBJDUMP = avr-objdump
+SIZE = avr-size
+
+
+# Programming support using avrdude.
+AVRDUDE = avrdude
+
+
+REMOVE = rm -f
+COPY = cp
+
+HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
+ELFSIZE = $(SIZE) -A $(TARGET).elf
+
+
+
+# Define Messages
+# English
+MSG_ERRORS_NONE = Errors: none
+MSG_BEGIN = -------- begin --------
+MSG_END = -------- end --------
+MSG_SIZE_BEFORE = Size before:
+MSG_SIZE_AFTER = Size after:
+MSG_COFF = Converting to AVR COFF:
+MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
+MSG_FLASH = Creating load file for Flash:
+MSG_EEPROM = Creating load file for EEPROM:
+MSG_EXTENDED_LISTING = Creating Extended Listing:
+MSG_SYMBOL_TABLE = Creating Symbol Table:
+MSG_LINKING = Linking:
+MSG_COMPILING = Compiling:
+MSG_ASSEMBLING = Assembling:
+MSG_CLEANING = Cleaning project:
+
+
+
+
+# Define all object files.
+OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
+
+# Define all listing files.
+LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)
+
+# Combine all necessary flags and optional flags.
+# Add target processor to flags.
+ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
+ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
+
+
+
+# Default target: make program!
+all: begin gccversion sizebefore $(TARGET).elf $(TARGET).hex $(TARGET).eep \
+ $(TARGET).lss $(TARGET).sym sizeafter finished end
+ $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
+
+# Eye candy.
+# AVR Studio 3.x does not check make's exit code but relies on
+# the following magic strings to be generated by the compile job.
+begin:
+ @echo
+ @echo $(MSG_BEGIN)
+
+finished:
+ @echo $(MSG_ERRORS_NONE)
+
+end:
+ @echo $(MSG_END)
+ @echo
+
+
+# Display size of file.
+sizebefore:
+ @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
+
+sizeafter:
+ @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
+
+
+
+# Display compiler version information.
+gccversion :
+ @$(CC) --version
+
+
+
+
+# Convert ELF to COFF for use in debugging / simulating in
+# AVR Studio or VMLAB.
+COFFCONVERT=$(OBJCOPY) --debugging \
+ --change-section-address .data-0x800000 \
+ --change-section-address .bss-0x800000 \
+ --change-section-address .noinit-0x800000 \
+ --change-section-address .eeprom-0x810000
+
+
+coff: $(TARGET).elf
+ @echo
+ @echo $(MSG_COFF) $(TARGET).cof
+ $(COFFCONVERT) -O coff-avr $< $(TARGET).cof
+
+
+extcoff: $(TARGET).elf
+ @echo
+ @echo $(MSG_EXTENDED_COFF) $(TARGET).cof
+ $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
+
+
+
+
+# Program the device.
+program: $(TARGET).hex $(TARGET).eep
+ $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
+
+
+
+
+# Create final output files (.hex, .eep) from ELF output file.
+%.hex: %.elf
+ @echo
+ @echo $(MSG_FLASH) $@
+ $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
+
+%.eep: %.elf
+ @echo
+ @echo $(MSG_EEPROM) $@
+ -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
+ --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
+
+# Create extended listing file from ELF output file.
+%.lss: %.elf
+ @echo
+ @echo $(MSG_EXTENDED_LISTING) $@
+ $(OBJDUMP) -h -S $< > $@
+
+# Create a symbol table from ELF output file.
+%.sym: %.elf
+ @echo
+ @echo $(MSG_SYMBOL_TABLE) $@
+ avr-nm -n $< > $@
+
+
+
+# Link: create ELF output file from object files.
+.SECONDARY : $(TARGET).elf
+.PRECIOUS : $(OBJ)
+%.elf: $(OBJ)
+ @echo
+ @echo $(MSG_LINKING) $@
+ $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)
+
+
+# Compile: create object files from C source files.
+%.o : %.c
+ @echo
+ @echo $(MSG_COMPILING) $<
+ $(CC) -c $(ALL_CFLAGS) $< -o $@
+
+
+# Compile: create assembler files from C source files.
+%.s : %.c
+ $(CC) -S $(ALL_CFLAGS) $< -o $@
+
+
+# Assemble: create object files from assembler source files.
+%.o : %.S
+ @echo
+ @echo $(MSG_ASSEMBLING) $<
+ $(CC) -c $(ALL_ASFLAGS) $< -o $@
+
+
+
+
+
+
+# Target: clean project.
+clean: begin clean_list finished end
+
+clean_list :
+ @echo
+ @echo $(MSG_CLEANING)
+ $(REMOVE) $(TARGET).hex
+ $(REMOVE) $(TARGET).eep
+ $(REMOVE) $(TARGET).obj
+ $(REMOVE) $(TARGET).cof
+ $(REMOVE) $(TARGET).elf
+ $(REMOVE) $(TARGET).map
+ $(REMOVE) $(TARGET).obj
+ $(REMOVE) $(TARGET).a90
+ $(REMOVE) $(TARGET).sym
+ $(REMOVE) $(TARGET).lnk
+ $(REMOVE) $(TARGET).lss
+ $(REMOVE) $(OBJ)
+ $(REMOVE) $(LST)
+ $(REMOVE) $(SRC:.c=.s)
+ $(REMOVE) $(SRC:.c=.d)
+ $(REMOVE) *~
+
+# Automatically generate C source code dependencies.
+# (Code originally taken from the GNU make user manual and modified
+# (See README.txt Credits).)
+#
+# Note that this will work with sh (bash) and sed that is shipped with WinAVR
+# (see the SHELL variable defined above).
+# This may not work with other shells or other seds.
+#
+%.d: %.c
+ set -e; $(CC) -MM $(ALL_CFLAGS) $< \
+ | sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > $@; \
+ [ -s $@ ] || rm -f $@
+
+
+# Remove the '-' if you want to see the dependency files generated.
+-include $(SRC:.c=.d)
+
+
+
+# Listing of phony targets.
+.PHONY : all begin finish end sizebefore sizeafter gccversion coff extcoff \
+ clean clean_list program
+
View
403 Archived/esmokebomb_v01/esmokebomb_v01.c
@@ -0,0 +1,403 @@
+/* Eric's Timed Smokebomb v0.1 */
+
+#include <avr/interrupt.h> //Defines pins, ports, etc to make programs easier to read
+#define F_CPU 100000UL //Sets up the default speed for delay.h
+#include <util/delay.h> //Used to delay the script
+
+//Initialization Variables/Macros
+int bomb_state = 0; //0 - Set Disarm Code, 1 - Set Time, 2 - Armed, 3 - Detonated, 4 - Diffused
+int disarm_key_1 = 0; //First disarm button
+int disarm_key_2 = 0; //Second disarm button
+int disarm_key_3 = 0; //Third disarm button
+int disarm_key_4 = 0; //Fourth disarm button
+int current_min = 0; //Set countdown minutes to our macro definition
+int current_sec = 0; //Seconds should be 0 to start off
+int current_key_set = 1; //Keeps track of the current disarm key we're setting for the display function
+#define MULTIPLEXING_MS 50 //Time, in ms, to multiplex 7 segment array
+
+/* 7 Segment Display Functions */
+
+void display1_on(void) //Enables Display 1 for Writing
+{
+ PORTD &= ~(1<<PD4); //Enable Display 1
+ PORTD |= (1<<PD5); //Disable Display 2
+}
+
+void display2_on(void) //Enables Display 2 for Writing
+{
+ PORTD &= ~(1<<PD5); //Enable Display 2
+ PORTD |= (1<<PD4); //Disable Display 1
+}
+
+void clear_display(void) //Clears all VCC 7 Segment Pins
+{
+ PORTD &= ~(1<<PD1);
+ PORTD &= ~(1<<PD2);
+ PORTD &= ~(1<<PD0);
+ PORTA &= ~(1<<PA0);
+ PORTA &= ~(1<<PA1);
+ PORTB &= ~(1<<PB5);
+ PORTB &= ~(1<<PB6);
+ PORTB &= ~(1<<PB7);
+}
+
+//Takes binary "byte" and outputs to VCC pins of 7 segments
+void display_segment_byte(int bita,int bitb,int bitc,int bitd,int bite,int bitf,int bitg,int bitdp)
+{
+ if (bita)
+ PORTD |= (1<<PD1);
+ if (bitb)
+ PORTD |= (1<<PD2);
+ if (bitc)
+ PORTD |= (1<<PD0);
+ if (bitd)
+ PORTA |= (1<<PA0);
+ if (bite)
+ PORTA |= (1<<PA1);
+ if (bitf)
+ PORTB |= (1<<PB5);
+ if (bitg)
+ PORTB |= (1<<PB6);
+ //Blink the dot LEDs every even second while armed
+ if ((current_sec % 2) == 0 && bomb_state == 2)
+ PORTB |= (1<<PB7);
+}
+
+//Function for multiplexing segment array
+void display_segment_array(int disp, int num)
+{
+ if (disp == 1)
+ display1_on();
+ else if (disp == 2)
+ display2_on();
+
+ if (num == 0)
+ display_segment_byte(1,1,1,1,1,1,0,0);
+ else if (num == 1)
+ display_segment_byte(1,1,0,0,0,0,0,0);
+ else if (num == 2)
+ display_segment_byte(1,0,1,1,0,1,1,0);
+ else if (num == 3)
+ display_segment_byte(1,1,1,0,0,1,1,0);
+ else if (num == 4)
+ display_segment_byte(1,1,0,0,1,0,1,0);
+ else if (num == 5)
+ display_segment_byte(0,1,1,0,1,1,1,0);
+ else if (num == 6)
+ display_segment_byte(0,1,1,1,1,1,1,0);
+ else if (num == 7)
+ display_segment_byte(1,1,0,0,0,1,0,0);
+ else if (num == 8)
+ display_segment_byte(1,1,1,1,1,1,1,0);
+ else if (num == 9)
+ display_segment_byte(1,1,1,0,1,1,1,0);
+ else if (num == 11) //Display a "d"
+ display_segment_byte(1,1,1,1,0,0,1,0);
+ else if (num == 22) //Display an "e"
+ display_segment_byte(0,0,1,1,1,1,1,0);
+ else if (num == 33) //Display a "b"
+ display_segment_byte(0,1,1,1,1,0,1,0);
+
+ _delay_ms(MULTIPLEXING_MS);
+ clear_display();
+}
+
+/* End 7 Segment Display Functions */
+
+void detonated(void)
+{
+ static int frame_counter = 0;
+
+ frame_counter++;
+
+ //Tells the program that we are in the detonated state
+ bomb_state = 3;
+
+ //Run Buzzer / Smoke Igniter for 5 frames
+ if (frame_counter <= 5)
+ PORTD |= (1<<PD6);
+ else
+ PORTD &= ~(1<<PD6);
+}
+
+void diffused(void)
+{
+ //Diffused Sequence
+ bomb_state = 4; //Tells the program that we are in the diffused state
+}
+
+void key_check(int input)
+{
+ static int current_key = 1;
+ static int last_input = 0;
+
+ //Make sure to ignore multiple "same" button presses (acts as debouncer)
+ if (input != last_input)
+ {
+ switch (current_key)
+ {
+ case 1:
+ if (input != disarm_key_1)
+ detonated();
+ else
+ current_key++;
+ break;
+ case 2:
+ if (input != disarm_key_2)
+ detonated();
+ else
+ current_key++;
+ break;
+ case 3:
+ if (input != disarm_key_3)
+ detonated();
+ else
+ current_key++;
+ break;
+ case 4:
+ if (input != disarm_key_4)
+ detonated();
+ else
+ diffused();
+ break;
+ }
+ }
+
+ //Keep track of the last hit button
+ last_input = input;
+}
+
+void set_keys(int input)
+{
+ static int last_input = 0;
+
+ //Make sure to ignore multiple "same" button presses (acts as debouncer)
+ if (input != last_input)
+ {
+ switch (current_key_set)
+ {
+ case 1:
+ disarm_key_1 = input;
+ current_key_set++;
+ break;
+ case 2:
+ disarm_key_2 = input;
+ current_key_set++;
+ break;
+ case 3:
+ disarm_key_3 = input;
+ current_key_set++;
+ break;
+ case 4:
+ disarm_key_4 = input;
+ current_key_set++;
+ _delay_ms(1000);
+ bomb_state++;
+ break;
+ }
+ }
+
+ //Keep track of the last hit button
+ last_input = input;
+}
+
+void handle_inputs(void)
+{
+ static int keyswitch_enabled = 0;
+
+ //Keyswitch
+ if (PINB & (1<<PB4)) //If PB0 goes high
+ {
+ if (bomb_state == 1)
+ bomb_state++;
+
+ keyswitch_enabled = 1; //Enable Keyswitch Based Functions
+ PORTD |= (1<<PD3); //Turn Keyswitch LED On
+ }
+ else //If PB0 goes low
+ {
+ keyswitch_enabled = 0; //Disable Keyswitch Based Functions
+ PORTD &= ~(1<<PD3); //Turn Keyswitch LED Off
+ }
+
+ //Keypad
+ if (bomb_state == 0)
+ {
+ if (PINB & (1<<PB0)) //If PB1 goes high
+ set_keys(1);
+ else if (PINB & (1<<PB1)) //If PB2 goes high
+ set_keys(2);
+ else if (PINB & (1<<PB2)) //If PB3 goes high
+ set_keys(3);
+ else if (PINB & (1<<PB3)) //If PB4 goes high
+ set_keys(4);
+ }
+ else if (bomb_state == 1)
+ {
+ if (PINB & (1<<PB0)) //If PB1 goes high
+ {
+ _delay_ms(500);
+ if (PINB & (1<<PB0))
+ current_min--;
+ }
+ else if (PINB & (1<<PB3)) //If PB2 goes high
+ {
+ _delay_ms(500);
+ if (PINB & (1<<PB3))
+ current_min++;
+ }
+
+ //Keep within our range of 0-99 minutes
+ if (current_min < 0)
+ current_min = 0;
+ else if (current_min > 99)
+ current_min = 99;
+ }
+ else if (keyswitch_enabled && bomb_state == 2)
+ {
+ if (PINB & (1<<PB0)) //If PB1 goes high
+ key_check(1);
+ else if (PINB & (1<<PB1)) //If PB2 goes high
+ key_check(2);
+ else if (PINB & (1<<PB2)) //If PB3 goes high
+ key_check(3);
+ else if (PINB & (1<<PB3)) //If PB4 goes high
+ key_check(4);
+ }
+
+}
+
+
+/* Function: proc_init()
+ Purpose: Handles initialization of the system on startup.
+ Called: main() */
+void proc_init(void)
+{
+ /* PORT CONFIG */
+
+ //Keyswitch and Keypad - Inputs
+ DDRB &= ~(1<<PB0); //Setup PB0 for input in direction register
+ DDRB &= ~(1<<PB1); //Setup PB1 for input in direction register
+ DDRB &= ~(1<<PB2); //Setup PB2 for input in direction register
+ DDRB &= ~(1<<PB3); //Setup PB3 for input in direction register
+ DDRB &= ~(1<<PB4); //Setup PB4 for input in direction register
+
+ //7 Segment Array Grounds - Outputs
+ DDRD |= (1<<PD4); //Setup Display 1 Ground as output
+ DDRD |= (1<<PD5); //Setup Display 2 Ground as output
+
+ //7 Segment Array VCC Pins - Outputs
+ DDRD |= (1<<PD1); //Setup A pin as output
+ DDRD |= (1<<PD2); //Setup B pin as output
+ DDRD |= (1<<PD0); //Setup C pin as output
+ DDRA |= (1<<PA0); //Setup D pin as output
+ DDRA |= (1<<PA1); //Setup E pin as output
+ DDRB |= (1<<PB5); //Setup F pin as output
+ DDRB |= (1<<PB6); //Setup G pin as output
+ DDRB |= (1<<PB7); //Setup DP pin as output
+
+ //Status LEDs/Buzzers - Outputs
+ DDRD |= (1<<PD3); //Used for Keyswitch LED
+ DDRD |= (1<<PD6); //Used for Buzzer/Smoke
+
+ //Interrupt Config - PCIE
+ PCMSK |= (1<<PCINT0); //Tell pin change mask to listen to pin12
+ PCMSK |= (1<<PCINT1); //Tell pin change mask to listen to pin13
+ PCMSK |= (1<<PCINT2); //Tell pin change mask to listen to pin14
+ PCMSK |= (1<<PCINT3); //Tell pin change mask to listen to pin15
+ PCMSK |= (1<<PCINT4); //Tell pin change mask to listen to pin16
+ GIMSK |= (1<<PCIE); //Enable PCINT interrupt in the general interrupt mask
+
+ //Interrupt Config - TIMER1
+ TCCR1B |= (1<<WGM12); // Configure timer 1 for CTC mode
+ TIMSK |= (1<<OCIE1A); // Enable CTC interrupt
+ OCR1A = 15625; // Set CTC compare value (1mhz = 1000000/64 = 15625)
+ TCCR1B |= ((1<<CS10) | (1<<CS11)); // Start timer at FCPU/64
+
+ //Enable all interrupts
+ sei();
+}
+
+
+/* Function: main()
+ Purpose: Main program loop.
+ Called: On System Startup */
+int main(void)
+{
+ //Used to store digits for each 7 segment display we're writing to
+ int dig1 = 0;
+ int dig2 = 0;
+
+ proc_init(); //Let's init everything
+
+ //While we're setting the disarm code...
+ while(bomb_state == 0)
+ {
+ display_segment_array(1,33); //Writes a "b" to display 1
+ display_segment_array(2,current_key_set); //Writes the current button being set to display 2
+ }
+
+ //While we're not detonated or diffused...
+ while(bomb_state == 1 || bomb_state == 2)
+ {
+ //Display Minutes
+ if (current_min > 0)
+ {
+ dig2 = (current_min % 10);
+ dig1 = ((current_min - dig2) / 10);
+ }
+ //Display Seconds
+ else if (current_sec > 0)
+ {
+ dig2 = (current_sec % 10);
+ dig1 = ((current_sec - dig2) / 10);
+ }
+ //Display 00s
+ else
+ dig2 = dig1 = 0;
+
+ //Actually write the display values to the segment array
+ display_segment_array(1,dig1); //Writes the first digit to display 1
+ display_segment_array(2,dig2); //Writes the second digit to display 2
+ }
+
+ //While we're detonated...
+ while(bomb_state == 3)
+ {
+ display_segment_array(1,22); //Writes an "e" to display 1
+ display_segment_array(2,22); //Writes an "e" to display 2
+ }
+
+ //While we're diffused...
+ while(bomb_state == 4)
+ {
+ display_segment_array(1,11); //Writes a "d" to display 1
+ display_segment_array(2,11); //Writes a "d" to display 2
+ }
+
+ return(0);
+}
+
+
+SIGNAL (SIG_PCINT)
+{
+ handle_inputs(); //A keypad/keyswitch interrupt has occured! Handle it to figure out which pin.
+}
+
+
+ISR(TIMER1_COMPA_vect)
+{
+ if (bomb_state == 2)
+ {
+ current_sec--;
+ if (current_sec < 0)
+ {
+ current_min--;
+ current_sec = 59;
+ }
+ if (current_min < 0)
+ detonated();
+ }
+ else if (bomb_state == 3)
+ detonated();
+}
View
388 Archived/esmokebomb_v02/Makefile
@@ -0,0 +1,388 @@
+# WinAVR Sample makefile written by Eric B. Weddington, Jörg Wunsch, et al.
+# Modified (bringing often-changed options to the top) by Elliot Williams
+
+# make all = Make software and program
+# make clean = Clean out built project files.
+# make coff = Convert ELF to AVR COFF (for use with AVR Studio 3.x or VMLAB).
+# make extcoff = Convert ELF to AVR Extended COFF (for use with AVR Studio
+# 4.07 or greater).
+# make program = Download the hex file to the device, using avrdude. Please
+# customize the avrdude settings below first!
+# make filename.s = Just compile filename.c into the assembler code only
+# To rebuild project do "make clean" then "make all".
+
+# Microcontroller Type
+# MCU = attiny13
+MCU = attiny2313
+# MCU = atmega8
+
+# Target file name (without extension).
+TARGET = esmokebomb_v02
+
+# Programming hardware: type avrdude -c ?
+# to get a full listing.
+AVRDUDE_PROGRAMMER = dapa # official name of
+
+# AVRDUDE_PORT = /dev/parport0 # linux
+AVRDUDE_PORT = lpt1 # windows
+
+############# Don't need to change below here for most purposes (Elliot)
+
+# Optimization level, can be [0, 1, 2, 3, s]. 0 turns off optimization.
+# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
+OPT = s
+
+# Output format. (can be srec, ihex, binary)
+FORMAT = ihex
+
+# List C source files here. (C dependencies are automatically generated.)
+SRC = $(TARGET).c
+
+# If there is more than one source file, append them above, or modify and
+# uncomment the following:
+#SRC += foo.c bar.c
+
+# You can also wrap lines by appending a backslash to the end of the line:
+#SRC += baz.c \
+#xyzzy.c
+
+
+
+# List Assembler source files here.
+# Make them always end in a capital .S. Files ending in a lowercase .s
+# will not be considered source files but generated files (assembler
+# output from the compiler), and will be deleted upon "make clean"!
+# Even though the DOS/Win* filesystem matches both .s and .S the same,
+# it will preserve the spelling of the filenames, and gcc itself does
+# care about how the name is spelled on its command-line.
+ASRC =
+
+
+# List any extra directories to look for include files here.
+# Each directory must be seperated by a space.
+EXTRAINCDIRS =
+
+
+# Optional compiler flags.
+# -g: generate debugging information (for GDB, or for COFF conversion)
+# -O*: optimization level
+# -f...: tuning, see gcc manual and avr-libc documentation
+# -Wall...: warning level
+# -Wa,...: tell GCC to pass this to the assembler.
+# -ahlms: create assembler listing
+CFLAGS = -g -O$(OPT) \
+-funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums \
+-Wall -Wstrict-prototypes \
+-Wa,-adhlns=$(<:.c=.lst) \
+$(patsubst %,-I%,$(EXTRAINCDIRS))
+
+
+# Set a "language standard" compiler flag.
+# Unremark just one line below to set the language standard to use.
+# gnu99 = C99 + GNU extensions. See GCC manual for more information.
+#CFLAGS += -std=c89
+#CFLAGS += -std=gnu89
+#CFLAGS += -std=c99
+CFLAGS += -std=gnu99
+
+
+
+# Optional assembler flags.
+# -Wa,...: tell GCC to pass this to the assembler.
+# -ahlms: create listing
+# -gstabs: have the assembler create line number information; note that
+# for use in COFF files, additional information about filenames
+# and function names needs to be present in the assembler source
+# files -- see avr-libc docs [FIXME: not yet described there]
+ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
+
+
+
+# Optional linker flags.
+# -Wl,...: tell GCC to pass this to linker.
+# -Map: create map file
+# --cref: add cross reference to map file
+LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
+
+
+
+# Additional libraries
+
+# Minimalistic printf version
+#LDFLAGS += -Wl,-u,vfprintf -lprintf_min
+
+# Floating point printf version (requires -lm below)
+#LDFLAGS += -Wl,-u,vfprintf -lprintf_flt
+
+# -lm = math library
+LDFLAGS += -lm
+
+
+# Programming support using avrdude. Settings and variables.
+
+
+AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
+#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
+
+AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
+
+# Uncomment the following if you want avrdude's erase cycle counter.
+# Note that this counter needs to be initialized first using -Yn,
+# see avrdude manual.
+#AVRDUDE_ERASE += -y
+
+# Uncomment the following if you do /not/ wish a verification to be
+# performed after programming the device.
+#AVRDUDE_FLAGS += -V
+
+# Increase verbosity level. Please use this when submitting bug
+# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
+# to submit bug reports.
+#AVRDUDE_FLAGS += -v -v
+
+#Run while cable attached or don't
+AVRDUDE_FLAGS += -E reset #keep chip disabled while cable attached
+#AVRDUDE_FLAGS += -E noreset
+
+#AVRDUDE_WRITE_FLASH = -U lfuse:w:0x04:m #run with 8 Mhz clock
+
+#AVRDUDE_WRITE_FLASH = -U lfuse:w:0x21:m #run with 1 Mhz clock #default clock mode
+
+#AVRDUDE_WRITE_FLASH = -U lfuse:w:0x01:m #run with 1 Mhz clock no start up time
+
+# ---------------------------------------------------------------------------
+
+# Define directories, if needed.
+DIRAVR = c:/winavr
+DIRAVRBIN = $(DIRAVR)/bin
+DIRAVRUTILS = $(DIRAVR)/utils/bin
+DIRINC = .
+DIRLIB = $(DIRAVR)/avr/lib
+
+
+# Define programs and commands.
+SHELL = sh
+
+CC = avr-gcc
+
+OBJCOPY = avr-objcopy
+OBJDUMP = avr-objdump
+SIZE = avr-size
+
+
+# Programming support using avrdude.
+AVRDUDE = avrdude
+
+
+REMOVE = rm -f
+COPY = cp
+
+HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
+ELFSIZE = $(SIZE) -A $(TARGET).elf
+
+
+
+# Define Messages
+# English
+MSG_ERRORS_NONE = Errors: none
+MSG_BEGIN = -------- begin --------
+MSG_END = -------- end --------
+MSG_SIZE_BEFORE = Size before:
+MSG_SIZE_AFTER = Size after:
+MSG_COFF = Converting to AVR COFF:
+MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
+MSG_FLASH = Creating load file for Flash:
+MSG_EEPROM = Creating load file for EEPROM:
+MSG_EXTENDED_LISTING = Creating Extended Listing:
+MSG_SYMBOL_TABLE = Creating Symbol Table:
+MSG_LINKING = Linking:
+MSG_COMPILING = Compiling:
+MSG_ASSEMBLING = Assembling:
+MSG_CLEANING = Cleaning project:
+
+
+
+
+# Define all object files.
+OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
+
+# Define all listing files.
+LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)
+
+# Combine all necessary flags and optional flags.
+# Add target processor to flags.
+ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
+ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
+
+
+
+# Default target: make program!
+all: begin gccversion sizebefore $(TARGET).elf $(TARGET).hex $(TARGET).eep \
+ $(TARGET).lss $(TARGET).sym sizeafter finished end
+ $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
+
+# Eye candy.
+# AVR Studio 3.x does not check make's exit code but relies on
+# the following magic strings to be generated by the compile job.
+begin:
+ @echo
+ @echo $(MSG_BEGIN)
+
+finished:
+ @echo $(MSG_ERRORS_NONE)
+
+end:
+ @echo $(MSG_END)
+ @echo
+
+
+# Display size of file.
+sizebefore:
+ @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
+
+sizeafter:
+ @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
+
+
+
+# Display compiler version information.
+gccversion :
+ @$(CC) --version
+
+
+
+
+# Convert ELF to COFF for use in debugging / simulating in
+# AVR Studio or VMLAB.
+COFFCONVERT=$(OBJCOPY) --debugging \
+ --change-section-address .data-0x800000 \
+ --change-section-address .bss-0x800000 \
+ --change-section-address .noinit-0x800000 \
+ --change-section-address .eeprom-0x810000
+
+
+coff: $(TARGET).elf
+ @echo
+ @echo $(MSG_COFF) $(TARGET).cof
+ $(COFFCONVERT) -O coff-avr $< $(TARGET).cof
+
+
+extcoff: $(TARGET).elf
+ @echo
+ @echo $(MSG_EXTENDED_COFF) $(TARGET).cof
+ $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
+
+
+
+
+# Program the device.
+program: $(TARGET).hex $(TARGET).eep
+ $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
+
+
+
+
+# Create final output files (.hex, .eep) from ELF output file.
+%.hex: %.elf
+ @echo
+ @echo $(MSG_FLASH) $@
+ $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
+
+%.eep: %.elf
+ @echo
+ @echo $(MSG_EEPROM) $@
+ -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
+ --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
+
+# Create extended listing file from ELF output file.
+%.lss: %.elf
+ @echo
+ @echo $(MSG_EXTENDED_LISTING) $@
+ $(OBJDUMP) -h -S $< > $@
+
+# Create a symbol table from ELF output file.
+%.sym: %.elf
+ @echo
+ @echo $(MSG_SYMBOL_TABLE) $@
+ avr-nm -n $< > $@
+
+
+
+# Link: create ELF output file from object files.
+.SECONDARY : $(TARGET).elf
+.PRECIOUS : $(OBJ)
+%.elf: $(OBJ)
+ @echo
+ @echo $(MSG_LINKING) $@
+ $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)
+
+
+# Compile: create object files from C source files.
+%.o : %.c
+ @echo
+ @echo $(MSG_COMPILING) $<
+ $(CC) -c $(ALL_CFLAGS) $< -o $@
+
+
+# Compile: create assembler files from C source files.
+%.s : %.c
+ $(CC) -S $(ALL_CFLAGS) $< -o $@
+
+
+# Assemble: create object files from assembler source files.
+%.o : %.S
+ @echo
+ @echo $(MSG_ASSEMBLING) $<
+ $(CC) -c $(ALL_ASFLAGS) $< -o $@
+
+
+
+
+
+
+# Target: clean project.
+clean: begin clean_list finished end
+
+clean_list :
+ @echo
+ @echo $(MSG_CLEANING)
+ $(REMOVE) $(TARGET).hex
+ $(REMOVE) $(TARGET).eep
+ $(REMOVE) $(TARGET).obj
+ $(REMOVE) $(TARGET).cof
+ $(REMOVE) $(TARGET).elf
+ $(REMOVE) $(TARGET).map
+ $(REMOVE) $(TARGET).obj
+ $(REMOVE) $(TARGET).a90
+ $(REMOVE) $(TARGET).sym
+ $(REMOVE) $(TARGET).lnk
+ $(REMOVE) $(TARGET).lss
+ $(REMOVE) $(OBJ)
+ $(REMOVE) $(LST)
+ $(REMOVE) $(SRC:.c=.s)
+ $(REMOVE) $(SRC:.c=.d)
+ $(REMOVE) *~
+
+# Automatically generate C source code dependencies.
+# (Code originally taken from the GNU make user manual and modified
+# (See README.txt Credits).)
+#
+# Note that this will work with sh (bash) and sed that is shipped with WinAVR
+# (see the SHELL variable defined above).
+# This may not work with other shells or other seds.
+#
+%.d: %.c
+ set -e; $(CC) -MM $(ALL_CFLAGS) $< \
+ | sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > $@; \
+ [ -s $@ ] || rm -f $@
+
+
+# Remove the '-' if you want to see the dependency files generated.
+-include $(SRC:.c=.d)
+
+
+
+# Listing of phony targets.
+.PHONY : all begin finish end sizebefore sizeafter gccversion coff extcoff \
+ clean clean_list program
+
View
45 Archived/esmokebomb_v02/eSmoke_PinOut.txt
@@ -0,0 +1,45 @@
+eSmoke v0.1 Pin Connections
+
+Ex:
+
+M20 = Microcontroller Pin 20
+D16 = Display Pin 16
+- = Connection Wire
+
+Display
+--------
+(A)M3-D16-(D11)
+(B)M6-D15-(D10)
+(C)M2-D3-(D8)
+(D)M5-D2-(D6)
+(E)M4-D1-(D5)
+(F)M17-D18-(D12)
+(G)M18-D17-(D7)
+(DP)M19-D4-(D9)
+(DGND1)M8-D14
+(DGND2)M9-D13
+
+
+Resistors
+---------
+(GND)M10-RES-M16
+(GND)M10-RES-M15
+(GND)M10-RES-M14
+(GND)M10-RES-M13
+(GND)M10-RES-M12
+
+Buzzer
+---------
+(GND)M10-BUZZ-M11
+
+LED
+---------
+(GND)M10-LED-M7
+
+Switches
+---------
+(VCC)M20-KEY-M16
+(VCC)M20-SW4-M15
+(VCC)M20-SW3-M14
+(VCC)M20-SW2-M13
+(VCC)M20-SW1-M12
View
403 Archived/esmokebomb_v02/esmokebomb_v02.c
@@ -0,0 +1,403 @@
+/* Eric's Timed Smokebomb v0.2 */
+
+#include <avr/interrupt.h> //Defines pins, ports, etc to make programs easier to read
+#define F_CPU 100000UL //Sets up the default speed for delay.h
+#include <util/delay.h> //Used to delay the script
+
+//Initialization Variables/Macros
+int bomb_state = 0; //0 - Set Disarm Code, 1 - Set Time, 2 - Armed, 3 - Detonated, 4 - Diffused
+int disarm_key_1 = 0; //First disarm button
+int disarm_key_2 = 0; //Second disarm button
+int disarm_key_3 = 0; //Third disarm button
+int disarm_key_4 = 0; //Fourth disarm button
+int current_min = 0; //Set countdown minutes to our macro definition
+int current_sec = 0; //Seconds should be 0 to start off
+int current_key_set = 1; //Keeps track of the current disarm key we're setting for the display function
+#define MULTIPLEXING_MS 50 //Time, in ms, to multiplex 7 segment array
+
+/* 7 Segment Display Functions */
+
+void display1_on(void) //Enables Display 1 for Writing
+{
+ PORTD &= ~(1<<PD4); //Enable Display 1
+ PORTD |= (1<<PD5); //Disable Display 2
+}
+
+void display2_on(void) //Enables Display 2 for Writing
+{
+ PORTD &= ~(1<<PD5); //Enable Display 2
+ PORTD |= (1<<PD4); //Disable Display 1
+}
+
+void clear_display(void) //Clears all VCC 7 Segment Pins
+{
+ PORTD &= ~(1<<PD1);
+ PORTD &= ~(1<<PD2);
+ PORTD &= ~(1<<PD0);
+ PORTA &= ~(1<<PA0);
+ PORTA &= ~(1<<PA1);
+ PORTB &= ~(1<<PB5);
+ PORTB &= ~(1<<PB6);
+ PORTB &= ~(1<<PB7);
+}
+
+//Takes binary "byte" and outputs to VCC pins of 7 segments
+void display_segment_byte(int bita,int bitb,int bitc,int bitd,int bite,int bitf,int bitg,int bitdp)
+{
+ if (bita)
+ PORTD |= (1<<PD1);
+ if (bitb)
+ PORTD |= (1<<PD2);
+ if (bitc)
+ PORTD |= (1<<PD0);
+ if (bitd)
+ PORTA |= (1<<PA0);
+ if (bite)
+ PORTA |= (1<<PA1);
+ if (bitf)
+ PORTB |= (1<<PB5);
+ if (bitg)
+ PORTB |= (1<<PB6);
+ //Blink the dot LEDs every even second while armed
+ if ((current_sec % 2) == 0 && bomb_state == 2)
+ PORTB |= (1<<PB7);
+}
+
+//Function for multiplexing segment array
+void display_segment_array(int disp, int num)
+{
+ if (disp == 1)
+ display1_on();
+ else if (disp == 2)
+ display2_on();
+
+ if (num == 0)
+ display_segment_byte(1,1,1,1,1,1,0,0);
+ else if (num == 1)
+ display_segment_byte(0,1,1,0,0,0,0,0);
+ else if (num == 2)
+ display_segment_byte(1,1,0,1,1,0,1,0);
+ else if (num == 3)
+ display_segment_byte(1,1,1,1,0,0,1,0);
+ else if (num == 4)
+ display_segment_byte(0,1,1,0,0,1,1,0);
+ else if (num == 5)
+ display_segment_byte(1,0,1,1,0,1,1,0);
+ else if (num == 6)
+ display_segment_byte(1,0,1,1,1,1,1,0);
+ else if (num == 7)
+ display_segment_byte(1,1,1,0,0,0,0,0);
+ else if (num == 8)
+ display_segment_byte(1,1,1,1,1,1,1,0);
+ else if (num == 9)
+ display_segment_byte(1,1,1,1,0,1,1,0);
+ else if (num == 11) //Display a "d"
+ display_segment_byte(0,1,1,1,1,0,1,0);
+ else if (num == 22) //Display an "e"
+ display_segment_byte(1,0,0,1,1,1,1,0);
+ else if (num == 33) //Display a "b"
+ display_segment_byte(0,0,1,1,1,1,1,0);
+
+ _delay_ms(MULTIPLEXING_MS);
+ clear_display();
+}
+
+/* End 7 Segment Display Functions */
+
+void detonated(void)
+{
+ static int frame_counter = 0;
+
+ frame_counter++;
+
+ //Tells the program that we are in the detonated state
+ bomb_state = 3;
+
+ //Run Buzzer / Smoke Igniter for 5 frames
+ if (frame_counter <= 5)
+ PORTD |= (1<<PD6);
+ else
+ PORTD &= ~(1<<PD6);
+}
+
+void diffused(void)
+{
+ //Diffused Sequence
+ bomb_state = 4; //Tells the program that we are in the diffused state
+}
+
+void key_check(int input)
+{
+ static int current_key = 1;
+ static int last_input = 0;
+
+ //Make sure to ignore multiple "same" button presses (acts as debouncer)
+ if (input != last_input)
+ {
+ switch (current_key)
+ {
+ case 1:
+ if (input != disarm_key_1)
+ detonated();
+ else
+ current_key++;
+ break;
+ case 2:
+ if (input != disarm_key_2)
+ detonated();
+ else
+ current_key++;
+ break;
+ case 3:
+ if (input != disarm_key_3)
+ detonated();
+ else
+ current_key++;
+ break;
+ case 4:
+ if (input != disarm_key_4)
+ detonated();
+ else
+ diffused();
+ break;
+ }
+ }
+
+ //Keep track of the last hit button
+ last_input = input;
+}
+
+void set_keys(int input)
+{
+ static int last_input = 0;
+
+ //Make sure to ignore multiple "same" button presses (acts as debouncer)
+ if (input != last_input)
+ {
+ switch (current_key_set)
+ {
+ case 1:
+ disarm_key_1 = input;
+ current_key_set++;
+ break;
+ case 2:
+ disarm_key_2 = input;
+ current_key_set++;
+ break;
+ case 3:
+ disarm_key_3 = input;
+ current_key_set++;
+ break;
+ case 4:
+ disarm_key_4 = input;
+ current_key_set++;
+ _delay_ms(1000);
+ bomb_state++;
+ break;
+ }
+ }
+
+ //Keep track of the last hit button
+ last_input = input;
+}
+
+void handle_inputs(void)
+{
+ static int keyswitch_enabled = 0;
+
+ //Keyswitch
+ if (PINB & (1<<PB4)) //If PB0 goes high
+ {
+ if (bomb_state == 1)
+ bomb_state++;
+
+ keyswitch_enabled = 1; //Enable Keyswitch Based Functions
+ PORTD |= (1<<PD3); //Turn Keyswitch LED On
+ }
+ else //If PB0 goes low
+ {
+ keyswitch_enabled = 0; //Disable Keyswitch Based Functions
+ PORTD &= ~(1<<PD3); //Turn Keyswitch LED Off
+ }
+
+ //Keypad
+ if (bomb_state == 0)
+ {
+ if (PINB & (1<<PB0)) //If PB1 goes high
+ set_keys(1);
+ else if (PINB & (1<<PB1)) //If PB2 goes high
+ set_keys(2);
+ else if (PINB & (1<<PB2)) //If PB3 goes high
+ set_keys(3);
+ else if (PINB & (1<<PB3)) //If PB4 goes high
+ set_keys(4);
+ }
+ else if (bomb_state == 1)
+ {
+ if (PINB & (1<<PB0)) //If PB1 goes high
+ {
+ _delay_ms(500);
+ if (PINB & (1<<PB0))
+ current_min--;
+ }
+ else if (PINB & (1<<PB3)) //If PB2 goes high
+ {
+ _delay_ms(500);
+ if (PINB & (1<<PB3))
+ current_min++;
+ }
+
+ //Keep within our range of 0-99 minutes
+ if (current_min < 0)
+ current_min = 0;
+ else if (current_min > 99)
+ current_min = 99;
+ }
+ else if (keyswitch_enabled && bomb_state == 2)
+ {
+ if (PINB & (1<<PB0)) //If PB1 goes high
+ key_check(1);
+ else if (PINB & (1<<PB1)) //If PB2 goes high
+ key_check(2);
+ else if (PINB & (1<<PB2)) //If PB3 goes high
+ key_check(3);
+ else if (PINB & (1<<PB3)) //If PB4 goes high
+ key_check(4);
+ }
+
+}
+
+
+/* Function: proc_init()
+ Purpose: Handles initialization of the system on startup.
+ Called: main() */
+void proc_init(void)
+{
+ /* PORT CONFIG */
+
+ //Keyswitch and Keypad - Inputs
+ DDRB &= ~(1<<PB0); //Setup PB0 for input in direction register
+ DDRB &= ~(1<<PB1); //Setup PB1 for input in direction register
+ DDRB &= ~(1<<PB2); //Setup PB2 for input in direction register
+ DDRB &= ~(1<<PB3); //Setup PB3 for input in direction register
+ DDRB &= ~(1<<PB4); //Setup PB4 for input in direction register
+
+ //7 Segment Array Grounds - Outputs
+ DDRD |= (1<<PD4); //Setup Display 1 Ground as output
+ DDRD |= (1<<PD5); //Setup Display 2 Ground as output
+
+ //7 Segment Array VCC Pins - Outputs
+ DDRD |= (1<<PD1); //Setup A pin as output
+ DDRD |= (1<<PD2); //Setup B pin as output
+ DDRD |= (1<<PD0); //Setup C pin as output
+ DDRA |= (1<<PA0); //Setup D pin as output
+ DDRA |= (1<<PA1); //Setup E pin as output
+ DDRB |= (1<<PB5); //Setup F pin as output
+ DDRB |= (1<<PB6); //Setup G pin as output
+ DDRB |= (1<<PB7); //Setup DP pin as output
+
+ //Status LEDs/Buzzers - Outputs
+ DDRD |= (1<<PD3); //Used for Keyswitch LED
+ DDRD |= (1<<PD6); //Used for Buzzer/Smoke
+
+ //Interrupt Config - PCIE
+ PCMSK |= (1<<PCINT0); //Tell pin change mask to listen to pin12
+ PCMSK |= (1<<PCINT1); //Tell pin change mask to listen to pin13
+ PCMSK |= (1<<PCINT2); //Tell pin change mask to listen to pin14
+ PCMSK |= (1<<PCINT3); //Tell pin change mask to listen to pin15
+ PCMSK |= (1<<PCINT4); //Tell pin change mask to listen to pin16
+ GIMSK |= (1<<PCIE); //Enable PCINT interrupt in the general interrupt mask
+
+ //Interrupt Config - TIMER1
+ TCCR1B |= (1<<WGM12); // Configure timer 1 for CTC mode
+ TIMSK |= (1<<OCIE1A); // Enable CTC interrupt
+ OCR1A = 15625; // Set CTC compare value (1mhz = 1000000/64 = 15625)
+ TCCR1B |= ((1<<CS10) | (1<<CS11)); // Start timer at FCPU/64
+
+ //Enable all interrupts
+ sei();
+}
+
+
+/* Function: main()
+ Purpose: Main program loop.
+ Called: On System Startup */
+int main(void)
+{
+ //Used to store digits for each 7 segment display we're writing to
+ int dig1 = 0;
+ int dig2 = 0;
+
+ proc_init(); //Let's init everything
+
+ //While we're setting the disarm code...
+ while(bomb_state == 0)
+ {
+ display_segment_array(1,33); //Writes a "b" to display 1
+ display_segment_array(2,current_key_set); //Writes the current button being set to display 2
+ }
+
+ //While we're not detonated or diffused...
+ while(bomb_state == 1 || bomb_state == 2)
+ {
+ //Display Minutes
+ if (current_min > 0)
+ {
+ dig2 = (current_min % 10);
+ dig1 = ((current_min - dig2) / 10);
+ }
+ //Display Seconds
+ else if (current_sec > 0)
+ {
+ dig2 = (current_sec % 10);
+ dig1 = ((current_sec - dig2) / 10);
+ }
+ //Display 00s
+ else
+ dig2 = dig1 = 0;
+
+ //Actually write the display values to the segment array
+ display_segment_array(1,dig1); //Writes the first digit to display 1
+ display_segment_array(2,dig2); //Writes the second digit to display 2
+ }
+
+ //While we're detonated...
+ while(bomb_state == 3)
+ {
+ display_segment_array(1,22); //Writes an "e" to display 1
+ display_segment_array(2,22); //Writes an "e" to display 2
+ }
+
+ //While we're diffused...
+ while(bomb_state == 4)
+ {
+ display_segment_array(1,11); //Writes a "d" to display 1
+ display_segment_array(2,11); //Writes a "d" to display 2
+ }
+
+ return(0);
+}
+
+
+SIGNAL (SIG_PCINT)
+{
+ handle_inputs(); //A keypad/keyswitch interrupt has occured! Handle it to figure out which pin.
+}
+
+
+ISR(TIMER1_COMPA_vect)
+{
+ if (bomb_state == 2)
+ {
+ current_sec--;
+ if (current_sec < 0)
+ {
+ current_min--;
+ current_sec = 59;
+ }
+ if (current_min < 0)
+ detonated();
+ }
+ else if (bomb_state == 3)
+ detonated();
+}
View
BIN  Datasheets/36.pdf
Binary file not shown
View
BIN  Datasheets/37312.pdf
Binary file not shown
View
BIN  Datasheets/FQP4N20L.pdf
Binary file not shown
View
BIN  Datasheets/KT-400377.pdf
Binary file not shown
View
BIN  Datasheets/LITEON_7SEG.pdf
Binary file not shown
View
5 Guidelines.txt
@@ -0,0 +1,5 @@
+Game Type
+-------------
+Assault - arm/disarm code
+Defend - disarm code (clock starts at beginning of game)
+Capture - team1/team2 code (2 timers counting down)
View
595 MockTimer_v3/MockTimer_v3.pde
@@ -0,0 +1,595 @@
+#include <LiquidCrystal.h>
+#include <Keypad.h>
+
+#define SETGAMETYPE 1
+#define SETCODES 2
+#define SETATTEMPTS 3
+#define SETTIME 4
+#define STARTGAME 5
+#define SETUPCOMPLETE 6
+
+#define ASSAULT 1
+#define DEFEND 2
+#define CAPTURE 3
+
+#define ALPHA 1
+#define BRAVO 2
+
+int buzzPin = 3; // Buzzer pin
+int auxPortPin = 14; // Aux Port pin
+const byte ROWS = 4; // Four keypad rows
+const byte COLS = 3; // Three keypad columns
+char keys[ROWS][COLS] = {
+ {'1','2','3'},
+ {'4','5','6'},
+ {'7','8','9'},
+ {'*','0','#'}
+};
+byte rowPins[ROWS] = {9, 7, 13, 11}; //connect to the row pinouts of the keypad
+byte colPins[COLS] = {10, 8, 12}; //connect to the column pinouts of the keypad
+
+//Define our keypad and LCD objects
+Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
+LiquidCrystal lcd(6,5,0,1,2,4);
+
+//Global variables used throughout the program
+unsigned long timeLeftAlpha;
+unsigned long timeLeftBravo;
+unsigned long lastMillis = 0;
+unsigned long attemptsMillis = 0;
+unsigned long overflowLimit = 4294900000;
+unsigned int matchNum;
+unsigned int countingTeam = 0;
+int disarmAttempts = 0;
+boolean detonated = false;
+boolean disarmed = false;
+boolean armed = false;
+boolean paused = false;
+boolean codesConfigured = false;
+boolean timeSet = false;
+boolean matchStart = false;
+boolean battAlert = false;
+unsigned int setupState = SETGAMETYPE;
+int gameType = 0;
+
+//Key vars
+int codeIndex = 0;
+int disarmIndex = 0;
+int timeIndex = 0;
+char disarmInput[] = "******";
+char alphaKey[] = "------"; //Alpha / Arm Code
+char bravoKey[] = "------"; //Bravo / Disarm Code
+char refKey[] = "------"; //Ref Code
+char disarmEntered[] = "--";
+char hourAlpha[] = "--";
+char hourBravo[] = "--";
+char minAlpha[] = "--";
+char minBravo[] = "--";
+
+//Beep vars
+unsigned long nextBeep = 0;
+unsigned long nextBeepOff = 0;
+
+
+void setup()
+{
+ pinMode(buzzPin, OUTPUT); //set buzzer pin as output
+ pinMode(auxPortPin, OUTPUT); //set aux pin as output
+ digitalWrite(auxPortPin, LOW);
+ lcd.begin(20,4);
+ randomSeed(analogRead(5));
+ matchNum = random(1000);
+ while (setupState != SETUPCOMPLETE) {
+ setupMode();
+ }
+ lastMillis = millis();
+}
+
+void loop()
+{
+ int timeDiff;
+
+ displayMenu("*-Del Enter-#");
+
+ while (!disarmed && !detonated) {
+ if (!paused)
+ timeDiff = millis() - lastMillis;
+ else
+ timeDiff = 0;
+
+ lastMillis = millis();
+ countdown(timeDiff);
+
+ if (!battAlert)
+ batteryCheck();
+ }
+ endGameMode();
+}
+
+
+/*** MAIN STATES FUNCTIONS ***/
+
+void setupMode() {
+ switch(setupState){
+ case SETGAMETYPE:
+ lcd.setCursor(0,0);
+ lcd.print("--Choose Game Type--");
+ lcd.setCursor(0,1);
+ lcd.print("1-ASSAULT (ARM/DARM)");
+ lcd.setCursor(0,2);
+ lcd.print("2-DEFEND (DARM ONLY)");
+ lcd.setCursor(0,3);
+ lcd.print("3-CAPTURE (KOTH)");
+ while (gameType == 0) {
+ handleKeypadEvents();
+ }
+ setupState++;
+ break;
+ case SETCODES:
+ lcd.clear();
+ displayMenu("*-Del SetCodes-#");
+ while (codesConfigured == false) {
+ lcd.setCursor(0,0);
+ lcd.print("Ref Code: ");
+ lcd.print(refKey);
+ lcd.setCursor(0,1);
+ if (gameType == ASSAULT)
+ lcd.print("Arm Code: ");
+ else if (gameType == CAPTURE)
+ lcd.print("Alpha Code: ");
+ if (gameType != DEFEND)
+ lcd.print(alphaKey);
+ lcd.setCursor(0,2);
+ if (gameType != CAPTURE)
+ lcd.print("Disarm Code: ");
+ else
+ lcd.print("Bravo Code: ");
+ lcd.print(bravoKey);
+ handleKeypadEvents();
+ }
+ setupState++;
+ break;
+ case SETATTEMPTS:
+ if (gameType == CAPTURE) {
+ setupState++;
+ break;
+ }
+ lcd.clear();
+ lcd.setCursor(0,0);
+ lcd.print("---Disarm Options---");
+ lcd.setCursor(0,2);
+ lcd.print("Enter value 01 to 99");
+ displayMenu("*-Del Enter-#");
+ while (disarmAttempts == 0) {
+ lcd.setCursor(0,1);
+ lcd.print("Set Attempts: ");
+ lcd.print(disarmEntered);
+ handleKeypadEvents();
+ }
+ setupState++;
+ break;
+ case SETTIME:
+ lcd.setCursor(0,0);
+ lcd.print("---Countdown Time---");
+ displayMenu("*-Del SetTime-#");
+ while (timeSet == false) {
+ lcd.setCursor(0,1);
+ if (gameType == CAPTURE)
+ lcd.print("Alpha: ");
+ else
+ lcd.print("Time: ");
+ lcd.print(hourAlpha);
+ lcd.print("hrs ");
+ lcd.print(minAlpha);
+ lcd.print("mins");
+ if (gameType == CAPTURE) {
+ lcd.setCursor(0,2);
+ lcd.print("Bravo: ");
+ lcd.print(hourBravo);
+ lcd.print("hrs ");
+ lcd.print(minBravo);
+ lcd.print("mins");
+ }
+ handleKeypadEvents();
+ }
+
+ timeLeftAlpha = (atoi(hourAlpha) * 3600000) + (atoi(minAlpha) * 60000);
+
+ if (gameType == CAPTURE)
+ timeLeftBravo = (atoi(hourBravo) * 3600000) + (atoi(minBravo) * 60000);
+
+ setupState++;
+ break;
+ case STARTGAME:
+ displayMatchNum();
+ lcd.setCursor(0,1);
+ lcd.print("Take note of match #");
+ lcd.setCursor(0,2);
+ lcd.print(" ");
+ displayMenu(" BEGIN MATCH-#");
+ while (matchStart == false) {
+ handleKeypadEvents();
+ }
+ setupState++;
+ break;
+ case SETUPCOMPLETE:
+ break;
+ default:
+ break;
+ }
+
+ lcd.clear();
+
+ if (gameType != CAPTURE)
+ displayMatchNum();
+ if (gameType == ASSAULT)
+ paused = true;
+
+ codeIndex = 0;
+}
+
+
+void countdown(int timeDiff) {
+ lcd.setCursor(0,2);
+ lcd.print("Enter Code: ");
+ lcd.print(disarmInput);
+
+ if (gameType == CAPTURE) {
+ displayTimeLeft(timeLeftAlpha, 0);
+ displayTimeLeft(timeLeftBravo, 1);
+ if (countingTeam == ALPHA)
+ timeLeftAlpha -= timeDiff;
+ else if (countingTeam == BRAVO)
+ timeLeftBravo -= timeDiff;
+ }
+ else {
+ if (millis() < attemptsMillis) {
+ lcd.setCursor(0,1);
+ lcd.print("Tries Left: ");
+ lcd.print(disarmAttempts);
+ }
+ else
+ displayTimeLeft(timeLeftAlpha, 1);
+ timeLeftAlpha -= timeDiff;
+ }
+
+ if (!paused)
+ countdownBeeper();
+ else
+ analogWrite(buzzPin, 0);
+
+ handleKeypadEvents();
+
+ if (timeLeftAlpha > overflowLimit) { //Check if we've run out of time (timer overflow)
+ timeLeftAlpha = 0;
+ detonateSeq();
+ }
+ else if (timeLeftBravo > overflowLimit) { //Check if we've run out of time (timer overflow)
+ timeLeftBravo = 0;
+ detonateSeq();
+ }
+}
+
+void endGameMode() {
+ displayMatchNum();
+ while(1) {
+ if ((millis() % 1000) < 500) {
+ displayTimeLeft(timeLeftAlpha, 1);
+ if (gameType == CAPTURE)
+ displayTimeLeft(timeLeftBravo, 2);
+ else
+ displayTimeLeft(timeLeftAlpha, 2);
+ }
+ else {
+ displayBlankTime();
+ }
+ }
+}
+
+
+
+/* BEGIN Keypad press handler */
+void handleKeypadEvents() {
+ char key = keypad.getKey();
+
+ if (key != NO_KEY){
+ //Chirp!
+ TCCR2B = (TCCR2B & 0xF8) | 2; //Set the last value lower to get a higher tone and vice versa
+ analogWrite(buzzPin, 127);
+ delay(15);
+ analogWrite(buzzPin, 0);
+
+ if (setupState == SETGAMETYPE) {
+ if (key == '1')
+ gameType = ASSAULT;
+ else if (key == '2')
+ gameType = DEFEND;
+ else if (key == '3')
+ gameType = CAPTURE;
+ }
+ else if (setupState == SETATTEMPTS) {
+ if (disarmIndex < 2 && key != '*' && key != '#')
+ disarmEntered[disarmIndex++] = key;
+ else if (key == '*' && disarmIndex > 0)
+ disarmEntered[--disarmIndex] = '-';
+ else if (key == '#' && disarmIndex == 2) {
+ if (atoi(disarmEntered) > 0 && atoi(disarmEntered) < 100) {
+ disarmAttempts = atoi(disarmEntered);
+ }
+ }
+ }
+ else if (setupState == SETCODES) {
+ if (key == '*' && gameType == DEFEND && codeIndex == 12)
+ codeIndex = 6;
+
+ if (key != '*' && key != '#') {
+ if (codeIndex < 6)
+ refKey[codeIndex++] = key;
+ else if (codeIndex >= 6 && codeIndex < 12)
+ alphaKey[((codeIndex++) - 6)] = key;
+ else if (codeIndex >= 12 && codeIndex < 18)
+ bravoKey[((codeIndex++) - 12)] = key;
+ }
+ else if (key == '*') {
+ if (codeIndex > 0 && codeIndex < 7)
+ refKey[--codeIndex] = '-';
+ else if (codeIndex >= 7 && codeIndex < 13)
+ alphaKey[--codeIndex - 6] = '-';
+ else if (codeIndex >= 13 && codeIndex < 19)
+ bravoKey[--codeIndex - 12] = '-';
+ }
+ else if (key == '#') {
+ if (codeIndex == 18 && strcmp(alphaKey, refKey) != 0 && strcmp(bravoKey, refKey) != 0) {
+ if (gameType == CAPTURE && strcmp(bravoKey, alphaKey) == 0)
+ codesConfigured = false;
+ else
+ codesConfigured = true;
+ }
+ }
+
+ if (gameType == DEFEND && codeIndex == 6)