add working homie with basic preset function
This commit is contained in:
parent
c640931bc3
commit
fb5862e1f3
|
@ -8,9 +8,37 @@
|
|||
; Please visit documentation for the other options and examples
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
;Testet at platform = espressif32 @ 6.4.0
|
||||
;|-- Bounce2 @ 2.71.0
|
||||
;|-- Homie @ 3.0.1+sha.ba452ea
|
||||
;|-- AsyncTCP @ 1.1.1
|
||||
;|-- ESP Async WebServer @ 1.2.3
|
||||
|
||||
; - framework-arduinoespressif32 @ 3.20011.230801 (2.0.11)
|
||||
; - tool-esptoolpy @ 1.40501.0 (4.5.1)
|
||||
; - tool-mkfatfs @ 2.0.1
|
||||
; - tool-mklittlefs @ 1.203.210628 (2.3)
|
||||
; - tool-mkspiffs @ 2.230.0 (2.30)
|
||||
; - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
|
||||
|
||||
|
||||
|
||||
[platformio]
|
||||
data_dir=data
|
||||
#Upload Data with pio run -t uploadfs
|
||||
|
||||
[env:esp32doit-devkit-v1]
|
||||
platform = espressif32
|
||||
board = esp32doit-devkit-v1
|
||||
framework = arduino
|
||||
|
||||
monitor_speed = 115200
|
||||
monitor_speed = 115200
|
||||
|
||||
build_flags = -D PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
|
||||
|
||||
lib_deps =
|
||||
Bounce2
|
||||
https://github.com/homieiot/homie-esp8266.git
|
||||
me-no-dev/AsyncTCP@1.1.1
|
||||
me-no-dev/ESP Async WebServer@1.2.3
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ void Image::setBuffer_solid(bool set)
|
|||
}
|
||||
|
||||
|
||||
void Image::setBuffer_Image1()
|
||||
void Image::setBuffer_Image1() //Bumblebee
|
||||
{
|
||||
backBuffer[0]=0b0000000000000111;
|
||||
backBuffer[1]=0b0000000000000000;
|
||||
|
@ -129,7 +129,7 @@ backBuffer[74]=0b0000000000000000;
|
|||
flag_updating=true; //make update run
|
||||
}
|
||||
|
||||
void Image::setBuffer_Image2()
|
||||
void Image::setBuffer_Image2() //CTDO
|
||||
{
|
||||
backBuffer[0]=0b0000000000000000;
|
||||
backBuffer[1]=0b0000000000000000;
|
||||
|
@ -212,7 +212,7 @@ flag_updating=true; //make update run
|
|||
}
|
||||
|
||||
|
||||
void Image::setBuffer_Image3()
|
||||
void Image::setBuffer_Image3() //23:24
|
||||
{
|
||||
backBuffer[0]=0b1111111111111111;
|
||||
backBuffer[1]=0b1111111111111111;
|
||||
|
@ -298,7 +298,7 @@ backBuffer[74]=0b1111111111111111;
|
|||
|
||||
|
||||
|
||||
void Image::setBuffer_Image4()
|
||||
void Image::setBuffer_Image4() //Linux
|
||||
{
|
||||
|
||||
backBuffer[0]=0b0000000000000000;
|
||||
|
@ -383,7 +383,7 @@ backBuffer[74]=0b0000000000000000;
|
|||
|
||||
|
||||
|
||||
void Image::setBuffer_Image5()
|
||||
void Image::setBuffer_Image5() //Datamatrix ctdo.de
|
||||
{
|
||||
|
||||
backBuffer[0]=0b1111111111111111;
|
||||
|
@ -468,7 +468,7 @@ backBuffer[74]=0b1111111111111111;
|
|||
|
||||
|
||||
|
||||
void Image::setBuffer_Image6()
|
||||
void Image::setBuffer_Image6() //13:37
|
||||
{
|
||||
backBuffer[0]=0b1111111111111111;
|
||||
backBuffer[1]=0b1111111111111111;
|
||||
|
@ -551,7 +551,7 @@ backBuffer[74]=0b1111111111111111;
|
|||
}
|
||||
|
||||
|
||||
void Image::setBuffer_Image7()
|
||||
void Image::setBuffer_Image7() //13:59
|
||||
{
|
||||
backBuffer[0]=0b1111111111111111;
|
||||
backBuffer[1]=0b1111111111111111;
|
||||
|
@ -634,7 +634,7 @@ backBuffer[74]=0b1111111111111111;
|
|||
}
|
||||
|
||||
|
||||
void Image::setBuffer_Image8()
|
||||
void Image::setBuffer_Image8() //14:00
|
||||
{
|
||||
backBuffer[0]=0b1111111111111111;
|
||||
backBuffer[1]=0b1111111111111111;
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
#include <Arduino.h>
|
||||
|
||||
#include <Homie.h>
|
||||
|
||||
HomieNode flipdotNode("display", "Display", "display");
|
||||
HomieNode resultNode("result", "Result", "result");
|
||||
|
||||
#include "flipdot.h"
|
||||
#include "image.h"
|
||||
|
@ -14,6 +17,14 @@ unsigned long loopmillis=0;
|
|||
unsigned long last_update=0;
|
||||
|
||||
|
||||
bool presetHandler(const HomieRange& range, const String& value);
|
||||
|
||||
/*bool globalInputHandler(const HomieNode& node, const HomieRange& range, const String& property, const String& value) {
|
||||
Homie.getLogger() << "Global input handler. Received on node " << node.getId() << ": " << property << " = " << value << endl;
|
||||
return false;
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
void setup() {
|
||||
flip.init();
|
||||
|
@ -21,25 +32,39 @@ void setup() {
|
|||
Serial.begin(115200);
|
||||
flip.setBuffer_solid(0);
|
||||
|
||||
//Setup Homie
|
||||
Homie_setFirmware("flipdot", "0.1.0");
|
||||
flipdotNode.advertise("preset").settable(presetHandler);
|
||||
//Homie.setGlobalInputHandler(globalInputHandler);
|
||||
Homie.setup();
|
||||
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
Homie.loop();
|
||||
loopmillis = millis();
|
||||
|
||||
static unsigned long last_change=0;
|
||||
static bool color=0;
|
||||
//static bool color=0;
|
||||
|
||||
if (loopmillis-last_change >= 1000*10)
|
||||
{
|
||||
flipdotNode.setProperty("preset").send("asdf");
|
||||
last_change=loopmillis;
|
||||
}
|
||||
|
||||
/*
|
||||
static uint8_t image=0;
|
||||
if (loopmillis-last_change >= 1000*10)
|
||||
{
|
||||
/*
|
||||
Serial.print("Change to Solid color ="); Serial.println(color);
|
||||
|
||||
flip.setBuffer_solid(color);
|
||||
color=1-color;
|
||||
//Serial.print("Change to Solid color ="); Serial.println(color);
|
||||
|
||||
//flip.setBuffer_solid(color);
|
||||
//color=1-color;
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
switch (image){
|
||||
|
@ -78,25 +103,26 @@ void loop() {
|
|||
|
||||
|
||||
|
||||
/*
|
||||
uint8_t _randomvalue=random(128);
|
||||
Serial.print("set buffer random. ");
|
||||
Serial.println(_randomvalue);
|
||||
flip.setBuffer_random(_randomvalue);
|
||||
*/
|
||||
/*
|
||||
for (uint8_t _x=0;_x<COLUMNS;_x++) {
|
||||
uint8_t _y=(sin( loopmillis/100000.0 + _x/5.0 )/2+0.5)*15+0.5;
|
||||
uint16_t _row=pow(2, _y);
|
||||
flip.setBufferColumn(_x,_row);
|
||||
}
|
||||
*/
|
||||
|
||||
//uint8_t _randomvalue=random(128);
|
||||
//Serial.print("set buffer random. ");
|
||||
//Serial.println(_randomvalue);
|
||||
//flip.setBuffer_random(_randomvalue);
|
||||
|
||||
|
||||
//for (uint8_t _x=0;_x<COLUMNS;_x++) {
|
||||
// uint8_t _y=(sin( loopmillis/100000.0 + _x/5.0 )/2+0.5)*15+0.5;
|
||||
// uint16_t _row=pow(2, _y);
|
||||
// flip.setBufferColumn(_x,_row);
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
last_change=loopmillis;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
UpdateReturn result=flip.updateByColumn(false,true,true); //0=not finished, 1=finished
|
||||
|
@ -106,9 +132,53 @@ void loop() {
|
|||
unsigned long duration=millis()-last_change;
|
||||
Serial.print("Last Change took "); Serial.print(duration); Serial.println(" ms");
|
||||
Serial.print("Update max took "); Serial.print(flip.updateDuration); Serial.println(" ms");
|
||||
resultNode.setProperty("duration").send((String)duration);
|
||||
resultNode.setProperty("updateduration").send((String)flip.updateDuration);
|
||||
flip.updateDuration=0; //reset
|
||||
|
||||
flip.shuffleOrder(10);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool presetHandler(const HomieRange& range, const String& value) {
|
||||
Serial.print("Received: "); Serial.println(value);
|
||||
if (value == "white"){
|
||||
flip.setBuffer_solid(1);
|
||||
Homie.getLogger() << "Preset is White" << endl;
|
||||
}else if(value == "black"){
|
||||
flip.setBuffer_solid(0);
|
||||
Homie.getLogger() << "Preset is Black" << endl;
|
||||
}else if(value == "image1"){
|
||||
flip.setBuffer_Image1();
|
||||
Homie.getLogger() << "Preset is Image1" << endl;
|
||||
}else if(value == "image2"){
|
||||
flip.setBuffer_Image2();
|
||||
Homie.getLogger() << "Preset is Image2" << endl;
|
||||
}else if(value == "image3"){
|
||||
flip.setBuffer_Image3();
|
||||
Homie.getLogger() << "Preset is Image3" << endl;
|
||||
}else if(value == "image4"){
|
||||
flip.setBuffer_Image4();
|
||||
Homie.getLogger() << "Preset is Image4" << endl;
|
||||
}else if(value == "image5"){
|
||||
flip.setBuffer_Image5();
|
||||
Homie.getLogger() << "Preset is Image5" << endl;
|
||||
}else if(value == "image6"){
|
||||
flip.setBuffer_Image6();
|
||||
Homie.getLogger() << "Preset is Image6" << endl;
|
||||
}else if(value == "image7"){
|
||||
flip.setBuffer_Image7();
|
||||
Homie.getLogger() << "Preset is Image7" << endl;
|
||||
}else if(value == "image8"){
|
||||
flip.setBuffer_Image8();
|
||||
Homie.getLogger() << "Preset is Image8" << endl;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
flipdotNode.setProperty("preset").send(value);
|
||||
|
||||
return true;
|
||||
}
|
Loading…
Reference in New Issue