1 Commits

Author SHA1 Message Date
1fc90511ac poti plugin to control color wheel 2018-10-03 17:20:48 +02:00
4 changed files with 50 additions and 17 deletions

View File

@@ -1,13 +1,9 @@
image: python:2.7-stretch
variables:
S3_BUCKET_NAME: "wirelos"
PROJECT_NAME: "illucat"
stages:
- build
- test
- release
- build
- production
cache:
key: ${CI_COMMIT_REF_SLUG}
@@ -26,16 +22,11 @@ firmware:
- pio run -t buildfs
release:
stage: release
only:
- /^release-.*$/
image: python:latest
stage: production
script:
- pip install awscli
- mkdir -p ${PROJECT_NAME}/${CI_COMMIT_TAG}
- mv .pioenvs/build/firmware.bin ${PROJECT_NAME}/${CI_COMMIT_TAG}
- mv .pioenvs/build/spiffs.bin ${PROJECT_NAME}/${CI_COMMIT_TAG}
- aws s3 --endpoint-url=https://$DO_SPACE_ENDPOINT cp ./ s3://$S3_BUCKET_NAME/ --recursive --exclude "*" --include "*.bin"
- mkdir release
- mv .pioenvs/build/firmware.bin release
- mv .pioenvs/build/spiffs.bin release
artifacts:
paths:
- ${PROJECT_NAME}/${CI_COMMIT_TAG}
- release

View File

@@ -1,6 +1,6 @@
{
"pin": 4,
"length": 32,
"length": 300,
"brightness": 64,
"updateInterval": 50,
"defaultColor": 100

View File

@@ -17,6 +17,7 @@
#include <plugins/WebServerPlugin.cpp>
#include <plugins/WebConfigPlugin.cpp>
#include "PixelPlugin.h"
#include "PotPlugin.h"
using namespace std;
using namespace std::placeholders;
@@ -80,6 +81,7 @@ class IlluCat : public MeshSprocket {
addPlugin(new WebServerPlugin(webConfig, server));
addPlugin(new WebConfigPlugin(server));
addPlugin(new PixelPlugin(pixelConfig, pixels));
addPlugin(new PotPlugin());
defaultAnimation();
String softApPrt = "SoftAP IP: " + WiFi.softAPIP().toString();

40
src/PotPlugin.h Normal file
View File

@@ -0,0 +1,40 @@
#ifndef __POT_PLUGIN_H__
#define __POT_PLUGIN_H__
#include <FS.h>
#include "TaskSchedulerDeclarations.h"
#include "ArduinoOTA.h"
#include "Plugin.h"
#include "utils_print.h"
#include "config.h"
using namespace std;
using namespace std::placeholders;
class PotPlugin : public Plugin {
public:
Task inputTask;
int currentVal = 0;
PotPlugin(){
}
void activate(Scheduler* userScheduler, Network* network){
inputTask.set(TASK_MILLISECOND * 50, TASK_FOREVER, bind(&PotPlugin::checkInput, this));
userScheduler->addTask(inputTask);
inputTask.enable();
PRINT_MSG(Serial, SPROCKET_TYPE, "PotPlugin activated");
}
long toRange(long x, long in_min, long in_max, long out_min, long out_max){
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
void checkInput(){
//Serial.println(String("Pot:") + String(analogRead(A0)));
int newVal = toRange(analogRead(A0), 0, 1024, 0, 255);
if(newVal > 0 &&
(newVal >= currentVal + 5 || newVal <= currentVal - 5)){
publish("pixels/colorWheel",String(newVal));
currentVal = newVal;
}
}
};
#endif