/Designs/skrysohledac2/SW/gps.c
File deleted
/Designs/skrysohledac2/SW/uart.h
File deleted
/Designs/skrysohledac2/SW/gps.h
File deleted
/Designs/skrysohledac2/SW/timer.c
File deleted
/Designs/skrysohledac2/SW/avrlibtypes.h
File deleted
/Designs/skrysohledac2/SW/rprintf.c
File deleted
/Designs/skrysohledac2/SW/buffer.h
File deleted
/Designs/skrysohledac2/SW/buffer.c
File deleted
/Designs/skrysohledac2/SW/nmea.c
File deleted
/Designs/skrysohledac2/SW/uart2.c
File deleted
/Designs/skrysohledac2/SW/lcd_hd44780.c
File deleted
/Designs/skrysohledac2/SW/avrlibdefs.h
File deleted
/Designs/skrysohledac2/SW/timer.h
File deleted
/Designs/skrysohledac2/SW/rprintf.h
File deleted
/Designs/skrysohledac2/SW/nmea.h
File deleted
/Designs/skrysohledac2/SW/uart2.h
File deleted
/Designs/skrysohledac2/SW/lcd_hd44780.h
File deleted
/Designs/skrysohledac2/SW/tsip.c
File deleted
/Designs/skrysohledac2/SW/port128.h
File deleted
/Designs/skrysohledac2/SW/tsip.h
File deleted
/Designs/skrysohledac2/SW/uart.c
File deleted
/Designs/skrysohledac2/SW/AVRProject.vcproj
3,7 → 3,7
ProjectType="Visual C++"
Version="8,00"
Name="AVRProject"
ProjectGUID="{E81EE5C5-BF61-4F63-97E0-F94397BD48AF}"
ProjectGUID="{38E1D1A1-FC7A-4A6C-9127-1A1C2FEF668D}"
Keyword="MakeFileProj"
>
<Platforms>
86,114 → 86,58
Name="Resource Files"
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
>
</Filter>
<Filter
Name="avrlib"
>
<File
RelativePath=".\avrlibdefs.h"
RelativePath="..\..\gps.c"
>
</File>
<File
RelativePath=".\avrlibtypes.h"
RelativePath="..\..\gps.h"
>
</File>
<File
RelativePath=".\buffer.c"
RelativePath="..\..\lcd_hd44780.c"
>
</File>
<File
RelativePath=".\buffer.h"
RelativePath="..\..\lcd_hd44780.h"
>
</File>
<File
RelativePath=".\gps.c"
RelativePath="makefile"
>
</File>
<File
RelativePath=".\gps.h"
RelativePath="..\..\nmea.c"
>
</File>
<File
RelativePath=".\lcd_hd44780.c"
RelativePath="..\..\nmea.h"
>
</File>
<File
RelativePath=".\lcd_hd44780.h"
RelativePath="..\..\rprintf.c"
>
</File>
<File
RelativePath=".\lcdconf.h"
RelativePath="..\..\rprintf.h"
>
</File>
<File
RelativePath=".\nmea.c"
RelativePath="..\..\tsip.c"
>
</File>
<File
RelativePath=".\nmea.h"
RelativePath="..\..\tsip.h"
>
</File>
<File
RelativePath=".\port128.h"
RelativePath="..\..\utm.c"
>
</File>
<File
RelativePath=".\rprintf.c"
RelativePath="..\..\utm.h"
>
</File>
<File
RelativePath=".\rprintf.h"
>
</File>
<File
RelativePath=".\timer.c"
>
</File>
<File
RelativePath=".\timer.h"
>
</File>
<File
RelativePath=".\tsip.c"
>
</File>
<File
RelativePath=".\tsip.h"
>
</File>
<File
RelativePath=".\uart.c"
>
</File>
<File
RelativePath=".\uart.h"
>
</File>
<File
RelativePath=".\uart2.c"
>
</File>
<File
RelativePath=".\uart2.h"
>
</File>
<File
RelativePath=".\utm.c"
>
</File>
<File
RelativePath=".\utm.h"
>
</File>
<File
RelativePath=".\vt100.c"
>
</File>
<File
RelativePath=".\vt100.h"
>
</File>
</Filter>
</Files>
<Globals>
/Designs/skrysohledac2/SW/gpstest.c
96,7 → 96,7
 
