Skip to content

Commit

Permalink
Rename LED::set to LED::write, and change led status to bool
Browse files Browse the repository at this point in the history
  • Loading branch information
maniacbug committed Jun 12, 2012
1 parent 78bea2f commit 54af0f9
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions examples/sensornet/sensornet.pde
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ public:
digitalWrite(pin,LOW);
}
}
void set(int state) const
void write(bool state) const
{
if (pin)
digitalWrite(pin,state);
digitalWrite(pin,state?HIGH:LOW);
}

};
Expand All @@ -130,25 +130,25 @@ private:
const LED** leds;
const LED** current;
const LED** end;
int state;
bool state;
protected:
virtual void onFired(void)
{
(*current)->set(state);
(*current)->write(state);
++current;
if ( current >= end )
{
if ( state == HIGH )
if ( state )
{
state = LOW;
state = false;
current = leds;
}
else
disable();
}
}
public:
Startup(const LED** _leds, int _num): Timer(250), leds(_leds), current(_leds), end(_leds+_num), state(HIGH)
Startup(const LED** _leds, int _num): Timer(250), leds(_leds), current(_leds), end(_leds+_num), state(true)
{
}
};
Expand All @@ -160,21 +160,21 @@ class CalibrationLEDs: public Timer
{
const LED** leds;
const LED** end;
int state;
bool state;
protected:
void write()
{
const LED** current = end;
while (current-- > leds)
(*current)->set(state);
(*current)->write(state);
}
virtual void onFired()
{
state = state ^ HIGH;
state = ! state;
write();
}
public:
CalibrationLEDs(const LED** _leds, int _num, unsigned long duration = 500): Timer(duration), leds(_leds), end(_leds+_num), state(LOW)
CalibrationLEDs(const LED** _leds, int _num, unsigned long duration = 500): Timer(duration), leds(_leds), end(_leds+_num), state(false)
{
Timer::disable();
}
Expand Down Expand Up @@ -286,11 +286,11 @@ void loop(void)
if ( this_node > 0 && ( Sleep || send_timer.wasFired() ) && ! calibration_mode )
{
// Transmission beginning, TX LED ON
Yellow.set(HIGH);
Yellow.write(true);
if ( test_mode )
{
Green.set(LOW);
Red.set(LOW);
Green.write(false);
Red.write(false);
}

int i;
Expand Down Expand Up @@ -326,18 +326,18 @@ void loop(void)
if (ok)
{
if ( test_mode )
Green.set(HIGH);
Green.write(true);
printf_P(PSTR("%lu: APP Send ok\n\r"),millis());
}
else
{
if ( test_mode )
Red.set(HIGH);
Red.write(true);
printf_P(PSTR("%lu: APP Send failed\n\r"),millis());
}

// Transmission complete, TX LED OFF
Yellow.set(LOW);
Yellow.write(false);

if ( Sleep && ! test_mode )
{
Expand Down Expand Up @@ -366,8 +366,8 @@ void loop(void)
else if ( test_mode )
{
test_mode = false;
Green.set(LOW);
Red.set(LOW);
Green.write(false);
Red.write(false);
}
else if ( calibration_mode )
{
Expand Down

0 comments on commit 54af0f9

Please sign in to comment.