#include #include #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 /* * Below is an is the 'legacy' way of initialising the MatrixPanel_I2S_DMA class. * i.e. MATRIX_WIDTH and MATRIX_HEIGHT are modified by compile-time directives. * By default the library assumes a single 64x32 pixel panel is connected. * * Refer to the example '2_PatternPlasma' on the new / correct way to setup this library * for different resolutions / panel chain lengths within the sketch 'setup()'. * */ MatrixPanel_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(); }