lcd_init(); // Init LCD (interface and display module)
rprintfInit(lcd_putc);
rprintfProgStrM("Ahoj...xxxxx"); rprintfCRLF();
rprintfProgStrM("Ahoj..."); rprintfCRLF();
_delay_ms(500);
lcd_clear();
 
134,12 → 134,10
else
gpsInfoPrintLCD2();
 
/*
sbi(DDRC, 0); // sets PC0 to be an output
sbi(DDRC, 0); // sets PC0 to be an output
cbi(PORTC, 0); // sets PC0 to output a LOW
_delay_ms(5);
sbi(PORTC, 0); // sets PC0 to output a HIGH
*/
}
}
 
/Designs/skrysohledac2/SW/makefile
30,8 → 30,7
# They will be compiled in the order you list them, so it's probably best
# to list $(TRG).c, your top-level target file, last.
 
# SRC = $(AVRLIB)/buffer.c $(AVRLIB)/uart2.c $(AVRLIB)/rprintf.c $(AVRLIB)/timer.c $(AVRLIB)/vt100.c $(AVRLIB)/tsip.c $(AVRLIB)/nmea.c $(AVRLIB)/gps.c $(AVRLIB)/lcd_hd44780.c $(AVRLIB)/utm.c $(TRG).c
SRC = buffer.c uart2.c rprintf.c timer.c vt100.c tsip.c nmea.c gps.c lcd_hd44780.c utm.c $(TRG).c
SRC = $(AVRLIB)/buffer.c $(AVRLIB)/uart2.c $(AVRLIB)/rprintf.c $(AVRLIB)/timer.c $(AVRLIB)/vt100.c $(AVRLIB)/tsip.c $(AVRLIB)/nmea.c $(AVRLIB)/gps.c $(AVRLIB)/lcd_hd44780.c $(TRG).c $(AVRLIB)/utm.c
 
#put additional assembler source file here
# The ASRC line allows you to list files which contain assembly code/routines that
79,15 → 78,15
uart.o : uart.c uart.h global.h
uart2.o : uart2.c uart2.h global.h
rprintf.o : rprintf.c rprintf.h
#a2d.o : a2d.c a2d.h
a2d.o : a2d.c a2d.h
timer.o : timer.c timer.h global.h
#pulse.o : pulse.c pulse.h timer.h global.h
pulse.o : pulse.c pulse.h timer.h global.h
lcd.o : lcd.c lcd.h lcdconf.h global.h
#i2c.o : i2c.c i2c.h global.h
#spi.o : spi.c spi.h global.h
#swpwm.o : swpwm.c swpwm.h global.h
#servo.o : servo.c servo.h global.h
#swuart.o : swuart.c swuart.h global.h
i2c.o : i2c.c i2c.h global.h
spi.o : spi.c spi.h global.h
swpwm.o : swpwm.c swpwm.h global.h
servo.o : servo.c servo.h global.h
swuart.o : swuart.c swuart.h global.h
tsip.o : tsip.c tsip.h global.h
nmea.o : nmea.c nmea.h global.h
vt100.o : vt100.c vt100.h global.h
/Designs/skrysohledac2/SW/AVRProject.sln
1,7 → 1,7

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AVRProject", "AVRProject.vcproj", "{E81EE5C5-BF61-4F63-97E0-F94397BD48AF}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AVRProject", "AVRProject.vcproj", "{38E1D1A1-FC7A-4A6C-9127-1A1C2FEF668D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
9,10 → 9,10
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E81EE5C5-BF61-4F63-97E0-F94397BD48AF}.Debug|Win32.ActiveCfg = Debug|Win32
{E81EE5C5-BF61-4F63-97E0-F94397BD48AF}.Debug|Win32.Build.0 = Debug|Win32
{E81EE5C5-BF61-4F63-97E0-F94397BD48AF}.Release|Win32.ActiveCfg = Release|Win32
{E81EE5C5-BF61-4F63-97E0-F94397BD48AF}.Release|Win32.Build.0 = Release|Win32
{38E1D1A1-FC7A-4A6C-9127-1A1C2FEF668D}.Debug|Win32.ActiveCfg = Debug|Win32
{38E1D1A1-FC7A-4A6C-9127-1A1C2FEF668D}.Debug|Win32.Build.0 = Debug|Win32
{38E1D1A1-FC7A-4A6C-9127-1A1C2FEF668D}.Release|Win32.ActiveCfg = Release|Win32
{38E1D1A1-FC7A-4A6C-9127-1A1C2FEF668D}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
/Designs/skrysohledac2/SW/utm.c
24,9 → 24,9
 
