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 {
35 {
36 public:
43  struct Commands {
44  uint8_t setColumn;
45  uint8_t setRow;
46  uint8_t readStart;
47  uint8_t read;
48  uint8_t writeStart;
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 
68  {
71  if(callback == nullptr) {
72  request.async = false;
73  }
74  }
75 
80 
81 protected:
83 
85  uint16_t datalen{0};
86  uint16_t repeats{0};
87  Code code{};
88  uint8_t repeatBuffer[64];
89 };
90 
91 } // namespace Graphics
Stores list of low-level display commands.
Definition: DisplayList.h:149
Code
Definition: DisplayList.h:151
void(*)(void *parameterData) Callback
Queued callback.
Definition: DisplayList.h:215
void prepare(Callback callback, void *param)
Prepare for playback.
Definition: DisplayList.h:443
Callback callback
Definition: DisplayList.h:560
void * param
Definition: DisplayList.h:561
Display list for hardware SPI devices.
Definition: SpiDisplayList.h:35
void prepare(Callback callback, void *param)
Definition: SpiDisplayList.h:67
bool fillRequest()
Called from interrupt context to re-fill the SPI request packet.
static bool staticRequestCallback(HSPI::Request &request)
bool isBusy() const
Definition: SpiDisplayList.h:56
const Commands & commands
Definition: SpiDisplayList.h:84
uint16_t repeats
How many remaining repeats for this data block.
Definition: SpiDisplayList.h:86
HSPI::Request request
The HSPI request packet used by this list.
Definition: SpiDisplayList.h:79
Code code
Command being executed.
Definition: SpiDisplayList.h:87
uint8_t repeatBuffer[64]
Buffer to fill out small repeated data chunks.
Definition: SpiDisplayList.h:88
SpiDisplayList(const Commands &commands, Params &&... params)
Definition: SpiDisplayList.h:52
uint16_t datalen
Size of data at current position.
Definition: SpiDisplayList.h:85
Definition: Virtual.h:31
Commonly-used display-specific command codes.
Definition: SpiDisplayList.h:43
uint8_t setColumn
Definition: SpiDisplayList.h:44
uint8_t read
Definition: SpiDisplayList.h:47
uint8_t readStart
Definition: SpiDisplayList.h:46
uint8_t writeStart
Definition: SpiDisplayList.h:48
uint8_t setRow
Definition: SpiDisplayList.h:45
Defines an SPI Request Packet.
Definition: HardwareSPI/src/include/HSPI/Request.h:57
uint8_t async
Set for asynchronous operation.
Definition: HardwareSPI/src/include/HSPI/Request.h:62
void setAsync(Callback callback=nullptr, void *param=nullptr)
Set request to asynchronous execution with optional callback.
Definition: HardwareSPI/src/include/HSPI/Request.h:142
volatile uint8_t busy
Request in progress.
Definition: HardwareSPI/src/include/HSPI/Request.h:64