2018-12-01 17:26:27 +00:00
|
|
|
#include <Wire.h>
|
|
|
|
#include <LiquidCrystal_I2C.h>
|
2018-12-03 09:54:53 +00:00
|
|
|
#include "xbee_wrapper.h"
|
|
|
|
#include "packet.h"
|
2018-12-01 17:26:27 +00:00
|
|
|
|
2018-12-01 17:38:00 +00:00
|
|
|
#define WAVE_TIMEOUT 5000
|
2018-12-01 17:26:27 +00:00
|
|
|
|
|
|
|
// Peripherals
|
|
|
|
LiquidCrystal_I2C screen(0x27, 16, 2);
|
2018-12-03 09:54:53 +00:00
|
|
|
XBeeWrapper xbee = XBeeWrapper();
|
2018-12-01 17:26:27 +00:00
|
|
|
|
|
|
|
// ACTUAL DATA
|
|
|
|
uint8_t wave_id = 250;
|
2018-12-03 09:54:53 +00:00
|
|
|
Packet send;
|
2018-12-01 17:26:27 +00:00
|
|
|
|
|
|
|
void setup() {
|
2018-12-03 09:54:53 +00:00
|
|
|
Serial.begin(38400);
|
|
|
|
Serial.println("+ ready");
|
2018-12-01 17:26:27 +00:00
|
|
|
|
2018-12-03 09:54:53 +00:00
|
|
|
screen.begin();
|
|
|
|
screen.backlight();
|
2018-12-01 17:26:27 +00:00
|
|
|
|
2018-12-03 09:54:53 +00:00
|
|
|
xbee.begin(38400);
|
2018-12-01 17:26:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void loop() {
|
|
|
|
|
2018-12-03 09:54:53 +00:00
|
|
|
delay(WAVE_TIMEOUT);
|
2018-12-01 17:26:27 +00:00
|
|
|
|
2018-12-03 09:54:53 +00:00
|
|
|
screen.clear();
|
|
|
|
screen.print("+ wave");
|
|
|
|
screen.print(wave_id+1);
|
2018-12-01 17:26:27 +00:00
|
|
|
|
2018-12-03 09:54:53 +00:00
|
|
|
// increment wave id (will overflow from 255 to 0)
|
|
|
|
send.setOpcode(0);
|
|
|
|
send.setWave(++wave_id);
|
|
|
|
send.setDist(0);
|
2018-12-01 17:26:27 +00:00
|
|
|
|
2018-12-03 09:54:53 +00:00
|
|
|
if( xbee.broadcast(send) == XBWSEND_OK )
|
|
|
|
Serial.println("sent");
|
|
|
|
else
|
|
|
|
Serial.println("failed");
|
2018-12-01 17:26:27 +00:00
|
|
|
|
|
|
|
}
|