Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 151 lines (117 sloc) 2.43 KB
/*
This example code for Flutter is
Copyright 2015, Taylor Alexander and Flutter Wireless, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "Flutter.h"
Flutter flutter;
byte mydata = 0;
void setup()
{
// Open connection to USB and wait for host to connect.
SerialUSB.begin(115200);
while(!SerialUSB);
flutter.band = BAND;
flutter.setNetworkName("Serial USB");
SerialUSB.println("Initializing...");
if (flutter.init() == true)
{
SerialUSB.println("Init success.");
flutter.ledLightShow();
delay(500);
//analogWrite(LED_R, 128);
}
else
{
flutter.setLED(RED);
SerialUSB.println("Init failed.");
while (true);
}
flutter.setAddress(1);
flutter.connect(1); //form a network with this and one other device
}
void loop()
{
SerialUSB.print("Millis = ");
SerialUSB.println(millis());
delay(100);
}
void button1()
{
interrupts();
int val = digitalRead(BUTTON1); //top button
if (val == HIGH)
{
// _button1=255;
}
else
{
// _button1=0;
// Software chip erase with a button press.
systemReset();
}
// buttonsChanged=true;
}
void button2()
{
interrupts();
int val = digitalRead(BUTTON2);
#ifdef FLUTTER_R2
if (val == HIGH)
#else
if (val == LOW)
#endif
{
//_button2=255;
}
else
{
//_button2=0;
}
// buttonsChanged=true;
}
void systemReset()
{
flutter.setLED(0, 0, 255);
delayMicroseconds(16000);
delayMicroseconds(16000);
flutter.setLED(0, 0, 0);
delayMicroseconds(16000);
delayMicroseconds(16000);
flutter.setLED(0, 255, 0);
delayMicroseconds(16000);
delayMicroseconds(16000);
flutter.setLED(0, 0, 0);
delayMicroseconds(16000);
delayMicroseconds(16000);
flutter.setLED(255, 0, 0);
delayMicroseconds(16000);
delayMicroseconds(16000);
flutter.setLED(0, 0, 0);
initiateReset(1);
tickReset();
}
void radioInterrupt()
{
flutter.interrupt();
}
void softInt()
{
flutter.processSoftInt();
}
extern boolean tickInterrupt()
{
if (!flutter.initialized)
{
return true;
}
return flutter.tickInt();
}