SpiDisplay.h
Go to the documentation of this file.
1 /****
2  * SpiDisplay.h
3  *
4  * Copyright 2021 mikee47 <mike@sillyhouse.net>
5  *
6  * This file is part of the Sming-Graphics Library
7  *
8  * This library is free software: you can redistribute it and/or modify it under the terms of the
9  * GNU General Public License as published by the Free Software Foundation, version 3 or later.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13  * See the GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along with this library.
16  * If not, see <https://www.gnu.org/licenses/>.
17  *
18  * @author: May 2021 - mikee47 <mike@sillyhouse.net>
19  *
20  ****/
21 
22 #pragma once
23 
24 #include "Device.h"
25 #include <HSPI/Device.h>
26 #include "SpiDisplayList.h"
27 #include <Digital.h>
28 #include "AbstractDisplay.h"
29 
30 namespace Graphics
31 {
32 class SpiDisplay : protected HSPI::Device, public AbstractDisplay
33 {
34 public:
36  {
37  }
38 
39  virtual bool begin(HSPI::PinSet pinSet, uint8_t chipSelect, uint8_t resetPin = PIN_NONE,
40  uint32_t clockSpeed = 4000000);
41 
43 
44  void execute(SpiDisplayList& list, DisplayList::Callback callback = nullptr, void* param = nullptr)
45  {
46  list.prepare(callback, param);
47  list.fillRequest();
48  execute(list.request);
49  }
50 
51  void execute(const SpiDisplayList::Commands& commands, const FSTR::ObjectBase& data);
52 
53  void reset(bool state)
54  {
55  if(resetPin != PIN_NONE) {
56  digitalWrite(resetPin, !state);
57  }
58  }
59 
61  {
62  return HSPI::IoMode::SPI;
63  }
64 
66  {
67  return addrWindow;
68  }
69 
70 protected:
72 
75 };
76 
77 } // namespace Graphics
PinSet
How SPI hardware pins are connected.
Definition: Common.h:108
HSPI::Request request
The HSPI request packet used by this list.
Definition: SpiDisplayList.h:79
uint8_t resetPin
Definition: SpiDisplay.h:73
bool fillRequest()
Called from interrupt context to re-fill the SPI request packet.
Definition: SpiDisplay.h:32
Display list for hardware SPI devices.
Definition: SpiDisplayList.h:34
Used when defining data structures.
Definition: ObjectBase.hpp:32
AddressWindow addrWindow
Definition: SpiDisplay.h:74
void digitalWrite(uint16_t pin, uint8_t val)
Set a digital output.
void(*)(void *parameterData) Callback
Queued callback.
Definition: DisplayList.h:215
void prepare(Callback callback, void *param)
Definition: SpiDisplayList.h:67
Definition: Common.h:34
A physical display device.
Definition: Libraries/Graphics/src/include/Graphics/Device.h:32
void execute(SpiDisplayList &list, DisplayList::Callback callback=nullptr, void *param=nullptr)
Definition: SpiDisplay.h:44
One bit per clock, MISO stage concurrent with MISO (full-duplex)
virtual bool begin(HSPI::PinSet pinSet, uint8_t chipSelect, uint8_t resetPin=PIN_NONE, uint32_t clockSpeed=4000000)
Commonly-used display-specific command codes.
Definition: SpiDisplayList.h:43
Manage a set of bit values using enumeration.
Definition: BitSet.h:44
static constexpr uint8_t PIN_NONE
Undefined I/O pin value.
Definition: Libraries/Graphics/src/include/Graphics/Types.h:37
AddressWindow & getAddressWindow()
Definition: SpiDisplay.h:65
Manages a rectangular area of display memory with position information.
Definition: AddressWindow.h:37
SpiDisplay(HSPI::Controller &spi)
Definition: SpiDisplay.h:35
HSPI::IoModes getSupportedIoModes() const override
Return set of IO modes supported by a device implementation.
Definition: SpiDisplay.h:60
Manages access to SPI hardware.
Definition: HardwareSPI/src/include/HSPI/Controller.h:51
Definition: Virtual.h:30
void reset(bool state)
Definition: SpiDisplay.h:53
uint32_t getSpeed() const
Definition: Libraries/HardwareSPI/src/include/HSPI/Device.h:91
Definition: AbstractDisplay.h:30
Manages a specific SPI device instance attached to a controller.
Definition: Libraries/HardwareSPI/src/include/HSPI/Device.h:44
void execute(Request &request)
Definition: Libraries/HardwareSPI/src/include/HSPI/Device.h:173