Skip to content

Commit 0fed683

Browse files
committed
Initial testmode implemented.
1 parent c6efc23 commit 0fed683

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

libraries/MySensors/examples/MysensorMicro/MysensorMicro.ino

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <Wire.h>
1111
#include <SI7021.h>
1212
#include <SPI.h>
13+
#include <SPIFlash.h>
1314
#include <EEPROM.h>
1415

1516
// Define a static node address, remove if you want auto address assignment
@@ -21,6 +22,7 @@
2122
#define CHILD_ID_BATT 199
2223

2324
//Pin definitions
25+
#define TEST_PIN A0
2426
#define RESET_CFG_PIN A1
2527
#define LED_PIN A2
2628

@@ -30,6 +32,8 @@
3032
#define FORCE_TRANSMIT_INTERVAL 30
3133

3234
SI7021 humiditySensor;
35+
SPIFlash flash(8, 0xEF30);
36+
3337
MySensor gw;
3438

3539
// Sensor messages
@@ -53,10 +57,13 @@ void setup() {
5357

5458
// First check if we should boot into clear eeprom mode
5559
pinMode(RESET_CFG_PIN, INPUT);
60+
pinMode(TEST_PIN,INPUT);
5661
digitalWrite(RESET_CFG_PIN, HIGH); // Enable pullup
62+
digitalWrite(TEST_PIN, HIGH);
63+
if (!digitalRead(TEST_PIN)) testMode();
5764
if (!digitalRead(RESET_CFG_PIN)) resetEEP();
5865
digitalWrite(RESET_CFG_PIN, LOW);
59-
66+
digitalWrite(TEST_PIN,LOW);
6067
digitalWrite(LED_PIN, HIGH);
6168

6269
#ifdef NODE_ADDRESS
@@ -196,3 +203,28 @@ void switchClock(unsigned char clk)
196203
CLKPR = clk;
197204
sei();
198205
}
206+
207+
void testMode()
208+
{
209+
if (humiditySensor.begin())
210+
if (flash.initialize())
211+
{
212+
while (1)
213+
{
214+
digitalWrite(LED_PIN, HIGH);
215+
delay(800);
216+
digitalWrite(LED_PIN, LOW);
217+
delay(200);
218+
}
219+
}
220+
else
221+
{
222+
while (1)
223+
{
224+
digitalWrite(LED_PIN, HIGH);
225+
delay(200);
226+
digitalWrite(LED_PIN, LOW);
227+
delay(200);
228+
}
229+
}
230+
}

0 commit comments

Comments
 (0)