uTrack
Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions | Variables
utWaterCurrent.c File Reference

Water current will calculate water current movement and write the result to the NMEA store. TideBot uses oled module for display of watercurrent measurements. More...

#include "uTrack.h"
#include "utNmeaStore.h"
#include "utTypes.h"
#include "utNmeaOutput.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "utGPIOEvents.h"
#include "utDisplay.h"
#include "utNav.h"
#include "utWaterCurrent.h"
#include "utMonitor.h"

Data Structures

struct  UT_DISPLAY_VALUES
 
struct  UT_WCT_DATA_POINT
 
struct  UT_WaterCurrent_Store
 

Macros

#define M_PI   3.14159265359
 
#define DEG2RAD(x)   ((float)(x) * (M_PI/180.0))
 
#define RAD2DEG(x)   ((float)(x) * (180.0/M_PI))
 

Enumerations

enum  UT_TIDEBOT_STATE {
  UT_TIDEBOT_IDLE , UT_TIDEBOT_STANDOFF , UT_TIDEBOT_RUNNING , UT_TIDEBOT_CALCULATING ,
  UT_TIDEBOT_RESULT , UT_TIDEBOT_ERROR
}
 
enum  UT_TIDEBOT_FAILURE_REASON {
  UT_TIDEBOT_SAMPLES , UT_TIDEBOT_MIN_TIME , UT_TIDEBOT_MIN_DISTANCE , UT_TIDEBOT_INVALID_CALC_ERROR ,
  UT_TIDEBOT_USER_CANCEL , UT_TIDEBOT_MAX
}
 
enum  UT_WCT_STORE_STATE { VALID_STICK_IN , VALID_STICK_OUT , VALID_READING , NO_DATA }
 
enum  UT_WCT_CONVENTION_TYPE { WCT_CONVENTION_FROM , WCT_CONVENTION_TO }
 
enum  UT_WCT_NORTH_TYPE { WCT_TRUE_NORTH , WCT_MAG_NORTH }
 
enum  UT_WCT_UNITS { WCT_MS_UNIT , WCT_KT_UNIT , WCT_BOATLEN_UNIT , WCT_MM_UNIT }
 
enum  UT_WCT_LOGGING { WCT_BRIEF , WCT_FULL , WCT_NONE }
 
enum  UT_WCT_USER_INPUT { WCT_BUTTON_TAPS , WCT_DISPLAY_GPIO , WCT_BOTH }
 

Functions

bool waterCurrentInsertPoint (void)
 
bool wctCalculateResult (bool final)
 
void ChangeState (UT_TIDEBOT_STATE state)
 
bool GetGPSCurrentPosition (UT_NMEA_Store *store, double *lat, double *lon, UT_DateTime *dateTime)
 
double getDirection (float latIn, float lonIn, float latOut, float lonOut)
 
double getDistance (float lat1, float lon1, float lat2, float lon2)
 
void resetWaterCurrentStore ()
 
bool utWCT_Notify (UT_DeviceMessage state)
 

Variables

UT_WaterCurrent_Store waterCurrentStore
 
double wctMinDist = 10
 
int wctMinTime = 30
 
UT_WCT_CONVENTION_TYPE wctConvention = WCT_CONVENTION_TO
 
UT_WCT_NORTH_TYPE wctNorth = WCT_TRUE_NORTH
 
UT_WCT_UNITS wctUnits = WCT_MS_UNIT
 
UT_WCT_LOGGING wctLogging = WCT_NONE
 
UT_WCT_USER_INPUT wctUserInput = WCT_BOTH
 
u32 wctInStandoff = 10
 
u32 wctOutStandoff = 10
 
double boatLength = 0
 
double decYear = 0
 
const u8 errorRadius = 6
 
double wctSMN = 0.0147
 

Detailed Description

Water current will calculate water current movement and write the result to the NMEA store. TideBot uses oled module for display of watercurrent measurements.

This module waits for user input to mark a GPS location for when a physical stick is placed into the water and out of the water. The Module will calculate the time difference and distance traveled between user "stick in" and "stick out" events to derive the Water current movement. The Calculated water current is then written back to a NMEA store, for automatic NMEA output/logging etc.

Precondition
First initialise the Wind and GPS nmea stores. Receives callbacks from GPIOEvents.c and utPic.c (PowerButton taps).
Author
Kylie Robinson & Adam Sherlaw
Date
01/07/2014 Updated: TideBot 05/10/2015

Enumeration Type Documentation

◆ UT_TIDEBOT_STATE

Software state the TideBot is in