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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
#include <Arduino.h>
#include <ESP32-RGB64x32MatrixPanel-I2S-DMA.h>
#include "Dhole_weather_icons32px.h"
/*--------------------- DEBUG -------------------------*/
#define Sprintln(a) (Serial.println(a))
#define SprintlnDEC(a, x) (Serial.println(a, x))
#define Sprint(a) (Serial.print(a))
#define SprintDEC(a, x) (Serial.print(a, x))
/*--------------------- RGB DISPLAY PINS -------------------------*/
#define R1_PIN 25
#define G1_PIN 26
#define B1_PIN 27
#define R2_PIN 14
#define G2_PIN 12
#define B2_PIN 13
#define A_PIN 23
#define B_PIN 19 // Changed from library default
#define C_PIN 5
#define D_PIN 17
#define E_PIN -1
#define LAT_PIN 4
#define OE_PIN 15
#define CLK_PIN 16
// Display
RGB64x32MatrixPanel_I2S_DMA display; // RGB Panel
// Wifi Logo, generated using LCD Image Converter: http://www.riuson.com/lcd-image-converter
const char wifi_image1bit[] PROGMEM = {
0x00,0x00,0x00,0xf8,0x1f,0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0x01,0x00,
0x00,0x00,0x00,0xf0,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0xfc,0xff,0xff,0x1f,
0x00,0x00,0x00,0x00,0xfe,0x07,0xe0,0x7f,0x00,0x00,0x00,0x80,0xff,0x00,0x00,
0xff,0x01,0x00,0x00,0xc0,0x1f,0x00,0x00,0xf8,0x03,0x00,0x00,0xe0,0x0f,0x00,
0x00,0xf0,0x07,0x00,0x00,0xf0,0x03,0xf0,0x0f,0xc0,0x0f,0x00,0x00,0xe0,0x01,
0xff,0xff,0x80,0x07,0x00,0x00,0xc0,0xc0,0xff,0xff,0x03,0x03,0x00,0x00,0x00,
0xe0,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0xf8,0x0f,0xf0,0x1f,0x00,0x00,0x00,
0x00,0xfc,0x01,0x80,0x3f,0x00,0x00,0x00,0x00,0x7c,0x00,0x00,0x3e,0x00,0x00,
0x00,0x00,0x38,0x00,0x00,0x1c,0x00,0x00,0x00,0x00,0x10,0xe0,0x07,0x08,0x00,
0x00,0x00,0x00,0x00,0xfc,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,0x7f,0x00,
0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x1f,0xf8,
0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x01,0x00,0x00,0x00,0x00,0x00,
0x00,0xc0,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x07,0x00,0x00,0x00,0x00,
0x00,0x00,0xe0,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x03,0x00,0x00,0x00,
0x00,0x00,0x00,0x80,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00 };
/* Draw a bitmap, default bitmap pixels to white if no color provided.
* Use LCD Image Converter to generate the char array: http://www.riuson.com/lcd-image-converter
* In Options>Conversion, use: Monochrome Preset
*/
void drawXbm565(int x, int y, int width, int height, const char *xbm, uint16_t color = 0xffff)
{
if (width % 8 != 0) {
width = ((width / 8) + 1) * 8;
}
for (int i = 0; i < width * height / 8; i++ ) {
unsigned char charColumn = pgm_read_byte(xbm + i);
for (int j = 0; j < 8; j++) {
int targetX = (i * 8 + j) % width + x;
int targetY = (8 * i / (width)) + y;
if (bitRead(charColumn, j)) {
display.drawPixel(targetX, targetY, color);
}
}
}
}
/* Bitmaps */
int current_icon = 0;
static int num_icons = 22;
static char icon_name[22][30] = {
"cloud_moon_bits",
"cloud_sun_bits",
"clouds_bits",
"cloud_wind_moon_bits",
"cloud_wind_sun_bits",
"cloud_wind_bits",
"cloud_bits",
"lightning_bits",
"moon_bits",
"rain0_sun_bits",
"rain0_bits",
"rain1_moon_bits",
"rain1_sun_bits",
"rain1_bits",
"rain2_bits",
"rain_lightning_bits",
"rain_snow_bits",
"snow_moon_bits",
"snow_sun_bits",
"snow_bits",
"sun_bits",
"wind_bits" };
static char *icon_bits[22] = { cloud_moon_bits,
cloud_sun_bits,
clouds_bits,
cloud_wind_moon_bits,
cloud_wind_sun_bits,
cloud_wind_bits,
cloud_bits,
lightning_bits,
moon_bits,
rain0_sun_bits,
rain0_bits,
rain1_moon_bits,
rain1_sun_bits,
rain1_bits,
rain2_bits,
rain_lightning_bits,
rain_snow_bits,
snow_moon_bits,
snow_sun_bits,
snow_bits,
sun_bits,
wind_bits};
void setup() {
// put your setup code here, to run once:
delay(1000); Serial.begin(115200); delay(200);
/************** DISPLAY **************/
Sprintln("...Starting Display");
display.begin(R1_PIN, G1_PIN, B1_PIN, R2_PIN, G2_PIN, B2_PIN, A_PIN, B_PIN, C_PIN, D_PIN, E_PIN, LAT_PIN, OE_PIN, CLK_PIN );
display.fillScreen(display.color444(0, 1, 0));
// Fade a Red Wifi Logo In
for (int r=0; r < 255; r++ )
{
drawXbm565(0,0,64,32, wifi_image1bit, display.color565(r,0,0));
delay(10);
}
delay(2000);
display.clearScreen();
}
void loop() {
// Loop through Weather Icons
Serial.print("Showing icon ");
Serial.println(icon_name[current_icon]);
drawXbm565(0,0, 32, 32, icon_bits[current_icon]);
current_icon = (current_icon +1 ) % num_icons;
delay(2000);
display.clearScreen();
}
|