Serial Wombat Arduino Library
SerialWombat18ABVGA.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*
4 Copyright 2023 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"
82 {
83 public:
89  {
90  }
97  int16_t begin(uint8_t vsyncPin, uint16_t bufferIndex = 0)
98  {
99  _pin = vsyncPin;
100  _pinMode = (uint8_t)PIN_MODE_VGA;
101 
102  uint8_t tx[] = { (uint8_t)SerialWombatCommands::CONFIGURE_PIN_MODE0,
103  _pin,
104  (uint8_t)_pinMode ,
105  0x55,
106  0x55,
107  SW_LE16(bufferIndex),
108  0x55
109  };
110  return _sw.sendPacket(tx);
111  }
112 
113 
121  int16_t writePixel(uint8_t x, uint8_t y, uint8_t color)
122  {
123  uint8_t tx[] = { (uint8_t)SerialWombatCommands::CONFIGURE_PIN_MODE1,
124  _pin,
125  (uint8_t)_pinMode ,
126  0, //Single pixel
127  x,
128  y,
129  color,
130  0x55,
131 
132  };
133  return _sw.sendPacket(tx);
134  }
135 
141  int16_t fillScreen(uint8_t color)
142  {
143  uint8_t tx[] = { (uint8_t)SerialWombatCommands::CONFIGURE_PIN_MODE1,
144  _pin,
145  (uint8_t)_pinMode ,
146  1, //FillScreen
147  color,
148  0x55,
149  0x55,
150  0x55
151 
152  };
153  return _sw.sendPacket(tx);
154  }
155 
156 
166  int16_t fillRect(uint8_t x, uint8_t y, uint8_t w, uint8_t h,
167  uint8_t color)
168  {
169  uint8_t tx[] = { (uint8_t)SerialWombatCommands::CONFIGURE_PIN_MODE1,
170  _pin,
171  (uint8_t)_pinMode ,
172  2, //Fill Rect
173  x,
174  y,
175  (uint8_t)(x + w - 1),
176  (uint8_t)(y + h - 1)
177 
178  };
179  if (color == 0)
180  {
181  tx[3] = 3; // Make clear rect
182  }
183  return _sw.sendPacket(tx);
184  }
185 
192  int16_t setLineColor(uint8_t color, uint8_t y)
193  {
194  uint8_t tx[] = { (uint8_t)SerialWombatCommands::CONFIGURE_PIN_MODE2,
195  _pin,
196  (uint8_t)_pinMode ,
197  y,
198  y,
199  color,
200  0x55,
201  0x55
202 
203  };
204  return _sw.sendPacket(tx);
205 
206  }
214  int16_t setLineColor(uint8_t color, uint8_t start, uint8_t end)
215  {
216  uint8_t tx[] = { (uint8_t)SerialWombatCommands::CONFIGURE_PIN_MODE2,
217  _pin,
218  (uint8_t)_pinMode ,
219 
220  start,
221  end,
222  color,
223  0x55,
224  0x55
225 
226  };
227  return _sw.sendPacket(tx);
228 
229  }
230 };
SerialWombatChip
Class for a Serial Wombat chip. Each Serial Wombat chip on a project should have its own instance.
Definition: SerialWombat.h:283
SerialWombat18ABVGA::setLineColor
int16_t setLineColor(uint8_t color, uint8_t start, uint8_t end)
Set the color of a horizontal line.
Definition: SerialWombat18ABVGA.h:214
SerialWombatCommands::CONFIGURE_PIN_MODE0
@ CONFIGURE_PIN_MODE0
(200)
SerialWombatPin::_sw
SerialWombatChip & _sw
Definition: SerialWombatPin.h:134
SerialWombat18ABVGA::writePixel
int16_t writePixel(uint8_t x, uint8_t y, uint8_t color)
Write a pixel to the buffer.
Definition: SerialWombat18ABVGA.h:121
SerialWombat18ABVGA::fillScreen
int16_t fillScreen(uint8_t color)
fill the entire screen
Definition: SerialWombat18ABVGA.h:141
SerialWombat.h
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:166
SerialWombat18ABVGA::setLineColor
int16_t setLineColor(uint8_t color, uint8_t y)
Set the color of a horizontal line.
Definition: SerialWombat18ABVGA.h:192
SerialWombatPin
Describes a Serial Wombat Pin. Is base class for other pin modes.
Definition: SerialWombatPin.h:38
SerialWombatPin::_pinMode
uint8_t _pinMode
Definition: SerialWombatPin.h:135
SerialWombatChip::sendPacket
int sendPacket(uint8_t tx[], uint8_t rx[])
Send an 8 byte packet to the Serial Wombat chip and wait for 8 bytes back.
Definition: SerialWombat.cpp:114
SerialWombat18ABVGA
A class for the Serial Wombat SW18AB chip VGA Driver.
Definition: SerialWombat18ABVGA.h:81
SerialWombatPin::_pin
uint8_t _pin
Definition: SerialWombatPin.h:133
SerialWombatCommands::CONFIGURE_PIN_MODE2
@ CONFIGURE_PIN_MODE2
(202)
SW_LE16
#define SW_LE16(_a)
Convert a uint16_t to two bytes in little endian format for array initialization.
Definition: SerialWombat.h:41
SerialWombat18ABVGA::SerialWombat18ABVGA
SerialWombat18ABVGA(SerialWombatChip &serialWombat)
Constructor for the SerialWombat18ABVGA class.
Definition: SerialWombat18ABVGA.h:88
SerialWombatCommands::CONFIGURE_PIN_MODE1
@ CONFIGURE_PIN_MODE1
(201)
SerialWombat18ABVGA::begin
int16_t begin(uint8_t vsyncPin, uint16_t bufferIndex=0)
Initalize the SerialWombat18ABVGA.
Definition: SerialWombat18ABVGA.h:97
PIN_MODE_VGA
@ PIN_MODE_VGA
(31)
Definition: SerialWombat.h:269