Skip to content

Commit

Permalink
Revert "Make power button disable stepper drive and turn off control …
Browse files Browse the repository at this point in the history
…panel. (#93)"

This reverts commit c956b26.
  • Loading branch information
clough42 committed Oct 10, 2020
1 parent c956b26 commit f27ba92
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 91 deletions.
7 changes: 0 additions & 7 deletions els-f280049c/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ Core :: Core( Encoder *encoder, StepperDrive *stepperDrive )
this->previousSpindlePosition = 0;
this->previousFeedDirection = 0;
this->previousFeed = NULL;

this->powerOn = true; // default to power on
}

void Core :: setReverse(bool reverse)
Expand All @@ -56,11 +54,6 @@ void Core :: setReverse(bool reverse)
}
}

void Core :: setPowerOn(bool powerOn)
{
this->powerOn = powerOn;
this->stepperDrive->setEnabled(powerOn);
}



Expand Down
10 changes: 0 additions & 10 deletions els-f280049c/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ class Core

int32 feedRatio(Uint32 count);

bool powerOn;

public:
Core( Encoder *encoder, StepperDrive *stepperDrive );

Expand All @@ -64,9 +62,6 @@ class Core
Uint16 getRPM(void);
bool isAlarm();

bool isPowerOn();
void setPowerOn(bool);

void ISR( void );
};

Expand All @@ -89,11 +84,6 @@ inline bool Core :: isAlarm()
return this->stepperDrive->isAlarm();
}

inline bool Core :: isPowerOn()
{
return this->powerOn;
}

inline int32 Core :: feedRatio(Uint32 count)
{
#ifdef USE_FLOATING_POINT
Expand Down
13 changes: 0 additions & 13 deletions els-f280049c/StepperDrive.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ class StepperDrive
void incrementCurrentPosition(int32 increment);
void setCurrentPosition(int32 position);

void setEnabled(bool);

bool isAlarm();

void ISR(void);
Expand All @@ -121,17 +119,6 @@ inline void StepperDrive :: setCurrentPosition(int32 position)
this->currentPosition = position;
}

inline void StepperDrive :: setEnabled(bool enabled)
{
if( enabled ) {
GPIO_SET_ENABLE;
}
else
{
GPIO_CLEAR_ENABLE;
}
}

inline bool StepperDrive :: isAlarm()
{
#ifdef USE_ALARM_PIN
Expand Down
112 changes: 52 additions & 60 deletions els-f280049c/UserInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ const MESSAGE SETTINGS_MESSAGE_1 =
.next = &SETTINGS_MESSAGE_2
};

const Uint16 VALUE_BLANK[4] = { BLANK, BLANK, BLANK, BLANK };

UserInterface :: UserInterface(ControlPanel *controlPanel, Core *core, FeedTableFactory *feedTableFactory)
{
this->controlPanel = controlPanel;
Expand All @@ -68,8 +66,6 @@ UserInterface :: UserInterface(ControlPanel *controlPanel, Core *core, FeedTable

this->keys.all = 0xff;

loadFeedTable();

setMessage(&STARTUP_MESSAGE_1);
}

Expand All @@ -79,23 +75,15 @@ const FEED_THREAD *UserInterface::loadFeedTable()
return this->feedTable->current();
}

LED_REG UserInterface::calculateLEDs()
LED_REG UserInterface::calculateLEDs(const FEED_THREAD *selectedFeed)
{
// get the LEDs for this feed
LED_REG leds = feedTable->current()->leds;
LED_REG leds = selectedFeed->leds;

if( this->core->isPowerOn() )
{
// and add a few of our own
leds.bit.POWER = 1;
leds.bit.REVERSE = this->reverse;
leds.bit.FORWARD = ! this->reverse;
}
else
{
// power is off
leds.all = 0;
}
// and add a few of our own
leds.bit.POWER = 1;
leds.bit.REVERSE = this->reverse;
leds.bit.FORWARD = ! this->reverse;

return leds;
}
Expand Down Expand Up @@ -126,44 +114,45 @@ void UserInterface :: overrideMessage( void )

void UserInterface :: loop( void )
{
const FEED_THREAD *newFeed = NULL;

// read the RPM up front so we can use it to make decisions
Uint16 currentRpm = core->getRPM();

// display an override message, if there is one
overrideMessage();

// just in case, initialize the first time through
if( feedTable == NULL ) {
newFeed = loadFeedTable();
}

// read keypresses from the control panel
keys = controlPanel->getKeys();

// respond to keypresses
if( currentRpm == 0 )
{
// these keys should only be sensitive when the machine is stopped
if( keys.bit.POWER ) {
this->core->setPowerOn(!this->core->isPowerOn());
if( keys.bit.IN_MM )
{
this->metric = ! this->metric;
newFeed = loadFeedTable();
}

// these should only work when the power is on
if( this->core->isPowerOn() ) {
if( keys.bit.IN_MM )
{
this->metric = ! this->metric;
core->setFeed(loadFeedTable());
}
if( keys.bit.FEED_THREAD )
{
this->thread = ! this->thread;
core->setFeed(loadFeedTable());
}
if( keys.bit.FWD_REV )
{
this->reverse = ! this->reverse;
core->setReverse(this->reverse);
}
if( keys.bit.SET )
{
setMessage(&SETTINGS_MESSAGE_1);
}
if( keys.bit.FEED_THREAD )
{
this->thread = ! this->thread;
newFeed = loadFeedTable();
}
if( keys.bit.FWD_REV )
{
this->reverse = ! this->reverse;
// feed table hasn't changed, but we need to trigger an update
newFeed = loadFeedTable();
}
if( keys.bit.SET )
{
setMessage(&SETTINGS_MESSAGE_1);
}
}

Expand All @@ -172,32 +161,35 @@ void UserInterface :: loop( void )
{
#endif // IGNORE_ALL_KEYS_WHEN_RUNNING

// these should only work when the power is on
if( this->core->isPowerOn() ) {
// these keys can be operated when the machine is running
if( keys.bit.UP )
{
core->setFeed(feedTable->next());
}
if( keys.bit.DOWN )
{
core->setFeed(feedTable->previous());
}
// these keys can be operated when the machine is running
if( keys.bit.UP )
{
newFeed = feedTable->next();
}
if( keys.bit.DOWN )
{
newFeed = feedTable->previous();
}

#ifdef IGNORE_ALL_KEYS_WHEN_RUNNING
}
#endif // IGNORE_ALL_KEYS_WHEN_RUNNING

// update the control panel
controlPanel->setLEDs(calculateLEDs());
controlPanel->setValue(feedTable->current()->display);
controlPanel->setRPM(currentRpm);
// if we have changed the feed
if( newFeed != NULL ) {
// update the display
LED_REG leds = this->calculateLEDs(newFeed);
controlPanel->setLEDs(leds);
controlPanel->setValue(newFeed->display);

if( ! core->isPowerOn() )
{
controlPanel->setValue(VALUE_BLANK);
// update the core
core->setFeed(newFeed);
core->setReverse(this->reverse);
}

// update the RPM display
controlPanel->setRPM(currentRpm);

// write data out to the display
controlPanel->refresh();
}
2 changes: 1 addition & 1 deletion els-f280049c/UserInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class UserInterface
Uint16 messageTime;

const FEED_THREAD *loadFeedTable();
LED_REG calculateLEDs();
LED_REG calculateLEDs(const FEED_THREAD *selectedFeed);
void setMessage(const MESSAGE *message);
void overrideMessage( void );

Expand Down

0 comments on commit f27ba92

Please sign in to comment.