Skip to content

Commit

Permalink
Merge pull request #1 from Tatskaari/master
Browse files Browse the repository at this point in the history
Moved code out of header file
  • Loading branch information
Jonathan Poole committed Dec 9, 2015
2 parents 3c68490 + 51a62f7 commit 3471ebb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
25 changes: 25 additions & 0 deletions christmas.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <arduino.h>
#include <string.h>
#include "christmas.h"

void setup() {
initialise();
Serial.begin(9600);
}

void loop() {
while(Serial.available() > 0){
String line = Serial.readStringUntil('\n');
if(strcmp(line.c_str(), "HO! HO! HO!") == 0){
ho_ho_ho();
}
else if(strcmp(line.c_str(), "Merry Christmas!") == 0){
merry_christmas();
}
else if(strcmp(line.c_str(), "Happy New Year!") == 0){
happy_new_year();
}
}
delay(1000);
tick();
}
28 changes: 3 additions & 25 deletions christmas.h
Original file line number Diff line number Diff line change
@@ -1,38 +1,16 @@
#include <arduino.h>
#include <string.h>
#ifndef __christmas_h_
#define __christmas_h_

#define HO_HO_HO "HO! HO! HO!"
#define MERRY_CHRISTMAS "Merry Christmas!"
#define HAPPY_NEW_YEAR "Happy New Year!"

long last_tick_time = 0;

void initialise();
void tick();

void ho_ho_ho();
void merry_christmas();
void happy_new_year();

void setup() {
initialise();
Serial.begin(9600);

}
#endif //__christmas_h_

void loop() {
while(Serial.available() > 0){
String line = Serial.readStringUntil('\n');
if(strcmp(line.c_str(), "HO! HO! HO!") == 0){
ho_ho_ho();
}
else if(strcmp(line.c_str(), "Merry Christmas!") == 0){
merry_christmas();
}
else if(strcmp(line.c_str(), "Happy New Year!") == 0){
happy_new_year();
}
}
delay(1000);
tick();
}

0 comments on commit 3471ebb

Please sign in to comment.