mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 11:49:51 +03:00
@@ -1,7 +1,10 @@
|
|||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
CUSTOM_BUILD_FLAGS_FILE="custom-build-flags/build_flags_mega2560.sh"
|
CUSTOM_BUILD_FLAGS_FILE="custom-build-flags/build_flags_mega2560-5500.sh"
|
||||||
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
||||||
export FLAGS="$FLAGS -DWiz5500"
|
export FLAGS="$FLAGS -DWiz5500"
|
||||||
|
export FLAGS="$FLAGS -DMODBUS_DIMMER_PARAM=SERIAL_8E1"
|
||||||
|
export FLAGS="$FLAGS -DAVR_DMXOUT_PIN=18"
|
||||||
|
|
||||||
#TODO: make one file for all envs
|
#TODO: make one file for all envs
|
||||||
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
|
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
|
||||||
source $CUSTOM_BUILD_FLAGS_FILE
|
source $CUSTOM_BUILD_FLAGS_FILE
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
CUSTOM_BUILD_FLAGS_FILE="custom-build-flags/build_flags_mega2560-slim.sh"
|
CUSTOM_BUILD_FLAGS_FILE="custom-build-flags/build_flags_mega2560-slim.sh"
|
||||||
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
||||||
|
export FLAGS="$FLAGS -DMODBUS_DIMMER_PARAM=SERIAL_8E1"
|
||||||
|
export FLAGS="$FLAGS -DAVR_DMXOUT_PIN=18"
|
||||||
#TODO: make one file for all envs
|
#TODO: make one file for all envs
|
||||||
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
|
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
|
||||||
source $CUSTOM_BUILD_FLAGS_FILE
|
source $CUSTOM_BUILD_FLAGS_FILE
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
CUSTOM_BUILD_FLAGS_FILE=custom-build-flags/build_flags_mega2560.sh
|
CUSTOM_BUILD_FLAGS_FILE=custom-build-flags/build_flags_mega2560.sh
|
||||||
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
export FLAGS="$FLAGS -DPIO_SRC_REV="$(git log --pretty=format:%h_%ad -1 --date=short)
|
||||||
|
export FLAGS="$FLAGS -DMODBUS_DIMMER_PARAM=SERIAL_8E1"
|
||||||
|
export FLAGS="$FLAGS -DAVR_DMXOUT_PIN=18"
|
||||||
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
|
if [ -f $CUSTOM_BUILD_FLAGS_FILE ]; then
|
||||||
source $CUSTOM_BUILD_FLAGS_FILE
|
source $CUSTOM_BUILD_FLAGS_FILE
|
||||||
fi
|
fi
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -449,47 +449,49 @@ void Input::contactPoll() {
|
|||||||
|
|
||||||
|
|
||||||
void Input::analogPoll() {
|
void Input::analogPoll() {
|
||||||
int16_t mappedInputVal;
|
int16_t inputVal;
|
||||||
|
int32_t mappedInputVal; // 10x inputVal
|
||||||
aJsonObject *inputMap = aJson.getObjectItem(inputObj, "map");
|
aJsonObject *inputMap = aJson.getObjectItem(inputObj, "map");
|
||||||
short Noize = ANALOG_NOIZE;
|
int16_t Noize = ANALOG_NOIZE;
|
||||||
short simple = 0;
|
short simple = 0;
|
||||||
|
|
||||||
/*
|
|
||||||
#if defined(ARDUINO_ARCH_STM32)
|
|
||||||
WiringPinMode inputPinMode;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(__SAM3X8E__)||defined(ARDUINO_ARCH_AVR)||defined(ARDUINO_ARCH_ESP8266)||defined(ARDUINO_ARCH_ESP32)
|
|
||||||
#endif */
|
|
||||||
uint32_t inputPinMode;
|
uint32_t inputPinMode;
|
||||||
|
int max=1024*10;
|
||||||
|
int min=0;
|
||||||
|
|
||||||
|
|
||||||
if (inType & IN_ACTIVE_HIGH) {
|
if (inType & IN_ACTIVE_HIGH) {
|
||||||
inputPinMode = INPUT;
|
inputPinMode = INPUT;
|
||||||
} else {
|
} else {
|
||||||
inputPinMode = INPUT_PULLUP;
|
inputPinMode = INPUT_PULLUP;
|
||||||
}
|
}
|
||||||
pinMode(pin, inputPinMode);
|
pinMode(pin, inputPinMode);
|
||||||
mappedInputVal = analogRead(pin);
|
inputVal = analogRead(pin);
|
||||||
// Mapping
|
// Mapping
|
||||||
if (inputMap && inputMap->type == aJson_Array)
|
if (inputMap && inputMap->type == aJson_Array)
|
||||||
{
|
{
|
||||||
int max=1024;
|
|
||||||
if (aJson.getArraySize(inputMap)>=4)
|
if (aJson.getArraySize(inputMap)>=4)
|
||||||
mappedInputVal = map (mappedInputVal,
|
mappedInputVal = map (inputVal,
|
||||||
aJson.getArrayItem(inputMap, 0)->valueint,
|
aJson.getArrayItem(inputMap, 0)->valueint,
|
||||||
aJson.getArrayItem(inputMap, 1)->valueint,
|
aJson.getArrayItem(inputMap, 1)->valueint,
|
||||||
aJson.getArrayItem(inputMap, 2)->valueint,
|
min=aJson.getArrayItem(inputMap, 2)->valueint*10,
|
||||||
max=aJson.getArrayItem(inputMap, 3)->valueint);
|
max=aJson.getArrayItem(inputMap, 3)->valueint*10);
|
||||||
|
else mappedInputVal = inputVal*10;
|
||||||
|
|
||||||
if (aJson.getArraySize(inputMap)==5) Noize = aJson.getArrayItem(inputMap, 4)->valueint;
|
if (aJson.getArraySize(inputMap)==5) Noize = aJson.getArrayItem(inputMap, 4)->valueint;
|
||||||
|
|
||||||
if (mappedInputVal>max) mappedInputVal = max;
|
if (mappedInputVal>max) mappedInputVal = max;
|
||||||
|
if (mappedInputVal<min) mappedInputVal = min;
|
||||||
|
|
||||||
if (aJson.getArraySize(inputMap)==2)
|
if (aJson.getArraySize(inputMap)==2)
|
||||||
{
|
{
|
||||||
simple = 1;
|
simple = 1;
|
||||||
if (mappedInputVal < aJson.getArrayItem(inputMap, 0)->valueint) mappedInputVal = 0;
|
if (inputVal < aJson.getArrayItem(inputMap, 0)->valueint) mappedInputVal = 0;
|
||||||
else if (mappedInputVal > aJson.getArrayItem(inputMap, 1)->valueint) mappedInputVal = 1;
|
else if (inputVal > aJson.getArrayItem(inputMap, 1)->valueint) mappedInputVal = 1;
|
||||||
else return;
|
else return;
|
||||||
}
|
}
|
||||||
}
|
} else mappedInputVal = inputVal*10; //No mapping arguments
|
||||||
|
|
||||||
if (simple) {
|
if (simple) {
|
||||||
if (mappedInputVal != store->currentValue)
|
if (mappedInputVal != store->currentValue)
|
||||||
{
|
{
|
||||||
@@ -497,17 +499,20 @@ void Input::analogPoll() {
|
|||||||
store->currentValue = mappedInputVal;
|
store->currentValue = mappedInputVal;
|
||||||
}}
|
}}
|
||||||
else
|
else
|
||||||
if (abs(mappedInputVal - store->currentValue)>Noize) // value changed >ANALOG_NOIZE
|
{
|
||||||
|
//if (abs(mappedInputVal - store->currentValue)>Noize || mappedInputVal == min || mappedInputVal ==max) // value changed >ANALOG_NOIZE
|
||||||
|
if (abs(inputVal - store->currentValue)>Noize ) // value changed >ANALOG_NOIZE
|
||||||
store->bounce = 0;
|
store->bounce = 0;
|
||||||
else // no change
|
else // no change
|
||||||
if (store->bounce<ANALOG_STATE_ATTEMPTS) store->bounce ++;
|
if (store->bounce<ANALOG_STATE_ATTEMPTS) store->bounce ++;
|
||||||
|
|
||||||
if (store->bounce<ANALOG_STATE_ATTEMPTS-1 && (mappedInputVal != store->currentValue)) //confirmed change
|
if ((store->bounce<ANALOG_STATE_ATTEMPTS-1 || mappedInputVal == min || mappedInputVal ==max )&& (inputVal != store->currentValue))//confirmed change
|
||||||
{
|
{
|
||||||
onAnalogChanged(mappedInputVal);
|
onAnalogChanged(mappedInputVal/10.);
|
||||||
store->currentValue = mappedInputVal;
|
// store->currentValue = mappedInputVal;
|
||||||
|
store->currentValue = inputVal;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -563,7 +568,7 @@ if (!strchr(addrstr,'/')) setTopic(addrstr,sizeof(addrstr),T_OUT,emit->valuestri
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Input::onAnalogChanged(int newValue) {
|
void Input::onAnalogChanged(float newValue) {
|
||||||
debugSerial << F("IN:") << (pin) << F("=") << newValue << endl;
|
debugSerial << F("IN:") << (pin) << F("=") << newValue << endl;
|
||||||
aJsonObject *item = aJson.getObjectItem(inputObj, "item");
|
aJsonObject *item = aJson.getObjectItem(inputObj, "item");
|
||||||
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
aJsonObject *emit = aJson.getObjectItem(inputObj, "emit");
|
||||||
@@ -581,15 +586,17 @@ void Input::onAnalogChanged(int newValue) {
|
|||||||
strncpy(addrstr,emit->valuestring,sizeof(addrstr));
|
strncpy(addrstr,emit->valuestring,sizeof(addrstr));
|
||||||
if (!strchr(addrstr,'/')) setTopic(addrstr,sizeof(addrstr),T_OUT,emit->valuestring);
|
if (!strchr(addrstr,'/')) setTopic(addrstr,sizeof(addrstr),T_OUT,emit->valuestring);
|
||||||
char strVal[16];
|
char strVal[16];
|
||||||
itoa(newValue,strVal,10);
|
//itoa(newValue,strVal,10);
|
||||||
|
printFloatValueToStr(newValue, strVal);
|
||||||
if (mqttClient.connected() && !ethernetIdleCount)
|
if (mqttClient.connected() && !ethernetIdleCount)
|
||||||
mqttClient.publish(addrstr, strVal, true);
|
mqttClient.publish(addrstr, strVal, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item) {
|
if (item) {
|
||||||
|
int intNewValue = round(newValue);
|
||||||
Item it(item->valuestring);
|
Item it(item->valuestring);
|
||||||
if (it.isValid()) {
|
if (it.isValid()) {
|
||||||
it.Ctrl(0, 1, &newValue, true);
|
it.Ctrl(0, 1, &intNewValue, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ public:
|
|||||||
boolean isValid();
|
boolean isValid();
|
||||||
|
|
||||||
void onContactChanged(int newValue);
|
void onContactChanged(int newValue);
|
||||||
void onAnalogChanged(int newValue);
|
void onAnalogChanged(float newValue);
|
||||||
|
|
||||||
int poll(short cause);
|
int poll(short cause);
|
||||||
void setup();
|
void setup();
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ int in_hdc1080::Poll()
|
|||||||
int reg;
|
int reg;
|
||||||
if (!HDC1080ready) {debugSerial<<F("HDC1080 not initialized")<<endl; return 0;}
|
if (!HDC1080ready) {debugSerial<<F("HDC1080 not initialized")<<endl; return 0;}
|
||||||
Serial.print("HDC Status=");
|
Serial.print("HDC Status=");
|
||||||
Serial.print(reg=hdc1080.readRegister().rawData,HEX);
|
Serial.println(reg=hdc1080.readRegister().rawData,HEX);
|
||||||
if (reg!=0xff)
|
if (reg!=0xff)
|
||||||
{
|
{
|
||||||
Serial.print(" T=");
|
Serial.print(" T=");
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ env_default =
|
|||||||
; mega2560-5100
|
; mega2560-5100
|
||||||
|
|
||||||
; Arduino Mega + Ethernet shield Wiznet 5500
|
; Arduino Mega + Ethernet shield Wiznet 5500
|
||||||
; mega2560-5500
|
mega2560-5500
|
||||||
|
|
||||||
; LightHub controller HW revision 2.1 and above (Wiznet 5500 CS on pin 53)
|
; LightHub controller HW revision 2.1 and above (Wiznet 5500 CS on pin 53)
|
||||||
; lighthub21
|
; lighthub21
|
||||||
@@ -288,6 +288,7 @@ lib_ignore =
|
|||||||
DmxDue
|
DmxDue
|
||||||
DueFlashStorage
|
DueFlashStorage
|
||||||
WifiManager
|
WifiManager
|
||||||
|
Ethernet
|
||||||
Ethernet3
|
Ethernet3
|
||||||
HTTPClient
|
HTTPClient
|
||||||
NRFFlashStorage
|
NRFFlashStorage
|
||||||
@@ -304,7 +305,7 @@ lib_deps =
|
|||||||
https://github.com/anklimov/CmdArduino
|
https://github.com/anklimov/CmdArduino
|
||||||
https://github.com/anklimov/ModbusMaster
|
https://github.com/anklimov/ModbusMaster
|
||||||
https://github.com/anklimov/DMXSerial
|
https://github.com/anklimov/DMXSerial
|
||||||
https://github.com/anklimov/Ethernet
|
https://github.com/anklimov/Ethernet2
|
||||||
https://github.com/knolleary/pubsubclient.git
|
https://github.com/knolleary/pubsubclient.git
|
||||||
https://github.com/anklimov/Artnet.git
|
https://github.com/anklimov/Artnet.git
|
||||||
FastLED
|
FastLED
|
||||||
|
|||||||
Reference in New Issue
Block a user