Skip to content

Commit

Permalink
Fixes after testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Sommer committed Apr 20, 2013
1 parent 339a685 commit ffffa20
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
16 changes: 8 additions & 8 deletions cPWM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ cPWM::cPWM(int id)
*/
void cPWM::DutyA_ns(unsigned int nanoseconds)
{
if(nanoseconds > cPWM::Period_ns)
if(nanoseconds > cPWM::period)
throw std::out_of_range("DutyA_ns: ");

cPWM::DutyA_ns = nanoseconds;
cPWM::dutyA = nanoseconds;
sysfsfid_dutyA_ns << nanoseconds << std::endl;
}

Expand All @@ -118,7 +118,6 @@ void cPWM::DutyA_percent(unsigned int percent)
if(percent > 100)
throw std::out_of_range("DutyA_percent: ");

cPWM::DutyA_percent = percent;
sysfsfid_dutyA_percent << percent << std::endl;
}

Expand All @@ -130,10 +129,10 @@ void cPWM::DutyA_percent(unsigned int percent)
*/
void cPWM::DutyB_ns(unsigned int nanoseconds)
{
if(nanoseconds > cPWM::Period_ns)
if(nanoseconds > cPWM::period)
throw std::out_of_range("DutyB_ns: ");

cPWM::dutyB_ns = nanoseconds;
cPWM::dutyB = nanoseconds;
sysfsfid_dutyB_ns << nanoseconds << std::endl;
}

Expand All @@ -149,7 +148,6 @@ void cPWM::DutyB_percent(unsigned int percent)
if(percent > 100)
throw std::out_of_range("DutyB_percent: ");

cPWM::DutyB_percent = percent;
sysfsfid_dutyB_percent << percent << std::endl;
}

Expand All @@ -162,7 +160,8 @@ void cPWM::DutyB_percent(unsigned int percent)
*/
void cPWM::Period_ns(unsigned int nanoseconds)
{
cPWM::Period_ns = nanoseconds;
cPWM::period = nanoseconds;
cPWM::freq_Hz = 1000000000 / nanoseconds;
sysfsfid_period_ns << nanoseconds << std::endl;
}

Expand All @@ -174,7 +173,8 @@ void cPWM::Period_ns(unsigned int nanoseconds)
*/
void cPWM::Period_freq(unsigned int freq_Hz)
{
cPWM::Period_freq = freq_Hz;
cPWM::freq_Hz = freq_Hz;
cPWM::period = 1000000000 / freq_Hz;
sysfsfid_period_freq << freq_Hz<< std::endl;
}

Expand Down
18 changes: 11 additions & 7 deletions cPWM.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,22 @@
namespace cPWM {

class cPWM {

public:
enum Polarity
{
ActiveHigh,
ActiveLow
};

private:
int id;
int dutyA;
int dutyB;
int period;
cPWM::Polarity polarityA;
cPWM::Polarity polarityB;
int freq_Hz;
enum cPWM::Polarity polarityA;
enum cPWM::Polarity polarityB;
int runA;
int runB;
/*****************************************
Expand Down Expand Up @@ -73,11 +82,6 @@ Define files to match sysfs tree:
std::ofstream sysfsfid_requestB;

public:
enum Polarity
{
ActiveHigh,
ActiveLow
};

cPWM(int id);
virtual ~cPWM();
Expand Down

0 comments on commit ffffa20

Please sign in to comment.