Skip to content

Commit adeca1c

Browse files
committed
Updated testmode, removed clearEEP function as it's not needed in production.
1 parent 0fed683 commit adeca1c

File tree

1 file changed

+36
-24
lines changed

1 file changed

+36
-24
lines changed

libraries/MySensors/examples/MysensorMicro/MysensorMicro.ino

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include <SPI.h>
1313
#include <SPIFlash.h>
1414
#include <EEPROM.h>
15+
//#include <sha204_library.h>
16+
1517

1618
// Define a static node address, remove if you want auto address assignment
1719
//#define NODE_ADDRESS 3
@@ -23,8 +25,8 @@
2325

2426
//Pin definitions
2527
#define TEST_PIN A0
26-
#define RESET_CFG_PIN A1
2728
#define LED_PIN A2
29+
#define ATSHA204_PIN 17 // A3
2830

2931
#define MEASURE_INTERVAL 60000
3032

@@ -56,13 +58,9 @@ void setup() {
5658
digitalWrite(LED_PIN, LOW);
5759

5860
// First check if we should boot into clear eeprom mode
59-
pinMode(RESET_CFG_PIN, INPUT);
6061
pinMode(TEST_PIN,INPUT);
61-
digitalWrite(RESET_CFG_PIN, HIGH); // Enable pullup
6262
digitalWrite(TEST_PIN, HIGH);
6363
if (!digitalRead(TEST_PIN)) testMode();
64-
if (!digitalRead(RESET_CFG_PIN)) resetEEP();
65-
digitalWrite(RESET_CFG_PIN, LOW);
6664
digitalWrite(TEST_PIN,LOW);
6765
digitalWrite(LED_PIN, HIGH);
6866

@@ -82,7 +80,7 @@ void setup() {
8280
gw.present(CHILD_ID_HUM,S_HUM);
8381

8482
gw.present(CHILD_ID_BATT, S_POWER);
85-
switchClock(1<<CLKPS2);
83+
switchClock(1<<CLKPS2); // Switch to 1Mhz for the reminder of the sketch, save power.
8684
}
8785

8886

@@ -180,21 +178,6 @@ long readVcc() {
180178
return result; // Vcc in millivolts
181179
}
182180

183-
184-
/*
185-
* Resets eeprom to default value (while blinking LED_PIN)
186-
*/
187-
void resetEEP()
188-
{
189-
for (int i=0;i<512;i++) {
190-
digitalWrite(LED_PIN, HIGH);
191-
delay(100);
192-
digitalWrite(LED_PIN, LOW);
193-
delay(100);
194-
EEPROM.write(i, 0xff);
195-
}
196-
}
197-
198181
void switchClock(unsigned char clk)
199182
{
200183
cli();
@@ -204,12 +187,40 @@ void switchClock(unsigned char clk)
204187
sei();
205188
}
206189

190+
191+
// Verify all peripherals, and signal via the LED if any problems.
207192
void testMode()
208193
{
209-
if (humiditySensor.begin())
194+
byte tests = 0;
195+
196+
Serial.println("Testing peripherals!");
197+
198+
if (humiditySensor.begin())
199+
{
200+
Serial.println("Si7021 ok!");
201+
tests ++;
202+
}
203+
else
204+
{
205+
Serial.println("---> Si7021 FAILED!");
206+
}
207+
210208
if (flash.initialize())
211209
{
212-
while (1)
210+
Serial.println("flash OK!");
211+
tests ++;
212+
}
213+
else
214+
{
215+
Serial.println("---> flash failed!");
216+
}
217+
218+
Serial.println("Test finished");
219+
220+
if (tests == 2)
221+
{
222+
Serial.println("Selftest ok!");
223+
while (1) // Blink OK pattern!
213224
{
214225
digitalWrite(LED_PIN, HIGH);
215226
delay(800);
@@ -219,7 +230,8 @@ void testMode()
219230
}
220231
else
221232
{
222-
while (1)
233+
Serial.println("----> Selftest failed!");
234+
while (1) // Blink FAILED pattern! Rappidly blinking..
223235
{
224236
digitalWrite(LED_PIN, HIGH);
225237
delay(200);

0 commit comments

Comments
 (0)