├── README.md ├── .gitattributes ├── libraries ├── GyverOLED │ ├── Image converter │ │ ├── ImageProcessor │ │ │ └── download.txt │ │ └── BITmaper (устарело) │ │ │ └── BITmaper.exe │ ├── library.properties │ ├── examples │ │ ├── drawBattery │ │ │ └── drawBattery.ino │ │ ├── OLD EXAMPLES │ │ │ ├── customFont │ │ │ │ └── customFont.ino │ │ │ ├── ball │ │ │ │ └── ball.ino │ │ │ ├── demo │ │ │ │ └── demo.ino │ │ │ ├── 3Dcube │ │ │ │ └── 3Dcube.ino │ │ │ └── bitmap_demo │ │ │ │ └── bitmap_demo.ino │ │ ├── bitmap_move_fast_nobuf │ │ │ └── bitmap_move_fast_nobuf.ino │ │ ├── bitmap_move_fast │ │ │ └── bitmap_move_fast.ino │ │ ├── graphics │ │ │ └── graphics.ino │ │ ├── graphics2 │ │ │ └── graphics2.ino │ │ ├── oledPrintTest │ │ │ └── oledPrintTest.ino │ │ └── bitmap_demo │ │ │ └── bitmap_demo.ino │ └── keywords.txt ├── Adafruit-GFX-Library │ ├── .gitignore │ ├── fontconvert │ │ ├── Makefile │ │ ├── makefonts.sh │ │ └── fontconvert_win.md │ ├── Adafruit_SPITFT_Macros.h │ ├── library.properties │ ├── .github │ │ ├── workflows │ │ │ └── githubci.yml │ │ ├── PULL_REQUEST_TEMPLATE.md │ │ └── ISSUE_TEMPLATE.md │ ├── gfxfont.h │ ├── license.txt │ ├── examples │ │ └── GFXcanvas │ │ │ ├── GFXcanvasSerialDemo.cpp │ │ │ ├── GFXcanvasSerialDemo.h │ │ │ └── GFXcanvas.ino │ ├── README.md │ ├── Adafruit_GrayOLED.h │ └── Fonts │ │ └── Tiny3x3a2pt7b.h ├── microWire │ ├── library.properties │ ├── keywords.txt │ ├── examples │ │ └── microWire_example │ │ │ └── microWire_example.ino │ ├── microWire.h │ └── microWire.cpp └── Adafruit-ST7735-Library-master │ ├── library.properties │ ├── README.txt │ ├── Adafruit_ST7735.h │ └── examples │ └── spitftbitmap │ └── spitftbitmap.ino ├── firmware ├── OLED │ ├── webcamOLED │ │ ├── microUART.h │ │ └── webcamOLED.ino │ └── webcamOLED_proc │ │ ├── webcamOLED_proc.pde │ │ ├── GUI.pde │ │ └── dither.pde ├── ST7735 │ ├── webcamST7735 │ │ ├── microUART.h │ │ └── webcamST7735.ino │ └── webcamST7735_proc │ │ ├── webcamST7735_proc.pde │ │ └── GUI.pde ├── MAX7219 │ ├── webcamMAX7219 │ │ ├── microUART.h │ │ ├── GyverGFX.h │ │ ├── webcamMAX7219.ino │ │ ├── FastIO.h │ │ ├── GyverMAX7219.h │ │ └── GyverGFX.cpp │ └── webcamMAX7219_proc │ │ ├── webcamMAX7219_proc.pde │ │ ├── GUI.pde │ │ ├── FastIO.h │ │ └── dither.pde ├── MAX7219_mux │ ├── webcamMAX7219_mux │ │ ├── microUART.h │ │ ├── GyverGFX.h │ │ ├── FastIO.h │ │ ├── webcamMAX7219_mux.ino │ │ ├── GyverGFX.cpp │ │ └── GyverMAX7219.h │ └── webcamMAX7219_proc_mux │ │ ├── webcamMAX7219_proc_mux.pde │ │ ├── GUI.pde │ │ └── dither.pde ├── telegram │ ├── FastIO.h │ ├── ESP8266TelegramBOT.h │ ├── telegram.ino │ └── GyverMAX7219.h ├── telegram3 │ ├── FastIO.h │ ├── GyverMAX7219.h │ └── telegram3.ino └── telegram4 │ ├── FastIO.h │ ├── GyverGFX.h │ ├── FastBot.h │ ├── GyverMAX7219.h │ ├── telegram4.ino │ └── charMap.h └── index.html /README.md: -------------------------------------------------------------------------------- 1 | # webcamStream 2 | 3 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /libraries/GyverOLED/Image converter/ImageProcessor/download.txt: -------------------------------------------------------------------------------- 1 | https://github.com/AlexGyver/imageProcessor -------------------------------------------------------------------------------- /libraries/Adafruit-GFX-Library/.gitignore: -------------------------------------------------------------------------------- 1 | default.vim 2 | fontconvert/fontconvert 3 | # Our handy .gitignore for automation ease 4 | Doxyfile* 5 | doxygen_sqlite3.db 6 | html -------------------------------------------------------------------------------- /libraries/GyverOLED/Image converter/BITmaper (устарело)/BITmaper.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AlexGyver/webcamStream/HEAD/libraries/GyverOLED/Image converter/BITmaper (устарело)/BITmaper.exe -------------------------------------------------------------------------------- /libraries/microWire/library.properties: -------------------------------------------------------------------------------- 1 | name=microWire 2 | version=2.1 3 | author=AlexGyver 4 | maintainer=AlexGyver 5 | sentence=Light library for I2C communication. 6 | paragraph=Very light. 7 | category=Other 8 | url=https://github.com/AlexGyver/GyverLibs 9 | architectures=* -------------------------------------------------------------------------------- /libraries/Adafruit-GFX-Library/fontconvert/Makefile: -------------------------------------------------------------------------------- 1 | all: fontconvert 2 | 3 | CC = gcc 4 | CFLAGS = -Wall -I/usr/local/include/freetype2 -I/usr/include/freetype2 -I/usr/include 5 | LIBS = -lfreetype 6 | 7 | fontconvert: fontconvert.c 8 | $(CC) $(CFLAGS) $< $(LIBS) -o $@ 9 | strip $@ 10 | 11 | clean: 12 | rm -f fontconvert 13 | -------------------------------------------------------------------------------- /libraries/Adafruit-GFX-Library/Adafruit_SPITFT_Macros.h: -------------------------------------------------------------------------------- 1 | // THIS FILE INTENTIONALLY LEFT BLANK. 2 | 3 | // Macros previously #defined here have been made into (mostly) inline 4 | // functions in the Adafruit_SPITFT class. Other libraries might still 5 | // contain code trying to #include this header file, so until everything's 6 | // updated this file still exists (but doing nothing) to avoid trouble. 7 | -------------------------------------------------------------------------------- /libraries/GyverOLED/library.properties: -------------------------------------------------------------------------------- 1 | name=GyverOLED 2 | version=1.0 3 | author=AlexGyver 4 | maintainer=AlexGyver 5 | sentence=Fast and light library for OLED display on SSD1306. 6 | paragraph=Allows to control OLED without software buffer: drawing and typing text. 7 | category=Display 8 | url=https://github.com/AlexGyver/GyverLibs 9 | architectures=* 10 | -------------------------------------------------------------------------------- /libraries/Adafruit-ST7735-Library-master/library.properties: -------------------------------------------------------------------------------- 1 | name=Adafruit ST7735 Library 2 | version=1.0.0 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=This is a library for the Adafruit 1.8" SPI displays. 6 | paragraph=This is a library for the Adafruit 1.8" SPI displays. 7 | category=Display 8 | url=https://github.com/adafruit/Adafruit-ST7735-Library 9 | architectures=* 10 | -------------------------------------------------------------------------------- /libraries/Adafruit-GFX-Library/library.properties: -------------------------------------------------------------------------------- 1 | name=Adafruit GFX Library 2 | version=1.10.6 3 | author=Adafruit 4 | maintainer=Adafruit 5 | sentence=Adafruit GFX graphics core library, this is the 'core' class that all our other graphics libraries derive from. 6 | paragraph=Install this library in addition to the display library for your hardware. 7 | category=Display 8 | url=https://github.com/adafruit/Adafruit-GFX-Library 9 | architectures=* 10 | depends=Adafruit BusIO 11 | -------------------------------------------------------------------------------- /firmware/OLED/webcamOLED/microUART.h: -------------------------------------------------------------------------------- 1 | #ifndef microUART_h 2 | #define microUART_h 3 | class microUART { 4 | public: 5 | void begin(uint32_t baudrate) { 6 | UBRR0 = (F_CPU / (8L * baudrate)) - 1; 7 | UCSR0A = (1 << U2X0); 8 | UCSR0B = (1 << TXEN0) | (1 << RXEN0); 9 | UCSR0C = (1 << UCSZ01) | (1 << UCSZ00); 10 | } 11 | void write(byte data) { 12 | while (!(UCSR0A & (1 << UDRE0))); 13 | UDR0 = data; 14 | } 15 | bool available() { 16 | return (UCSR0A & (1 << RXC0)); 17 | } 18 | byte read() { 19 | byte data = UDR0; 20 | return data; 21 | } 22 | void end() { 23 | UCSR0B = 0; 24 | } 25 | private: 26 | }; 27 | #endif -------------------------------------------------------------------------------- /firmware/ST7735/webcamST7735/microUART.h: -------------------------------------------------------------------------------- 1 | #ifndef microUART_h 2 | #define microUART_h 3 | class microUART { 4 | public: 5 | void begin(uint32_t baudrate) { 6 | UBRR0 = (F_CPU / (8L * baudrate)) - 1; 7 | UCSR0A = (1 << U2X0); 8 | UCSR0B = (1 << TXEN0) | (1 << RXEN0); 9 | UCSR0C = (1 << UCSZ01) | (1 << UCSZ00); 10 | } 11 | void write(byte data) { 12 | while (!(UCSR0A & (1 << UDRE0))); 13 | UDR0 = data; 14 | } 15 | bool available() { 16 | return (UCSR0A & (1 << RXC0)); 17 | } 18 | byte read() { 19 | byte data = UDR0; 20 | return data; 21 | } 22 | void end() { 23 | UCSR0B = 0; 24 | } 25 | private: 26 | }; 27 | #endif -------------------------------------------------------------------------------- /firmware/MAX7219/webcamMAX7219/microUART.h: -------------------------------------------------------------------------------- 1 | #ifndef microUART_h 2 | #define microUART_h 3 | class microUART { 4 | public: 5 | void begin(uint32_t baudrate) { 6 | UBRR0 = (F_CPU / (8L * baudrate)) - 1; 7 | UCSR0A = (1 << U2X0); 8 | UCSR0B = (1 << TXEN0) | (1 << RXEN0); 9 | UCSR0C = (1 << UCSZ01) | (1 << UCSZ00); 10 | } 11 | void write(byte data) { 12 | while (!(UCSR0A & (1 << UDRE0))); 13 | UDR0 = data; 14 | } 15 | bool available() { 16 | return (UCSR0A & (1 << RXC0)); 17 | } 18 | byte read() { 19 | byte data = UDR0; 20 | return data; 21 | } 22 | void end() { 23 | UCSR0B = 0; 24 | } 25 | private: 26 | }; 27 | #endif -------------------------------------------------------------------------------- /firmware/MAX7219_mux/webcamMAX7219_mux/microUART.h: -------------------------------------------------------------------------------- 1 | #ifndef microUART_h 2 | #define microUART_h 3 | class microUART { 4 | public: 5 | void begin(uint32_t baudrate) { 6 | UBRR0 = (F_CPU / (8L * baudrate)) - 1; 7 | UCSR0A = (1 << U2X0); 8 | UCSR0B = (1 << TXEN0) | (1 << RXEN0); 9 | UCSR0C = (1 << UCSZ01) | (1 << UCSZ00); 10 | } 11 | void write(byte data) { 12 | while (!(UCSR0A & (1 << UDRE0))); 13 | UDR0 = data; 14 | } 15 | bool available() { 16 | return (UCSR0A & (1 << RXC0)); 17 | } 18 | byte read() { 19 | byte data = UDR0; 20 | return data; 21 | } 22 | void end() { 23 | UCSR0B = 0; 24 | } 25 | private: 26 | }; 27 | #endif 28 | -------------------------------------------------------------------------------- /libraries/microWire/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For microWire 3 | ####################################### 4 | ####################################### 5 | # Datatypes (KEYWORD1) 6 | ####################################### 7 | microWire KEYWORD1 8 | ####################################### 9 | # Methods and Functions (KEYWORD2) 10 | ####################################### 11 | begin KEYWORD2 12 | setClock KEYWORD2 13 | beginTransmission KEYWORD2 14 | endTransmission KEYWORD2 15 | write KEYWORD2 16 | read KEYWORD2 17 | requestFrom KEYWORD2 18 | available KEYWORD2 19 | ####################################### 20 | # Constants (LITERAL1) 21 | ####################################### 22 | 23 | -------------------------------------------------------------------------------- /firmware/OLED/webcamOLED/webcamOLED.ino: -------------------------------------------------------------------------------- 1 | #define USE_MICRO_WIRE 2 | #include 3 | GyverOLED oled; 4 | #include "microUART.h" 5 | microUART uart; 6 | bool startup = false; 7 | 8 | void setup() { 9 | uart.begin(500000); 10 | oled.init(); 11 | Wire.setClock(800000); 12 | oled.sendCommand(OLED_ADDRESSING_MODE, OLED_HORIZONTAL); 13 | oled.clear(); 14 | } 15 | 16 | void loop() { 17 | if (uart.available()) { // если есть что на приём 18 | byte data = uart.read(); // прочитать 19 | if (data == 1) { // синхронизация 20 | if (!startup) oled.endData(); 21 | startup = 1; 22 | oled.setWindow(0, 0, 127, 7); 23 | oled.beginData(); 24 | } else { 25 | if (startup) oled.writeOptimised(data); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /libraries/GyverOLED/examples/drawBattery/drawBattery.ino: -------------------------------------------------------------------------------- 1 | #include 2 | GyverOLED oled; 3 | // можно передать адрес: GyverOLED oled(0x3C); 4 | 5 | void setup() { 6 | oled.init(); // инициализация 7 | oled.clear(); 8 | } 9 | 10 | void loop() { 11 | for (byte i = 0; i < 100; i += 5) { 12 | oled.setCursorXY(0, 0); 13 | drawBattery(i); 14 | delay(50); 15 | } 16 | for (int i = 100; i > 0; i -= 5) { 17 | oled.setCursorXY(0, 0); 18 | drawBattery(i); 19 | delay(50); 20 | } 21 | } 22 | 23 | void drawBattery(byte percent) { 24 | oled.drawByte(0b00111100); // пипка 25 | oled.drawByte(0b00111100); 26 | oled.drawByte(0b11111111); // стенка 27 | for (byte i = 0; i < (100 - percent) / 8; i++) oled.drawByte(0b10000001); 28 | for (byte i = 0; i < (percent) / 8; i++) oled.drawByte(0b11111111); 29 | oled.drawByte(0b11111111); // попка 30 | } 31 | -------------------------------------------------------------------------------- /firmware/MAX7219/webcamMAX7219/GyverGFX.h: -------------------------------------------------------------------------------- 1 | #ifndef GyverGFX_h 2 | #define GyverGFX_h 3 | #include 4 | 5 | #define GFX_CLEAR 0 6 | #define GFX_FILL 1 7 | #define GFX_STROKE 2 8 | #define GFX_SWAP(x,y) if (x > y) x = x ^ y ^ (y = x); 9 | 10 | class GyverGFX { 11 | public: 12 | virtual void dot(int x, int y, uint8_t fill = 1); 13 | void fastLineH(int y, int x0, int x1, uint8_t fill = 1); 14 | void fastLineV(int x, int y0, int y1, uint8_t fill = 1); 15 | void line(int x0, int y0, int x1, int y1, uint8_t fill = 1); 16 | void rect(int x0, int y0, int x1, int y1, uint8_t fill = GFX_STROKE); 17 | void roundRect(int x0, int y0, int x1, int y1, uint8_t fill = GFX_STROKE); 18 | void circle(int x, int y, int radius, uint8_t fill = 0); 19 | void bezier(uint8_t* arr, uint8_t size, uint8_t dense, uint8_t fill = 1); 20 | void bezier16(int* arr, uint8_t size, uint8_t dense, uint8_t fill = 1); 21 | private: 22 | }; 23 | #endif 24 | -------------------------------------------------------------------------------- /firmware/MAX7219_mux/webcamMAX7219_mux/GyverGFX.h: -------------------------------------------------------------------------------- 1 | #ifndef GyverGFX_h 2 | #define GyverGFX_h 3 | #include 4 | 5 | #define GFX_CLEAR 0 6 | #define GFX_FILL 1 7 | #define GFX_STROKE 2 8 | #define GFX_SWAP(x,y) if (x > y) x = x ^ y ^ (y = x); 9 | 10 | class GyverGFX { 11 | public: 12 | virtual void dot(int x, int y, uint8_t fill = 1); 13 | void fastLineH(int y, int x0, int x1, uint8_t fill = 1); 14 | void fastLineV(int x, int y0, int y1, uint8_t fill = 1); 15 | void line(int x0, int y0, int x1, int y1, uint8_t fill = 1); 16 | void rect(int x0, int y0, int x1, int y1, uint8_t fill = GFX_STROKE); 17 | void roundRect(int x0, int y0, int x1, int y1, uint8_t fill = GFX_STROKE); 18 | void circle(int x, int y, int radius, uint8_t fill = 0); 19 | void bezier(uint8_t* arr, uint8_t size, uint8_t dense, uint8_t fill = 1); 20 | void bezier16(int* arr, uint8_t size, uint8_t dense, uint8_t fill = 1); 21 | private: 22 | }; 23 | #endif 24 | -------------------------------------------------------------------------------- /libraries/GyverOLED/examples/OLD EXAMPLES/customFont/customFont.ino: -------------------------------------------------------------------------------- 1 | // Пример GyverOLED. Смотри документацию на http://alexgyver.ru/gyveroled/ 2 | #define OLED_SOFT_BUFFER_64 // использовать буфер на стороне микроконтроллера 3 | #define OLED_EXTFONTS // указываем, что используются расширенные шрифты 4 | 5 | #include 6 | GyverOLED oled; 7 | // можно передать адрес: GyverOLED oled(0x3C); 8 | 9 | extern uint8_t ExtFont8x12[]; // подключаем шрифт 10 | //extern uint8_t ExtFont8x13[]; 11 | /* 12 | на выбор: 13 | ExtFont8x12 14 | ExtFont8x13 15 | ExtFont8x13OnlyRus 16 | ExtFont8x14 17 | ExtFont8x14B 18 | */ 19 | 20 | void setup() { 21 | oled.init(OLED128x64); 22 | oled.clear(); 23 | oled.home(); 24 | 25 | // устанавливаем шрифт в качестве текущего 26 | // можно подключить (выше где extern) несколько и переключаться между ними 27 | oled.setFont(ExtFont8x12); 28 | 29 | oled.print("Peace! Миру мир!"); 30 | oled.print("Папа у Васи силён в математике! Учится папа за Васю весь год."); 31 | oled.update(); 32 | } 33 | 34 | void loop() { 35 | } 36 | -------------------------------------------------------------------------------- /libraries/Adafruit-GFX-Library/.github/workflows/githubci.yml: -------------------------------------------------------------------------------- 1 | name: Arduino Library CI 2 | 3 | on: [pull_request, push, repository_dispatch] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - uses: actions/setup-python@v1 11 | with: 12 | python-version: '3.x' 13 | - uses: actions/checkout@v2 14 | - uses: actions/checkout@v2 15 | with: 16 | repository: adafruit/ci-arduino 17 | path: ci 18 | 19 | - name: pre-install 20 | run: bash ci/actions_install.sh 21 | 22 | - name: extra libraries 23 | run: | 24 | git clone --quiet https://github.com/adafruit/Adafruit_ILI9341.git /home/runner/Arduino/libraries/Adafruit_ILI9341 25 | 26 | - name: test platforms 27 | run: python3 ci/build_platform.py main_platforms 28 | 29 | - name: clang 30 | run: python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" -r . 31 | 32 | - name: doxygen 33 | env: 34 | GH_REPO_TOKEN: ${{ secrets.GH_REPO_TOKEN }} 35 | PRETTYNAME : "Adafruit GFX Library" 36 | run: bash ci/doxy_gen_and_deploy.sh 37 | -------------------------------------------------------------------------------- /firmware/MAX7219/webcamMAX7219/webcamMAX7219.ino: -------------------------------------------------------------------------------- 1 | #define MAX_SPI_SPEED 500000 2 | #include "GyverMAX7219.h" 3 | 4 | // CLK 13, DAT 11 5 | #define AM_W 4 6 | #define AM_H 2 7 | MAX7219<9, AM_W, AM_H, 0> mtrx; // CS, W, H, buf 8 | 9 | #include "microUART.h" 10 | microUART uart; 11 | 12 | void setup() { 13 | uart.begin(100000); 14 | mtrx.begin(); 15 | mtrx.setBright(0); 16 | /* 17 | for (;;) { 18 | mtrx.begin(); 19 | mtrx.restartStream(); 20 | for (int i = 0; i < AM_W * AM_H * 8; i++) { 21 | mtrx.nextByte(0b00011000); 22 | delayMicroseconds(1000); 23 | } 24 | mtrx.restartStream(); 25 | for (int i = 0; i < AM_W * AM_H * 8; i++) { 26 | mtrx.nextByte(0); 27 | delayMicroseconds(1000); 28 | } 29 | mtrx.clear(); 30 | } 31 | */ 32 | } 33 | byte counter = 0; 34 | void loop() { 35 | if (uart.available()) { // если есть что на приём 36 | byte data = uart.read(); // прочитать 37 | if (data == 1) { 38 | mtrx.restartStream(); 39 | if (!(++counter & 0b111)) mtrx.begin(); 40 | } 41 | else if (counter & 0b111) mtrx.nextByte(data); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /libraries/GyverOLED/examples/OLD EXAMPLES/ball/ball.ino: -------------------------------------------------------------------------------- 1 | // Пример GyverOLED. Смотри документацию на http://alexgyver.ru/gyveroled/ 2 | // пример со скачущим шариком 3 | 4 | #define OLED_SOFT_BUFFER_64 // использовать буфер для 128x64 на стороне микроконтроллера 5 | #include 6 | GyverOLED oled; 7 | // можно передать адрес: GyverOLED oled(0x3C); 8 | 9 | void setup() { 10 | oled.init(OLED128x64); // инициализация, указываем размер 11 | oled.setContrast(1); // яркость 12 | oled.clear(); // очистить 13 | } 14 | 15 | void loop() { 16 | static byte ballSize = 10; 17 | static int posX = 50, posY = 50; 18 | static int velX = 5, velY = 3; 19 | 20 | oled.clear(); 21 | oled.circle(posX, posY, ballSize, false); 22 | oled.update(); 23 | posX += velX; 24 | posY += velY; 25 | if (posX < ballSize) { 26 | velX = -velX; 27 | posX = ballSize; 28 | } 29 | if (posX > 128 - ballSize - 1) { 30 | velX = -velX; 31 | posX = 128 - ballSize; 32 | } 33 | if (posY < ballSize) { 34 | velY = -velY; 35 | posY = ballSize; 36 | } 37 | if (posY > 64 - ballSize - 1) { 38 | velY = -velY; 39 | posY = 64 - ballSize; 40 | } 41 | delay(40); 42 | } 43 | -------------------------------------------------------------------------------- /libraries/Adafruit-GFX-Library/gfxfont.h: -------------------------------------------------------------------------------- 1 | // Font structures for newer Adafruit_GFX (1.1 and later). 2 | // Example fonts are included in 'Fonts' directory. 3 | // To use a font in your Arduino sketch, #include the corresponding .h 4 | // file and pass address of GFXfont struct to setFont(). Pass NULL to 5 | // revert to 'classic' fixed-space bitmap font. 6 | 7 | #ifndef _GFXFONT_H_ 8 | #define _GFXFONT_H_ 9 | 10 | /// Font data stored PER GLYPH 11 | typedef struct { 12 | uint16_t bitmapOffset; ///< Pointer into GFXfont->bitmap 13 | uint8_t width; ///< Bitmap dimensions in pixels 14 | uint8_t height; ///< Bitmap dimensions in pixels 15 | uint8_t xAdvance; ///< Distance to advance cursor (x axis) 16 | int8_t xOffset; ///< X dist from cursor pos to UL corner 17 | int8_t yOffset; ///< Y dist from cursor pos to UL corner 18 | } GFXglyph; 19 | 20 | /// Data stored for FONT AS A WHOLE 21 | typedef struct { 22 | uint8_t *bitmap; ///< Glyph bitmaps, concatenated 23 | GFXglyph *glyph; ///< Glyph array 24 | uint16_t first; ///< ASCII extents (first char) 25 | uint16_t last; ///< ASCII extents (last char) 26 | uint8_t yAdvance; ///< Newline distance (y axis) 27 | } GFXfont; 28 | 29 | #endif // _GFXFONT_H_ 30 | -------------------------------------------------------------------------------- /libraries/Adafruit-ST7735-Library-master/README.txt: -------------------------------------------------------------------------------- 1 | This is a library for the Adafruit 1.8" SPI display. 2 | This library works with the Adafruit 1.8" TFT Breakout w/SD card 3 | ----> http://www.adafruit.com/products/358 4 | The 1.8" TFT shield 5 | ----> https://www.adafruit.com/product/802 6 | The 1.44" TFT breakout 7 | ----> https://www.adafruit.com/product/2088 8 | as well as Adafruit raw 1.8" TFT display 9 | ----> http://www.adafruit.com/products/618 10 | 11 | 12 | Check out the links above for our tutorials and wiring diagrams. 13 | These displays use SPI to communicate, 4 or 5 pins are required 14 | to interface (RST is optional). 15 | Adafruit invests time and resources providing this open source code, 16 | please support Adafruit and open-source hardware by purchasing 17 | products from Adafruit! 18 | 19 | Written by Limor Fried/Ladyada for Adafruit Industries. 20 | MIT license, all text above must be included in any redistribution 21 | 22 | To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder Adafruit_ST7735. Check that the Adafruit_ST7735 folder contains Adafruit_ST7735.cpp and Adafruit_ST7735. 23 | 24 | Place the Adafruit_ST7735 library folder your /libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE 25 | 26 | Also requires the Adafruit_GFX library for Arduino. 27 | -------------------------------------------------------------------------------- /libraries/Adafruit-GFX-Library/fontconvert/makefonts.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Ugly little Bash script, generates a set of .h files for GFX using 4 | # GNU FreeFont sources. There are three fonts: 'Mono' (Courier-like), 5 | # 'Sans' (Helvetica-like) and 'Serif' (Times-like); four styles: regular, 6 | # bold, oblique or italic, and bold+oblique or bold+italic; and four 7 | # sizes: 9, 12, 18 and 24 point. No real error checking or anything, 8 | # this just powers through all the combinations, calling the fontconvert 9 | # utility and redirecting the output to a .h file for each combo. 10 | 11 | # Adafruit_GFX repository does not include the source outline fonts 12 | # (huge zipfile, different license) but they're easily acquired: 13 | # http://savannah.gnu.org/projects/freefont/ 14 | 15 | convert=./fontconvert 16 | inpath=~/Desktop/freefont/ 17 | outpath=../Fonts/ 18 | fonts=(FreeMono FreeSans FreeSerif) 19 | styles=("" Bold Italic BoldItalic Oblique BoldOblique) 20 | sizes=(9 12 18 24) 21 | 22 | for f in ${fonts[*]} 23 | do 24 | for index in ${!styles[*]} 25 | do 26 | st=${styles[$index]} 27 | for si in ${sizes[*]} 28 | do 29 | infile=$inpath$f$st".ttf" 30 | if [ -f $infile ] # Does source combination exist? 31 | then 32 | outfile=$outpath$f$st$si"pt7b.h" 33 | # printf "%s %s %s > %s\n" $convert $infile $si $outfile 34 | $convert $infile $si > $outfile 35 | fi 36 | done 37 | done 38 | done 39 | -------------------------------------------------------------------------------- /libraries/Adafruit-GFX-Library/license.txt: -------------------------------------------------------------------------------- 1 | Software License Agreement (BSD License) 2 | 3 | Copyright (c) 2012 Adafruit Industries. All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | - Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | - Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /libraries/GyverOLED/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For GyverOLED 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | GyverOLED KEYWORD1 9 | 10 | ####################################### 11 | # Methods and Functions (KEYWORD2) 12 | ####################################### 13 | init KEYWORD2 14 | clear KEYWORD2 15 | setContrast KEYWORD2 16 | flipH KEYWORD2 17 | flipV KEYWORD2 18 | setScale KEYWORD2 19 | invertText KEYWORD2 20 | invertDisplay KEYWORD2 21 | autoPrintln KEYWORD2 22 | 23 | home KEYWORD2 24 | setCursor KEYWORD2 25 | setCursorXY KEYWORD2 26 | 27 | dot KEYWORD2 28 | line KEYWORD2 29 | rect KEYWORD2 30 | roundRect KEYWORD2 31 | circle KEYWORD2 32 | fill KEYWORD2 33 | drawByte KEYWORD2 34 | drawBitmap KEYWORD2 35 | 36 | update KEYWORD2 37 | createBuf KEYWORD2 38 | sendBuf KEYWORD2 39 | 40 | ####################################### 41 | # Constants (LITERAL1) 42 | ####################################### 43 | SSD1306_128x32 LITERAL1 44 | SSD1306_128x64 LITERAL1 45 | SSH1106_128x64 LITERAL1 46 | 47 | OLED_BUFFER LITERAL1 48 | OLED_NO_BUFFER LITERAL1 49 | 50 | OLED_STROKE LITERAL1 51 | OLED_FILL LITERAL1 52 | OLED_CLEAR LITERAL1 53 | OLED_INVERT LITERAL1 54 | 55 | BUF_ADD LITERAL1 56 | BUF_SUBTRACT LITERAL1 57 | BUF_REPLACE LITERAL1 58 | 59 | BITMAP_NORMAL LITERAL1 60 | BITMAP_INVERT LITERAL1 61 | 62 | USE_MICRO_WIRE LITERAL1 -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Drawer 6 | 7 | 8 | Generate image as array from selected checkboxes
9 | 10 | 11 | 12 | 13 | 14 |
15 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /libraries/Adafruit-GFX-Library/.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thank you for creating a pull request to contribute to Adafruit's GitHub code! 2 | Before you open the request please review the following guidelines and tips to 3 | help it be more easily integrated: 4 | 5 | - **Describe the scope of your change--i.e. what the change does and what parts 6 | of the code were modified.** This will help us understand any risks of integrating 7 | the code. 8 | 9 | - **Describe any known limitations with your change.** For example if the change 10 | doesn't apply to a supported platform of the library please mention it. 11 | 12 | - **Please run any tests or examples that can exercise your modified code.** We 13 | strive to not break users of the code and running tests/examples helps with this 14 | process. 15 | 16 | Thank you again for contributing! We will try to test and integrate the change 17 | as soon as we can, but be aware we have many GitHub repositories to manage and 18 | can't immediately respond to every request. There is no need to bump or check in 19 | on a pull request (it will clutter the discussion of the request). 20 | 21 | Also don't be worried if the request is closed or not integrated--sometimes the 22 | priorities of Adafruit's GitHub code (education, ease of use) might not match the 23 | priorities of the pull request. Don't fret, the open source community thrives on 24 | forks and GitHub makes it easy to keep your changes in a forked repo. 25 | 26 | After reviewing the guidelines above you can delete this text from the pull request. 27 | -------------------------------------------------------------------------------- /firmware/telegram/FastIO.h: -------------------------------------------------------------------------------- 1 | #ifndef FastIO_h 2 | #define FastIO_h 3 | // быстрый IO, v1.0 4 | 5 | // быстрое чтение пина 6 | bool fastRead(const uint8_t pin) { 7 | #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__) 8 | if (pin < 8) return bitRead(PIND, pin); 9 | else if (pin < 14) return bitRead(PINB, pin - 8); 10 | else if (pin < 20) return bitRead(PINC, pin - 14); 11 | 12 | #elif defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny13__) 13 | return bitRead(PINB, pin); 14 | 15 | #elif defined(AVR) 16 | uint8_t *_pin_reg = portInputRegister(digitalPinToPort(pin)); 17 | uint8_t _bit_mask = digitalPinToBitMask(pin); 18 | return bool(*_pin_reg & _bit_mask); 19 | 20 | #else 21 | return digitalRead(pin); 22 | 23 | #endif 24 | return 0; 25 | } 26 | 27 | // быстрая запись 28 | void fastWrite(const uint8_t pin, bool val) { 29 | #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__) 30 | if (pin < 8) bitWrite(PORTD, pin, val); 31 | else if (pin < 14) bitWrite(PORTB, (pin - 8), val); 32 | else if (pin < 20) bitWrite(PORTC, (pin - 14), val); 33 | 34 | #elif defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny13__) 35 | bitWrite(PORTB, pin, val); 36 | 37 | #elif defined(AVR) 38 | uint8_t *_port_reg = portInputRegister(digitalPinToPort(pin)); 39 | uint8_t _bit_mask = digitalPinToBitMask(pin); 40 | _port_reg = portOutputRegister(digitalPinToPort(pin)); 41 | _bit_mask = digitalPinToBitMask(pin); 42 | if (val) *_port_reg |= _bit_mask; // HIGH 43 | else *_port_reg &= ~_bit_mask; // LOW 44 | 45 | #else 46 | digitalWrite(pin, val); 47 | 48 | #endif 49 | } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /firmware/telegram3/FastIO.h: -------------------------------------------------------------------------------- 1 | #ifndef FastIO_h 2 | #define FastIO_h 3 | // быстрый IO, v1.0 4 | 5 | // быстрое чтение пина 6 | bool fastRead(const uint8_t pin) { 7 | #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__) 8 | if (pin < 8) return bitRead(PIND, pin); 9 | else if (pin < 14) return bitRead(PINB, pin - 8); 10 | else if (pin < 20) return bitRead(PINC, pin - 14); 11 | 12 | #elif defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny13__) 13 | return bitRead(PINB, pin); 14 | 15 | #elif defined(AVR) 16 | uint8_t *_pin_reg = portInputRegister(digitalPinToPort(pin)); 17 | uint8_t _bit_mask = digitalPinToBitMask(pin); 18 | return bool(*_pin_reg & _bit_mask); 19 | 20 | #else 21 | return digitalRead(pin); 22 | 23 | #endif 24 | return 0; 25 | } 26 | 27 | // быстрая запись 28 | void fastWrite(const uint8_t pin, bool val) { 29 | #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__) 30 | if (pin < 8) bitWrite(PORTD, pin, val); 31 | else if (pin < 14) bitWrite(PORTB, (pin - 8), val); 32 | else if (pin < 20) bitWrite(PORTC, (pin - 14), val); 33 | 34 | #elif defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny13__) 35 | bitWrite(PORTB, pin, val); 36 | 37 | #elif defined(AVR) 38 | uint8_t *_port_reg = portInputRegister(digitalPinToPort(pin)); 39 | uint8_t _bit_mask = digitalPinToBitMask(pin); 40 | _port_reg = portOutputRegister(digitalPinToPort(pin)); 41 | _bit_mask = digitalPinToBitMask(pin); 42 | if (val) *_port_reg |= _bit_mask; // HIGH 43 | else *_port_reg &= ~_bit_mask; // LOW 44 | 45 | #else 46 | digitalWrite(pin, val); 47 | 48 | #endif 49 | } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /firmware/telegram4/FastIO.h: -------------------------------------------------------------------------------- 1 | #ifndef FastIO_h 2 | #define FastIO_h 3 | // быстрый IO, v1.0 4 | 5 | // быстрое чтение пина 6 | bool fastRead(const uint8_t pin) { 7 | #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__) 8 | if (pin < 8) return bitRead(PIND, pin); 9 | else if (pin < 14) return bitRead(PINB, pin - 8); 10 | else if (pin < 20) return bitRead(PINC, pin - 14); 11 | 12 | #elif defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny13__) 13 | return bitRead(PINB, pin); 14 | 15 | #elif defined(AVR) 16 | uint8_t *_pin_reg = portInputRegister(digitalPinToPort(pin)); 17 | uint8_t _bit_mask = digitalPinToBitMask(pin); 18 | return bool(*_pin_reg & _bit_mask); 19 | 20 | #else 21 | return digitalRead(pin); 22 | 23 | #endif 24 | return 0; 25 | } 26 | 27 | // быстрая запись 28 | void fastWrite(const uint8_t pin, bool val) { 29 | #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__) 30 | if (pin < 8) bitWrite(PORTD, pin, val); 31 | else if (pin < 14) bitWrite(PORTB, (pin - 8), val); 32 | else if (pin < 20) bitWrite(PORTC, (pin - 14), val); 33 | 34 | #elif defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny13__) 35 | bitWrite(PORTB, pin, val); 36 | 37 | #elif defined(AVR) 38 | uint8_t *_port_reg = portInputRegister(digitalPinToPort(pin)); 39 | uint8_t _bit_mask = digitalPinToBitMask(pin); 40 | _port_reg = portOutputRegister(digitalPinToPort(pin)); 41 | _bit_mask = digitalPinToBitMask(pin); 42 | if (val) *_port_reg |= _bit_mask; // HIGH 43 | else *_port_reg &= ~_bit_mask; // LOW 44 | 45 | #else 46 | digitalWrite(pin, val); 47 | 48 | #endif 49 | } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /firmware/OLED/webcamOLED_proc/webcamOLED_proc.pde: -------------------------------------------------------------------------------- 1 | int w = 128; 2 | int h = 64; 3 | int rate = 30; 4 | int baud = 500000; 5 | 6 | // video 7 | import processing.video.*; 8 | PImage frame; 9 | Capture cam; 10 | 11 | // P5 12 | import controlP5.*; 13 | ControlP5 cp5; 14 | ScrollableList com_list, cam_list; 15 | String curCam = ""; 16 | 17 | // JAVA 18 | import processing.serial.*; 19 | import java.util.*; 20 | Serial myPort; 21 | String curPort = ""; 22 | boolean streamStatus = false; 23 | boolean COMstatus = false; 24 | byte buf[] = new byte[1024]; 25 | int tmr; 26 | int ov = 0; 27 | 28 | void setup() { 29 | size(400, 200); 30 | GUIinit(); 31 | } 32 | 33 | void draw() { 34 | if (streamStatus) { 35 | if (millis() - tmr > 1000/rate && cam.available()) { 36 | tmr = millis(); 37 | cam.read(); 38 | frame = cam; 39 | ditherImage(frame); 40 | background(130); 41 | image(frame, 100, -ov); 42 | if (COMstatus) sendImage(); 43 | } 44 | } else { 45 | background(130); 46 | } 47 | } 48 | 49 | void sendImage() { 50 | //frame.loadPixels(); 51 | myPort.write(1); 52 | int counter = 0; 53 | for (int j = 0; j < h/8; j++) { 54 | for (int i = 0; i < w; i++) { 55 | byte thisByte = 0; 56 | for (int k = 0; k < 8; k++) { 57 | //if ((byte)frame.pixels[i + (j*8+k)*w + ov*w] != 0) thisByte |= 1 << k; 58 | if ((byte)get(100+i,(j*8+k)) != 0) thisByte |= 1 << k; 59 | } 60 | if (thisByte == 1) thisByte++; 61 | buf[counter] = thisByte; 62 | counter++; 63 | } 64 | } 65 | //frame.updatePixels(); 66 | myPort.write(buf); 67 | } 68 | -------------------------------------------------------------------------------- /firmware/telegram4/GyverGFX.h: -------------------------------------------------------------------------------- 1 | #ifndef GyverGFX_h 2 | #define GyverGFX_h 3 | #include 4 | #include 5 | #include "charMap.h" 6 | 7 | #define GFX_CLEAR 0 8 | #define GFX_FILL 1 9 | #define GFX_STROKE 2 10 | #define GFX_ADD 0 11 | #define GFX_REPLACE 1 12 | 13 | #define GFX_SWAP(x,y) if (x > y) x = x ^ y ^ (y = x); 14 | 15 | class GyverGFX : public Print { 16 | public: 17 | GyverGFX(int x, int y); 18 | virtual void dot(int x, int y, uint8_t fill = 1); 19 | void fastLineH(int y, int x0, int x1, uint8_t fill = 1); 20 | void fastLineV(int x, int y0, int y1, uint8_t fill = 1); 21 | void line(int x0, int y0, int x1, int y1, uint8_t fill = 1); 22 | void rect(int x0, int y0, int x1, int y1, uint8_t fill = 1); 23 | void roundRect(int x0, int y0, int x1, int y1, uint8_t fill = 1); 24 | void circle(int x, int y, int radius, uint8_t fill = 1); 25 | void bezier(uint8_t* arr, uint8_t size, uint8_t dense, uint8_t fill = 1); 26 | void bezier16(int* arr, uint8_t size, uint8_t dense, uint8_t fill = 1); 27 | void drawBitmap(int x, int y, const uint8_t *frame, int width, int height, uint8_t invert = 0, byte mode = 0); 28 | 29 | void setCursor(int x, int y); 30 | void setScale(uint8_t scale); 31 | void invertText(bool inv); 32 | void autoPrintln(bool mode); 33 | virtual size_t write(uint8_t data); 34 | using Print::write; 35 | 36 | private: 37 | uint8_t getFont(uint8_t font, uint8_t row); 38 | int _x = 0, _y = 0; 39 | uint8_t _scaleX = 1, _scaleY = 8; 40 | bool _invert = 0, _println = 0; 41 | uint8_t _lastChar; 42 | int _maxX = 5, _maxY = 5; 43 | }; 44 | #endif 45 | -------------------------------------------------------------------------------- /libraries/GyverOLED/examples/OLD EXAMPLES/demo/demo.ino: -------------------------------------------------------------------------------- 1 | // Пример GyverOLED. Смотри документацию на http://alexgyver.ru/gyveroled/ 2 | //#define OLED_SOFT_BUFFER_64 // использовать буфер на стороне микроконтроллера 3 | #include 4 | GyverOLED oled; 5 | // можно передать адрес: GyverOLED oled(0x3C); 6 | 7 | void setup() { 8 | // при инициализации можно установить частоту (скорость) шины 9 | // максимум 800 кГц, самый быстрый вывод! 10 | oled.init(OLED128x64, 800); 11 | oled.setContrast(1); // яркость 0-255 12 | oled.clear(); // очистить 13 | oled.home(); // курсор в 0,0 14 | 15 | oled.scale1X(); // масштаб шрифта х1 16 | oled.print("Привет, "); 17 | oled.inverse(1); // пишем с инверсией 18 | oled.println("мир!0123"); 19 | oled.inverse(0); 20 | 21 | oled.scale2X(); // масштаб шрифта х2 22 | oled.print("Привет, "); 23 | oled.inverse(1); 24 | oled.println("мир!012"); 25 | 26 | delay(1000); 27 | 28 | oled.line(0, 0, 127, 63); // линия х0, у0, х1, у1 29 | delay(1000); 30 | oled.line(127, 32, 0, 63); 31 | delay(1000); 32 | oled.rect(70, 20, 100, 30, 0); // прямоугольник х0, у0, х1, у1, заливка NO_FILL, FILL, CLEAR 33 | delay(1000); 34 | oled.rect(70, 20, 100, 30, FILL); // прямоугольник х0, у0, х1, у1, заливка NO_FILL, FILL, CLEAR 35 | delay(1000); 36 | oled.roundRect(50, 40, 100, 60, FILL); // прямоугольник скруглённый х0, у0, х1, у1, заливка NO_FILL, FILL, CLEAR 37 | delay(1000); 38 | oled.circle(20, 60, 15, 0); // окружность х0, у0, радиус, заливка NO_FILL, FILL, CLEAR 39 | 40 | oled.update(); // обновить (только при использовании буфера) 41 | } 42 | 43 | void loop() { 44 | 45 | } 46 | -------------------------------------------------------------------------------- /libraries/GyverOLED/examples/bitmap_move_fast_nobuf/bitmap_move_fast_nobuf.ino: -------------------------------------------------------------------------------- 1 | // работаем с буфером. Выводим битмап, обновляем только в области изменения 2 | // получаем огромную скорость обновления! 3 | 4 | const uint8_t bitmap_32x32[] PROGMEM = { 5 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0xE0, 0xF0, 0x70, 0x70, 0x30, 0x30, 0x30, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF0, 0x70, 0x30, 0x30, 0x20, 0x00, 0x00, 6 | 0x00, 0x30, 0x78, 0xFC, 0x7F, 0x3F, 0x0F, 0x0F, 0x1F, 0x3C, 0x78, 0xF0, 0xE0, 0xC0, 0x80, 0x80, 0x80, 0x40, 0xE0, 0xF0, 0xF8, 0xFC, 0xFF, 0x7F, 0x33, 0x13, 0x1E, 0x1C, 0x1C, 0x0E, 0x07, 0x00, 7 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF9, 0xF7, 0xEF, 0x5F, 0x3F, 0x7F, 0xFE, 0xFD, 0xFB, 0xF1, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 8 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x1E, 0x33, 0x33, 0x1F, 0x0F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x1F, 0x0E, 0x04, 0x00, 0x00, 0x00, 0x00, 9 | }; 10 | 11 | #include 12 | GyverOLED oled; 13 | // можно передать адрес: GyverOLED oled(0x3C); 14 | 15 | void setup() { 16 | oled.init(); 17 | Wire.setClock(400000L); 18 | } 19 | 20 | int posX = 64, posY = 32; // начальная позиция 21 | int velX = 4, velY = 3; // скорость 22 | void loop() { 23 | // движение с отскоками. Заходим на половину за стенки! Для теста 24 | posX += velX; 25 | posY += velY; 26 | if (posX >= 128 - 16 || posX <= -16) velX = -velX; 27 | if (posY >= 64 - 16 || posY <= -16) velY = -velY; 28 | 29 | // выводим картинку 30 | oled.drawBitmap(posX, posY, bitmap_32x32, 32, 32); 31 | 32 | delay(50); 33 | 34 | // очищаем только область картинки 35 | oled.clear(posX, posY, posX + 32, posY + 32); 36 | } 37 | -------------------------------------------------------------------------------- /libraries/microWire/examples/microWire_example/microWire_example.ino: -------------------------------------------------------------------------------- 1 | /* Пример записи и чтения данных в I2C - EEPROM "AT24C32" */ 2 | 3 | // #include // заменяем Wire.h на microWire.h 4 | #include 5 | 6 | uint8_t chipAddress = 0x57; // адрес устройства (используйте i2c scaner для определения) 7 | uint16_t cellAddress = 3064; // адрес первой ячейки , куда будем писать и откуда читать 8 | uint8_t data_0 = 115; // данные , которые запишем в EEPROM ( сравнивайте с этим числом при чтении ) 9 | uint8_t data_1 = 14; 10 | 11 | void setup() { 12 | Serial.begin(9600); 13 | Wire.begin(); 14 | 15 | /* запись */ 16 | Wire.beginTransmission(chipAddress); // начинаем передачу с устройством , зовем по адресу 17 | Wire.write(highByte(cellAddress)); // отправляем старший байт первой адреса ячейки 18 | Wire.write(lowByte(cellAddress)); // отправляем младший байт первой адреса ячейки 19 | Wire.write(data_0); // отпарвляем байт данных 20 | Wire.write(data_1); // отпарвляем еще байт данных 21 | Wire.endTransmission(); // завершаем передачу 22 | 23 | delay(50); // подождем 24 | 25 | /* чтение */ 26 | Wire.beginTransmission(chipAddress); // начинаем передачу с устройством , зовем по адресу 27 | Wire.write(highByte(cellAddress)); // отправляем старший байт адреса первой ячейки 28 | Wire.write(lowByte(cellAddress)); // отправляем младший байт адреса первой ячейки 29 | Wire.endTransmission(); // завершаем передачу 30 | Wire.requestFrom(chipAddress , 2); // запрашиваем свои 2 байта данных 31 | while (Wire.available()) { // пока запрошенные данные не кончились 32 | Serial.println(Wire.read()); // читаем и выводим их 33 | } 34 | 35 | } 36 | 37 | void loop() { 38 | 39 | } 40 | -------------------------------------------------------------------------------- /libraries/GyverOLED/examples/bitmap_move_fast/bitmap_move_fast.ino: -------------------------------------------------------------------------------- 1 | // работаем с буфером. Выводим битмап, обновляем только в области изменения 2 | // получаем огромную скорость обновления! 3 | 4 | const uint8_t bitmap_32x32[] PROGMEM = { 5 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0xE0, 0xF0, 0x70, 0x70, 0x30, 0x30, 0x30, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF0, 0x70, 0x30, 0x30, 0x20, 0x00, 0x00, 6 | 0x00, 0x30, 0x78, 0xFC, 0x7F, 0x3F, 0x0F, 0x0F, 0x1F, 0x3C, 0x78, 0xF0, 0xE0, 0xC0, 0x80, 0x80, 0x80, 0x40, 0xE0, 0xF0, 0xF8, 0xFC, 0xFF, 0x7F, 0x33, 0x13, 0x1E, 0x1C, 0x1C, 0x0E, 0x07, 0x00, 7 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF9, 0xF7, 0xEF, 0x5F, 0x3F, 0x7F, 0xFE, 0xFD, 0xFB, 0xF1, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 8 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x1E, 0x33, 0x33, 0x1F, 0x0F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x1F, 0x0E, 0x04, 0x00, 0x00, 0x00, 0x00, 9 | }; 10 | 11 | #include 12 | GyverOLED oled; 13 | // можно передать адрес: GyverOLED oled(0x3C); 14 | 15 | void setup() { 16 | oled.init(); 17 | Wire.setClock(400000L); 18 | } 19 | 20 | int posX = 64, posY = 32; // начальная позиция 21 | int velX = 4, velY = 3; // скорость 22 | void loop() { 23 | // движение с отскоками. Заходим на половину за стенки! Для теста 24 | posX += velX; 25 | posY += velY; 26 | if (posX >= 128 - 16 || posX <= -16) velX = -velX; 27 | if (posY >= 64 - 16 || posY <= -16) velY = -velY; 28 | 29 | // выводим картинку 30 | oled.drawBitmap(posX, posY, bitmap_32x32, 32, 32); 31 | 32 | // обновляем буфер только в области изменения (+-4х и +-3y от рисования) 33 | oled.update(posX - 4, posY - 3, posX + 32 + 4, posY + 32 + 3); 34 | 35 | // очищаем буфер 36 | oled.clear(posX, posY, posX + 32, posY + 32); 37 | } 38 | -------------------------------------------------------------------------------- /firmware/ST7735/webcamST7735_proc/webcamST7735_proc.pde: -------------------------------------------------------------------------------- 1 | int w = 160; 2 | int h = 128; 3 | int baud = 2000000; 4 | byte pack = 2; // 2 - RGB16, 1 - RGB8 5 | 6 | // установить либу video 7 | import processing.video.*; 8 | PImage frame; 9 | Capture cam; 10 | 11 | // P5 12 | import controlP5.*; 13 | ControlP5 cp5; 14 | ScrollableList com_list, cam_list; 15 | String curCam = ""; 16 | 17 | // JAVA 18 | import processing.serial.*; 19 | import java.util.*; 20 | Serial myPort; 21 | 22 | String curPort = ""; 23 | boolean streamStatus = false; 24 | boolean COMstatus = false; 25 | int ov = 0; 26 | byte buf[] = new byte[128*160*pack]; 27 | 28 | void setup() { 29 | size(400, 200); 30 | GUIinit(); 31 | } 32 | 33 | void draw() { 34 | if (streamStatus) { 35 | if (cam.available()) { 36 | cam.read(); 37 | frame = cam; 38 | //ditherImage(frame); 39 | background(130); 40 | image(frame, 100, -ov); 41 | if (COMstatus) sendImage(); 42 | } 43 | } else { 44 | background(130); 45 | } 46 | } 47 | 48 | void sendImage() { 49 | myPort.write(1); 50 | int count = 0; 51 | for (int j = 0; j < h; j++) { 52 | for (int i = 0; i < w; i++) { 53 | int col = get(100+i, j); 54 | // 2 байта 55 | if (pack == 2) { 56 | col = ( ((col & 0xF80000) >> 8) | ((col & 0xFC00) >> 5) | ((col & 0xF8) >> 3) ); // RGB24 to RGB16 57 | byte col1 = byte((col >> 8) & 0xFF); 58 | byte col2 = byte(col & 0xFF); 59 | if (col1 == 1) col1++; 60 | if (col2 == 1) col2++; 61 | buf[count++] = col1; 62 | buf[count++] = col2; 63 | 64 | // 1 байт 65 | } else if (pack == 1) { 66 | col = ( ((col & 0xE00000) >> 16) | ((col & 0xC000) >> 11) | ((col & 0xE0) >> 5) ); // RGB24 to RGB8 67 | byte col1 = byte(col & 0xFF); 68 | if (col1 == 1) col1++; 69 | buf[count++] = col1; 70 | } 71 | } 72 | } 73 | myPort.write(buf); 74 | } 75 | -------------------------------------------------------------------------------- /firmware/telegram/ESP8266TelegramBOT.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 Giancarlo Bacchio. All right reserved. 3 | 4 | TelegramBot - Library to create your own Telegram Bot using 5 | ESP8266 on Arduino IDE. 6 | Ref. Library at https:github/esp8266/Arduino 7 | 8 | This library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU Lesser General Public 10 | License as published by the Free Software Foundation; either 11 | version 2.1 of the License, or (at your option) any later version. 12 | 13 | This library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser General Public License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public 19 | License along with this library; if not, write to the Free Software 20 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | */ 22 | // Отключил дебаг. AlexGyver 23 | 24 | #ifndef ESP8266TelegramBOT_h 25 | #define ESP8266TelegramBOT_h 26 | 27 | //#define DEBUG_SERIAL 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | //#include 35 | 36 | class TelegramBOT 37 | { 38 | public: 39 | TelegramBOT (String, String, String); 40 | String message[3][6]; // amount of messages read per time (update_id, name_id, name, lastname, chat_id, text) 41 | void begin(void); 42 | void analizeMessages(void); 43 | void sendMessage(String chat_id, String text, String reply_markup); 44 | void getUpdates(String offset); 45 | //const char* fingerprint = "37:21:36:77:50:57:F3:C9:28:D0:F7:FA:4C:05:35:7F:60:C1:20:44"; //Telegram.org Certificate 46 | 47 | private: 48 | String connectToTelegram(String command); 49 | String _token; 50 | String _name; 51 | String _username; 52 | //WiFiClientSecure client; 53 | 54 | }; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /firmware/MAX7219/webcamMAX7219_proc/webcamMAX7219_proc.pde: -------------------------------------------------------------------------------- 1 | int w = 4*8; 2 | int h = 2*8; 3 | int rate = 30; 4 | int baud = 100000; 5 | 6 | int W = w/8; 7 | int H = h/8; 8 | 9 | // video 10 | import processing.video.*; 11 | PImage frame; 12 | Capture cam; 13 | 14 | // P5 15 | import controlP5.*; 16 | ControlP5 cp5; 17 | ScrollableList com_list, cam_list; 18 | String curCam = ""; 19 | 20 | // JAVA 21 | import processing.serial.*; 22 | import java.util.*; 23 | Serial myPort; 24 | String curPort = ""; 25 | boolean streamStatus = false; 26 | boolean COMstatus = false; 27 | byte buf[] = new byte[W*H*8]; 28 | int tmr; 29 | int ov = 0; 30 | 31 | void setup() { 32 | size(400, 200); 33 | GUIinit(); 34 | } 35 | 36 | void draw() { 37 | if (streamStatus) { 38 | if (millis() - tmr > 1000/rate && cam.available()) { 39 | tmr = millis(); 40 | cam.read(); 41 | frame = cam; 42 | ditherImage(frame); 43 | background(130); 44 | image(frame, 100, -ov); 45 | if (COMstatus) sendImage(); 46 | } 47 | } else { 48 | background(130); 49 | } 50 | } 51 | 52 | void sendImage() { 53 | //frame.loadPixels(); 54 | myPort.write(1); 55 | 56 | for (int yy = 0; yy < h; yy++) { 57 | for (int xx = 0; xx < w; xx+=8) { 58 | int x = xx; 59 | int y = yy; 60 | byte thisByte = 0; 61 | boolean odd = ((y / 8) % 2 == 1); 62 | for (int k = 0; k < 8; k++) { 63 | if ((byte)get(100+x+k, y) != 0) { 64 | if (odd) thisByte |= 1 << (7-k); 65 | else thisByte |= 1 << k; 66 | } 67 | } 68 | if (thisByte == 1) thisByte++; 69 | 70 | if (odd) { // если это нечётная матрица: (y / 8) % 2 71 | x = W * 8 - 1 - x; // отзеркалить x 72 | y = (y / 8) * 8 + (7 - (y % 8)); // отзеркалить y: (y / 8) * 8 + (7 - (y % 8)); 73 | } 74 | int curByte = W * (H - 1 - y / 8) + (W - 1 - x / 8) + (y % 8) * W * H; 75 | buf[curByte] = thisByte; 76 | } 77 | } 78 | //frame.updatePixels(); 79 | myPort.write(buf); 80 | } 81 | -------------------------------------------------------------------------------- /firmware/MAX7219_mux/webcamMAX7219_proc_mux/webcamMAX7219_proc_mux.pde: -------------------------------------------------------------------------------- 1 | int w = 24*8; 2 | int h = 16*8; 3 | int rate = 30; 4 | int baud = 200000; 5 | 6 | int W = w/8; 7 | int H = h/8; 8 | 9 | // video 10 | import processing.video.*; 11 | PImage frame; 12 | Capture cam; 13 | 14 | // P5 15 | import controlP5.*; 16 | ControlP5 cp5; 17 | ScrollableList com_list, cam_list; 18 | String curCam = ""; 19 | 20 | // JAVA 21 | import processing.serial.*; 22 | import java.util.*; 23 | Serial myPort; 24 | String curPort = ""; 25 | boolean streamStatus = false; 26 | boolean COMstatus = false; 27 | byte buf[] = new byte[W*H*8]; 28 | int tmr; 29 | int ov = 0; 30 | 31 | void setup() { 32 | size(400, 200); 33 | GUIinit(); 34 | } 35 | 36 | void draw() { 37 | if (streamStatus) { 38 | if (millis() - tmr > 1000/rate && cam.available()) { 39 | tmr = millis(); 40 | cam.read(); 41 | frame = cam; 42 | ditherImage(frame); 43 | background(130); 44 | image(frame, 100, -ov); 45 | if (COMstatus) sendImage(); 46 | } 47 | } else { 48 | background(130); 49 | } 50 | } 51 | 52 | void sendImage() { 53 | //frame.loadPixels(); 54 | myPort.write(1); 55 | 56 | for (int yy = 0; yy < h; yy++) { 57 | for (int xx = 0; xx < w; xx+=8) { 58 | int x = xx; 59 | int y = yy; 60 | byte thisByte = 0; 61 | boolean odd = ((y / 8) % 2 == 1); 62 | for (int k = 0; k < 8; k++) { 63 | if ((byte)get(100+x+k, y) != 0) { 64 | if (odd) thisByte |= 1 << (7-k); 65 | else thisByte |= 1 << k; 66 | } 67 | } 68 | if (thisByte == 1) thisByte++; 69 | y &= 15; 70 | if (odd) { // если это нечётная матрица: (y / 8) % 2 71 | x = W * 8 - 1 - x; // отзеркалить x 72 | y = (y / 8) * 8 + (7 - (y % 8)); // отзеркалить y: (y / 8) * 8 + (7 - (y % 8)); 73 | } 74 | int curByte = W * (2 - 1 - y / 8) + (W - 1 - x / 8) + (y % 8) * W * 2; 75 | curByte += W * 16 * (yy / 16); 76 | buf[curByte] = thisByte; 77 | } 78 | } 79 | //frame.updatePixels(); 80 | myPort.write(buf); 81 | } 82 | -------------------------------------------------------------------------------- /firmware/OLED/webcamOLED_proc/GUI.pde: -------------------------------------------------------------------------------- 1 | void GUIinit() { 2 | cp5 = new ControlP5(this); 3 | cp5.addSlider("overlap").setCaptionLabel("overlap").setPosition(0, 50).setSize(100, 25).setRange(0, 150).setValue(0); 4 | cp5.getController("overlap").getCaptionLabel().setPaddingX(-40); 5 | 6 | cp5.addButton("start_stream").setCaptionLabel("start stream").setPosition(0, 75).setSize(100, 25); 7 | cp5.addButton("stop_stream").setCaptionLabel("stop stream").setPosition(0, 100).setSize(100, 25); 8 | cp5.addButton("start_send").setCaptionLabel("start send").setPosition(0, 125).setSize(100, 25); 9 | cp5.addButton("stop_send").setCaptionLabel("stop send").setPosition(0, 150).setSize(100, 25); 10 | 11 | // лист СAМ 12 | cam_list = cp5.addScrollableList("CAM") 13 | .setCaptionLabel("CAMERA") 14 | .setPosition(0, 25) 15 | .setSize(100, 100) 16 | .setBarHeight(25) 17 | .setItemHeight(25) 18 | .close(); 19 | cam_list.onEnter(new CallbackListener() { 20 | public void controlEvent(CallbackEvent ev) { 21 | cam_list.clear(); 22 | cam_list.addItems(Arrays.asList(Capture.list())); 23 | } 24 | } 25 | ); 26 | // лист СОМ 27 | com_list = cp5.addScrollableList("COM") 28 | .setCaptionLabel("PORT") 29 | .setPosition(0, 0) 30 | .setSize(100, 100) 31 | .setBarHeight(25) 32 | .setItemHeight(25) 33 | .close(); 34 | com_list.onEnter(new CallbackListener() { 35 | public void controlEvent(CallbackEvent ev) { 36 | com_list.clear(); 37 | com_list.addItems(Arrays.asList(Serial.list())); 38 | } 39 | } 40 | ); 41 | } 42 | 43 | void overlap (int n) { 44 | ov = n; 45 | background(130); 46 | if (streamStatus) start_stream(); 47 | } 48 | 49 | void COM(int n) { 50 | curPort = Serial.list()[n]; 51 | } 52 | void CAM(int n) { 53 | curCam = Capture.list()[n]; 54 | } 55 | 56 | void start_stream() { 57 | if (curCam != null) { 58 | frame = createImage(w, h+ov, RGB); 59 | cam = new Capture(this, w, h+ov, curCam, rate); 60 | cam.start(); 61 | streamStatus = true; 62 | } 63 | } 64 | void stop_stream() { 65 | if (curCam != null) { 66 | cam.stop(); 67 | streamStatus = false; 68 | } 69 | } 70 | void start_send() { 71 | if (!COMstatus) { 72 | myPort = new Serial(this, curPort, baud); 73 | COMstatus = true; 74 | } 75 | } 76 | void stop_send() { 77 | myPort.stop(); 78 | COMstatus = false; 79 | } 80 | -------------------------------------------------------------------------------- /firmware/ST7735/webcamST7735_proc/GUI.pde: -------------------------------------------------------------------------------- 1 | void GUIinit() { 2 | cp5 = new ControlP5(this); 3 | cp5.addSlider("overlap").setCaptionLabel("overlap").setPosition(0, 50).setSize(100, 25).setRange(0, 150).setValue(0); 4 | cp5.getController("overlap").getCaptionLabel().setPaddingX(-40); 5 | 6 | cp5.addButton("start_stream").setCaptionLabel("start stream").setPosition(0, 75).setSize(100, 25); 7 | cp5.addButton("stop_stream").setCaptionLabel("stop stream").setPosition(0, 100).setSize(100, 25); 8 | cp5.addButton("start_send").setCaptionLabel("start send").setPosition(0, 125).setSize(100, 25); 9 | cp5.addButton("stop_send").setCaptionLabel("stop send").setPosition(0, 150).setSize(100, 25); 10 | 11 | // лист СAМ 12 | cam_list = cp5.addScrollableList("CAM") 13 | .setCaptionLabel("CAMERA") 14 | .setPosition(0, 25) 15 | .setSize(100, 100) 16 | .setBarHeight(25) 17 | .setItemHeight(25) 18 | .close(); 19 | cam_list.onEnter(new CallbackListener() { 20 | public void controlEvent(CallbackEvent ev) { 21 | cam_list.clear(); 22 | cam_list.addItems(Arrays.asList(Capture.list())); 23 | } 24 | } 25 | ); 26 | // лист СОМ 27 | com_list = cp5.addScrollableList("COM") 28 | .setCaptionLabel("PORT") 29 | .setPosition(0, 0) 30 | .setSize(100, 100) 31 | .setBarHeight(25) 32 | .setItemHeight(25) 33 | .close(); 34 | com_list.onEnter(new CallbackListener() { 35 | public void controlEvent(CallbackEvent ev) { 36 | com_list.clear(); 37 | com_list.addItems(Arrays.asList(Serial.list())); 38 | } 39 | } 40 | ); 41 | } 42 | 43 | void overlap (int n) { 44 | ov = n; 45 | background(130); 46 | if (streamStatus) start_stream(); 47 | } 48 | 49 | void COM(int n) { 50 | curPort = Serial.list()[n]; 51 | } 52 | void CAM(int n) { 53 | curCam = Capture.list()[n]; 54 | } 55 | 56 | void start_stream() { 57 | if (curCam != null) { 58 | frame = createImage(w, h+ov, RGB); 59 | cam = new Capture(this, w, h+ov, curCam, 30); 60 | cam.start(); 61 | streamStatus = true; 62 | } 63 | } 64 | void stop_stream() { 65 | if (curCam != null) { 66 | cam.stop(); 67 | streamStatus = false; 68 | } 69 | } 70 | void start_send() { 71 | if (!COMstatus) { 72 | myPort = new Serial(this, curPort, baud); 73 | COMstatus = true; 74 | } 75 | } 76 | void stop_send() { 77 | myPort.stop(); 78 | COMstatus = false; 79 | } 80 | -------------------------------------------------------------------------------- /firmware/MAX7219/webcamMAX7219_proc/GUI.pde: -------------------------------------------------------------------------------- 1 | void GUIinit() { 2 | cp5 = new ControlP5(this); 3 | cp5.addSlider("overlap").setCaptionLabel("overlap").setPosition(0, 50).setSize(100, 25).setRange(0, 150).setValue(0); 4 | cp5.getController("overlap").getCaptionLabel().setPaddingX(-40); 5 | 6 | cp5.addButton("start_stream").setCaptionLabel("start stream").setPosition(0, 75).setSize(100, 25); 7 | cp5.addButton("stop_stream").setCaptionLabel("stop stream").setPosition(0, 100).setSize(100, 25); 8 | cp5.addButton("start_send").setCaptionLabel("start send").setPosition(0, 125).setSize(100, 25); 9 | cp5.addButton("stop_send").setCaptionLabel("stop send").setPosition(0, 150).setSize(100, 25); 10 | 11 | // лист СAМ 12 | cam_list = cp5.addScrollableList("CAM") 13 | .setCaptionLabel("CAMERA") 14 | .setPosition(0, 25) 15 | .setSize(100, 100) 16 | .setBarHeight(25) 17 | .setItemHeight(25) 18 | .close(); 19 | cam_list.onEnter(new CallbackListener() { 20 | public void controlEvent(CallbackEvent ev) { 21 | cam_list.clear(); 22 | cam_list.addItems(Arrays.asList(Capture.list())); 23 | } 24 | } 25 | ); 26 | // лист СОМ 27 | com_list = cp5.addScrollableList("COM") 28 | .setCaptionLabel("PORT") 29 | .setPosition(0, 0) 30 | .setSize(100, 100) 31 | .setBarHeight(25) 32 | .setItemHeight(25) 33 | .close(); 34 | com_list.onEnter(new CallbackListener() { 35 | public void controlEvent(CallbackEvent ev) { 36 | com_list.clear(); 37 | com_list.addItems(Arrays.asList(Serial.list())); 38 | } 39 | } 40 | ); 41 | } 42 | 43 | void overlap (int n) { 44 | ov = n; 45 | background(130); 46 | if (streamStatus) start_stream(); 47 | } 48 | 49 | void COM(int n) { 50 | curPort = Serial.list()[n]; 51 | } 52 | void CAM(int n) { 53 | curCam = Capture.list()[n]; 54 | } 55 | 56 | void start_stream() { 57 | if (curCam != null) { 58 | frame = createImage(w, h+ov, RGB); 59 | cam = new Capture(this, w, h+ov, curCam, rate); 60 | cam.start(); 61 | streamStatus = true; 62 | } 63 | } 64 | void stop_stream() { 65 | if (curCam != null) { 66 | cam.stop(); 67 | streamStatus = false; 68 | } 69 | } 70 | void start_send() { 71 | if (!COMstatus) { 72 | myPort = new Serial(this, curPort, baud); 73 | COMstatus = true; 74 | } 75 | } 76 | void stop_send() { 77 | myPort.stop(); 78 | COMstatus = false; 79 | } 80 | -------------------------------------------------------------------------------- /firmware/MAX7219_mux/webcamMAX7219_proc_mux/GUI.pde: -------------------------------------------------------------------------------- 1 | void GUIinit() { 2 | cp5 = new ControlP5(this); 3 | cp5.addSlider("overlap").setCaptionLabel("overlap").setPosition(0, 50).setSize(100, 25).setRange(0, 150).setValue(0); 4 | cp5.getController("overlap").getCaptionLabel().setPaddingX(-40); 5 | 6 | cp5.addButton("start_stream").setCaptionLabel("start stream").setPosition(0, 75).setSize(100, 25); 7 | cp5.addButton("stop_stream").setCaptionLabel("stop stream").setPosition(0, 100).setSize(100, 25); 8 | cp5.addButton("start_send").setCaptionLabel("start send").setPosition(0, 125).setSize(100, 25); 9 | cp5.addButton("stop_send").setCaptionLabel("stop send").setPosition(0, 150).setSize(100, 25); 10 | 11 | // лист СAМ 12 | cam_list = cp5.addScrollableList("CAM") 13 | .setCaptionLabel("CAMERA") 14 | .setPosition(0, 25) 15 | .setSize(100, 100) 16 | .setBarHeight(25) 17 | .setItemHeight(25) 18 | .close(); 19 | cam_list.onEnter(new CallbackListener() { 20 | public void controlEvent(CallbackEvent ev) { 21 | cam_list.clear(); 22 | cam_list.addItems(Arrays.asList(Capture.list())); 23 | } 24 | } 25 | ); 26 | // лист СОМ 27 | com_list = cp5.addScrollableList("COM") 28 | .setCaptionLabel("PORT") 29 | .setPosition(0, 0) 30 | .setSize(100, 100) 31 | .setBarHeight(25) 32 | .setItemHeight(25) 33 | .close(); 34 | com_list.onEnter(new CallbackListener() { 35 | public void controlEvent(CallbackEvent ev) { 36 | com_list.clear(); 37 | com_list.addItems(Arrays.asList(Serial.list())); 38 | } 39 | } 40 | ); 41 | } 42 | 43 | void overlap (int n) { 44 | ov = n; 45 | background(130); 46 | if (streamStatus) start_stream(); 47 | } 48 | 49 | void COM(int n) { 50 | curPort = Serial.list()[n]; 51 | } 52 | void CAM(int n) { 53 | curCam = Capture.list()[n]; 54 | } 55 | 56 | void start_stream() { 57 | if (curCam != null) { 58 | frame = createImage(w, h+ov, RGB); 59 | cam = new Capture(this, w, h+ov, curCam, rate); 60 | cam.start(); 61 | streamStatus = true; 62 | } 63 | } 64 | void stop_stream() { 65 | if (curCam != null) { 66 | cam.stop(); 67 | streamStatus = false; 68 | } 69 | } 70 | void start_send() { 71 | if (!COMstatus) { 72 | myPort = new Serial(this, curPort, baud); 73 | COMstatus = true; 74 | } 75 | } 76 | void stop_send() { 77 | myPort.stop(); 78 | COMstatus = false; 79 | } 80 | -------------------------------------------------------------------------------- /libraries/Adafruit-GFX-Library/examples/GFXcanvas/GFXcanvasSerialDemo.cpp: -------------------------------------------------------------------------------- 1 | #include "GFXcanvasSerialDemo.h" 2 | #include 3 | 4 | GFXcanvas1SerialDemo::GFXcanvas1SerialDemo(uint16_t w, uint16_t h) 5 | : GFXcanvas1(w, h) {} 6 | 7 | void GFXcanvas1SerialDemo::print(bool rotated) { 8 | char pixel_buffer[8]; 9 | uint16_t width, height; 10 | 11 | if (rotated) { 12 | width = this->width(); 13 | height = this->height(); 14 | } else { 15 | width = this->WIDTH; 16 | height = this->HEIGHT; 17 | } 18 | 19 | for (uint16_t y = 0; y < height; y++) { 20 | for (uint16_t x = 0; x < width; x++) { 21 | bool pixel; 22 | if (rotated) { 23 | pixel = this->getPixel(x, y); 24 | } else { 25 | pixel = this->getRawPixel(x, y); 26 | } 27 | sprintf(pixel_buffer, " %d", pixel); 28 | Serial.print(pixel_buffer); 29 | } 30 | Serial.print("\n"); 31 | } 32 | } 33 | 34 | GFXcanvas8SerialDemo::GFXcanvas8SerialDemo(uint16_t w, uint16_t h) 35 | : GFXcanvas8(w, h) {} 36 | 37 | void GFXcanvas8SerialDemo::print(bool rotated) { 38 | char pixel_buffer[8]; 39 | uint16_t width, height; 40 | 41 | if (rotated) { 42 | width = this->width(); 43 | height = this->height(); 44 | } else { 45 | width = this->WIDTH; 46 | height = this->HEIGHT; 47 | } 48 | 49 | for (uint16_t y = 0; y < height; y++) { 50 | for (uint16_t x = 0; x < width; x++) { 51 | uint8_t pixel; 52 | if (rotated) { 53 | pixel = this->getPixel(x, y); 54 | } else { 55 | pixel = this->getRawPixel(x, y); 56 | } 57 | sprintf(pixel_buffer, " %02x", pixel); 58 | Serial.print(pixel_buffer); 59 | } 60 | Serial.print("\n"); 61 | } 62 | } 63 | 64 | GFXcanvas16SerialDemo::GFXcanvas16SerialDemo(uint16_t w, uint16_t h) 65 | : GFXcanvas16(w, h) {} 66 | 67 | void GFXcanvas16SerialDemo::print(bool rotated) { 68 | char pixel_buffer[8]; 69 | uint16_t width, height; 70 | 71 | if (rotated) { 72 | width = this->width(); 73 | height = this->height(); 74 | } else { 75 | width = this->WIDTH; 76 | height = this->HEIGHT; 77 | } 78 | 79 | for (uint16_t y = 0; y < height; y++) { 80 | for (uint16_t x = 0; x < width; x++) { 81 | uint16_t pixel; 82 | if (rotated) { 83 | pixel = this->getPixel(x, y); 84 | } else { 85 | pixel = this->getRawPixel(x, y); 86 | } 87 | sprintf(pixel_buffer, " %04x", pixel); 88 | Serial.print(pixel_buffer); 89 | } 90 | Serial.print("\n"); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /firmware/telegram/telegram.ino: -------------------------------------------------------------------------------- 1 | // константы 2 | #define WIFI_SSID "" 3 | #define WIFI_PASS "" 4 | #define BOT_TOKEN "" 5 | #define BOT_NAME "" 6 | #define BOT_USERNAME "" 7 | #define CHAT_ID "" 8 | 9 | #include 10 | #include 11 | #include "ESP8266TelegramBOT.h" 12 | TelegramBOT bot(BOT_TOKEN, BOT_NAME, BOT_USERNAME); 13 | 14 | #define MAX_SPI_SPEED 500000 15 | #include "GyverMAX7219.h" 16 | #define AM_W 12*8 17 | #define AM_H 8*8 18 | MAX7219 < 5, AM_W / 8, AM_H / 8 > mtrx; // CS, W, H 19 | 20 | void setup() { 21 | delay(4000); 22 | mtrx.update(); 23 | Serial.begin(115200); 24 | Serial.println(); 25 | 26 | WiFi.begin(WIFI_SSID, WIFI_PASS); 27 | while (WiFi.status() != WL_CONNECTED) { 28 | delay(500); 29 | Serial.print("."); 30 | } 31 | Serial.println("Connected"); 32 | bot.begin(); 33 | } 34 | 35 | void loop() { 36 | parseBot(); 37 | } 38 | 39 | void parseBot() { 40 | static uint32_t tmr; 41 | static byte count = 0; 42 | if (millis() - tmr > 1000) { 43 | bot.getUpdates(bot.message[0][1]); 44 | for (int i = 1; i < bot.message[0][0].toInt() + 1; i++) { 45 | if (bot.message[i][4] == CHAT_ID && bot.message[i][5].length() <= 12) { 46 | String str = bot.message[i][5]; 47 | byte mode = 2; 48 | if (str.startsWith("/set ")) mode = 1; 49 | else if (str.startsWith("/clr ")) mode = 0; 50 | if (mode == 2) continue; 51 | 52 | // супер парсинг без стрингов 53 | int pos[2] = {0, 0}; 54 | int count = -1; 55 | for (byte i = 5; i < 12; i++) { 56 | char sym = str[i]; 57 | if (sym >= 48 && sym <= 57) { 58 | if (count == -1) count = 0; 59 | pos[count] *= 10; 60 | pos[count] += sym - '0'; 61 | } else if (sym == 32) { 62 | if (count == 0) count++; 63 | else mode = 2; 64 | } else if (sym == NULL) { 65 | if (count != 1) mode = 2; 66 | break; 67 | } else { 68 | mode = 2; 69 | } 70 | } 71 | if (mode != 2) { 72 | Serial.print(mode); 73 | Serial.print(','); 74 | Serial.print(pos[0]); 75 | Serial.print(','); 76 | Serial.println(pos[1]); 77 | mtrx.dot(pos[0], pos[1], mode); 78 | if (++count == 100) { 79 | count = 0; 80 | mtrx.begin(); 81 | } 82 | mtrx.update(); 83 | } 84 | } 85 | } 86 | bot.message[0][0] = ""; 87 | tmr = millis(); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /libraries/GyverOLED/examples/graphics/graphics.ino: -------------------------------------------------------------------------------- 1 | #include 2 | GyverOLED oled; 3 | // можно передать адрес: GyverOLED oled(0x3C); 4 | 5 | 6 | void setup() { 7 | Serial.begin(9600); 8 | oled.init(); // инициализация 9 | Wire.setClock(400000L); 10 | oled.clear(); 11 | oled.update(); 12 | /* 13 | byte textPos1 = 8; 14 | byte textPos2 = 32; 15 | 16 | oled.createBuffer(5, 0, 66, textPos2 + 8 + 2); 17 | 18 | oled.roundRect(5, textPos1 - 4, 65, textPos1 + 8 + 2, OLED_STROKE); 19 | oled.setCursorXY(10, textPos1); 20 | oled.print("SET MODE"); 21 | 22 | oled.roundRect(5, textPos2 - 4, 65, textPos2 + 8 + 2, OLED_FILL); 23 | oled.setCursorXY(10, textPos2); 24 | oled.invertText(true); 25 | oled.print("SUCK COCK"); 26 | 27 | oled.sendBuffer(); 28 | oled.update(); 29 | for (;;); 30 | oled.createBuffer(0, 0, 60, 7); 31 | oled.home(); 32 | oled.print("hello"); 33 | oled.line(0, 4, 40, 7); 34 | oled.sendBuffer(); 35 | for (;;); 36 | circleModes(); 37 | oled.update(); 38 | for (;;); 39 | */ 40 | } 41 | 42 | int posX = 64, posY = 32; // начальная позиция 43 | int velX = 4, velY = 3; // скорость 44 | void loop() { 45 | // движение с отскоками. Заходим на половину за стенки! Для теста 46 | posX += velX; 47 | posY += velY; 48 | if (posX >= 128 - 16 || posX <= -16) velX = -velX; 49 | if (posY >= 64 - 16 || posY <= -16) velY = -velY; 50 | 51 | //oled.fill(255); 52 | oled.rect(posX, posY, posX + 32, posY + 32, OLED_FILL); 53 | oled.update(); 54 | delay(30); 55 | oled.clear(posX, posY, posX + 32, posY + 32); 56 | //oled.update(); 57 | } 58 | 59 | void lineFill() { 60 | for (byte y = 0; y < 64; y += 3) { 61 | oled.line(0, 0, 128, y, OLED_FILL); 62 | oled.update(); 63 | //delay(10); 64 | } 65 | for (int x = 128; x >= 0; x -= 3) { 66 | oled.line(0, 0, x, 64, OLED_FILL); 67 | oled.update(); 68 | //delay(10); 69 | } 70 | delay(1000); 71 | } 72 | 73 | void circleModes() { 74 | for (;;) { 75 | oled.clear(); 76 | oled.fill(255); 77 | oled.createBuffer(64 - 20, 32 - 20, 64 + 20, 32 + 20, 255); 78 | oled.circle(64, 32, 20, OLED_CLEAR); 79 | oled.sendBuffer(); 80 | oled.update(); 81 | delay(800); 82 | 83 | oled.clear(); 84 | oled.createBuffer(64 - 20, 32 - 20, 64 + 20, 32 + 20); 85 | oled.circle(64, 32, 20, OLED_FILL); 86 | oled.sendBuffer(); 87 | oled.update(); 88 | delay(800); 89 | 90 | oled.clear(); 91 | oled.createBuffer(64 - 20, 32 - 20, 64 + 20, 32 + 20); 92 | oled.circle(64, 32, 20, OLED_STROKE); 93 | oled.sendBuffer(); 94 | oled.update(); 95 | delay(800); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /libraries/Adafruit-GFX-Library/examples/GFXcanvas/GFXcanvasSerialDemo.h: -------------------------------------------------------------------------------- 1 | #ifndef __GFXcanvasSerialDemo__ 2 | #define __GFXcanvasSerialDemo__ 3 | #include 4 | 5 | /**********************************************************************/ 6 | /*! 7 | @brief Demonstrates using the GFXconvas classes as the backing store 8 | for a device driver. 9 | */ 10 | /**********************************************************************/ 11 | class GFXcanvas1SerialDemo : public GFXcanvas1 { 12 | public: 13 | GFXcanvas1SerialDemo(uint16_t w, uint16_t h); 14 | 15 | /**********************************************************************/ 16 | /*! 17 | @brief Prints the current contents of the canvas to Serial 18 | @param rotated true to print according to the current GFX rotation, 19 | false to print to the native rotation of the canvas (or unrotated). 20 | */ 21 | /**********************************************************************/ 22 | void print(bool rotated); 23 | }; 24 | 25 | /**********************************************************************/ 26 | /*! 27 | @brief Demonstrates using the GFXconvas classes as the backing store 28 | for a device driver. 29 | */ 30 | /**********************************************************************/ 31 | class GFXcanvas8SerialDemo : public GFXcanvas8 { 32 | public: 33 | GFXcanvas8SerialDemo(uint16_t w, uint16_t h); 34 | 35 | /**********************************************************************/ 36 | /*! 37 | @brief Prints the current contents of the canvas to Serial 38 | @param rotated true to print according to the current GFX rotation, 39 | false to print to the native rotation of the canvas (or unrotated). 40 | */ 41 | /**********************************************************************/ 42 | void print(bool rotated); 43 | }; 44 | 45 | /**********************************************************************/ 46 | /*! 47 | @brief Demonstrates using the GFXconvas classes as the backing store 48 | for a device driver. 49 | */ 50 | /**********************************************************************/ 51 | class GFXcanvas16SerialDemo : public GFXcanvas16 { 52 | public: 53 | GFXcanvas16SerialDemo(uint16_t w, uint16_t h); 54 | 55 | /**********************************************************************/ 56 | /*! 57 | @brief Prints the current contents of the canvas to Serial 58 | @param rotated true to print according to the current GFX rotation, 59 | false to print to the native rotation of the canvas (or unrotated). 60 | */ 61 | /**********************************************************************/ 62 | void print(bool rotated); 63 | }; 64 | 65 | #endif // __GFXcanvasSerialDemo__ 66 | -------------------------------------------------------------------------------- /libraries/Adafruit-GFX-Library/.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thank you for opening an issue on an Adafruit Arduino library repository. To 2 | improve the speed of resolution please review the following guidelines and 3 | common troubleshooting steps below before creating the issue: 4 | 5 | - **Do not use GitHub issues for troubleshooting projects and issues.** Instead use 6 | the forums at http://forums.adafruit.com to ask questions and troubleshoot why 7 | something isn't working as expected. In many cases the problem is a common issue 8 | that you will more quickly receive help from the forum community. GitHub issues 9 | are meant for known defects in the code. If you don't know if there is a defect 10 | in the code then start with troubleshooting on the forum first. 11 | 12 | - **If following a tutorial or guide be sure you didn't miss a step.** Carefully 13 | check all of the steps and commands to run have been followed. Consult the 14 | forum if you're unsure or have questions about steps in a guide/tutorial. 15 | 16 | - **For Arduino projects check these very common issues to ensure they don't apply**: 17 | 18 | - For uploading sketches or communicating with the board make sure you're using 19 | a **USB data cable** and **not** a **USB charge-only cable**. It is sometimes 20 | very hard to tell the difference between a data and charge cable! Try using the 21 | cable with other devices or swapping to another cable to confirm it is not 22 | the problem. 23 | 24 | - **Be sure you are supplying adequate power to the board.** Check the specs of 25 | your board and plug in an external power supply. In many cases just 26 | plugging a board into your computer is not enough to power it and other 27 | peripherals. 28 | 29 | - **Double check all soldering joints and connections.** Flakey connections 30 | cause many mysterious problems. See the [guide to excellent soldering](https://learn.adafruit.com/adafruit-guide-excellent-soldering/tools) for examples of good solder joints. 31 | 32 | - **Ensure you are using an official Arduino or Adafruit board.** We can't 33 | guarantee a clone board will have the same functionality and work as expected 34 | with this code and don't support them. 35 | 36 | If you're sure this issue is a defect in the code and checked the steps above 37 | please fill in the following fields to provide enough troubleshooting information. 38 | You may delete the guideline and text above to just leave the following details: 39 | 40 | - Arduino board: **INSERT ARDUINO BOARD NAME/TYPE HERE** 41 | 42 | - Arduino IDE version (found in Arduino -> About Arduino menu): **INSERT ARDUINO 43 | VERSION HERE** 44 | 45 | - List the steps to reproduce the problem below (if possible attach a sketch or 46 | copy the sketch code in too): **LIST REPRO STEPS BELOW** 47 | -------------------------------------------------------------------------------- /firmware/ST7735/webcamST7735/webcamST7735.ino: -------------------------------------------------------------------------------- 1 | #define RGB_PACK 0 // 0 - RGB16, 1 - RGB8 2 | 3 | #include // Core graphics library 4 | #include // Hardware-specific library 5 | #include 6 | #define TFT_CS 10 7 | #define TFT_RST 8 8 | #define TFT_DC 9 9 | Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST); 10 | 11 | #include "microUART.h" 12 | microUART uart; 13 | void setup() { 14 | uart.begin(2000000); 15 | tft.initR(INITR_BLACKTAB); // инициализация 16 | tft.setRotation(tft.getRotation() + 3); // крутим дисп 17 | tft.fillScreen(ST7735_BLACK); // чисти чисти 18 | 19 | SPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0)); 20 | digitalWrite(TFT_CS, 0); 21 | } 22 | 23 | 24 | void loop() { 25 | /*fill(ST7735_YELLOW >> 8, ST7735_YELLOW); 26 | delay(300); 27 | fill(ST7735_GREEN >> 8, ST7735_GREEN); 28 | delay(300);*/ 29 | 30 | if (uart.available()) { // если есть что на приём 31 | byte data = uart.read(); // прочитать 32 | if (data == 1) { // синхронизация 33 | home(); 34 | startSend(); 35 | } else { 36 | if (RGB_PACK == 0) SPI.transfer(data); 37 | else { 38 | SPI.transfer((data & 0b11100000) | ((data & 0b00011000) >> 2)); 39 | SPI.transfer((data & 0b00000111) << 2); 40 | } 41 | } 42 | } 43 | } 44 | 45 | void fill(byte colorH, byte colorL) { 46 | home(); 47 | digitalWrite(TFT_CS, 0); 48 | digitalWrite(TFT_DC, 1); 49 | SPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0)); 50 | for (int x = 0; x < 160 * 128; x++) { 51 | SPI.transfer(colorH); 52 | SPI.transfer(colorL); 53 | } 54 | SPI.endTransaction(); 55 | digitalWrite(TFT_CS, 1); 56 | } 57 | 58 | void home() { 59 | digitalWrite(TFT_DC, 0); 60 | SPI.transfer(ST7735_CASET); // Column addr set 61 | SPI.transfer(0); 62 | SPI.transfer(0); // XSTART 63 | SPI.transfer(0); 64 | SPI.transfer(160); // XEND 65 | SPI.transfer(ST7735_RASET); // Row addr set 66 | SPI.transfer(0); 67 | SPI.transfer(0); // YSTART 68 | SPI.transfer(0); 69 | SPI.transfer(128); // YEND 70 | SPI.transfer(ST7735_RAMWR); // write to RAM 71 | } 72 | void startSend() { 73 | digitalWrite(TFT_DC, 1); 74 | } 75 | void setWindow(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1) { 76 | digitalWrite(TFT_CS, 0); 77 | digitalWrite(TFT_DC, 0); 78 | SPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0)); 79 | SPI.transfer(ST7735_CASET); // Column addr set 80 | SPI.transfer(0x00); 81 | SPI.transfer(x0); // XSTART 82 | SPI.transfer(0x00); 83 | SPI.transfer(x1); // XEND 84 | 85 | SPI.transfer(ST7735_RASET); // Row addr set 86 | SPI.transfer(0x00); 87 | SPI.transfer(y0); // YSTART 88 | SPI.transfer(0x00); 89 | SPI.transfer(y1); // YEND 90 | 91 | SPI.transfer(ST7735_RAMWR); // write to RAM 92 | SPI.endTransaction(); 93 | digitalWrite(TFT_CS, 1); 94 | } 95 | -------------------------------------------------------------------------------- /libraries/microWire/microWire.h: -------------------------------------------------------------------------------- 1 | /* 2 | Лёгкая библиотека со стандартным набором инструментов для работы с аппаратным I2C. 3 | Реализована поддержка всех стандартных функций в роли master. 4 | Облегчайте свой код простой заменой Wire.h на microWire.h 5 | Не все библиотеки на Wire смогут работать с microWire , подробный список поддерживаемых библиотек уточняйте на сайте. 6 | Поддержка контроллеров : ATmega168/328p (nano,uno,mini), ATmega32u4 (leonardo,micro) , ATmega2560 (mega) 7 | Версия 2.1 by Egor 'Nich1con' Zaharov от 02.03.2020 8 | */ 9 | 10 | /* 11 | ВНИМАНИЕ!!! 12 | Для экономии места и возможности запроса большого кол-ва байта (например чтение пакетов EEPROM) , буферов на чтение и запись НЕТ!!! 13 | Функция write сразу отправляет байт на шину , не дожидаясь endTransmission , очереди на отправку нет , отправка занимает некоторое время. 14 | Функция read напрямую читает байт из шины, специфика работы с шиной требует читать последний байт в особом порядке , читайте сразу ВСЕ запрошенные байты. 15 | Пока не будет прочитан последний байт , шина будет занята. Для чтения всех байт воспользуйтесь конструкцией " for(unt8_t i = 0; Wire.available() ,i++){ data[i] = Wire.read } ". 16 | */ 17 | 18 | #ifndef microWire_h 19 | #define microWire_h 20 | #include 21 | #include "pins_arduino.h" 22 | 23 | class TwoWire { 24 | public: 25 | void begin(void); // инициализация шины 26 | void setClock(uint32_t clock); // ручная установка частоты шины 31-900 kHz (в герцах) 27 | void beginTransmission(uint8_t address); // открыть соединение (для записи данных) 28 | uint8_t endTransmission(bool stop); // закрыть соединение , произвести stop или restart (по умолчанию - stop) 29 | uint8_t endTransmission(void); // закрыть соединение , произвести stop 30 | void write(uint8_t data); // отправить в шину байт данных , отправка производится сразу , формат - byte "unsigned char" 31 | void requestFrom(uint8_t address , uint8_t length , bool stop); //открыть соединение и запросить данные от устройства, отпустить или удержать шину 32 | void requestFrom(uint8_t address , uint8_t length); //открыть соединение и запросить данные от устройства, отпустить шину 33 | uint8_t read(void); // прочитать байт , БУФЕРА НЕТ!!! , читайте сразу все запрошенные байты , stop или restart после чтения последнего байта, настраивается в requestFrom 34 | uint8_t available(void); // вернет количество оставшихся для чтения байт 35 | private: 36 | uint8_t _requested_bytes = 0; // переменная хранит количество запрошенных и непрочитанных байт 37 | bool _address_nack = false; // Флаг для отслеживания ошибки при передаче адреса 38 | bool _data_nack = false; // Флаг для отслеживания ошибки при передаче данных 39 | bool _stop_after_request = true; // stop или restart после чтения последнего байта 40 | void start(void); // сервисная функция с нее начинается любая работа с шиной 41 | void stop(void); // сервисная функция ей заканчивается работа с шиной 42 | }; 43 | extern TwoWire Wire; 44 | #endif -------------------------------------------------------------------------------- /firmware/MAX7219/webcamMAX7219/FastIO.h: -------------------------------------------------------------------------------- 1 | #ifndef FastIO_h 2 | #define FastIO_h 3 | // быстрый IO, v1.0 4 | 5 | // быстрое чтение пина 6 | bool fastRead(const uint8_t pin) { 7 | #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__) 8 | if (pin < 8) return bitRead(PIND, pin); 9 | else if (pin < 14) return bitRead(PINB, pin - 8); 10 | else if (pin < 20) return bitRead(PINC, pin - 14); 11 | 12 | #elif defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny13__) 13 | return bitRead(PINB, pin); 14 | 15 | #elif defined(AVR) 16 | uint8_t *_pin_reg = portInputRegister(digitalPinToPort(pin)); 17 | uint8_t _bit_mask = digitalPinToBitMask(pin); 18 | return bool(*_pin_reg & _bit_mask); 19 | 20 | #else 21 | return digitalRead(pin); 22 | 23 | #endif 24 | return 0; 25 | } 26 | 27 | // быстрая запись 28 | void fastWrite(const uint8_t pin, bool val) { 29 | #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__) 30 | if (pin < 8) bitWrite(PORTD, pin, val); 31 | else if (pin < 14) bitWrite(PORTB, (pin - 8), val); 32 | else if (pin < 20) bitWrite(PORTC, (pin - 14), val); 33 | 34 | #elif defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny13__) 35 | bitWrite(PORTB, pin, val); 36 | 37 | #elif defined(AVR) 38 | uint8_t *_port_reg = portInputRegister(digitalPinToPort(pin)); 39 | uint8_t _bit_mask = digitalPinToBitMask(pin); 40 | _port_reg = portOutputRegister(digitalPinToPort(pin)); 41 | _bit_mask = digitalPinToBitMask(pin); 42 | if (val) *_port_reg |= _bit_mask; // HIGH 43 | else *_port_reg &= ~_bit_mask; // LOW 44 | 45 | #else 46 | digitalWrite(pin, val); 47 | 48 | #endif 49 | } 50 | 51 | // быстрый shiftIn 52 | byte fastShiftIn(byte dataPin, byte clockPin, byte bitOrder) { 53 | #if defined(AVR) 54 | volatile uint8_t *_clk_port = portOutputRegister(digitalPinToPort(clockPin)); 55 | volatile uint8_t *_dat_port = portInputRegister(digitalPinToPort(dataPin)); 56 | byte _clk_mask = digitalPinToBitMask(clockPin); 57 | byte _dat_mask = digitalPinToBitMask(dataPin); 58 | byte data = 0; 59 | for (uint8_t i = 0; i < 8; i++) { 60 | *_clk_port |= _clk_mask; 61 | if (bitOrder == MSBFIRST) { 62 | data <<= 1; 63 | if (bool(*_dat_port & _dat_mask)) data |= 1; 64 | } else { 65 | data >>= 1; 66 | if (bool(*_dat_port & _dat_mask)) data |= 1 << 7; 67 | } 68 | *_clk_port &= ~_clk_mask; 69 | } 70 | return data; 71 | #else 72 | return shiftIn(dataPin, clockPin, bitOrder); 73 | #endif 74 | } 75 | 76 | // быстрый shiftOut 77 | void fastShiftOut(byte dataPin, byte clockPin, byte bitOrder, byte data) { 78 | #if defined(AVR) 79 | volatile uint8_t *_clk_port = portOutputRegister(digitalPinToPort(clockPin)); 80 | volatile uint8_t *_dat_port = portOutputRegister(digitalPinToPort(dataPin)); 81 | byte _clk_mask = digitalPinToBitMask(clockPin); 82 | byte _dat_mask = digitalPinToBitMask(dataPin); 83 | for (uint8_t i = 0; i < 8; i++) { 84 | if (bitOrder == MSBFIRST) { 85 | if (data & (1 << 7)) *_dat_port |= _dat_mask; 86 | else *_dat_port &= ~_dat_mask; 87 | data <<= 1; 88 | } else { 89 | if (data & 1) *_dat_port |= _dat_mask; 90 | else *_dat_port &= ~_dat_mask; 91 | data >>= 1; 92 | } 93 | *_clk_port |= _clk_mask; 94 | *_clk_port &= ~_clk_mask; 95 | } 96 | #else 97 | shiftOut(dataPin, clockPin, bitOrder, data); 98 | #endif 99 | } 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /firmware/MAX7219/webcamMAX7219_proc/FastIO.h: -------------------------------------------------------------------------------- 1 | #ifndef FastIO_h 2 | #define FastIO_h 3 | // быстрый IO, v1.0 4 | 5 | // быстрое чтение пина 6 | bool fastRead(const uint8_t pin) { 7 | #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__) 8 | if (pin < 8) return bitRead(PIND, pin); 9 | else if (pin < 14) return bitRead(PINB, pin - 8); 10 | else if (pin < 20) return bitRead(PINC, pin - 14); 11 | 12 | #elif defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny13__) 13 | return bitRead(PINB, pin); 14 | 15 | #elif defined(AVR) 16 | uint8_t *_pin_reg = portInputRegister(digitalPinToPort(pin)); 17 | uint8_t _bit_mask = digitalPinToBitMask(pin); 18 | return bool(*_pin_reg & _bit_mask); 19 | 20 | #else 21 | return digitalRead(pin); 22 | 23 | #endif 24 | return 0; 25 | } 26 | 27 | // быстрая запись 28 | void fastWrite(const uint8_t pin, bool val) { 29 | #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__) 30 | if (pin < 8) bitWrite(PORTD, pin, val); 31 | else if (pin < 14) bitWrite(PORTB, (pin - 8), val); 32 | else if (pin < 20) bitWrite(PORTC, (pin - 14), val); 33 | 34 | #elif defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny13__) 35 | bitWrite(PORTB, pin, val); 36 | 37 | #elif defined(AVR) 38 | uint8_t *_port_reg = portInputRegister(digitalPinToPort(pin)); 39 | uint8_t _bit_mask = digitalPinToBitMask(pin); 40 | _port_reg = portOutputRegister(digitalPinToPort(pin)); 41 | _bit_mask = digitalPinToBitMask(pin); 42 | if (val) *_port_reg |= _bit_mask; // HIGH 43 | else *_port_reg &= ~_bit_mask; // LOW 44 | 45 | #else 46 | digitalWrite(pin, val); 47 | 48 | #endif 49 | } 50 | 51 | // быстрый shiftIn 52 | byte fastShiftIn(byte dataPin, byte clockPin, byte bitOrder) { 53 | #if defined(AVR) 54 | volatile uint8_t *_clk_port = portOutputRegister(digitalPinToPort(clockPin)); 55 | volatile uint8_t *_dat_port = portInputRegister(digitalPinToPort(dataPin)); 56 | byte _clk_mask = digitalPinToBitMask(clockPin); 57 | byte _dat_mask = digitalPinToBitMask(dataPin); 58 | byte data = 0; 59 | for (uint8_t i = 0; i < 8; i++) { 60 | *_clk_port |= _clk_mask; 61 | if (bitOrder == MSBFIRST) { 62 | data <<= 1; 63 | if (bool(*_dat_port & _dat_mask)) data |= 1; 64 | } else { 65 | data >>= 1; 66 | if (bool(*_dat_port & _dat_mask)) data |= 1 << 7; 67 | } 68 | *_clk_port &= ~_clk_mask; 69 | } 70 | return data; 71 | #else 72 | return shiftIn(dataPin, clockPin, bitOrder); 73 | #endif 74 | } 75 | 76 | // быстрый shiftOut 77 | void fastShiftOut(byte dataPin, byte clockPin, byte bitOrder, byte data) { 78 | #if defined(AVR) 79 | volatile uint8_t *_clk_port = portOutputRegister(digitalPinToPort(clockPin)); 80 | volatile uint8_t *_dat_port = portOutputRegister(digitalPinToPort(dataPin)); 81 | byte _clk_mask = digitalPinToBitMask(clockPin); 82 | byte _dat_mask = digitalPinToBitMask(dataPin); 83 | for (uint8_t i = 0; i < 8; i++) { 84 | if (bitOrder == MSBFIRST) { 85 | if (data & (1 << 7)) *_dat_port |= _dat_mask; 86 | else *_dat_port &= ~_dat_mask; 87 | data <<= 1; 88 | } else { 89 | if (data & 1) *_dat_port |= _dat_mask; 90 | else *_dat_port &= ~_dat_mask; 91 | data >>= 1; 92 | } 93 | *_clk_port |= _clk_mask; 94 | *_clk_port &= ~_clk_mask; 95 | } 96 | #else 97 | shiftOut(dataPin, clockPin, bitOrder, data); 98 | #endif 99 | } 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /firmware/MAX7219_mux/webcamMAX7219_mux/FastIO.h: -------------------------------------------------------------------------------- 1 | #ifndef FastIO_h 2 | #define FastIO_h 3 | // быстрый IO, v1.0 4 | 5 | // быстрое чтение пина 6 | bool fastRead(const uint8_t pin) { 7 | #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__) 8 | if (pin < 8) return bitRead(PIND, pin); 9 | else if (pin < 14) return bitRead(PINB, pin - 8); 10 | else if (pin < 20) return bitRead(PINC, pin - 14); 11 | 12 | #elif defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny13__) 13 | return bitRead(PINB, pin); 14 | 15 | #elif defined(AVR) 16 | uint8_t *_pin_reg = portInputRegister(digitalPinToPort(pin)); 17 | uint8_t _bit_mask = digitalPinToBitMask(pin); 18 | return bool(*_pin_reg & _bit_mask); 19 | 20 | #else 21 | return digitalRead(pin); 22 | 23 | #endif 24 | return 0; 25 | } 26 | 27 | // быстрая запись 28 | void fastWrite(const uint8_t pin, bool val) { 29 | #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__) 30 | if (pin < 8) bitWrite(PORTD, pin, val); 31 | else if (pin < 14) bitWrite(PORTB, (pin - 8), val); 32 | else if (pin < 20) bitWrite(PORTC, (pin - 14), val); 33 | 34 | #elif defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny13__) 35 | bitWrite(PORTB, pin, val); 36 | 37 | #elif defined(AVR) 38 | uint8_t *_port_reg = portInputRegister(digitalPinToPort(pin)); 39 | uint8_t _bit_mask = digitalPinToBitMask(pin); 40 | _port_reg = portOutputRegister(digitalPinToPort(pin)); 41 | _bit_mask = digitalPinToBitMask(pin); 42 | if (val) *_port_reg |= _bit_mask; // HIGH 43 | else *_port_reg &= ~_bit_mask; // LOW 44 | 45 | #else 46 | digitalWrite(pin, val); 47 | 48 | #endif 49 | } 50 | 51 | // быстрый shiftIn 52 | byte fastShiftIn(byte dataPin, byte clockPin, byte bitOrder) { 53 | #if defined(AVR) 54 | volatile uint8_t *_clk_port = portOutputRegister(digitalPinToPort(clockPin)); 55 | volatile uint8_t *_dat_port = portInputRegister(digitalPinToPort(dataPin)); 56 | byte _clk_mask = digitalPinToBitMask(clockPin); 57 | byte _dat_mask = digitalPinToBitMask(dataPin); 58 | byte data = 0; 59 | for (uint8_t i = 0; i < 8; i++) { 60 | *_clk_port |= _clk_mask; 61 | if (bitOrder == MSBFIRST) { 62 | data <<= 1; 63 | if (bool(*_dat_port & _dat_mask)) data |= 1; 64 | } else { 65 | data >>= 1; 66 | if (bool(*_dat_port & _dat_mask)) data |= 1 << 7; 67 | } 68 | *_clk_port &= ~_clk_mask; 69 | } 70 | return data; 71 | #else 72 | return shiftIn(dataPin, clockPin, bitOrder); 73 | #endif 74 | } 75 | 76 | // быстрый shiftOut 77 | void fastShiftOut(byte dataPin, byte clockPin, byte bitOrder, byte data) { 78 | #if defined(AVR) 79 | volatile uint8_t *_clk_port = portOutputRegister(digitalPinToPort(clockPin)); 80 | volatile uint8_t *_dat_port = portOutputRegister(digitalPinToPort(dataPin)); 81 | byte _clk_mask = digitalPinToBitMask(clockPin); 82 | byte _dat_mask = digitalPinToBitMask(dataPin); 83 | for (uint8_t i = 0; i < 8; i++) { 84 | if (bitOrder == MSBFIRST) { 85 | if (data & (1 << 7)) *_dat_port |= _dat_mask; 86 | else *_dat_port &= ~_dat_mask; 87 | data <<= 1; 88 | } else { 89 | if (data & 1) *_dat_port |= _dat_mask; 90 | else *_dat_port &= ~_dat_mask; 91 | data >>= 1; 92 | } 93 | *_clk_port |= _clk_mask; 94 | *_clk_port &= ~_clk_mask; 95 | } 96 | #else 97 | shiftOut(dataPin, clockPin, bitOrder, data); 98 | #endif 99 | } 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /firmware/OLED/webcamOLED_proc/dither.pde: -------------------------------------------------------------------------------- 1 | // ================== ФИЛЬТР DITHERING ================== 2 | 3 | // https://gist.github.com/joshmurr/7998502 4 | color[] colorPalette = new color[] { 5 | color(0, 0, 0), 6 | color(0, 0, 255), 7 | color(0, 255, 0), 8 | color(0, 255, 255), 9 | color(255, 0, 0), 10 | color(255, 0, 255), 11 | color(255, 255, 0), 12 | color(255, 255, 255) 13 | }; 14 | 15 | color[] greyPalette = new color[] { 16 | color(0), 17 | color(51), 18 | color(102), 19 | color(153), 20 | color(204), 21 | color(255) 22 | }; 23 | 24 | color[] bwPalette = new color[] { 25 | color(0, 0, 0), 26 | color(255, 255, 255) 27 | }; 28 | 29 | color[] rbPalette = new color[] { 30 | color(255, 0, 0), 31 | color(0, 0, 255) 32 | }; 33 | 34 | color[] rPalette = new color[] { 35 | color(156, 7, 201), 36 | color(9, 245, 89) 37 | }; 38 | 39 | void ditherImage(PImage img) { 40 | img.loadPixels(); 41 | int w = img.width; 42 | int h = img.height; 43 | 44 | color[][] p = new color[h][w]; 45 | float s = 7.0/16; 46 | float t = 3.0/16; 47 | float f = 5.0/16; 48 | float o = 1.0/16; 49 | 50 | for (int y=0; y> 16 & 0xFF) + s * qr; 71 | float ng = (p[y][x+1] >> 8 & 0xFF) + s * qg; 72 | float nb = (p[y][x+1] & 0xFF) + s * qb; 73 | p[y][x+1] = color(nr, ng, nb); 74 | } 75 | 76 | if (x-1>=0 && y+1> 16 & 0xFF) + t * qr; 78 | float ng = (p[y+1][x-1] >> 8 & 0xFF) + t * qg; 79 | float nb = (p[y+1][x-1] & 0xFF) + t * qb; 80 | p[y+1][x-1] = color(nr, ng, nb); 81 | } 82 | if (y+1 < h) { 83 | float nr = (p[y+1][x] >> 16 & 0xFF) + f * qr; 84 | float ng = (p[y+1][x] >> 8 & 0xFF) + f * qg; 85 | float nb = (p[y+1][x] & 0xFF) + f * qb; 86 | p[y+1][x] = color(nr, ng, nb); 87 | } 88 | if (x+1> 16 & 0xFF) + o * qr; 90 | float ng = (p[y+1][x+1] >> 8 & 0xFF) + o * qg; 91 | float nb = (p[y+1][x+1] & 0xFF) + o * qb; 92 | p[y+1][x+1] = color(nr, ng, nb); 93 | } 94 | } 95 | } 96 | 97 | img.updatePixels(); 98 | image(img, 0, 0); 99 | } 100 | 101 | color find_new_color(color c, color[] palette) { 102 | int bestIndex = 0; 103 | 104 | PVector[] vpalette = new PVector[palette.length]; 105 | PVector vcolor = new PVector((c >> 16 & 0xFF), (c >> 8 & 0xFF), (c & 0xFF)); 106 | float distance = vcolor.dist(new PVector(0, 0, 0)); 107 | 108 | for (int i=0; i> 16 & 0xFF), (palette[i] >> 8 & 0xFF), (palette[i] & 0xFF)); 110 | float d = vcolor.dist(vpalette[i]); 111 | if (d < distance) { 112 | distance = d; 113 | bestIndex = i; 114 | } 115 | } 116 | return palette[bestIndex]; 117 | } 118 | -------------------------------------------------------------------------------- /firmware/MAX7219/webcamMAX7219_proc/dither.pde: -------------------------------------------------------------------------------- 1 | // ================== ФИЛЬТР DITHERING ================== 2 | 3 | // https://gist.github.com/joshmurr/7998502 4 | color[] colorPalette = new color[] { 5 | color(0, 0, 0), 6 | color(0, 0, 255), 7 | color(0, 255, 0), 8 | color(0, 255, 255), 9 | color(255, 0, 0), 10 | color(255, 0, 255), 11 | color(255, 255, 0), 12 | color(255, 255, 255) 13 | }; 14 | 15 | color[] greyPalette = new color[] { 16 | color(0), 17 | color(51), 18 | color(102), 19 | color(153), 20 | color(204), 21 | color(255) 22 | }; 23 | 24 | color[] bwPalette = new color[] { 25 | color(0, 0, 0), 26 | color(255, 255, 255) 27 | }; 28 | 29 | color[] rbPalette = new color[] { 30 | color(255, 0, 0), 31 | color(0, 0, 255) 32 | }; 33 | 34 | color[] rPalette = new color[] { 35 | color(156, 7, 201), 36 | color(9, 245, 89) 37 | }; 38 | 39 | void ditherImage(PImage img) { 40 | img.loadPixels(); 41 | int w = img.width; 42 | int h = img.height; 43 | 44 | color[][] p = new color[h][w]; 45 | float s = 7.0/16; 46 | float t = 3.0/16; 47 | float f = 5.0/16; 48 | float o = 1.0/16; 49 | 50 | for (int y=0; y> 16 & 0xFF) + s * qr; 71 | float ng = (p[y][x+1] >> 8 & 0xFF) + s * qg; 72 | float nb = (p[y][x+1] & 0xFF) + s * qb; 73 | p[y][x+1] = color(nr, ng, nb); 74 | } 75 | 76 | if (x-1>=0 && y+1> 16 & 0xFF) + t * qr; 78 | float ng = (p[y+1][x-1] >> 8 & 0xFF) + t * qg; 79 | float nb = (p[y+1][x-1] & 0xFF) + t * qb; 80 | p[y+1][x-1] = color(nr, ng, nb); 81 | } 82 | if (y+1 < h) { 83 | float nr = (p[y+1][x] >> 16 & 0xFF) + f * qr; 84 | float ng = (p[y+1][x] >> 8 & 0xFF) + f * qg; 85 | float nb = (p[y+1][x] & 0xFF) + f * qb; 86 | p[y+1][x] = color(nr, ng, nb); 87 | } 88 | if (x+1> 16 & 0xFF) + o * qr; 90 | float ng = (p[y+1][x+1] >> 8 & 0xFF) + o * qg; 91 | float nb = (p[y+1][x+1] & 0xFF) + o * qb; 92 | p[y+1][x+1] = color(nr, ng, nb); 93 | } 94 | } 95 | } 96 | 97 | img.updatePixels(); 98 | image(img, 0, 0); 99 | } 100 | 101 | color find_new_color(color c, color[] palette) { 102 | int bestIndex = 0; 103 | 104 | PVector[] vpalette = new PVector[palette.length]; 105 | PVector vcolor = new PVector((c >> 16 & 0xFF), (c >> 8 & 0xFF), (c & 0xFF)); 106 | float distance = vcolor.dist(new PVector(0, 0, 0)); 107 | 108 | for (int i=0; i> 16 & 0xFF), (palette[i] >> 8 & 0xFF), (palette[i] & 0xFF)); 110 | float d = vcolor.dist(vpalette[i]); 111 | if (d < distance) { 112 | distance = d; 113 | bestIndex = i; 114 | } 115 | } 116 | return palette[bestIndex]; 117 | } 118 | -------------------------------------------------------------------------------- /firmware/MAX7219_mux/webcamMAX7219_proc_mux/dither.pde: -------------------------------------------------------------------------------- 1 | // ================== ФИЛЬТР DITHERING ================== 2 | 3 | // https://gist.github.com/joshmurr/7998502 4 | color[] colorPalette = new color[] { 5 | color(0, 0, 0), 6 | color(0, 0, 255), 7 | color(0, 255, 0), 8 | color(0, 255, 255), 9 | color(255, 0, 0), 10 | color(255, 0, 255), 11 | color(255, 255, 0), 12 | color(255, 255, 255) 13 | }; 14 | 15 | color[] greyPalette = new color[] { 16 | color(0), 17 | color(51), 18 | color(102), 19 | color(153), 20 | color(204), 21 | color(255) 22 | }; 23 | 24 | color[] bwPalette = new color[] { 25 | color(0, 0, 0), 26 | color(255, 255, 255) 27 | }; 28 | 29 | color[] rbPalette = new color[] { 30 | color(255, 0, 0), 31 | color(0, 0, 255) 32 | }; 33 | 34 | color[] rPalette = new color[] { 35 | color(156, 7, 201), 36 | color(9, 245, 89) 37 | }; 38 | 39 | void ditherImage(PImage img) { 40 | img.loadPixels(); 41 | int w = img.width; 42 | int h = img.height; 43 | 44 | color[][] p = new color[h][w]; 45 | float s = 7.0/16; 46 | float t = 3.0/16; 47 | float f = 5.0/16; 48 | float o = 1.0/16; 49 | 50 | for (int y=0; y> 16 & 0xFF) + s * qr; 71 | float ng = (p[y][x+1] >> 8 & 0xFF) + s * qg; 72 | float nb = (p[y][x+1] & 0xFF) + s * qb; 73 | p[y][x+1] = color(nr, ng, nb); 74 | } 75 | 76 | if (x-1>=0 && y+1> 16 & 0xFF) + t * qr; 78 | float ng = (p[y+1][x-1] >> 8 & 0xFF) + t * qg; 79 | float nb = (p[y+1][x-1] & 0xFF) + t * qb; 80 | p[y+1][x-1] = color(nr, ng, nb); 81 | } 82 | if (y+1 < h) { 83 | float nr = (p[y+1][x] >> 16 & 0xFF) + f * qr; 84 | float ng = (p[y+1][x] >> 8 & 0xFF) + f * qg; 85 | float nb = (p[y+1][x] & 0xFF) + f * qb; 86 | p[y+1][x] = color(nr, ng, nb); 87 | } 88 | if (x+1> 16 & 0xFF) + o * qr; 90 | float ng = (p[y+1][x+1] >> 8 & 0xFF) + o * qg; 91 | float nb = (p[y+1][x+1] & 0xFF) + o * qb; 92 | p[y+1][x+1] = color(nr, ng, nb); 93 | } 94 | } 95 | } 96 | 97 | img.updatePixels(); 98 | image(img, 0, 0); 99 | } 100 | 101 | color find_new_color(color c, color[] palette) { 102 | int bestIndex = 0; 103 | 104 | PVector[] vpalette = new PVector[palette.length]; 105 | PVector vcolor = new PVector((c >> 16 & 0xFF), (c >> 8 & 0xFF), (c & 0xFF)); 106 | float distance = vcolor.dist(new PVector(0, 0, 0)); 107 | 108 | for (int i=0; i> 16 & 0xFF), (palette[i] >> 8 & 0xFF), (palette[i] & 0xFF)); 110 | float d = vcolor.dist(vpalette[i]); 111 | if (d < distance) { 112 | distance = d; 113 | bestIndex = i; 114 | } 115 | } 116 | return palette[bestIndex]; 117 | } 118 | -------------------------------------------------------------------------------- /firmware/telegram4/FastBot.h: -------------------------------------------------------------------------------- 1 | // очень простая и быстрая библиотека для телеграм бота 2 | // оптимизирована для большой нагрузки (спокойно принимает 50 сообщ в секунду) 3 | 4 | #ifndef FastBot_h 5 | #define FastBot_h 6 | #include 7 | #include 8 | #include 9 | static std::unique_ptrclient(new BearSSL::WiFiClientSecure); 10 | static HTTPClient https; 11 | 12 | /* 13 | Статусы tick: 14 | 0 - ожидание 15 | 1 - ОК 16 | 2 - Переполнен по ovf 17 | 3 - Ошибка телеграм 18 | 4 - Ошибка подключения 19 | */ 20 | 21 | class FastBot { 22 | public: 23 | FastBot (String token, int limit = 10, int ovf = 10000, int period = 1000) { 24 | _request = (String)"https://api.telegram.org/bot" + token + "/getUpdates?limit=" + limit + "&offset="; 25 | _ovf = ovf; 26 | _period = period; 27 | client->setInsecure(); 28 | } 29 | void setChatID(String chatID) { 30 | _chatID = chatID; 31 | } 32 | 33 | void attach(void (*handler)(String&)) { 34 | _callback = handler; 35 | } 36 | 37 | byte tickManual() { 38 | byte status = 1; 39 | if (https.begin(*client, _request + ID)) { 40 | if (https.GET() == HTTP_CODE_OK) { 41 | if (https.getSize() > _ovf) { 42 | int IDpos = https.getString().indexOf("{\"update_id\":", IDpos); 43 | if (IDpos > 0) ID = https.getString().substring(IDpos + 13, https.getString().indexOf(',', IDpos)).toInt(); 44 | ID++; 45 | https.end(); 46 | return 2; 47 | } 48 | 49 | // считаем, сколько в пакете данных (метка update_id) 50 | int count = 0; 51 | int IDpos = 0; 52 | while (1) { 53 | IDpos = https.getString().indexOf("{\"update_id\":", IDpos); 54 | if (IDpos > 0) { 55 | ID = https.getString().substring(IDpos + 13, https.getString().indexOf(',', IDpos)).toInt() + 1; // сразу ++ для следующего пакета 56 | IDpos++; 57 | count++; 58 | } else break; 59 | } 60 | 61 | // считаем и парсим сообщения 62 | if (count) { 63 | int textPos = 0; 64 | while (1) { 65 | if (_chatID.length() > 0) { 66 | textPos = https.getString().indexOf("\"chat\":{\"id\":", textPos); 67 | if (textPos < 0) break; 68 | int endPos = https.getString().indexOf(",\"", textPos); 69 | String chatID = https.getString().substring(textPos + 13, endPos); 70 | textPos = endPos; 71 | if (!chatID.equals(_chatID)) continue; 72 | } 73 | textPos = https.getString().indexOf(",\"text\":\"", textPos); 74 | if (textPos < 0) break; 75 | int endPos = https.getString().indexOf("\"}}", textPos); 76 | int endPos2 = https.getString().indexOf("\",\"entities", textPos); 77 | if (endPos > 0 && endPos2 > 0) endPos = min(endPos, endPos2); 78 | else if (endPos < 0) endPos = endPos2; 79 | //if (https.getString()[textPos + 9] == '/') textPos++; 80 | String str = https.getString().substring(textPos + 9, endPos); 81 | if (*_callback) _callback(str); 82 | textPos = endPos; 83 | yield(); 84 | } 85 | } 86 | } else status = 3; 87 | https.end(); 88 | } else status = 4; 89 | return status; 90 | } 91 | 92 | byte tick() { 93 | if (millis() - tmr >= _period) { 94 | tmr = millis(); 95 | return tickManual(); 96 | } 97 | return 0; 98 | } 99 | 100 | private: 101 | void (*_callback)(String& str) = NULL; 102 | String _request; 103 | int _ovf = 5000, _period = 1000; 104 | long ID = 0; 105 | uint32_t tmr = 0; 106 | String _chatID = ""; 107 | }; 108 | #endif 109 | -------------------------------------------------------------------------------- /firmware/telegram/GyverMAX7219.h: -------------------------------------------------------------------------------- 1 | #ifndef GyverMAX7219_h 2 | #define GyverMAX7219_h 3 | // самая резкая библиотека для матриц MAX7219 на диком западе 4 | 5 | #include 6 | #include 7 | #include "FastIO.h" 8 | 9 | #ifndef MAX_SPI_SPEED 10 | #define MAX_SPI_SPEED 1000000 11 | #endif 12 | 13 | template 14 | class MAX7219 { 15 | public: 16 | MAX7219() { 17 | begin(); 18 | } 19 | ~MAX7219() { 20 | SPI.end(); 21 | SPI.endTransaction(); 22 | } 23 | void begin() { 24 | pinMode(CSpin, OUTPUT); 25 | SPI.begin(); 26 | SPI.beginTransaction(SPISettings(MAX_SPI_SPEED, MSBFIRST, SPI_MODE0)); 27 | sendCMD(0x0f, 0x00); // отключить режим теста 28 | sendCMD(0x09, 0x00); // выключить декодирование 29 | sendCMD(0x0a, 0x00); // яркость 30 | sendCMD(0x0b, 0x0f); // отображаем всё 31 | sendCMD(0x0C, 0x01); // включить 32 | clear(); 33 | } 34 | void setBright(byte value) { // 8x8: 0/8/15 - 30/310/540 ma 35 | sendCMD(0x0a, value); // яркость 0-15 36 | } 37 | void setPower(bool value) { 38 | sendCMD(0x0c, value); 39 | } 40 | void clear() { 41 | fillMatrix(0); 42 | } 43 | void fill() { 44 | fillMatrix(255); 45 | } 46 | void fillMatrix(byte data) { 47 | if (buf) { 48 | for (int i = 0; i < width * height * 8; i++) buffer[i] = data; 49 | } else { 50 | for (int k = 7; k >= 0; k--) { 51 | beginData(); 52 | for (int i = 0; i < _amount; i++) sendByte(k, data); 53 | endData(); 54 | } 55 | } 56 | } 57 | void sendByte(uint8_t address, uint8_t value) { 58 | SPI.transfer(8 - address); 59 | SPI.transfer(value); 60 | } 61 | void dot(int x, int y, byte fill = 1) { 62 | if (buf && x >= 0 && x < width * 8 && y >= 0 && y < height * 8) { 63 | if ((y >> 3) & 1) { // если это нечётная матрица: (y / 8) % 2 64 | x = width * 8 - 1 - x; // отзеркалить x 65 | y = (y & 0xF8) + (7 - (y & 7)); // отзеркалить y: (y / 8) * 8 + (7 - (y % 8)); 66 | } 67 | // позиция в буфере 68 | int curByte = width * (height - 1 - (y >> 3)) + (width - 1 - (x >> 3)) + (y & 7) * width * height; 69 | bitWrite(buffer[curByte], x & 7, fill); 70 | } 71 | } 72 | void update() { 73 | if (buf) { 74 | int count = 0; 75 | for (int k = 0; k < 8; k++) { 76 | beginData(); 77 | for (int i = 0; i < _amount; i++) sendByte(k, buffer[count++]); 78 | endData(); 79 | } 80 | } 81 | } 82 | 83 | // stream 84 | void restartStream() { 85 | _row = 0; 86 | _count = 0; 87 | } 88 | void nextByte(byte data) { 89 | if (_row == 8) return; 90 | if (_count == 0) beginData(); 91 | sendByte(_row, data); 92 | if (++_count == _amount) { 93 | endData(); 94 | _count = 0; 95 | _row++; 96 | } 97 | } 98 | byte buffer[width * height * 8 * buf]; 99 | private: 100 | void beginData() { 101 | fastWrite(CSpin, 0); 102 | } 103 | void endData() { 104 | fastWrite(CSpin, 1); 105 | } 106 | void sendCMD(uint8_t address, uint8_t value) { 107 | beginData(); 108 | for (int i = 0; i < _amount; i++) { 109 | SPI.transfer(address); 110 | SPI.transfer(value); 111 | } 112 | endData(); 113 | } 114 | 115 | const int _amount = width * height; 116 | int _row = 0, _count = 0; 117 | }; 118 | #endif 119 | -------------------------------------------------------------------------------- /libraries/GyverOLED/examples/graphics2/graphics2.ino: -------------------------------------------------------------------------------- 1 | #include 2 | GyverOLED oled; 3 | // можно передать адрес: GyverOLED oled(0x3C); 4 | 5 | void setup() { 6 | Serial.begin(9600); 7 | oled.init(); // инициализация 8 | Wire.setClock(400000L); 9 | oled.clear(); 10 | oled.update(); 11 | } 12 | 13 | void loop() { 14 | //lines(); 15 | //ball(); 16 | //bezier(); 17 | bezier2(); 18 | //bigBall(); 19 | } 20 | 21 | void bezier2() { 22 | const byte amount = 3; 23 | static bool start = false; 24 | static int x[amount], y[amount]; 25 | static int velX[amount], velY[amount]; 26 | if (!start) { 27 | start = 1; 28 | for (byte i = 0; i < amount; i++) { 29 | x[i] = random(10, (128 - 1) * 10); 30 | y[i] = random(10, (64 - 1) * 10); 31 | velX[i] = random(5, 20); 32 | velY[i] = random(5, 20); 33 | } 34 | } 35 | oled.clear(); 36 | int bez[(amount + 1) * 2]; 37 | for (byte i = 0; i < amount; i++) { 38 | x[i] += velX[i]; 39 | y[i] += velY[i]; 40 | if (x[i] >= (128 - 1) * 10 || x[i] < 0) velX[i] = -velX[i]; 41 | if (y[i] >= (64 - 1) * 10 || y[i] < 0) velY[i] = -velY[i]; 42 | oled.dot(x[i] / 10, y[i] / 10, 1); 43 | bez[i * 2] = x[i] / 10; 44 | bez[i * 2 + 1] = y[i] / 10; 45 | } 46 | bez[amount * 2] = bez[0]; 47 | bez[amount * 2 + 1] = bez[1]; 48 | 49 | oled.bezier(bez, amount + 1, 8); 50 | oled.update(); 51 | } 52 | 53 | void bigBall() { 54 | oled.clear(); 55 | byte radius = 5; 56 | static int x = (128 / 2) * 10, y = (64 / 2) * 10; 57 | static int velX = 9, velY = 6; 58 | static bool fillFlag = 0; 59 | x += velX; 60 | y += velY; 61 | if (x >= (128 - 4) * 10 || x < radius * 10) { 62 | velX = -velX; 63 | fillFlag = !fillFlag; 64 | } 65 | if (y >= (64 - 4) * 10 || y < radius * 10) { 66 | velY = -velY; 67 | fillFlag = !fillFlag; 68 | } 69 | 70 | oled.circle(x / 10, y / 10, radius, fillFlag ? OLED_STROKE : OLED_FILL); 71 | oled.update(); 72 | } 73 | 74 | void bezier() { 75 | int data[] = {0, 0, 128 / 2, 64 / 2, 0, 64 - 1}; 76 | for (int i = 0; i < 128; i++) { 77 | oled.clear(); 78 | data[0] = data[4] = 128 - i; 79 | data[2] = i; 80 | oled.bezier(data, 3, 7); 81 | oled.update(); 82 | } 83 | for (int i = 128; i > 0; i--) { 84 | oled.clear(); 85 | data[0] = data[4] = 128 - i; 86 | data[2] = i; 87 | oled.bezier(data, 3, 7); 88 | oled.update(); 89 | } 90 | } 91 | 92 | void lines() { 93 | oled.clear(); 94 | for (byte i = 0; i < 128 - 1; i += 3) { 95 | oled.line(0, 0, i, 64); 96 | oled.update(); 97 | delay(30); 98 | } 99 | for (byte i = 0; i < 64 - 1; i += 3) { 100 | oled.line(0, 0, 128, i); 101 | oled.update(); 102 | delay(30); 103 | } 104 | delay(100); 105 | 106 | oled.clear(); 107 | for (int i = 128 - 1; i > 0; i -= 3) { 108 | oled.line(128 - 1, 0, i, 64); 109 | oled.update(); 110 | delay(30); 111 | } 112 | for (int i = 0; i < 64; i += 3) { 113 | oled.line(128 - 1, 64 - 1, 0, i); 114 | oled.update(); 115 | delay(30); 116 | } 117 | delay(100); 118 | } 119 | 120 | void ball() { 121 | oled.clear(); 122 | static int x, y; 123 | static int velX = 5, velY = 8; 124 | x += velX; 125 | y += velY; 126 | if (x >= (128 - 1) * 10 || x < 0) velX = -velX; 127 | if (y >= (64 - 1) * 10 || y < 0) velY = -velY; 128 | 129 | oled.dot(x / 10, y / 10, 1); 130 | oled.dot(x / 10 + 1, y / 10 + 1, 1); 131 | oled.dot(x / 10 + 1, y / 10, 1); 132 | oled.dot(x / 10, y / 10 + 1, 1); 133 | oled.update(); 134 | delay(10); 135 | } 136 | -------------------------------------------------------------------------------- /firmware/MAX7219/webcamMAX7219/GyverMAX7219.h: -------------------------------------------------------------------------------- 1 | #ifndef GyverMAX7219_h 2 | #define GyverMAX7219_h 3 | // самая резкая библиотека для матриц MAX7219 на диком западе 4 | 5 | #include 6 | #include 7 | #include "GyverGFX.h" 8 | #include "FastIO.h" 9 | 10 | #ifndef MAX_SPI_SPEED 11 | #define MAX_SPI_SPEED 1000000 12 | #endif 13 | 14 | template 15 | class MAX7219 : public GyverGFX { 16 | public: 17 | MAX7219() { 18 | begin(); 19 | } 20 | ~MAX7219() { 21 | SPI.end(); 22 | SPI.endTransaction(); 23 | } 24 | void begin() { 25 | pinMode(CSpin, OUTPUT); 26 | SPI.begin(); 27 | SPI.beginTransaction(SPISettings(MAX_SPI_SPEED, MSBFIRST, SPI_MODE0)); 28 | sendCMD(0x0f, 0x00); // отключить режим теста 29 | sendCMD(0x09, 0x00); // выключить декодирование 30 | sendCMD(0x0a, 0x00); // яркость 31 | sendCMD(0x0b, 0x0f); // отображаем всё 32 | sendCMD(0x0C, 0x01); // включить 33 | clear(); 34 | } 35 | void setBright(byte value) { // 8x8: 0/8/15 - 30/310/540 ma 36 | sendCMD(0x0a, value); // яркость 0-15 37 | } 38 | void setPower(bool value) { 39 | sendCMD(0x0c, value); 40 | } 41 | void clear() { 42 | fillMatrix(0); 43 | } 44 | void fill() { 45 | fillMatrix(255); 46 | } 47 | void fillMatrix(byte data) { 48 | if (buf) { 49 | for (int i = 0; i < width * height * 8; i++) buffer[i] = data; 50 | } else { 51 | for (int k = 7; k >= 0; k--) { 52 | beginData(); 53 | for (int i = 0; i < _amount; i++) sendByte(k, data); 54 | endData(); 55 | } 56 | } 57 | } 58 | void sendByte(uint8_t address, uint8_t value) { 59 | SPI.transfer(8 - address); 60 | SPI.transfer(value); 61 | } 62 | void dot(int x, int y, byte fill = 1) { 63 | if (buf && x >= 0 && x < width * 8 && y >= 0 && y < height * 8) { 64 | if ((y >> 3) & 1) { // если это нечётная матрица: (y / 8) % 2 65 | x = width * 8 - 1 - x; // отзеркалить x 66 | y = (y & 0xF8) + (7 - (y & 7)); // отзеркалить y: (y / 8) * 8 + (7 - (y % 8)); 67 | } 68 | // позиция в буфере 69 | int curByte = width * (height - 1 - (y >> 3)) + (width - 1 - (x >> 3)) + (y & 7) * width * height; 70 | bitWrite(buffer[curByte], x & 7, fill); 71 | } 72 | } 73 | void update() { 74 | if (buf) { 75 | int count = 0; 76 | for (int k = 0; k < 8; k++) { 77 | beginData(); 78 | for (int i = 0; i < _amount; i++) sendByte(k, buffer[count++]); 79 | endData(); 80 | } 81 | } 82 | } 83 | 84 | // stream 85 | void restartStream() { 86 | _row = 0; 87 | _count = 0; 88 | } 89 | void nextByte(byte data) { 90 | if (_row == 8) return; 91 | if (_count == 0) beginData(); 92 | sendByte(_row, data); 93 | if (++_count == _amount) { 94 | endData(); 95 | _count = 0; 96 | _row++; 97 | } 98 | } 99 | byte buffer[width * height * 8 * buf]; 100 | private: 101 | void beginData() { 102 | fastWrite(CSpin, 0); 103 | } 104 | void endData() { 105 | fastWrite(CSpin, 1); 106 | } 107 | void sendCMD(uint8_t address, uint8_t value) { 108 | beginData(); 109 | for (int i = 0; i < _amount; i++) { 110 | SPI.transfer(address); 111 | SPI.transfer(value); 112 | } 113 | endData(); 114 | } 115 | 116 | const int _amount = width * height; 117 | int _row = 0, _count = 0; 118 | }; 119 | #endif 120 | -------------------------------------------------------------------------------- /firmware/telegram4/GyverMAX7219.h: -------------------------------------------------------------------------------- 1 | #ifndef GyverMAX7219_h 2 | #define GyverMAX7219_h 3 | // самая резкая библиотека для матриц MAX7219 на диком западе 4 | 5 | #include 6 | #include 7 | #include "GyverGFX.h" 8 | #include "FastIO.h" 9 | 10 | #ifndef MAX_SPI_SPEED 11 | #define MAX_SPI_SPEED 1000000 12 | #endif 13 | 14 | template 15 | class MAX7219 : public GyverGFX { 16 | public: 17 | MAX7219() : GyverGFX(width * 8, height * 8) { 18 | begin(); 19 | } 20 | ~MAX7219() { 21 | SPI.end(); 22 | SPI.endTransaction(); 23 | } 24 | void begin() { 25 | pinMode(CSpin, OUTPUT); 26 | SPI.begin(); 27 | SPI.beginTransaction(SPISettings(MAX_SPI_SPEED, MSBFIRST, SPI_MODE0)); 28 | sendCMD(0x0f, 0x00); // отключить режим теста 29 | sendCMD(0x09, 0x00); // выключить декодирование 30 | sendCMD(0x0a, 0x00); // яркость 31 | sendCMD(0x0b, 0x0f); // отображаем всё 32 | sendCMD(0x0C, 0x01); // включить 33 | //clear(); 34 | } 35 | void setBright(byte value) { // 8x8: 0/8/15 - 30/310/540 ma 36 | sendCMD(0x0a, value); // яркость 0-15 37 | } 38 | void setPower(bool value) { 39 | sendCMD(0x0c, value); 40 | } 41 | void clear() { 42 | fillMatrix(0); 43 | } 44 | void fill() { 45 | fillMatrix(255); 46 | } 47 | void fillMatrix(byte data) { 48 | if (buf) { 49 | for (int i = 0; i < width * height * 8; i++) buffer[i] = data; 50 | } else { 51 | for (int k = 7; k >= 0; k--) { 52 | beginData(); 53 | for (int i = 0; i < _amount; i++) sendByte(k, data); 54 | endData(); 55 | } 56 | } 57 | } 58 | void sendByte(uint8_t address, uint8_t value) { 59 | SPI.transfer(8 - address); 60 | SPI.transfer(value); 61 | } 62 | void dot(int x, int y, byte fill = 1) { 63 | if (buf && x >= 0 && x < width * 8 && y >= 0 && y < height * 8) { 64 | if ((y >> 3) & 1) { // если это нечётная матрица: (y / 8) % 2 65 | x = width * 8 - 1 - x; // отзеркалить x 66 | y = (y & 0xF8) + (7 - (y & 7)); // отзеркалить y: (y / 8) * 8 + (7 - (y % 8)); 67 | } 68 | // позиция в буфере 69 | int curByte = width * (height - 1 - (y >> 3)) + (width - 1 - (x >> 3)) + (y & 7) * width * height; 70 | bitWrite(buffer[curByte], x & 7, fill); 71 | } 72 | } 73 | void update() { 74 | if (buf) { 75 | int count = 0; 76 | for (int k = 0; k < 8; k++) { 77 | beginData(); 78 | for (int i = 0; i < _amount; i++) sendByte(k, buffer[count++]); 79 | endData(); 80 | } 81 | } 82 | } 83 | 84 | // stream 85 | void restartStream() { 86 | _row = 0; 87 | _count = 0; 88 | } 89 | void nextByte(byte data) { 90 | if (_row == 8) return; 91 | if (_count == 0) beginData(); 92 | sendByte(_row, data); 93 | if (++_count == _amount) { 94 | endData(); 95 | _count = 0; 96 | _row++; 97 | } 98 | } 99 | byte buffer[width * height * 8 * buf]; 100 | private: 101 | void beginData() { 102 | fastWrite(CSpin, 0); 103 | } 104 | void endData() { 105 | fastWrite(CSpin, 1); 106 | } 107 | void sendCMD(uint8_t address, uint8_t value) { 108 | beginData(); 109 | for (int i = 0; i < _amount; i++) { 110 | SPI.transfer(address); 111 | SPI.transfer(value); 112 | } 113 | endData(); 114 | } 115 | 116 | const int _amount = width * height; 117 | int _row = 0, _count = 0; 118 | }; 119 | #endif 120 | -------------------------------------------------------------------------------- /libraries/Adafruit-GFX-Library/README.md: -------------------------------------------------------------------------------- 1 | # Adafruit GFX Library ![Build Status](https://github.com/adafruit/Adafruit-GFX-Library/workflows/Arduino%20Library%20CI/badge.svg) 2 | 3 | This is the core graphics library for all our displays, providing a common set of graphics primitives (points, lines, circles, etc.). It needs to be paired with a hardware-specific library for each display device we carry (to handle the lower-level functions). 4 | 5 | Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit! 6 | 7 | Written by Limor Fried/Ladyada for Adafruit Industries. 8 | BSD license, check license.txt for more information. 9 | All text above must be included in any redistribution. 10 | 11 | Recent Arduino IDE releases include the Library Manager for easy installation. Otherwise, to download, click the DOWNLOAD ZIP button, uncompress and rename the uncompressed folder Adafruit_GFX. Confirm that the Adafruit_GFX folder contains Adafruit_GFX.cpp and Adafruit_GFX.h. Place the Adafruit_GFX library folder your ArduinoSketchFolder/Libraries/ folder. You may need to create the Libraries subfolder if its your first library. Restart the IDE. 12 | 13 | **You will also need to install the latest Adafruit BusIO library.** Search for "Adafruit BusIO" in the library manager, or install by hand from https://github.com/adafruit/Adafruit_BusIO 14 | 15 | # Useful Resources 16 | 17 | - Image2Code: This is a handy Java GUI utility to convert a BMP file into the array code necessary to display the image with the drawBitmap function. Check out the code at ehubin's GitHub repository: https://github.com/ehubin/Adafruit-GFX-Library/tree/master/Img2Code 18 | 19 | - drawXBitmap function: You can use the GIMP photo editor to save a .xbm file and use the array saved in the file to draw a bitmap with the drawXBitmap function. See the pull request here for more details: https://github.com/adafruit/Adafruit-GFX-Library/pull/31 20 | 21 | - 'Fonts' folder contains bitmap fonts for use with recent (1.1 and later) Adafruit_GFX. To use a font in your Arduino sketch, \#include the corresponding .h file and pass address of GFXfont struct to setFont(). Pass NULL to revert to 'classic' fixed-space bitmap font. 22 | 23 | - 'fontconvert' folder contains a command-line tool for converting TTF fonts to Adafruit_GFX header format. 24 | 25 | - You can also use [this GFX Font Customiser tool](https://github.com/tchapi/Adafruit-GFX-Font-Customiser) (_web version [here](https://tchapi.github.io/Adafruit-GFX-Font-Customiser/)_) to customize or correct the output from [fontconvert](https://github.com/adafruit/Adafruit-GFX-Library/tree/master/fontconvert), and create fonts with only a subset of characters to optimize size. 26 | 27 | --- 28 | 29 | ### Roadmap 30 | 31 | The PRIME DIRECTIVE is to maintain backward compatibility with existing Arduino sketches -- many are hosted elsewhere and don't track changes here, some are in print and can never be changed! This "little" library has grown organically over time and sometimes we paint ourselves into a design corner and just have to live with it or add ungainly workarounds. 32 | 33 | Highly unlikely to merge any changes for additional or incompatible font formats (see Prime Directive above). There are already two formats and the code is quite bloaty there as it is (this also creates liabilities for tools and documentation). If you *must* have a more sophisticated font format, consider creating a fork with the features required for your project. For similar reasons, also unlikely to add any more bitmap formats, it's getting messy. 34 | 35 | Please don't reformat code for the sake of reformatting code. The resulting large "visual diff" makes it impossible to untangle actual bug fixes from merely rearranged lines. 36 | -------------------------------------------------------------------------------- /firmware/telegram3/GyverMAX7219.h: -------------------------------------------------------------------------------- 1 | #ifndef GyverMAX7219_h 2 | #define GyverMAX7219_h 3 | // самая резкая библиотека для матриц MAX7219 на диком западе 4 | 5 | #include 6 | #include 7 | #include "FastIO.h" 8 | 9 | #ifndef MAX_SPI_SPEED 10 | #define MAX_SPI_SPEED 1000000 11 | #endif 12 | 13 | template 14 | class MAX7219 { 15 | public: 16 | MAX7219() { 17 | begin(); 18 | } 19 | ~MAX7219() { 20 | SPI.end(); 21 | SPI.endTransaction(); 22 | } 23 | void begin() { 24 | SPI.end(); 25 | SPI.endTransaction(); 26 | pinMode(CSpin, OUTPUT); 27 | SPI.begin(); 28 | SPI.beginTransaction(SPISettings(MAX_SPI_SPEED, MSBFIRST, SPI_MODE0)); 29 | sendCMD(0x0f, 0x00); // отключить режим теста 30 | sendCMD(0x09, 0x00); // выключить декодирование 31 | sendCMD(0x0a, 0x00); // яркость 32 | sendCMD(0x0b, 0x0f); // отображаем всё 33 | sendCMD(0x0C, 0x01); // включить 34 | //clear(); 35 | } 36 | void setBright(byte value) { // 8x8: 0/8/15 - 30/310/540 ma 37 | sendCMD(0x0a, value); // яркость 0-15 38 | } 39 | void setPower(bool value) { 40 | sendCMD(0x0c, value); 41 | } 42 | void clear() { 43 | fillMatrix(0); 44 | } 45 | void fill() { 46 | fillMatrix(255); 47 | } 48 | void fillMatrix(byte data) { 49 | if (buf) { 50 | for (int i = 0; i < width * height * 8; i++) buffer[i] = data; 51 | } else { 52 | for (int k = 7; k >= 0; k--) { 53 | beginData(); 54 | for (int i = 0; i < _amount; i++) sendByte(k, data); 55 | endData(); 56 | } 57 | } 58 | } 59 | void sendByte(uint8_t address, uint8_t value) { 60 | SPI.transfer(8 - address); 61 | SPI.transfer(value); 62 | } 63 | void dot(int x, int y, byte fill = 1) { 64 | if (buf && x >= 0 && x < width * 8 && y >= 0 && y < height * 8) { 65 | if ((y >> 3) & 1) { // если это нечётная матрица: (y / 8) % 2 66 | x = width * 8 - 1 - x; // отзеркалить x 67 | y = (y & 0xF8) + (7 - (y & 7)); // отзеркалить y: (y / 8) * 8 + (7 - (y % 8)); 68 | } 69 | // позиция в буфере 70 | int curByte = width * (height - 1 - (y >> 3)) + (width - 1 - (x >> 3)) + (y & 7) * width * height; 71 | bitWrite(buffer[curByte], x & 7, fill); 72 | } 73 | } 74 | void update() { 75 | if (buf) { 76 | int count = 0; 77 | for (int k = 0; k < 8; k++) { 78 | beginData(); 79 | for (int i = 0; i < _amount; i++) sendByte(k, buffer[count++]); 80 | endData(); 81 | yield(); 82 | } 83 | } 84 | } 85 | 86 | // stream 87 | void restartStream() { 88 | _row = 0; 89 | _count = 0; 90 | } 91 | void nextByte(byte data) { 92 | if (_row == 8) return; 93 | if (_count == 0) beginData(); 94 | sendByte(_row, data); 95 | if (++_count == _amount) { 96 | endData(); 97 | _count = 0; 98 | _row++; 99 | } 100 | } 101 | byte buffer[width * height * 8 * buf]; 102 | private: 103 | void beginData() { 104 | fastWrite(CSpin, 0); 105 | } 106 | void endData() { 107 | fastWrite(CSpin, 1); 108 | } 109 | void sendCMD(uint8_t address, uint8_t value) { 110 | beginData(); 111 | for (int i = 0; i < _amount; i++) { 112 | SPI.transfer(address); 113 | SPI.transfer(value); 114 | } 115 | endData(); 116 | } 117 | 118 | const int _amount = width * height; 119 | int _row = 0, _count = 0; 120 | }; 121 | #endif 122 | -------------------------------------------------------------------------------- /firmware/MAX7219_mux/webcamMAX7219_mux/webcamMAX7219_mux.ino: -------------------------------------------------------------------------------- 1 | #define MAX_SPI_SPEED 2000000 2 | #include "GyverMAX7219.h" 3 | 4 | // CLK 13, DAT 11 5 | #define AM_W 24 6 | #define AM_H 16 7 | MAX7219<9, AM_W, AM_H> mtrx; // CS, W, H, buf 8 | 9 | #include "microUART.h" 10 | microUART uart; 11 | 12 | void setup() { 13 | uart.begin(200000); 14 | //test(); 15 | } 16 | byte counter = 0; 17 | void loop() { 18 | if (uart.available()) { // если есть что на приём 19 | byte data = uart.read(); // прочитать 20 | if (data == 1) { 21 | mtrx.restartStream(); 22 | if (!(++counter & 0b111111)) mtrx.begin(); 23 | } 24 | else if (counter & 0b111111) mtrx.nextByte(data); 25 | } 26 | } 27 | 28 | void test() { 29 | for (;;) { 30 | mtrx.clear(); 31 | byte radius = 3; 32 | static int x = (AM_W * 8 / 2) * 10, y = (AM_H * 8 / 2) * 10; 33 | static int velX = 15, velY = 21; 34 | static bool fillFlag = 0; 35 | x += velX; 36 | y += velY; 37 | if (x >= (AM_W * 8 - radius) * 10 || x < radius * 10) { 38 | velX = -velX; 39 | fillFlag = !fillFlag; 40 | } 41 | if (y >= (AM_H * 8 - radius) * 10 || y < radius * 10) { 42 | velY = -velY; 43 | fillFlag = !fillFlag; 44 | } 45 | 46 | mtrx.circle(x / 10, y / 10, radius, fillFlag ? GFX_STROKE : GFX_FILL); 47 | mtrx.update(); 48 | } 49 | /*for (;;) { 50 | const byte amount = 10; 51 | const byte radius = 4; 52 | static bool start = false; 53 | static int x[amount], y[amount]; 54 | static int velX[amount], velY[amount]; 55 | if (!start) { 56 | start = 1; 57 | for (byte i = 0; i < amount; i++) { 58 | x[i] = random(10, (AM_W*8 - 1) * 10); 59 | y[i] = random(10, (AM_H*8 - 1) * 10); 60 | velX[i] = random(10, 20); 61 | velY[i] = random(10, 20); 62 | } 63 | } 64 | mtrx.clear(); 65 | 66 | for (byte i = 0; i < amount; i++) { 67 | x[i] += velX[i]; 68 | y[i] += velY[i]; 69 | if (x[i] >= (AM_W*8 - radius) * 10 || x[i] < 0) velX[i] = -velX[i]; 70 | if (y[i] >= (AM_H*8 - radius) * 10 || y[i] < 0) velY[i] = -velY[i]; 71 | mtrx.circle(x[i] / 10, y[i] / 10, radius, GFX_FILL); 72 | } 73 | mtrx.update(); 74 | delay(30); 75 | }*/ 76 | 77 | for (;;) { 78 | mtrx.begin(); 79 | mtrx.clear(); 80 | for (int i = 0; i < 24 * 8; i++) { 81 | mtrx.clear(); 82 | mtrx.line(i, 0, i, AM_H * 8); 83 | mtrx.update(); 84 | //delay(10); 85 | } 86 | /*for (int i = 0; i < 24 * 8; i++) { 87 | mtrx.clear(); 88 | mtrx.dot(i, 16); 89 | mtrx.update(); 90 | }*/ 91 | //mtrx.line(0, 0, AM_W * 8 - 1, AM_H * 8 - 1); 92 | /*int offs = 24 * 16; 93 | for (int i = 0 + offs; i < 24 * 2 + offs; i++) { 94 | mtrx.buffer[i] = 0b00011000; 95 | } 96 | for (int i = 24 * 2 + offs; i < 24 * 4 + offs; i++) { 97 | mtrx.buffer[i] = 0b00100100; 98 | } 99 | for (int i = 24 * 4 + offs; i < 24 * 6 + offs; i++) { 100 | mtrx.buffer[i] = 0b01000010; 101 | }*/ 102 | mtrx.update(); 103 | delay(100); 104 | } 105 | /*byte val; 106 | for (;;) { 107 | mtrx.begin(); 108 | mtrx.fillMatrix(bit(val)); 109 | val = ++val & 0b111; 110 | }*/ 111 | /* 112 | for (;;) { 113 | mtrx.begin(); 114 | mtrx.restartStream(); 115 | for (int i = 0; i < AM_W * AM_H * 8; i++) { 116 | mtrx.nextByte(0b00011000); 117 | delayMicroseconds(1000); 118 | } 119 | mtrx.restartStream(); 120 | for (int i = 0; i < AM_W * AM_H * 8; i++) { 121 | mtrx.nextByte(0); 122 | delayMicroseconds(1000); 123 | } 124 | mtrx.clear(); 125 | } 126 | */ 127 | } 128 | -------------------------------------------------------------------------------- /libraries/Adafruit-GFX-Library/fontconvert/fontconvert_win.md: -------------------------------------------------------------------------------- 1 | ### A short guide to use fontconvert.c to create your own fonts using MinGW. 2 | 3 | #### STEP 1: INSTALL MinGW 4 | 5 | Install MinGW (Minimalist GNU for Windows) from [MinGW.org](http://www.mingw.org/). 6 | Please read carefully the instructions found on [Getting started page](http://www.mingw.org/wiki/Getting_Started). 7 | I suggest installing with the "Graphical User Interface Installer". 8 | To complete your initial installation you should further install some "packages". 9 | For our purpose you should only install the "Basic Setup" packages. 10 | To do that: 11 | 12 | 1. Open the MinGW Installation Manager 13 | 2. From the left panel click "Basic Setup". 14 | 3. On the right panel choose "mingw32-base", "mingw-gcc-g++", "mingw-gcc-objc" and "msys-base" 15 | and click "Mark for installation" 16 | 4. From the Menu click "Installation" and then "Apply changes". In the pop-up window select "Apply". 17 | 18 | 19 | #### STEP 2: INSTALL Freetype Library 20 | 21 | To read about the freetype project visit [freetype.org](https://www.freetype.org/). 22 | To Download the latest version of freetype go to [download page](http://download.savannah.gnu.org/releases/freetype/) 23 | and choose "freetype-2.7.tar.gz" file (or a newer version if available). 24 | To avoid long cd commands later in the command prompt, I suggest you unzip the file in the C:\ directory. 25 | (I also renamed the folder to "ft27") 26 | Before you build the library it's good to read these articles: 27 | * [Using MSYS with MinGW](http://www.mingw.org/wiki/MSYS) 28 | * [Installation and Use of Supplementary Libraries with MinGW](http://www.mingw.org/wiki/LibraryPathHOWTO) 29 | * [Include Path](http://www.mingw.org/wiki/IncludePathHOWTO) 30 | 31 | Inside the unzipped folder there is another folder named "docs". Open it and read the INSTALL.UNIX (using notepad). 32 | Pay attention to paragraph 3 (Build and Install the Library). So, let's begin the installation. 33 | To give the appropriate commands we will use the MSYS command prompt (not cmd.exe of windows) which is UNIX like. 34 | Follow the path C:\MinGW\msys\1.0 and double click "msys.bat". The command prompt environment appears. 35 | Enter "ft27" directory using the cd commands: 36 | ``` 37 | cd /c 38 | cd ft27 39 | ``` 40 | 41 | and then type one by one the commands: 42 | ``` 43 | ./configure --prefix=/mingw 44 | make 45 | make install 46 | ``` 47 | Once you're finished, go inside "C:\MinGW\include" and there should be a new folder named "freetype2". 48 | That, hopefully, means that you have installed the library correctly !! 49 | 50 | #### STEP 3: Build fontconvert.c 51 | 52 | Before proceeding I suggest you make a copy of Adafruit_GFX_library folder in C:\ directory. 53 | Then, inside "fontconvert" folder open the "makefile" with an editor ( I used notepad++). 54 | Change the commands so in the end the program looks like : 55 | ``` 56 | all: fontconvert 57 | 58 | CC = gcc 59 | CFLAGS = -Wall -I c:/mingw/include/freetype2 60 | LIBS = -lfreetype 61 | 62 | fontconvert: fontconvert.c 63 | $(CC) $(CFLAGS) $< $(LIBS) -o $@ 64 | 65 | clean: 66 | rm -f fontconvert 67 | ``` 68 | Go back in the command prompt and with a cd command enter the fontconvert directory. 69 | ``` 70 | cd /c/adafruit_gfx_library\fontconvert 71 | ``` 72 | Give the command: 73 | ``` 74 | make 75 | ``` 76 | This command will, eventually, create a "fontconvert.exe" file inside fontconvert directory. 77 | 78 | #### STEP 4: Create your own font header files 79 | 80 | Now that you have an executable file, you can use it to create your own fonts to work with Adafruit GFX lib. 81 | So, if we suppose that you already have a .ttf file with your favorite fonts, jump to the command prompt and type: 82 | ``` 83 | ./fontconvert yourfonts.ttf 9 > yourfonts9pt7b.h 84 | ``` 85 | You can read more details at: [learn.adafruit](https://learn.adafruit.com/adafruit-gfx-graphics-library/using-fonts). 86 | 87 | Taraaaaaammm !! you've just created your new font header file. Put it inside the "Fonts" folder, grab a cup of coffee 88 | and start playing with your Arduino (or whatever else ....)+ display module project. 89 | -------------------------------------------------------------------------------- /libraries/Adafruit-GFX-Library/examples/GFXcanvas/GFXcanvas.ino: -------------------------------------------------------------------------------- 1 | /*** 2 | This example is intended to demonstrate the use of getPixel() versus 3 | getRawPixel() and the fast horizontal and vertical drawing routines 4 | in the GFXcanvas family of classes, 5 | 6 | When using the GFXcanvas* classes as the image buffer for a hardware driver, 7 | there is a need to get individual pixel color values at given physical 8 | coordinates. Rather than subclasses or client classes call getBuffer() and 9 | reinterpret the byte layout of the buffer, two methods are added to each of the 10 | GFXcanvas* classes that allow fetching of specific pixel values. 11 | 12 | * getPixel(x, y) : Gets the pixel color value at the rotated coordinates in 13 | the image. 14 | * getRawPixel(x,y) : Gets the pixel color value at the unrotated coordinates 15 | in the image. This is useful for getting the pixel value to map to a hardware 16 | pixel location. This method was made protected as only the hardware driver 17 | should be accessing it. 18 | 19 | The GFXcanvas*SerialDemo classes in this example will print to Serial the 20 | contents of the underlying GFXcanvas buffer in both the current rotated layout 21 | and the underlying physical layout. 22 | ***/ 23 | 24 | #include "GFXcanvasSerialDemo.h" 25 | #include 26 | 27 | void setup() { 28 | Serial.begin(115200); 29 | 30 | // first create a rectangular GFXcanvas8SerialDemo object and draw to it 31 | GFXcanvas8SerialDemo demo8(21, 11); 32 | 33 | demo8.fillScreen(0x00); 34 | demo8.setRotation(1); // now canvas is 11x21 35 | demo8.fillCircle(5, 10, 5, 0xAA); 36 | demo8.writeFastHLine(0, 0, 11, 0x11); 37 | demo8.writeFastHLine(10, 10, -11, 0x22); 38 | demo8.writeFastHLine(0, 20, 11, 0x33); 39 | demo8.writeFastVLine(0, 0, 21, 0x44); 40 | demo8.writeFastVLine(10, 20, -21, 0x55); 41 | 42 | Serial.println("Demonstrating GFXcanvas rotated and raw pixels.\n"); 43 | 44 | // print it out rotated 45 | 46 | Serial.println("The canvas's content in the rotation of '0':\n"); 47 | demo8.setRotation(0); 48 | demo8.print(true); 49 | Serial.println("\n"); 50 | 51 | Serial.println("The canvas's content in the rotation of '1' (which is what " 52 | "it was drawn in):\n"); 53 | demo8.setRotation(1); 54 | demo8.print(true); 55 | Serial.println("\n"); 56 | 57 | Serial.println("The canvas's content in the rotation of '2':\n"); 58 | demo8.setRotation(2); 59 | demo8.print(true); 60 | Serial.println("\n"); 61 | 62 | Serial.println("The canvas's content in the rotation of '3':\n"); 63 | demo8.setRotation(3); 64 | demo8.print(true); 65 | Serial.println("\n"); 66 | 67 | // print it out unrotated 68 | Serial.println("The canvas's content in it's raw, physical layout:\n"); 69 | demo8.print(false); 70 | Serial.println("\n"); 71 | 72 | // Demonstrate GFXcanvas1SerialDemo 73 | 74 | GFXcanvas1SerialDemo demo1(21, 11); 75 | demo1.fillScreen(0); 76 | demo1.setRotation(0); 77 | demo1.writeFastHLine(0, 0, 9, 1); 78 | demo1.setRotation(1); 79 | demo1.writeFastHLine(0, 0, 9, 1); 80 | demo1.setRotation(2); 81 | demo1.writeFastHLine(0, 0, 9, 1); 82 | demo1.setRotation(3); 83 | demo1.writeFastHLine(0, 0, 9, 1); 84 | demo1.setRotation(1); 85 | demo1.fillRect(3, 8, 5, 5, 1); 86 | 87 | Serial.println("\nThe GFXcanvas1 raw content after drawing a fast horizontal " 88 | "line in each rotation:\n"); 89 | demo1.print(false); 90 | Serial.println("\n"); 91 | 92 | // Demonstrate GFXcanvas16SerialDemo 93 | 94 | GFXcanvas16SerialDemo demo16(21, 11); 95 | demo16.fillScreen(0); 96 | demo16.setRotation(0); 97 | demo16.writeFastHLine(0, 0, 9, 0x1111); 98 | demo16.setRotation(1); 99 | demo16.writeFastHLine(0, 0, 9, 0x2222); 100 | demo16.setRotation(2); 101 | demo16.writeFastHLine(0, 0, 9, 0x3333); 102 | demo16.setRotation(3); 103 | demo16.writeFastHLine(0, 0, 9, 0x4444); 104 | demo16.setRotation(1); 105 | demo16.fillRect(3, 8, 5, 5, 0x8888); 106 | 107 | Serial.println("\nThe GFXcanvas16 raw content after drawing a fast " 108 | "horizontal line in each rotation:\n"); 109 | demo16.print(false); 110 | Serial.println("\n"); 111 | } 112 | 113 | void loop() {} 114 | -------------------------------------------------------------------------------- /libraries/GyverOLED/examples/oledPrintTest/oledPrintTest.ino: -------------------------------------------------------------------------------- 1 | #include 2 | // попробуй с буфером и без 3 | GyverOLED oled; 4 | // можно передать адрес: GyverOLED oled(0x3C); 5 | 6 | char Lorem_ipsum[] = "Lorem ipsum dolor sit amet, лорем ипсум долор сит амет привет народ ё, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip..."; 7 | void setup() { 8 | Serial.begin(9600); 9 | oled.init(); // инициализация 10 | 11 | // ускорим вывод, ВЫЗЫВАТЬ ПОСЛЕ oled.init()!!! 12 | Wire.setClock(400000L); // макс. 800'000 13 | 14 | printScale(1); 15 | printScale(2); 16 | printScale(3); 17 | printScale(4); 18 | overlapTest(); 19 | printTest(); 20 | party(); 21 | showText(); 22 | scrollText(); 23 | scaleText(); 24 | } 25 | 26 | void loop() { 27 | } 28 | 29 | void printScale(byte x) { 30 | oled.clear(); 31 | oled.setScale(x); 32 | for (byte i = 0; i < 8; i += x) { 33 | oled.setCursor(0, i); 34 | oled.print("Hello!"); 35 | } 36 | delay(1000); 37 | } 38 | 39 | void party() { 40 | oled.clear(); 41 | uint32_t tmr = millis(); 42 | oled.setScale(3); 43 | oled.setCursor(10, 2); 44 | oled.print("ПЕННАЯ"); 45 | oled.setScale(2); 46 | oled.setCursor(6, 5); 47 | oled.print("ВЕЧЕРИНКА!"); 48 | oled.update(); 49 | for (;;) { 50 | oled.invertDisplay(true); 51 | delay(200); 52 | oled.invertDisplay(false); 53 | delay(200); 54 | if (millis() - tmr > 5000) return; 55 | } 56 | } 57 | 58 | void overlapTest() { 59 | oled.clear(); 60 | oled.setScale(1); 61 | oled.setCursorXY(0, 0); 62 | oled.print("LOL"); 63 | oled.update(); 64 | delay(500); 65 | oled.setCursorXY(0, 8); 66 | oled.print("KEK!"); 67 | oled.update(); 68 | delay(500); 69 | 70 | oled.setCursorXY(40, 4); 71 | oled.print("LOL"); 72 | oled.update(); 73 | delay(500); 74 | oled.setCursorXY(40, 12); 75 | oled.print("KEK!"); 76 | oled.update(); 77 | delay(500); 78 | 79 | oled.setScale(2); 80 | oled.setCursorXY(0, 24); 81 | oled.print("LOL"); 82 | oled.update(); 83 | delay(500); 84 | oled.setCursorXY(0, 40); 85 | oled.print("KEK!"); 86 | oled.update(); 87 | delay(500); 88 | 89 | oled.setCursorXY(60, 28); 90 | oled.print("LOL"); 91 | oled.update(); 92 | delay(500); 93 | oled.setCursorXY(60, 44); 94 | oled.print("KEK!"); 95 | oled.update(); 96 | delay(5000); 97 | } 98 | 99 | void printTest() { 100 | oled.clear(); 101 | char data0[] = "Привет!"; 102 | char data1 = 'b'; 103 | int data2 = -50; 104 | float data3 = 1.25; 105 | oled.home(); 106 | oled.setScale(1); 107 | oled.println(data0); 108 | oled.println(data1); 109 | oled.invertText(true); 110 | oled.println(data2); 111 | oled.println(data3); 112 | oled.invertText(false); 113 | oled.update(); 114 | delay(5000); 115 | } 116 | 117 | void showText() { 118 | oled.clear(); 119 | oled.home(); 120 | oled.autoPrintln(true); 121 | oled.setScale(1); 122 | oled.print(Lorem_ipsum); 123 | oled.update(); 124 | delay(5000); 125 | } 126 | 127 | void scrollText() { 128 | oled.clear(); 129 | uint32_t tmr = millis(); 130 | oled.autoPrintln(false); 131 | int val = 128; 132 | for (;;) { 133 | //oled.clear(); // ЗАКОММЕНТИРУЙ, ЕСЛИ ВКЛЮЧЕН БУФЕР 134 | oled.setScale(1); 135 | oled.setCursor(val, 0); 136 | oled.print(Lorem_ipsum); 137 | 138 | oled.setScale(2); 139 | oled.setCursor(val, 1); 140 | oled.print(Lorem_ipsum); 141 | 142 | oled.setScale(3); 143 | oled.setCursor(val, 4); 144 | oled.print(Lorem_ipsum); 145 | oled.update(); 146 | val--; 147 | if (millis() - tmr > 5000) return; 148 | } 149 | } 150 | 151 | void scaleText() { 152 | oled.clear(); 153 | uint32_t tmr = millis(); 154 | byte scale = 1; 155 | oled.autoPrintln(true); 156 | for (;;) { 157 | oled.setScale(scale); 158 | oled.home(); 159 | oled.print("Привет!"); 160 | oled.update(); 161 | delay(1000); 162 | oled.clear(); 163 | scale++; 164 | if (scale > 4) scale = 1; 165 | if (millis() - tmr > 5000) return; 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /firmware/telegram3/telegram3.ino: -------------------------------------------------------------------------------- 1 | #define WIFI_SSID "" 2 | #define WIFI_PASS "" 3 | #define BOT_TOKEN "" 4 | 5 | #define MAX_SPI_SPEED 500000 6 | #include "GyverMAX7219.h" 7 | #define AM_W 12*8 8 | #define AM_H 8*8 9 | MAX7219 < 5, AM_W / 8, AM_H / 8 > mtrx; // CS, W, H 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | std::unique_ptrclient(new BearSSL::WiFiClientSecure); 16 | HTTPClient https; 17 | 18 | #define DEBUGLN(x) Serial.println(x) 19 | #define DEBUG(x) Serial.print(x) 20 | 21 | void setup() { 22 | mtrx.update(); 23 | Serial.begin(115200); 24 | Serial.println(); 25 | client->setInsecure(); 26 | 27 | WiFi.begin(WIFI_SSID, WIFI_PASS); 28 | while (WiFi.status() != WL_CONNECTED) { 29 | delay(500); 30 | Serial.print("."); 31 | } 32 | Serial.println("Connected"); 33 | } 34 | 35 | void loop() { 36 | static uint32_t tmr, tmr2, tmr3, tmr4; 37 | if (millis() - tmr4 > 2 * 3600 * 1000ul) { 38 | tmr4 = millis(); 39 | mtrx.clear(); 40 | } 41 | if (millis() - tmr3 > 500) { 42 | tmr3 = millis(); 43 | mtrx.update(); 44 | } 45 | if (millis() - tmr2 > 5000) { 46 | tmr2 = millis(); 47 | mtrx.begin(); 48 | mtrx.update(); 49 | } 50 | if (millis() - tmr > 300) { 51 | tmr = millis(); 52 | checkBot(); 53 | } 54 | } 55 | 56 | void checkBot() { 57 | static long ID = 0; 58 | if (https.begin(*client, (String)"https://api.telegram.org/bot" + BOT_TOKEN + "/getUpdates?offset=" + ID + "&limit=3")) { 59 | if (https.GET() == HTTP_CODE_OK) { 60 | String json = https.getString(); 61 | if (https.getSize() > 5000) { 62 | DEBUGLN("ovf"); 63 | int IDpos = json.indexOf("{\"update_id\":", IDpos); 64 | if (IDpos > 0) ID = json.substring(IDpos + 13, json.indexOf(',', IDpos)).toInt(); 65 | ID++; 66 | https.end(); 67 | return; 68 | } 69 | // считаем, сколько в пакете данных (метка update_id) 70 | int count = 0; 71 | int IDpos = 0; 72 | while (1) { 73 | IDpos = json.indexOf("{\"update_id\":", IDpos); 74 | if (IDpos > 0) { 75 | ID = json.substring(IDpos + 13, json.indexOf(',', IDpos)).toInt() + 1; // сразу ++ для следующего пакета 76 | IDpos++; 77 | count++; 78 | } else break; 79 | } 80 | 81 | // считаем и парсим сообщения 82 | if (count) { 83 | int textPos = 0; 84 | while (1) { 85 | textPos = json.indexOf(",\"text\":\"", textPos); 86 | if (textPos < 0) break; 87 | int endPos = json.indexOf("\"}}", textPos); 88 | int endPos2 = json.indexOf("\",\"entities", textPos); 89 | if (endPos > 0 && endPos2 > 0) endPos = min(endPos, endPos2); 90 | else if (endPos < 0) endPos = endPos2; 91 | String str = json.substring(textPos + 9, endPos); 92 | parseCMD(str); 93 | textPos = endPos; 94 | } 95 | } 96 | } else DEBUGLN("GET telegram failed"); 97 | https.end(); 98 | } else DEBUGLN("Unable to connect"); 99 | } 100 | 101 | void parseCMD(String& str) { 102 | if (str.length() <= 12) { 103 | DEBUGLN(str); 104 | byte mode = 2; 105 | if (str.startsWith("/set ")) mode = 1; 106 | else if (str.startsWith("/clr ")) mode = 0; 107 | if (mode == 2) return; 108 | 109 | // супер парсинг без стрингов 110 | int pos[2] = {0, 0}; 111 | int count = -1; 112 | for (byte i = 5; i < 12; i++) { 113 | char sym = str[i]; 114 | if (sym >= 48 && sym <= 57) { 115 | if (count == -1) count = 0; 116 | pos[count] *= 10; 117 | pos[count] += sym - '0'; 118 | } else if (sym == 32) { 119 | if (count == 0) count++; 120 | else mode = 2; 121 | } else if (sym == NULL) { 122 | if (count != 1) mode = 2; 123 | break; 124 | } else { 125 | mode = 2; 126 | } 127 | } 128 | if (mode != 2) { 129 | /*Serial.print(mode); 130 | Serial.print(','); 131 | Serial.print(pos[0]); 132 | Serial.print(','); 133 | Serial.println(pos[1]);*/ 134 | mtrx.dot(pos[0], pos[1], mode); 135 | } 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /libraries/Adafruit-GFX-Library/Adafruit_GrayOLED.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file Adafruit_GrayOLED.h 3 | * 4 | * This is part of for Adafruit's GFX library, supplying generic support 5 | * for grayscale OLED displays: http://www.adafruit.com/category/63_98 6 | * 7 | * These displays use I2C or SPI to communicate. I2C requires 2 pins 8 | * (SCL+SDA) and optionally a RESET pin. SPI requires 4 pins (MOSI, SCK, 9 | * select, data/command) and optionally a reset pin. Hardware SPI or 10 | * 'bitbang' software SPI are both supported. 11 | * 12 | * Adafruit invests time and resources providing this open source code, 13 | * please support Adafruit and open-source hardware by purchasing 14 | * products from Adafruit! 15 | * 16 | * Written by Limor Fried/Ladyada for Adafruit Industries, with 17 | * contributions from the open source community. 18 | * 19 | * BSD license, all text above, and the splash screen header file, 20 | * must be included in any redistribution. 21 | * 22 | */ 23 | 24 | #ifndef _Adafruit_GRAYOLED_H_ 25 | #define _Adafruit_GRAYOLED_H_ 26 | 27 | #if !defined(__AVR_ATtiny85__) // Not for ATtiny, at all 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #define GRAYOLED_SETCONTRAST 0x81 ///< Generic contrast for almost all OLEDs 36 | #define GRAYOLED_NORMALDISPLAY 0xA6 ///< Generic non-invert for almost all OLEDs 37 | #define GRAYOLED_INVERTDISPLAY 0xA7 ///< Generic invert for almost all OLEDs 38 | 39 | #define MONOOLED_BLACK 0 ///< Default black 'color' for monochrome OLEDS 40 | #define MONOOLED_WHITE 1 ///< Default white 'color' for monochrome OLEDS 41 | #define MONOOLED_INVERSE 2 ///< Default inversion command for monochrome OLEDS 42 | 43 | /*! 44 | @brief Class that stores state and functions for interacting with 45 | generic grayscale OLED displays. 46 | */ 47 | class Adafruit_GrayOLED : public Adafruit_GFX { 48 | public: 49 | Adafruit_GrayOLED(uint8_t bpp, uint16_t w, uint16_t h, TwoWire *twi = &Wire, 50 | int8_t rst_pin = -1, uint32_t preclk = 400000, 51 | uint32_t postclk = 100000); 52 | Adafruit_GrayOLED(uint8_t bpp, uint16_t w, uint16_t h, int8_t mosi_pin, 53 | int8_t sclk_pin, int8_t dc_pin, int8_t rst_pin, 54 | int8_t cs_pin); 55 | Adafruit_GrayOLED(uint8_t bpp, uint16_t w, uint16_t h, SPIClass *spi, 56 | int8_t dc_pin, int8_t rst_pin, int8_t cs_pin, 57 | uint32_t bitrate = 8000000UL); 58 | 59 | ~Adafruit_GrayOLED(void); 60 | 61 | /** 62 | @brief The function that sub-classes define that writes out the buffer to 63 | the display over I2C or SPI 64 | **/ 65 | virtual void display(void) = 0; 66 | void clearDisplay(void); 67 | void invertDisplay(bool i); 68 | void setContrast(uint8_t contrastlevel); 69 | void drawPixel(int16_t x, int16_t y, uint16_t color); 70 | bool getPixel(int16_t x, int16_t y); 71 | uint8_t *getBuffer(void); 72 | 73 | void oled_command(uint8_t c); 74 | bool oled_commandList(const uint8_t *c, uint8_t n); 75 | 76 | protected: 77 | bool _init(uint8_t i2caddr = 0x3C, bool reset = true); 78 | 79 | Adafruit_SPIDevice *spi_dev = NULL; ///< The SPI interface BusIO device 80 | Adafruit_I2CDevice *i2c_dev = NULL; ///< The I2C interface BusIO device 81 | int32_t i2c_preclk = 400000, ///< Configurable 'high speed' I2C rate 82 | i2c_postclk = 100000; ///< Configurable 'low speed' I2C rate 83 | uint8_t *buffer = NULL; ///< Internal 1:1 framebuffer of display mem 84 | 85 | int16_t window_x1, ///< Dirty tracking window minimum x 86 | window_y1, ///< Dirty tracking window minimum y 87 | window_x2, ///< Dirty tracking window maximum x 88 | window_y2; ///< Dirty tracking window maximum y 89 | 90 | int dcPin, ///< The Arduino pin connected to D/C (for SPI) 91 | csPin, ///< The Arduino pin connected to CS (for SPI) 92 | rstPin; ///< The Arduino pin connected to reset (-1 if unused) 93 | 94 | uint8_t _bpp = 1; ///< Bits per pixel color for this display 95 | private: 96 | TwoWire *_theWire = NULL; ///< The underlying hardware I2C 97 | }; 98 | 99 | #endif // end __AVR_ATtiny85__ 100 | #endif // _Adafruit_GrayOLED_H_ 101 | -------------------------------------------------------------------------------- /firmware/MAX7219/webcamMAX7219/GyverGFX.cpp: -------------------------------------------------------------------------------- 1 | #include "GyverGFX.h" 2 | 3 | void GyverGFX::dot(int x, int y, uint8_t fill) {} 4 | 5 | void GyverGFX::fastLineH(int y, int x0, int x1, uint8_t fill) { 6 | GFX_SWAP(x0, x1); 7 | for (int x = x0; x <= x1; x++) dot(x, y, fill); 8 | } 9 | 10 | void GyverGFX::fastLineV(int x, int y0, int y1, uint8_t fill) { 11 | GFX_SWAP(y0, y1); 12 | for (int y = y0; y <= y1; y++) dot(x, y, fill); 13 | } 14 | 15 | void GyverGFX::line(int x0, int y0, int x1, int y1, uint8_t fill) { 16 | if (x0 == x1) fastLineV(x0, y0, y1, fill); 17 | else if (y0 == y1) fastLineH(y0, x0, x1, fill); 18 | else { 19 | GFX_SWAP(x0, x1); 20 | GFX_SWAP(y0, y1); 21 | int sx, sy, e2, err; 22 | int dx = abs(x1 - x0); 23 | int dy = abs(y1 - y0); 24 | if (x0 < x1) sx = 1; else sx = -1; 25 | if (y0 < y1) sy = 1; else sy = -1; 26 | err = dx - dy; 27 | for (;;) { 28 | dot(x0, y0, fill); 29 | if (x0 == x1 && y0 == y1) return; 30 | e2 = err << 1; 31 | if (e2 > -dy) { 32 | err = err - dy; 33 | x0 = x0 + sx; 34 | } 35 | if (e2 < dx) { 36 | err = err + dx; 37 | y0 = y0 + sy; 38 | } 39 | } 40 | } 41 | } 42 | 43 | void GyverGFX::rect(int x0, int y0, int x1, int y1, uint8_t fill) { 44 | if (fill == GFX_STROKE) { 45 | fastLineH(y0, x0 + 1, x1 - 1); 46 | fastLineH(y1, x0 + 1, x1 - 1); 47 | fastLineV(x0, y0, y1); 48 | fastLineV(x1, y0, y1); 49 | } else { 50 | GFX_SWAP(y0, y1); 51 | for (int y = y0; y <= y1; y++) fastLineH(y, x0, x1, fill); 52 | } 53 | } 54 | 55 | void GyverGFX::roundRect(int x0, int y0, int x1, int y1, uint8_t fill) { 56 | if (fill == GFX_STROKE) { 57 | fastLineV(x0, y0 + 2, y1 - 2); 58 | fastLineV(x1, y0 + 2, y1 - 2); 59 | fastLineH(y0, x0 + 2, x1 - 2); 60 | fastLineH(y1, x0 + 2, x1 - 2); 61 | dot(x0 + 1, y0 + 1); 62 | dot(x1 - 1, y0 + 1); 63 | dot(x1 - 1, y1 - 1); 64 | dot(x0 + 1, y1 - 1); 65 | } else { 66 | fastLineV(x0, y0 + 2, y1 - 2, fill); 67 | fastLineV(x0 + 1, y0 + 1, y1 - 1, fill); 68 | fastLineV(x1 - 1, y0 + 1, y1 - 1, fill); 69 | fastLineV(x1, y0 + 2, y1 - 2, fill); 70 | rect(x0 + 2, y0, x1 - 2, y1, fill); 71 | } 72 | } 73 | 74 | void GyverGFX::circle(int x, int y, int radius, uint8_t fill) { 75 | int f = 1 - radius; 76 | int ddF_x = 1; 77 | int ddF_y = -2 * radius; 78 | int x1 = 0; 79 | int y1 = radius; 80 | uint8_t fillLine = (fill == GFX_CLEAR) ? 0 : 1; 81 | dot(x, y + radius, fillLine); 82 | dot(x, y - radius, fillLine); 83 | dot(x + radius, y, fillLine); 84 | dot(x - radius, y, fillLine); 85 | if (fill != GFX_STROKE) fastLineV(x, y - radius, y + radius - 1, fillLine); 86 | while (x1 < y1) { 87 | if (f >= 0) { 88 | y1--; 89 | ddF_y += 2; 90 | f += ddF_y; 91 | } 92 | x1++; 93 | ddF_x += 2; 94 | f += ddF_x; 95 | if (fill == GFX_STROKE) { 96 | dot(x + x1, y + y1); 97 | dot(x - x1, y + y1); 98 | dot(x + x1, y - y1); 99 | dot(x - x1, y - y1); 100 | dot(x + y1, y + x1); 101 | dot(x - y1, y + x1); 102 | dot(x + y1, y - x1); 103 | dot(x - y1, y - x1); 104 | } else { 105 | fastLineV(x + x1, y - y1, y + y1, fillLine); 106 | fastLineV(x - x1, y - y1, y + y1, fillLine); 107 | fastLineV(x + y1, y - x1, y + x1, fillLine); 108 | fastLineV(x - y1, y - x1, y + x1, fillLine); 109 | } 110 | } 111 | } 112 | 113 | void GyverGFX::bezier(uint8_t* arr, uint8_t size, uint8_t dense, uint8_t fill = 1) { 114 | int a[size * 2]; 115 | for (int i = 0; i < (1 << dense); i++) { 116 | for (int j = 0; j < size * 2; j++) a[j] = arr[j] << 3; 117 | for (int j = (size - 1) * 2 - 1; j > 0; j -= 2) 118 | for (int k = 0; k <= j; k++) 119 | a[k] = a[k] + (((a[k + 2] - a[k]) * i) >> dense); 120 | dot(a[0] >> 3, a[1] >> 3, fill); 121 | } 122 | } 123 | 124 | void GyverGFX::bezier16(int* arr, uint8_t size, uint8_t dense, uint8_t fill = 1) { 125 | int a[size * 2]; 126 | for (int i = 0; i < (1 << dense); i++) { 127 | for (int j = 0; j < size * 2; j++) a[j] = arr[j]; 128 | for (int j = (size - 1) * 2 - 1; j > 0; j -= 2) 129 | for (int k = 0; k <= j; k++) 130 | a[k] = a[k] + (((a[k + 2] - a[k]) * i) >> dense); 131 | dot(a[0], a[1], fill); 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /firmware/MAX7219_mux/webcamMAX7219_mux/GyverGFX.cpp: -------------------------------------------------------------------------------- 1 | #include "GyverGFX.h" 2 | 3 | void GyverGFX::dot(int x, int y, uint8_t fill) {} 4 | 5 | void GyverGFX::fastLineH(int y, int x0, int x1, uint8_t fill) { 6 | GFX_SWAP(x0, x1); 7 | for (int x = x0; x <= x1; x++) dot(x, y, fill); 8 | } 9 | 10 | void GyverGFX::fastLineV(int x, int y0, int y1, uint8_t fill) { 11 | GFX_SWAP(y0, y1); 12 | for (int y = y0; y <= y1; y++) dot(x, y, fill); 13 | } 14 | 15 | void GyverGFX::line(int x0, int y0, int x1, int y1, uint8_t fill) { 16 | if (x0 == x1) fastLineV(x0, y0, y1, fill); 17 | else if (y0 == y1) fastLineH(y0, x0, x1, fill); 18 | else { 19 | GFX_SWAP(x0, x1); 20 | GFX_SWAP(y0, y1); 21 | int sx, sy, e2, err; 22 | int dx = abs(x1 - x0); 23 | int dy = abs(y1 - y0); 24 | if (x0 < x1) sx = 1; else sx = -1; 25 | if (y0 < y1) sy = 1; else sy = -1; 26 | err = dx - dy; 27 | for (;;) { 28 | dot(x0, y0, fill); 29 | if (x0 == x1 && y0 == y1) return; 30 | e2 = err << 1; 31 | if (e2 > -dy) { 32 | err = err - dy; 33 | x0 = x0 + sx; 34 | } 35 | if (e2 < dx) { 36 | err = err + dx; 37 | y0 = y0 + sy; 38 | } 39 | } 40 | } 41 | } 42 | 43 | void GyverGFX::rect(int x0, int y0, int x1, int y1, uint8_t fill) { 44 | if (fill == GFX_STROKE) { 45 | fastLineH(y0, x0 + 1, x1 - 1); 46 | fastLineH(y1, x0 + 1, x1 - 1); 47 | fastLineV(x0, y0, y1); 48 | fastLineV(x1, y0, y1); 49 | } else { 50 | GFX_SWAP(y0, y1); 51 | for (int y = y0; y <= y1; y++) fastLineH(y, x0, x1, fill); 52 | } 53 | } 54 | 55 | void GyverGFX::roundRect(int x0, int y0, int x1, int y1, uint8_t fill) { 56 | if (fill == GFX_STROKE) { 57 | fastLineV(x0, y0 + 2, y1 - 2); 58 | fastLineV(x1, y0 + 2, y1 - 2); 59 | fastLineH(y0, x0 + 2, x1 - 2); 60 | fastLineH(y1, x0 + 2, x1 - 2); 61 | dot(x0 + 1, y0 + 1); 62 | dot(x1 - 1, y0 + 1); 63 | dot(x1 - 1, y1 - 1); 64 | dot(x0 + 1, y1 - 1); 65 | } else { 66 | fastLineV(x0, y0 + 2, y1 - 2, fill); 67 | fastLineV(x0 + 1, y0 + 1, y1 - 1, fill); 68 | fastLineV(x1 - 1, y0 + 1, y1 - 1, fill); 69 | fastLineV(x1, y0 + 2, y1 - 2, fill); 70 | rect(x0 + 2, y0, x1 - 2, y1, fill); 71 | } 72 | } 73 | 74 | void GyverGFX::circle(int x, int y, int radius, uint8_t fill) { 75 | int f = 1 - radius; 76 | int ddF_x = 1; 77 | int ddF_y = -2 * radius; 78 | int x1 = 0; 79 | int y1 = radius; 80 | uint8_t fillLine = (fill == GFX_CLEAR) ? 0 : 1; 81 | dot(x, y + radius, fillLine); 82 | dot(x, y - radius, fillLine); 83 | dot(x + radius, y, fillLine); 84 | dot(x - radius, y, fillLine); 85 | if (fill != GFX_STROKE) fastLineV(x, y - radius, y + radius - 1, fillLine); 86 | while (x1 < y1) { 87 | if (f >= 0) { 88 | y1--; 89 | ddF_y += 2; 90 | f += ddF_y; 91 | } 92 | x1++; 93 | ddF_x += 2; 94 | f += ddF_x; 95 | if (fill == GFX_STROKE) { 96 | dot(x + x1, y + y1); 97 | dot(x - x1, y + y1); 98 | dot(x + x1, y - y1); 99 | dot(x - x1, y - y1); 100 | dot(x + y1, y + x1); 101 | dot(x - y1, y + x1); 102 | dot(x + y1, y - x1); 103 | dot(x - y1, y - x1); 104 | } else { 105 | fastLineV(x + x1, y - y1, y + y1, fillLine); 106 | fastLineV(x - x1, y - y1, y + y1, fillLine); 107 | fastLineV(x + y1, y - x1, y + x1, fillLine); 108 | fastLineV(x - y1, y - x1, y + x1, fillLine); 109 | } 110 | } 111 | } 112 | 113 | void GyverGFX::bezier(uint8_t* arr, uint8_t size, uint8_t dense, uint8_t fill) { 114 | int a[size * 2]; 115 | for (int i = 0; i < (1 << dense); i++) { 116 | for (int j = 0; j < size * 2; j++) a[j] = arr[j] << 3; 117 | for (int j = (size - 1) * 2 - 1; j > 0; j -= 2) 118 | for (int k = 0; k <= j; k++) 119 | a[k] = a[k] + (((a[k + 2] - a[k]) * i) >> dense); 120 | dot(a[0] >> 3, a[1] >> 3, fill); 121 | } 122 | } 123 | 124 | void GyverGFX::bezier16(int* arr, uint8_t size, uint8_t dense, uint8_t fill) { 125 | int a[size * 2]; 126 | for (int i = 0; i < (1 << dense); i++) { 127 | for (int j = 0; j < size * 2; j++) a[j] = arr[j]; 128 | for (int j = (size - 1) * 2 - 1; j > 0; j -= 2) 129 | for (int k = 0; k <= j; k++) 130 | a[k] = a[k] + (((a[k + 2] - a[k]) * i) >> dense); 131 | dot(a[0], a[1], fill); 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /libraries/GyverOLED/examples/OLD EXAMPLES/3Dcube/3Dcube.ino: -------------------------------------------------------------------------------- 1 | // Пример GyverOLED. Смотри документацию на http://alexgyver.ru/gyveroled/ 2 | // классический пример с 3D кубом 3 | #define OLED_SOFT_BUFFER_64 // использовать буфер на стороне микроконтроллера 4 | 5 | #include 6 | GyverOLED oled; 7 | 8 | double vectors[8][3] = {{20, 20, 20}, { -20, 20, 20}, { -20, -20, 20}, {20, -20, 20}, {20, 20, -20}, { -20, 20, -20}, { -20, -20, -20}, {20, -20, -20}}; 9 | double perspective = 100.0f; 10 | int deltaX, deltaY, deltaZ, iter = 0; 11 | uint32_t timer; 12 | 13 | void setup() { 14 | // при инициализации можно установить частоту (скорость) шины 15 | // максимум 800 кГц, самый быстрый вывод! 16 | oled.init(OLED128x64, 800); 17 | } 18 | 19 | void loop() { 20 | timer = millis(); 21 | oled.clear(); 22 | drawVectors(); 23 | oled.update(); 24 | if (iter == 0) 25 | { 26 | deltaX = random(7) - 3; 27 | deltaY = random(7) - 3; 28 | deltaZ = random(7) - 3; 29 | iter = random(250) + 5; 30 | } 31 | rotateX(deltaX); 32 | rotateY(deltaY); 33 | rotateZ(deltaZ); 34 | iter--; 35 | timer = millis() - timer; 36 | oled.home(); 37 | oled.print(1000/timer); 38 | oled.update(); 39 | } 40 | 41 | int translateX(double x, double z) 42 | { 43 | return (int)((x + 64) + (z * (x / perspective))); 44 | } 45 | 46 | int translateY(double y, double z) 47 | { 48 | return (int)((y + 32) + (z * (y / perspective))); 49 | } 50 | 51 | void rotateX(int angle) 52 | { 53 | double rad, cosa, sina, Yn, Zn; 54 | 55 | rad = angle * PI / 180; 56 | cosa = cos(rad); 57 | sina = sin(rad); 58 | for (int i = 0; i < 8; i++) 59 | { 60 | Yn = (vectors[i][1] * cosa) - (vectors[i][2] * sina); 61 | Zn = (vectors[i][1] * sina) + (vectors[i][2] * cosa); 62 | vectors[i][1] = Yn; 63 | vectors[i][2] = Zn; 64 | } 65 | } 66 | 67 | void rotateY(int angle) 68 | { 69 | double rad, cosa, sina, Xn, Zn; 70 | 71 | rad = angle * PI / 180; 72 | cosa = cos(rad); 73 | sina = sin(rad); 74 | for (int i = 0; i < 8; i++) 75 | { 76 | Xn = (vectors[i][0] * cosa) - (vectors[i][2] * sina); 77 | Zn = (vectors[i][0] * sina) + (vectors[i][2] * cosa); 78 | vectors[i][0] = Xn; 79 | vectors[i][2] = Zn; 80 | } 81 | } 82 | 83 | void rotateZ(int angle) 84 | { 85 | double rad, cosa, sina, Xn, Yn; 86 | 87 | rad = angle * PI / 180; 88 | cosa = cos(rad); 89 | sina = sin(rad); 90 | for (int i = 0; i < 8; i++) 91 | { 92 | Xn = (vectors[i][0] * cosa) - (vectors[i][1] * sina); 93 | Yn = (vectors[i][0] * sina) + (vectors[i][1] * cosa); 94 | vectors[i][0] = Xn; 95 | vectors[i][1] = Yn; 96 | } 97 | } 98 | 99 | void drawVectors() 100 | { 101 | oled.line(translateX(vectors[0][0], vectors[0][2]), translateY(vectors[0][1], vectors[0][2]), translateX(vectors[1][0], vectors[1][2]), translateY(vectors[1][1], vectors[1][2])); 102 | oled.line(translateX(vectors[1][0], vectors[1][2]), translateY(vectors[1][1], vectors[1][2]), translateX(vectors[2][0], vectors[2][2]), translateY(vectors[2][1], vectors[2][2])); 103 | oled.line(translateX(vectors[2][0], vectors[2][2]), translateY(vectors[2][1], vectors[2][2]), translateX(vectors[3][0], vectors[3][2]), translateY(vectors[3][1], vectors[3][2])); 104 | oled.line(translateX(vectors[3][0], vectors[3][2]), translateY(vectors[3][1], vectors[3][2]), translateX(vectors[0][0], vectors[0][2]), translateY(vectors[0][1], vectors[0][2])); 105 | oled.line(translateX(vectors[4][0], vectors[4][2]), translateY(vectors[4][1], vectors[4][2]), translateX(vectors[5][0], vectors[5][2]), translateY(vectors[5][1], vectors[5][2])); 106 | oled.line(translateX(vectors[5][0], vectors[5][2]), translateY(vectors[5][1], vectors[5][2]), translateX(vectors[6][0], vectors[6][2]), translateY(vectors[6][1], vectors[6][2])); 107 | oled.line(translateX(vectors[6][0], vectors[6][2]), translateY(vectors[6][1], vectors[6][2]), translateX(vectors[7][0], vectors[7][2]), translateY(vectors[7][1], vectors[7][2])); 108 | oled.line(translateX(vectors[7][0], vectors[7][2]), translateY(vectors[7][1], vectors[7][2]), translateX(vectors[4][0], vectors[4][2]), translateY(vectors[4][1], vectors[4][2])); 109 | oled.line(translateX(vectors[0][0], vectors[0][2]), translateY(vectors[0][1], vectors[0][2]), translateX(vectors[4][0], vectors[4][2]), translateY(vectors[4][1], vectors[4][2])); 110 | oled.line(translateX(vectors[1][0], vectors[1][2]), translateY(vectors[1][1], vectors[1][2]), translateX(vectors[5][0], vectors[5][2]), translateY(vectors[5][1], vectors[5][2])); 111 | oled.line(translateX(vectors[2][0], vectors[2][2]), translateY(vectors[2][1], vectors[2][2]), translateX(vectors[6][0], vectors[6][2]), translateY(vectors[6][1], vectors[6][2])); 112 | oled.line(translateX(vectors[3][0], vectors[3][2]), translateY(vectors[3][1], vectors[3][2]), translateX(vectors[7][0], vectors[7][2]), translateY(vectors[7][1], vectors[7][2])); 113 | } 114 | -------------------------------------------------------------------------------- /libraries/microWire/microWire.cpp: -------------------------------------------------------------------------------- 1 | #include "microWire.h" 2 | 3 | void TwoWire::begin() 4 | { // Инициализация шины в роли master 5 | pinMode(SDA, INPUT_PULLUP); // Подтяжка шины 6 | pinMode(SCL, INPUT_PULLUP); // Подтяжка шины 7 | TWBR = 72; // Стандартная скорость - 100kHz 8 | TWSR = 0; // Делитель - /1 , статус - 0; 9 | } 10 | 11 | void TwoWire::setClock(uint32_t clock) 12 | { // Функция установки частоты шины 31-900 kHz (в герцах) 13 | TWBR = (((long)F_CPU / clock) - 16) / 2; // Расчет baudrate - регистра 14 | } 15 | 16 | void TwoWire::beginTransmission(uint8_t address) 17 | { // Начать передачу (для записи данных) 18 | TwoWire::start(); // Старт 19 | TwoWire::write(address << 1); // Отправка slave - устройству адреса с битом "write" 20 | } 21 | 22 | uint8_t TwoWire::endTransmission(void) 23 | { // Завершить передачу и отпустить шину 24 | return TwoWire::endTransmission(true); 25 | } 26 | 27 | uint8_t TwoWire::endTransmission(bool stop) 28 | { // Завершить передачу (после записи данных) 29 | if (stop) TwoWire::stop(); // Если задано stop или аргумент пуст - отпустить шину 30 | else TwoWire::start(); // Иначе - restart (другой master на шине не сможет влезть между сообщениями) 31 | if (_address_nack) { // Если нет ответа при передаче адреса 32 | _address_nack = false; // Обнуляем оба флага 33 | _data_nack = false; // Обнуляем оба флага 34 | return 2; // Возвращаем '2' 35 | } if (_data_nack) { // Если нет ответа при передаче данных 36 | _address_nack = false; // Обнуляем оба флага 37 | _data_nack = false; // Обнуляем оба флага 38 | return 3; // Возвращаем '2' 39 | } return 0; // Если все ОК - возвращаем '0' 40 | } 41 | 42 | void TwoWire::write(uint8_t data) 43 | { // Прямая отправка байта на шину 44 | TWDR = data; // Записать данные в data - регистр 45 | TWCR = _BV(TWEN) | _BV(TWINT); // Запустить передачу 46 | while (!(TWCR & _BV(TWINT))); // Дождаться окончания 47 | uint8_t _bus_status = TWSR & 0xF8; // Чтение статуса шины 48 | if(_bus_status == 0x20) _address_nack = true; // SLA + W + NACK ? - нет ответа при передаче адреса 49 | if(_bus_status == 0x30) _data_nack = true; // BYTE + NACK ? - нет ответа при передаче данных 50 | } 51 | 52 | uint8_t TwoWire::available() 53 | { // Вернуть оставшееся количество запрошенных для чтения байт 54 | return _requested_bytes; // Это содержимое этой переменной 55 | } 56 | 57 | uint8_t TwoWire::read() 58 | { // Прямое чтение байта из шины после запроса 59 | if (--_requested_bytes) { // Если байт не последний 60 | TWCR = _BV(TWEN) | _BV(TWINT) | _BV(TWEA); // Запустить чтение шины (с подтверждением "ACK") 61 | while (!(TWCR & _BV(TWINT))); // Дождаться окончания приема данных 62 | return TWDR; // Вернуть принятые данные , это содержимое data - регистра 63 | } 64 | _requested_bytes = 0; // Если читаем последний байт 65 | TWCR = _BV(TWEN) | _BV(TWINT); // Запустить чтение шины (БЕЗ подтверждения "NACK") 66 | while (!(TWCR & _BV(TWINT))); // Дождаться окончания приема данных 67 | if (_stop_after_request) TwoWire::stop(); // Если в requestFrom не задан аргумент stop , или stop задан как true - отпустить шину 68 | else TwoWire::start(); // Иначе - restart (другой master на шине не сможет влезть между сообщениями) 69 | return TWDR; // Вернуть принятый ранее байт из data - регистра 70 | } 71 | 72 | void TwoWire::requestFrom(uint8_t address , uint8_t length) 73 | { // Запрос n-го кол-ва байт от ведомого устройства и отпускание шины 74 | TwoWire::requestFrom(address , length , true); 75 | } 76 | 77 | void TwoWire::requestFrom(uint8_t address , uint8_t length , bool stop) 78 | { // Запрос n-го кол-ва байт от ведомого устройства (Читайте все байты сразу!!!) 79 | _stop_after_request = stop; // stop или restart после чтения последнего байта 80 | _requested_bytes = length; // Записать в переменную количество запрошенных байт 81 | TwoWire::start(); // Начать работу на шине 82 | TwoWire::write((address << 1) | 0x1); // Отправить устройству адрес + бит "read" 83 | } 84 | 85 | void TwoWire::start() 86 | { // сервисная функция с нее начинается любая работа с шиной 87 | TWCR = _BV(TWSTA) | _BV(TWEN) | _BV(TWINT); // start + TwoWire enable + установка флага "выполнить задачу" 88 | while (!(TWCR & _BV(TWINT))); // Ожидание завершения 89 | } 90 | 91 | void TwoWire::stop() 92 | { // сервисная функция ей заканчивается работа с шиной 93 | TWCR = _BV(TWSTO) | _BV(TWEN) | _BV(TWINT); // stop + TwoWire enable + установка флага "выполнить задачу" 94 | } 95 | 96 | TwoWire Wire = TwoWire(); -------------------------------------------------------------------------------- /firmware/telegram4/telegram4.ino: -------------------------------------------------------------------------------- 1 | #define WIFI_SSID "" 2 | #define WIFI_PASS "" 3 | #define BOT_TOKEN "" 4 | #define CHAT_ID "-1001261708053" 5 | 6 | #include "abitmaps.h" 7 | 8 | #define MAX_SPI_SPEED 500000 9 | #include "GyverMAX7219.h" 10 | #define AM_W 12*8 11 | #define AM_H 8*8 12 | MAX7219 < 5, AM_W / 8, AM_H / 8 > mtrx; // CS, W, H 13 | 14 | #include 15 | #include "FastBot.h" 16 | FastBot bot(BOT_TOKEN, 8, 10000, 200); 17 | 18 | #define DEBUGLN(x) Serial.println(x) 19 | #define DEBUG(x) Serial.print(x) 20 | 21 | void setup() { 22 | mtrx.update(); 23 | Serial.begin(115200); 24 | Serial.println(); 25 | 26 | WiFi.begin(WIFI_SSID, WIFI_PASS); 27 | while (WiFi.status() != WL_CONNECTED) { 28 | delay(500); 29 | Serial.print("."); 30 | } 31 | Serial.println("Connected"); 32 | 33 | bot.setChatID(CHAT_ID); 34 | bot.attach(parseHandler); 35 | } 36 | 37 | int parseInts(String& buf, int* data, int len, char div = ',', char ter = NULL) { 38 | int b = 0, c = 0; 39 | data[b] = 0; 40 | while (true) { 41 | if (buf[c] == div) { 42 | b++; 43 | c++; 44 | if (b == len) return b; 45 | data[b] = 0; 46 | continue; 47 | } 48 | if (buf[c] == ter || b == len) return b + 1; 49 | data[b] *= 10; 50 | data[b] += buf[c] - '0'; 51 | c++; 52 | } 53 | } 54 | 55 | void loop() { 56 | bot.tick(); 57 | 58 | static uint32_t tmr2, tmr3, tmr4; 59 | if (millis() - tmr4 > 2 * 3600 * 1000ul) { 60 | tmr4 = millis(); 61 | //mtrx.clear(); 62 | } 63 | if (millis() - tmr2 > 5000) { 64 | tmr2 = millis(); 65 | mtrx.begin(); 66 | mtrx.update(); 67 | } 68 | if (millis() - tmr3 > 500) { 69 | tmr3 = millis(); 70 | mtrx.update(); 71 | } 72 | /*if (Serial.available()) { 73 | String str = Serial.readString(); 74 | int data[5]; 75 | parseInts(str, data, 5); 76 | mtrx.rect(data[0], data[1], data[2], data[3], data[4]); 77 | }*/ 78 | 79 | if (Serial.available()) { 80 | String str = Serial.readString(); 81 | String arr[3]; 82 | int startPos = 0; 83 | for (int i = 0; i < 3; i++) { 84 | int endPos = str.indexOf('\b', startPos); 85 | if (endPos < 0) endPos = str.length(); 86 | String data = str.substring(startPos, endPos); 87 | arr[i] = data; 88 | startPos = endPos + 1; 89 | } 90 | int amount = arr[0].toInt(); 91 | static bool flag = 0; 92 | if (amount == 50) { 93 | int posX = random(AM_W / 2, AM_W - 32); 94 | int posY = random(0, AM_H - 27 - 8); 95 | mtrx.drawBitmap(posX, posY, gyverlogo_32x27, 32, 27, 0, GFX_REPLACE); 96 | mtrx.setCursor(posX + 16 - arr[1].length() * 6 / 2, posY + 27); 97 | mtrx.print(arr[1]); 98 | } else if (amount == 100) { 99 | int len = arr[2].length() * 6; 100 | int posX = 0; 101 | if (len < AM_W) posX = random(0, AM_W - len); 102 | int posY = random(0, AM_H - 8); 103 | mtrx.setCursor(posX, posY); 104 | mtrx.invertText(flag = !flag); 105 | mtrx.print(arr[2]); 106 | if (flag) { 107 | mtrx.fastLineV(posX - 1, posY - 1, posY + 8); 108 | mtrx.fastLineH(posY - 1, posX - 1, posX + len); 109 | } 110 | } else { 111 | switch (amount) { 112 | case 10: drawImage(impostor_17x21, 17, 21); break; 113 | case 20: drawImage(cat_24x24, 24, 24); break; 114 | case 25: drawImage(catface_24x21, 24, 21); break; 115 | case 35: drawImage(starwars_29x32, 29, 32); break; 116 | case 40: drawImage(doggo_26x39, 26, 39); break; 117 | case 55: drawImage(picachu2_43x33, 43, 33); break; 118 | case 60: drawImage(nyancat_47x30, 47, 30); break; 119 | case 80: drawImage(picachu_38x41, 38, 41); break; 120 | case 90: drawImage(girl_50x50, 50, 50); break; 121 | //case 120: drawImage(pirate_57x42, 57, 42); break; 122 | //case 150: drawImage(trollface_59x47, 59, 47); break; 123 | //case 170: drawImage(gyver_53x64, 53, 64); break; 124 | //case 200: drawImage(arduino_92x64, 92, 64); break; 125 | case 500: mtrx.clear(); break; 126 | } 127 | } 128 | } 129 | } 130 | 131 | void drawImage(const uint8_t *frame, int width, int height) { 132 | int posX = random(AM_W / 2 - 2, AM_W - width + 1); 133 | int posY = random(0, AM_H - height); 134 | mtrx.drawBitmap(posX, posY, frame, width, height, 0, GFX_REPLACE); 135 | } 136 | 137 | void parseHandler(String& str) { 138 | if (str.length() <= 12) { 139 | DEBUGLN(str); 140 | byte mode = 2; 141 | if (str.startsWith("/set ")) mode = 1; 142 | else if (str.startsWith("/clr ")) mode = 0; 143 | if (mode == 2) return; 144 | 145 | // супер парсинг без стрингов 146 | int pos[2] = {0, 0}; 147 | int count = -1; 148 | for (byte i = 5; i < 12; i++) { 149 | char sym = str[i]; 150 | if (sym >= 48 && sym <= 57) { 151 | if (count == -1) count = 0; 152 | pos[count] *= 10; 153 | pos[count] += sym - '0'; 154 | } else if (sym == 32) { 155 | if (count == 0) count++; 156 | else mode = 2; 157 | } else if (sym == NULL) { 158 | if (count != 1) mode = 2; 159 | break; 160 | } else { 161 | mode = 2; 162 | } 163 | } 164 | if (mode != 2) { 165 | /*Serial.print(mode); 166 | Serial.print(','); 167 | Serial.print(pos[0]); 168 | Serial.print(','); 169 | Serial.println(pos[1]);*/ 170 | mtrx.dot(pos[0], pos[1], mode); 171 | } 172 | } 173 | } 174 | -------------------------------------------------------------------------------- /libraries/Adafruit-ST7735-Library-master/Adafruit_ST7735.h: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | This is a library for the Adafruit 1.8" SPI display. 3 | 4 | This library works with the Adafruit 1.8" TFT Breakout w/SD card 5 | ----> http://www.adafruit.com/products/358 6 | The 1.8" TFT shield 7 | ----> https://www.adafruit.com/product/802 8 | The 1.44" TFT breakout 9 | ----> https://www.adafruit.com/product/2088 10 | as well as Adafruit raw 1.8" TFT display 11 | ----> http://www.adafruit.com/products/618 12 | 13 | Check out the links above for our tutorials and wiring diagrams 14 | These displays use SPI to communicate, 4 or 5 pins are required to 15 | interface (RST is optional) 16 | Adafruit invests time and resources providing this open source code, 17 | please support Adafruit and open-source hardware by purchasing 18 | products from Adafruit! 19 | 20 | Written by Limor Fried/Ladyada for Adafruit Industries. 21 | MIT license, all text above must be included in any redistribution 22 | ****************************************************/ 23 | 24 | #ifndef _ADAFRUIT_ST7735H_ 25 | #define _ADAFRUIT_ST7735H_ 26 | 27 | #if ARDUINO >= 100 28 | #include "Arduino.h" 29 | #include "Print.h" 30 | #else 31 | #include "WProgram.h" 32 | #endif 33 | 34 | #include 35 | 36 | #if defined(__SAM3X8E__) 37 | #include 38 | #define PROGMEM 39 | #define pgm_read_byte(addr) (*(const unsigned char *)(addr)) 40 | #define pgm_read_word(addr) (*(const unsigned short *)(addr)) 41 | typedef unsigned char prog_uchar; 42 | #endif 43 | #ifdef __AVR__ 44 | #include 45 | #endif 46 | 47 | #if defined(__SAM3X8E__) 48 | #undef __FlashStringHelper::F(string_literal) 49 | #define F(string_literal) string_literal 50 | #endif 51 | 52 | // some flags for initR() :( 53 | #define INITR_GREENTAB 0x0 54 | #define INITR_REDTAB 0x1 55 | #define INITR_BLACKTAB 0x2 56 | 57 | #define INITR_18GREENTAB INITR_GREENTAB 58 | #define INITR_18REDTAB INITR_REDTAB 59 | #define INITR_18BLACKTAB INITR_BLACKTAB 60 | #define INITR_144GREENTAB 0x1 61 | 62 | #define ST7735_TFTWIDTH 128 63 | // for 1.44" display 64 | #define ST7735_TFTHEIGHT_144 128 65 | // for 1.8" display 66 | #define ST7735_TFTHEIGHT_18 160 67 | 68 | #define ST7735_NOP 0x00 69 | #define ST7735_SWRESET 0x01 70 | #define ST7735_RDDID 0x04 71 | #define ST7735_RDDST 0x09 72 | 73 | #define ST7735_SLPIN 0x10 74 | #define ST7735_SLPOUT 0x11 75 | #define ST7735_PTLON 0x12 76 | #define ST7735_NORON 0x13 77 | 78 | #define ST7735_INVOFF 0x20 79 | #define ST7735_INVON 0x21 80 | #define ST7735_DISPOFF 0x28 81 | #define ST7735_DISPON 0x29 82 | #define ST7735_CASET 0x2A 83 | #define ST7735_RASET 0x2B 84 | #define ST7735_RAMWR 0x2C 85 | #define ST7735_RAMRD 0x2E 86 | 87 | #define ST7735_PTLAR 0x30 88 | #define ST7735_COLMOD 0x3A 89 | #define ST7735_MADCTL 0x36 90 | 91 | #define ST7735_FRMCTR1 0xB1 92 | #define ST7735_FRMCTR2 0xB2 93 | #define ST7735_FRMCTR3 0xB3 94 | #define ST7735_INVCTR 0xB4 95 | #define ST7735_DISSET5 0xB6 96 | 97 | #define ST7735_PWCTR1 0xC0 98 | #define ST7735_PWCTR2 0xC1 99 | #define ST7735_PWCTR3 0xC2 100 | #define ST7735_PWCTR4 0xC3 101 | #define ST7735_PWCTR5 0xC4 102 | #define ST7735_VMCTR1 0xC5 103 | 104 | #define ST7735_RDID1 0xDA 105 | #define ST7735_RDID2 0xDB 106 | #define ST7735_RDID3 0xDC 107 | #define ST7735_RDID4 0xDD 108 | 109 | #define ST7735_PWCTR6 0xFC 110 | 111 | #define ST7735_GMCTRP1 0xE0 112 | #define ST7735_GMCTRN1 0xE1 113 | 114 | // Color definitions 115 | #define ST7735_BLACK 0x0000 116 | #define ST7735_BLUE 0x001F 117 | #define ST7735_RED 0xF800 118 | #define ST7735_GREEN 0x07E0 119 | #define ST7735_CYAN 0x07FF 120 | #define ST7735_MAGENTA 0xF81F 121 | #define ST7735_YELLOW 0xFFE0 122 | #define ST7735_WHITE 0xFFFF 123 | 124 | 125 | class Adafruit_ST7735 : public Adafruit_GFX { 126 | 127 | public: 128 | 129 | Adafruit_ST7735(int8_t CS, int8_t RS, int8_t SID, int8_t SCLK, int8_t RST = -1); 130 | Adafruit_ST7735(int8_t CS, int8_t RS, int8_t RST = -1); 131 | 132 | void initB(void), // for ST7735B displays 133 | initR(uint8_t options = INITR_GREENTAB), // for ST7735R 134 | setAddrWindow(uint8_t x0, uint8_t y0, uint8_t x1, uint8_t y1), 135 | pushColor(uint16_t color), 136 | fillScreen(uint16_t color), 137 | drawPixel(int16_t x, int16_t y, uint16_t color), 138 | drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color), 139 | drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color), 140 | fillRect(int16_t x, int16_t y, int16_t w, int16_t h, 141 | uint16_t color), 142 | setRotation(uint8_t r), 143 | invertDisplay(boolean i); 144 | uint16_t Color565(uint8_t r, uint8_t g, uint8_t b); 145 | 146 | /* These are not for current use, 8-bit protocol only! 147 | uint8_t readdata(void), 148 | readcommand8(uint8_t); 149 | uint16_t readcommand16(uint8_t); 150 | uint32_t readcommand32(uint8_t); 151 | void dummyclock(void); 152 | */ 153 | 154 | private: 155 | uint8_t tabcolor; 156 | 157 | void spiwrite(uint8_t), 158 | writecommand(uint8_t c), 159 | writedata(uint8_t d), 160 | commandList(const uint8_t *addr), 161 | commonInit(const uint8_t *cmdList); 162 | //uint8_t spiread(void); 163 | 164 | boolean hwSPI; 165 | 166 | #if defined(__AVR__) || defined(CORE_TEENSY) 167 | volatile uint8_t *dataport, *clkport, *csport, *rsport; 168 | uint8_t _cs, _rs, _rst, _sid, _sclk, 169 | datapinmask, clkpinmask, cspinmask, rspinmask, 170 | colstart, rowstart; // some displays need this changed 171 | #endif // #ifdef __AVR__ 172 | 173 | #if defined(__SAM3X8E__) 174 | Pio *dataport, *clkport, *csport, *rsport; 175 | uint32_t _cs, _rs, _rst, _sid, _sclk, 176 | datapinmask, clkpinmask, cspinmask, rspinmask, 177 | colstart, rowstart; // some displays need this changed 178 | #endif // #if defined(__SAM3X8E__) 179 | 180 | }; 181 | 182 | #endif 183 | -------------------------------------------------------------------------------- /libraries/Adafruit-GFX-Library/Fonts/Tiny3x3a2pt7b.h: -------------------------------------------------------------------------------- 1 | /** 2 | ** The FontStruction “Tiny3x3a” 3 | ** (https://fontstruct.com/fontstructions/show/670512) by “Michaelangel007” is 4 | ** licensed under a Creative Commons Attribution Non-commercial Share Alike 5 | *license 6 | ** (http://creativecommons.org/licenses/by-nc-sa/3.0/). 7 | ** “Tiny3x3a” was originally cloned (copied) from the FontStruction 8 | ** “CHECKER” (https://fontstruct.com/fontstructions/show/2391) by Wolf grant 9 | ** Grant, which is licensed under a Creative Commons Attribution Non-commercial 10 | ** Share Alike license (http://creativecommons.org/licenses/by-nc-sa/3.0/). 11 | * 12 | * Converted by eadmaster with fontconvert 13 | **/ 14 | 15 | const uint8_t Tiny3x3a2pt7bBitmaps[] PROGMEM = { 16 | 0xC0, 0xB4, 0xBF, 0x80, 0x6B, 0x00, 0xDD, 0x80, 0x59, 0x80, 0x80, 0x64, 17 | 0x98, 0xF0, 0x5D, 0x00, 0xC0, 0xE0, 0x80, 0x2A, 0x00, 0x55, 0x00, 0x94, 18 | 0xC9, 0x80, 0xEF, 0x80, 0xBC, 0x80, 0x6B, 0x00, 0x9F, 0x80, 0xE4, 0x80, 19 | 0x7F, 0x00, 0xFC, 0x80, 0xA0, 0x58, 0x64, 0xE3, 0x80, 0x98, 0xD8, 0xD8, 20 | 0x80, 0x5E, 0x80, 0xDF, 0x80, 0x71, 0x80, 0xD7, 0x00, 0xFB, 0x80, 0xFA, 21 | 0x00, 0xD7, 0x80, 0xBE, 0x80, 0xE0, 0x27, 0x00, 0xBA, 0x80, 0x93, 0x80, 22 | 0xFE, 0x80, 0xF6, 0x80, 0xF7, 0x80, 0xFE, 0x00, 0xF7, 0x00, 0xDE, 0x80, 23 | 0x6B, 0x00, 0xE9, 0x00, 0xB7, 0x80, 0xB5, 0x00, 0xBF, 0x80, 0xAA, 0x80, 24 | 0xA9, 0x00, 0xEB, 0x80, 0xEC, 0x88, 0x80, 0xDC, 0x54, 0xE0, 0x90, 0x70, 25 | 0xBC, 0xF0, 0x7C, 0xB0, 0x68, 0xFC, 0xBC, 0xC0, 0x58, 0x9A, 0x80, 0xA4, 26 | 0xDC, 0xD4, 0xF0, 0xF8, 0xF4, 0xE0, 0x60, 0x59, 0x80, 0xBC, 0xA8, 0xEC, 27 | 0xF0, 0xAC, 0x80, 0x90, 0x79, 0x80, 0xF0, 0xCF, 0x00, 0x78}; 28 | 29 | const GFXglyph Tiny3x3a2pt7bGlyphs[] PROGMEM = { 30 | {0, 0, 0, 4, 0, 1}, // 0x20 ' ' 31 | {0, 1, 2, 3, 1, -2}, // 0x21 '!' 32 | {1, 3, 2, 4, 0, -2}, // 0x22 '"' 33 | {2, 3, 3, 4, 0, -2}, // 0x23 '#' 34 | {4, 3, 3, 4, 0, -2}, // 0x24 '$' 35 | {6, 3, 3, 4, 0, -2}, // 0x25 '%' 36 | {8, 3, 3, 4, 0, -2}, // 0x26 '&' 37 | {10, 1, 1, 3, 1, -2}, // 0x27 ''' 38 | {11, 2, 3, 3, 0, -2}, // 0x28 '(' 39 | {12, 2, 3, 4, 1, -2}, // 0x29 ')' 40 | {13, 2, 2, 4, 1, -2}, // 0x2A '*' 41 | {14, 3, 3, 4, 0, -2}, // 0x2B '+' 42 | {16, 1, 2, 2, 0, 0}, // 0x2C ',' 43 | {17, 3, 1, 4, 0, -1}, // 0x2D '-' 44 | {18, 1, 1, 2, 0, 0}, // 0x2E '.' 45 | {19, 3, 3, 4, 0, -2}, // 0x2F '/' 46 | {21, 3, 3, 4, 0, -2}, // 0x30 '0' 47 | {23, 2, 3, 3, 0, -2}, // 0x31 '1' 48 | {24, 3, 3, 4, 0, -2}, // 0x32 '2' 49 | {26, 3, 3, 4, 0, -2}, // 0x33 '3' 50 | {28, 3, 3, 4, 0, -2}, // 0x34 '4' 51 | {30, 3, 3, 4, 0, -2}, // 0x35 '5' 52 | {32, 3, 3, 4, 0, -2}, // 0x36 '6' 53 | {34, 3, 3, 4, 0, -2}, // 0x37 '7' 54 | {36, 3, 3, 4, 0, -2}, // 0x38 '8' 55 | {38, 3, 3, 4, 0, -2}, // 0x39 '9' 56 | {40, 1, 3, 3, 1, -2}, // 0x3A ':' 57 | {41, 2, 3, 3, 0, -1}, // 0x3B ';' 58 | {42, 2, 3, 3, 0, -2}, // 0x3C '<' 59 | {43, 3, 3, 4, 0, -2}, // 0x3D '=' 60 | {45, 2, 3, 4, 1, -2}, // 0x3E '>' 61 | {46, 2, 3, 4, 1, -2}, // 0x3F '?' 62 | {47, 3, 3, 4, 0, -2}, // 0x40 '@' 63 | {49, 3, 3, 4, 0, -2}, // 0x41 'A' 64 | {51, 3, 3, 4, 0, -2}, // 0x42 'B' 65 | {53, 3, 3, 4, 0, -2}, // 0x43 'C' 66 | {55, 3, 3, 4, 0, -2}, // 0x44 'D' 67 | {57, 3, 3, 4, 0, -2}, // 0x45 'E' 68 | {59, 3, 3, 4, 0, -2}, // 0x46 'F' 69 | {61, 3, 3, 4, 0, -2}, // 0x47 'G' 70 | {63, 3, 3, 4, 0, -2}, // 0x48 'H' 71 | {65, 1, 3, 3, 1, -2}, // 0x49 'I' 72 | {66, 3, 3, 4, 0, -2}, // 0x4A 'J' 73 | {68, 3, 3, 4, 0, -2}, // 0x4B 'K' 74 | {70, 3, 3, 4, 0, -2}, // 0x4C 'L' 75 | {72, 3, 3, 4, 0, -2}, // 0x4D 'M' 76 | {74, 3, 3, 4, 0, -2}, // 0x4E 'N' 77 | {76, 3, 3, 4, 0, -2}, // 0x4F 'O' 78 | {78, 3, 3, 4, 0, -2}, // 0x50 'P' 79 | {80, 3, 3, 4, 0, -2}, // 0x51 'Q' 80 | {82, 3, 3, 4, 0, -2}, // 0x52 'R' 81 | {84, 3, 3, 4, 0, -2}, // 0x53 'S' 82 | {86, 3, 3, 4, 0, -2}, // 0x54 'T' 83 | {88, 3, 3, 4, 0, -2}, // 0x55 'U' 84 | {90, 3, 3, 4, 0, -2}, // 0x56 'V' 85 | {92, 3, 3, 4, 0, -2}, // 0x57 'W' 86 | {94, 3, 3, 4, 0, -2}, // 0x58 'X' 87 | {96, 3, 3, 4, 0, -2}, // 0x59 'Y' 88 | {98, 3, 3, 4, 0, -2}, // 0x5A 'Z' 89 | {100, 2, 3, 3, 0, -2}, // 0x5B '[' 90 | {101, 3, 3, 4, 0, -2}, // 0x5C '\' 91 | {103, 2, 3, 4, 1, -2}, // 0x5D ']' 92 | {104, 3, 2, 4, 0, -2}, // 0x5E '^' 93 | {105, 3, 1, 4, 0, 0}, // 0x5F '_' 94 | {106, 2, 2, 3, 0, -2}, // 0x60 '`' 95 | {107, 2, 2, 3, 0, -1}, // 0x61 'a' 96 | {108, 2, 3, 3, 0, -2}, // 0x62 'b' 97 | {109, 2, 2, 3, 0, -1}, // 0x63 'c' 98 | {110, 2, 3, 3, 0, -2}, // 0x64 'd' 99 | {111, 2, 2, 3, 0, -1}, // 0x65 'e' 100 | {112, 2, 3, 3, 0, -2}, // 0x66 'f' 101 | {113, 2, 3, 3, 0, -1}, // 0x67 'g' 102 | {114, 2, 3, 3, 0, -2}, // 0x68 'h' 103 | {115, 1, 2, 2, 0, -1}, // 0x69 'i' 104 | {116, 2, 3, 3, 0, -1}, // 0x6A 'j' 105 | {117, 3, 3, 4, 0, -2}, // 0x6B 'k' 106 | {119, 2, 3, 3, 0, -2}, // 0x6C 'l' 107 | {120, 3, 2, 4, 0, -1}, // 0x6D 'm' 108 | {121, 3, 2, 4, 0, -1}, // 0x6E 'n' 109 | {122, 2, 2, 3, 0, -1}, // 0x6F 'o' 110 | {123, 2, 3, 3, 0, -1}, // 0x70 'p' 111 | {124, 2, 3, 3, 0, -1}, // 0x71 'q' 112 | {125, 2, 2, 3, 0, -1}, // 0x72 'r' 113 | {126, 2, 2, 3, 0, -1}, // 0x73 's' 114 | {127, 3, 3, 4, 0, -2}, // 0x74 't' 115 | {129, 3, 2, 4, 0, -1}, // 0x75 'u' 116 | {130, 3, 2, 4, 0, -1}, // 0x76 'v' 117 | {131, 3, 2, 4, 0, -1}, // 0x77 'w' 118 | {132, 2, 2, 3, 0, -1}, // 0x78 'x' 119 | {133, 3, 3, 4, 0, -1}, // 0x79 'y' 120 | {135, 2, 2, 3, 0, -1}, // 0x7A 'z' 121 | {136, 3, 3, 4, 0, -2}, // 0x7B '{' 122 | {138, 1, 4, 3, 1, -2}, // 0x7C '|' 123 | {139, 3, 3, 4, 0, -2}, // 0x7D '}' 124 | {141, 3, 2, 4, 0, -2}}; // 0x7E '~' 125 | 126 | const GFXfont Tiny3x3a2pt7b PROGMEM = {(uint8_t *)Tiny3x3a2pt7bBitmaps, 127 | (GFXglyph *)Tiny3x3a2pt7bGlyphs, 0x20, 128 | 0x7E, 4}; 129 | 130 | // Approx. 814 bytes 131 | -------------------------------------------------------------------------------- /libraries/GyverOLED/examples/OLD EXAMPLES/bitmap_demo/bitmap_demo.ino: -------------------------------------------------------------------------------- 1 | // Пример GyverOLED. Смотри документацию на http://alexgyver.ru/gyveroled/ 2 | // вывод картинки из памяти 3 | 4 | // битмап из программы BITmaper OLED (см. в папке с библиотекой) 5 | const uint8_t frame0_128x64[] PROGMEM = { 6 | 0xFE, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x04, 0xFC, 0x04, 0xFC, 0x04, 0xFC, 0x04, 0xFC, 0xFC, 0x04, 0xFC, 0x04, 0xFC, 0x04, 0xFC, 0x04, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0x7C, 0x00, 0x1C, 0x80, 0xEC, 0x60, 0x2C, 0x20, 0x2C, 0x40, 0x4C, 0x40, 0x5C, 0x80, 0x9C, 0x00, 0x3C, 0x00, 0x3C, 0x00, 0x7C, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x04, 0xFC, 0x14, 0x7C, 0xE0, 0x00, 0x1C, 0x1C, 0xEC, 0x84, 0xFC, 0x04, 0xFC, 0x84, 0x7C, 0x64, 0x1C, 0x10, 0x8C, 0xC8, 0x64, 0xC4, 7 | 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x40, 0xFF, 0x20, 0x3F, 0x3F, 0x20, 0x3F, 0x20, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x7F, 0x00, 0x7F, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x0F, 0xF0, 0xC0, 0x00, 0x7F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x40, 0x40, 0x80, 0x80, 0x80, 0x00, 0x40, 0x41, 0x40, 0x81, 0x88, 0x8B, 0x08, 0x1B, 0x10, 0x17, 0x30, 0x2F, 0x20, 0x2F, 0x10, 0x1F, 0x00, 0x0F, 0x10, 0x1F, 0x00, 0x00, 0x3F, 0x1F, 0x0C, 0x00, 0x81, 0x81, 0x1F, 0x66, 0x71, 0xD9, 0x8E, 0x07, 0x03, 0x87, 0xCD, 0x78, 0x78, 0xCC, 8 | 0xFF, 0x00, 0xFF, 0x00, 0x3F, 0x00, 0x0F, 0x00, 0x07, 0x30, 0x73, 0xD0, 0xD3, 0x18, 0x09, 0x08, 0x01, 0x00, 0x03, 0x00, 0x03, 0x00, 0x07, 0x00, 0x0F, 0x08, 0x0F, 0x00, 0x1F, 0x00, 0xE3, 0xFC, 0xFF, 0xFF, 0xFC, 0xFE, 0xFE, 0xF9, 0xF8, 0xF2, 0xF8, 0xF9, 0xFC, 0xFC, 0xFF, 0xFE, 0xE6, 0xE2, 0xF0, 0xBD, 0x50, 0x0F, 0x00, 0xBF, 0xE0, 0x4F, 0xE0, 0xF7, 0xF0, 0x7B, 0xBC, 0xDE, 0x6B, 0x81, 0x80, 0x80, 0xC0, 0xF8, 0x8C, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x09, 0x00, 0xFE, 0x00, 0xF8, 0x00, 0xF1, 0x01, 0xF3, 0x02, 0xF2, 0x00, 0xF0, 0x00, 0xF0, 0x00, 0xF0, 0x00, 0xF0, 0x00, 0xF0, 0x00, 0xF0, 0x00, 0xE0, 0x00, 0xC0, 0x00, 0xC0, 0x10, 0xF0, 0x30, 0xB0, 0x78, 0xC8, 0xE9, 0x61, 0xF0, 0xE8, 0x18, 0xFC, 0xC7, 0x83, 0x03, 0x87, 0xCC, 0x7C, 0x78, 0x6C, 9 | 0x03, 0x80, 0x00, 0x00, 0x30, 0xF8, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xC7, 0xE7, 0x74, 0x7C, 0xF8, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xC0, 0x80, 0x00, 0x10, 0x30, 0xE0, 0xE6, 0x67, 0x7F, 0x79, 0x71, 0xEF, 0xFF, 0xFF, 0x7F, 0x7F, 0x3F, 0x3F, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x6F, 0xF7, 0xF8, 0xFD, 0xFE, 0xFF, 0xFF, 0xFC, 0xF9, 0xF2, 0xFA, 0xFC, 0xE1, 0xC3, 0xE7, 0x9C, 0xD9, 0xC0, 0x9E, 0x3E, 0x7E, 0x7E, 0xFE, 0xFD, 0xFD, 0xFD, 0xFD, 0x9D, 0xD2, 0xEA, 0x3A, 0x04, 0xC8, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x03, 0xFC, 0x0F, 0xF3, 0x13, 0xE6, 0x2C, 0xC8, 0x0C, 10 | 0xFF, 0x01, 0xE6, 0x18, 0x20, 0xE7, 0x7F, 0x59, 0x60, 0x70, 0xF8, 0xFC, 0x3E, 0x7F, 0xFF, 0x0C, 0x0C, 0x4F, 0x4F, 0x4F, 0x7F, 0x7F, 0xC9, 0x6B, 0x37, 0x1F, 0x0E, 0x00, 0x86, 0x87, 0x80, 0x80, 0xC0, 0xC0, 0xC1, 0x41, 0x00, 0x00, 0x88, 0xCC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7E, 0xFE, 0xFE, 0x7C, 0x3D, 0xC3, 0x07, 0xFF, 0xFF, 0xFF, 0xF3, 0xF7, 0xEF, 0xED, 0xEC, 0xFD, 0xF9, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0x3C, 0x01, 0x03, 0x03, 0x03, 0x0E, 0x0D, 0x03, 0x7C, 0x00, 0x7F, 0x00, 0x7F, 0x00, 0x7F, 0x00, 0x7F, 0x00, 0x7F, 0x00, 0xFF, 0x00, 0x7F, 0x80, 0x1F, 0x00, 0x1F, 0x00, 0x9F, 0xC0, 0x3F, 0x40, 0x7F, 0x00, 0x7F, 0x00, 0x7F, 0x00, 0x7F, 0x40, 0x7F, 0x40, 0x7F, 0x40, 0x7F, 0x7F, 0x40, 0x7F, 0x40, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 11 | 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFC, 0x06, 0xE6, 0x0C, 0xCC, 0x19, 0x98, 0x10, 0x91, 0x01, 0xC0, 0x04, 0xC4, 0x04, 0x84, 0x04, 0xC4, 0x04, 0xEC, 0x09, 0x89, 0x09, 0x89, 0x89, 0x89, 0x09, 0xE0, 0xE0, 0xE0, 0xF4, 0xFE, 0xFF, 0xFF, 0xFD, 0xFB, 0xFB, 0xF7, 0xCF, 0xCF, 0xCF, 0xCF, 0xCC, 0x8C, 0xB4, 0xA7, 0x67, 0x94, 0x33, 0x33, 0xCB, 0x17, 0xAF, 0xDF, 0x3F, 0xFF, 0xFF, 0x3F, 0xCF, 0xE7, 0xF3, 0xFB, 0xF9, 0xFD, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0x84, 0x78, 0xFF, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, 0x0E, 0x0F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x0E, 0x06, 0x06, 0x04, 0x85, 0x06, 0x06, 0x06, 12 | 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x7F, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x80, 0x9F, 0xC2, 0x3F, 0x24, 0xF7, 0x99, 0x99, 0x99, 0xE9, 0xC9, 0xD9, 0xE9, 0xE9, 0xF1, 0xF1, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFF, 0xFF, 0xFE, 0xFF, 0xFE, 0x7D, 0x7A, 0xB4, 0x3C, 0xC1, 0x02, 0xDC, 0x1B, 0xB7, 0x2B, 0x57, 0x6F, 0x57, 0x6F, 0x57, 0x6F, 0x57, 0x6F, 0xB7, 0x2F, 0xB7, 0x2F, 0xB7, 0x2F, 0xB7, 0x2F, 0xB7, 0x2F, 0xB7, 0x1B, 0xD7, 0x1B, 0xD7, 0x1B, 0xEF, 0x0C, 0xF3, 0x0E, 0x90, 0x20, 0xA0, 0x00, 0xC0, 0x00, 0xC0, 0x10, 0xC0, 0x30, 0xF8, 0x00, 0xF8, 0x00, 0xF8, 0x00, 0xF0, 0x10, 0xF0, 0x0C, 0xF8, 0xF8, 0x08, 0xF8, 0x08, 0xFE, 0x04, 0xFF, 0x00, 0xFE, 0x00, 0xFF, 0x00, 0xFF, 0x00, 13 | 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3D, 0x3A, 0x3C, 0x3A, 0x34, 0x38, 0x35, 0x08, 0x13, 0x24, 0x0F, 0x00, 0x03, 0x3C, 0x35, 0x02, 0x01, 0x3D, 0x0F, 0x27, 0x03, 0x1B, 0x13, 0x13, 0x13, 0x1B, 0x13, 0x1B, 0x13, 0x1B, 0x13, 0x1B, 0x01, 0x1D, 0x01, 0x1D, 0x01, 0x1D, 0x01, 0x3E, 0x00, 0x3E, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x1F, 0x00, 0x27, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0x1F, 0x10, 0x1F, 0x10, 0x1F, 0x10, 0x1F, 0x1F, 0x10, 0x1F, 0x10, 0x1F, 0x10, 0x1F, 0x10, 0x1F, 0x00, 0x1F, 0x00, 0x1F, 0x00, 14 | }; 15 | 16 | #include 17 | GyverOLED oled; 18 | // можно передать адрес: GyverOLED oled(0x3C); 19 | 20 | void setup() { 21 | oled.init(OLED128x64); 22 | 23 | // вывод битмапа: x, y, имя, размерХ, размерУ, инверсия INVERT или не указана 24 | oled.drawBitmap(0, 0, frame0_128x64, 128, 64); 25 | //oled.drawBitmap(0, 0, frame0_128x64, 128, 64, INVERT); 26 | } 27 | 28 | void loop() { 29 | 30 | } 31 | -------------------------------------------------------------------------------- /firmware/MAX7219_mux/webcamMAX7219_mux/GyverMAX7219.h: -------------------------------------------------------------------------------- 1 | #define MUX_S0 5 2 | #define MUX_S1 6 3 | #define MUX_S2 7 4 | #define MUX_S3 8 5 | #define MUX_EN 10 6 | 7 | #define HC595_CLK 4 8 | #define HC595_DAT 2 9 | #define HC595_CS 3 10 | 11 | #ifndef GyverMAX7219_h 12 | #define GyverMAX7219_h 13 | // самая резкая библиотека для матриц MAX7219 на диком западе 14 | 15 | #include 16 | #include 17 | #include "GyverGFX.h" 18 | #include "FastIO.h" 19 | 20 | #ifndef MAX_SPI_SPEED 21 | #define MAX_SPI_SPEED 1000000 22 | #endif 23 | 24 | class MUX { 25 | public: 26 | void init(byte s0, byte s1, byte s2, byte s3, byte en) { 27 | _s0 = s0; 28 | _s1 = s1; 29 | _s2 = s2; 30 | _s3 = s3; 31 | _en = en; 32 | pinMode(_s0, OUTPUT); 33 | pinMode(_s1, OUTPUT); 34 | pinMode(_s2, OUTPUT); 35 | pinMode(_s3, OUTPUT); 36 | pinMode(_en, OUTPUT); 37 | clear(); 38 | } 39 | void setOut(byte num) { 40 | clear(); 41 | fastWrite(_s0, num & 1); 42 | num >>= 1; 43 | fastWrite(_s1, num & 1); 44 | num >>= 1; 45 | fastWrite(_s2, num & 1); 46 | num >>= 1; 47 | fastWrite(_s3, num & 1); 48 | fastWrite(_en, 0); 49 | } 50 | void clear() { 51 | fastWrite(_en, 1); 52 | } 53 | private: 54 | byte _s0, _s1, _s2, _s3, _en; 55 | }; 56 | 57 | class HC595 { 58 | public: 59 | void init(byte clk, byte cs, byte dat) { 60 | _clk = clk; 61 | _cs = cs; 62 | _dat = dat; 63 | pinMode(_clk, 1); 64 | pinMode(_cs, 1); 65 | pinMode(_dat, 1); 66 | fastWrite(_cs, 0); 67 | fastShiftOut(_dat, _clk, MSBFIRST, 0xff); 68 | fastWrite(_cs, 1); 69 | } 70 | void setCS(byte num) { 71 | fastWrite(_cs, 0); 72 | fastShiftOut(_dat, _clk, MSBFIRST, 0xff & ~bit(num)); 73 | fastWrite(_cs, 1); 74 | } 75 | void clear() { 76 | fastWrite(_cs, 0); 77 | fastShiftOut(_dat, _clk, MSBFIRST, 0xff); 78 | fastWrite(_cs, 1); 79 | } 80 | private: 81 | byte _clk = 0, _cs = 0, _dat = 0; 82 | }; 83 | 84 | template 85 | class MAX7219 : public GyverGFX { 86 | public: 87 | MAX7219() { 88 | begin(); 89 | } 90 | ~MAX7219() { 91 | SPI.end(); 92 | SPI.endTransaction(); 93 | } 94 | void begin() { 95 | mux.init(MUX_S0, MUX_S1, MUX_S2, MUX_S3, MUX_EN); 96 | CSsw.init(HC595_CLK, HC595_CS, HC595_DAT); 97 | 98 | pinMode(CSpin, OUTPUT); 99 | SPI.begin(); 100 | SPI.beginTransaction(SPISettings(MAX_SPI_SPEED, MSBFIRST, SPI_MODE0)); 101 | sendCMD(0x0f, 0x00); // отключить режим теста 102 | sendCMD(0x09, 0x00); // выключить декодирование 103 | sendCMD(0x0a, 0x00); // яркость 104 | sendCMD(0x0b, 0x0f); // отображаем всё 105 | sendCMD(0x0C, 0x01); // включить 106 | clear(); 107 | } 108 | void setBright(byte value) { // 8x8: 0/8/15 - 30/310/540 ma 109 | sendCMD(0x0a, value); // яркость 0-15 110 | } 111 | void setPower(bool value) { 112 | sendCMD(0x0c, value); 113 | } 114 | void clear() { 115 | fillMatrix(0); 116 | } 117 | void fill() { 118 | fillMatrix(255); 119 | } 120 | void fillMatrix(byte data) { 121 | if (buf) { 122 | for (int i = 0; i < width * height * 8; i++) buffer[i] = data; 123 | } else { 124 | for (int k = 7; k >= 0; k--) { 125 | beginData(0); 126 | int prevI = 0; 127 | for (int i = 0; i < _amount; i++) { 128 | if (i != prevI) { 129 | prevI = i; 130 | int num = i / (width * 2); // каждые 2 строки 131 | beginData(num); 132 | } 133 | sendByte(k, data); 134 | } 135 | endData(); 136 | } 137 | } 138 | } 139 | void sendByte(uint8_t address, uint8_t value) { 140 | SPI.transfer(8 - address); 141 | SPI.transfer(value); 142 | } 143 | void dot(int x, int y, byte fill = 1) { 144 | if (buf && x >= 0 && x < width * 8 && y >= 0 && y < height * 8) { 145 | int yy = y; 146 | y &= 15; 147 | if ((y >> 3) & 1) { // если это нечётная матрица: (y / 8) % 2 148 | x = width * 8 - 1 - x; // отзеркалить x 149 | y = (y & 0xF8) + (7 - (y & 7)); // отзеркалить y: (y / 8) * 8 + (7 - (y % 8)); 150 | } 151 | // позиция в буфере 152 | int curByte = width * (2 - 1 - (y >> 3)) + (width - 1 - (x >> 3)) + (y & 7) * width * 2; 153 | curByte += width * 16 * (yy / 16); 154 | bitWrite(buffer[curByte], x & 7, fill); 155 | } 156 | } 157 | void update() { 158 | if (buf) { 159 | int count = 0; 160 | for (int h = 0; h < height / 2; h++) { 161 | for (int k = 0; k < 8; k++) { 162 | beginData(h); 163 | for (int w = 0; w < width * 2; w++) { 164 | sendByte(k, buffer[count++]); 165 | } 166 | endData(); 167 | } 168 | } 169 | /* 170 | int count = 0; 171 | for (int k = 0; k < 8; k++) { 172 | beginData(0); 173 | int prevI = 0; 174 | for (int i = 0; i < _amount; i++) { 175 | if (i != prevI) { 176 | prevI = i; 177 | int num = i / (width * 2); // каждые 2 строки 178 | beginData(num); 179 | } 180 | sendByte(k, buffer[count++]); 181 | } 182 | endData(); 183 | }*/ 184 | } 185 | } 186 | 187 | // stream 188 | void restartStream() { 189 | _row = 0; 190 | _count = 0; 191 | _line = 0; 192 | } 193 | void nextByte(byte data) { 194 | if (_line == height / 2) return; 195 | if (_count == 0) beginData(_line); 196 | sendByte(_row, data); 197 | if (++_count == width * 2) { 198 | endData(); 199 | _count = 0; 200 | _row++; 201 | if (_row == 8) { 202 | _row = 0; 203 | _line++; 204 | } 205 | } 206 | /*if (_row == 8) return; 207 | if (_count == 0) beginData(); 208 | sendByte(_row, data); 209 | if (++_count == _amount) { 210 | endData(); 211 | _count = 0; 212 | _row++; 213 | }*/ 214 | } 215 | byte buffer[width * height * 8 * buf]; 216 | HC595 CSsw; 217 | MUX mux; 218 | private: 219 | void beginData(byte num) { 220 | //fastWrite(CSpin, 0); 221 | //num += 2; 222 | mux.setOut(num); 223 | CSsw.setCS(num); 224 | //delayMicroseconds(10); 225 | } 226 | void endData() { 227 | //fastWrite(CSpin, 1); 228 | mux.clear(); 229 | CSsw.clear(); 230 | //delayMicroseconds(10); 231 | } 232 | void sendCMD(uint8_t address, uint8_t value) { 233 | beginData(0); 234 | int prevI = 0; 235 | for (int i = 0; i < _amount; i++) { 236 | if (i != prevI) { 237 | prevI = i; 238 | int num = i / (width * 2); // каждые 2 строки 239 | beginData(num); 240 | } 241 | SPI.transfer(address); 242 | SPI.transfer(value); 243 | } 244 | endData(); 245 | } 246 | 247 | const int _amount = width * height; 248 | int _row = 0, _count = 0, _line = 0; 249 | }; 250 | #endif 251 | -------------------------------------------------------------------------------- /libraries/GyverOLED/examples/bitmap_demo/bitmap_demo.ino: -------------------------------------------------------------------------------- 1 | // Пример GyverOLED. Смотри документацию на http://alexgyver.ru/gyveroled/ 2 | // вывод картинки из памяти, буфер не используем 3 | 4 | // битмап из программы BITmaper OLED (ищи в папке с библиотекой) 5 | const uint8_t bitmap_128x64[] PROGMEM = { 6 | 0xFE, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x04, 0xFC, 0x04, 0xFC, 0x04, 0xFC, 0x04, 0xFC, 0xFC, 0x04, 0xFC, 0x04, 0xFC, 0x04, 0xFC, 0x04, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0x7C, 0x00, 0x1C, 0x80, 0xEC, 0x60, 0x2C, 0x20, 0x2C, 0x40, 0x4C, 0x40, 0x5C, 0x80, 0x9C, 0x00, 0x3C, 0x00, 0x3C, 0x00, 0x7C, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x00, 0xFC, 0x04, 0xFC, 0x14, 0x7C, 0xE0, 0x00, 0x1C, 0x1C, 0xEC, 0x84, 0xFC, 0x04, 0xFC, 0x84, 0x7C, 0x64, 0x1C, 0x10, 0x8C, 0xC8, 0x64, 0xC4, 7 | 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x40, 0xFF, 0x20, 0x3F, 0x3F, 0x20, 0x3F, 0x20, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x7F, 0x00, 0x7F, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x0F, 0xF0, 0xC0, 0x00, 0x7F, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x40, 0x40, 0x80, 0x80, 0x80, 0x00, 0x40, 0x41, 0x40, 0x81, 0x88, 0x8B, 0x08, 0x1B, 0x10, 0x17, 0x30, 0x2F, 0x20, 0x2F, 0x10, 0x1F, 0x00, 0x0F, 0x10, 0x1F, 0x00, 0x00, 0x3F, 0x1F, 0x0C, 0x00, 0x81, 0x81, 0x1F, 0x66, 0x71, 0xD9, 0x8E, 0x07, 0x03, 0x87, 0xCD, 0x78, 0x78, 0xCC, 8 | 0xFF, 0x00, 0xFF, 0x00, 0x3F, 0x00, 0x0F, 0x00, 0x07, 0x30, 0x73, 0xD0, 0xD3, 0x18, 0x09, 0x08, 0x01, 0x00, 0x03, 0x00, 0x03, 0x00, 0x07, 0x00, 0x0F, 0x08, 0x0F, 0x00, 0x1F, 0x00, 0xE3, 0xFC, 0xFF, 0xFF, 0xFC, 0xFE, 0xFE, 0xF9, 0xF8, 0xF2, 0xF8, 0xF9, 0xFC, 0xFC, 0xFF, 0xFE, 0xE6, 0xE2, 0xF0, 0xBD, 0x50, 0x0F, 0x00, 0xBF, 0xE0, 0x4F, 0xE0, 0xF7, 0xF0, 0x7B, 0xBC, 0xDE, 0x6B, 0x81, 0x80, 0x80, 0xC0, 0xF8, 0x8C, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x09, 0x00, 0xFE, 0x00, 0xF8, 0x00, 0xF1, 0x01, 0xF3, 0x02, 0xF2, 0x00, 0xF0, 0x00, 0xF0, 0x00, 0xF0, 0x00, 0xF0, 0x00, 0xF0, 0x00, 0xF0, 0x00, 0xE0, 0x00, 0xC0, 0x00, 0xC0, 0x10, 0xF0, 0x30, 0xB0, 0x78, 0xC8, 0xE9, 0x61, 0xF0, 0xE8, 0x18, 0xFC, 0xC7, 0x83, 0x03, 0x87, 0xCC, 0x7C, 0x78, 0x6C, 9 | 0x03, 0x80, 0x00, 0x00, 0x30, 0xF8, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xC7, 0xE7, 0x74, 0x7C, 0xF8, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xC0, 0x80, 0x00, 0x10, 0x30, 0xE0, 0xE6, 0x67, 0x7F, 0x79, 0x71, 0xEF, 0xFF, 0xFF, 0x7F, 0x7F, 0x3F, 0x3F, 0x3F, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x6F, 0xF7, 0xF8, 0xFD, 0xFE, 0xFF, 0xFF, 0xFC, 0xF9, 0xF2, 0xFA, 0xFC, 0xE1, 0xC3, 0xE7, 0x9C, 0xD9, 0xC0, 0x9E, 0x3E, 0x7E, 0x7E, 0xFE, 0xFD, 0xFD, 0xFD, 0xFD, 0x9D, 0xD2, 0xEA, 0x3A, 0x04, 0xC8, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x03, 0xFC, 0x0F, 0xF3, 0x13, 0xE6, 0x2C, 0xC8, 0x0C, 10 | 0xFF, 0x01, 0xE6, 0x18, 0x20, 0xE7, 0x7F, 0x59, 0x60, 0x70, 0xF8, 0xFC, 0x3E, 0x7F, 0xFF, 0x0C, 0x0C, 0x4F, 0x4F, 0x4F, 0x7F, 0x7F, 0xC9, 0x6B, 0x37, 0x1F, 0x0E, 0x00, 0x86, 0x87, 0x80, 0x80, 0xC0, 0xC0, 0xC1, 0x41, 0x00, 0x00, 0x88, 0xCC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7E, 0xFE, 0xFE, 0x7C, 0x3D, 0xC3, 0x07, 0xFF, 0xFF, 0xFF, 0xF3, 0xF7, 0xEF, 0xED, 0xEC, 0xFD, 0xF9, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0x3C, 0x01, 0x03, 0x03, 0x03, 0x0E, 0x0D, 0x03, 0x7C, 0x00, 0x7F, 0x00, 0x7F, 0x00, 0x7F, 0x00, 0x7F, 0x00, 0x7F, 0x00, 0xFF, 0x00, 0x7F, 0x80, 0x1F, 0x00, 0x1F, 0x00, 0x9F, 0xC0, 0x3F, 0x40, 0x7F, 0x00, 0x7F, 0x00, 0x7F, 0x00, 0x7F, 0x40, 0x7F, 0x40, 0x7F, 0x40, 0x7F, 0x7F, 0x40, 0x7F, 0x40, 0xFF, 0x80, 0xFF, 0x80, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 11 | 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFC, 0x06, 0xE6, 0x0C, 0xCC, 0x19, 0x98, 0x10, 0x91, 0x01, 0xC0, 0x04, 0xC4, 0x04, 0x84, 0x04, 0xC4, 0x04, 0xEC, 0x09, 0x89, 0x09, 0x89, 0x89, 0x89, 0x09, 0xE0, 0xE0, 0xE0, 0xF4, 0xFE, 0xFF, 0xFF, 0xFD, 0xFB, 0xFB, 0xF7, 0xCF, 0xCF, 0xCF, 0xCF, 0xCC, 0x8C, 0xB4, 0xA7, 0x67, 0x94, 0x33, 0x33, 0xCB, 0x17, 0xAF, 0xDF, 0x3F, 0xFF, 0xFF, 0x3F, 0xCF, 0xE7, 0xF3, 0xFB, 0xF9, 0xFD, 0xFE, 0xFE, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0x84, 0x78, 0xFF, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, 0x0E, 0x0F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0E, 0x0E, 0x06, 0x06, 0x04, 0x85, 0x06, 0x06, 0x06, 12 | 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x7F, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x80, 0x9F, 0xC2, 0x3F, 0x24, 0xF7, 0x99, 0x99, 0x99, 0xE9, 0xC9, 0xD9, 0xE9, 0xE9, 0xF1, 0xF1, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFF, 0xFF, 0xFE, 0xFF, 0xFE, 0x7D, 0x7A, 0xB4, 0x3C, 0xC1, 0x02, 0xDC, 0x1B, 0xB7, 0x2B, 0x57, 0x6F, 0x57, 0x6F, 0x57, 0x6F, 0x57, 0x6F, 0xB7, 0x2F, 0xB7, 0x2F, 0xB7, 0x2F, 0xB7, 0x2F, 0xB7, 0x2F, 0xB7, 0x1B, 0xD7, 0x1B, 0xD7, 0x1B, 0xEF, 0x0C, 0xF3, 0x0E, 0x90, 0x20, 0xA0, 0x00, 0xC0, 0x00, 0xC0, 0x10, 0xC0, 0x30, 0xF8, 0x00, 0xF8, 0x00, 0xF8, 0x00, 0xF0, 0x10, 0xF0, 0x0C, 0xF8, 0xF8, 0x08, 0xF8, 0x08, 0xFE, 0x04, 0xFF, 0x00, 0xFE, 0x00, 0xFF, 0x00, 0xFF, 0x00, 13 | 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3D, 0x3A, 0x3C, 0x3A, 0x34, 0x38, 0x35, 0x08, 0x13, 0x24, 0x0F, 0x00, 0x03, 0x3C, 0x35, 0x02, 0x01, 0x3D, 0x0F, 0x27, 0x03, 0x1B, 0x13, 0x13, 0x13, 0x1B, 0x13, 0x1B, 0x13, 0x1B, 0x13, 0x1B, 0x01, 0x1D, 0x01, 0x1D, 0x01, 0x1D, 0x01, 0x3E, 0x00, 0x3E, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x3F, 0x00, 0x1F, 0x00, 0x27, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0x1F, 0x00, 0x1F, 0x10, 0x1F, 0x10, 0x1F, 0x10, 0x1F, 0x1F, 0x10, 0x1F, 0x10, 0x1F, 0x10, 0x1F, 0x10, 0x1F, 0x00, 0x1F, 0x00, 0x1F, 0x00, 14 | }; 15 | 16 | const uint8_t bitmap_32x32[] PROGMEM = { 17 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0xE0, 0xF0, 0x70, 0x70, 0x30, 0x30, 0x30, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF0, 0x70, 0x30, 0x30, 0x20, 0x00, 0x00, 18 | 0x00, 0x30, 0x78, 0xFC, 0x7F, 0x3F, 0x0F, 0x0F, 0x1F, 0x3C, 0x78, 0xF0, 0xE0, 0xC0, 0x80, 0x80, 0x80, 0x40, 0xE0, 0xF0, 0xF8, 0xFC, 0xFF, 0x7F, 0x33, 0x13, 0x1E, 0x1C, 0x1C, 0x0E, 0x07, 0x00, 19 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF9, 0xF7, 0xEF, 0x5F, 0x3F, 0x7F, 0xFE, 0xFD, 0xFB, 0xF1, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 20 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x1E, 0x33, 0x33, 0x1F, 0x0F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x1F, 0x0E, 0x04, 0x00, 0x00, 0x00, 0x00, 21 | }; 22 | 23 | #include 24 | GyverOLED oled; 25 | // можно передать адрес: GyverOLED oled(0x3C); 26 | 27 | void setup() { 28 | oled.init(); 29 | oled.clear(); 30 | 31 | // вывод битмапа: (x, y, имя, размерХ, размерУ, инверсия INVERT или не указана) 32 | oled.drawBitmap(0, 0, bitmap_128x64, 128, 64); 33 | oled.drawBitmap(25, 16, bitmap_32x32, 32, 32); 34 | } 35 | 36 | void loop() { 37 | } 38 | -------------------------------------------------------------------------------- /firmware/telegram4/charMap.h: -------------------------------------------------------------------------------- 1 | #ifndef charMap_h 2 | #define charMap_f 3 | // шрифты для вывода текста 4 | const uint8_t charMap[][5] PROGMEM = { 5 | {0x00, 0x00, 0x00, 0x00, 0x00}, // 0x20 32 6 | {0x00, 0x00, 0x6f, 0x00, 0x00}, // ! 0x21 33 7 | {0x00, 0x07, 0x00, 0x07, 0x00}, // " 0x22 34 8 | {0x14, 0x7f, 0x14, 0x7f, 0x14}, // # 0x23 35 9 | {0x8C, 0x92, 0xFF, 0x92, 0x62}, // $ 0x24 36 10 | {0x23, 0x13, 0x08, 0x64, 0x62}, // % 0x25 37 11 | {0x36, 0x49, 0x56, 0x20, 0x50}, // & 0x26 38 12 | {0x00, 0x00, 0x07, 0x00, 0x00}, // ' 0x27 39 13 | {0x00, 0x1c, 0x22, 0x41, 0x00}, // ( 0x28 40 14 | {0x00, 0x41, 0x22, 0x1c, 0x00}, // ) 0x29 41 15 | {0x14, 0x08, 0x3e, 0x08, 0x14}, // * 0x2a 42 16 | {0x08, 0x08, 0x3e, 0x08, 0x08}, // + 0x2b 43 17 | {0x00, 0x50, 0x30, 0x00, 0x00}, // , 0x2c 44 18 | {0x08, 0x08, 0x08, 0x08, 0x08}, // - 0x2d 45 19 | {0x00, 0x60, 0x60, 0x00, 0x00}, // . 0x2e 46 20 | {0x20, 0x10, 0x08, 0x04, 0x02}, // / 0x2f 47 21 | {0x3e, 0x51, 0x49, 0x45, 0x3e}, // 0 0x30 48 22 | {0x00, 0x42, 0x7f, 0x40, 0x00}, // 1 0x31 49 23 | {0x42, 0x61, 0x51, 0x49, 0x46}, // 2 0x32 50 24 | {0x21, 0x41, 0x45, 0x4b, 0x31}, // 3 0x33 51 25 | {0x18, 0x14, 0x12, 0x7f, 0x10}, // 4 0x34 52 26 | {0x27, 0x45, 0x45, 0x45, 0x39}, // 5 0x35 53 27 | {0x3c, 0x4a, 0x49, 0x49, 0x30}, // 6 0x36 54 28 | {0x01, 0x71, 0x09, 0x05, 0x03}, // 7 0x37 55 29 | {0x36, 0x49, 0x49, 0x49, 0x36}, // 8 0x38 56 30 | {0x06, 0x49, 0x49, 0x29, 0x1e}, // 9 0x39 57 31 | {0x00, 0x36, 0x36, 0x00, 0x00}, // : 0x3a 58 32 | {0x00, 0x56, 0x36, 0x00, 0x00}, // ; 0x3b 59 33 | {0x08, 0x14, 0x22, 0x41, 0x00}, // < 0x3c 60 34 | {0x14, 0x14, 0x14, 0x14, 0x14}, // = 0x3d 61 35 | {0x00, 0x41, 0x22, 0x14, 0x08}, // > 0x3e 62 36 | {0x02, 0x01, 0x51, 0x09, 0x06}, // ? 0x3f 63 37 | {0x3e, 0x41, 0x5d, 0x49, 0x4e}, // @ 0x40 64 38 | {0x7e, 0x09, 0x09, 0x09, 0x7e}, // A 0x41 65 39 | {0x7f, 0x49, 0x49, 0x49, 0x36}, // B 0x42 66 40 | {0x3e, 0x41, 0x41, 0x41, 0x22}, // C 0x43 67 41 | {0x7f, 0x41, 0x41, 0x41, 0x3e}, // D 0x44 68 42 | {0x7f, 0x49, 0x49, 0x49, 0x41}, // E 0x45 69 43 | {0x7f, 0x09, 0x09, 0x09, 0x01}, // F 0x46 70 44 | {0x3e, 0x41, 0x49, 0x49, 0x7a}, // G 0x47 71 45 | {0x7f, 0x08, 0x08, 0x08, 0x7f}, // H 0x48 72 46 | {0x00, 0x41, 0x7f, 0x41, 0x00}, // I 0x49 73 47 | {0x20, 0x40, 0x41, 0x3f, 0x01}, // J 0x4a 74 48 | {0x7f, 0x08, 0x14, 0x22, 0x41}, // K 0x4b 75 49 | {0x7f, 0x40, 0x40, 0x40, 0x40}, // L 0x4c 76 50 | {0x7f, 0x02, 0x0c, 0x02, 0x7f}, // M 0x4d 77 51 | {0x7f, 0x04, 0x08, 0x10, 0x7f}, // N 0x4e 78 52 | {0x3e, 0x41, 0x41, 0x41, 0x3e}, // O 0x4f 79 53 | {0x7f, 0x09, 0x09, 0x09, 0x06}, // P 0x50 80 54 | {0x3e, 0x41, 0x51, 0x21, 0x5e}, // Q 0x51 81 55 | {0x7f, 0x09, 0x19, 0x29, 0x46}, // R 0x52 82 56 | {0x46, 0x49, 0x49, 0x49, 0x31}, // S 0x53 83 57 | {0x01, 0x01, 0x7f, 0x01, 0x01}, // T 0x54 84 58 | {0x3f, 0x40, 0x40, 0x40, 0x3f}, // U 0x55 85 59 | {0x0f, 0x30, 0x40, 0x30, 0x0f}, // V 0x56 86 60 | {0x3f, 0x40, 0x30, 0x40, 0x3f}, // W 0x57 87 61 | {0x63, 0x14, 0x08, 0x14, 0x63}, // X 0x58 88 62 | {0x07, 0x08, 0x70, 0x08, 0x07}, // Y 0x59 89 63 | {0x61, 0x51, 0x49, 0x45, 0x43}, // Z 0x5a 90 64 | {0x00, 0x00, 0x7f, 0x41, 0x00}, // [ 0x5b 91 65 | {0x02, 0x04, 0x08, 0x10, 0x20}, // \ 0x5c 92 66 | {0x00, 0x41, 0x7f, 0x00, 0x00}, // ] 0x5d 93 67 | {0x04, 0x02, 0x01, 0x02, 0x04}, // ^ 0x5e 94 68 | {0x40, 0x40, 0x40, 0x40, 0x40}, // _ 0x5f 95 69 | {0x00, 0x00, 0x03, 0x04, 0x00}, // ` 0x60 96 70 | {0x20, 0x54, 0x54, 0x54, 0x78}, // a 0x61 97 71 | {0x7f, 0x48, 0x44, 0x44, 0x38}, // b 0x62 98 72 | {0x38, 0x44, 0x44, 0x44, 0x20}, // c 0x63 99 73 | {0x38, 0x44, 0x44, 0x48, 0x7f}, // d 0x64 100 74 | {0x38, 0x54, 0x54, 0x54, 0x18}, // e 0x65 101 75 | {0x08, 0x7e, 0x09, 0x01, 0x02}, // f 0x66 102 76 | {0x0c, 0x52, 0x52, 0x52, 0x3e}, // g 0x67 103 77 | {0x7f, 0x08, 0x04, 0x04, 0x78}, // h 0x68 104 78 | {0x00, 0x44, 0x7d, 0x40, 0x00}, // i 0x69 105 79 | {0x20, 0x40, 0x44, 0x3d, 0x00}, // j 0x6a 106 80 | {0x00, 0x7f, 0x10, 0x28, 0x44}, // k 0x6b 107 81 | {0x00, 0x41, 0x7f, 0x40, 0x00}, // l 0x6c 108 82 | {0x7c, 0x04, 0x18, 0x04, 0x78}, // m 0x6d 109 83 | {0x7c, 0x08, 0x04, 0x04, 0x78}, // n 0x6e 110 84 | {0x38, 0x44, 0x44, 0x44, 0x38}, // o 0x6f 111 85 | {0x7c, 0x14, 0x14, 0x14, 0x08}, // p 0x70 112 86 | {0x08, 0x14, 0x14, 0x18, 0x7c}, // q 0x71 113 87 | {0x7c, 0x08, 0x04, 0x04, 0x08}, // r 0x72 114 88 | {0x48, 0x54, 0x54, 0x54, 0x20}, // s 0x73 115 89 | {0x04, 0x3f, 0x44, 0x40, 0x20}, // t 0x74 116 90 | {0x3c, 0x40, 0x40, 0x20, 0x7c}, // u 0x75 117 91 | {0x1c, 0x20, 0x40, 0x20, 0x1c}, // v 0x76 118 92 | {0x3c, 0x40, 0x30, 0x40, 0x3c}, // w 0x77 119 93 | {0x44, 0x28, 0x10, 0x28, 0x44}, // x 0x78 120 94 | {0x0c, 0x50, 0x50, 0x50, 0x3c}, // y 0x79 121 95 | {0x44, 0x64, 0x54, 0x4c, 0x44}, // z 0x7a 122 96 | {0x00, 0x08, 0x36, 0x41, 0x41}, // { 0x7b 123 97 | {0x00, 0x00, 0x7f, 0x00, 0x00}, // | 0x7c 124 98 | {0x41, 0x41, 0x36, 0x08, 0x00}, // } 0x7d 125 99 | {0x04, 0x02, 0x04, 0x08, 0x04}, // ~ 0x7e 126 100 | 101 | {0x7E, 0x11, 0x11, 0x11, 0x7E}, //__А (0xC0). 102 | {0x7F, 0x49, 0x49, 0x49, 0x33}, //__Б (0xC1). 103 | {0x7F, 0x49, 0x49, 0x49, 0x36}, //__В (0xC2). 104 | {0x7F, 0x01, 0x01, 0x01, 0x03}, //__Г (0xC3). 105 | {0xE0, 0x51, 0x4F, 0x41, 0xFF}, //__Д (0xC4). 106 | {0x7F, 0x49, 0x49, 0x49, 0x41}, //__Е (0xC5). 107 | {0x77, 0x08, 0x7F, 0x08, 0x77}, //__Ж (0xC6). 108 | {0x41, 0x49, 0x49, 0x49, 0x36}, //__З (0xC7). 109 | {0x7F, 0x10, 0x08, 0x04, 0x7F}, //__И (0xC8). 110 | {0x7C, 0x21, 0x12, 0x09, 0x7C}, //__Й (0xC9). 111 | {0x7F, 0x08, 0x14, 0x22, 0x41}, //__К (0xCA). 112 | {0x20, 0x41, 0x3F, 0x01, 0x7F}, //__Л (0xCB). 113 | {0x7F, 0x02, 0x0C, 0x02, 0x7F}, //__М (0xCC). 114 | {0x7F, 0x08, 0x08, 0x08, 0x7F}, //__Н (0xCD). 115 | {0x3E, 0x41, 0x41, 0x41, 0x3E}, //__О (0xCE). 116 | {0x7F, 0x01, 0x01, 0x01, 0x7F}, //__П (0xCF). 117 | {0x7F, 0x09, 0x09, 0x09, 0x06}, //__Р (0xD0). 118 | {0x3E, 0x41, 0x41, 0x41, 0x22}, //__С (0xD1). 119 | {0x01, 0x01, 0x7F, 0x01, 0x01}, //__Т (0xD2). 120 | {0x47, 0x28, 0x10, 0x08, 0x07}, //__У (0xD3). 121 | {0x1C, 0x22, 0x7F, 0x22, 0x1C}, //__Ф (0xD4). 122 | {0x63, 0x14, 0x08, 0x14, 0x63}, //__Х (0xD5). 123 | {0x7F, 0x40, 0x40, 0x40, 0xFF}, //__Ц (0xD6). 124 | {0x07, 0x08, 0x08, 0x08, 0x7F}, //__Ч (0xD7). 125 | {0x7F, 0x40, 0x7F, 0x40, 0x7F}, //__Ш (0xD8). 126 | {0x7F, 0x40, 0x7F, 0x40, 0xFF}, //__Щ (0xD9). 127 | {0x01, 0x7F, 0x48, 0x48, 0x30}, //__Ъ (0xDA). 128 | {0x7F, 0x48, 0x30, 0x00, 0x7F}, //__Ы (0xDB). 129 | {0x00, 0x7F, 0x48, 0x48, 0x30}, //__Ь (0xDC). 130 | {0x22, 0x41, 0x49, 0x49, 0x3E}, //__Э (0xDD). 131 | {0x7F, 0x08, 0x3E, 0x41, 0x3E}, //__Ю (0xDE). 132 | {0x46, 0x29, 0x19, 0x09, 0x7F}, //__Я (0xDF). 133 | 134 | {0x20, 0x54, 0x54, 0x54, 0x78}, //__а (0xE0). 135 | {0x3C, 0x4A, 0x4A, 0x49, 0x31}, //__б (0xE1). 136 | {0x7C, 0x54, 0x54, 0x28, 0x00}, //__в (0xE2). 137 | {0x7C, 0x04, 0x04, 0x0C, 0x00}, //__г (0xE3). 138 | {0xE0, 0x54, 0x4C, 0x44, 0xFC}, //__д (0xE4). 139 | {0x38, 0x54, 0x54, 0x54, 0x18}, //__е (0xE5). 140 | {0x6C, 0x10, 0x7C, 0x10, 0x6C}, //__ж (0xE6). 141 | {0x44, 0x54, 0x54, 0x28, 0x00}, //__з (0xE7). 142 | {0x7C, 0x20, 0x10, 0x08, 0x7C}, //__и (0xE8). 143 | {0x78, 0x42, 0x24, 0x12, 0x78}, //__й (0xE9). 144 | {0x7C, 0x10, 0x28, 0x44, 0x00}, //__к (0xEA). 145 | {0x20, 0x44, 0x3C, 0x04, 0x7C}, //__л (0xEB). 146 | {0x7C, 0x08, 0x10, 0x08, 0x7C}, //__м (0xEC). 147 | {0x7C, 0x10, 0x10, 0x10, 0x7C}, //__н (0xED). 148 | {0x38, 0x44, 0x44, 0x44, 0x38}, //__о (0xEE). 149 | {0x7C, 0x04, 0x04, 0x04, 0x7C}, //__п (0xEF). 150 | {0x7C, 0x14, 0x14, 0x14, 0x08}, //__р (0xF0). 151 | {0x38, 0x44, 0x44, 0x44, 0x00}, //__с (0xF1). 152 | {0x04, 0x04, 0x7C, 0x04, 0x04}, //__т (0xF2). 153 | {0x0C, 0x50, 0x50, 0x50, 0x3C}, //__у (0xF3). 154 | {0x30, 0x48, 0xFE, 0x48, 0x30}, //__ф (0xF4). 155 | {0x44, 0x28, 0x10, 0x28, 0x44}, //__х (0xF5). 156 | {0x7C, 0x40, 0x40, 0x7C, 0xC0}, //__ц (0xF6). 157 | {0x0C, 0x10, 0x10, 0x10, 0x7C}, //__ч (0xF7). 158 | {0x7C, 0x40, 0x7C, 0x40, 0x7C}, //__ш (0xF8). 159 | {0x7C, 0x40, 0x7C, 0x40, 0xFC}, //__щ (0xF9). 160 | {0x04, 0x7C, 0x50, 0x50, 0x20}, //__ъ (0xFA). 161 | {0x7C, 0x50, 0x50, 0x20, 0x7C}, //__ы (0xFB). 162 | {0x7C, 0x50, 0x50, 0x20, 0x00}, //__ь (0xFC). 163 | {0x28, 0x44, 0x54, 0x54, 0x38}, //__э (0xFD). 164 | {0x7C, 0x10, 0x38, 0x44, 0x38}, //__ю (0xFE). 165 | {0x08, 0x54, 0x34, 0x14, 0x7C}, //__я (0xFF). 166 | {0x38, 0x55, 0x54, 0x55, 0x18}, //__ё (0xFF). 167 | }; 168 | #endif -------------------------------------------------------------------------------- /libraries/Adafruit-ST7735-Library-master/examples/spitftbitmap/spitftbitmap.ino: -------------------------------------------------------------------------------- 1 | /*************************************************** 2 | This is a library for the Adafruit 1.8" SPI display. 3 | 4 | This library works with the Adafruit 1.8" TFT Breakout w/SD card 5 | ----> http://www.adafruit.com/products/358 6 | The 1.8" TFT shield 7 | ----> https://www.adafruit.com/product/802 8 | The 1.44" TFT breakout 9 | ----> https://www.adafruit.com/product/2088 10 | as well as Adafruit raw 1.8" TFT display 11 | ----> http://www.adafruit.com/products/618 12 | 13 | Check out the links above for our tutorials and wiring diagrams 14 | These displays use SPI to communicate, 4 or 5 pins are required to 15 | interface (RST is optional) 16 | Adafruit invests time and resources providing this open source code, 17 | please support Adafruit and open-source hardware by purchasing 18 | products from Adafruit! 19 | 20 | Written by Limor Fried/Ladyada for Adafruit Industries. 21 | MIT license, all text above must be included in any redistribution 22 | ****************************************************/ 23 | 24 | #include // Core graphics library 25 | #include // Hardware-specific library 26 | #include 27 | #include 28 | 29 | // TFT display and SD card will share the hardware SPI interface. 30 | // Hardware SPI pins are specific to the Arduino board type and 31 | // cannot be remapped to alternate pins. For Arduino Uno, 32 | // Duemilanove, etc., pin 11 = MOSI, pin 12 = MISO, pin 13 = SCK. 33 | #define TFT_CS 10 // Chip select line for TFT display 34 | #define TFT_RST 9 // Reset line for TFT (or see below...) 35 | #define TFT_DC 8 // Data/command line for TFT 36 | 37 | #define SD_CS 4 // Chip select line for SD card 38 | 39 | //Use this reset pin for the shield! 40 | //#define TFT_RST 0 // you can also connect this to the Arduino reset! 41 | 42 | Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST); 43 | 44 | void setup(void) { 45 | Serial.begin(9600); 46 | 47 | // Use this initializer if you're using a 1.8" TFT 48 | tft.initR(INITR_BLACKTAB); 49 | 50 | // Use this initializer (uncomment) if you're using a 1.44" TFT 51 | //tft.initR(INITR_144GREENTAB); 52 | 53 | Serial.print("Initializing SD card..."); 54 | if (!SD.begin(SD_CS)) { 55 | Serial.println("failed!"); 56 | return; 57 | } 58 | Serial.println("OK!"); 59 | 60 | // change the name here! 61 | bmpDraw("parrot.bmp", 0, 0); 62 | // wait 5 seconds 63 | delay(5000); 64 | } 65 | 66 | void loop() { 67 | // uncomment these lines to draw bitmaps in different locations/rotations! 68 | /* 69 | tft.fillScreen(ST7735_BLACK); // Clear display 70 | for(uint8_t i=0; i<4; i++) // Draw 4 parrots 71 | bmpDraw("parrot.bmp", tft.width() / 4 * i, tft.height() / 4 * i); 72 | delay(1000); 73 | tft.setRotation(tft.getRotation() + 1); // Inc rotation 90 degrees 74 | */ 75 | } 76 | 77 | // This function opens a Windows Bitmap (BMP) file and 78 | // displays it at the given coordinates. It's sped up 79 | // by reading many pixels worth of data at a time 80 | // (rather than pixel by pixel). Increasing the buffer 81 | // size takes more of the Arduino's precious RAM but 82 | // makes loading a little faster. 20 pixels seems a 83 | // good balance. 84 | 85 | #define BUFFPIXEL 20 86 | 87 | void bmpDraw(char *filename, uint8_t x, uint8_t y) { 88 | 89 | File bmpFile; 90 | int bmpWidth, bmpHeight; // W+H in pixels 91 | uint8_t bmpDepth; // Bit depth (currently must be 24) 92 | uint32_t bmpImageoffset; // Start of image data in file 93 | uint32_t rowSize; // Not always = bmpWidth; may have padding 94 | uint8_t sdbuffer[3*BUFFPIXEL]; // pixel buffer (R+G+B per pixel) 95 | uint8_t buffidx = sizeof(sdbuffer); // Current position in sdbuffer 96 | boolean goodBmp = false; // Set to true on valid header parse 97 | boolean flip = true; // BMP is stored bottom-to-top 98 | int w, h, row, col; 99 | uint8_t r, g, b; 100 | uint32_t pos = 0, startTime = millis(); 101 | 102 | if((x >= tft.width()) || (y >= tft.height())) return; 103 | 104 | Serial.println(); 105 | Serial.print("Loading image '"); 106 | Serial.print(filename); 107 | Serial.println('\''); 108 | 109 | // Open requested file on SD card 110 | if ((bmpFile = SD.open(filename)) == NULL) { 111 | Serial.print("File not found"); 112 | return; 113 | } 114 | 115 | // Parse BMP header 116 | if(read16(bmpFile) == 0x4D42) { // BMP signature 117 | Serial.print("File size: "); Serial.println(read32(bmpFile)); 118 | (void)read32(bmpFile); // Read & ignore creator bytes 119 | bmpImageoffset = read32(bmpFile); // Start of image data 120 | Serial.print("Image Offset: "); Serial.println(bmpImageoffset, DEC); 121 | // Read DIB header 122 | Serial.print("Header size: "); Serial.println(read32(bmpFile)); 123 | bmpWidth = read32(bmpFile); 124 | bmpHeight = read32(bmpFile); 125 | if(read16(bmpFile) == 1) { // # planes -- must be '1' 126 | bmpDepth = read16(bmpFile); // bits per pixel 127 | Serial.print("Bit Depth: "); Serial.println(bmpDepth); 128 | if((bmpDepth == 24) && (read32(bmpFile) == 0)) { // 0 = uncompressed 129 | 130 | goodBmp = true; // Supported BMP format -- proceed! 131 | Serial.print("Image size: "); 132 | Serial.print(bmpWidth); 133 | Serial.print('x'); 134 | Serial.println(bmpHeight); 135 | 136 | // BMP rows are padded (if needed) to 4-byte boundary 137 | rowSize = (bmpWidth * 3 + 3) & ~3; 138 | 139 | // If bmpHeight is negative, image is in top-down order. 140 | // This is not canon but has been observed in the wild. 141 | if(bmpHeight < 0) { 142 | bmpHeight = -bmpHeight; 143 | flip = false; 144 | } 145 | 146 | // Crop area to be loaded 147 | w = bmpWidth; 148 | h = bmpHeight; 149 | if((x+w-1) >= tft.width()) w = tft.width() - x; 150 | if((y+h-1) >= tft.height()) h = tft.height() - y; 151 | 152 | // Set TFT address window to clipped image bounds 153 | tft.setAddrWindow(x, y, x+w-1, y+h-1); 154 | 155 | for (row=0; row= sizeof(sdbuffer)) { // Indeed 175 | bmpFile.read(sdbuffer, sizeof(sdbuffer)); 176 | buffidx = 0; // Set index to beginning 177 | } 178 | 179 | // Convert pixel from BMP to TFT format, push to display 180 | b = sdbuffer[buffidx++]; 181 | g = sdbuffer[buffidx++]; 182 | r = sdbuffer[buffidx++]; 183 | tft.pushColor(tft.Color565(r,g,b)); 184 | } // end pixel 185 | } // end scanline 186 | Serial.print("Loaded in "); 187 | Serial.print(millis() - startTime); 188 | Serial.println(" ms"); 189 | } // end goodBmp 190 | } 191 | } 192 | 193 | bmpFile.close(); 194 | if(!goodBmp) Serial.println("BMP format not recognized."); 195 | } 196 | 197 | // These read 16- and 32-bit types from the SD card file. 198 | // BMP data is stored little-endian, Arduino is little-endian too. 199 | // May need to reverse subscript order if porting elsewhere. 200 | 201 | uint16_t read16(File f) { 202 | uint16_t result; 203 | ((uint8_t *)&result)[0] = f.read(); // LSB 204 | ((uint8_t *)&result)[1] = f.read(); // MSB 205 | return result; 206 | } 207 | 208 | uint32_t read32(File f) { 209 | uint32_t result; 210 | ((uint8_t *)&result)[0] = f.read(); // LSB 211 | ((uint8_t *)&result)[1] = f.read(); 212 | ((uint8_t *)&result)[2] = f.read(); 213 | ((uint8_t *)&result)[3] = f.read(); // MSB 214 | return result; 215 | } --------------------------------------------------------------------------------