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-10-14 21:40:13 +0300
committerDavid Crocker <dcrocker@eschertech.com>2020-10-14 21:40:13 +0300
commit9d8bd8942179f920f8f59bd921f73ffb20e3dcbb (patch)
tree9551a46854b8572e38beb7c82bb7f20f0e8e51a5 /src/Display
parent3af0163899465d64c5431fdd6a2f1c4cbaa219fb (diff)
Added direct display parameters to object model
Diffstat (limited to 'src/Display')
-rw-r--r--src/Display/Display.cpp25
-rw-r--r--src/Display/Display.h6
2 files changed, 30 insertions, 1 deletions
diff --git a/src/Display/Display.cpp b/src/Display/Display.cpp
index 28ab7dfe..aaf0778e 100644
--- a/src/Display/Display.cpp
+++ b/src/Display/Display.cpp
@@ -28,6 +28,31 @@ constexpr size_t LargeFontNumber = 1;
constexpr uint32_t NormalRefreshMillis = 250;
constexpr uint32_t FastRefreshMillis = 50;
+#if SUPPORT_OBJECT_MODEL
+
+// Object model table and functions
+// Note: if using GCC version 7.3.1 20180622 and lambda functions are used in this table, you must compile this file with option -std=gnu++17.
+// Otherwise the table will be allocated in RAM instead of flash, which wastes too much RAM.
+
+// Macro to build a standard lambda function that includes the necessary type conversions
+#define OBJECT_MODEL_FUNC(...) OBJECT_MODEL_FUNC_BODY(Display, __VA_ARGS__)
+#define OBJECT_MODEL_FUNC_IF(...) OBJECT_MODEL_FUNC_IF_BODY(Display, __VA_ARGS__)
+
+constexpr ObjectModelTableEntry Display::objectModelTable[] =
+{
+ // Within each group, these entries must be in alphabetical order
+ // 0. Display members
+ { "pulsesPerClick", OBJECT_MODEL_FUNC((int32_t)self->encoder->GetPulsesPerClick()), ObjectModelEntryFlags::none },
+ { "spiFreq", OBJECT_MODEL_FUNC((int32_t)self->lcd->GetSpiFrequency()), ObjectModelEntryFlags::none },
+ { "typeName", OBJECT_MODEL_FUNC(self->lcd->GetDisplayTypeName()), ObjectModelEntryFlags::none },
+};
+
+constexpr uint8_t Display::objectModelTableDescriptor[] = { 1, 3 };
+
+DEFINE_GET_OBJECT_MODEL_TABLE(Display)
+
+#endif
+
Display::Display() noexcept
: lcd(nullptr), menu(nullptr), encoder(nullptr), lastRefreshMillis(0),
mboxSeq(0), mboxActive(false), beepActive(false), updatingFirmware(false)
diff --git a/src/Display/Display.h b/src/Display/Display.h
index 05cf6c2e..9e2dbb6a 100644
--- a/src/Display/Display.h
+++ b/src/Display/Display.h
@@ -16,8 +16,9 @@
#include "Lcd/Lcd.h"
#include "Menu.h"
#include "GCodes/GCodeResult.h"
+#include "ObjectModel/ObjectModel.h"
-class Display
+class Display INHERIT_OBJECT_MODEL
{
public:
Display() noexcept;
@@ -35,6 +36,9 @@ public:
constexpr static uint8_t DefaultDisplayContrastRatio = 30; // this works well for the Fysetc display
constexpr static uint8_t DefaultDisplayResistorRatio = 6; // the recommended Fysetc display uses 6, some other displays use 3
+protected:
+ DECLARE_OBJECT_MODEL
+
private:
void InitDisplay(GCodeBuffer& gb, Lcd *newLcd, Pin csPin, Pin a0Pin, bool defaultCsPolarity);