Нипанятна.
Если просто делаю переменную, всё работает (соответственно пока питание есть). Когда ставлю галочку "сохранить в EEPROM", из кода эта переменная удаляется.
Сейчас снова скачиваю и обновлю программу, может с ней что нетак.
Хотя странно, на резисторе работало, на энкодере не хотит.
#include "flprogUtilites.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "STM32encoder.h"
LiquidCrystal_I2C _lcd1(0x27, 16, 2);
int _dispTempLength1=0;
boolean _isNeedClearDisp1;
bool en_enc;
int16_t Set;
bool en_Set;
int16_t Reset;
bool en_Reset;
int16_t pos_enc;
int16_t my_var;
bool Short_press;
bool Long_press;
STM32encoder enc(TIM2);
int16_t myVar= 0;
bool _gtv1;
bool _gtv2;
int16_t _gtv4 = 0;
int16_t _disp2oldLength = 0;
int16_t _disp1oldLength = 0;
void setup()
{
Wire.begin();
delay(10);
_lcd1.init();
_lcd1.backlight();
enc.bind(&myVar, 1, -20, 100);
enc.setButton(PA2);
}
void loop()
{
if (_isNeedClearDisp1) {_lcd1.clear(); _isNeedClearDisp1= 0;}
//Плата:1
en_enc = !(0);
Set = _gtv4;
en_Set = _gtv1;
Reset = 0;
en_Reset = 0;
if(en_enc) {
Short_press = 0;
Long_press = 0;
switch(enc.button()){
case BTN_EVT_CLICK:
Short_press = 1;
break;
case BTN_EVT_LONG:
Long_press = 1;
break;
}
if (en_Set) {
myVar = Set;
my_var = myVar;
}
if (en_Reset) {
myVar = Reset;
my_var = myVar;
}
if (enc.isUpdated())
{
pos_enc = enc.pos();
my_var = myVar;
}
}
_gtv2 = Long_press;
_gtv1 = Short_press;
if (_gtv2) {
_gtv4 = my_var;
}
if (!(0)) {
_dispTempLength1 = (((String(my_var, DEC)))).length();
if (_disp1oldLength > _dispTempLength1) {_isNeedClearDisp1 = 1;}
_disp1oldLength = _dispTempLength1;
_lcd1.setCursor(0, 0);
_lcd1.print(((String(my_var, DEC))));
} else {
if (_disp1oldLength > 0) {_isNeedClearDisp1 = 1; _disp1oldLength = 0;}
}
if (!(0)) {
_dispTempLength1 = (((String(_gtv4, DEC)))).length();
if (_disp2oldLength > _dispTempLength1) {_isNeedClearDisp1 = 1;}
_disp2oldLength = _dispTempLength1;
_lcd1.setCursor(0, 1);
_lcd1.print(((String(_gtv4, DEC))));
} else {
if (_disp2oldLength > 0) {_isNeedClearDisp1 = 1; _disp2oldLength = 0;}
}
}
#include "flprogUtilites.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "STM32encoder.h"
LiquidCrystal_I2C _lcd1(0x27, 16, 2);
int _dispTempLength1=0;
boolean _isNeedClearDisp1;
bool en_enc;
int16_t Set;
bool en_Set;
int16_t Reset;
bool en_Reset;
int16_t pos_enc;
int16_t my_var;
bool Short_press;
bool Long_press;
STM32encoder enc(TIM2);
int16_t myVar= 0;
bool _gtv1;
bool _gtv2;
int16_t _disp2oldLength = 0;
int16_t _disp1oldLength = 0;
void setup()
{
Wire.begin();
delay(10);
_lcd1.init();
_lcd1.backlight();
enc.bind(&myVar, 1, -20, 100);
enc.setButton(PA2);
}
void loop()
{
if (_isNeedClearDisp1) {_lcd1.clear(); _isNeedClearDisp1= 0;}
//Плата:1
en_enc = !(0);
Set = ;
en_Set = _gtv1;
Reset = 0;
en_Reset = 0;
if(en_enc) {
Short_press = 0;
Long_press = 0;
switch(enc.button()){
case BTN_EVT_CLICK:
Short_press = 1;
break;
case BTN_EVT_LONG:
Long_press = 1;
break;
}
if (en_Set) {
myVar = Set;
my_var = myVar;
}
if (en_Reset) {
myVar = Reset;
my_var = myVar;
}
if (enc.isUpdated())
{
pos_enc = enc.pos();
my_var = myVar;
}
}
_gtv2 = Long_press;
_gtv1 = Short_press;
if (_gtv2) {
}
if (!(0)) {
_dispTempLength1 = (((String(my_var, DEC)))).length();
if (_disp1oldLength > _dispTempLength1) {_isNeedClearDisp1 = 1;}
_disp1oldLength = _dispTempLength1;
_lcd1.setCursor(0, 0);
_lcd1.print(((String(my_var, DEC))));
} else {
if (_disp1oldLength > 0) {_isNeedClearDisp1 = 1; _disp1oldLength = 0;}
}
if (!(0)) {
_dispTempLength1 = (((String(, DEC)))).length();
if (_disp2oldLength > _dispTempLength1) {_isNeedClearDisp1 = 1;}
_disp2oldLength = _dispTempLength1;
_lcd1.setCursor(0, 1);
_lcd1.print(((String(, DEC))));
} else {
if (_disp2oldLength > 0) {_isNeedClearDisp1 = 1; _disp2oldLength = 0;}
}
}
====================================================================================================
Скачал 9 программу, открыл прежний файл, снова фиг-вам (индейская народная изба).
Открыл проект с резистором, который исправный, собрал в нём, всё прекрасно заработало.
Собрал проект с ноля, тоже всё замечательно.
Делаю вывод - если что-то не так, то желательно проект собирать с чистого листа. Периодически нажимая "глазик", контролируя этим код.
#include "flprogUtilites.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "STM32encoder.h"
#include "flprogInternalEEPROM.h"
FLProgInternalEEPROM InternalEEPROM_41185707(3, 230);
LiquidCrystal_I2C _lcd1(0x27, 16, 2);
int _dispTempLength1=0;
boolean _isNeedClearDisp1;
bool en_enc;
int16_t Set;
bool en_Set;
int16_t Reset;
bool en_Reset;
int16_t pos_enc;
int16_t my_var;
bool Short_press;
bool Long_press;
STM32encoder enc(TIM2);
int16_t myVar= 0;
bool _gtv2;
int16_t _disp1oldLength = 0;
int16_t _disp2oldLength = 0;
void setup()
{
Wire.begin();
delay(10);
InternalEEPROM_41185707.setIntegerStartValue(1, 0);
InternalEEPROM_41185707.setSkippingEvents(0);
InternalEEPROM_41185707.begin();
_lcd1.init();
_lcd1.backlight();
enc.bind(&myVar, 1, -20, 100);
enc.setButton(PA2);
}
void loop()
{
InternalEEPROM_41185707.pool();
if (_isNeedClearDisp1)
{
_lcd1.clear();
_isNeedClearDisp1= 0;
}
//Плата:1
if (!(0))
{
_dispTempLength1 = (((String(((InternalEEPROM_41185707.readInteger(1))), DEC)))).length();
if (_disp2oldLength > _dispTempLength1)
{
_isNeedClearDisp1 = 1;
}
_disp2oldLength = _dispTempLength1;
_lcd1.setCursor(0, 1);
_lcd1.print(((String(((InternalEEPROM_41185707.readInteger(1))), DEC))));
}
else
{
if (_disp2oldLength > 0)
{
_isNeedClearDisp1 = 1;
_disp2oldLength = 0;
}
}
en_enc = !(0);
Set = ((InternalEEPROM_41185707.readInteger(1)));
en_Set = _gtv2;
Reset = 0;
en_Reset = 0;
if(en_enc)
{
Short_press = 0;
Long_press = 0;
switch(enc.button())
{
case BTN_EVT_CLICK:
Short_press = 1;
break;
case BTN_EVT_LONG:
Long_press = 1;
break;
}
if (en_Set)
{
myVar = Set;
my_var = myVar;
}
if (en_Reset)
{
myVar = Reset;
my_var = myVar;
}
if (enc.isUpdated())
{
pos_enc = enc.pos();
my_var = myVar;
}
}
_gtv2 = Short_press;
if (Long_press)
{
InternalEEPROM_41185707.saveInteger(1, ((my_var)));
}
if (!(0))
{
_dispTempLength1 = (((String(my_var, DEC)))).length();
if (_disp1oldLength > _dispTempLength1)
{
_isNeedClearDisp1 = 1;
}
_disp1oldLength = _dispTempLength1;
_lcd1.setCursor(0, 0);
_lcd1.print(((String(my_var, DEC))));
}
else
{
if (_disp1oldLength > 0)
{
_isNeedClearDisp1 = 1;
_disp1oldLength = 0;
}
}
}
Добавлю.
ecoins прав, проект был создан в 9 версии, потом по игрался в 8 версии и продолжил снова в 9 версии. При создании проектов это надо учитывать.