SpiDisplayList.h
Go to the documentation of this file.
1 /****
2  * SpiDisplayList.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 "DisplayList.h"
25 #include <HSPI/Request.h>
26 
27 namespace Graphics
28 {
34 class SpiDisplayList : public DisplayList
35 {
36 public:
43  struct Commands {
47  uint8_t read;
49  };
50 
51  template <typename... Params>
52  SpiDisplayList(const Commands& commands, Params&&... params) : DisplayList(params...), commands(commands)
53  {
54  }
55 
56  bool isBusy() const
57  {
58  return request.busy;
59  }
60 
65  bool fillRequest();
66 
67  void prepare(Callback callback, void* param)
68  {
71  if(callback == nullptr) {
72  request.async = false;
73  }
74  }
75 
80 
81 protected:
83 
84  const Commands& commands;
85  uint16_t datalen{0};
86  uint16_t repeats{0};
87  Code code{};
88  uint8_t repeatBuffer[64];
89 };
90 
91 } // namespace Graphics
uint16_t datalen
Size of data at current position.
Definition: SpiDisplayList.h:123
bool isBusy() const
Definition: SpiDisplayList.h:94
void(*)(void *parameterData) Callback
Queued callback.
Definition: DisplayList.h:215
Code code
Command being executed.
Definition: SpiDisplayList.h:125
volatile uint8_t busy
Request in progress.
Definition: HardwareSPI/src/include/HSPI/Request.h:86
void * param
Definition: DisplayList.h:561
Code
Definition: DisplayList.h:151
HSPI::Request request
The HSPI request packet used by this list.
Definition: SpiDisplayList.h:117
const Commands & commands
Definition: SpiDisplayList.h:122
uint8_t repeatBuffer[64]
Buffer to fill out small repeated data chunks.
Definition: SpiDisplayList.h:126
Definition: Virtual.h:30
Defines an SPI Request Packet.
Definition: HardwareSPI/src/include/HSPI/Request.h:79
Commonly-used display-specific command codes.
Definition: SpiDisplayList.h:81
uint8_t setRow
Definition: SpiDisplayList.h:102
void prepare(Callback callback, void *param)
Definition: SpiDisplayList.h:105
Callback callback
Definition: DisplayList.h:560
uint8_t writeStart
Definition: SpiDisplayList.h:105
uint8_t readStart
Definition: SpiDisplayList.h:103
void setAsync(Callback callback=nullptr, void *param=nullptr)
Set request to asynchronous execution with optional callback.
Definition: HardwareSPI/src/include/HSPI/Request.h:164
void prepare(Callback callback, void *param)
Prepare for playback.
Definition: DisplayList.h:443
DisplayList(AddressWindow &addrWindow, size_t bufferSize)
Definition: DisplayList.h:235
uint8_t setColumn
Definition: SpiDisplayList.h:101
SpiDisplayList(const Commands &commands, Params &&... params)
Definition: SpiDisplayList.h:90
uint8_t async
Set for asynchronous operation.
Definition: HardwareSPI/src/include/HSPI/Request.h:84
uint8_t read
Definition: SpiDisplayList.h:104
static bool staticRequestCallback(HSPI::Request &request)
bool fillRequest()
Called from interrupt context to re-fill the SPI request packet.
uint16_t repeats
How many remaining repeats for this data block.
Definition: SpiDisplayList.h:124