Ejemplo n.º 1
0
#define MIN_SETSPEED 190.0f

#define MIN_POS 50.0f
#define MAX_POS 970.0f

#define CYCLE_MOV 50

typedef enum {
  kIdleState,
  kWaitMoveState,
  kMovingState,
  kErrorState,
} FingerState;

CmdMessenger cmdMessenger = CmdMessenger(MYSERIAL);
int	oldPos[NUM_FINGERS];

enum
{
  kSetFingers,
};

FingerState states[NUM_FINGERS];

void OnSetFingers()
{
  MYSERIAL.println("OnSetFingers");
  int i;
  for(i = 0; i < NUM_FINGERS; ++i)
  {
#define EEPROM_SIZE EEPROMSizeATmega328

#define EEPROM_MAGIC_ADDR         0
#define EEPROM_DEVICE_UUID_ADDR   (EEPROM_MAGIC_ADDR + sizeof(magic))
#define EEPROM_DEVICE_NAME_ADDR   (EEPROM_DEVICE_UUID_ADDR + sizeof(deviceUuid))
#define EEPROM_SSID_ADDR          (EEPROM_DEVICE_NAME_ADDR + sizeof(deviceName))
#define EEPROM_PHRASE_ADDR        (EEPROM_SSID_ADDR + sizeof(ssid))

#ifdef WIFLY_SERIAL_HARDWARE
HardwareSerial& wifly_serial = Serial;
#else
SoftwareSerial wifly_serial(WIFLY_RXD_PIN, WIFLY_TXD_PIN);
#endif
static WiFly wifly(wifly_serial);

static CmdMessenger messenger = CmdMessenger(wifly);

static DeviceDescriptor* device;

#define BUF_LEN 128
static char buf[BUF_LEN + 1];
#define SERVER_ADDRESS_LEN 15
static char serverAddress[SERVER_ADDRESS_LEN + 1];
static unsigned long blinkMillis;
static int blinkIndex;
static int* blinkPattern;
#ifdef AUTO_CONFIG
#define MAC_LEN 17
static char mac[MAC_LEN + 1];
static int newDeviceBlinkPattern[] = { 1500, 100, 0 };
static int discoveredBlinkPattern[] = { 500, 500, 0 };
Ejemplo n.º 3
0
bool ledPSTimedout = false;
uint16_t ledPSTimeout = 30000;
uint8_t ledFadeTargetMin;
uint8_t ledFadeTargetMax;
uint8_t ledFade;
uint8_t ledControlMode;
uint8_t ledControlModeRestore;

void ledController(void);
void ledPSControl(void);
void ledFadeTo(uint8_t pin, uint8_t brightness);
bool ledFadeFlag = false;
uint8_t ledFadeTarget = 0;

//command messenger
CmdMessenger cmdMessenger = CmdMessenger(Serial);
void onReturnStatus(void);
void onReturnDeviceInfo(void);
void onSaveSettings(void);
void onDataSetPushMode(void);
void onDataReturnPushMode(void);
void onDataSetQueryInt(void);
void onDataReturnQueryInt(void);
void onReturnTempQuery(void);
void onReturnHumiQuery(void);
void onReturnPresQuery(void);
void onReturnLuxQuery(void);
void onReturnPSQuery(void);
void onLedSetMode(void);
void onLedReturnMode(void);
void onLedRestoreMode(void);