Skip to content

Instantly share code, notes, and snippets.

@jorge-teixeira
Last active March 25, 2020 19:21
Show Gist options
  • Save jorge-teixeira/6f9a0bef4519fccb7acc63b60bd29d28 to your computer and use it in GitHub Desktop.
Save jorge-teixeira/6f9a0bef4519fccb7acc63b60bd29d28 to your computer and use it in GitHub Desktop.
#include <LEDMatrixDriver.hpp>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
const char* ssid = "WIFIID";
const char* password = "WIFIPASSWORD";
// TCP server at port 80 will respond to HTTP requests
WiFiServer server(80);
/*
* ESP8266 pins need wired are below:
* DIN (data in) on Matrix ---> 13 or MOSI on ESP8266
* Clock(CLK) on Matrix --> 14 or SCK on ESP8266
* CS pin on Matrix define below --->( pick 15 on esp8266)
*/
const uint8_t LEDMATRIX_CS_PIN = 15;
// Define LED Matrix dimensions (0-n) - eg: 32x8 = 31x7
const int LEDMATRIX_WIDTH = 64;
const int LEDMATRIX_HEIGHT = 8;
const int LEDMATRIX_SEGMENTS = 8;
// The LEDMatrixDriver class instance
LEDMatrixDriver lmd(LEDMATRIX_SEGMENTS, LEDMATRIX_CS_PIN);
// Block font 8x8
byte font[][8] = {
// --------------------------- 0-127 ---------------------------
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 0000 (uni0000.dup1)
{0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e}, // 0001 (uni0001)
{0x7e, 0xff, 0xdb, 0xff, 0xc3, 0xe7, 0xff, 0x7e}, // 0002 (uni0002)
{0x6c, 0xfe, 0xfe, 0xfe, 0x7c, 0x38, 0x10, 0x00}, // 0003 (uni0003)
{0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x10, 0x00}, // 0004 (uni0004)
{0x38, 0x7c, 0x38, 0xfe, 0xfe, 0x7c, 0x38, 0x7c}, // 0005 (uni0005)
{0x10, 0x10, 0x38, 0x7c, 0xfe, 0x7c, 0x38, 0x7c}, // 0006 (uni0006)
{0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00}, // 0007 (uni0007)
{0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff}, // 0008 (uni0008)
{0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00}, // 0009 (uni0009)
{0xff, 0xc3, 0x99, 0xbd, 0xbd, 0x99, 0xc3, 0xff}, // 000a (uni000A)
{0x0f, 0x07, 0x0f, 0x7d, 0xcc, 0xcc, 0xcc, 0x78}, // 000b (uni000B)
{0x3c, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18}, // 000c (uni000C)
{0x3f, 0x33, 0x3f, 0x30, 0x30, 0x70, 0xf0, 0xe0}, // 000d (uni000D)
{0x7f, 0x63, 0x7f, 0x63, 0x63, 0x67, 0xe6, 0xc0}, // 000e (uni000E)
{0x99, 0x5a, 0x3c, 0xe7, 0xe7, 0x3c, 0x5a, 0x99}, // 000f (uni000F)
{0x80, 0xe0, 0xf8, 0xfe, 0xf8, 0xe0, 0x80, 0x00}, // 0010 (uni0010)
{0x02, 0x0e, 0x3e, 0xfe, 0x3e, 0x0e, 0x02, 0x00}, // 0011 (uni0011)
{0x18, 0x3c, 0x7e, 0x18, 0x18, 0x7e, 0x3c, 0x18}, // 0012 (uni0012)
{0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00}, // 0013 (uni0013)
{0x7f, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x00}, // 0014 (uni0014)
{0x3e, 0x63, 0x38, 0x6c, 0x6c, 0x38, 0xcc, 0x78}, // 0015 (uni0015)
{0x00, 0x00, 0x00, 0x00, 0x7e, 0x7e, 0x7e, 0x00}, // 0016 (uni0016)
{0x18, 0x3c, 0x7e, 0x18, 0x7e, 0x3c, 0x18, 0xff}, // 0017 (uni0017)
{0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x00}, // 0018 (uni0018)
{0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00}, // 0019 (uni0019)
{0x00, 0x18, 0x0c, 0xfe, 0x0c, 0x18, 0x00, 0x00}, // 001a (uni001A)
{0x00, 0x30, 0x60, 0xfe, 0x60, 0x30, 0x00, 0x00}, // 001b (uni001B)
{0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xfe, 0x00, 0x00}, // 001c (uni001C)
{0x00, 0x24, 0x66, 0xff, 0x66, 0x24, 0x00, 0x00}, // 001d (uni001D)
{0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x00, 0x00}, // 001e (uni001E)
{0x00, 0xff, 0xff, 0x7e, 0x3c, 0x18, 0x00, 0x00}, // 001f (uni001F)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 0020 (space)
{0x30, 0x78, 0x78, 0x30, 0x30, 0x00, 0x30, 0x00}, // 0021 (exclam)
{0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00}, // 0022 (quotedbl)
{0x6c, 0x6c, 0xfe, 0x6c, 0xfe, 0x6c, 0x6c, 0x00}, // 0023 (numbersign)
{0x30, 0x7c, 0xc0, 0x78, 0x0c, 0xf8, 0x30, 0x00}, // 0024 (dollar)
{0x00, 0xc6, 0xcc, 0x18, 0x30, 0x66, 0xc6, 0x00}, // 0025 (percent)
{0x38, 0x6c, 0x38, 0x76, 0xdc, 0xcc, 0x76, 0x00}, // 0026 (ampersand)
{0x60, 0x60, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00}, // 0027 (quotesingle)
{0x18, 0x30, 0x60, 0x60, 0x60, 0x30, 0x18, 0x00}, // 0028 (parenleft)
{0x60, 0x30, 0x18, 0x18, 0x18, 0x30, 0x60, 0x00}, // 0029 (parenright)
{0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00}, // 002a (asterisk)
{0x00, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x00, 0x00}, // 002b (plus)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x60}, // 002c (comma)
{0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00}, // 002d (hyphen)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x00}, // 002e (period)
{0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x80, 0x00}, // 002f (slash)
{0x7c, 0xc6, 0xce, 0xde, 0xf6, 0xe6, 0x7c, 0x00}, // 0030 (zero)
{0x30, 0x70, 0x30, 0x30, 0x30, 0x30, 0xfc, 0x00}, // 0031 (one)
{0x78, 0xcc, 0x0c, 0x38, 0x60, 0xc4, 0xfc, 0x00}, // 0032 (two)
{0x78, 0xcc, 0x0c, 0x38, 0x0c, 0xcc, 0x78, 0x00}, // 0033 (three)
{0x1c, 0x3c, 0x6c, 0xcc, 0xfe, 0x0c, 0x1e, 0x00}, // 0034 (four)
{0xfc, 0xc0, 0xf8, 0x0c, 0x0c, 0xcc, 0x78, 0x00}, // 0035 (five)
{0x38, 0x60, 0xc0, 0xf8, 0xcc, 0xcc, 0x78, 0x00}, // 0036 (six)
{0xfc, 0xcc, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x00}, // 0037 (seven)
{0x78, 0xcc, 0xcc, 0x78, 0xcc, 0xcc, 0x78, 0x00}, // 0038 (eight)
{0x78, 0xcc, 0xcc, 0x7c, 0x0c, 0x18, 0x70, 0x00}, // 0039 (nine)
{0x00, 0x30, 0x30, 0x00, 0x00, 0x30, 0x30, 0x00}, // 003a (colon)
{0x00, 0x30, 0x30, 0x00, 0x30, 0x30, 0x60, 0x00}, // 003b (semicolon)
{0x18, 0x30, 0x60, 0xc0, 0x60, 0x30, 0x18, 0x00}, // 003c (less)
{0x00, 0x00, 0xfc, 0x00, 0x00, 0xfc, 0x00, 0x00}, // 003d (equal)
{0x60, 0x30, 0x18, 0x0c, 0x18, 0x30, 0x60, 0x00}, // 003e (greater)
{0x78, 0xcc, 0x0c, 0x18, 0x30, 0x00, 0x30, 0x00}, // 003f (question)
{0x7c, 0xc6, 0xde, 0xde, 0xde, 0xc0, 0x78, 0x00}, // 0040 (at)
{0x30, 0x78, 0xcc, 0xcc, 0xfc, 0xcc, 0xcc, 0x00}, // 0041 (A)
{0xfc, 0x66, 0x66, 0x7c, 0x66, 0x66, 0xfc, 0x00}, // 0042 (B)
{0x3c, 0x66, 0xc0, 0xc0, 0xc0, 0x66, 0x3c, 0x00}, // 0043 (C)
{0xf8, 0x6c, 0x66, 0x66, 0x66, 0x6c, 0xf8, 0x00}, // 0044 (D)
{0xfe, 0x62, 0x68, 0x78, 0x68, 0x62, 0xfe, 0x00}, // 0045 (E)
{0xfe, 0x62, 0x68, 0x78, 0x68, 0x60, 0xf0, 0x00}, // 0046 (F)
{0x3c, 0x66, 0xc0, 0xc0, 0xce, 0x66, 0x3e, 0x00}, // 0047 (G)
{0xcc, 0xcc, 0xcc, 0xfc, 0xcc, 0xcc, 0xcc, 0x00}, // 0048 (H)
{0x78, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00}, // 0049 (I)
{0x1e, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0x78, 0x00}, // 004a (J)
{0xe6, 0x66, 0x6c, 0x78, 0x6c, 0x66, 0xe6, 0x00}, // 004b (K)
{0xf0, 0x60, 0x60, 0x60, 0x62, 0x66, 0xfe, 0x00}, // 004c (L)
{0xc6, 0xee, 0xfe, 0xfe, 0xd6, 0xc6, 0xc6, 0x00}, // 004d (M)
{0xc6, 0xe6, 0xf6, 0xde, 0xce, 0xc6, 0xc6, 0x00}, // 004e (N)
{0x38, 0x6c, 0xc6, 0xc6, 0xc6, 0x6c, 0x38, 0x00}, // 004f (O)
{0xfc, 0x66, 0x66, 0x7c, 0x60, 0x60, 0xf0, 0x00}, // 0050 (P)
{0x78, 0xcc, 0xcc, 0xcc, 0xdc, 0x78, 0x1c, 0x00}, // 0051 (Q)
{0xfc, 0x66, 0x66, 0x7c, 0x6c, 0x66, 0xe6, 0x00}, // 0052 (R)
{0x78, 0xcc, 0xe0, 0x70, 0x1c, 0xcc, 0x78, 0x00}, // 0053 (S)
{0xfc, 0xb4, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00}, // 0054 (T)
{0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xfc, 0x00}, // 0055 (U)
{0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x00}, // 0056 (V)
{0xc6, 0xc6, 0xc6, 0xd6, 0xfe, 0xee, 0xc6, 0x00}, // 0057 (W)
{0xc6, 0xc6, 0x6c, 0x38, 0x38, 0x6c, 0xc6, 0x00}, // 0058 (X)
{0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x30, 0x78, 0x00}, // 0059 (Y)
{0xfe, 0xc6, 0x8c, 0x18, 0x32, 0x66, 0xfe, 0x00}, // 005a (Z)
{0x78, 0x60, 0x60, 0x60, 0x60, 0x60, 0x78, 0x00}, // 005b (bracketleft)
{0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x02, 0x00}, // 005c (backslash)
{0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, 0x00}, // 005d (bracketright)
{0x10, 0x38, 0x6c, 0xc6, 0x00, 0x00, 0x00, 0x00}, // 005e (asciicircum)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff}, // 005f (underscore)
{0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}, // 0060 (grave)
{0x00, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x76, 0x00}, // 0061 (a)
{0xe0, 0x60, 0x60, 0x7c, 0x66, 0x66, 0xdc, 0x00}, // 0062 (b)
{0x00, 0x00, 0x78, 0xcc, 0xc0, 0xcc, 0x78, 0x00}, // 0063 (c)
{0x1c, 0x0c, 0x0c, 0x7c, 0xcc, 0xcc, 0x76, 0x00}, // 0064 (d)
{0x00, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00}, // 0065 (e)
{0x38, 0x6c, 0x60, 0xf0, 0x60, 0x60, 0xf0, 0x00}, // 0066 (f)
{0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8}, // 0067 (g)
{0xe0, 0x60, 0x6c, 0x76, 0x66, 0x66, 0xe6, 0x00}, // 0068 (h)
{0x30, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00}, // 0069 (i)
{0x0c, 0x00, 0x0c, 0x0c, 0x0c, 0xcc, 0xcc, 0x78}, // 006a (j)
{0xe0, 0x60, 0x66, 0x6c, 0x78, 0x6c, 0xe6, 0x00}, // 006b (k)
{0x70, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00}, // 006c (l)
{0x00, 0x00, 0xcc, 0xfe, 0xfe, 0xd6, 0xc6, 0x00}, // 006d (m)
{0x00, 0x00, 0xf8, 0xcc, 0xcc, 0xcc, 0xcc, 0x00}, // 006e (n)
{0x00, 0x00, 0x78, 0xcc, 0xcc, 0xcc, 0x78, 0x00}, // 006f (o)
{0x00, 0x00, 0xdc, 0x66, 0x66, 0x7c, 0x60, 0xf0}, // 0070 (p)
{0x00, 0x00, 0x76, 0xcc, 0xcc, 0x7c, 0x0c, 0x1e}, // 0071 (q)
{0x00, 0x00, 0xdc, 0x76, 0x66, 0x60, 0xf0, 0x00}, // 0072 (r)
{0x00, 0x00, 0x7c, 0xc0, 0x78, 0x0c, 0xf8, 0x00}, // 0073 (s)
{0x10, 0x30, 0x7c, 0x30, 0x30, 0x34, 0x18, 0x00}, // 0074 (t)
{0x00, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x76, 0x00}, // 0075 (u)
{0x00, 0x00, 0xcc, 0xcc, 0xcc, 0x78, 0x30, 0x00}, // 0076 (v)
{0x00, 0x00, 0xc6, 0xd6, 0xfe, 0xfe, 0x6c, 0x00}, // 0077 (w)
{0x00, 0x00, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0x00}, // 0078 (x)
{0x00, 0x00, 0xcc, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8}, // 0079 (y)
{0x00, 0x00, 0xfc, 0x98, 0x30, 0x64, 0xfc, 0x00}, // 007a (z)
{0x1c, 0x30, 0x30, 0xe0, 0x30, 0x30, 0x1c, 0x00}, // 007b (braceleft)
{0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00}, // 007c (bar)
{0xe0, 0x30, 0x30, 0x1c, 0x30, 0x30, 0xe0, 0x00}, // 007d (braceright)
{0x76, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 007e (asciitilde)
{0x00, 0x10, 0x38, 0x6c, 0xc6, 0xc6, 0xfe, 0x00}, // 007f (uni007F)
// --------------------------- 160-255 ---------------------------
// ------- empty chars ascii table https://cs.stanford.edu/people/miles/iso8859.html ------------
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni0 0A0)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni00A0)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni00A0)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni00A0)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni00A0)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni00A0)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni00A0)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni00A0)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni00A0)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni00A0)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni00A0)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni00A0)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni00A0)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni00A0)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni00A0)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni00A0)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni00A0)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni00A0)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni00A0)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni00A0)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni00A0)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni00A0)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni00A0)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni00A0)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni00A0)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni00A0)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni00A0)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni00A0)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni00A0)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni00A0)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni00A0)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni00A0)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a0 (uni00A0)
{0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00}, // 00a1 (exclamdown)
{0x18, 0x18, 0x7e, 0xc0, 0xc0, 0x7e, 0x18, 0x18}, // 00a2 (cent)
{0x38, 0x6c, 0x64, 0xf0, 0x60, 0xe6, 0xfc, 0x00}, // 00a3 (sterling)
{0x00, 0xc6, 0x7c, 0xc6, 0xc6, 0x7c, 0xc6, 0x00}, // 00a4 (currency)
{0xcc, 0xcc, 0x78, 0xfc, 0x30, 0xfc, 0x30, 0x30}, // 00a5 (yen)
{0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00}, // 00a6 (brokenbar)
{0x3e, 0x63, 0x38, 0x6c, 0x6c, 0x38, 0xcc, 0x78}, // 00a7 (section)
{0xc6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00a8 (dieresis)
{0x7e, 0x81, 0x9d, 0xa1, 0xa1, 0x9d, 0x81, 0x7e}, // 00a9 (copyright)
{0x3c, 0x6c, 0x6c, 0x3e, 0x00, 0x7e, 0x00, 0x00}, // 00aa (ordfeminine)
{0x00, 0x33, 0x66, 0xcc, 0x66, 0x33, 0x00, 0x00}, // 00ab (guillemotleft)
{0x00, 0x00, 0x00, 0xfc, 0x0c, 0x0c, 0x00, 0x00}, // 00ac (logicalnot)
{0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00}, // 00ad (uni00AD)
{0x7e, 0x81, 0xb9, 0xa5, 0xb9, 0xa5, 0x81, 0x7e}, // 00ae (registered)
{0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00af (macron)
{0x38, 0x6c, 0x6c, 0x38, 0x00, 0x00, 0x00, 0x00}, // 00b0 (degree)
{0x30, 0x30, 0xfc, 0x30, 0x30, 0x00, 0xfc, 0x00}, // 00b1 (plusminus)
{0x70, 0x18, 0x30, 0x60, 0x78, 0x00, 0x00, 0x00}, // 00b2 (uni00B2)
{0x70, 0x18, 0x30, 0x18, 0x70, 0x00, 0x00, 0x00}, // 00b3 (uni00B3)
{0x0c, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00}, // 00b4 (acute)
{0x00, 0x66, 0x66, 0x66, 0x66, 0x7c, 0x60, 0xc0}, // 00b5 (mu)
{0x7f, 0xdb, 0xdb, 0x7b, 0x1b, 0x1b, 0x1b, 0x00}, // 00b6 (paragraph)
{0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00}, // 00b7 (periodcentered)
{0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0c, 0x38}, // 00b8 (cedilla)
{0x30, 0x70, 0x30, 0x30, 0x78, 0x00, 0x00, 0x00}, // 00b9 (uni00B9)
{0x38, 0x6c, 0x6c, 0x38, 0x00, 0x7c, 0x00, 0x00}, // 00ba (ordmasculine)
{0x00, 0xcc, 0x66, 0x33, 0x66, 0xcc, 0x00, 0x00}, // 00bb (guillemotright)
{0xc3, 0xc6, 0xcc, 0xdb, 0x37, 0x6f, 0xcf, 0x03}, // 00bc (onequarter)
{0xc3, 0xc6, 0xcc, 0xde, 0x33, 0x66, 0xcc, 0x0f}, // 00bd (onehalf)
{0xe0, 0x33, 0x66, 0x3c, 0xfb, 0x37, 0x6f, 0xc3}, // 00be (threequarters)
{0x30, 0x00, 0x30, 0x60, 0xc0, 0xcc, 0x78, 0x00}, // 00bf (questiondown)
{0xc0, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0xc6, 0x00}, // 00c0 (Agrave)
{0x06, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0xc6, 0x00}, // 00c1 (Aacute)
{0x7c, 0xc6, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0x00}, // 00c2 (Acircumflex)
{0x76, 0xdc, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0x00}, // 00c3 (Atilde)
{0xc6, 0x38, 0x6c, 0xc6, 0xfe, 0xc6, 0xc6, 0x00}, // 00c4 (Adieresis)
{0x30, 0x30, 0x00, 0x78, 0xcc, 0xfc, 0xcc, 0x00}, // 00c5 (Aring)
{0x3e, 0x6c, 0xcc, 0xfe, 0xcc, 0xcc, 0xce, 0x00}, // 00c6 (AE)
{0x78, 0xcc, 0xc0, 0xcc, 0x78, 0x18, 0x0c, 0x78}, // 00c7 (Ccedilla)
{0xe0, 0x00, 0xfc, 0x60, 0x78, 0x60, 0xfc, 0x00}, // 00c8 (Egrave)
{0x1c, 0x00, 0xfc, 0x60, 0x78, 0x60, 0xfc, 0x00}, // 00c9 (Eacute)
{0x78, 0xcc, 0xfc, 0x60, 0x78, 0x60, 0xfc, 0x00}, // 00ca (Ecircumflex)
{0xcc, 0x00, 0xfc, 0x60, 0x78, 0x60, 0xfc, 0x00}, // 00cb (Edieresis)
{0xe0, 0x00, 0x78, 0x30, 0x30, 0x30, 0x78, 0x00}, // 00cc (Igrave)
{0x1c, 0x00, 0x78, 0x30, 0x30, 0x30, 0x78, 0x00}, // 00cd (Iacute)
{0x7e, 0xc3, 0x3c, 0x18, 0x18, 0x18, 0x3c, 0x00}, // 00ce (Icircumflex)
{0xcc, 0x00, 0x78, 0x30, 0x30, 0x30, 0x78, 0x00}, // 00cf (Idieresis)
{0xf8, 0x6c, 0x66, 0xf6, 0x66, 0x6c, 0xf8, 0x00}, // 00d0 (Eth)
{0xfc, 0x00, 0xcc, 0xec, 0xfc, 0xdc, 0xcc, 0x00}, // 00d1 (Ntilde)
{0xc0, 0x38, 0x6c, 0xc6, 0xc6, 0x6c, 0x38, 0x00}, // 00d2 (Ograve)
{0x06, 0x38, 0x6c, 0xc6, 0xc6, 0x6c, 0x38, 0x00}, // 00d3 (Oacute)
{0x7c, 0xc6, 0x38, 0x6c, 0xc6, 0x6c, 0x38, 0x00}, // 00d4 (Ocircumflex)
{0x76, 0xdc, 0x38, 0x6c, 0xc6, 0x6c, 0x38, 0x00}, // 00d5 (Otilde)
{0xc3, 0x18, 0x3c, 0x66, 0x66, 0x3c, 0x18, 0x00}, // 00d6 (Odieresis)
{0x00, 0xc6, 0x6c, 0x38, 0x6c, 0xc6, 0x00, 0x00}, // 00d7 (multiply)
{0x3a, 0x6c, 0xce, 0xd6, 0xe6, 0x6c, 0xb8, 0x00}, // 00d8 (Oslash)
{0xe0, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x00}, // 00d9 (Ugrave)
{0x1c, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x00}, // 00da (Uacute)
{0x7c, 0xc6, 0x00, 0xc6, 0xc6, 0xc6, 0x7c, 0x00}, // 00db (Ucircumflex)
{0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0xcc, 0x78, 0x00}, // 00dc (Udieresis)
{0x1c, 0x00, 0xcc, 0xcc, 0x78, 0x30, 0x78, 0x00}, // 00dd (Yacute)
{0xf0, 0x60, 0x7c, 0x66, 0x7c, 0x60, 0xf0, 0x00}, // 00de (Thorn)
{0x78, 0xcc, 0xcc, 0xd8, 0xcc, 0xc6, 0xcc, 0x00}, // 00df (germandbls)
{0xe0, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x7e, 0x00}, // 00e0 (agrave)
{0x1c, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x7e, 0x00}, // 00e1 (aacute)
{0x7e, 0xc3, 0x3c, 0x06, 0x3e, 0x66, 0x3f, 0x00}, // 00e2 (acircumflex)
{0x76, 0xdc, 0x78, 0x0c, 0x7c, 0xcc, 0x7e, 0x00}, // 00e3 (atilde)
{0xcc, 0x00, 0x78, 0x0c, 0x7c, 0xcc, 0x7e, 0x00}, // 00e4 (adieresis)
{0x30, 0x30, 0x78, 0x0c, 0x7c, 0xcc, 0x7e, 0x00}, // 00e5 (aring)
{0x00, 0x00, 0x7f, 0x0c, 0x7f, 0xcc, 0x7f, 0x00}, // 00e6 (ae)
{0x00, 0x00, 0x78, 0xc0, 0xc0, 0x78, 0x0c, 0x38}, // 00e7 (ccedilla)
{0xe0, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00}, // 00e8 (egrave)
{0x1c, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00}, // 00e9 (eacute)
{0x7e, 0xc3, 0x3c, 0x66, 0x7e, 0x60, 0x3c, 0x00}, // 00ea (ecircumflex)
{0xcc, 0x00, 0x78, 0xcc, 0xfc, 0xc0, 0x78, 0x00}, // 00eb (edieresis)
{0xe0, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00}, // 00ec (igrave)
{0x38, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00}, // 00ed (iacute)
{0x7c, 0xc6, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00}, // 00ee (icircumflex)
{0xcc, 0x00, 0x70, 0x30, 0x30, 0x30, 0x78, 0x00}, // 00ef (idieresis)
{0x30, 0x7e, 0x0c, 0x7c, 0xcc, 0xcc, 0x78, 0x00}, // 00f0 (eth)
{0x00, 0xf8, 0x00, 0xf8, 0xcc, 0xcc, 0xcc, 0x00}, // 00f1 (ntilde)
{0x00, 0xe0, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00}, // 00f2 (ograve)
{0x00, 0x1c, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00}, // 00f3 (oacute)
{0x78, 0xcc, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00}, // 00f4 (ocircumflex)
{0x76, 0xdc, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00}, // 00f5 (otilde)
{0x00, 0xcc, 0x00, 0x78, 0xcc, 0xcc, 0x78, 0x00}, // 00f6 (odieresis)
{0x30, 0x30, 0x00, 0xfc, 0x00, 0x30, 0x30, 0x00}, // 00f7 (divide)
{0x00, 0x02, 0x7c, 0xce, 0xd6, 0xe6, 0x7c, 0x80}, // 00f8 (oslash)
{0x00, 0xe0, 0x00, 0xcc, 0xcc, 0xcc, 0x7e, 0x00}, // 00f9 (ugrave)
{0x00, 0x1c, 0x00, 0xcc, 0xcc, 0xcc, 0x7e, 0x00}, // 00fa (uacute)
{0x78, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0x7e, 0x00}, // 00fb (ucircumflex)
{0x00, 0xcc, 0x00, 0xcc, 0xcc, 0xcc, 0x7e, 0x00}, // 00fc (udieresis)
{0x00, 0x1c, 0x00, 0xcc, 0xcc, 0x7c, 0x0c, 0x78}, // 00fd (yacute)
{0xe0, 0x60, 0x7c, 0x66, 0x66, 0x7c, 0x60, 0xf0}, // 00fe (thorn)
{0x00, 0xcc, 0x00, 0xcc, 0xcc, 0x7c, 0x0c, 0xf8}, // 00ff (ydieresis)
};
int x=LEDMATRIX_WIDTH, y=0; // start top left
// Marquee text
char text[75] = " Hello ";
int len = strlen(text);
// Marquee speed
const int ANIM_DELAY = 75;
unsigned long myTime=millis();
unsigned long intro=millis();
IPAddress ip ;
void setup() {
//Initialize the display
Serial.begin(115200);
Serial.print("on ligado");
Serial.println(" Hello World ");
lmd.setEnabled(true);
lmd.setIntensity(2); // 0 = low, 10 = high
sprintf(text,"Connecting to %s",ssid);
len=strlen(text);
// Connect to WiFi network
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
displayText(text);
delay(ANIM_DELAY);
}
// Start TCP (HTTP) server
server.begin();
ip = WiFi.localIP();
String ipStr = String(ip[0]) + '.' + String(ip[1]) + '.' + String(ip[2]) + '.' + String(ip[3]);
strcpy(text, ipStr.c_str());
len=strlen(text);
}
void loop()
{
displayText(text);
// Check if a client has connected
WiFiClient client = server.available();
if (!client) {
return;
}
// Wait for data from client to become available
while(client.connected() && !client.available()){
displayText(text);
delay(1);
}
// Read the first line of HTTP request
String req = client.readStringUntil('\r');
// First line of HTTP request looks like "GET /path HTTP/1.1"
// Retrieve the "/path" part by finding the spaces
int addr_start = req.indexOf(' ');
int addr_end = req.indexOf(' ', addr_start + 1);
if (addr_start == -1 || addr_end == -1) {
return;
}
req = req.substring(addr_start + 1, addr_end);
client.flush();
String s;
String answer;
int pos;
if (req.indexOf('?')>0) {
//Change url tags to text
answer=req.substring(req.indexOf('=')+1);
answer.replace('+',' ');
//Conver HTML URL Encode to Text:
//https://www.w3schools.com/tags/ref_urlencode.asp
answer.replace("%20"," ");
answer.replace("%21","\!");
answer.replace("%22","\"");
answer.replace("%23","\#");
answer.replace("%24","\$");
answer.replace("%25","%");
answer.replace("%26","&");
answer.replace("%27","\'");
answer.replace("%28","\(");
answer.replace("%29","\)");
answer.replace("%2B","\+");
answer.replace("%2C","\,");
answer.replace("%2D","\-");
answer.replace("%2E","\.");
answer.replace("%2F","\/");
answer.replace("%3A","\:");
answer.replace("%3B","\;");
answer.replace("%3C","\<");
answer.replace("%3D","\=");
answer.replace("%3E","\>");
answer.replace("%3F","\?");
answer.replace("%40","\@");
answer.replace("%5B","\[");
answer.replace("%5C","\\");
answer.replace("%5D","\]");
answer.replace("%5E","\^");
answer.replace("%7B","\{");
answer.replace("%7C","\|");
answer.replace("%7D","\}");
answer.replace("%E7","\xE7");
answer.replace("%E3","\xE3");
answer.replace("%E0","\xE0");
answer.replace("%E1","\xE1");
answer.replace("%C1","\xC1");
answer.replace("%E2","\xE2");
answer.replace("%C2","\xC2");
answer.replace("%C9","\xC9");
answer.replace("%E9","\xE9");
answer.replace("%CD","\xCD");
answer.replace("%ED","\xED");
answer.replace("%D3","\xD3");
answer.replace("%F3","\xF3");
answer.replace("%DA","\xDA");
answer.replace("%FA","\xFA");
answer.replace("%D5","\xD5");
answer.replace("%F5","\xF5");
answer.replace("%FA","\xFA");
strcpy(text, answer.c_str());
len=strlen(text);
x=LEDMATRIX_WIDTH;
lmd.clear();
//Serial.println(req.substring(req.indexOf('=')+1));
s="HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML><style> #header{ min-height: 20px; background-color: #666699; } #menu{ min-height: 20px; margin-top: 1%; background-color: #999999; } #body{ min-height: 200px; margin-top: 1%; } #footer{ min-height: 20px; margin-top: 1%; background-color: #666699; } #header, #menu, #body, #footer{ margin-left: 10%; margin-right: 10%; box-shadow: 3px 5px 7px #666666; border: 1px solid black; } @viewport{ zoom: 1.0; width: extend-to-zoom; } @-ms-viewport{ width: extend-to-zoom; zoom: 1.0; } </style> <html lang='en'> <head> <meta name='viewport' content='width=device-width, initial-scale=1'> <title>ESP8266 Web Server</title> </head> <body> <div id='header'><center><h1>Welcome to the ESP8266 Web Server</H1></center></div>";
s+=" <div id='menu'><center><H2>Printing to the 4 - 8x8 Matrix</h2></center></div> ";
s+="<div id='body'><center><div><div><br/><H3>";
s+=answer;
s+="<p><a href='./'>Back</a></p>";
s+="</H3></div></div> </center> </div> <div id='footer'> </div> </body></html> ";
//s+=req.substring(req.indexOf('=')+1);
s+"</body></html>\r\n\r\n";
client.print(s);
return;
}
else
{
s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n";
s+="<!doctype html> <style> \#header{ min-height: 20px; background-color: \#666699; } \#menu{ min-height: 20px; margin-top: 1%; background-color: \#999999; } \#body{ min-height: 200px; margin-top: 1%; } \#footer{ min-height: 20px; margin-top: 1%; background-color: \#666699; } \#header, \#menu, \#body, \#footer{ margin-left: 10%; margin-right: 10%; box-shadow: 3px 5px 7px \#666666; border: 1px solid black; } @viewport{ zoom: 1.0; width: extend-to-zoom; } @-ms-viewport{ width: extend-to-zoom; zoom: 1.0; } </style> <html lang='en'> <head> <meta name='viewport' content='width=device-width, initial-scale=1'> <title>ESP8266 Web Server</title> </head> <body> <div id='header'><center><h1>Welcome to the ESP8266 Web Server</H1></center></div> <div id='menu'><center><H2>Enter text which will be displayed on a 4 - 8x8 led matrix</h2></center></div> <div id='body'><center><div><div><br> <form action='esp8266'> <br>Enter Text to display on LED Matrix:<br><input type='text' maxlength='70' name='max' value=''><br><br> <input type='submit' value='Submit'></form> </div></div> </center> </div> <div id='footer'> </div> </body>";
s += "</html>\r\n\r\n";
client.print(s);
return;
}
}
/* This function is called in loop but
* only does stuff when animimation delay
* is met.
*
* This will allow loop to do other thing instead
* of waiting for a delay to happen.
*
* Delay=bad programming.
*/
void displayText ( char * theText)
{
if ( myTime + ANIM_DELAY < millis())
{
myTime=millis();
// Draw the text to the current position
drawString(theText, len, x, 0);
// In case you wonder why we don't have to call lmd.clear() in every loop: The font has a opaque (black) background...
// Toggle display of the new framebuffer
lmd.display();
// Advance to next coordinate
if( --x < len * -8 )
{
x = LEDMATRIX_WIDTH;
lmd.clear();
}
}
}
/**
* This function draws a string of the given length to the given position.
*/
void drawString(char* text, int len, int x, int y )
{
for( int idx = 0; idx < len; idx ++ )
{
int c = text[idx];
// Serial.println(c);
// stop if char is outside visible area
if( x + idx * 8 > LEDMATRIX_WIDTH )
return;
// only draw if char is visible
if( 8 + x + idx * 8 > 0 )
drawSprite( font[c], x + idx * 8, y, 8, 8 );
}
}
/**
* This draws a sprite to the given position using the width and height supplied (usually 8x8)
*/
void drawSprite( byte* sprite, int x, int y, int width, int height )
{
// The mask is used to get the column bit from the sprite row
byte mask = B10000000;
for( int iy = 0; iy < height; iy++ )
{
for( int ix = 0; ix < width; ix++ )
{
//Yes my font is backwards so I swap it around.
lmd.setPixel(x + ix, y + iy, (bool)(sprite[iy] & mask ));
// lmd.setPixel(x + (width - ix), y + iy, (bool)(sprite[iy] & mask ));
// shift the mask by one pixel to the right
mask = mask >> 1;
}
// reset column mask
mask = B10000000;
}
}
@jorge-teixeira
Copy link
Author

jorge-teixeira commented Mar 25, 2020 via email

@bartoszbielawski
Copy link

Good! As I said, you had a "hole" in the array, so basically reaching element for cedilla was beyond the array.
Now - this is a programmer's daily routine. Sometimes you need to step back and think and understand what your code does.
Here, have some fun: https://i.redd.it/wp4wn3859so41.jpg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment