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  bool begin(HSPI::PinSet pinSet, uint8_t chipSelect, uint8_t resetPin = PIN_NONE, uint32_t clockSpeed = 4000000);
40 
42 
43  void execute(SpiDisplayList& list, DisplayList::Callback callback = nullptr, void* param = nullptr)
44  {
45  list.prepare(callback, param);
46  list.fillRequest();
47  execute(list.request);
48  }
49 
50  void execute(const SpiDisplayList::Commands& commands, const FSTR::ObjectBase& data);
51 
52  void reset(bool state)
53  {
54  if(resetPin != PIN_NONE) {
55  digitalWrite(resetPin, !state);
56  }
57  }
58 
59  HSPI::IoModes getSupportedIoModes() const override
60  {
61  return HSPI::IoMode::SPI;
62  }
63 
64  AddressWindow& getAddressWindow()
65  {
66  return addrWindow;
67  }
68 
69 protected:
71 
74 };
75 
76 } // namespace Graphics
Definition: Common.h:34
void(*)(void *parameterData) Callback
Queued callback.
Definition: DisplayList.h:215
uint8_t resetPin
Definition: SpiDisplay.h:110
Manages a rectangular area of display memory with position information.
Definition: AddressWindow.h:56
@ SPI
One bit per clock, MISO stage concurrent with MISO (full-duplex)
uint32_t getSpeed() const
Definition: Libraries/HardwareSPI/src/include/HSPI/Device.h:151
void digitalWrite(uint16_t pin, uint8_t val)
Set a digital output.
Manages access to SPI hardware.
Definition: HardwareSPI/src/include/HSPI/Controller.h:71
Used when defining data structures.
Definition: ObjectBase.hpp:51
SpiDisplay(HSPI::Controller &spi)
Definition: SpiDisplay.h:73
static constexpr uint8_t PIN_NONE
Undefined I/O pin value.
Definition: Libraries/Graphics/src/include/Graphics/Types.h:56
bool begin(HSPI::PinSet pinSet, uint8_t chipSelect, uint8_t resetPin=PIN_NONE, uint32_t clockSpeed=4000000)
AddressWindow & getAddressWindow()
Definition: SpiDisplay.h:102
Definition: Virtual.h:30
Manages a specific SPI device instance attached to a controller.
Definition: Libraries/HardwareSPI/src/include/HSPI/Device.h:74
AddressWindow addrWindow
Definition: SpiDisplay.h:111
Manage a set of bit values using enumeration.
Definition: BitSet.h:44
PinSet
How SPI hardware pins are connected.
Definition: Common.h:108
HSPI::IoModes getSupportedIoModes() const override
Return set of IO modes supported by a device implementation.
Definition: SpiDisplay.h:97
void execute(Request &request)
Definition: Libraries/HardwareSPI/src/include/HSPI/Device.h:233
Device(Controller &controller)
Definition: Libraries/HardwareSPI/src/include/HSPI/Device.h:107
void execute(SpiDisplayList &list, DisplayList::Callback callback=nullptr, void *param=nullptr)
Definition: SpiDisplay.h:81
void reset(bool state)
Definition: SpiDisplay.h:90