diff --git a/display.cpp b/display.cpp index f5dd8a748afd6cd323e0b9bafa43aa6b63b01c76..936b3b41f25c65486730b34a1f76ef2408e9016f 100644 --- a/display.cpp +++ b/display.cpp @@ -26,12 +26,15 @@ ***************************************************************************/ #include "display.h" +#include "misc_inst.h" #include "pthread_lock.h" #if MXGUI_SETTINGS_VERSION != 101 #error Wrong mxgui_settings.h version. You need to upgrade it. #endif +using namespace std; + namespace mxgui { // @@ -67,7 +70,7 @@ DisplayManager::DisplayManager() // class Display // -Display::Display() : isDisplayOn(true) +Display::Display() : isDisplayOn(true), font(miscFixed) { pthread_mutexattr_t temp; pthread_mutexattr_init(&temp); @@ -98,6 +101,22 @@ void Display::setBrightness(int brt) doSetBrightness(brt); } +void Display::setTextColor(pair<Color,Color> colors) +{ + Font::generatePalette(textColor,colors.first,colors.second); +} + +pair<Color,Color> Display::getTextColor() const +{ + return make_pair(textColor[3],textColor[0]); +} + +void Display::setFont(const Font& font) { this->font=font; } + +Font Display::getFont() const { return font; } + +void Display::update() {} + Display::~Display() {} } //namespace mxgui diff --git a/display.h b/display.h index 3fc2ae16603e5a3209f73c2592f04313c8ed3113..f12d90f262c5c002683076e62abb80735799fe41 100644 --- a/display.h +++ b/display.h @@ -163,10 +163,7 @@ public: */ virtual ~Display(); -private: - Display(const Display&)=delete; - Display& operator=(const Display&)=delete; - +protected: /** * Turn the display On after it has been turned Off. * Display initial state is On. @@ -305,33 +302,44 @@ private: * Set colors used for writing text * \param colors a pair with the text foreground and background colors */ - virtual void setTextColor(std::pair<Color,Color> colors)=0; + void setTextColor(std::pair<Color,Color> colors); /** * \return a pair with the foreground and background colors. * Those colors are used to draw text on screen */ - virtual std::pair<Color,Color> getTextColor() const=0; + std::pair<Color,Color> getTextColor() const; /** * Set the font used for writing text * \param font new font */ - virtual void setFont(const Font& font)=0; + void setFont(const Font& font); /** * \return the current font used to draw text */ - virtual Font getFont() const=0; + Font getFont() const; /** * Make all changes done to the display since the last call to update() - * visible. This backends does not require it, so it is empty. + * visible. Backends that require it may override this. */ - virtual void update()=0; + virtual void update(); +private: + Display(const Display&)=delete; + Display& operator=(const Display&)=delete; + pthread_mutex_t dispMutex; ///< To lock concurrent access to the display bool isDisplayOn; ///< True if display is on + +protected: + Font font; ///< Current font selected for writing text + /// textColors[0] is the background color, textColor[3] the foreground + /// while the other two are the intermediate colors for drawing antialiased + /// fonts. They remain just for compatibilty, as this screen in monochrome + Color textColor[4]; friend class DrawingContext; }; diff --git a/drivers/display_bitsboard.cpp b/drivers/display_bitsboard.cpp index 200891cccf5fad60a5f8c0f40069316ad499f7bd..d424ceb14f563e0692822260146660898164528f 100644 --- a/drivers/display_bitsboard.cpp +++ b/drivers/display_bitsboard.cpp @@ -239,22 +239,6 @@ void DisplayImpl::drawRectangle(Point a, Point b, Color c) line(Point(a.x(),b.y()),a,c); } -void DisplayImpl::setTextColor(pair<Color,Color> colors) -{ - Font::generatePalette(textColor,colors.first,colors.second); -} - -pair<Color,Color> DisplayImpl::getTextColor() const -{ - return make_pair(textColor[3],textColor[0]); -} - -void DisplayImpl::setFont(const Font& font) { this->font=font; } - -Font DisplayImpl::getFont() const { return font; } - -void DisplayImpl::update() {} - DisplayImpl::pixel_iterator DisplayImpl::begin(Point p1, Point p2, IteratorDirection d) { bool fail=false; @@ -280,8 +264,9 @@ DisplayImpl::~DisplayImpl() if(buffer) delete[] buffer; } -DisplayImpl::DisplayImpl(): buffer(0), textColor(), font(miscFixed), last() +DisplayImpl::DisplayImpl(): buffer(0), last() { + setFont(miscFixed); setTextColor(make_pair(Color(black),Color(white))); { FastInterruptDisableLock dLock; diff --git a/drivers/display_bitsboard.h b/drivers/display_bitsboard.h index 168ff71c651ec8432b0d50132e22102d71e1f315..d3c0f96e8fb7172dc07d323d36c70b84b816f02b 100644 --- a/drivers/display_bitsboard.h +++ b/drivers/display_bitsboard.h @@ -195,36 +195,6 @@ public: */ void drawRectangle(Point a, Point b, Color c) override; - /** - * Set colors used for writing text - * \param fgcolor text color - * \param bgcolor background color - */ - void setTextColor(std::pair<Color,Color> colors) override; - - /** - * \return a pair with the foreground and background colors. - * Those colors are used to draw text on screen - */ - std::pair<Color,Color> getTextColor() const override; - - /** - * Set the font used for writing text - * \param font new font - */ - void setFont(const Font& font) override; - - /** - * \return the current font used to draw text - */ - Font getFont() const override; - - /** - * Make all changes done to the display since the last call to update() - * visible. This backends does not require it, so it is empty. - */ - void update() override; - /** * Pixel iterator. A pixel iterator is an output iterator that allows to * define a window on the display and write to its pixels. @@ -419,11 +389,6 @@ private: #endif Color *buffer; ///< For scanLineBuffer - /// textColors[0] is the background color, textColor[3] the foreground - /// while the other two are the intermediate colors for drawing antialiased - /// fonts. They remain just for compatibilty, as this screen in monochrome - Color textColor[4]; - Font font; ///< Current font selected for writing text pixel_iterator last; ///< Last iterator for end of iteration check unsigned int *framebufferBitBandAlias; ///< For fast pixel_iterator }; diff --git a/drivers/display_mp3v2.cpp b/drivers/display_mp3v2.cpp index 7d992eb3dd69bba6f6f91c3e8609d0157dcf8cb1..13f04df2e75a0e8b0f55b0d45d39455a97f63eec 100644 --- a/drivers/display_mp3v2.cpp +++ b/drivers/display_mp3v2.cpp @@ -256,22 +256,6 @@ void DisplayImpl::drawRectangle(Point a, Point b, Color c) line(Point(a.x(),b.y()),a,c); } -void DisplayImpl::setTextColor(pair<Color,Color> colors) -{ - Font::generatePalette(textColor,colors.first,colors.second); -} - -pair<Color,Color> DisplayImpl::getTextColor() const -{ - return make_pair(textColor[3],textColor[0]); -} - -void DisplayImpl::setFont(const Font& font) { this->font=font; } - -Font DisplayImpl::getFont() const { return font; } - -void DisplayImpl::update() {} - DisplayImpl::pixel_iterator DisplayImpl::begin(Point p1, Point p2, IteratorDirection d) { @@ -293,7 +277,7 @@ DisplayImpl::~DisplayImpl() if(buffer) delete[] buffer; } -DisplayImpl::DisplayImpl(): buffer(0), textColor(), font(droid11) +DisplayImpl::DisplayImpl(): buffer(0) { //FIXME: This assumes xram is already initialized an so D0..D15, A0, NOE, //NWE are correctly initialized @@ -372,6 +356,7 @@ DisplayImpl::DisplayImpl(): buffer(0), textColor(), font(droid11) //Power up sequence -- end // + setFont(droid11); setTextColor(make_pair(Color(0xffff),Color(0x0000))); clear(black); } diff --git a/drivers/display_mp3v2.h b/drivers/display_mp3v2.h index 9bad9aa633b6773eedfe7ace065d9ca7e3f925c0..2c29e0df7f5a1e8af04ffb32b388bf0a80a3a87e 100644 --- a/drivers/display_mp3v2.h +++ b/drivers/display_mp3v2.h @@ -192,36 +192,6 @@ public: */ void drawRectangle(Point a, Point b, Color c) override; - /** - * Set colors used for writing text - * \param fgcolor text color - * \param bgcolor background color - */ - void setTextColor(std::pair<Color,Color> colors) override; - - /** - * \return a pair with the foreground and background colors. - * Those colors are used to draw text on screen - */ - std::pair<Color,Color> getTextColor() const override; - - /** - * Set the font used for writing text - * \param font new font - */ - void setFont(const Font& font) override; - - /** - * \return the current font used to draw text - */ - Font getFont() const override; - - /** - * Make all changes done to the display since the last call to update() - * visible. This backends does not require it, so it is empty. - */ - void update() override; - /** * Pixel iterator. A pixel iterator is an output iterator that allows to * define a window on the display and write to its pixels. @@ -519,11 +489,6 @@ private: } Color *buffer; ///< For scanLineBuffer - /// textColors[0] is the background color, textColor[3] the foreground - /// while the other two are the intermediate colors for drawing antialiased - /// fonts. - Color textColor[4]; - Font font; ///< Current font selected for writing text }; } //namespace mxgui diff --git a/drivers/display_oledboard2.cpp b/drivers/display_oledboard2.cpp index 7acceab5b288fdf329af2c2c401618c9065ffefd..10d82bad1f0ee5df6aabfd058f8e2a38e2f294a6 100644 --- a/drivers/display_oledboard2.cpp +++ b/drivers/display_oledboard2.cpp @@ -289,22 +289,6 @@ void DisplayImpl::drawRectangle(Point a, Point b, Color c) line(Point(a.x(),b.y()),a,c); } -void DisplayImpl::setTextColor(pair<Color,Color> colors) -{ - Font::generatePalette(textColor,colors.first,colors.second); -} - -pair<Color,Color> DisplayImpl::getTextColor() const -{ - return make_pair(textColor[3],textColor[0]); -} - -void DisplayImpl::setFont(const Font& font) { this->font=font; } - -Font DisplayImpl::getFont() const { return font; } - -void DisplayImpl::update() {} - DisplayImpl::pixel_iterator DisplayImpl::begin(Point p1, Point p2, IteratorDirection d) { @@ -330,7 +314,7 @@ DisplayImpl::~DisplayImpl() {} DisplayImpl::DisplayImpl() : framebuffer1(reinterpret_cast<unsigned short*>(0xd0600000)), - buffer(framebuffer1+numPixels), font(droid21) + buffer(framebuffer1+numPixels) { /* * Display refresh rate is critical, as a high rate takes up a significant @@ -499,6 +483,7 @@ DisplayImpl::DisplayImpl() sendCommand8(0x23,0x00); sendCommand8(0x26,0xa0); + setFont(droid21); setTextColor(make_pair(Color(0xffff),Color(0x0000))); clear(black); doTurnOn(); diff --git a/drivers/display_oledboard2.h b/drivers/display_oledboard2.h index 941a73c938a9255560d16d73288851a6189b2075..5e7eaa86a256570c37237727450b5a88f8323a05 100644 --- a/drivers/display_oledboard2.h +++ b/drivers/display_oledboard2.h @@ -191,36 +191,6 @@ public: * \param c color of the line */ void drawRectangle(Point a, Point b, Color c) override; - - /** - * Set colors used for writing text - * \param fgcolor text color - * \param bgcolor background color - */ - void setTextColor(std::pair<Color,Color> colors) override; - - /** - * \return a pair with the foreground and background colors. - * Those colors are used to draw text on screen - */ - std::pair<Color,Color> getTextColor() const override; - - /** - * Set the font used for writing text - * \param font new font - */ - void setFont(const Font& font) override; - - /** - * \return the current font used to draw text - */ - Font getFont() const override; - - /** - * Make all changes done to the display since the last call to update() - * visible. This backends does not require it, so it is empty. - */ - void update() override; /** * Pixel iterator. A pixel iterator is an output iterator that allows to @@ -382,11 +352,6 @@ private: */ Color * const framebuffer1; Color *buffer; ///< For scanLineBuffer - /// textColors[0] is the background color, textColor[3] the foreground - /// while the other two are the intermediate colors for drawing antialiased - /// fonts. - Color textColor[4]; - Font font; ///< Current font selected for writing text pixel_iterator last; ///< Last iterator for end of iteration check static const unsigned int bpp=sizeof(Color); ///< Bytes per pixel static const int numPixels=width*height; ///< Number of pixels of the display diff --git a/drivers/display_qt.cpp b/drivers/display_qt.cpp index f63235fa598f4705fd270f5266687043a154e6ec..beac01260e84ddb82b1976aa5c9f988c5aaa0dac 100644 --- a/drivers/display_qt.cpp +++ b/drivers/display_qt.cpp @@ -211,20 +211,6 @@ void DisplayImpl::drawRectangle(Point a, Point b, Color c) line(Point(a.x(),b.y()),a,c); } -void DisplayImpl::setTextColor(pair<Color,Color> colors) -{ - Font::generatePalette(textColor,colors.first,colors.second); -} - -pair<Color,Color> DisplayImpl::getTextColor() const -{ - return make_pair(textColor[3],textColor[0]); -} - -void DisplayImpl::setFont(const Font& font) { this->font=font; } - -Font DisplayImpl::getFont() const { return font; } - void DisplayImpl::update() { backend.getSender()->update(); @@ -254,9 +240,10 @@ DisplayImpl::~DisplayImpl() if(buffer) delete[] buffer; } -DisplayImpl::DisplayImpl(): buffer(0), textColor(), font(droid11), last(), - beginPixelCalled(false), backend(QTBackend::instance()) +DisplayImpl::DisplayImpl(): buffer(0), last(), beginPixelCalled(false), + backend(QTBackend::instance()) { + setFont(droid11); setTextColor(make_pair(Color(SIMULATOR_FGCOLOR),Color(SIMULATOR_BGCOLOR))); } diff --git a/drivers/display_qt.h b/drivers/display_qt.h index ceeba04bb1a8aa69b5f7efd7e5184afd308182a8..c679ecd9c2e39857cd18d6c294748ac749ac6f01 100644 --- a/drivers/display_qt.h +++ b/drivers/display_qt.h @@ -195,30 +195,6 @@ public: */ void drawRectangle(Point a, Point b, Color c) override; - /** - * Set colors used for writing text - * \param fgcolor text color - * \param bgcolor background color - */ - void setTextColor(std::pair<Color,Color> colors) override; - - /** - * \return a pair with the foreground and background colors. - * Those colors are used to draw text on screen - */ - std::pair<Color,Color> getTextColor() const override; - - /** - * Set the font used for writing text - * \param font new font - */ - void setFont(const Font& font) override; - - /** - * \return the current font used to draw text - */ - Font getFont() const override; - /** * Make all changes done to the display since the last call to update() * visible. This backends require it. @@ -356,11 +332,6 @@ private: static const short int height=FrameBuffer::height; Color *buffer; ///< For scanLineBuffer - /// textColors[0] is the background color, textColor[3] the foreground - /// while the other two are the intermediate colors for drawing antialiased - /// fonts. - Color textColor[4]; - Font font; ///< Current font selected for writing text pixel_iterator last; ///< Last iterator for end of iteration check QTBackend& backend; ///< Backend which contains the framebuffer bool beginPixelCalled; ///< Used to check for beginPixel calls diff --git a/drivers/display_redbull_v2.cpp b/drivers/display_redbull_v2.cpp index 796c9bad6e091a4f3ed4bad4b7d1e409697f22a0..11cc0a276c0e63ff47c3e060c85b7942b470ae41 100644 --- a/drivers/display_redbull_v2.cpp +++ b/drivers/display_redbull_v2.cpp @@ -188,22 +188,6 @@ void DisplayImpl::drawRectangle(Point a, Point b, Color c) line(Point(a.x(),b.y()),a,c); } -void DisplayImpl::setTextColor(pair<Color,Color> colors) -{ - Font::generatePalette(textColor,colors.first,colors.second); -} - -pair<Color,Color> DisplayImpl::getTextColor() const -{ - return make_pair(textColor[3],textColor[0]); -} - -void DisplayImpl::setFont(const Font& font) { this->font=font; } - -Font DisplayImpl::getFont() const { return font; } - -void DisplayImpl::update() {} - DisplayImpl::pixel_iterator DisplayImpl::begin(Point p1, Point p2, IteratorDirection d) { @@ -225,7 +209,7 @@ DisplayImpl::~DisplayImpl() if(buffer) delete[] buffer; } -DisplayImpl::DisplayImpl(): buffer(0), textColor(), font(droid11) +DisplayImpl::DisplayImpl(): buffer(0) { //LCD connection GPIO should have been initialized at @@ -305,6 +289,7 @@ DisplayImpl::DisplayImpl(): buffer(0), textColor(), font(droid11) writeReg(0x004f,0); writeReg(0x004e,0); //Fill display + setFont(droid11); setTextColor(make_pair(white, black)); clear(black); } diff --git a/drivers/display_redbull_v2.h b/drivers/display_redbull_v2.h index 45ec2afdef48a265ab725062b48c856787e39abd..cc7e2e198a3d7e5ad812670461be1e24e68bcfd8 100644 --- a/drivers/display_redbull_v2.h +++ b/drivers/display_redbull_v2.h @@ -198,36 +198,6 @@ public: */ void drawRectangle(Point a, Point b, Color c) override; - /** - * Set colors used for writing text - * \param fgcolor text color - * \param bgcolor background color - */ - void setTextColor(std::pair<Color,Color> colors) override; - - /** - * \return a pair with the foreground and background colors. - * Those colors are used to draw text on screen - */ - std::pair<Color,Color> getTextColor() const override; - - /** - * Set the font used for writing text - * \param font new font - */ - void setFont(const Font& font) override; - - /** - * \return the current font used to draw text - */ - Font getFont() const override; - - /** - * Make all changes done to the display since the last call to update() - * visible. This backends does not require it, so it is empty. - */ - void update() override; - /** * Pixel iterator. A pixel iterator is an output iterator that allows to * define a window on the display and write to its pixels. @@ -439,11 +409,6 @@ private: } Color *buffer; ///< For scanLineBuffer - /// textColors[0] is the background color, textColor[3] the foreground - /// while the other two are the intermediate colors for drawing antialiased - /// fonts. - Color textColor[4]; - Font font; ///< Current font selected for writing text }; } //namespace mxgui diff --git a/drivers/display_sony-newman.cpp b/drivers/display_sony-newman.cpp index e5247dc99dad5d90c667a356bf9ebb76a8ca841b..8622ec35b20862f08c9065ec73e01ee69324c44e 100644 --- a/drivers/display_sony-newman.cpp +++ b/drivers/display_sony-newman.cpp @@ -346,20 +346,6 @@ void DisplayImpl::drawRectangle(Point a, Point b, Color c) line(Point(a.x(),b.y()),a,c); } -void DisplayImpl::setTextColor(pair<Color,Color> colors) -{ - Font::generatePalette(textColor,colors.first,colors.second); -} - -pair<Color,Color> DisplayImpl::getTextColor() const -{ - return make_pair(textColor[3],textColor[0]); -} - -void DisplayImpl::setFont(const Font& font) { this->font=font; } - -Font DisplayImpl::getFont() const { return font; } - void DisplayImpl::update() { waitDmaCompletion(); } DisplayImpl::pixel_iterator DisplayImpl::begin(Point p1, @@ -384,9 +370,10 @@ DisplayImpl::pixel_iterator DisplayImpl::begin(Point p1, DisplayImpl::~DisplayImpl() {} -DisplayImpl::DisplayImpl(): which(0), textColor(), font(droid11) +DisplayImpl::DisplayImpl(): which(0) { doTurnOn(); + setFont(droid11); setTextColor(make_pair(Color(0xffff),Color(0x0000))); } diff --git a/drivers/display_sony-newman.h b/drivers/display_sony-newman.h index c0f5aaa310768ffe3dd161884adb2326d84458a6..79e57801229deb979ca54eb61bd8d921bc2c791c 100644 --- a/drivers/display_sony-newman.h +++ b/drivers/display_sony-newman.h @@ -215,30 +215,6 @@ public: */ void drawRectangle(Point a, Point b, Color c) override; - /** - * Set colors used for writing text - * \param fgcolor text color - * \param bgcolor background color - */ - void setTextColor(std::pair<Color,Color> colors) override; - - /** - * \return a pair with the foreground and background colors. - * Those colors are used to draw text on screen - */ - std::pair<Color,Color> getTextColor() const override; - - /** - * Set the font used for writing text - * \param font new font - */ - void setFont(const Font& font) override; - - /** - * \return the current font used to draw text - */ - Font getFont() const override; - /** * Make all changes done to the display since the last call to update() * visible. This backends does require it. @@ -357,8 +333,7 @@ private: /** * Constructor. - * Do not instantiate objects of this type directly from application code, - * use Display::instance() instead. + * Do not instantiate objects of this type directly from application code. */ DisplayImpl(); @@ -484,11 +459,6 @@ private: Color pixel; ///< Buffer of one pixel, for overlapped I/O Color buffers[2][128]; ///< Line buffers for scanline overlapped I/O int which; ///< Currently empty buffer - /// textColors[0] is the background color, textColor[3] the foreground - /// while the other two are the intermediate colors for drawing antialiased - /// fonts. - Color textColor[4]; - Font font; ///< Current font selected for writing text }; } //namespace mxgui diff --git a/drivers/display_stm3210e-eval.cpp b/drivers/display_stm3210e-eval.cpp index 97e36a201c332556917bd4c35c8447fc361b1125..6e8341b8a67b15ad4169f8636988789059fea80e 100644 --- a/drivers/display_stm3210e-eval.cpp +++ b/drivers/display_stm3210e-eval.cpp @@ -217,22 +217,6 @@ void DisplayImpl::drawRectangle(Point a, Point b, Color c) line(Point(a.x(),b.y()),a,c); } -void DisplayImpl::setTextColor(pair<Color,Color> colors) -{ - Font::generatePalette(textColor,colors.first,colors.second); -} - -std::pair<Color,Color> DisplayImpl::getTextColor() const -{ - return make_pair(textColor[3],textColor[0]); -} - -void DisplayImpl::setFont(const Font& font) { this->font=font; } - -Font DisplayImpl::getFont() const { return font; } - -void DisplayImpl::update() {} - DisplayImpl::pixel_iterator DisplayImpl::begin(Point p1, Point p2, IteratorDirection d) { @@ -254,8 +238,7 @@ DisplayImpl::~DisplayImpl() if(buffer) delete[] buffer; } -DisplayImpl::DisplayImpl(): buffer(0), displayType(UNKNOWN), textColor(), - font(droid11) +DisplayImpl::DisplayImpl(): buffer(0), displayType(UNKNOWN) { //FIXME: This assumes xram is already initialized an so D0..D15, A0, NOE, //NWE are correctly initialized @@ -305,6 +288,7 @@ DisplayImpl::DisplayImpl(): buffer(0), displayType(UNKNOWN), textColor(), break; } + setFont(droid11); setTextColor(make_pair(Color(0xffff),Color(0x0000))); clear(black); } diff --git a/drivers/display_stm3210e-eval.h b/drivers/display_stm3210e-eval.h index b0c974c855a64867339ba94e594c9e42ddbae3ea..a0359fd6e3966f8e96550010db481317f7be23ff 100644 --- a/drivers/display_stm3210e-eval.h +++ b/drivers/display_stm3210e-eval.h @@ -196,36 +196,6 @@ public: */ void drawRectangle(Point a, Point b, Color c) override; - /** - * Set colors used for writing text - * \param fgcolor text color - * \param bgcolor background color - */ - void setTextColor(std::pair<Color,Color> colors); - - /** - * \return a pair with the foreground and background colors. - * Those colors are used to draw text on screen - */ - std::pair<Color,Color> getTextColor() const override; - - /** - * Set the font used for writing text - * \param font new font - */ - void setFont(const Font& font) override; - - /** - * \return the current font used to draw text - */ - Font getFont() const override; - - /** - * Make all changes done to the display since the last call to update() - * visible. This backends does not require it, so it is empty. - */ - void update() override; - /** * Pixel iterator. A pixel iterator is an output iterator that allows to * define a window on the display and write to its pixels. @@ -534,12 +504,6 @@ private: Color *buffer; ///< For scanLineBuffer DisplayType displayType;//Contains the display controller ID - - /// textColors[0] is the background color, textColor[3] the foreground - /// while the other two are the intermediate colors for drawing antialiased - /// fonts. - Color textColor[4]; - Font font; ///< Current font selected for writing text }; } //namespace mxgui diff --git a/drivers/display_stm32f4discovery.cpp b/drivers/display_stm32f4discovery.cpp index efed3dfe19ee0e0cf3f64faf1853a80a3e5b73f3..fe75d081602d0b28efba0a328086cbca8435693d 100644 --- a/drivers/display_stm32f4discovery.cpp +++ b/drivers/display_stm32f4discovery.cpp @@ -300,22 +300,6 @@ void DisplayImpl::drawRectangle(Point a, Point b, Color c) line(Point(a.x(),b.y()),a,c); } -void DisplayImpl::setTextColor(pair<Color,Color> colors) -{ - Font::generatePalette(textColor,colors.first,colors.second); -} - -pair<Color,Color> DisplayImpl::getTextColor() const -{ - return make_pair(textColor[3],textColor[0]); -} - -void DisplayImpl::setFont(const Font& font) { this->font=font; } - -Font DisplayImpl::getFont() const { return font; } - -void DisplayImpl::update() {} - DisplayImpl::pixel_iterator DisplayImpl::begin(Point p1, Point p2, IteratorDirection d) { @@ -341,7 +325,7 @@ DisplayImpl::~DisplayImpl() {} DisplayImpl::DisplayImpl() : framebuffer1(reinterpret_cast<unsigned short*>(0xd0600000)), - buffer(framebuffer1+numPixels), font(droid11) + buffer(framebuffer1+numPixels) { { FastInterruptDisableLock dLock; @@ -483,6 +467,7 @@ DisplayImpl::DisplayImpl() | 0 //no dithering | LTDC_GCR_LTDCEN; //Display enabled + setFont(droid11); setTextColor(make_pair(Color(0xffff),Color(0x0000))); clear(black); } diff --git a/drivers/display_stm32f4discovery.h b/drivers/display_stm32f4discovery.h index 6b8bbe32dbdb235ee9eb3520cdfef46dfa3170c7..bee1d5b21d3bfb73a439b58830a7f80d635ed3ec 100644 --- a/drivers/display_stm32f4discovery.h +++ b/drivers/display_stm32f4discovery.h @@ -191,36 +191,6 @@ public: * \param c color of the line */ void drawRectangle(Point a, Point b, Color c) override; - - /** - * Set colors used for writing text - * \param fgcolor text color - * \param bgcolor background color - */ - void setTextColor(std::pair<Color,Color> colors) override; - - /** - * \return a pair with the foreground and background colors. - * Those colors are used to draw text on screen - */ - std::pair<Color,Color> getTextColor() const override; - - /** - * Set the font used for writing text - * \param font new font - */ - void setFont(const Font& font) override; - - /** - * \return the current font used to draw text - */ - Font getFont() const override; - - /** - * Make all changes done to the display since the last call to update() - * visible. This backends does not require it, so it is empty. - */ - void update() override; /** * Pixel iterator. A pixel iterator is an output iterator that allows to @@ -382,11 +352,6 @@ private: */ Color * const framebuffer1; Color *buffer; ///< For scanLineBuffer - /// textColors[0] is the background color, textColor[3] the foreground - /// while the other two are the intermediate colors for drawing antialiased - /// fonts. - Color textColor[4]; - Font font; ///< Current font selected for writing text pixel_iterator last; ///< Last iterator for end of iteration check static const unsigned int bpp=sizeof(Color); ///< Bytes per pixel static const int numPixels=width*height; ///< Number of pixels of the display diff --git a/drivers/display_strive.cpp b/drivers/display_strive.cpp index 0a9b39768630dc23024c946ff9d6e2495eea81a7..0afac75fe91b18e6cb1525b46426e7cd35f1fa00 100644 --- a/drivers/display_strive.cpp +++ b/drivers/display_strive.cpp @@ -348,22 +348,6 @@ void DisplayImpl::drawRectangle(Point a, Point b, Color c) line(Point(a.x(),b.y()),a,c); } -void DisplayImpl::setTextColor(pair<Color,Color> colors) -{ - Font::generatePalette(textColor,colors.first,colors.second); -} - -pair<Color,Color> DisplayImpl::getTextColor() const -{ - return make_pair(textColor[3],textColor[0]); -} - -void DisplayImpl::setFont(const Font& font) { this->font=font; } - -Font DisplayImpl::getFont() const { return font; } - -void DisplayImpl::update() {} - DisplayImpl::pixel_iterator DisplayImpl::begin(Point p1, Point p2, IteratorDirection d) { @@ -385,7 +369,7 @@ DisplayImpl::~DisplayImpl() if(buffer) delete[] buffer; } -DisplayImpl::DisplayImpl(): buffer(0), textColor(), font(droid11) +DisplayImpl::DisplayImpl(): buffer(0) { //LCD connection GPIO should have been initialized at @@ -493,6 +477,7 @@ DisplayImpl::DisplayImpl(): buffer(0), textColor(), font(droid11) writeReg(0x07, D0 | D1 |DTE | GON | BASEE); //Fill display + setFont(droid11); setTextColor(make_pair(white, black)); clear(black); } diff --git a/drivers/display_strive.h b/drivers/display_strive.h index 12164d7bedfd6e3f4608faceb3e792b30cbb30d5..741c3b221aea10957423bdc954de16dc486d36d0 100644 --- a/drivers/display_strive.h +++ b/drivers/display_strive.h @@ -191,36 +191,6 @@ public: * \param c color of the line */ void drawRectangle(Point a, Point b, Color c) override;; - - /** - * Set colors used for writing text - * \param fgcolor text color - * \param bgcolor background color - */ - void setTextColor(std::pair<Color,Color> colors) override; - - /** - * \return a pair with the foreground and background colors. - * Those colors are used to draw text on screen - */ - std::pair<Color,Color> getTextColor() const override; - - /** - * Set the font used for writing text - * \param font new font - */ - void setFont(const Font& font) override; - - /** - * \return the current font used to draw text - */ - Font getFont() const override; - - /** - * Make all changes done to the display since the last call to update() - * visible. This backends does not require it, so it is empty. - */ - void update() override; /** * Pixel iterator. A pixel iterator is an output iterator that allows to @@ -507,11 +477,6 @@ private: } Color *buffer; ///< For scanLineBuffer - /// textColors[0] is the background color, textColor[3] the foreground - /// while the other two are the intermediate colors for drawing antialiased - /// fonts. - Color textColor[4]; - Font font; ///< Current font selected for writing text }; } //namespace mxgui diff --git a/drivers/display_win.cpp b/drivers/display_win.cpp index 58217c31c126f1be108dc3b1aa8dcb9c3af51142..04b809ea373bd425f2fa30fa3c6512cc329b4cd5 100644 --- a/drivers/display_win.cpp +++ b/drivers/display_win.cpp @@ -214,20 +214,6 @@ void DisplayImpl::drawRectangle(Point a, Point b, Color c) line(Point(a.x(),b.y()),a,c); } -void DisplayImpl::setTextColor(pair<Color,Color> colors) -{ - Font::generatePalette(textColor,colors.first,colors.second); -} - -pair<Color,Color> DisplayImpl::getTextColor() const -{ - return make_pair(textColor[3],textColor[0]); -} - -void DisplayImpl::setFont(const Font& font) { this->font=font; } - -Font DisplayImpl::getFont() const { return font; } - void DisplayImpl::update() { beginPixelCalled=false; @@ -258,11 +244,11 @@ DisplayImpl::~DisplayImpl() DisplayImpl::DisplayImpl(): buffer(0), - font(droid11), last(), beginPixelCalled(false), backend(WinBackend::instance()) { + setFont(droid11); setTextColor(make_pair(Color(0xffff), Color(0x0000))); } diff --git a/drivers/display_win.h b/drivers/display_win.h index 5c0d0ddfb1b74dd3f6c9164ad0b03ec626dad44e..f35e5bec46c5baff97a7d02f9a74eea0a8ef484e 100644 --- a/drivers/display_win.h +++ b/drivers/display_win.h @@ -195,30 +195,6 @@ public: */ void drawRectangle(Point a, Point b, Color c) override; - /** - * Set colors used for writing text - * \param fgcolor text color - * \param bgcolor background color - */ - void setTextColor(std::pair<Color,Color> colors) override; - - /** - * \return a pair with the foreground and background colors. - * Those colors are used to draw text on screen - */ - std::pair<Color,Color> getTextColor() const override; - - /** - * Set the font used for writing text - * \param font new font - */ - void setFont(const Font& font) override; - - /** - * \return the current font used to draw text - */ - Font getFont() const override; - /** * Make all changes done to the display since the last call to update() * visible. This backends require it. @@ -356,11 +332,6 @@ private: static const short int height = SIMULATOR_DISP_HEIGHT; Color *buffer; ///< For scanLineBuffer - /// textColors[0] is the background color, textColor[3] the foreground - /// while the other two are the intermediate colors for drawing antialiased - /// fonts. - Color textColor[4]; - Font font; ///< Current font selected for writing text pixel_iterator last; ///< Last iterator for end of iteration check WinBackend& backend; ///< Backend which contains the framebuffer bool beginPixelCalled; ///< Used to check for beginPixel calls