diff options
author | David Crocker <dcrocker@eschertech.com> | 2018-02-04 22:38:29 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2018-02-04 22:38:29 +0300 |
commit | 1448121041393c9a878c3dd84ddd97dff2a4687f (patch) | |
tree | 23441e82f7705680779812bba25a953e6e5a2379 /src/Display/Display.cpp | |
parent | 7dc0079595cab16ebf1563b59c07e24b341c3efa (diff) |
Towards 1.21RC2
Refactored some string handling
Fixes for Duet 2M
Diffstat (limited to 'src/Display/Display.cpp')
-rw-r--r-- | src/Display/Display.cpp | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/src/Display/Display.cpp b/src/Display/Display.cpp index ea037c7c..aa8fcba6 100644 --- a/src/Display/Display.cpp +++ b/src/Display/Display.cpp @@ -6,6 +6,12 @@ */ #include "Display.h" +#include "GCodes/GCodes.h" + +extern const LcdFont font16x16; +//extern const LcdFont font10x10; + +static int val = 0; Display::Display() : lcd(LcdCSPin), encoder(EncoderPinA, EncoderPinB, EncoderPinSw, 4) @@ -15,7 +21,20 @@ Display::Display() void Display::Init() { - lcd.begin(); + lcd.Init(); + encoder.Init(); + + //TODO display top menu here + // For now we just print some text to test the display + lcd.SetFont(&font16x16); + + lcd.SetCursor(5, 5); + lcd.SetRightMargin(128); + lcd.print(reprap.GetPlatform().GetElectronicsString()); + + lcd.SetCursor(20, 5); + lcd.SetRightMargin(50); + lcd.print(val); } void Display::Spin(bool full) @@ -23,13 +42,36 @@ void Display::Spin(bool full) encoder.Poll(); if (full) { - lcd.Update(); + // 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) + { + val += ch; + } + 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(); } } void Display::Exit() { - // Nothing needed here except perhaps display a "shutdown" message + // TODO display a "shutdown" message, or turn the display off? } // End |