Skip to content

Commit

Permalink
fixed shift reg clk
Browse files Browse the repository at this point in the history
  • Loading branch information
Reksotiv committed Jan 29, 2022
1 parent 557f04c commit 3741354
Show file tree
Hide file tree
Showing 8 changed files with 242 additions and 181 deletions.
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#define MAJOR_VERSION 1
#define MINOR_VERSION 7
#define PATCH_VERSION 1
#define BUILD_VERSION 1
#define BUILD_VERSION 2

#ifdef INNO_SETUP
#define APP_VERSION Str(MAJOR_VERSION) + "." + Str(MINOR_VERSION) + "." + Str(PATCH_VERSION) + "." + "b" + Str(BUILD_VERSION)
Expand Down
19 changes: 13 additions & 6 deletions src/widgets/pins/pinconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ PinConfig::PinConfig(QWidget *parent) : // пины - первое, чт
m_contrLite->hide();

m_maxButtonsWarning = false;
m_shiftLatchCount = 0;
m_shiftDataCount = 0;
m_shiftLatchCount = m_shiftDataCount = m_shiftClkCount = 0;

// create pin combo box. i+1! start from 1
// возможно использовать одни и те же комбобоксы пинов в разных виджетах плат - изврат,
Expand Down Expand Up @@ -173,18 +172,26 @@ void PinConfig::signalsForWidgets(int currentDeviceEnum, int previousDeviceEnum,
// shift register latch selected
if (currentDeviceEnum == SHIFT_REG_LATCH){
m_shiftLatchCount++;
emit shiftRegSelected(pinNumber, 0, m_pinCBoxPtrList[0]->pinList()[pinIndex].guiName); // hz
emit shiftRegSelected(pinNumber, 0, 0, m_pinCBoxPtrList[0]->pinList()[pinIndex].guiName); // hz
} else if (previousDeviceEnum == SHIFT_REG_LATCH){
m_shiftLatchCount--;
emit shiftRegSelected((pinNumber)*-1, 0, m_pinCBoxPtrList[0]->pinList()[pinIndex].guiName); // hz
emit shiftRegSelected((pinNumber)*-1, 0, 0, m_pinCBoxPtrList[0]->pinList()[pinIndex].guiName); // hz
}
// shift register CLK selected
if (currentDeviceEnum == SHIFT_REG_CLK){
m_shiftClkCount++;
emit shiftRegSelected(0, pinNumber, 0, m_pinCBoxPtrList[0]->pinList()[pinIndex].guiName); // hz
} else if (previousDeviceEnum == SHIFT_REG_CLK){
m_shiftClkCount--;
emit shiftRegSelected(0, (pinNumber)*-1, 0, m_pinCBoxPtrList[0]->pinList()[pinIndex].guiName); // hz
}
// shift register data selected
if (currentDeviceEnum == SHIFT_REG_DATA){
m_shiftDataCount++;
emit shiftRegSelected(0, pinNumber, m_pinCBoxPtrList[0]->pinList()[pinIndex].guiName); // hz
emit shiftRegSelected(0, 0, pinNumber, m_pinCBoxPtrList[0]->pinList()[pinIndex].guiName); // hz
} else if (previousDeviceEnum == SHIFT_REG_DATA){
m_shiftDataCount--;
emit shiftRegSelected(0, (pinNumber)*-1, m_pinCBoxPtrList[0]->pinList()[pinIndex].guiName); // hz
emit shiftRegSelected(0, 0, (pinNumber)*-1, m_pinCBoxPtrList[0]->pinList()[pinIndex].guiName); // hz
}
// I2C selected
if (currentDeviceEnum == I2C_SCL){// || current_device_enum == I2C_SDA){
Expand Down
6 changes: 4 additions & 2 deletions src/widgets/pins/pinconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class QGridLayout;
QT_END_NAMESPACE

#define SOURCE_COUNT 8
#define PIN_TYPE_LIMIT_COUNT 2
#define PIN_TYPE_LIMIT_COUNT 3

namespace Ui {
class PinConfig;
Expand All @@ -37,7 +37,7 @@ class PinConfig : public QWidget
void totalButtonsValueChanged(int count);
void totalLEDsValueChanged(int totalLed);
void fastEncoderSelected(const QString &pinGuiName, bool isSelected);
void shiftRegSelected(int latchPin, int dataPin, const QString &pinGuiName);
void shiftRegSelected(int latchPin, int clkPin, int dataPin, const QString &pinGuiName);
void i2cSelected(bool i2cSelected);
void axesSourceChanged(int sourceEnum, const QString &sourceName, bool isAdd);

Expand Down Expand Up @@ -67,6 +67,7 @@ private slots:

int m_shiftLatchCount;
int m_shiftDataCount;
int m_shiftClkCount;

void signalsForWidgets(int currentDeviceEnum, int previousDeviceEnum, int pinNumber, QString pinName);
void pinTypeLimit(int currentDeviceEnum, int previousDeviceEnum);
Expand Down Expand Up @@ -104,6 +105,7 @@ private slots:
{
{SHIFT_REG_LATCH, 4},
{SHIFT_REG_DATA, 4},
{SHIFT_REG_CLK, 4},
};

enum // and in current config
Expand Down
15 changes: 14 additions & 1 deletion src/widgets/shift-reg/shiftregisters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ ShiftRegisters::ShiftRegisters(int shiftRegNumber, QWidget *parent)
for (int i = 0; i < SHIFT_REG_TYPES; ++i) {
ui->comboBox_ShiftRegType->addItem(m_shiftRegistersList[i].guiName);
ui->label_DataPin->setText(m_notDefined);
ui->label_ClkPin->setText(m_notDefined);
ui->label_LatchPin->setText(m_notDefined);
}

Expand Down Expand Up @@ -62,6 +63,18 @@ void ShiftRegisters::setLatchPin(int latchPin, QString pinGuiName)
setUiOnOff();
}

void ShiftRegisters::setClkPin(int clkPin, QString pinGuiName)
{
if (clkPin != 0) {
m_clkPin = clkPin;
ui->label_ClkPin->setText(pinGuiName);
} else {
m_clkPin = 0;
ui->label_ClkPin->setText(m_notDefined);
}
setUiOnOff();
}

void ShiftRegisters::setDataPin(int dataPin, QString pinGuiName)
{
if (dataPin != 0) {
Expand All @@ -76,7 +89,7 @@ void ShiftRegisters::setDataPin(int dataPin, QString pinGuiName)

void ShiftRegisters::setUiOnOff()
{
if (m_latchPin > 0 && m_dataPin > 0) {
if (m_latchPin > 0 && m_clkPin > 0 && m_dataPin > 0) {
for (auto &&child : this->findChildren<QWidget *>()) {
child->setEnabled(true);
}
Expand Down
2 changes: 2 additions & 0 deletions src/widgets/shift-reg/shiftregisters.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class ShiftRegisters : public QWidget
void retranslateUi();

void setLatchPin(int latchPin, QString pinGuiName);
void setClkPin(int clkPin, QString pinGuiName);
void setDataPin(int dataPin, QString pinGuiName);

const QString &defaultText() const;
Expand All @@ -44,6 +45,7 @@ private slots:
int m_buttonsCount;
int m_shiftRegNumber;
int m_latchPin;
int m_clkPin;
int m_dataPin;

const deviceEnum_guiName_t m_shiftRegistersList[SHIFT_REG_TYPES] = // порядов обязан быть как в common_types.h!!!!!!!!!!!
Expand Down
Loading

0 comments on commit 3741354

Please sign in to comment.