#include "comm.h"
#include "servo.h"

#include <SPI.h>
#include <LittleFS.h>

ServoController controller;
CommunicationsController comms;
void setup() {
    LittleFS.begin();
    comms.init();

    controller.initServos();
    controller.initMag();

    pinMode(15, OUTPUT);
    pinMode(12, OUTPUT);
    pinMode(14, OUTPUT);

    delay(1000);
}

float azimuth = 0.0;
float altitude = 0.0;

void loop() {
    byte resp = comms.process(&azimuth, &altitude);

    if (resp != 1) {
        return;
    }

    controller.updateHeading();
    controller.moveToAzAlt(azimuth, altitude);
}
