Serial Wombat Arduino Library

Loading...
Searching...
No Matches
SerialWombat18ABVGA.h
Go to the documentation of this file.
1#pragma once
2
3/*
4 Copyright 2023-2024 Broadwell Consulting Inc.
5
6"Serial Wombat" is a registered trademark of Broadwell Consulting Inc. in
7 the United States. See SerialWombat.com for usage guidance.
8
9 Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15
16 The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
18
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 * OTHER DEALINGS IN THE SOFTWARE.
26*/
27
28#include <stdint.h>
29#include "SerialWombat.h"
77
78
79
80 class SerialWombat18ABVGA : public SerialWombatPin
81{
82 public:
87 SerialWombat18ABVGA(SerialWombatChip& serialWombat) :SerialWombatPin(serialWombat)
88 {
89 }
90
96 int16_t begin(uint8_t vsyncPin, uint16_t bufferIndex = 0)
97 {
98 _pin = vsyncPin;
99 _pinMode = (uint8_t)PIN_MODE_VGA;
100
101 uint8_t tx[] = { (uint8_t)SerialWombatCommands::CONFIGURE_PIN_MODE0,
102 _pin,
103 (uint8_t)_pinMode ,
104 0x55,
105 0x55,
106 SW_LE16(bufferIndex),
107 0x55
108 };
109 return _sw.sendPacket(tx);
110 }
111
112
120 int16_t writePixel(uint8_t x, uint8_t y, uint8_t color)
121 {
122 uint8_t tx[] = { (uint8_t)SerialWombatCommands::CONFIGURE_PIN_MODE1,
123 _pin,
124 (uint8_t)_pinMode ,
125 0, //Single pixel
126 x,
127 y,
128 color,
129 0x55,
130
131 };
132 return _sw.sendPacket(tx);
133 }
134
140 int16_t fillScreen(uint8_t color)
141 {
142 uint8_t tx[] = { (uint8_t)SerialWombatCommands::CONFIGURE_PIN_MODE1,
143 _pin,
144 (uint8_t)_pinMode ,
145 1, //FillScreen
146 color,
147 0x55,
148 0x55,
149 0x55
150
151 };
152 return _sw.sendPacket(tx);
153 }
154
155
165 int16_t fillRect(uint8_t x, uint8_t y, uint8_t w, uint8_t h,
166 uint8_t color)
167 {
168 uint8_t tx[] = { (uint8_t)SerialWombatCommands::CONFIGURE_PIN_MODE1,
169 _pin,
170 (uint8_t)_pinMode ,
171 2, //Fill Rect
172 x,
173 y,
174 (uint8_t)(x + w - 1),
175 (uint8_t)(y + h - 1)
176
177 };
178 if (color == 0)
179 {
180 tx[3] = 3; // Make clear rect
181 }
182 return _sw.sendPacket(tx);
183 }
184
191 int16_t setLineColor(uint8_t color, uint8_t y)
192 {
193 uint8_t tx[] = { (uint8_t)SerialWombatCommands::CONFIGURE_PIN_MODE2,
194 _pin,
195 (uint8_t)_pinMode ,
196 y,
197 y,
198 color,
199 0x55,
200 0x55
201
202 };
203 return _sw.sendPacket(tx);
204
205 }
206
213 int16_t setLineColor(uint8_t color, uint8_t start, uint8_t end)
214 {
215 uint8_t tx[] = { (uint8_t)SerialWombatCommands::CONFIGURE_PIN_MODE2,
216 _pin,
217 (uint8_t)_pinMode ,
218
219 start,
220 end,
221 color,
222 0x55,
223 0x55
224
225 };
226 return _sw.sendPacket(tx);
227
228 }
229};
SerialWombat.h
SW_LE16
#define SW_LE16(_a)
Convert a uint16_t to two bytes in little endian format for array initialization.
Definition SerialWombat.h:46
SerialWombatCommands::CONFIGURE_PIN_MODE0
@ CONFIGURE_PIN_MODE0
(200)
Definition SerialWombat.h:237
SerialWombatCommands::CONFIGURE_PIN_MODE2
@ CONFIGURE_PIN_MODE2
(202)
Definition SerialWombat.h:239
SerialWombatCommands::CONFIGURE_PIN_MODE1
@ CONFIGURE_PIN_MODE1
(201)
Definition SerialWombat.h:238
PIN_MODE_VGA
@ PIN_MODE_VGA
(31)
Definition SerialWombat.h:289
SerialWombat18ABVGA::setLineColor
int16_t setLineColor(uint8_t color, uint8_t start, uint8_t end)
Set the color of a horizontal line.
Definition SerialWombat18ABVGA.h:213
SerialWombat18ABVGA::setLineColor
int16_t setLineColor(uint8_t color, uint8_t y)
Set the color of a horizontal line.
Definition SerialWombat18ABVGA.h:191
SerialWombat18ABVGA::fillScreen
int16_t fillScreen(uint8_t color)
fill the entire screen
Definition SerialWombat18ABVGA.h:140
SerialWombat18ABVGA::fillRect
int16_t fillRect(uint8_t x, uint8_t y, uint8_t w, uint8_t h, uint8_t color)
Draw a filled rectangle on the screen.
Definition SerialWombat18ABVGA.h:165
SerialWombat18ABVGA::writePixel
int16_t writePixel(uint8_t x, uint8_t y, uint8_t color)
Write a pixel to the buffer.
Definition SerialWombat18ABVGA.h:120
SerialWombat18ABVGA::SerialWombat18ABVGA
SerialWombat18ABVGA(SerialWombatChip &serialWombat)
Constructor for the SerialWombat18ABVGA class.
Definition SerialWombat18ABVGA.h:87
SerialWombat18ABVGA::begin
int16_t begin(uint8_t vsyncPin, uint16_t bufferIndex=0)
Initalize the SerialWombat18ABVGA.
Definition SerialWombat18ABVGA.h:96
SerialWombatChip
Class for a Serial Wombat chip. Each Serial Wombat chip on a project should have its own instance.
Definition SerialWombat.h:313
SerialWombatPin::_sw
SerialWombatChip & _sw
Definition SerialWombatPin.h:214
SerialWombatPin::SerialWombatPin
SerialWombatPin(SerialWombatChip &serialWombatChip)
Instantiates a Serial Wombat Pin.
Definition SerialWombatPin.h:45
SerialWombatPin::_pin
uint8_t _pin
Definition SerialWombatPin.h:213
SerialWombatPin::_pinMode
uint8_t _pinMode
Definition SerialWombatPin.h:215