forked from DustinWatts/FreeTouchDeck
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDrawHelper.h
58 lines (58 loc) · 1.71 KB
/
DrawHelper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#pragma once
#include "globals.hpp"
#include <TFT_eSPI.h> // The TFT_eSPI library
namespace FreeTouchDeck
{
void drawErrorMessage(bool stop, const char *module, const char *fmt, ...);
void printDeviceAddress();
void LoadFontsTable();
void displayInit();
void PrintScreenMessage(bool clear, const char *message, ...);
void drawErrorMessage(String message);
const GFXfont *GetCurrentFont();
bool SetFont(const GFXfont *newFont);
bool SetDefaultFont();
void ClearScreen();
void InitFontsTable();
bool SetSmallerFont();
bool SetSmallestFont(int whichOne = 0);
bool SetLargestFont();
bool SetLargerFont();
void DrawSplash();
extern TFT_eSPI tft;
const char *convertRGB656ToHTMLRGB888(unsigned long rgb565);
unsigned int convertHTMLRGB888ToRGB565(const char *html);
unsigned long convertHTMLtoRGB888(const char *html);
const char *convertRGB888oHTMLRGB888(unsigned long rgb888);
unsigned long convertRGB656ToRGB888(unsigned long rgb565);
/**
* @brief This function converts RGB888 to RGB565.
*
* @param rgb unsigned long
*
* @return unsigned int
*
* @note none
*/
inline unsigned int convertRGB888ToRGB565(unsigned long rgb)
{
return tft.color24to16(rgb);
}
inline unsigned int convertRGB888ToRGB565(uint8_t * rgb, uint8_t depth)
{
// Values are received in LSB
uint8_t * pV=(uint8_t *)rgb;
switch (depth)
{
case 24:
// colors are stored as BGR
//*tptr++ = ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3);
return (pV[0] >>3) | ((pV[1] & 0xfc)<<3)| ((pV[2] & 0xF8)<< 8);
break;
default:
break;
}
return 0;
}
extern std::vector<std::string> Messages;
}