diff --git a/src/main.cpp b/src/main.cpp index 37298fa..c2c2ab7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,12 +21,13 @@ Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); Servo servo; -int servoPin = 13; +int servoPin = 16; SoftwareSerial altserial(14, 12); // rx, tx Adafruit_GPS GPS(&altserial); uint32_t tstamp = millis(); +float az = 0.0; typedef struct { time_t epoch; @@ -79,7 +80,7 @@ void init_servo() { // /////////////////////////////////////////////////////////////////////////////////////// void setup() { Serial.begin(115200); -// init_servo(); + init_servo(); init_display(); init_gps(); wmm_init(); @@ -165,19 +166,32 @@ void debug_solar() { // Serial.print("Antenna status: "); Serial.println((int)GPS.antenna); } -// void servo_sweep() { -// int pos; +// value 80 mirror is pointing up +// 180 is pointing forward at 90 degrees +void hg_set_zenith(float z) { + Serial.print("moving to zenith -> "); + Serial.print( z ); + Serial.println(); + int a = (int)ceilf(180.0 - z); + servo.write( a ); + delay(20); +} -// for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees -// // in steps of 1 degree -// servo.write(pos); // tell servo to go to position in variable 'pos' -// delay(15); // waits 15ms for the servo to reach the position -// } -// for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees -// servo.write(pos); // tell servo to go to position in variable 'pos' -// delay(15); // waits 15ms for the servo to reach the position -// } -// } +/* +void servo_sweep() { + int pos; + + for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees + // in steps of 1 degree + servo.write(pos); // tell servo to go to position in variable 'pos' + delay(10); // waits 15ms for the servo to reach the position + } + for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees + servo.write(pos); // tell servo to go to position in variable 'pos' + delay(10); // waits 15ms for the servo to reach the position + } +} +*/ float compute_magnetic_declination() { float wmmtime = wmm_get_date(GPS.year, GPS.month, GPS.day); @@ -226,7 +240,7 @@ void gps_pump() { void loop() { gps_pump(); - + // // approximately every 2 seconds or so, print out the current stats if (millis() - tstamp > 2000) { tstamp = millis(); // reset the timer @@ -241,10 +255,17 @@ void loop() { // // servo.write( ceil(sun.elevation) ); // // delay(20); + // move mirror to zenith position + //hg_set_zenith(sun.zenith); + hg_set_zenith(az); + az += 1.0; + if(az > 180) { az = .0; } + // debug_solar(); ui_sunpos(); } else { ui_nogpsfix(); } } + } // loop()