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>2020-01-04 21:15:22 +0300
committerDavid Crocker <dcrocker@eschertech.com>2020-01-04 21:15:22 +0300
commit5bd28a1aea25e83e6e1d7a0ca50cd000e7baf1a7 (patch)
tree059d11bfc384d80c7ff07d3457e994ac50a0c07e /src/Display
parent8ded9143fa9d07dcddd525683403980c42881f1a (diff)
Conditional GCode fixes and exception specifiers
Loops are now working Added noexcept specifiers to omst of the remaining C++ source files
Diffstat (limited to 'src/Display')
-rw-r--r--src/Display/Display.cpp16
-rw-r--r--src/Display/Display.h22
-rw-r--r--src/Display/Menu.cpp48
-rw-r--r--src/Display/Menu.h56
-rw-r--r--src/Display/MenuItem.cpp82
-rw-r--r--src/Display/MenuItem.h134
-rw-r--r--src/Display/RotaryEncoder.cpp12
-rw-r--r--src/Display/RotaryEncoder.h14
-rw-r--r--src/Display/ST7920/lcd7920.cpp60
-rw-r--r--src/Display/ST7920/lcd7920.h70
10 files changed, 257 insertions, 257 deletions
diff --git a/src/Display/Display.cpp b/src/Display/Display.cpp
index ba6e16c1..e4e51b55 100644
--- a/src/Display/Display.cpp
+++ b/src/Display/Display.cpp
@@ -26,13 +26,13 @@ constexpr size_t LargeFontNumber = 1;
constexpr uint32_t NormalRefreshMillis = 250;
constexpr uint32_t FastRefreshMillis = 50;
-Display::Display()
+Display::Display() noexcept
: lcd(nullptr), menu(nullptr), encoder(nullptr), lastRefreshMillis(0),
mboxSeq(0), mboxActive(false), beepActive(false), updatingFirmware(false)
{
}
-void Display::Spin()
+void Display::Spin() noexcept
{
if (lcd != nullptr)
{
@@ -104,7 +104,7 @@ void Display::Spin()
}
}
-void Display::Exit()
+void Display::Exit() noexcept
{
if (lcd != nullptr)
{
@@ -123,7 +123,7 @@ void Display::Exit()
// NOTE: nothing enforces that this beep concludes before another is begun;
// that is, in rapid succession of commands, only the last beep issued will be heard by the user
-void Display::Beep(unsigned int frequency, unsigned int milliseconds)
+void Display::Beep(unsigned int frequency, unsigned int milliseconds) noexcept
{
if (lcd != nullptr)
{
@@ -134,17 +134,17 @@ void Display::Beep(unsigned int frequency, unsigned int milliseconds)
}
}
-void Display::SuccessBeep()
+void Display::SuccessBeep() noexcept
{
Beep(2000, 100);
}
-void Display::ErrorBeep()
+void Display::ErrorBeep() noexcept
{
Beep(500, 1000);
}
-GCodeResult Display::Configure(GCodeBuffer& gb, const StringRef& reply)
+GCodeResult Display::Configure(GCodeBuffer& gb, const StringRef& reply) noexcept
{
bool seen = false;
@@ -205,7 +205,7 @@ GCodeResult Display::Configure(GCodeBuffer& gb, const StringRef& reply)
}
// Suspend normal operation and display an "Updating firmware" message
-void Display::UpdatingFirmware()
+void Display::UpdatingFirmware() noexcept
{
updatingFirmware = true;
if (lcd != nullptr)
diff --git a/src/Display/Display.h b/src/Display/Display.h
index 7329ddd5..1fe5a0d1 100644
--- a/src/Display/Display.h
+++ b/src/Display/Display.h
@@ -20,17 +20,17 @@
class Display
{
public:
- Display();
-
- void Init() { }
- GCodeResult Configure(GCodeBuffer& gb, const StringRef& reply);
- void Spin();
- void Exit();
- void Beep(unsigned int frequency, unsigned int milliseconds);
- void SuccessBeep();
- void ErrorBeep();
- bool IsPresent() const { return lcd != nullptr; }
- void UpdatingFirmware();
+ Display() noexcept;
+
+ void Init() noexcept { }
+ GCodeResult Configure(GCodeBuffer& gb, const StringRef& reply) noexcept;
+ void Spin() noexcept;
+ void Exit() noexcept;
+ void Beep(unsigned int frequency, unsigned int milliseconds) noexcept;
+ void SuccessBeep() noexcept;
+ void ErrorBeep() noexcept;
+ bool IsPresent() const noexcept { return lcd != nullptr; }
+ void UpdatingFirmware() noexcept;
private:
Lcd7920 *lcd;
diff --git a/src/Display/Menu.cpp b/src/Display/Menu.cpp
index 05954849..5c890e80 100644
--- a/src/Display/Menu.cpp
+++ b/src/Display/Menu.cpp
@@ -81,7 +81,7 @@
const uint32_t InactivityTimeout = 20000; // inactivity timeout
const uint32_t ErrorTimeout = 6000; // how long we display an error message for
-Menu::Menu(Lcd7920& refLcd)
+Menu::Menu(Lcd7920& refLcd) noexcept
: lcd(refLcd),
timeoutValue(0), lastActionTime(0),
selectableItems(nullptr), unSelectableItems(nullptr), highlightedItem(nullptr), numNestedMenus(0),
@@ -90,7 +90,7 @@ Menu::Menu(Lcd7920& refLcd)
{
}
-void Menu::Load(const char* filename)
+void Menu::Load(const char* filename) noexcept
{
if (numNestedMenus < MaxMenuNesting)
{
@@ -101,7 +101,7 @@ void Menu::Load(const char* filename)
}
}
-void Menu::LoadFixedMenu()
+void Menu::LoadFixedMenu() noexcept
{
displayingFixedMenu = true;
numNestedMenus = 0;
@@ -139,7 +139,7 @@ void Menu::LoadFixedMenu()
}
// Display a M291 message box
-void Menu::DisplayMessageBox(const MessageBox& mbox)
+void Menu::DisplayMessageBox(const MessageBox& mbox) noexcept
{
ResetCache();
displayingMessageBox = true;
@@ -195,13 +195,13 @@ void Menu::DisplayMessageBox(const MessageBox& mbox)
}
// Clear the message box and display the menu underneath it
-void Menu::ClearMessageBox()
+void Menu::ClearMessageBox() noexcept
{
displayingMessageBox = false;
Reload();
}
-void Menu::Pop()
+void Menu::Pop() noexcept
{
// currentMargin = 0;
lcd.Clear();
@@ -210,7 +210,7 @@ void Menu::Pop()
Reload();
}
-void Menu::LoadError(const char *msg, unsigned int line)
+void Menu::LoadError(const char *msg, unsigned int line) noexcept
{
// Remove selectable items that may obscure view of the error message
ResetCache();
@@ -239,7 +239,7 @@ void Menu::LoadError(const char *msg, unsigned int line)
// Parse a line in a menu layout file returning any error message, or nullptr if there was no error.
// Leading whitespace has already been skipped.
-const char *Menu::ParseMenuLine(char * const commandWord)
+const char *Menu::ParseMenuLine(char * const commandWord) noexcept
{
errorColumn = 0;
@@ -406,7 +406,7 @@ const char *Menu::ParseMenuLine(char * const commandWord)
return nullptr;
}
-void Menu::ResetCache()
+void Menu::ResetCache() noexcept
{
highlightedItem = nullptr;
@@ -425,7 +425,7 @@ void Menu::ResetCache()
}
}
-void Menu::Reload()
+void Menu::Reload() noexcept
{
displayingFixedMenu = false;
if (numNestedMenus == 1)
@@ -492,14 +492,14 @@ void Menu::Reload()
}
}
-void Menu::AddItem(MenuItem *item, bool isSelectable)
+void Menu::AddItem(MenuItem *item, bool isSelectable) noexcept
{
item->UpdateWidthAndHeight(lcd);
MenuItem::AppendToList((isSelectable) ? &selectableItems : &unSelectableItems, item);
}
// Append a string to the string buffer and return its index
-const char *Menu::AppendString(const char *s)
+const char *Menu::AppendString(const char *s) noexcept
{
// TODO: hold a fixed reference to '\0' -- if any strings passed in are empty, return this reference
const size_t oldIndex = commandBufferIndex;
@@ -512,7 +512,7 @@ const char *Menu::AppendString(const char *s)
}
// TODO: there is no error handling if a command within a sequence cannot be accepted...
-void Menu::EncoderAction_ExecuteHelper(const char *const cmd)
+void Menu::EncoderAction_ExecuteHelper(const char *const cmd) noexcept
{
if (StringEqualsIgnoreCase(cmd, "return"))
{
@@ -532,7 +532,7 @@ void Menu::EncoderAction_ExecuteHelper(const char *const cmd)
}
}
-void Menu::EncoderActionEnterItemHelper()
+void Menu::EncoderActionEnterItemHelper() noexcept
{
if (highlightedItem != nullptr && highlightedItem->IsVisible())
{
@@ -556,7 +556,7 @@ void Menu::EncoderActionEnterItemHelper()
}
}
-void Menu::EncoderActionScrollItemHelper(int action)
+void Menu::EncoderActionScrollItemHelper(int action) noexcept
{
// Based mainly on file listing requiring we handle list of unknown length
// before moving on to the next selectable item at the Menu level, we let the
@@ -601,7 +601,7 @@ void Menu::EncoderActionScrollItemHelper(int action)
// Perform the specified encoder action
// If 'action' is zero then the button was pressed, else 'action' is the number of clicks (+ve for clockwise)
// EncoderAction is what's called in response to all wheel/button actions; a convenient place to set new timeout values
-void Menu::EncoderAction(int action)
+void Menu::EncoderAction(int action) noexcept
{
if (displayingErrorMessage)
{
@@ -645,7 +645,7 @@ void Menu::EncoderAction(int action)
}
}
-/*static*/ const char *Menu::SkipWhitespace(const char *s)
+/*static*/ const char *Menu::SkipWhitespace(const char *s) noexcept
{
while (*s == ' ' || *s == '\t')
{
@@ -654,7 +654,7 @@ void Menu::EncoderAction(int action)
return s;
}
-/*static*/ char *Menu::SkipWhitespace(char *s)
+/*static*/ char *Menu::SkipWhitespace(char *s) noexcept
{
while (*s == ' ' || *s == '\t')
{
@@ -664,7 +664,7 @@ void Menu::EncoderAction(int action)
}
// Refresh is called every Spin() of the Display under most circumstances; an appropriate place to check if timeout action needs to be taken
-void Menu::Refresh()
+void Menu::Refresh() noexcept
{
if (!MassStorage::IsDriveMounted(0))
{
@@ -684,7 +684,7 @@ void Menu::Refresh()
DrawAll();
}
-void Menu::DrawAll()
+void Menu::DrawAll() noexcept
{
// First erase any displayed items that should now be invisible
for (MenuItem *item = selectableItems; item != nullptr; item = item->GetNext())
@@ -711,7 +711,7 @@ void Menu::DrawAll()
}
// Clear any highlighting. Call Refresh() after calling this to clear it on the display.
-void Menu::ClearHighlighting()
+void Menu::ClearHighlighting() noexcept
{
highlightedItem = nullptr;
itemIsSelected = false;
@@ -719,7 +719,7 @@ void Menu::ClearHighlighting()
// Move the highlighted item forwards or backwards through the selectable items, setting it to nullptr if nothing is selectable
// On entry, n is nonzero
-void Menu::AdvanceHighlightedItem(int n)
+void Menu::AdvanceHighlightedItem(int n) noexcept
{
if (highlightedItem == nullptr)
{
@@ -756,7 +756,7 @@ void Menu::AdvanceHighlightedItem(int n)
// Find the next selectable item, or the first one if nullptr is passed in
// Note, there may be no selectable items, or there may be just one
-MenuItem *Menu::FindNextSelectableItem(MenuItem *p) const
+MenuItem *Menu::FindNextSelectableItem(MenuItem *p) const noexcept
{
if (selectableItems == nullptr)
{
@@ -782,7 +782,7 @@ MenuItem *Menu::FindNextSelectableItem(MenuItem *p) const
// Find the previous selectable item, or the last one if nullptr is passed in
// Note, there may be no selectable items, and the one we pass in may not be selectable
-MenuItem *Menu::FindPrevSelectableItem(MenuItem *p) const
+MenuItem *Menu::FindPrevSelectableItem(MenuItem *p) const noexcept
{
if (selectableItems == nullptr)
{
diff --git a/src/Display/Menu.h b/src/Display/Menu.h
index e60657f8..1efc874c 100644
--- a/src/Display/Menu.h
+++ b/src/Display/Menu.h
@@ -21,36 +21,36 @@ class MessageBox;
class Menu
{
public:
- Menu(Lcd7920& refLcd);
- void Load(const char* filename); // load a menu file
- void Pop();
- void EncoderAction(int action);
- void Refresh();
- void ClearHighlighting();
- void DisplayMessageBox(const MessageBox& mbox);
- void ClearMessageBox();
+ Menu(Lcd7920& refLcd) noexcept;
+ void Load(const char* filename) noexcept; // load a menu file
+ void Pop() noexcept;
+ void EncoderAction(int action) noexcept;
+ void Refresh() noexcept;
+ void ClearHighlighting() noexcept;
+ void DisplayMessageBox(const MessageBox& mbox) noexcept;
+ void ClearMessageBox() noexcept;
private:
- void LoadFixedMenu();
- void ResetCache();
- void Reload();
- void DrawAll();
- const char *ParseMenuLine(char * s);
- void LoadError(const char *msg, unsigned int line);
- void AddItem(MenuItem *item, bool isSelectable);
- const char *AppendString(const char *s);
-
- void EncoderActionEnterItemHelper();
- void EncoderActionScrollItemHelper(int action);
- void EncoderAction_ExecuteHelper(const char *const cmd);
-
- void AdvanceHighlightedItem(int n);
- MenuItem *FindNextSelectableItem(MenuItem *p) const;
- MenuItem *FindPrevSelectableItem(MenuItem *p) const;
-
- static const char *SkipWhitespace(const char *s);
- static char *SkipWhitespace(char *s);
- static bool CheckVisibility(MenuItem::Visibility vis);
+ void LoadFixedMenu() noexcept;
+ void ResetCache() noexcept;
+ void Reload() noexcept;
+ void DrawAll() noexcept;
+ const char *ParseMenuLine(char * s) noexcept;
+ void LoadError(const char *msg, unsigned int line) noexcept;
+ void AddItem(MenuItem *item, bool isSelectable) noexcept;
+ const char *AppendString(const char *s) noexcept;
+
+ void EncoderActionEnterItemHelper() noexcept;
+ void EncoderActionScrollItemHelper(int action) noexcept;
+ void EncoderAction_ExecuteHelper(const char *const cmd) noexcept;
+
+ void AdvanceHighlightedItem(int n) noexcept;
+ MenuItem *FindNextSelectableItem(MenuItem *p) const noexcept;
+ MenuItem *FindPrevSelectableItem(MenuItem *p) const noexcept;
+
+ static const char *SkipWhitespace(const char *s) noexcept;
+ static char *SkipWhitespace(char *s) noexcept;
+ static bool CheckVisibility(MenuItem::Visibility vis) noexcept;
static const size_t CommandBufferSize = 2500;
static const size_t MaxMenuLineLength = 120; // adjusts behaviour in Reload()
diff --git a/src/Display/MenuItem.cpp b/src/Display/MenuItem.cpp
index 0f807d13..2a28839b 100644
--- a/src/Display/MenuItem.cpp
+++ b/src/Display/MenuItem.cpp
@@ -19,12 +19,12 @@
#include "Networking/Network.h"
#include "PrintMonitor.h"
-MenuItem::MenuItem(PixelNumber r, PixelNumber c, PixelNumber w, Alignment a, FontNumber fn, Visibility vis)
+MenuItem::MenuItem(PixelNumber r, PixelNumber c, PixelNumber w, Alignment a, FontNumber fn, Visibility vis) noexcept
: row(r), column(c), width(w), height(0), align(a), fontNumber(fn), visCase(vis), itemChanged(true), highlighted(false), drawn(false), next(nullptr)
{
}
-/*static*/ void MenuItem::AppendToList(MenuItem **root, MenuItem *item)
+/*static*/ void MenuItem::AppendToList(MenuItem **root, MenuItem *item) noexcept
{
while (*root != nullptr)
{
@@ -35,7 +35,7 @@ MenuItem::MenuItem(PixelNumber r, PixelNumber c, PixelNumber w, Alignment a, Fon
}
// Print the item at the correct place with the correct alignment
-void MenuItem::PrintAligned(Lcd7920& lcd, PixelNumber tOffset, PixelNumber rightMargin)
+void MenuItem::PrintAligned(Lcd7920& lcd, PixelNumber tOffset, PixelNumber rightMargin) noexcept
{
PixelNumber colsToSkip = 0;
lcd.SetFont(fontNumber);
@@ -69,7 +69,7 @@ void MenuItem::PrintAligned(Lcd7920& lcd, PixelNumber tOffset, PixelNumber right
lcd.TextInvert(false);
}
-bool MenuItem::IsVisible() const
+bool MenuItem::IsVisible() const noexcept
{
switch (visCase)
{
@@ -89,7 +89,7 @@ bool MenuItem::IsVisible() const
}
// Erase this item if it is drawn but should not be visible
-void MenuItem::EraseIfInvisible(Lcd7920& lcd, PixelNumber tOffset)
+void MenuItem::EraseIfInvisible(Lcd7920& lcd, PixelNumber tOffset) noexcept
{
if (drawn && !IsVisible())
{
@@ -98,17 +98,17 @@ void MenuItem::EraseIfInvisible(Lcd7920& lcd, PixelNumber tOffset)
}
}
-TextMenuItem::TextMenuItem(PixelNumber r, PixelNumber c, PixelNumber w, Alignment a, FontNumber fn, Visibility vis, const char* t)
+TextMenuItem::TextMenuItem(PixelNumber r, PixelNumber c, PixelNumber w, Alignment a, FontNumber fn, Visibility vis, const char* t) noexcept
: MenuItem(r, c, w, a, fn, vis), text(t)
{
}
-void TextMenuItem::CorePrint(Lcd7920& lcd)
+void TextMenuItem::CorePrint(Lcd7920& lcd) noexcept
{
lcd.print(text);
}
-void TextMenuItem::Draw(Lcd7920& lcd, PixelNumber rightMargin, bool highlight, PixelNumber tOffset)
+void TextMenuItem::Draw(Lcd7920& lcd, PixelNumber rightMargin, bool highlight, PixelNumber tOffset) noexcept
{
// We ignore the 'highlight' parameter because text items are not selectable
if (IsVisible() && (!drawn || itemChanged))
@@ -119,7 +119,7 @@ void TextMenuItem::Draw(Lcd7920& lcd, PixelNumber rightMargin, bool highlight, P
}
}
-void TextMenuItem::UpdateWidthAndHeight(Lcd7920& lcd)
+void TextMenuItem::UpdateWidthAndHeight(Lcd7920& lcd) noexcept
{
if (width == 0)
{
@@ -141,19 +141,19 @@ void TextMenuItem::UpdateWidthAndHeight(Lcd7920& lcd)
}
}
-ButtonMenuItem::ButtonMenuItem(PixelNumber r, PixelNumber c, PixelNumber w, FontNumber fn, Visibility vis, const char* t, const char* cmd, char const* acFile)
+ButtonMenuItem::ButtonMenuItem(PixelNumber r, PixelNumber c, PixelNumber w, FontNumber fn, Visibility vis, const char* t, const char* cmd, char const* acFile) noexcept
: MenuItem(r, c, w, CentreAlign, fn, vis), text(t), command(cmd), m_acFile(acFile)
{
}
-void ButtonMenuItem::CorePrint(Lcd7920& lcd)
+void ButtonMenuItem::CorePrint(Lcd7920& lcd) noexcept
{
lcd.WriteSpaces(1); // space at start in case highlighted
lcd.print(text);
lcd.WriteSpaces(1); // space at end to allow for highlighting
}
-void ButtonMenuItem::Draw(Lcd7920& lcd, PixelNumber rightMargin, bool highlight, PixelNumber tOffset)
+void ButtonMenuItem::Draw(Lcd7920& lcd, PixelNumber rightMargin, bool highlight, PixelNumber tOffset) noexcept
{
if (IsVisible() && (itemChanged || !drawn || highlight != highlighted) && column < lcd.GetNumCols())
{
@@ -164,7 +164,7 @@ void ButtonMenuItem::Draw(Lcd7920& lcd, PixelNumber rightMargin, bool highlight,
}
}
-void ButtonMenuItem::UpdateWidthAndHeight(Lcd7920& lcd)
+void ButtonMenuItem::UpdateWidthAndHeight(Lcd7920& lcd) noexcept
{
if (width == 0)
{
@@ -183,7 +183,7 @@ void ButtonMenuItem::UpdateWidthAndHeight(Lcd7920& lcd)
}
// TODO WS1: if we overflow the command or directory string, we should probably offer a return value that tells the caller to do nothing...
-bool ButtonMenuItem::Select(const StringRef& cmd)
+bool ButtonMenuItem::Select(const StringRef& cmd) noexcept
{
const int nReplacementIndex = StringContains(command, "#0");
if (-1 != nReplacementIndex)
@@ -205,7 +205,7 @@ bool ButtonMenuItem::Select(const StringRef& cmd)
return true;
}
-PixelNumber ButtonMenuItem::GetVisibilityRowOffset(PixelNumber tCurrentOffset, PixelNumber fontHeight) const
+PixelNumber ButtonMenuItem::GetVisibilityRowOffset(PixelNumber tCurrentOffset, PixelNumber fontHeight) const noexcept
{
PixelNumber tOffsetRequest = tCurrentOffset;
@@ -224,12 +224,12 @@ PixelNumber ButtonMenuItem::GetVisibilityRowOffset(PixelNumber tCurrentOffset, P
return tOffsetRequest;
}
-ValueMenuItem::ValueMenuItem(PixelNumber r, PixelNumber c, PixelNumber w, Alignment a, FontNumber fn, Visibility vis, bool adj, unsigned int v, unsigned int d)
+ValueMenuItem::ValueMenuItem(PixelNumber r, PixelNumber c, PixelNumber w, Alignment a, FontNumber fn, Visibility vis, bool adj, unsigned int v, unsigned int d) noexcept
: MenuItem(r, c, ((w != 0) ? w : DefaultWidth), a, fn, vis), valIndex(v), currentFormat(PrintFormat::undefined), decimals(d), adjusting(AdjustMode::displaying), adjustable(adj)
{
}
-void ValueMenuItem::CorePrint(Lcd7920& lcd)
+void ValueMenuItem::CorePrint(Lcd7920& lcd) noexcept
{
if (adjustable)
{
@@ -304,7 +304,7 @@ void ValueMenuItem::CorePrint(Lcd7920& lcd)
}
}
-void ValueMenuItem::Draw(Lcd7920& lcd, PixelNumber rightMargin, bool highlight, PixelNumber tOffset)
+void ValueMenuItem::Draw(Lcd7920& lcd, PixelNumber rightMargin, bool highlight, PixelNumber tOffset) noexcept
{
if (IsVisible())
{
@@ -487,13 +487,13 @@ void ValueMenuItem::Draw(Lcd7920& lcd, PixelNumber rightMargin, bool highlight,
}
}
-bool ValueMenuItem::Select(const StringRef& cmd)
+bool ValueMenuItem::Select(const StringRef& cmd) noexcept
{
adjusting = AdjustMode::adjusting;
return false;
}
-void ValueMenuItem::UpdateWidthAndHeight(Lcd7920& lcd)
+void ValueMenuItem::UpdateWidthAndHeight(Lcd7920& lcd) noexcept
{
// The width is always set for a ValueMenuItem so we just need to determine the height
if (height == 0)
@@ -503,13 +503,13 @@ void ValueMenuItem::UpdateWidthAndHeight(Lcd7920& lcd)
}
}
-PixelNumber ValueMenuItem::GetVisibilityRowOffset(PixelNumber tCurrentOffset, PixelNumber fontHeight) const
+PixelNumber ValueMenuItem::GetVisibilityRowOffset(PixelNumber tCurrentOffset, PixelNumber fontHeight) const noexcept
{
// TODO
return 0;
}
-bool ValueMenuItem::Adjust_SelectHelper()
+bool ValueMenuItem::Adjust_SelectHelper() noexcept
{
if (adjusting == AdjustMode::adjusting)
{
@@ -587,7 +587,7 @@ bool ValueMenuItem::Adjust_SelectHelper()
return true;
}
-unsigned int ValueMenuItem::GetReferencedToolNumber() const
+unsigned int ValueMenuItem::GetReferencedToolNumber() const noexcept
{
unsigned int uToolNumber = valIndex % 100;
if (79 == uToolNumber)
@@ -600,7 +600,7 @@ unsigned int ValueMenuItem::GetReferencedToolNumber() const
// Adjust the value of this item by 'clicks' click of the encoder. 'clicks' is nonzero.
// Return true if we have finished adjusting it.
-bool ValueMenuItem::Adjust_AlterHelper(int clicks)
+bool ValueMenuItem::Adjust_AlterHelper(int clicks) noexcept
{
itemChanged = true; // we will probably change the value, so it will need to be re-displayed
const unsigned int itemNumber = GetReferencedToolNumber();
@@ -684,14 +684,14 @@ bool ValueMenuItem::Adjust_AlterHelper(int clicks)
// Adjust this element, returning true if we have finished adjustment.
// 'clicks' is the number of encoder clicks to adjust by, or 0 if the button was pushed.
-bool ValueMenuItem::Adjust(int clicks)
+bool ValueMenuItem::Adjust(int clicks) noexcept
{
return (clicks == 0) // if button has been pressed
? Adjust_SelectHelper()
: Adjust_AlterHelper(clicks);
}
-FilesMenuItem::FilesMenuItem(PixelNumber r, PixelNumber c, PixelNumber w, FontNumber fn, Visibility vis, const char *cmd, const char *dir, const char *acFile, unsigned int nf)
+FilesMenuItem::FilesMenuItem(PixelNumber r, PixelNumber c, PixelNumber w, FontNumber fn, Visibility vis, const char *cmd, const char *dir, const char *acFile, unsigned int nf) noexcept
: MenuItem(r, c, w, LeftAlign, fn, vis), numDisplayLines(nf), command(cmd), initialDirectory(dir), m_acFile(acFile),
m_uListingFirstVisibleIndex(0), m_uListingSelectedIndex(0)
{
@@ -707,13 +707,13 @@ FilesMenuItem::FilesMenuItem(PixelNumber r, PixelNumber c, PixelNumber w, FontNu
sdCardState = notStarted;
}
-void FilesMenuItem::vResetViewState()
+void FilesMenuItem::vResetViewState() noexcept
{
m_uListingSelectedIndex = 0;
m_uListingFirstVisibleIndex = 0;
}
-void FilesMenuItem::EnterDirectory()
+void FilesMenuItem::EnterDirectory() noexcept
{
vResetViewState();
@@ -734,7 +734,7 @@ void FilesMenuItem::EnterDirectory()
itemChanged = true; // force a redraw
}
-uint8_t FilesMenuItem::GetDirectoryNesting() const
+uint8_t FilesMenuItem::GetDirectoryNesting() const noexcept
{
const char *pcPathElement = currentDirectory.c_str();
uint8_t uNumSlashes = 0;
@@ -750,17 +750,17 @@ uint8_t FilesMenuItem::GetDirectoryNesting() const
return uNumSlashes;
}
-bool FilesMenuItem::bInSubdirectory() const
+bool FilesMenuItem::bInSubdirectory() const noexcept
{
return GetDirectoryNesting() > initialDirectoryNesting;
}
-unsigned int FilesMenuItem::uListingEntries() const
+unsigned int FilesMenuItem::uListingEntries() const noexcept
{
return bInSubdirectory() ? (1 + m_uHardItemsInDirectory) : m_uHardItemsInDirectory;
}
-void FilesMenuItem::Draw(Lcd7920& lcd, PixelNumber rightMargin, bool highlight, PixelNumber tOffset)
+void FilesMenuItem::Draw(Lcd7920& lcd, PixelNumber rightMargin, bool highlight, PixelNumber tOffset) noexcept
{
// The 'highlight' parameter is not used to highlight this item, but it is still used to tell whether this item is selected or not
if (!IsVisible())
@@ -823,7 +823,7 @@ void FilesMenuItem::Draw(Lcd7920& lcd, PixelNumber rightMargin, bool highlight,
}
}
-void FilesMenuItem::ListFiles(Lcd7920& lcd, PixelNumber rightMargin, bool highlight, PixelNumber tOffset)
+void FilesMenuItem::ListFiles(Lcd7920& lcd, PixelNumber rightMargin, bool highlight, PixelNumber tOffset) noexcept
{
lcd.SetFont(fontNumber);
lcd.SetRightMargin(rightMargin);
@@ -918,7 +918,7 @@ void FilesMenuItem::ListFiles(Lcd7920& lcd, PixelNumber rightMargin, bool highli
highlighted = highlight;
}
-void FilesMenuItem::Enter(bool bForwardDirection)
+void FilesMenuItem::Enter(bool bForwardDirection) noexcept
{
if (bForwardDirection || uListingEntries() == 0)
{
@@ -933,7 +933,7 @@ void FilesMenuItem::Enter(bool bForwardDirection)
itemChanged = true;
}
-int FilesMenuItem::Advance(int nCounts)
+int FilesMenuItem::Advance(int nCounts) noexcept
{
// In case of empty directory, there's nothing the control itself can do
if (uListingEntries() != 0)
@@ -981,7 +981,7 @@ int FilesMenuItem::Advance(int nCounts)
return nCounts;
}
-bool FilesMenuItem::Select(const StringRef& cmd)
+bool FilesMenuItem::Select(const StringRef& cmd) noexcept
{
// Several cases:
// TEST 1. ".." entry - call EnterDirectory(), using saved state information
@@ -1071,7 +1071,7 @@ bool FilesMenuItem::Select(const StringRef& cmd)
return false;
}
-void FilesMenuItem::UpdateWidthAndHeight(Lcd7920& lcd)
+void FilesMenuItem::UpdateWidthAndHeight(Lcd7920& lcd) noexcept
{
// The width is always set for a FilesMenuItem so we just need to determine the height
if (height == 0)
@@ -1081,7 +1081,7 @@ void FilesMenuItem::UpdateWidthAndHeight(Lcd7920& lcd)
}
}
-PixelNumber FilesMenuItem::GetVisibilityRowOffset(PixelNumber tCurrentOffset, PixelNumber fontHeight) const
+PixelNumber FilesMenuItem::GetVisibilityRowOffset(PixelNumber tCurrentOffset, PixelNumber fontHeight) const noexcept
{
// TODO
return 0;
@@ -1092,13 +1092,13 @@ PixelNumber FilesMenuItem::GetVisibilityRowOffset(PixelNumber tCurrentOffset, Pi
// Byte 0 = number of columns
// Byte 1 = number of rows
// Remaining bytes = data, 1 row at a time. If the number of columns is not a multiple of 8 then the data for each row is padded to a multiple of 8 bits.
-ImageMenuItem::ImageMenuItem(PixelNumber r, PixelNumber c, Visibility vis, const char *pFileName)
+ImageMenuItem::ImageMenuItem(PixelNumber r, PixelNumber c, Visibility vis, const char *pFileName) noexcept
: MenuItem(r, c, 0, 0, 0, vis)
{
fileName.copy(pFileName);
}
-void ImageMenuItem::Draw(Lcd7920& lcd, PixelNumber rightMargin, bool highlight, PixelNumber tOffset)
+void ImageMenuItem::Draw(Lcd7920& lcd, PixelNumber rightMargin, bool highlight, PixelNumber tOffset) noexcept
{
if (IsVisible() && (!drawn || itemChanged || highlight != highlighted))
{
@@ -1132,7 +1132,7 @@ void ImageMenuItem::Draw(Lcd7920& lcd, PixelNumber rightMargin, bool highlight,
}
}
-void ImageMenuItem::UpdateWidthAndHeight(Lcd7920& lcd)
+void ImageMenuItem::UpdateWidthAndHeight(Lcd7920& lcd) noexcept
{
if (width == 0 || height == 0)
{
diff --git a/src/Display/MenuItem.h b/src/Display/MenuItem.h
index 7bb800e1..2664ab57 100644
--- a/src/Display/MenuItem.h
+++ b/src/Display/MenuItem.h
@@ -28,58 +28,58 @@ public:
static constexpr Visibility AlwaysVisible = 0;
// Draw this element on the LCD respecting 'maxWidth' and 'highlight'
- virtual void Draw(Lcd7920& lcd, PixelNumber maxWidth, bool highlight, PixelNumber tOffset) = 0;
+ virtual void Draw(Lcd7920& lcd, PixelNumber maxWidth, bool highlight, PixelNumber tOffset) noexcept = 0;
// Select this element with a push of the encoder.
// If it returns nullptr false go into adjustment mode, if we can adjust the item.
// If it returns true, execute the command returned via the parameter.
- virtual bool Select(const StringRef& cmd) { return false; }
+ virtual bool Select(const StringRef& cmd) noexcept { return false; }
// Actions to be taken when the menu system selects this item
- virtual void Enter(bool forwardDirection) {};
+ virtual void Enter(bool forwardDirection) noexcept { };
// Actions to be taken when the menu system receives encoder counts and this item is currently selected
// TODO: may be able to merge down with Adjust()
- virtual int Advance(int nCounts) { return nCounts; }
+ virtual int Advance(int nCounts) noexcept { return nCounts; }
// Return true if we can select this element for adjustment
- virtual bool CanAdjust() { return false; }
+ virtual bool CanAdjust() const noexcept { return false; }
// Adjust this element, returning true if we have finished adjustment.
// 'clicks' is the number of encoder clicks to adjust by, or 0 if the button was pushed.
- virtual bool Adjust(int clicks) { return true; }
+ virtual bool Adjust(int clicks) noexcept { return true; }
// If the width was specified as zero, update it with the actual width. Also update the height.
- virtual void UpdateWidthAndHeight(Lcd7920& lcd) = 0;
+ virtual void UpdateWidthAndHeight(Lcd7920& lcd) noexcept = 0;
// DC: I don't know what this one is for, the person who wrote it didn't document it
- virtual PixelNumber GetVisibilityRowOffset(PixelNumber tCurrentOffset, PixelNumber fontHeight) const { return 0; }
+ virtual PixelNumber GetVisibilityRowOffset(PixelNumber tCurrentOffset, PixelNumber fontHeight) const noexcept { return 0; }
- virtual ~MenuItem() { }
+ virtual ~MenuItem() noexcept { }
- MenuItem *GetNext() const { return next; }
- FontNumber GetFontNumber() const { return fontNumber; }
- void SetChanged() { itemChanged = true; }
- bool IsVisible() const;
+ MenuItem *GetNext() const noexcept { return next; }
+ FontNumber GetFontNumber() const noexcept { return fontNumber; }
+ void SetChanged() noexcept { itemChanged = true; }
+ bool IsVisible() const noexcept;
// Erase this item if it is drawn but should not be visible
- void EraseIfInvisible(Lcd7920& lcd, PixelNumber tOffset);
+ void EraseIfInvisible(Lcd7920& lcd, PixelNumber tOffset) noexcept;
// Return the width of this item in pixels
- PixelNumber GetWidth() const { return width; }
- PixelNumber GetHeight() const { return height; }
+ PixelNumber GetWidth() const noexcept { return width; }
+ PixelNumber GetHeight() const noexcept { return height; }
- static void AppendToList(MenuItem **root, MenuItem *item);
+ static void AppendToList(MenuItem **root, MenuItem *item) noexcept;
protected:
- MenuItem(PixelNumber r, PixelNumber c, PixelNumber w, Alignment a, FontNumber fn, Visibility v);
+ MenuItem(PixelNumber r, PixelNumber c, PixelNumber w, Alignment a, FontNumber fn, Visibility v) noexcept;
// Print the item starting at the current cursor position, which may be off screen. Used to find the width and also to really print the item.
// Overridden for items that support variable alignment
- virtual void CorePrint(Lcd7920& lcd) { }
+ virtual void CorePrint(Lcd7920& lcd) noexcept { }
// Print the item at the correct place with the correct alignment
- void PrintAligned(Lcd7920& lcd, PixelNumber tOffset, PixelNumber rightMargin);
+ void PrintAligned(Lcd7920& lcd, PixelNumber tOffset, PixelNumber rightMargin) noexcept;
const PixelNumber row, column;
PixelNumber width, height;
@@ -98,15 +98,15 @@ private:
class TextMenuItem final : public MenuItem
{
public:
- void* operator new(size_t sz) { return Allocate<TextMenuItem>(); }
- void operator delete(void* p) { Release<TextMenuItem>(p); }
+ void* operator new(size_t sz) noexcept { return Allocate<TextMenuItem>(); }
+ void operator delete(void* p) noexcept { Release<TextMenuItem>(p); }
- TextMenuItem(PixelNumber r, PixelNumber c, PixelNumber w, Alignment a, FontNumber fn, Visibility vis, const char *t);
- void Draw(Lcd7920& lcd, PixelNumber maxWidth, bool highlight, PixelNumber tOffset) override;
- void UpdateWidthAndHeight(Lcd7920& lcd) override;
+ TextMenuItem(PixelNumber r, PixelNumber c, PixelNumber w, Alignment a, FontNumber fn, Visibility vis, const char *t) noexcept;
+ void Draw(Lcd7920& lcd, PixelNumber maxWidth, bool highlight, PixelNumber tOffset) noexcept override;
+ void UpdateWidthAndHeight(Lcd7920& lcd) noexcept override;
protected:
- void CorePrint(Lcd7920& lcd) override;
+ void CorePrint(Lcd7920& lcd) noexcept override;
private:
const char *text;
@@ -115,18 +115,18 @@ private:
class ButtonMenuItem final : public MenuItem
{
public:
- void* operator new(size_t sz) { return Allocate<ButtonMenuItem>(); }
- void operator delete(void* p) { Release<ButtonMenuItem>(p); }
+ void* operator new(size_t sz) noexcept { return Allocate<ButtonMenuItem>(); }
+ void operator delete(void* p) noexcept { Release<ButtonMenuItem>(p); }
- ButtonMenuItem(PixelNumber r, PixelNumber c, PixelNumber w, FontNumber fn, Visibility vis, const char *t, const char *cmd, const char *acFile);
- void Draw(Lcd7920& lcd, PixelNumber maxWidth, bool highlight, PixelNumber tOffset) override;
- void UpdateWidthAndHeight(Lcd7920& lcd) override;
- bool Select(const StringRef& cmd) override;
+ ButtonMenuItem(PixelNumber r, PixelNumber c, PixelNumber w, FontNumber fn, Visibility vis, const char *t, const char *cmd, const char *acFile) noexcept;
+ void Draw(Lcd7920& lcd, PixelNumber maxWidth, bool highlight, PixelNumber tOffset) noexcept override;
+ void UpdateWidthAndHeight(Lcd7920& lcd) noexcept override;
+ bool Select(const StringRef& cmd) noexcept override;
- PixelNumber GetVisibilityRowOffset(PixelNumber tCurrentOffset, PixelNumber fontHeight) const override;
+ PixelNumber GetVisibilityRowOffset(PixelNumber tCurrentOffset, PixelNumber fontHeight) const noexcept override;
protected:
- void CorePrint(Lcd7920& lcd) override;
+ void CorePrint(Lcd7920& lcd) noexcept override;
private:
const char *text;
@@ -137,29 +137,29 @@ private:
class ValueMenuItem final : public MenuItem
{
public:
- void* operator new(size_t sz) { return Allocate<ValueMenuItem>(); }
- void operator delete(void* p) { Release<ValueMenuItem>(p); }
+ void* operator new(size_t sz) noexcept { return Allocate<ValueMenuItem>(); }
+ void operator delete(void* p) noexcept { Release<ValueMenuItem>(p); }
- ValueMenuItem(PixelNumber r, PixelNumber c, PixelNumber w, Alignment a, FontNumber fn, Visibility vis, bool adj, unsigned int v, unsigned int d);
- void Draw(Lcd7920& lcd, PixelNumber maxWidth, bool highlight, PixelNumber tOffset) override;
- bool Select(const StringRef& cmd) override;
- bool CanAdjust() override { return true; }
- bool Adjust(int clicks) override;
- void UpdateWidthAndHeight(Lcd7920& lcd) override;
+ ValueMenuItem(PixelNumber r, PixelNumber c, PixelNumber w, Alignment a, FontNumber fn, Visibility vis, bool adj, unsigned int v, unsigned int d) noexcept;
+ void Draw(Lcd7920& lcd, PixelNumber maxWidth, bool highlight, PixelNumber tOffset) noexcept override;
+ bool Select(const StringRef& cmd) noexcept override;
+ bool CanAdjust() const noexcept override { return true; }
+ bool Adjust(int clicks) noexcept override;
+ void UpdateWidthAndHeight(Lcd7920& lcd) noexcept override;
- PixelNumber GetVisibilityRowOffset(PixelNumber tCurrentOffset, PixelNumber fontHeight) const override;
+ PixelNumber GetVisibilityRowOffset(PixelNumber tCurrentOffset, PixelNumber fontHeight) const noexcept override;
- unsigned int GetReferencedToolNumber() const;
+ unsigned int GetReferencedToolNumber() const noexcept;
protected:
- void CorePrint(Lcd7920& lcd) override;
+ void CorePrint(Lcd7920& lcd) noexcept override;
private:
enum class AdjustMode : uint8_t { displaying, adjusting, liveAdjusting };
enum class PrintFormat : uint8_t { undefined, asFloat, asUnsigned, asSigned, asPercent, asText, asIpAddress, asTime };
- bool Adjust_SelectHelper();
- bool Adjust_AlterHelper(int clicks);
+ bool Adjust_SelectHelper() noexcept;
+ bool Adjust_AlterHelper(int clicks) noexcept;
static constexpr PixelNumber DefaultWidth = 25; // default numeric field width
@@ -184,26 +184,26 @@ private:
class FilesMenuItem final : public MenuItem
{
public:
- void* operator new(size_t sz) { return Allocate<FilesMenuItem>(); }
- void operator delete(void* p) { Release<FilesMenuItem>(p); }
+ void* operator new(size_t sz) noexcept { return Allocate<FilesMenuItem>(); }
+ void operator delete(void* p) noexcept { Release<FilesMenuItem>(p); }
- FilesMenuItem(PixelNumber r, PixelNumber c, PixelNumber w, FontNumber fn, Visibility vis, const char *cmd, const char *dir, const char *acFile, unsigned int nf);
- void Draw(Lcd7920& lcd, PixelNumber rightMargin, bool highlight, PixelNumber tOffset) override;
- void Enter(bool bForwardDirection) override;
- int Advance(int nCounts) override;
- bool Select(const StringRef& cmd) override;
- void UpdateWidthAndHeight(Lcd7920& lcd) override;
+ FilesMenuItem(PixelNumber r, PixelNumber c, PixelNumber w, FontNumber fn, Visibility vis, const char *cmd, const char *dir, const char *acFile, unsigned int nf) noexcept;
+ void Draw(Lcd7920& lcd, PixelNumber rightMargin, bool highlight, PixelNumber tOffset) noexcept override;
+ void Enter(bool bForwardDirection) noexcept override;
+ int Advance(int nCounts) noexcept override;
+ bool Select(const StringRef& cmd) noexcept override;
+ void UpdateWidthAndHeight(Lcd7920& lcd) noexcept override;
- PixelNumber GetVisibilityRowOffset(PixelNumber tCurrentOffset, PixelNumber fontHeight) const override;
+ PixelNumber GetVisibilityRowOffset(PixelNumber tCurrentOffset, PixelNumber fontHeight) const noexcept override;
- void EnterDirectory();
+ void EnterDirectory() noexcept;
protected:
- void vResetViewState();
+ void vResetViewState() noexcept;
private:
- void ListFiles(Lcd7920& lcd, PixelNumber rightMargin, bool highlight, PixelNumber tOffset);
- uint8_t GetDirectoryNesting() const;
+ void ListFiles(Lcd7920& lcd, PixelNumber rightMargin, bool highlight, PixelNumber tOffset) noexcept;
+ uint8_t GetDirectoryNesting() const noexcept;
const unsigned int numDisplayLines;
@@ -214,8 +214,8 @@ private:
// Working
String<MaxFilenameLength> currentDirectory;
- bool bInSubdirectory() const;
- unsigned int uListingEntries() const;
+ bool bInSubdirectory() const noexcept;
+ unsigned int uListingEntries() const noexcept;
// Files on the file system, real count i.e. no ".." included
unsigned int m_uHardItemsInDirectory;
@@ -231,13 +231,13 @@ private:
class ImageMenuItem final : public MenuItem
{
public:
- void* operator new(size_t sz) { return Allocate<ImageMenuItem>(); }
- void operator delete(void* p) { Release<ImageMenuItem>(p); }
+ void* operator new(size_t sz) noexcept { return Allocate<ImageMenuItem>(); }
+ void operator delete(void* p) noexcept { Release<ImageMenuItem>(p); }
- ImageMenuItem(PixelNumber r, PixelNumber c, Visibility vis, const char *pFileName);
+ ImageMenuItem(PixelNumber r, PixelNumber c, Visibility vis, const char *pFileName) noexcept;
- void Draw(Lcd7920& lcd, PixelNumber rightMargin, bool highlight, PixelNumber tOffset) override;
- void UpdateWidthAndHeight(Lcd7920& lcd) override;
+ void Draw(Lcd7920& lcd, PixelNumber rightMargin, bool highlight, PixelNumber tOffset) noexcept override;
+ void UpdateWidthAndHeight(Lcd7920& lcd) noexcept override;
private:
String<MaxFilenameLength> fileName;
diff --git a/src/Display/RotaryEncoder.cpp b/src/Display/RotaryEncoder.cpp
index 69273719..90995aed 100644
--- a/src/Display/RotaryEncoder.cpp
+++ b/src/Display/RotaryEncoder.cpp
@@ -5,15 +5,15 @@
#include "Pins.h"
#include "Hardware/IoPorts.h"
-RotaryEncoder::RotaryEncoder(Pin p0, Pin p1, Pin pb)
+RotaryEncoder::RotaryEncoder(Pin p0, Pin p1, Pin pb) noexcept
: pin0(p0), pin1(p1), pinButton(pb), ppc(1), encoderChange(0), encoderState(0), newPress(false), reverseDirection(false) {}
-inline unsigned int RotaryEncoder::ReadEncoderState() const
+inline unsigned int RotaryEncoder::ReadEncoderState() const noexcept
{
return (digitalRead(pin0) ? 1u : 0u) | (digitalRead(pin1) ? 2u : 0u);
}
-void RotaryEncoder::Init(int pulsesPerClick)
+void RotaryEncoder::Init(int pulsesPerClick) noexcept
{
ppc = max<unsigned int>(abs(pulsesPerClick), 1);
reverseDirection = (pulsesPerClick < 0);
@@ -34,7 +34,7 @@ void RotaryEncoder::Init(int pulsesPerClick)
newPress = false;
}
-void RotaryEncoder::Poll()
+void RotaryEncoder::Poll() noexcept
{
// State transition table. Each entry has the following meaning:
// 0 - the encoder hasn't moved
@@ -75,7 +75,7 @@ void RotaryEncoder::Poll()
}
}
-int RotaryEncoder::GetChange()
+int RotaryEncoder::GetChange() noexcept
{
int r;
if (encoderChange >= ppc - 1)
@@ -94,7 +94,7 @@ int RotaryEncoder::GetChange()
return (reverseDirection) ? -r : r;
}
-bool RotaryEncoder::GetButtonPress()
+bool RotaryEncoder::GetButtonPress() noexcept
{
const bool ret = newPress;
newPress = false;
diff --git a/src/Display/RotaryEncoder.h b/src/Display/RotaryEncoder.h
index bbfbf30a..e3df5d4c 100644
--- a/src/Display/RotaryEncoder.h
+++ b/src/Display/RotaryEncoder.h
@@ -17,18 +17,18 @@ class RotaryEncoder
bool reverseDirection;
uint32_t whenSame;
- unsigned int ReadEncoderState() const;
+ unsigned int ReadEncoderState() const noexcept;
static constexpr uint32_t DebounceMillis = 5;
public:
- RotaryEncoder(Pin p0, Pin p1, Pin pb);
+ RotaryEncoder(Pin p0, Pin p1, Pin pb) noexcept;
- void Init(int pulsesPerClick);
- void Poll();
- int GetChange();
- bool GetButtonPress();
- int GetPulsesPerClick() const { return ppc; }
+ void Init(int pulsesPerClick) noexcept;
+ void Poll() noexcept;
+ int GetChange() noexcept;
+ bool GetButtonPress() noexcept;
+ int GetPulsesPerClick() const noexcept { return ppc; }
};
#endif
diff --git a/src/Display/ST7920/lcd7920.cpp b/src/Display/ST7920/lcd7920.cpp
index f458479a..fd66b913 100644
--- a/src/Display/ST7920/lcd7920.cpp
+++ b/src/Display/ST7920/lcd7920.cpp
@@ -29,17 +29,17 @@ constexpr unsigned int LcdCommandDelayMicros = 72 - 8; // 72us required, less 7u
constexpr unsigned int LcdDataDelayMicros = 4; // delay between sending data bytes
constexpr unsigned int LcdDisplayClearDelayMillis = 3; // 1.6ms should be enough
-inline void Lcd7920::CommandDelay()
+inline void Lcd7920::CommandDelay() noexcept
{
delayMicroseconds(LcdCommandDelayMicros);
}
-inline void Lcd7920::DataDelay()
+inline void Lcd7920::DataDelay() noexcept
{
delayMicroseconds(LcdDataDelayMicros);
}
-Lcd7920::Lcd7920(Pin csPin, const LcdFont * const fnts[], size_t nFonts)
+Lcd7920::Lcd7920(Pin csPin, const LcdFont * const fnts[], size_t nFonts) noexcept
: fonts(fnts), numFonts(nFonts), currentFontNumber(0), numContinuationBytesLeft(0), textInverted(false)
{
device.csPin = csPin;
@@ -52,12 +52,12 @@ Lcd7920::Lcd7920(Pin csPin, const LcdFont * const fnts[], size_t nFonts)
}
// Set the SPI clock frequency
-void Lcd7920::SetSpiClockFrequency(uint32_t freq)
+void Lcd7920::SetSpiClockFrequency(uint32_t freq) noexcept
{
device.clockFrequency = freq;
}
-void Lcd7920::Init()
+void Lcd7920::Init() noexcept
{
sspi_master_init(&device, 8);
numContinuationBytesLeft = 0;
@@ -102,7 +102,7 @@ void Lcd7920::Init()
currentFontNumber = 0;
}
-void Lcd7920::SetFont(size_t newFont)
+void Lcd7920::SetFont(size_t newFont) noexcept
{
if (newFont < numFonts)
{
@@ -111,13 +111,13 @@ void Lcd7920::SetFont(size_t newFont)
}
// Get the current font height
-PixelNumber Lcd7920::GetFontHeight() const
+PixelNumber Lcd7920::GetFontHeight() const noexcept
{
return fonts[currentFontNumber]->height;
}
// Get the height of a specified font
-PixelNumber Lcd7920::GetFontHeight(size_t fontNumber) const
+PixelNumber Lcd7920::GetFontHeight(size_t fontNumber) const noexcept
{
if (fontNumber >= numFonts)
{
@@ -128,7 +128,7 @@ PixelNumber Lcd7920::GetFontHeight(size_t fontNumber) const
// Flag a pixel as dirty. The r and c parameters must be no greater than NumRows-1 and NumCols-1 respectively.
// Only one pixel in each 16-bit word needs to be flagged dirty for the whole word to get refreshed.
-void Lcd7920::SetDirty(PixelNumber r, PixelNumber c)
+void Lcd7920::SetDirty(PixelNumber r, PixelNumber c) noexcept
{
// if (r >= NumRows) { debugPrintf("r=%u\n", r); return; }
// if (c >= NumCols) { debugPrintf("c=%u\n", c); return; }
@@ -141,7 +141,7 @@ void Lcd7920::SetDirty(PixelNumber r, PixelNumber c)
// Write a UTF8 byte.
// If textYpos is off the end of the display, then don't write anything, just update textXpos and lastCharColData
-size_t Lcd7920::write(uint8_t c)
+size_t Lcd7920::write(uint8_t c) noexcept
{
if (numContinuationBytesLeft == 0)
{
@@ -205,7 +205,7 @@ size_t Lcd7920::write(uint8_t c)
}
}
-size_t Lcd7920::writeNative(uint16_t ch)
+size_t Lcd7920::writeNative(uint16_t ch) noexcept
{
const LcdFont * const currentFont = fonts[currentFontNumber];
if (ch == '\n')
@@ -318,7 +318,7 @@ size_t Lcd7920::writeNative(uint16_t ch)
}
// Write a space
-void Lcd7920::WriteSpaces(PixelNumber numPixels)
+void Lcd7920::WriteSpaces(PixelNumber numPixels) noexcept
{
const LcdFont * const currentFont = fonts[currentFontNumber];
uint8_t ySize = currentFont->height;
@@ -358,19 +358,19 @@ void Lcd7920::WriteSpaces(PixelNumber numPixels)
}
// Set the left margin. This is where the cursor goes to when we print newline.
-void Lcd7920::SetLeftMargin(PixelNumber c)
+void Lcd7920::SetLeftMargin(PixelNumber c) noexcept
{
leftMargin = min<uint8_t>(c, NumCols);
}
// Set the right margin. In graphics mode, anything written will be truncated at the right margin. Defaults to the right hand edge of the display.
-void Lcd7920::SetRightMargin(PixelNumber r)
+void Lcd7920::SetRightMargin(PixelNumber r) noexcept
{
rightMargin = min<uint8_t>(r, NumCols);
}
// Clear a rectangle from the current position to the right margin. The height of the rectangle is the height of the current font.
-void Lcd7920::ClearToMargin()
+void Lcd7920::ClearToMargin() noexcept
{
const uint8_t fontHeight = fonts[currentFontNumber]->height;
while (column < rightMargin)
@@ -404,7 +404,7 @@ void Lcd7920::ClearToMargin()
}
// Select normal or inverted text
-void Lcd7920::TextInvert(bool b)
+void Lcd7920::TextInvert(bool b) noexcept
{
if (b != textInverted)
{
@@ -417,7 +417,7 @@ void Lcd7920::TextInvert(bool b)
}
// Clear a rectangular block of pixels starting at rows, scol ending just before erow, ecol
-void Lcd7920::Clear(PixelNumber sRow, PixelNumber sCol, PixelNumber eRow, PixelNumber eCol)
+void Lcd7920::Clear(PixelNumber sRow, PixelNumber sCol, PixelNumber eRow, PixelNumber eCol) noexcept
{
if (eCol > NumCols) { eCol = NumCols; }
if (eRow > NumRows) { eRow = NumRows; }
@@ -461,7 +461,7 @@ void Lcd7920::Clear(PixelNumber sRow, PixelNumber sCol, PixelNumber eRow, PixelN
}
// Draw a line using the Bresenham Algorithm (thanks Wikipedia)
-void Lcd7920::Line(PixelNumber y0, PixelNumber x0, PixelNumber y1, PixelNumber x1, PixelMode mode)
+void Lcd7920::Line(PixelNumber y0, PixelNumber x0, PixelNumber y1, PixelNumber x1, PixelMode mode) noexcept
{
int dx = (x1 >= x0) ? x1 - x0 : x0 - x1;
int dy = (y1 >= y0) ? y1 - y0 : y0 - y1;
@@ -491,7 +491,7 @@ void Lcd7920::Line(PixelNumber y0, PixelNumber x0, PixelNumber y1, PixelNumber x
}
// Draw a circle using the Bresenham Algorithm (thanks Wikipedia)
-void Lcd7920::Circle(PixelNumber x0, PixelNumber y0, PixelNumber radius, PixelMode mode)
+void Lcd7920::Circle(PixelNumber x0, PixelNumber y0, PixelNumber radius, PixelMode mode) noexcept
{
int f = 1 - (int)radius;
int ddF_x = 1;
@@ -530,7 +530,7 @@ void Lcd7920::Circle(PixelNumber x0, PixelNumber y0, PixelNumber radius, PixelMo
}
// Draw a bitmap. x0 and numCols must be divisible by 8.
-void Lcd7920::Bitmap(PixelNumber x0, PixelNumber y0, PixelNumber width, PixelNumber height, const uint8_t data[])
+void Lcd7920::Bitmap(PixelNumber x0, PixelNumber y0, PixelNumber width, PixelNumber height, const uint8_t data[]) noexcept
{
for (PixelNumber r = 0; r < height && r + y0 < NumRows; ++r)
{
@@ -550,7 +550,7 @@ void Lcd7920::Bitmap(PixelNumber x0, PixelNumber y0, PixelNumber width, PixelNum
}
// Draw a single bitmap row. 'left' and 'width' do not need to be divisible by 8.
-void Lcd7920::BitmapRow(PixelNumber top, PixelNumber left, PixelNumber width, const uint8_t data[], bool invert)
+void Lcd7920::BitmapRow(PixelNumber top, PixelNumber left, PixelNumber width, const uint8_t data[], bool invert) noexcept
{
if (width != 0) // avoid possible arithmetic underflow
{
@@ -592,7 +592,7 @@ void Lcd7920::BitmapRow(PixelNumber top, PixelNumber left, PixelNumber width, co
}
// Flush all of the dirty part of the image to the lcd. Only called during startup and shutdown.
-void Lcd7920::FlushAll()
+void Lcd7920::FlushAll() noexcept
{
while (FlushSome())
{
@@ -601,7 +601,7 @@ void Lcd7920::FlushAll()
}
// Flush some of the dirty part of the image to the LCD, returning true if there is more to do
-bool Lcd7920::FlushSome()
+bool Lcd7920::FlushSome() noexcept
{
// See if there is anything to flush
if (endCol > startCol && endRow > startRow)
@@ -654,7 +654,7 @@ bool Lcd7920::FlushSome()
}
// Set the cursor position
-void Lcd7920::SetCursor(PixelNumber r, PixelNumber c)
+void Lcd7920::SetCursor(PixelNumber r, PixelNumber c) noexcept
{
row = r;
column = c;
@@ -662,7 +662,7 @@ void Lcd7920::SetCursor(PixelNumber r, PixelNumber c)
justSetCursor = true;
}
-void Lcd7920::SetPixel(PixelNumber y, PixelNumber x, PixelMode mode)
+void Lcd7920::SetPixel(PixelNumber y, PixelNumber x, PixelMode mode) noexcept
{
if (y < NumRows && x < rightMargin)
{
@@ -694,7 +694,7 @@ void Lcd7920::SetPixel(PixelNumber y, PixelNumber x, PixelMode mode)
}
}
-bool Lcd7920::ReadPixel(PixelNumber x, PixelNumber y) const
+bool Lcd7920::ReadPixel(PixelNumber x, PixelNumber y) const noexcept
{
if (y < NumRows && x < NumCols)
{
@@ -705,7 +705,7 @@ bool Lcd7920::ReadPixel(PixelNumber x, PixelNumber y) const
}
// Set the address to write to. The column address is in 16-bit words, so it ranges from 0 to 7.
-void Lcd7920::setGraphicsAddress(unsigned int r, unsigned int c)
+void Lcd7920::setGraphicsAddress(unsigned int r, unsigned int c) noexcept
{
sendLcdCommand(LcdSetGdramAddress | (r & 31));
//commandDelay(); // don't seem to need this one
@@ -714,20 +714,20 @@ void Lcd7920::setGraphicsAddress(unsigned int r, unsigned int c)
}
// Send a command to the LCD. The SPI mutex is already owned
-void Lcd7920::sendLcdCommand(uint8_t command)
+void Lcd7920::sendLcdCommand(uint8_t command) noexcept
{
sendLcd(0xF8, command);
}
// Send a data byte to the LCD. The SPI mutex is already owned
-void Lcd7920::sendLcdData(uint8_t data)
+void Lcd7920::sendLcdData(uint8_t data) noexcept
{
sendLcd(0xFA, data);
}
// Send a command to the lcd. Data1 is sent as-is, data2 is split into 2 bytes, high nibble first.
// The SPI mutex is already owned
-void Lcd7920::sendLcd(uint8_t data1, uint8_t data2)
+void Lcd7920::sendLcd(uint8_t data1, uint8_t data2) noexcept
{
uint8_t data[3];
data[0] = data1;
diff --git a/src/Display/ST7920/lcd7920.h b/src/Display/ST7920/lcd7920.h
index e19f3517..17e88f1f 100644
--- a/src/Display/ST7920/lcd7920.h
+++ b/src/Display/ST7920/lcd7920.h
@@ -38,93 +38,93 @@ class Lcd7920 : public Print
{
public:
// Construct a GLCD driver.
- Lcd7920(Pin csPin, const LcdFont * const fnts[], size_t nFonts);
+ Lcd7920(Pin csPin, const LcdFont * const fnts[], size_t nFonts) noexcept;
- constexpr PixelNumber GetNumRows() const { return NumRows; }
- constexpr PixelNumber GetNumCols() const { return NumCols; }
+ constexpr PixelNumber GetNumRows() const noexcept { return NumRows; }
+ constexpr PixelNumber GetNumCols() const noexcept { return NumCols; }
// Set the SPI clock frequency
- void SetSpiClockFrequency(uint32_t freq);
+ void SetSpiClockFrequency(uint32_t freq) noexcept;
// Write a single character in the current font. Called by the 'print' functions.
// c = character to write
// Returns the number of characters written (1 if we wrote it, 0 otherwise)
- virtual size_t write(uint8_t c); // write a character
+ virtual size_t write(uint8_t c) noexcept; // write a character
// Write a space
- void WriteSpaces(PixelNumber numPixels);
+ void WriteSpaces(PixelNumber numPixels) noexcept;
// Initialize the display. Call this in setup(). Also call setFont to select initial text font.
- void Init();
+ void Init() noexcept;
// Return the number of fonts
- size_t GetNumFonts() const { return numFonts; }
+ size_t GetNumFonts() const noexcept { return numFonts; }
// Select the font to use for subsequent calls to write() in graphics mode
- void SetFont(size_t newFont);
+ void SetFont(size_t newFont) noexcept;
// Get the current font height
- PixelNumber GetFontHeight() const;
+ PixelNumber GetFontHeight() const noexcept;
// Get the height of a specified font
- PixelNumber GetFontHeight(size_t fontNumber) const;
+ PixelNumber GetFontHeight(size_t fontNumber) const noexcept;
// Select normal or inverted text (only works in graphics mode)
- void TextInvert(bool b);
+ void TextInvert(bool b) noexcept;
// Clear the display and select non-inverted text.
- void Clear(PixelNumber top = 0, PixelNumber left = 0, PixelNumber bottom = NumRows, PixelNumber right = NumCols);
+ void Clear(PixelNumber top = 0, PixelNumber left = 0, PixelNumber bottom = NumRows, PixelNumber right = NumCols) noexcept;
// Set the cursor position
// r = row, the number of pixels from the top of the display to the top of the character.
// c = column, is the number of pixels from the left hand edge of the display and the left hand edge of the character.
- void SetCursor(PixelNumber r, PixelNumber c);
+ void SetCursor(PixelNumber r, PixelNumber c) noexcept;
// Get the cursor row. Useful after we have written some text.
- PixelNumber GetRow() const { return row; }
+ PixelNumber GetRow() const noexcept { return row; }
// Get the cursor column. Useful after we have written some text.
- PixelNumber GetColumn() const { return column; }
+ PixelNumber GetColumn() const noexcept { return column; }
// Set the left margin. This is where the cursor goes to when we print newline.
- void SetLeftMargin(PixelNumber c);
+ void SetLeftMargin(PixelNumber c) noexcept;
// Set the right margin. In graphics mode, anything written will be truncated at the right margin. Defaults to the right hand edge of the display.
- void SetRightMargin(PixelNumber r);
+ void SetRightMargin(PixelNumber r) noexcept;
// Clear a rectangle from the current position to the right margin (graphics mode only). The height of the rectangle is the height of the current font.
- void ClearToMargin();
+ void ClearToMargin() noexcept;
// Flush the display buffer to the display. Data will not be committed to the display until this is called.
- void FlushAll();
+ void FlushAll() noexcept;
// Flush just some data, returning true if this needs to be called again
- bool FlushSome();
+ bool FlushSome() noexcept;
// Set, clear or invert a pixel
// x = x-coordinate of the pixel, measured from left hand edge of the display
// y = y-coordinate of the pixel, measured down from the top of the display
// mode = whether we want to set, clear or invert the pixel
- void SetPixel(PixelNumber y, PixelNumber x, PixelMode mode);
+ void SetPixel(PixelNumber y, PixelNumber x, PixelMode mode) noexcept;
// Read a pixel. Returns true if the pixel is set, false if it is clear.
// x = x-coordinate of the pixel, measured from left hand edge of the display
// y = y-coordinate of the pixel, measured down from the top of the display
- bool ReadPixel(PixelNumber y, PixelNumber x) const;
+ bool ReadPixel(PixelNumber y, PixelNumber x) const noexcept;
// Draw a line.
// x0 = x-coordinate of one end of the line, measured from left hand edge of the display
// y0 = y-coordinate of one end of the line, measured down from the top of the display
// x1, y1 = coordinates of the other end od the line
// mode = whether we want to set, clear or invert each pixel
- void Line(PixelNumber top, PixelNumber left, PixelNumber bottom, PixelNumber right, PixelMode mode);
+ void Line(PixelNumber top, PixelNumber left, PixelNumber bottom, PixelNumber right, PixelMode mode) noexcept;
// Draw a circle
// x0 = x-coordinate of the centre, measured from left hand edge of the display
// y0 = y-coordinate of the centre, measured down from the top of the display
// radius = radius of the circle in pixels
// mode = whether we want to set, clear or invert each pixel
- void Circle(PixelNumber row, PixelNumber col, PixelNumber radius, PixelMode mode);
+ void Circle(PixelNumber row, PixelNumber col, PixelNumber radius, PixelMode mode) noexcept;
// Draw a bitmap
// x0 = x-coordinate of the top left, measured from left hand edge of the display. Currently, must be a multiple of 8.
@@ -132,14 +132,14 @@ public:
// width = width of bitmap in pixels. Currently, must be a multiple of 8.
// rows = height of bitmap in pixels
// data = bitmap image, must be ((width/8) * rows) bytes long
- void Bitmap(PixelNumber top, PixelNumber left, PixelNumber height, PixelNumber width, const uint8_t data[]);
+ void Bitmap(PixelNumber top, PixelNumber left, PixelNumber height, PixelNumber width, const uint8_t data[]) noexcept;
// Draw a bitmap row
// x0 = x-coordinate of the top left, measured from left hand edge of the display
// y0 = y-coordinate of the top left, measured down from the top of the display
// width = width of bitmap in pixels
// data = bitmap image, must be ((width + 7)/8) bytes long
- void BitmapRow(PixelNumber top, PixelNumber left, PixelNumber width, const uint8_t data[], bool invert);
+ void BitmapRow(PixelNumber top, PixelNumber left, PixelNumber width, const uint8_t data[], bool invert) noexcept;
private:
const LcdFont * const *fonts;
@@ -157,14 +157,14 @@ private:
bool textInverted;
bool justSetCursor;
- void sendLcdCommand(uint8_t command);
- void sendLcdData(uint8_t data);
- void sendLcd(uint8_t data1, uint8_t data2);
- void CommandDelay();
- void DataDelay();
- void setGraphicsAddress(unsigned int r, unsigned int c);
- size_t writeNative(uint16_t c); // write a decoded character
- void SetDirty(PixelNumber r, PixelNumber c);
+ void sendLcdCommand(uint8_t command) noexcept;
+ void sendLcdData(uint8_t data) noexcept;
+ void sendLcd(uint8_t data1, uint8_t data2) noexcept;
+ void CommandDelay() noexcept;
+ void DataDelay() noexcept;
+ void setGraphicsAddress(unsigned int r, unsigned int c) noexcept;
+ size_t writeNative(uint16_t c) noexcept; // write a decoded character
+ void SetDirty(PixelNumber r, PixelNumber c) noexcept;
};
#endif