diff --git a/.drone.yml b/.drone.yml index 29eae09..4451cff 100644 --- a/.drone.yml +++ b/.drone.yml @@ -7,17 +7,22 @@ steps: image: python:3.10 commands: - "pip install -U platformio" - #- "cp ampel-firmware/config.public.h ampel-firmware/config.h" - "platformio run --environment esp8266" - - cp .pio/build/esp8266/firmware.bin esp8266.bin + - "sed -i date/homie/config.json 's/WIFISSID/${iotssid}/'" + - "sed -i date/homie/config.json 's/WIFIPASS/${iotpwd}/'" + - "sed -i date/homie/config.json 's/HOSTNAME/${hostname}/g'" + - "platformio run --target upload --environment d1_mini" + - "platformio run --target uploadfs --environment d1_mini" - name: release image: plugins/gitea-release settings: base_url: https://gitea.ctdo.de - api_key: - from_secret: gitea_token files: ./*.bin upload_port: from_secret: hostname + iotssid: + from_secret: iotssid + iotpwd: + from_secret: iotpwd when: event: tag \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..89cc49c --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.pio +.vscode/.browse.c_cpp.db* +.vscode/c_cpp_properties.json +.vscode/launch.json +.vscode/ipch diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..080e70d --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,10 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ], + "unwantedRecommendations": [ + "ms-vscode.cpptools-extension-pack" + ] +} diff --git a/data/homie/config.json b/data/homie/config.json new file mode 100644 index 0000000..4871a89 --- /dev/null +++ b/data/homie/config.json @@ -0,0 +1,16 @@ +{ + "name": "HOSTNAME", + "device_id": "HOSTNAME", + "wifi": { + "ssid": "WIFISSID", + "password": "PASSWORD" + }, + "mqtt": { + "host": "mqtt.ctdo.de", + "port": 1883, + "auth": false + }, + "ota": { + "enabled": true + } +} \ No newline at end of file diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 0000000..ff1cea5 --- /dev/null +++ b/platformio.ini @@ -0,0 +1,30 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html +; +; If you're recreating this project in PlatformIO, please go to your project folder and execute the following command on your terminal: +; ln -s src/platformio.ini ./platformio.ini + +[env:d1_mini] +# platform = espressif8266@^2 +platform = espressif8266 +board = d1_mini +framework = arduino +upload_speed = 1500000 +monitor_speed = 115200 +lib_deps = + bblanchon/ArduinoJson + https://github.com/homieiot/homie-esp8266 + https://github.com/PaulStoffregen/Encoder.git + https://github.com/adafruit/DHT-sensor-library + https://github.com/adafruit/Adafruit_Sensor +upload_protocol = espota +upload_port = 172.23.23.12 # volumeknob3 +upload_flags = --host_port=54321 +#upload_port = 10.90.25.206 diff --git a/esp-volumeknob/esp-volumeknob.ino b/src/esp-volumeknob.cpp similarity index 86% rename from esp-volumeknob/esp-volumeknob.ino rename to src/esp-volumeknob.cpp index cb72a5a..bc60c6d 100644 --- a/esp-volumeknob/esp-volumeknob.ino +++ b/src/esp-volumeknob.cpp @@ -1,6 +1,3 @@ -//curl -X PUT http://192.168.123.1/config --header "Content-Type: application/json" -d '{"name":"volumeknob3", "device_id":"volumeknob3","wifi":{"ssid":"CTDO-IoT","password":"xxx"},"mqtt":{"host":"raum.ctdo.de","port":1883,"ssl":false,"auth":false},"ota":{"enabled":false}}' - - #include #include #include //Library download: https://github.com/PaulStoffregen/Encoder @@ -30,8 +27,9 @@ long lastPositionCheck=0; long oldPosition = 0; -HomieNode knobNode("volumeknob", "Volumeknob"); - +// HomieNode knobNode("volumeknob", "Volumeknob"); +HomieNode knobNode("volumeknob", "Volumeknob", "commands"); +// HomieNode homieNode("pixel", "pixel", "commands"); void loopHandler() { @@ -44,7 +42,7 @@ void loopHandler() { long newPosition = myEnc.read()/4; - if (lastPositionCheck+POSITIONUPDATE < millis() && newPosition != oldPosition) { + if ((unsigned long)(lastPositionCheck+POSITIONUPDATE) < millis() && newPosition != oldPosition) { long positiondiff=newPosition-oldPosition; oldPosition = newPosition; Homie.getLogger() << "posdiff= " << positiondiff << endl;