diff --git a/warpsrvint/docker_esphome/templates/config/frekvens_panel/04B03.ttf b/warpsrvint/docker_esphome/files/config/04B03.ttf similarity index 100% rename from warpsrvint/docker_esphome/templates/config/frekvens_panel/04B03.ttf rename to warpsrvint/docker_esphome/files/config/04B03.ttf diff --git a/warpsrvint/docker_esphome/tasks/main.yml b/warpsrvint/docker_esphome/tasks/main.yml index 838a81cb2cda5755b67f5fae63074f7326e53bfa..b2bebe369be453a39297974b8d2afeb0d58a48e5 100644 --- a/warpsrvint/docker_esphome/tasks/main.yml +++ b/warpsrvint/docker_esphome/tasks/main.yml @@ -11,6 +11,16 @@ with_items: - "{{ basedir }}/" - "{{ basedir }}/config/" + - "{{ basedir }}/config/components/" + - "{{ basedir }}/config/components/frekvens_panel/" + +- name: "copy files for {{ servicename }}" + copy: + src: "{{ item }}" + dest: "{{ basedir }}/{{ item }}" + with_items: + - config/04B03.ttf + register: config - name: "create config files for {{ servicename }}" template: @@ -20,6 +30,8 @@ - docker-compose.yml - compile.sh - config/esphome_dach.yaml + - config/esphome_display01.yaml + - config/esphome_display02.yaml - config/esphome_feinstaub01.yaml - config/esphome_hauptraum.yaml - config/esphome_holzwerkstatt.yaml @@ -28,12 +40,9 @@ - config/esphome_lounge.yaml - config/esphome_luftfilter01.yaml - config/esphome_vortragsraum.yaml - - config/esphome_strommesser.yaml - - config/esphome_frekvens.yaml - - config/esphome_obegraensad.yaml register: config -- name: download config includes files +- name: download config includes files (esphome) get_url: url: "https://raw.githubusercontent.com/esphome/esphome-docs/current/_static/{{ item }}" dest: "{{ basedir }}/config/{{ item }}" @@ -41,6 +50,18 @@ - webserver-v1.min.css - webserver-v1.min.js +- name: download config includes files (frekvens module) + get_url: + url: "https://raw.githubusercontent.com/prashnts/esphome-frekvens-panel/master/components/frekvens_panel/{{ item }}" + dest: "{{ basedir }}/config/components/frekvens_panel/{{ item }}" + with_items: + - __init__.py + - display.py + - frekvens-driver.cpp + - frekvens-driver.h + - frekvens-panel.cpp + - frekvens-panel.h + - name: "stop {{ servicename }} docker" docker_compose: diff --git a/warpsrvint/docker_esphome/templates/config/esphome_freckvens.yaml b/warpsrvint/docker_esphome/templates/config/esphome_display01.yaml similarity index 64% rename from warpsrvint/docker_esphome/templates/config/esphome_freckvens.yaml rename to warpsrvint/docker_esphome/templates/config/esphome_display01.yaml index 2ef995f32ea870e51fe0301ee79bf7348765e0a2..49d4cea1ebc75c7d7bfd90277b39a6eae51c7e80 100644 --- a/warpsrvint/docker_esphome/templates/config/esphome_freckvens.yaml +++ b/warpsrvint/docker_esphome/templates/config/esphome_display01.yaml @@ -1,7 +1,18 @@ -{% set devicename = "esphome_frekvens" %} +{% set devicename = "esphome_display01" %} {% include "/includes/ansible.inc.yaml" %} + {% include "/includes/board.d1_mini.inc.yaml" %} + # force newline + platformio_options: + upload_speed: 115200 + lib_deps: + - me-no-dev/ESPAsyncTCP + - adafruit/Adafruit GFX Library # Required for FrekvensPanel. + - Adafruit BusIO # Required by GFX Library. + - Wire # Also required by GFX. + - SPI # Also required by GFX. + {% include "/includes/common.inc.yaml" %} @@ -30,7 +41,7 @@ time: timezone: 'Europe/Paris' font: - - file: "frekvens_panel/04B03.ttf" + - file: "04B03.ttf" id: b03 size: 8 diff --git a/warpsrvint/docker_esphome/templates/config/esphome_obegraensad.yaml b/warpsrvint/docker_esphome/templates/config/esphome_display02.yaml similarity index 62% rename from warpsrvint/docker_esphome/templates/config/esphome_obegraensad.yaml rename to warpsrvint/docker_esphome/templates/config/esphome_display02.yaml index 78fd62b0faae584807072a7d633fffc3d1457d00..a2cbf05896a54609e3fe50454233b27d921250f2 100644 --- a/warpsrvint/docker_esphome/templates/config/esphome_obegraensad.yaml +++ b/warpsrvint/docker_esphome/templates/config/esphome_display02.yaml @@ -1,14 +1,26 @@ -{% set devicename = "esphome_obegraensad" %} +{% set devicename = "esphome_display02" %} {% include "/includes/ansible.inc.yaml" %} + {% include "/includes/board.d1_mini.inc.yaml" %} + + platformio_options: + upload_speed: 115200 + lib_deps: + - me-no-dev/ESPAsyncTCP + - adafruit/Adafruit GFX Library # Required for FrekvensPanel. + - Adafruit BusIO # Required by GFX Library. + - Wire # Also required by GFX. + - SPI # Also required by GFX. + + {% include "/includes/common.inc.yaml" %} external_components: - source: type: local - path: . + path: /config/components/frekvens_panel/ light: - platform: monochromatic @@ -30,7 +42,7 @@ time: timezone: 'Europe/Paris' font: - - file: "frekvens_panel/04B03.ttf" + - file: "04B03.ttf" id: b03 size: 8 diff --git a/warpsrvint/docker_esphome/templates/config/frekvens_panel/.gitkeep b/warpsrvint/docker_esphome/templates/config/frekvens_panel/.gitkeep deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/warpsrvint/docker_esphome/templates/config/frekvens_panel/FrekvensPanel.cpp b/warpsrvint/docker_esphome/templates/config/frekvens_panel/FrekvensPanel.cpp deleted file mode 100644 index 29834821045ea9e5396a002ff6c9ca248a4e54cb..0000000000000000000000000000000000000000 --- a/warpsrvint/docker_esphome/templates/config/frekvens_panel/FrekvensPanel.cpp +++ /dev/null @@ -1,194 +0,0 @@ -// By /u/frumperino -// goodwires.org - -#include "FrekvensPanel.h" - -void init(int p_latch, int p_clock, int p_data, int p_enable); - -FrekvensPanel::FrekvensPanel(int p_latch, int p_clock, int p_data, int bitDepth, - int numPanels) : Adafruit_GFX(16, numPanels * 16) -{ - init(p_latch, p_clock, p_data, bitDepth, numPanels); -} - -FrekvensPanel::FrekvensPanel(int p_latch, int p_clock, int p_data) : -FrekvensPanel(p_latch, p_clock, p_data, 0, 1) { } - -void FrekvensPanel::init(int p_latch, int p_clock, int p_data, int bitDepth, int numPanels) -{ - _pLatch = p_latch; - _pClock = p_clock; - _pData = p_data; - pinMode(_pLatch, OUTPUT); - pinMode(_pClock, OUTPUT); - pinMode(_pData, OUTPUT); - _bitDepth = bitDepth; - _numPages = (1 << bitDepth); - _pageMask = _numPages - 1; - _numPanels = numPanels; - _pageStride = 16 * numPanels; - _numWords = _numPages * _pageStride; - _numPixels = 16 * 16 * numPanels; - _addressMask = _numPixels-1; - _width = 16; - _height = 16 * _numPanels; - buf = (unsigned short*) malloc(_numWords * sizeof(unsigned short)); -} - -void FrekvensPanel::clear() -{ - for (int i=0;i<_numWords;i++) - { - buf[i] = 0; - } -} - -void FrekvensPanel::writeDeepPixel(unsigned short x, unsigned short y, unsigned short value) -{ - if (x > 7) { y += 0x10; x &= 0x07; } - unsigned int address = (x + (y << 3)) & _addressMask; - unsigned short ba = address >> 4; - unsigned short br = address & 0x0F; - unsigned short ms = (1 << br); - unsigned short mc = 0xFFFF ^ ms; - unsigned short* wp = &buf[ba]; - unsigned short ofs = (x+y) & _pageMask; - for (unsigned int i=0;i<_numPages;i++) - { - ofs++; - ofs &= _pageMask; - char b = ((value >> ofs) & 0x01); - if (b) - { - *wp |= ms; - } - else - { - *wp &= mc; - } - wp+=_pageStride; - } -} - -void FrekvensPanel::scan() -{ - if (_numPages == 1) - { - // single bit plane - unsigned short* p = &buf[0]; - for (int i=0;i<_pageStride;i++) - { - unsigned short w = *p++; - for (int j=0;j<16;j++) - { - digitalWrite(_pData, w & 0x01); - w >>= 1; - digitalWrite(_pClock, HIGH); - delayMicroseconds(1); - digitalWrite(_pClock, LOW); - } - } - digitalWrite(_pLatch,HIGH); - delayMicroseconds(1); - digitalWrite(_pLatch,LOW); - } - else - { - // multiple bit planes - unsigned short* p = &buf[_pageStride * _activePage]; - for (int i=0;i<_pageStride;i++) - { - unsigned short w = *p++; - for (int j=0;j<16;j++) - { - digitalWrite(_pData, w & 0x01); - w >>= 1; - digitalWrite(_pClock, HIGH); - delayMicroseconds(1); - digitalWrite(_pClock, LOW); - } - } - digitalWrite(_pLatch,HIGH); - delayMicroseconds(1); - digitalWrite(_pLatch,LOW); - _activePage++; - _activePage %= _numPages; - } -} - -unsigned short FrekvensPanel::width() -{ - return this->_width; -} - -unsigned short FrekvensPanel::height() -{ - return this->_height; -} - -boolean FrekvensPanel::getPixel(int16_t x, int16_t y) -{ - if (x > 7) { y += 0x10; x &= 0x07; } - unsigned short address = (x + (y << 3)) & _addressMask; - unsigned short ba = address >> 4; - unsigned short br = address & 0x0F; - unsigned short* wp = &buf[ba]; - return ((*wp) >> br) & 0x01; -} - -void FrekvensPanel::drawPixel(int16_t x, int16_t y, uint16_t color) -{ - if ((x >= 0) && (y >= 0) && (x < _width) && ( y < _height)) - { - if (x > 7) { y += 0x10; x &= 0x07; } - unsigned short address = (x + (y << 3)) & _addressMask; - unsigned short ba = address >> 4; - unsigned short br = address & 0x0F; - unsigned short ms = (1 << br); - unsigned short* wp = &buf[ba]; - if (color & 0x01) - { - *wp |= ms; - } - else - { - *wp &= (0xFFFF ^ ms); - } - } -} - -void FrekvensPanel::drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color) -{ - for (int i=0;i<h;i++) - { - drawPixel(x,y+i,color); - } - -} - -void FrekvensPanel::drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color) -{ - for (int i=0;i<w;i++) - { - drawPixel(x+i,y,color); - } -} - -void FrekvensPanel::fillScreen(uint16_t color) -{ - for (int i=0;i<_numPages;i++) - { - unsigned short w = color & 0x01 ? 0xFFFF : 0x0000; - color >>= 1; - unsigned short* p = &buf[i * _pageStride]; - for (int j=0;j<_pageStride;j++) - { - *p++ = w; - } - } -} - - - - - diff --git a/warpsrvint/docker_esphome/templates/config/frekvens_panel/FrekvensPanel.h b/warpsrvint/docker_esphome/templates/config/frekvens_panel/FrekvensPanel.h deleted file mode 100644 index 78c6ef97712ed2b829c5015ee8a8a69ea28c1c62..0000000000000000000000000000000000000000 --- a/warpsrvint/docker_esphome/templates/config/frekvens_panel/FrekvensPanel.h +++ /dev/null @@ -1,54 +0,0 @@ -// by /u/frumperino -// goodwires.org - -#ifndef __FREKVENSPANEL_H -#define __FREKVENSPANEL_H - -#include <Arduino.h> -#include <Adafruit_GFX.h> - -class FrekvensPanel : public Adafruit_GFX -{ -private: - unsigned short _numPanels : 4; - unsigned short _numPages : 4; - unsigned short _activePage : 4; - unsigned short _bitDepth : 4; - unsigned short _pLatch; - unsigned short _pClock; - unsigned short _pData; - unsigned short* buf; - unsigned short _pageMask; - unsigned short _addressMask; - unsigned short _numWords; - unsigned short _pageStride; - unsigned short _numPixels; - unsigned short _width; - unsigned short _height; - -public: - FrekvensPanel(int p_latch, int p_clock, int p_data, int bitDepth, - int numPanels); - FrekvensPanel(int p_latch, int p_clock, int p_data); - - void init(int p_latch, int p_clock, int p_data, int bitDepth, int numPanels); - void clear(); - void scan(); - void writeDeepPixel(unsigned short x, unsigned short y, unsigned short value); - - boolean getPixel(int16_t x, int16_t y); - - unsigned short width(); - unsigned short height(); - - void drawPixel(int16_t x, int16_t y, uint16_t color) override; - void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color) override; - void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color) override; - void fillScreen(uint16_t color) override; - -private: - -}; - - -#endif //__FREKVENSPANEL_H