Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Crocker <dcrocker@eschertech.com>2018-05-08 00:16:44 +0300
committerDavid Crocker <dcrocker@eschertech.com>2018-05-08 00:16:44 +0300
commit71b060436abaaecd9f67d90d6e6581e2f5c8ad90 (patch)
treec9b27dc9dbd2c1ef3e3cef8d6999890cba79afdf /src/Display/Display.cpp
parentb23e785bc7086094818c8d7d9daf9ffbd6589929 (diff)
Version 2.0RC2 provisional
Fixed bug that causes a rare hard fault if we ran out of buffers Partially implemented 12864 menu system
Diffstat (limited to 'src/Display/Display.cpp')
-rw-r--r--src/Display/Display.cpp68
1 files changed, 29 insertions, 39 deletions
diff --git a/src/Display/Display.cpp b/src/Display/Display.cpp
index 28643dc0..f88a0f92 100644
--- a/src/Display/Display.cpp
+++ b/src/Display/Display.cpp
@@ -15,65 +15,45 @@
constexpr int DefaultPulsesPerClick = -4; // values that work with displays I have are 2 and -4
extern const LcdFont font11x14;
+const LcdFont& normalFont = font11x14;
//extern const LcdFont font10x10;
-static int val = 0;
-
Display::Display()
- : lcd(LcdCSPin), encoder(EncoderPinA, EncoderPinB, EncoderPinSw), present(false)
+ : lcd(LcdCSPin), encoder(EncoderPinA, EncoderPinB, EncoderPinSw), menu(lcd), present(false), beepActive(false), updatingFirmware(false)
{
- //TODO init menus here
}
void Display::Init()
{
lcd.Init();
encoder.Init(DefaultPulsesPerClick);
+ IoPort::SetPinMode(LcdBeepPin, OUTPUT_PWM_LOW);
- //TODO display top menu here
- // For now we just print some text to test the display
lcd.SetFont(&font11x14);
-
- lcd.SetCursor(5, 5);
- lcd.SetRightMargin(128);
- lcd.print(reprap.GetPlatform().GetElectronicsString());
-
- lcd.SetCursor(20, 5);
- lcd.SetRightMargin(50);
- lcd.print(val);
-
- IoPort::SetPinMode(LcdBeepPin, OUTPUT_PWM_LOW);
- beepActive = false;
+ menu.Load("main");
}
void Display::Spin(bool full)
{
encoder.Poll();
+
if (full)
{
- // Check encoder and update display here
- // For now we just test the encoder functionality
- const int ch = encoder.GetChange();
- const bool pressed = encoder.GetButtonPress();
-
- if (ch != 0)
+ if (!updatingFirmware)
{
- val += ch;
+ // Check encoder and update display here
+ // For now we just test the encoder functionality
+ const int ch = encoder.GetChange();
+ if (ch != 0)
+ {
+ menu.EncoderAction(ch);
+ }
+ else if (encoder.GetButtonPress())
+ {
+ menu.EncoderAction(0);
+ }
+ menu.Refresh();
}
- if (pressed)
- {
- val += 100;
- }
- if (ch != 0 || pressed)
- {
- if (val < 0) val += 1000;
- if (val >= 1000) val -= 1000;
- lcd.SetCursor(20, 5);
- lcd.SetRightMargin(50);
- lcd.print(val);
- lcd.ClearToMargin();
- }
-
lcd.FlushSome();
}
@@ -85,7 +65,16 @@ void Display::Spin(bool full)
void Display::Exit()
{
- // TODO display a "shutdown" message, or turn the display off?
+ IoPort::WriteAnalog(LcdBeepPin, 0.0, 0); // stop any beep
+ if (!updatingFirmware)
+ {
+ lcd.TextInvert(false);
+ lcd.Clear();
+ lcd.SetFont(&font11x14);
+ lcd.SetCursor(20, 0);
+ lcd.print("Shutting down...");
+ }
+ lcd.FlushAll();
}
void Display::Beep(unsigned int frequency, unsigned int milliseconds)
@@ -113,6 +102,7 @@ GCodeResult Display::Configure(GCodeBuffer& gb, const StringRef& reply)
// Suspend normal operation and display an "Updating firmware" message
void Display::UpdatingFirmware()
{
+ updatingFirmware = true;
IoPort::WriteAnalog(LcdBeepPin, 0.0, 0); // stop any beep
lcd.TextInvert(false);
lcd.Clear();