*/
 
//#include "stdafx.h"
//#include "Common.h"
//#include "osgb.h"
#include "stdafx.h"
#include "Common.h"
#include "osgb.h"
#include "utm.h"
#include <math.h>
 
117,8 → 117,8
// asterisk character ('*').
//=======================================================================
 
void LatLonToUtm (double a, double f, int* utmXZone, char* utmYZone,
double* easting, double* northing, double lat, double lon)
void LatLonToUtm (double a, double f, int& utmXZone, char& utmYZone,
double& easting, double& northing, double lat, double lon)
{
double recf;
double b;
142,26 → 142,24
double nfn;
 
if (lon <= 0.0) {
*utmXZone = 30 + (int)(lon / 6.0);
utmXZone = 30 + (int)(lon / 6.0);
} else {
*utmXZone = 31 + (int)(lon / 6.0);
utmXZone = 31 + (int)(lon / 6.0);
}
if (lat < 84.0 && lat >= 72.0) {
// Special case: zone X is 12 degrees from north to south, not 8.
*utmYZone = cArray[19];
utmYZone = cArray[19];
} else {
*utmYZone = cArray[(int)((lat + 80.0) / 8.0)];
utmYZone = cArray[(int)((lat + 80.0) / 8.0)];
}
if (lat >= 84.0 || lat < -80.0) {
// Invalid coordinate; the vertical zone is set to the invalid
// character.
*utmYZone = '*';
utmYZone = '*';
}
 
double latRad = lat * (M_PI/180);
double lonRad = lon * (M_PI/180);
// double latRad = lat * deg2rad;
// double lonRad = lon * deg2rad;
double latRad = lat * deg2rad;
double lonRad = lon * deg2rad;
recf = 1.0 / f;
b = a * (recf - 1.0) / recf;
eSquared = CalculateESquared (a, b);
177,7 → 175,7
dp = 35.0 * a * ((tn * tn * tn) - (tn * tn * tn * tn) + 11.0
* (tn * tn * tn * tn * tn) / 16.0) / 48.0;
ep = 315.0 * a * ((tn * tn * tn * tn) - (tn * tn * tn * tn * tn)) / 512.0;
olam = (*utmXZone * 6 - 183) * (M_PI/180);
olam = (utmXZone * 6 - 183) * deg2rad;
dlam = lonRad - olam;
s = sin (latRad);
c = cos (latRad);
190,12 → 188,12
t3 = sn * s * (c * c * c) * ok * (5.0 - (t * t) + 9.0 * eta + 4.0
* (eta * eta)) / 24.0;
if (latRad < 0.0) nfn = 10000000.0; else nfn = 0;
*northing = nfn + t1 + (dlam * dlam) * t2 + (dlam * dlam * dlam
northing = nfn + t1 + (dlam * dlam) * t2 + (dlam * dlam * dlam
* dlam) * t3 + (dlam * dlam * dlam * dlam * dlam * dlam) + 0.5;
t6 = sn * c * ok;
t7 = sn * (c * c * c) * (1.0 - (t * t) + eta) / 6.0;
*easting = fe + dlam * t6 + (dlam * dlam * dlam) * t7 + 0.5;
if (*northing >= 9999999.0) *northing = 9999999.0;
easting = fe + dlam * t6 + (dlam * dlam * dlam) * t7 + 0.5;
if (northing >= 9999999.0) northing = 9999999.0;
}
 
//=======================================================================
205,9 → 203,187
// LatLonToUtm() member function.)
//=======================================================================
 
void LatLonToUtmWGS84 (int* utmXZone, char* utmYZone,
double* easting, double* northing, double lat, double lon)
void LatLonToUtmWGS84 (int& utmXZone, char& utmYZone,
double& easting, double& northing, double lat, double lon)
{
LatLonToUtm (6378137.0, 1 / 298.257223563, utmXZone, utmYZone,
easting, northing, lat, lon);
}
 
 
 
 
//=======================================================================
// Purpose:
// This function converts the specified UTM coordinate to a lat/lon
// coordinate.
// Pre:
// - utmXZone must be between 1 and 60, inclusive.
// - utmYZone must be one of: CDEFGHJKLMNPQRSTUVWX
// Parameters:
// double a:
// Ellipsoid semi-major axis, in meters. (For WGS84 datum, use 6378137.0)
// double f:
// Ellipsoid flattening. (For WGS84 datum, use 1 / 298.257223563)
// int utmXZone:
// The horizontal zone number of the UTM coordinate.
// char utmYZone:
// The vertical zone letter of the UTM coordinate.
// double easting, double northing:
// The UTM coordinate to convert.
// double& lat:
// Upon exit, lat contains the latitude.
// double& lon:
// Upon exit, lon contains the longitude.
// Notes:
// The code in this function is a C conversion of some of the source code
// from the Mapping Datum Transformation Software (MADTRAN) program, written
// in PowerBasic. To get the source code for MADTRAN, go to:
//
// http://164.214.2.59/publications/guides/MADTRAN/index.html
//
// and download MADTRAN.ZIP
//=======================================================================
 
void UtmToLatLon (double a, double f, int utmXZone, char utmYZone,
double easting, double northing, double& lat, double& lon)
{
double recf;
double b;
double eSquared;
double e2Squared;
double tn;
double ap;
double bp;
double cp;
double dp;
double ep;
double nfn;
double tmd;
double sr;
double sn;
double ftphi;
double s;
double c;
double t;
double eta;
double de;
double dlam;
double olam;
 
recf = 1.0 / f;
b = a * (recf - 1) / recf;
eSquared = CalculateESquared (a, b);
e2Squared = CalculateE2Squared (a, b);
tn = (a - b) / (a + b);
ap = a * (1.0 - tn + 5.0 * ((tn * tn) - (tn * tn * tn)) / 4.0 + 81.0 *
((tn * tn * tn * tn) - (tn * tn * tn * tn * tn)) / 64.0);
bp = 3.0 * a * (tn - (tn * tn) + 7.0 * ((tn * tn * tn)
- (tn * tn * tn * tn)) / 8.0 + 55.0 * (tn * tn * tn * tn * tn) / 64.0)
/ 2.0;
cp = 15.0 * a * ((tn * tn) - (tn * tn * tn) + 3.0 * ((tn * tn * tn * tn)
- (tn * tn * tn * tn * tn)) / 4.0) / 16.0;
dp = 35.0 * a * ((tn * tn * tn) - (tn * tn * tn * tn) + 11.0
* (tn * tn * tn * tn * tn) / 16.0) / 48.0;
ep = 315.0 * a * ((tn * tn * tn * tn) - (tn * tn * tn * tn * tn)) / 512.0;
if ((utmYZone <= 'M' && utmYZone >= 'C')
|| (utmYZone <= 'm' && utmYZone >= 'c')) {
nfn = 10000000.0;
} else {
nfn = 0;
}
tmd = (northing - nfn) / ok;
sr = sphsr (a, eSquared, 0.0);
ftphi = tmd / sr;
double t10, t11, t14, t15;
for (int i = 0; i < 5; i++) {
t10 = sphtmd (ap, bp, cp, dp, ep, ftphi);
sr = sphsr (a, eSquared, ftphi);
ftphi = ftphi + (tmd - t10) / sr;
}
sr = sphsr (a, eSquared, ftphi);
sn = sphsn (a, eSquared, ftphi);
s = sin (ftphi);
c = cos (ftphi);
t = s / c;
eta = e2Squared * (c * c);
de = easting - fe;
t10 = t / (2.0 * sr * sn * (ok * ok));
t11 = t * (5.0 + 3.0 * (t * t) + eta - 4.0 * (eta * eta) - 9.0 * (t * t)
* eta) / (24.0 * sr * (sn * sn * sn) * (ok * ok * ok * ok));
lat = ftphi - (de * de) * t10 + (de * de * de * de) * t11;
t14 = 1.0 / (sn * c * ok);
t15 = (1.0 + 2.0 * (t * t) + eta) / (6 * (sn * sn * sn) * c
* (ok * ok * ok));
dlam = de * t14 - (de * de * de) * t15;
olam = (utmXZone * 6 - 183.0) * deg2rad;
lon = olam + dlam;
lon *= rad2deg;
lat *= rad2deg;
}
 
//=======================================================================
// Purpose:
// This function converts the specified UTM coordinate to a lat/lon
// coordinate in the WGS84 datum. (See the comment block for the
// UtmToLatLon() member function.
//=======================================================================
 
void UtmToLatLonWGS84 (int utmXZone, char utmYZone, double easting,
double northing, double& lat, double& lon)
{
UtmToLatLon (6378137.0, 1 / 298.257223563, utmXZone, utmYZone,
easting, northing, lat, lon);
}
 
//=======================================================================
/**
@func Build a position string
@parm target. must be 30 characters or longer.
*/
//=======================================================================
 
void CUtmPoint::GetString(TCHAR *position) const
{
_stprintf(position,
_T("%02d%c %06d %07d"),
m_xzone, m_yzone,
(int)m_easting,
(int)m_northing);
}
 
//=======================================================================
/**
@func get the position of a UTM point
@parm point out
*/
//=======================================================================
 
void CUtmPoint::ToPosition(CPosition &pos) const
{
double lat,lon;
UtmToLatLonWGS84(m_xzone,m_yzone,m_easting,m_northing,
lat,lon);
pos.Clear();
pos.SetLatitude(lat);
pos.SetLongitude(lon);
}
 
//=======================================================================
/**
@func turn a position into a UTM point
@parm position
@rdesc true if it was in range
*/
//=======================================================================
 
bool CUtmPoint::FromPosition(const CPosition &pos)
{
Clear();
if(!IsPositionInUtmSpace(pos))
return false;
LatLonToUtmWGS84(m_xzone,m_yzone,m_easting,m_northing,
pos.GetLatitude(),
pos.GetLongitude());
return true;
}
/Designs/skrysohledac2/SW/utm.h
10,6 → 10,7
* @doc
*
************************************************************************/
#pragma once
 
//=======================================================================
/**
16,6 → 17,86
* UTM support goes here
*/
//=======================================================================
void LatLonToUtmWGS84 (int* utmXZone, char* utmYZone,
double* easting, double* northing, double lat, double lon);
class CUtmPoint
{
protected:
double m_easting;
double m_northing;
int m_xzone;
char m_yzone;
public:
 
//=======================================================================
//=======================================================================
CUtmPoint()
{Clear();}
 
//=======================================================================
//=======================================================================
CUtmPoint(const CPosition &p)
{
FromPosition(p);
}
 
//=======================================================================
//=======================================================================
CUtmPoint(const CUtmPoint& that)
{
m_easting=that.m_easting;
m_northing=that.m_northing;
m_xzone=that.m_xzone;
m_yzone=that.m_yzone;
}
 
//=======================================================================
//=======================================================================
void Clear()
{
m_easting=m_northing=0;
m_xzone=0;
m_yzone=0;
}
 
//=======================================================================
/**
@func Build a position string
@parm target. must be 30 characters or longer.
*/
//=======================================================================
 
void GetString(TCHAR *position) const;
 
//=======================================================================
/**
@func get the position of a UTM point
@parm point out
*/
//=======================================================================
 
void ToPosition(CPosition &pos) const;
 
//=======================================================================
/**
@func turn a position into a UTM point
@parm position
@rdesc true if it was in range
*/
//=======================================================================
 
bool FromPosition(const CPosition &pos);
 
//=======================================================================
/**
range test
*/
//=======================================================================
 
static bool IsPositionInUtmSpace(const CPosition &pos)
{ return pos.GetLatitude()<=84 && pos.GetLatitude()>=-80;}
 
 
 
};