Разное о выращивании табака на Алтае
Вы не вошли.
Страницы 1
Не в сети
Не в сети
Не в сети
https://github.com/2dom/PxMatrix
Для нашей матрицы, правильное соединение с ESP8266/ESP32 такое.
Connect PI and PO as follows:(соединение между входной колодкой j1/PI и выходной колодкой j2/PO)
PI PO
R2 R1
G1 R2
G2 G1
B1 G2
B2 B1
Не в сети
Подключите вход панели (PI/J1) к ESP8266 / ESP32 следующим образом:
PI ESP8266 GPIO (NodeMCU) ESP32 GPIO
A 05 - (D1) 19
B 04 - (D2) 23
C 15 - (D8) 18
D 12 - (D6) 5
E 00 - (D3) 15
STB/LAT 16 - (D0) 22
P_OE 02 - (D4) 16
CLK 14 - (D5) 14
R1 13 - (D7) 13
Не в сети
Не в сети
#include <PxMatrix.h>
// Pins for LED MATRIX ESP8266
#include <Ticker.h>
Ticker display_ticker;
#define P_LAT 16
#define P_A 5
#define P_B 4
#define P_C 15
#define P_D 12
#define P_E 0
#define P_OE 2
#define matrix_width 64
#define matrix_height 64
// This defines the 'on' time of the display is us. The larger this number,
// the brighter the display. If too large the ESP will crash
uint8_t display_draw_time=20; //10-50 is usually fine
PxMATRIX display(64,64,P_LAT, P_OE,P_A,P_B,P_C,P_D,P_E);
// Some standard colors
uint16_t myRED = display.color565(255, 0, 0);
uint16_t myGREEN = display.color565(0, 255, 0);
uint16_t myBLUE = display.color565(0, 0, 255);
uint16_t myWHITE = display.color565(255, 255, 255);
uint16_t myYELLOW = display.color565(255, 255, 0);
uint16_t myCYAN = display.color565(0, 255, 255);
uint16_t myMAGENTA = display.color565(255, 0, 255);
uint16_t myBLACK = display.color565(0, 0, 0);
uint16_t myCOLORS[8]={myRED,myGREEN,myBLUE,myWHITE,myYELLOW,myCYAN,myMAGENTA,myBLACK};
uint8_t static weather_icons[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0xff,0xe0,0x00,0x00,0x00,0x00,0xff,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0x07,0xff,0x07,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x07,0xff,0x07,0xff,0x07,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,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,0x00,0x00,0x00,0x20,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0x00,0x00,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xe0,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,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0x07,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xdf,0x07,0xdf,0x07,0xdf,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x20,0x07,0xff,0x07,0xff,0x07,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0x00,0x00,0x00,0x00,0x07,0xff,0x07,0xff,0x07,0xdf,0x00,0x00,0x00,0x00,0x07,0xff,0x00,0x00,0x00,0x00,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0x00,0x00,0x00,0x00
,0x00,0x00,0x00,0x00,0xff,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xe0,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0xff,0xe0,0x00,0x00,0xff,0xe0,0xff,0xe0,0xff,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0x07,0xdf,0x07,0xff,0x07,0xff,0x07,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x00,0x00,0x00,0x00,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0x07,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0x07,0xff,0x00,0x00,0x00,0x00,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0x00,0x00,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0x00,0x00
,0x00,0x20,0x00,0x00,0x00,0x00,0xff,0xe0,0xff,0xe0,0xff,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0x07,0xff,0x07,0xff,0xff,0xe0,0xff,0xe0,0xff,0xe0,0x00,0x00,0xff,0xe0,0x00,0x00,0x07,0xff,0x07,0xff,0x07,0xdf,0x07,0xff,0x07,0xdf,0x07,0xff,0x07,0xff,0x00,0x00,0x00,0x00,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x00,0x00,0x00,0x00,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xdf,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x00,0x00,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xdf,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0x00,0x00,0x07,0xff,0x07,0xff,0x07,0xff,0x00,0x00,0x07,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0x00,0x00,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0x07,0xdf,0x07,0xdf,0x07,0xff,0xff,0xe0,0xff,0xe0,0x00,0x00
,0x00,0x00,0xff,0xe0,0x00,0x00,0xff,0xe0,0xff,0xe0,0xff,0xe0,0x00,0x00,0xff,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0x07,0xdf,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0xff,0xe0,0x00,0x20,0x00,0x00,0x07,0xdf,0x07,0xdf,0x07,0xdf,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x00,0x00,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x00,0x00,0x00,0x00,0x07,0xff,0x07,0xff,0x07,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xdf,0x07,0xdf,0x07,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0x00,0x00,0x00,0x00,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0xff,0xff,0x07,0xff,0x07,0xff,0x07,0xdf,0x07,0xff,0x00,0x00,0x07,0xff,0x00,0x00,0x00,0x00,0x07,0xff,0x07,0xff,0x07,0xdf,0x00,0x00,0x00,0x00,0x07,0xff,0x00,0x00,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0x00,0x00,0xff,0xe0,0xff,0xe0,0xff,0xe0,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xe0,0xff,0xe0,0xff,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xdf,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x00,0x00,0x00,0x00,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x00,0x00,0x00,0x00,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x07,0xff,0x00,0x20,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xdf,0x00,0x00,0x07,0xff,0x07,0xff,0x07,0xdf,0x00,0x00,0x07,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0x07,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0x07,0xdf,0x00,0x00,0x00,0x00,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0x00,0x00,0xff,0xe0,0xff,0xe0,0x07,0xdf,0x07,0xdf,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x00,0x00
,0x00,0x00,0x00,0x00,0xff,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x00,0x00,0x00,0x00,0xff,0xe0,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xe0,0x00,0x00,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0x00,0x00,0xff,0xe0,0xff,0xe0,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x00,0x00
,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xdf,0x07,0xdf,0x07,0xff,0x07,0xff,0x07,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x07,0xff,0x07,0xff,0x07,0xff,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0x00,0x00,0x00,0x00,0x07,0xff,0x07,0xdf,0x07,0xff,0x00,0x00,0x00,0x00,0x07,0xff,0x00,0x00,0x00,0x00,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xe0,0xff,0xe0,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,0x07,0xff,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,0x07,0xff,0x07,0xff,0x07,0xff,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x07,0xff,0x07,0xdf,0x07,0xdf,0x07,0xff,0x07,0xff,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,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,0xff,0xff,0x00,0x00,0xff,0xff,0x00,0x00,0x00,0x00,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0x07,0xdf,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xff,0x07,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xe0,0xff,0xe0,0x07,0xdf,0x07,0xff,0x07,0xff,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,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,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,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,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,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,0xff,0xe0,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,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,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
// ESP8266
// ISR for display refresh
void display_updater()
{
display.display(display_draw_time);
}
void display_update_enable(bool is_enable)
{
// ESP8266
if (is_enable)
display_ticker.attach(0.002, display_updater);
else
display_ticker.detach();
}
// Начало функции обработки кириллических символов
String utf8rus(String source) // Функция для конвертации русских символов из кодировки CP1251 в UTF8
{
int i,k;
String target;
unsigned char n;
char m[2] = { '0', '\0' };
k = source.length(); i = 0;
while (i < k) {
n = source[i]; i++;
if (n >= 0xBF){
switch (n) {
case 0xD0: {
n = source[i]; i++;
if (n == 0x81) { n = 0xA8; break; }
if (n >= 0x90 && n <= 0xBF) n = n + 0x2F;
break;
}
case 0xD1: {
n = source[i]; i++;
if (n == 0x91) { n = 0xB7; break; }
if (n >= 0x80 && n <= 0x8F) n = n + 0x6F;
break;
}
}
}
m[0] = n; target = target + String(m);
}
return target;
}
// Конец функции обработки кириллических симоволов
void setup() {
Serial.begin(9600);
// Define your display layout here, e.g. 1/8 step, and optional SPI pins begin(row_pattern, CLK, MOSI, MISO, SS)
display.begin(32);
display.setFastUpdate(true);
display.clearDisplay();
display.setTextColor(myCYAN);
display.setCursor(2,0);
display.print(utf8rus("РУССКИЙ АЛФАВИТ"));
display.setTextColor(myMAGENTA);
display.setCursor(2,25);
display.print("P3-32S-HL 1.2");
display_update_enable(true);
delay(5000);
}
union single_double{
uint8_t two[2];
uint16_t one;
} this_single_double;
// This draws the weather icons
void draw_weather_icon (uint8_t icon)
{
if (icon>10)
icon=10;
for (int yy=0; yy<10;yy++)
{
for (int xx=0; xx<10;xx++)
{
uint16_t byte_pos=(xx+icon*10)*2+yy*220;
this_single_double.two[1]=weather_icons[byte_pos];
this_single_double.two[0]=weather_icons[byte_pos+1];
display.drawPixel(1+xx,yy,this_single_double.one);
}
}
}
unsigned long last_draw=0;
void scroll_text(uint8_t ypos, unsigned long scroll_delay, String text, uint8_t colorR, uint8_t colorG, uint8_t colorB)
{
uint16_t text_length = text.length();
display.setTextWrap(false); // we don't wrap text so it scrolls nicely
display.setTextSize(3);
display.setRotation(0);
display.setTextColor(display.color565(colorR,colorG,colorB));
// Asuming 5 pixel average character width
for (int xpos=matrix_width; xpos>-(matrix_width+text_length*5); xpos--)
{
display.setTextColor(display.color565(colorR,colorG,colorB));
display.clearDisplay();
display.setCursor(xpos,ypos);
display.println(text);
delay(scroll_delay);
yield();
// This might smooth the transition a bit if we go slow
// display.setTextColor(display.color565(colorR/4,colorG/4,colorB/4));
// display.setCursor(xpos-1,ypos);
// display.println(text);
delay(scroll_delay/5);
yield();
}
}
uint8_t icon_index=0;
void loop() {
scroll_text(1,50,utf8rus("РУССКИЙ АЛФАВИТ"),96,96,50);
display.clearDisplay();
display.setTextSize(0);
display.setTextColor(myCYAN);
display.setCursor(2,0);
display.print(utf8rus("РУССКИЙ АЛФАВИТ"));
display.setTextColor(myMAGENTA);
display.setCursor(2,25);
display.print("P3-32S-HL 1.2");
display_update_enable(true);
delay(5000);
}
Не в сети
Не в сети
Не в сети
Не в сети
Для питания матрицы, использовал такой китайский миниUPS на 5В с одним аккумулятором 18650 на 3 А/ч.
https://aliexpress.ru/item/400105144779 … 1605147864
Можно использовать такой не дорогой БП.
https://aliexpress.ru/item/400106857927 … 1605147864
2А/5В, для дома будет вполне достаточно.
ESP32 тут покупал.
https://aliexpress.ru/item/400030808950 … 1605147864
Не в сети
Не в сети
Не в сети
Код.
#include "Arduino.h"
#include <ESPPerfectTime.h>
#include <TimeLib.h> // Time library https://github.com/PaulStoffregen/Time
#include <WiFi.h>
#include <WiFiUdp.h>
#include <ArduinoJson.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS_1 2//ВХОД DS18B20
OneWire oneWire_in(ONE_WIRE_BUS_1);
DallasTemperature sensor_inhouse(&oneWire_in);
#include <PxMatrix.h>
// Pins for LED MATRIX ESP32
#include <Ticker.h>
Ticker display_ticker;
#define P_LAT 22
#define P_A 19
#define P_B 23
#define P_C 18
#define P_D 5
#define P_E 15
#define P_OE 16
#define matrix_width 64
#define matrix_height 64
int iwifi=0;
int R=20;
int B=20;
int G=20;
float tempC =0;
float tempC1 =0;
float tempC11 =0;
float tempC12 =0;
uint8_t display_draw_time=20; //10-50 is usually fine
PxMATRIX display(64,64,P_LAT, P_OE,P_A,P_B,P_C,P_D,P_E);
// Some standard colors
uint16_t myRED = display.color565(255, 0, 0);
uint16_t myGREEN = display.color565(0, 255, 0);
uint16_t myBLUE = display.color565(0, 0, 255);
uint16_t myWHITE = display.color565(255, 255, 255);
uint16_t myYELLOW = display.color565(255, 255, 0);
uint16_t myCYAN = display.color565(0, 255, 255);
uint16_t myMAGENTA = display.color565(255, 0, 255);
uint16_t myBLACK = display.color565(0, 0, 0);
uint16_t myCOLORS[8]={myRED,myGREEN,myBLUE,myWHITE,myYELLOW,myCYAN,myMAGENTA,myBLACK};
// WiFi configuration
char ssid[] = "tele2"; // your network SSID (name)
char pass[] = "ta20242024"; // your network password
char pass1[] = "5K9S7Y8B875K9S7Y8B87";
char ssid1[] = "77777";
// NTP configuration
const char *ntpServerName = "pool.ntp.org";
const int timeZone = 0; // UTC
const int daylightOffset_sec = 3600; // DST offset in seconds
// Other variables and objects
WiFiClient wifiClient;
char timeZoneAbbreviation[10];
char timeZone_str[40];
time_t prevDisplay = 0; // when the digital clock was displayed
void display_updater()
{
display.display(display_draw_time);
}
void display_update_enable(bool is_enable)
{
// ESP8266
if (is_enable)
display_ticker.attach(0.002, display_updater);
else
display_ticker.detach();
}
// Начало функции обработки кириллических символов
String utf8rus(String source) // Функция для конвертации русских символов из кодировки CP1251 в UTF8
{
int i,k;
String target;
unsigned char n;
char m[2] = { '0', '\0' };
k = source.length(); i = 0;
while (i < k) {
n = source[i]; i++;
if (n >= 0xBF){
switch (n) {
case 0xD0: {
n = source[i]; i++;
if (n == 0x81) { n = 0xA8; break; }
if (n >= 0x90 && n <= 0xBF) n = n + 0x2F;
break;
}
case 0xD1: {
n = source[i]; i++;
if (n == 0x91) { n = 0xB7; break; }
if (n >= 0x80 && n <= 0x8F) n = n + 0x6F;
break;
}
}
}
m[0] = n; target = target + String(m);
}
return target;
}
// Конец функции обработки кириллических симоволов
void setup()///////////////////////////////////////////////////////////////////////////////////
{
Serial.begin(115200);
delay(500);
sensor_inhouse.begin();
delay(500);
// Define your display layout here, e.g. 1/8 step, and optional SPI pins begin(row_pattern, CLK, MOSI, MISO, SS)
display.begin(32);
delay(500);
display.setFastUpdate(true);
display.clearDisplay();
display.setTextColor(myCYAN);
display.setCursor(0,0);
// display.print(utf8rus("Температура воздуха"));
sensor_inhouse.requestTemperatures();
tempC = sensor_inhouse.getTempCByIndex(0);
if (tempC != DEVICE_DISCONNECTED_C){
display.setTextSize(2);
display.setTextColor(display.color565(0,0,20));
display.setCursor(2,0);
display.print(tempC);
}
display_update_enable(true);
// Connect to WiFi SSID
connectWiFi();
// Request http://worldtimeapi.org/api/ip
DynamicJsonDocument jsonDoc = httpJSONRequest(wifiClient, "worldtimeapi.org", "/api/ip");
strcpy(timeZoneAbbreviation, jsonDoc["abbreviation"]);
bool dst = jsonDoc["dst"]; // true
int dst_offset = jsonDoc["dst_offset"]; // 3600
strcpy(timeZone_str, jsonDoc["timezone"]);
const char* utc_offset = jsonDoc["utc_offset"]; // "+01:00"
// int week_number = jsonDoc["week_number"]; // 30
// convert UTC offset to signed float
float utc_offset_float = ((float)utc_offset[1] - 48) * 10 + ((float)utc_offset[2] - 48) + (((float)utc_offset[4] - 48) * 10 + ((float)utc_offset[5] - 48)) / 60.0;
if ((int)utc_offset[0] == 45) {
utc_offset_float *= -1;
}
Serial.println(timeZoneAbbreviation);
Serial.println(dst);
Serial.println(timeZone_str);
Serial.println(utc_offset);
Serial.println(utc_offset_float);
Serial.println("СЕТАП");
pftime::configTime(utc_offset_float * 3600, 0, ntpServerName);
}
/////////////////////////////////////////////END SETUP//////////////////////
union single_double{
uint8_t two[2];
uint16_t one;
} this_single_double;
unsigned long last_draw=0;
uint8_t icon_index=0;
///////////////////////////////////////////////////////////////////////////////////////////////
void temp()//////////функция обработки DS18B20/////////////////////////////////////////////////
{
display.setTextSize(2);
sensor_inhouse.requestTemperatures();
tempC = sensor_inhouse.getTempCByIndex(0);
if (tempC != DEVICE_DISCONNECTED_C)
{
}
else Serial.print("DEVICE1 ds18b20 DISCONNECTED");
sensor_inhouse.requestTemperatures();
tempC1 = sensor_inhouse.getTempCByIndex(0);
if (tempC1 !=tempC){
for (int y=24; y<38;y++)
{
display.drawLine(0,y,64,y,display.color565(0,0,0));
}
display.setTextSize(2);
display.setTextColor(display.color565(0,B,0));
display.setCursor(2,24);
display.print(tempC1);
}
}
////////////////////////////////////////////////////////////////////////////////////
void TIME()
{
if (now() != prevDisplay) { //update the display only if time has changed
// matrix.begin();//СТАРТ МАТРИЦЫ
prevDisplay = now();
// Get current local time as struct tm by calling pftime::localtime(nullptr)
struct tm *tm = pftime::localtime(nullptr);
// Get microseconds at the same time by passing suseconds_t* as 2nd argument
suseconds_t usec;
tm = pftime::localtime(nullptr, &usec);
// Get the time string
String dateString = getDateString(tm, usec);
String timeString = getTimeString(tm, usec);
// Print the time to serial
Serial.println(dateString + " | " + timeString + " " + timeZoneAbbreviation + " " + timeZone_str);
// if (WiFi.status() == WL_CONNECTED) WiFi.disconnect();
for (int y=0; y<23;y++)
{
display.drawLine(0,y,64,y,display.color565(0,0,0));
}
display.setTextSize(2);
display.setTextColor(display.color565(0,0,G));
display.setCursor(2,0);
display.print(timeString);
display.setTextSize(0);
display.setTextColor(display.color565(R,0,G));
display.setCursor(2,15);
display.print(dateString);
}
}
void loop()
{
TIME();
temp();
if (WiFi.status() == WL_CONNECTED){
delay(1000);
WiFi.disconnect();
}
// display.print(utf8rus("РУССКИЙ АЛФАВИТ"));
////////////////////////////////////////////////////////////////////////////////////////////////////////
}
void connectWiFi() {
WiFi.disconnect();
WiFi.mode(WIFI_MODE_STA);
WiFi.begin(ssid, pass);
Serial.print("\nConnecting to WiFi SSID " + String(ssid) + " ...");
while (WiFi.status() != WL_CONNECTED and iwifi<15) {
iwifi++;
Serial.print(".");
display.setTextSize(0);
display.setTextColor(display.color565(40,0,0));
display.setCursor(0,57);
display.print("WiFi - ");
display.print(iwifi);
delay(500);
display.setCursor(0,57);
display.print("WiFi - ");
display.setTextColor(display.color565(0,0,0));
display.print(iwifi);
}
display.clearDisplay();
Serial.println("\nConnected. ");
Serial.print("The IP number assigned by DHCP is ");
Serial.println(WiFi.localIP());
}
String getDateString(struct tm *tm, suseconds_t usec) {
char time_string[100];
sprintf(time_string, "%02d.%02d.%04d",
tm->tm_mday,
tm->tm_mon + 1,
tm->tm_year + 1900);
return time_string;
}
String getTimeString(struct tm *tm, suseconds_t usec) {
char time_string[100];
sprintf(time_string, "%02d:%02d",
tm->tm_hour,
tm->tm_min);
Serial.println(tm->tm_sec);
return time_string;
}
Не в сети
#include <WiFi.h>
DynamicJsonDocument httpJSONRequest(WiFiClient client, char *hostname, String endpoint) {
const size_t capacity = JSON_OBJECT_SIZE(15) + 350;
DynamicJsonDocument doc(capacity);
// Connect to HTTP server
client.setTimeout(10000);
if (!client.connect(hostname, 80)) {
Serial.println(F("Connection failed"));
return doc;
}
Serial.println(F("HTTP request client connected"));
// Send HTTP request
client.print(F("GET /"));
client.print(endpoint);
client.println(F(" HTTP/1.0"));
client.print(F("Host: "));
client.println(hostname);
client.println(F("Connection: close"));
if (client.println() == 0) {
Serial.println(F("Failed to send request"));
return doc;
}
// Check HTTP status
char status[32] = {0};
client.readBytesUntil('\r', status, sizeof(status));
// It should be "HTTP/1.0 200 OK" or "HTTP/1.1 200 OK"
if (strcmp(status + 9, "200 OK") != 0) {
Serial.print(F("Unexpected response: "));
Serial.println(status);
return doc;
}
// Skip HTTP headers
char endOfHeaders[] = "\r\n\r\n";
if (!client.find(endOfHeaders)) {
Serial.println(F("Invalid response"));
return doc;
}
// Parse the JSON response
deserializeJson(doc, client);
return doc;
}
Не в сети
/* http://worldtimeapi.org/api/ip
* {"abbreviation":"BST",
* "client_ip":"86.17.220.24",
* "datetime":"2020-07-25T14:51:01.689928+01:00",
* "day_of_week":6,
* "day_of_year":207,
* "dst":true,
* "dst_from":"2020-03-29T01:00:00+00:00",
* "dst_offset":3600,
* "dst_until":"2020-10-25T01:00:00+00:00",
* "raw_offset":0,
* "timezone":"Europe/London",
* "unixtime":1595685061,
* "utc_datetime":"2020-07-25T13:51:01.689928+00:00",
* "utc_offset":"+01:00",
* "week_number":30
* }
*/
//
//const size_t capacity = JSON_OBJECT_SIZE(15) + 350;
//DynamicJsonDocument doc(capacity);
//
//const char* json = "{\"abbreviation\":\"BST\",\"client_ip\":\"86.17.220.24\",\"datetime\":\"2020-07-25T14:51:01.689928+01:00\",\"day_of_week\":6,\"day_of_year\":207,\"dst\":true,\"dst_from\":\"2020-03-29T01:00:00+00:00\",\"dst_offset\":3600,\"dst_until\":\"2020-10-25T01:00:00+00:00\",\"raw_offset\":0,\"timezone\":\"Europe/London\",\"unixtime\":1595685061,\"utc_datetime\":\"2020-07-25T13:51:01.689928+00:00\",\"utc_offset\":\"+01:00\",\"week_number\":30}";
//
//deserializeJson(doc, json);
//
//const char* abbreviation = doc["abbreviation"]; // "BST"
//const char* client_ip = doc["client_ip"]; // "86.17.220.24"
//const char* datetime = doc["datetime"]; // "2020-07-25T14:51:01.689928+01:00"
//int day_of_week = doc["day_of_week"]; // 6
//int day_of_year = doc["day_of_year"]; // 207
//bool dst = doc["dst"]; // true
//const char* dst_from = doc["dst_from"]; // "2020-03-29T01:00:00+00:00"
//int dst_offset = doc["dst_offset"]; // 3600
//const char* dst_until = doc["dst_until"]; // "2020-10-25T01:00:00+00:00"
//int raw_offset = doc["raw_offset"]; // 0
//const char* timezone = doc["timezone"]; // "Europe/London"
//long unixtime = doc["unixtime"]; // 1595685061
//const char* utc_datetime = doc["utc_datetime"]; // "2020-07-25T13:51:01.689928+00:00"
//const char* utc_offset = doc["utc_offset"]; // "+01:00"
//int week_number = doc["week_number"]; // 30
Не в сети
Не в сети
Страницы 1