DUDS
Distributed Update of Data from Something
ST7920.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of the DUDS project. It is subject to the BSD-style
3  * license terms in the LICENSE file found in the top-level directory of this
4  * distribution and at https://github.com/jjackowski/duds/blob/master/LICENSE.
5  * No part of DUDS, including this file, may be copied, modified, propagated,
6  * or distributed except according to the terms contained in the LICENSE file.
7  *
8  * Copyright (C) 2018 Jeff Jackowski
9  */
13 #include <chrono>
14 
15 namespace duds { namespace hardware { namespace devices { namespace displays {
16 
64  std::vector<duds::hardware::interface::DigitalPinConfig> outcfg;
70  std::chrono::high_resolution_clock::time_point soonestSend;
74  std::chrono::nanoseconds nibblePeriod;
75  enum {
79  dataMask = 0xFF,
84  textFlag = 0x100,
88  writeFlag = 0x200, // not presently supported; wire to ground
93  nibbleFlag = 0x400
94  };
103  void wait() const;
107  struct Access {
117  };
127  void preparePins(Access &acc);
140  void sendByte(Access &acc, int val);
155  void writeBlock(
156  ST7920::Access &acc,
157  const std::uint16_t *start,
158  const std::uint16_t *end,
159  int pos
160  );
166  virtual void outputFrame(const duds::ui::graphics::BppImage *img);
167 public:
171  ST7920();
213  ST7920(
216  unsigned int w,
217  unsigned int h,
218  std::chrono::nanoseconds delay = std::chrono::nanoseconds(8000)
219  );
223  virtual ~ST7920();
265  void configure(
268  unsigned int w,
269  unsigned int h,
270  std::chrono::nanoseconds delay = std::chrono::nanoseconds(8000)
271  );
284  void initialize();
293  void off();
302  void on();
303 };
304 
305 } } } }
duds::hardware::interface::DigitalPinSetAccess output
The set used for the 4 data pins and the text flag, more commonly referred to as "RS".
Definition: ST7920.hpp:112
Implements graphic output to the ST7920 LCD controller using a 4-bit parallel interface.
Definition: ST7920.hpp:42
Provides access to multiple pins on a DigitalPort.
void preparePins(Access &acc)
Obtains access to the pins and configures them for output.
Definition: ST7920.cpp:101
Unsupported display-side write flag.
Definition: ST7920.hpp:88
ST7920()
Initializes the object with an invalid display size and no pins to use.
Definition: ST7920.cpp:19
void on()
Commands the display to turn on.
Definition: ST7920.cpp:196
duds::hardware::interface::DigitalPinSet outputs
Represents the 5 output lines, other than enable, that are needed to communicate with the LCD...
Definition: ST7920.hpp:52
duds::hardware::interface::ChipAccess enable
Used to assert the enable line of the LCD.
Definition: ST7920.hpp:116
Stores access objects together.
Definition: ST7920.hpp:107
An object to wrap together a ChipSelectManager and chip ID to simplify code that needs to repeatedly ...
Definition: ChipSelect.hpp:24
std::chrono::nanoseconds nibblePeriod
The amount of time to allow the display to read data.
Definition: ST7920.hpp:74
void initialize()
Initializes the display for use.
Definition: ST7920.cpp:149
Represents a set of pins on a single DigitalPort.
Flag for sending text to the display rather than a command.
Definition: ST7920.hpp:84
An object used to provide chip select control to a single user at a time.
Definition: ChipAccess.hpp:22
Flag to send only a nibble rather than a whole byte; used in display initalization.
Definition: ST7920.hpp:93
void off()
Commands the display to turn off.
Definition: ST7920.cpp:190
virtual ~ST7920()
Calls off().
Definition: ST7920.cpp:37
virtual void outputFrame(const duds::ui::graphics::BppImage *img)
Writes out only the changed portions of the image to the display, and updates the image in frmbuf to ...
Definition: ST7920.cpp:224
std::chrono::high_resolution_clock::time_point soonestSend
The soonest time a new command can be sent to the display.
Definition: ST7920.hpp:70
void sendByte(Access &acc, int val)
Sends a byte to the display a nibble at a time.
Definition: ST7920.cpp:116
General data mask for the display.
Definition: ST7920.hpp:79
Base class for bit-per-pixel graphic displays.
void configure(duds::hardware::interface::DigitalPinSet &&outPins, duds::hardware::interface::ChipSelect &&enablePin, unsigned int w, unsigned int h, std::chrono::nanoseconds delay=std::chrono::nanoseconds(8000))
Sets the pins to use for communicating with the display.
Definition: ST7920.cpp:43
void wait() const
Waits until the time in soonestSend has passed.
Definition: ST7920.cpp:94
An image that uses a single bit to represent the state of each pixel; a black or white picture...
Definition: BppImage.hpp:321
void writeBlock(ST7920::Access &acc, const std::uint16_t *start, const std::uint16_t *end, int pos)
Writes a contiguous block of pixel data to the display after setting the next location to write...
Definition: ST7920.cpp:202
std::vector< duds::hardware::interface::DigitalPinConfig > outcfg
The best output configuration for the display bus given the port in use.
Definition: ST7920.hpp:64
duds::hardware::interface::ChipSelect enable
Used to represent the enable line of the LCD.
Definition: ST7920.hpp:60