mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
On top updates
This commit is contained in:
parent
49b44089e7
commit
6f3f721c26
@ -161,7 +161,7 @@
|
||||
"conf_leds_note_layout_overwrite": "Note: Overwrite creates a default layout for {{plural:$1| one LED| all $1 LEDs}} given by the hardware LED count",
|
||||
"conf_leds_optgroup_RPiGPIO": "RPi GPIO",
|
||||
"conf_leds_optgroup_RPiPWM": "RPi PWM",
|
||||
"conf_leds_optgroup_RPiSPI": "RPi SPI",
|
||||
"conf_leds_optgroup_SPI": "SPI",
|
||||
"conf_leds_optgroup_debug": "Debug",
|
||||
"conf_leds_optgroup_network": "Network",
|
||||
"conf_leds_optgroup_other": "Other",
|
||||
|
@ -18,7 +18,7 @@ var bottomRight2bottomLeft = null;
|
||||
var bottomLeft2topLeft = null;
|
||||
var toggleKeystoneCorrectionArea = false;
|
||||
|
||||
var devRPiSPI = ['apa102', 'apa104', 'ws2801', 'lpd6803', 'lpd8806', 'p9813', 'sk6812spi', 'sk6822spi', 'sk9822', 'ws2812spi'];
|
||||
var devSPI = ['apa102', 'apa104', 'ws2801', 'lpd6803', 'lpd8806', 'p9813', 'sk6812spi', 'sk6822spi', 'sk9822', 'ws2812spi'];
|
||||
var devFTDI = ['apa102_ftdi', 'sk6812_ftdi', 'ws2812_ftdi'];
|
||||
var devRPiPWM = ['ws281x'];
|
||||
var devRPiGPIO = ['piblaster'];
|
||||
@ -1671,7 +1671,7 @@ $(document).ready(function () {
|
||||
optArr[6] = [];
|
||||
|
||||
for (var idx = 0; idx < ledDevices.length; idx++) {
|
||||
if ($.inArray(ledDevices[idx], devRPiSPI) != -1)
|
||||
if ($.inArray(ledDevices[idx], devSPI) != -1)
|
||||
optArr[0].push(ledDevices[idx]);
|
||||
else if ($.inArray(ledDevices[idx], devRPiPWM) != -1)
|
||||
optArr[1].push(ledDevices[idx]);
|
||||
@ -1958,8 +1958,8 @@ var updateOutputSelectList = function (ledType, discoveryInfo) {
|
||||
ledTypeGroup = "devNET";
|
||||
} else if ($.inArray(ledType, devSerial) != -1) {
|
||||
ledTypeGroup = "devSerial";
|
||||
} else if ($.inArray(ledType, devRPiSPI) != -1) {
|
||||
ledTypeGroup = "devRPiSPI";
|
||||
} else if ($.inArray(ledType, devSPI) != -1) {
|
||||
ledTypeGroup = "devSPI";
|
||||
} else if ($.inArray(ledType, devFTDI) != -1) {
|
||||
ledTypeGroup = "devFTDI";
|
||||
} else if ($.inArray(ledType, devRPiGPIO) != -1) {
|
||||
@ -2140,7 +2140,7 @@ var updateOutputSelectList = function (ledType, discoveryInfo) {
|
||||
}
|
||||
break;
|
||||
|
||||
case "devRPiSPI":
|
||||
case "devSPI":
|
||||
case "devRPiGPIO":
|
||||
key = "output";
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
LedDeviceSk6812_ftdi::LedDeviceSk6812_ftdi(const QJsonObject &deviceConfig)
|
||||
: ProviderFtdi(deviceConfig),
|
||||
_whiteAlgorithm(RGBW::WhiteAlgorithm::INVALID),
|
||||
SPI_BYTES_PER_COLOUR(4),
|
||||
bitpair_to_byte{
|
||||
0b10001000,
|
||||
@ -25,21 +26,30 @@ bool LedDeviceSk6812_ftdi::init(const QJsonObject &deviceConfig)
|
||||
if (ProviderFtdi::init(deviceConfig))
|
||||
{
|
||||
_brightnessControlMaxLevel = deviceConfig["brightnessControlMaxLevel"].toInt(255);
|
||||
Info(_log, "[%s] Setting maximum brightness to [%d]", QSTRING_CSTR(_activeDeviceType), _brightnessControlMaxLevel);
|
||||
Info(_log, "[%s] Setting maximum brightness to [%d]", QSTRING_CSTR(_activeDeviceType), _brightnessControlMaxLevel);
|
||||
|
||||
|
||||
QString whiteAlgorithm = deviceConfig["whiteAlgorithm"].toString("white_off");
|
||||
QString whiteAlgorithm = deviceConfig["whiteAlgorithm"].toString("white_off");
|
||||
|
||||
_whiteAlgorithm = RGBW::stringToWhiteAlgorithm(whiteAlgorithm);
|
||||
if (_whiteAlgorithm == RGBW::WhiteAlgorithm::INVALID)
|
||||
{
|
||||
QString errortext = QString ("unknown whiteAlgorithm: %1").arg(whiteAlgorithm);
|
||||
this->setInError(errortext);
|
||||
isInitOK = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Debug(_log, "whiteAlgorithm : %s", QSTRING_CSTR(whiteAlgorithm));
|
||||
Debug(_log, "whiteAlgorithm : %s", QSTRING_CSTR(whiteAlgorithm));
|
||||
|
||||
WarningIf((_baudRate_Hz < 2050000 || _baudRate_Hz > 3750000), _log, "Baud rate %d outside recommended range (2050000 -> 3750000)", _baudRate_Hz);
|
||||
WarningIf((_baudRate_Hz < 2050000 || _baudRate_Hz > 3750000), _log, "Baud rate %d outside recommended range (2050000 -> 3750000)", _baudRate_Hz);
|
||||
|
||||
const int SPI_FRAME_END_LATCH_BYTES = 3;
|
||||
_ledBuffer.resize(_ledRGBWCount * SPI_BYTES_PER_COLOUR + SPI_FRAME_END_LATCH_BYTES, 0x00);
|
||||
const int SPI_FRAME_END_LATCH_BYTES = 3;
|
||||
_ledBuffer.resize(_ledRGBWCount * SPI_BYTES_PER_COLOUR + SPI_FRAME_END_LATCH_BYTES, 0x00);
|
||||
|
||||
isInitOK = true;
|
||||
isInitOK = true;
|
||||
}
|
||||
}
|
||||
return isInitOK;
|
||||
}
|
||||
|
@ -13,18 +13,18 @@
|
||||
|
||||
namespace Pin
|
||||
{
|
||||
// enumerate the AD bus for convenience.
|
||||
enum bus_t
|
||||
{
|
||||
SK = 0x01, // ADBUS0, SPI data clock
|
||||
DO = 0x02, // ADBUS1, SPI data out
|
||||
CS = 0x08, // ADBUS3, SPI chip select, active low
|
||||
};
|
||||
// enumerate the AD bus for convenience.
|
||||
enum bus_t
|
||||
{
|
||||
SK = 0x01, // ADBUS0, SPI data clock
|
||||
DO = 0x02, // ADBUS1, SPI data out
|
||||
CS = 0x08, // ADBUS3, SPI chip select, active low
|
||||
};
|
||||
}
|
||||
|
||||
const unsigned char pinInitialState = Pin::CS;
|
||||
const uint8_t pinInitialState = Pin::CS;
|
||||
// Use these pins as outputs
|
||||
const unsigned char pinDirection = Pin::SK | Pin::DO | Pin::CS;
|
||||
const uint8_t pinDirection = Pin::SK | Pin::DO | Pin::CS;
|
||||
|
||||
const QString ProviderFtdi::AUTO_SETTING = QString("auto");
|
||||
|
||||
@ -56,43 +56,49 @@ int ProviderFtdi::open()
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
_ftdic = ftdi_new();
|
||||
_ftdic = ftdi_new();
|
||||
|
||||
Debug(_log, "Opening FTDI device=%s", QSTRING_CSTR(_deviceName));
|
||||
if (ftdi_init(_ftdic) < 0)
|
||||
{
|
||||
_ftdic = nullptr;
|
||||
setInError("Could not initialize the ftdi library");
|
||||
return -1;
|
||||
}
|
||||
|
||||
FTDI_CHECK_RESULT((rc = ftdi_usb_open_string(_ftdic, QSTRING_CSTR(_deviceName))) < 0);
|
||||
/* doing this disable resets things if they were in a bad state */
|
||||
FTDI_CHECK_RESULT((rc = ftdi_disable_bitbang(_ftdic)) < 0);
|
||||
FTDI_CHECK_RESULT((rc = ftdi_setflowctrl(_ftdic, SIO_DISABLE_FLOW_CTRL)) < 0);
|
||||
FTDI_CHECK_RESULT((rc = ftdi_set_bitmode(_ftdic, 0x00, BITMODE_RESET)) < 0);
|
||||
FTDI_CHECK_RESULT((rc = ftdi_set_bitmode(_ftdic, 0xff, BITMODE_MPSSE)) < 0);
|
||||
Debug(_log, "Opening FTDI device=%s", QSTRING_CSTR(_deviceName));
|
||||
|
||||
FTDI_CHECK_RESULT((rc = ftdi_usb_open_string(_ftdic, QSTRING_CSTR(_deviceName))) < 0);
|
||||
/* doing this disable resets things if they were in a bad state */
|
||||
FTDI_CHECK_RESULT((rc = ftdi_disable_bitbang(_ftdic)) < 0);
|
||||
FTDI_CHECK_RESULT((rc = ftdi_setflowctrl(_ftdic, SIO_DISABLE_FLOW_CTRL)) < 0);
|
||||
FTDI_CHECK_RESULT((rc = ftdi_set_bitmode(_ftdic, 0x00, BITMODE_RESET)) < 0);
|
||||
FTDI_CHECK_RESULT((rc = ftdi_set_bitmode(_ftdic, 0xff, BITMODE_MPSSE)) < 0);
|
||||
|
||||
double reference_clock = 60e6;
|
||||
int divisor = (reference_clock / 2 / _baudRate_Hz) - 1;
|
||||
std::vector<uint8_t> buf = {
|
||||
DIS_DIV_5,
|
||||
TCK_DIVISOR,
|
||||
static_cast<unsigned char>(divisor),
|
||||
static_cast<unsigned char>(divisor >> 8),
|
||||
SET_BITS_LOW, // opcode: set low bits (ADBUS[0-7]
|
||||
pinInitialState, // argument: inital pin state
|
||||
pinDirection
|
||||
};
|
||||
double reference_clock = 60e6;
|
||||
int divisor = (reference_clock / 2 / _baudRate_Hz) - 1;
|
||||
std::vector<uint8_t> buf = {
|
||||
DIS_DIV_5,
|
||||
TCK_DIVISOR,
|
||||
static_cast<unsigned char>(divisor),
|
||||
static_cast<unsigned char>(divisor >> 8),
|
||||
SET_BITS_LOW, // opcode: set low bits (ADBUS[0-7]
|
||||
pinInitialState, // argument: inital pin state
|
||||
pinDirection
|
||||
};
|
||||
|
||||
FTDI_CHECK_RESULT((rc = ftdi_write_data(_ftdic, buf.data(), buf.size())) != buf.size());
|
||||
FTDI_CHECK_RESULT((rc = ftdi_write_data(_ftdic, buf.data(), buf.size())) != buf.size());
|
||||
|
||||
_isDeviceReady = true;
|
||||
return rc;
|
||||
_isDeviceReady = true;
|
||||
return rc;
|
||||
}
|
||||
|
||||
int ProviderFtdi::close()
|
||||
{
|
||||
if (_ftdic != nullptr) {
|
||||
Debug(_log, "Closing FTDI device");
|
||||
// Delay to give time to push color black from writeBlack() into the led,
|
||||
// otherwise frame transmission will be terminated half way through
|
||||
wait(30);
|
||||
// Delay to give time to push color black from writeBlack() into the led,
|
||||
// otherwise frame transmission will be terminated half way through
|
||||
wait(30);
|
||||
ftdi_set_bitmode(_ftdic, 0x00, BITMODE_RESET);
|
||||
ftdi_usb_close(_ftdic);
|
||||
ftdi_free(_ftdic);
|
||||
@ -110,25 +116,24 @@ void ProviderFtdi::setInError(const QString &errorMsg, bool isRecoverable)
|
||||
|
||||
int ProviderFtdi::writeBytes(const qint64 size, const uint8_t *data)
|
||||
{
|
||||
int rc;
|
||||
int count_arg = size - 1;
|
||||
int rc;
|
||||
int count_arg = size - 1;
|
||||
std::vector<uint8_t> buf = {
|
||||
SET_BITS_LOW,
|
||||
pinInitialState & ~Pin::CS,
|
||||
pinDirection,
|
||||
MPSSE_DO_WRITE | MPSSE_WRITE_NEG,
|
||||
static_cast<unsigned char>(count_arg),
|
||||
static_cast<unsigned char>(count_arg >> 8),
|
||||
// LED's data will be inserted here
|
||||
SET_BITS_LOW,
|
||||
pinInitialState | Pin::CS,
|
||||
pinDirection
|
||||
};
|
||||
// insert before last SET_BITS_LOW command
|
||||
// SET_BITS_LOW takes 2 arguments, so we're inserting data in -3 position from the end
|
||||
buf.insert(buf.end() - 3, &data[0], &data[size]);
|
||||
SET_BITS_LOW,
|
||||
pinInitialState & ~Pin::CS,
|
||||
pinDirection,
|
||||
MPSSE_DO_WRITE | MPSSE_WRITE_NEG,
|
||||
static_cast<unsigned char>(count_arg),
|
||||
static_cast<unsigned char>(count_arg >> 8),
|
||||
SET_BITS_LOW,
|
||||
pinInitialState | Pin::CS,
|
||||
pinDirection
|
||||
};
|
||||
// insert before last SET_BITS_LOW command
|
||||
// SET_BITS_LOW takes 2 arguments, so we're inserting data in -3 position from the end
|
||||
buf.insert(buf.end() - 3, &data[0], &data[size]);
|
||||
|
||||
FTDI_CHECK_RESULT((rc = ftdi_write_data(_ftdic, buf.data(), buf.size())) != buf.size());
|
||||
FTDI_CHECK_RESULT((rc = ftdi_write_data(_ftdic, buf.data(), buf.size())) != buf.size());
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -22,10 +22,30 @@
|
||||
"whiteAlgorithm": {
|
||||
"type": "string",
|
||||
"title":"edt_dev_spec_whiteLedAlgor_title",
|
||||
"enum" : ["subtract_minimum","sub_min_cool_adjust","sub_min_warm_adjust","white_off"],
|
||||
"enum" : [
|
||||
"subtract_minimum",
|
||||
"sub_min_cool_adjust",
|
||||
"sub_min_warm_adjust",
|
||||
"cold_white",
|
||||
"neutral_white",
|
||||
"auto",
|
||||
"auto_max",
|
||||
"auto_accurate",
|
||||
"white_off"
|
||||
],
|
||||
"default": "subtract_minimum",
|
||||
"options" : {
|
||||
"enum_titles" : ["edt_dev_enum_subtract_minimum", "edt_dev_enum_sub_min_cool_adjust","edt_dev_enum_sub_min_warm_adjust", "edt_dev_enum_white_off"]
|
||||
"enum_titles" : [
|
||||
"edt_dev_enum_subtract_minimum",
|
||||
"edt_dev_enum_sub_min_cool_adjust",
|
||||
"edt_dev_enum_sub_min_warm_adjust",
|
||||
"edt_dev_enum_cold_white",
|
||||
"edt_dev_enum_neutral_white",
|
||||
"edt_dev_enum_auto",
|
||||
"edt_dev_enum_auto_max",
|
||||
"edt_dev_enum_auto_accurate",
|
||||
"edt_dev_enum_white_off"
|
||||
]
|
||||
},
|
||||
"propertyOrder" : 4
|
||||
},
|
||||
|
@ -43,10 +43,30 @@
|
||||
"whiteAlgorithm": {
|
||||
"type": "string",
|
||||
"title":"edt_dev_spec_whiteLedAlgor_title",
|
||||
"enum" : ["subtract_minimum","sub_min_cool_adjust","sub_min_warm_adjust","white_off"],
|
||||
"enum" : [
|
||||
"subtract_minimum",
|
||||
"sub_min_cool_adjust",
|
||||
"sub_min_warm_adjust",
|
||||
"cold_white",
|
||||
"neutral_white",
|
||||
"auto",
|
||||
"auto_max",
|
||||
"auto_accurate",
|
||||
"white_off"
|
||||
],
|
||||
"default": "subtract_minimum",
|
||||
"options" : {
|
||||
"enum_titles" : ["edt_dev_enum_subtract_minimum", "edt_dev_enum_sub_min_cool_adjust","edt_dev_enum_sub_min_warm_adjust", "edt_dev_enum_white_off"]
|
||||
"enum_titles" : [
|
||||
"edt_dev_enum_subtract_minimum",
|
||||
"edt_dev_enum_sub_min_cool_adjust",
|
||||
"edt_dev_enum_sub_min_warm_adjust",
|
||||
"edt_dev_enum_cold_white",
|
||||
"edt_dev_enum_neutral_white",
|
||||
"edt_dev_enum_auto",
|
||||
"edt_dev_enum_auto_max",
|
||||
"edt_dev_enum_auto_accurate",
|
||||
"edt_dev_enum_white_off"
|
||||
]
|
||||
},
|
||||
"propertyOrder" : 7
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user