Adding an astyle make target and running everything through it

This commit is contained in:
Dan Buch 2013-12-30 00:00:35 -05:00
parent e01c30f7c7
commit 7e43885af4
6 changed files with 50 additions and 46 deletions

View File

@ -5,6 +5,10 @@ EVERYTHING := \
.PHONY: all
all: $(EVERYTHING)
.PHONY: all
style:
astyle -r '*.ino' -n
arduino.mk:
curl -L -o $@ -s http://ed.am/dev/make/arduino-mk/arduino.mk

View File

@ -32,7 +32,7 @@ void playNote(int note) {
void playMeasure(int measure[]) {
for (int i = 0;;i++) {
for (int i = 0;; i++) {
int note = measure[i];
if (note == 0) {
return;

View File

@ -4,24 +4,24 @@ const unsigned int FLASH_DURATION = 100;
void flash(int n) {
for (int i = 0; i < n; i++) {
digitalWrite(LED_PIN, HIGH);
delay(FLASH_DURATION);
digitalWrite(LED_PIN, LOW);
delay(FLASH_DURATION);
}
for (int i = 0; i < n; i++) {
digitalWrite(LED_PIN, HIGH);
delay(FLASH_DURATION);
digitalWrite(LED_PIN, LOW);
delay(FLASH_DURATION);
}
}
void setup() {
pinMode(LED_PIN, OUTPUT);
pinMode(LED_PIN, OUTPUT);
}
void loop() {
for (int i = 1; i < 4; i++) {
flash(i);
for (int i = 1; i < 4; i++) {
flash(i);
delay(PAUSE);
}
delay(PAUSE);
}
delay(PAUSE);
}

View File

@ -2,53 +2,53 @@ const unsigned int LED_PIN = 13;
const unsigned int BAUD_RATE = 9600;
void ledOn() {
digitalWrite(LED_PIN, HIGH);
Serial.println("LED on");
digitalWrite(LED_PIN, HIGH);
Serial.println("LED on");
}
void ledOff() {
digitalWrite(LED_PIN, LOW);
Serial.println("LED off");
digitalWrite(LED_PIN, LOW);
Serial.println("LED off");
}
void ledBlink() {
Serial.println("BLINKY TIME");
for (int i = 0; i < 5; i++) {
ledOn();
delay(100);
ledOff();
delay(100);
}
Serial.println("BLINKY TIME");
for (int i = 0; i < 5; i++) {
ledOn();
delay(100);
ledOff();
delay(100);
}
}
void handleInput() {
int c = Serial.read();
int c = Serial.read();
switch (c) {
case '1':
ledOn();
break;
case '2':
ledOff();
break;
case '3':
ledBlink();
break;
default:
Serial.print("Unknown command: ");
Serial.println(c);
}
switch (c) {
case '1':
ledOn();
break;
case '2':
ledOff();
break;
case '3':
ledBlink();
break;
default:
Serial.print("Unknown command: ");
Serial.println(c);
}
}
void setup() {
pinMode(LED_PIN, OUTPUT);
Serial.begin(BAUD_RATE);
pinMode(LED_PIN, OUTPUT);
Serial.begin(BAUD_RATE);
}
void loop() {
if (Serial.available() <= 0) {
return;
}
if (Serial.available() <= 0) {
return;
}
handleInput();
handleInput();
}

View File

@ -13,7 +13,7 @@ void loop() {
const int CURRENT_BUTTON_STATE = digitalRead(BUTTON_PIN);
if (CURRENT_BUTTON_STATE != oldButtonState &&
CURRENT_BUTTON_STATE == HIGH) {
CURRENT_BUTTON_STATE == HIGH) {
if (ledState == LOW) {
ledState = HIGH;
} else {

View File

@ -13,7 +13,7 @@ void loop() {
const int CURRENT_BUTTON_STATE = digitalRead(BUTTON_PIN);
if (CURRENT_BUTTON_STATE != oldButtonState &&
CURRENT_BUTTON_STATE == HIGH) {
CURRENT_BUTTON_STATE == HIGH) {
if (ledState == LOW) {
ledState = HIGH;
} else {