Skip to content
Snippets Groups Projects
Commit 002bed50 authored by void's avatar void
Browse files

neue konfigurationen mit ikea frekvens modul

parent 2f8e51b9
No related branches found
No related tags found
No related merge requests found
......@@ -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:
......
{% 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
......
{% 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
......
// 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;
}
}
}
// 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment