-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathColors.h
115 lines (101 loc) · 4.69 KB
/
Colors.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
* Colors.h
*
* SUMMARY
* Blue Display is an Open Source Android remote Display for Arduino etc.
* It receives basic draw requests from Arduino etc. over Bluetooth and renders it.
* It also implements basic GUI elements as buttons and sliders.
* GUI callback, touch and sensor events are sent back to Arduino.
*
* Copyright (C) 2018 Armin Joachimsmeyer
*
* This file is part of BlueDisplay https://github.com/ArminJo/android-blue-display.
*
* BlueDisplay is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>.
*
*/
#ifndef COLORS_H_
#define COLORS_H_
#include <stdint.h>
// deprecated
typedef uint16_t Color_t __attribute__ ((deprecated ("Renamed to color16_t")));;
// new
typedef uint16_t color16_t;
/*
* Basic 16 Bit Colors
*/
// RGB to 16 bit 565 schema - 5 red | 6 green | 5 blue
#define COLOR_WHITE ((color16_t)0xFFFF)
// 01 because 0 is used as flag (e.g. in touch button for default color)
#define COLOR_BLACK ((color16_t)0X0001)
#define COLOR_RED ((color16_t)0xF800)
#define COLOR_GREEN ((color16_t)0X07E0)
#define COLOR_BLUE ((color16_t)0x001F)
#define COLOR_DARK_BLUE ((color16_t)0x0014)
#define COLOR_YELLOW ((color16_t)0XFFE0)
#define COLOR_ORANGE ((color16_t)0XFE00)
#define COLOR_PURPLE ((color16_t)0xF81F)
#define COLOR_CYAN ((color16_t)0x07FF)
// If used as background color for char or text, the background will not filled
#define COLOR_NO_BACKGROUND ((color16_t)0XFFFE)
#define BLUEMASK 0x1F
#define GET_RED(rgb) ((rgb & 0xF800) >> 8)
#define GET_GREEN(rgb) ((rgb & 0x07E0) >> 3)
#define GET_BLUE(rgb) ((rgb & 0x001F) << 3)
#define RGB(r,g,b) ((color16_t)(((r&0xF8)<<8)|((g&0xFC)<<3)|((b&0xF8)>>3))) //5 red | 6 green | 5 blue
#define COLOR16(r,g,b) ((color16_t)(((r&0xF8)<<8)|((g&0xFC)<<3)|((b&0xF8)>>3))) //5 red | 6 green | 5 blue
/*
* 32 Bit Color values
*/
typedef uint32_t color32_t;
// Eases constant color declarations but should only be used for constant colors. Otherwise better use Adafruit_NeoPixel::Color() it saves program space
#define COLOR32(r,g,b) ((color32_t)(((uint32_t)r<<16)|((uint16_t)g<<8)|b)) // return ((uint32_t)r << 16) | ((uint32_t)g << 8) | b;
#define COLOR_W32(r,g,b,w) ((color32_t)(((uint32_t)w<<24)|((uint32_t)r<<16)|((uint16_t)g<<8)|b)) // return ((uint32_t)w << 24) |(uint32_t)r << 16) | ((uint32_t)g << 8) | b;
#define WHITE(color) ((color >> 24) & 0xFF)
#define RED(color) ((color >> 16) & 0xFF)
#define GREEN(color) ((color >> 8) & 0xFF)
#define BLUE(color) (color 0xFF)
#define COLOR32_BLACK COLOR32(0,0,0)
#define COLOR32_WHITE COLOR32(255,255,255)
#define COLOR32_WHITE_HALF COLOR32(128,128,128) // to reduce power consumption
#define COLOR32_WHITE_QUARTER COLOR32(64,64,64) // to reduce power consumption
#define COLOR32_WHITE_EIGHTH COLOR32(32,32,32) // to reduce power consumption
#define COLOR32_WHITE_16TH COLOR32(16,16,16)
#define COLOR32_WHITE_32TH COLOR32(8,8,8)
#define COLOR32_WHITE_64TH COLOR32(4,4,4)
#define COLOR32_WHITE_32TH COLOR32(8,8,8)
#define COLOR32_RED COLOR32(255,0,0)
#define COLOR32_RED_HALF COLOR32(128,0,0)
#define COLOR32_RED_QUARTER COLOR32(64,0,0)
#define COLOR32_GREEN COLOR32(0,255,0)
#define COLOR32_GREEN_HALF COLOR32(0,128,0)
#define COLOR32_GREEN_QUARTER COLOR32(0,64,0)
#define COLOR32_BLUE COLOR32(0,0,255)
#define COLOR32_BLUE_HALF COLOR32(0,0,128)
#define COLOR32_BLUE_QUARTER COLOR32(0,0,64)
#define COLOR32_YELLOW COLOR32(255,200,0) // value was visually determined
#define COLOR32_YELLOW_HALF COLOR32(128,100,0)
#define COLOR32_YELLOW_QUARTER COLOR32(64,50,0)
#define COLOR32_ORANGE COLOR32(255,64,0) // value was visually determined
#define COLOR32_ORANGE_HALF COLOR32(128,32,0)
#define COLOR32_ORANGE_QUARTER COLOR32(64,16,0)
#define COLOR32_PURPLE COLOR32(255,0,255)
#define COLOR32_PURPLE_HALF COLOR32(128,0,128)
#define COLOR32_PURPLE_QUARTER COLOR32(64,0,64)
#define COLOR32_CYAN COLOR32(0,255,255)
#define COLOR32_CYAN_HALF COLOR32(0,128,128)
#define COLOR32_CYAN_QUARTER COLOR32(0,64,64)
#endif /* COLORS_H_ */
#pragma once