-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Justin Hyland
authored and
Justin Hyland
committed
Sep 4, 2023
0 parents
commit 738874e
Showing
7 changed files
with
1,443 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
// Black & Grays | ||
const uint16_t BLACK = 0x0000; | ||
const uint16_t GRAY = 0x8410; | ||
const uint16_t LIGHTGRAY = 0xD69A; | ||
const uint16_t SLATEGRAY = 0x7412; | ||
const uint16_t DIMGRAY = 0x6B4D; | ||
const uint16_t DARKSLATEGRAY = 0x2A69; | ||
const uint16_t DARKGRAY = 0xAD55; | ||
const uint16_t LIGHTSLATEGRAY = 0x7453; | ||
|
||
// White & Offwhites | ||
const uint16_t ANTIQUEWHITE = 0xFF5A; | ||
const uint16_t FLORALWHITE = 0xFFDE; | ||
const uint16_t FORESTGREEN = 0x2444; | ||
const uint16_t NAVAJOWHITE = 0xFEF5; | ||
const uint16_t GHOSTWHITE = 0xFFDF; | ||
const uint16_t WHITE = 0xFFFF; | ||
const uint16_t WHITESMOKE = 0xF7BE; | ||
const uint16_t BEIGE = 0xF7BB; | ||
|
||
// Blues | ||
const uint16_t ALICEBLUE = 0xF7DF; | ||
const uint16_t BLUE = 0x001F; | ||
const uint16_t BLUEVIOLET = 0x895C; | ||
const uint16_t CADETBLUE = 0x5CF4; | ||
const uint16_t CORNFLOWERBLUE = 0x64BD; | ||
const uint16_t DARKBLUE = 0x0011; | ||
const uint16_t DARKSLATEBLUE = 0x49F1; | ||
const uint16_t DEEPSKYBLUE = 0x05FF; | ||
const uint16_t DODGERBLUE = 0x1C9F; | ||
const uint16_t LIGHTBLUE = 0xAEDC; | ||
const uint16_t LIGHTSKYBLUE = 0x867F; | ||
const uint16_t LIGHTSTEELBLUE = 0xB63B; | ||
const uint16_t MEDIUMBLUE = 0x0019; | ||
const uint16_t MEDIUMSLATEBLUE = 0x7B5D; | ||
const uint16_t MIDNIGHTBLUE = 0x18CE; | ||
const uint16_t POWDERBLUE = 0xB71C; | ||
const uint16_t ROYALBLUE = 0x435C; | ||
const uint16_t SKYBLUE = 0x867D; | ||
const uint16_t SLATEBLUE = 0x6AD9; | ||
const uint16_t STEELBLUE = 0x4416; | ||
const uint16_t NAVY = 0x0010; | ||
const uint16_t CYAN = 0x07FF; | ||
const uint16_t DARKCYAN = 0x0451; | ||
const uint16_t LIGHTCYAN = 0xE7FF; | ||
const uint16_t AQUAMARINE = 0x7FFA; | ||
const uint16_t AZURE = 0xF7FF; | ||
|
||
|
||
// Greens | ||
const uint16_t DARKGREEN = 0x0320; | ||
const uint16_t DARKOLIVEGREEN = 0x5345; | ||
const uint16_t DARKSEAGREEN = 0x8DF1; | ||
const uint16_t GREEN = 0x0400; | ||
const uint16_t GREENYELLOW = 0xAFE5; | ||
const uint16_t LAWNGREEN = 0x7FE0; | ||
const uint16_t LIGHTGREEN = 0x9772; | ||
const uint16_t LIGHTSEAGREEN = 0x2595; | ||
const uint16_t LIMEGREEN = 0x3666; | ||
const uint16_t MEDIUMSEAGREEN = 0x3D8E; | ||
const uint16_t MEDIUMSPRINGGREEN = 0x07D3; | ||
const uint16_t PALEGREEN = 0x9FD3; | ||
const uint16_t SEAGREEN = 0x2C4A; | ||
const uint16_t SPRINGGREEN = 0x07EF; | ||
const uint16_t YELLOWGREEN = 0x9E66; | ||
const uint16_t LIME = 0x07E0; | ||
const uint16_t AQUA = 0x07FF; | ||
const uint16_t OLIVE = 0x8400; | ||
const uint16_t OLIVEDRAB = 0x6C64; | ||
const uint16_t ORCHID = 0xDB9A; | ||
|
||
// Reds | ||
const uint16_t DARKRED = 0x8800; | ||
const uint16_t INDIANRED = 0xCAEB; | ||
const uint16_t MEDIUMVIOLETRED = 0xC0B0; | ||
const uint16_t PALEVIOLETRED = 0xDB92; | ||
const uint16_t RED = 0xF800; | ||
const uint16_t TOMATO = 0xFB08; | ||
const uint16_t DARKMAGENTA = 0x8811; | ||
|
||
// Pinks | ||
const uint16_t PINK = 0xFE19; | ||
const uint16_t LIGHTPINK = 0xFDB8; | ||
const uint16_t HOTPINK = 0xFB56; | ||
const uint16_t DEEPPINK = 0xF8B2; | ||
|
||
// Purples | ||
const uint16_t PURPLE = 0x8010; | ||
|
||
// Orange | ||
const uint16_t ORANGE = 0xFD20; | ||
const uint16_t DARKORANGE = 0xFC60; | ||
const uint16_t ORANGERED = 0xFA20; | ||
|
||
// Yellows | ||
const uint16_t YELLOW = 0xFFE0; | ||
const uint16_t LIGHTYELLOW = 0xFFFC; | ||
const uint16_t LIGHTGOLDENRODYELLOW = 0xFFDA; | ||
const uint16_t GOLD = 0xFEA0; | ||
|
||
// Browns | ||
const uint16_t BROWN = 0xA145; | ||
const uint16_t ROSYBROWN = 0xBC71; | ||
const uint16_t SADDLEBROWN = 0x8A22; | ||
const uint16_t SANDYBROWN = 0xF52C; | ||
const uint16_t CHOCOLATE = 0xD343; | ||
|
||
// Colors yet to be grouped | ||
const uint16_t BISQUE = 0xFF38; | ||
const uint16_t BLANCHEDALMOND = 0xFF59; | ||
const uint16_t BURLYWOOD = 0xDDD0; | ||
const uint16_t CHARTREUSE = 0x7FE0; | ||
const uint16_t CORAL = 0xFBEA; | ||
const uint16_t CORNSILK = 0xFFDB; | ||
const uint16_t CRIMSON = 0xD8A7; | ||
const uint16_t DARKGOLDENROD = 0xBC21; | ||
const uint16_t DARKKHAKI = 0xBDAD; | ||
const uint16_t DARKORCHID = 0x9999; | ||
const uint16_t DARKSALMON = 0xECAF; | ||
const uint16_t DARKTURQUOISE = 0x067A; | ||
const uint16_t DARKVIOLET = 0x901A; | ||
const uint16_t FIREBRICK = 0xB104; | ||
const uint16_t FUCHSIA = 0xF81F; | ||
const uint16_t GAINSBORO = 0xDEFB; | ||
const uint16_t GOLDENROD = 0xDD24; | ||
const uint16_t HONEYDEW = 0xF7FE; | ||
const uint16_t INDIGO = 0x4810; | ||
const uint16_t IVORY = 0xFFFE; | ||
const uint16_t KHAKI = 0xF731; | ||
const uint16_t LAVENDER = 0xE73F; | ||
const uint16_t LAVENDERBLUSH = 0xFF9E; | ||
const uint16_t LEMONCHIFFON = 0xFFD9; | ||
const uint16_t LIGHTCORAL = 0xF410; | ||
const uint16_t LIGHTSALMON = 0xFD0F; | ||
const uint16_t LINEN = 0xFF9C; | ||
const uint16_t MAGENTA = 0xF81F; | ||
const uint16_t MAROON = 0x8000; | ||
const uint16_t MEDIUMAQUAMARINE = 0x6675; | ||
const uint16_t MEDIUMORCHID = 0xBABA; | ||
const uint16_t MEDIUMPURPLE = 0x939B; | ||
const uint16_t MEDIUMTURQUOISE = 0x4E99; | ||
const uint16_t MINTCREAM = 0xF7FF; | ||
const uint16_t MISTYROSE = 0xFF3C; | ||
const uint16_t MOCCASIN = 0xFF36; | ||
const uint16_t OLDLACE = 0xFFBC; | ||
const uint16_t PALEGOLDENROD = 0xEF55; | ||
const uint16_t PALETURQUOISE = 0xAF7D; | ||
const uint16_t PAPAYAWHIP = 0xFF7A; | ||
const uint16_t PEACHPUFF = 0xFED7; | ||
const uint16_t PERU = 0xCC27; | ||
const uint16_t PLUM = 0xDD1B; | ||
const uint16_t SALMON = 0xFC0E; | ||
const uint16_t SEASHELL = 0xFFBD; | ||
const uint16_t SIENNA = 0xA285; | ||
const uint16_t SILVER = 0xC618; | ||
const uint16_t SNOW = 0xFFDF; | ||
const uint16_t TAN = 0xD5B1; | ||
const uint16_t TEAL = 0x0410; | ||
const uint16_t THISTLE = 0xDDFB; | ||
const uint16_t TURQUOISE = 0x471A; | ||
const uint16_t VIOLET = 0xEC1D; | ||
const uint16_t WHEAT = 0xF6F6; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Tells compiler this file is to be included only once in a single compilation | ||
#pragma once | ||
|
||
#ifndef SIMPLE_UI_SETTINGS_H | ||
#define SIMPLE_UI_SETTINGS_H | ||
|
||
const size_t MAX_CHAR_LENGTH = 60; // Char length of strings in UI | ||
|
||
const int FONT_DEFAULT_SIZE = 1; | ||
const uint16_t FONT_FG_COLOR = 0x95e7; // White font color | ||
const uint16_t FONT_BG_COLOR = 0x0000; // Black font background | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#pragma once | ||
|
||
#include "SimpleUI.hpp" | ||
|
||
// Type-specific implementations. | ||
|
||
|
||
SimpleUI::SimpleUI(Adafruit_SSD1351 &GFXHandler) : GFXHandler (&GFXHandler) {} | ||
|
||
|
||
TextAnchor * SimpleUI::newAnchor( int x, int y ){ | ||
std::cout << "Inside SimpleUI::newAnchor\n\tX: " << x << "\n\tY: " << y << std::endl; | ||
|
||
TextAnchor * _anchor = new TextAnchor( * GFXHandler ); | ||
_anchor->setCursor( x, y ); | ||
_anchor->setFontSize( _textSize ); | ||
|
||
if ( _defFgColor != NULL && _defBgColor != NULL ){ | ||
_anchor->setColor( _defFgColor, _defBgColor ); | ||
} | ||
else if ( _defFgColor != NULL ){ | ||
_anchor->setColor( _defFgColor ); | ||
} | ||
|
||
_anchor->setAutoPrint( true ); | ||
_anchor->print(); | ||
|
||
return _anchor; | ||
} | ||
|
||
|
||
/* | ||
void SimpleUI::whatever(char str){ | ||
std::cout << "whatever - str was a string: " << str << std::endl; | ||
} | ||
*/ | ||
|
||
void SimpleUI::begin(){ | ||
GFXHandler->begin(); | ||
GFXHandler->setFont(); | ||
GFXHandler->fillScreen(_defBgColor); | ||
GFXHandler->setTextColor(_defFgColor); | ||
//GFXHandler.setRotation(1); | ||
GFXHandler->setTextSize(1); | ||
} | ||
|
||
void SimpleUI::begin( uint16_t fgColor , uint16_t bgColor ){ | ||
_defFgColor = fgColor; | ||
_defBgColor = bgColor; | ||
|
||
_begin(); | ||
} | ||
|
||
void SimpleUI::begin( uint16_t fgColor ){ | ||
_defFgColor = fgColor; | ||
|
||
_begin(); | ||
} | ||
|
||
void SimpleUI::_begin(){ | ||
GFXHandler->begin(); | ||
GFXHandler->setFont(); | ||
GFXHandler->fillScreen(_defBgColor); | ||
GFXHandler->setTextColor(_defFgColor); | ||
//GFXHandler.setRotation(1); | ||
GFXHandler->setTextSize(1); | ||
} | ||
|
||
void SimpleUI::setColor( uint16_t fgColor ){ | ||
std::cout << "Inside: SimpleUI::setColor(fg)" << std::endl; | ||
std::cout << "\tfgColor: " << fgColor << std::endl; | ||
|
||
_defFgColor = fgColor; | ||
} | ||
|
||
void SimpleUI::setColor( uint16_t fgColor, uint16_t bgColor ){ | ||
std::cout << "Inside: SimpleUI::setColor(fg, bg)" << std::endl; | ||
std::cout << "\tfgColor: " << fgColor << std::endl; | ||
std::cout << "\tbgColor: " << bgColor << std::endl; | ||
|
||
_defFgColor = fgColor; | ||
_defBgColor = bgColor; | ||
} | ||
/* | ||
void SimpleUI::print( char val ){ | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#pragma once | ||
|
||
#ifndef SIMPLE_UI_H | ||
#define SIMPLE_UI_H | ||
|
||
#include <Arduino.h> | ||
#include <Adafruit_GFX.h> | ||
#include <Adafruit_SSD1351.h> | ||
//#include <Arduino_Helpers.h> | ||
#include <SPI.h> | ||
#include <ArduinoSTL.h> | ||
#include <cstddef> | ||
#include "Settings.hpp" | ||
#include "TextAnchor.hpp" | ||
|
||
|
||
class SimpleUI { | ||
public: | ||
|
||
SimpleUI(Adafruit_SSD1351 &GFXHandler); | ||
|
||
void begin(); | ||
void begin( uint16_t fgColor ); | ||
void begin( uint16_t fgColor, uint16_t bgColor ); | ||
|
||
void setColor( uint16_t fgColor ); | ||
void setColor( uint16_t fgColor, uint16_t bgColor ); | ||
|
||
|
||
TextAnchor * newAnchor( int x, int y ); | ||
|
||
// void whatever(char str); | ||
|
||
//template<class T> void whatever(T param) { std::cout << "param: " << param << "; TYPE_NAME(): " << TYPE_NAME(param) << std::endl; } | ||
|
||
// void print( char val ); | ||
|
||
private: | ||
|
||
Adafruit_SSD1351 * GFXHandler; | ||
|
||
void _begin(); | ||
|
||
//int _x, _y; | ||
|
||
// DEFAULT fg/bg colors (can be changed on a TextArea basis); | ||
uint16_t _defFgColor = 0x95e7; | ||
uint16_t _defBgColor = 0x0000; | ||
|
||
int _textSize = FONT_DEFAULT_SIZE; | ||
|
||
}; | ||
|
||
|
||
|
||
#endif // SIMPLE_UI_H |
Oops, something went wrong.