ArduinoDroid и урок 11 Энергонезависимая память Eeprom.

Вопросы от новичков
Ответить
Аватара пользователя
montirovka
Сержант
Сообщения: 200
Зарегистрирован: 15.02.2021{, 16:16}
Репутация: 39
Откуда: Геленджик
Имя: Сергей

ArduinoDroid и урок 11 Энергонезависимая память Eeprom.

#1

Сообщение montirovka » 22.03.2021{, 11:48}

Установил на телефон Redmi 5 Plus программу ArduinoDroid версия 6.3.1. Залил свой скетч. Ошибку выдало при обращении к памяти. Решил разобраться с ошибкой. Залил скетч с 11 урока Энергонезависимая память Eeprom. Ошибка таже. Менял разные библиотеки EEPROM. Ошибка не исчезает. Подскажите чем можно заменить строки 153 и 193, что бы побороть ошибку?
153 _count1_Value = (readIntegerFromEEPROM(0, 0, 0x0));
193 (updateIntegerToEEPROM(0, 0, 0x0, (_count1_Value)));
СпойлерПоказать
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <EEPROM.h>
LiquidCrystal_I2C _lcd1(0x27, 16, 2);
int _dispTempLength1=0;
boolean _isNeedClearDisp1;
bool _count2I = 0;
int _count2_Value = 0;
bool _trgrt2 = 0;
bool _trgrt2I = 0;
bool _count1I = 0;
int _count1_Value = 0;
bool _bounseInputD3S = 0;
bool _bounseInputD3O = 0;
unsigned long _bounseInputD3P = 0UL;
bool _trgrt1 = 0;
bool _trgrt1I = 0;
bool _SEEPR1OSN = 0;
bool _bounseInputD2S = 0;
bool _bounseInputD2O = 0;
unsigned long _bounseInputD2P = 0UL;
int _disp2oldLength = 0;
int _disp1oldLength = 0;
void setup()
{
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
Wire.begin();
delay(10);
_lcd1.init();
_lcd1.backlight();
_bounseInputD3O = digitalRead(3);
_bounseInputD2O = digitalRead(2);
}
void loop()
{
if (_isNeedClearDisp1)
{
_lcd1.clear();
_isNeedClearDisp1= 0;
}
bool _bounceInputTmpD2 = (digitalRead (2));
if (_bounseInputD2S)
{
if (millis() >= (_bounseInputD2P + 40))
{
_bounseInputD2O= _bounceInputTmpD2;
_bounseInputD2S=0;
}
}
else
{
if (_bounceInputTmpD2 != _bounseInputD2O)
{
_bounseInputD2S=1;
_bounseInputD2P = millis();
}
}
bool _bounceInputTmpD3 = (digitalRead (3));
if (_bounseInputD3S)
{
if (millis() >= (_bounseInputD3P + 40))
{
_bounseInputD3O= _bounceInputTmpD3;
_bounseInputD3S=0;
}
}
else
{
if (_bounceInputTmpD3 != _bounseInputD3O)
{
_bounseInputD3S=1;
_bounseInputD3P = millis();
}
}
//Плата:1
if (!(_bounseInputD3O))
{
_count2_Value = 0;
}
else
{
if (!(_bounseInputD2O))
{
if (! _count2I)
{
_count2I = 1;
_count2_Value = _count2_Value + 1;
}
}
else
{
_count2I = 0;
}
}
if (1)
{
_dispTempLength1 = ((((String("Sch = ")) + ((String(_count2_Value, DEC)))))).length();
if (_disp2oldLength > _dispTempLength1)
{
_isNeedClearDisp1 = 1;
}
_disp2oldLength = _dispTempLength1;
_lcd1.setCursor(0, 0);
_lcd1.print((((String("Sch = ")) + ((String(_count2_Value, DEC))))));
}
else
{
if (_disp2oldLength > 0)
{
_isNeedClearDisp1 = 1;
_disp2oldLength = 0;
}
}
if (((analogRead (0))) <= (400))
{
if (_trgrt2I)
{
_trgrt2 = 0;
}
else
{
_trgrt2 = 1;
_trgrt2I = 1;
}
}
else
{
_trgrt2 = 0;
_trgrt2I = 0;
}
;
if (1)
{
if (_trgrt1I)
{
_trgrt1 = 0;
}
else
{
_trgrt1 = 1;
_trgrt1I = 1;
}
}
else
{
_trgrt1 = 0;
_trgrt1I = 0;
}
;
if (_trgrt1)
{
_count1_Value = (readIntegerFromEEPROM(0, 0, 0x0));
}
else
{
if (!(_bounseInputD2O))
{
if (! _count1I)
{
_count1I = 1;
_count1_Value = _count1_Value + 1;
}
}
else
{
_count1I = 0;
}
}
if (1)
{
_dispTempLength1 = ((((String("Obsh = ")) + ((String(_count1_Value, DEC)))))).length();
if (_disp1oldLength > _dispTempLength1)
{
_isNeedClearDisp1 = 1;
}
_disp1oldLength = _dispTempLength1;
_lcd1.setCursor(0, 1);
_lcd1.print((((String("Obsh = ")) + ((String(_count1_Value, DEC))))));
}
else
{
if (_disp1oldLength > 0)
{
_isNeedClearDisp1 = 1;
_disp1oldLength = 0;
}
}
if(_trgrt2)
{
if(!_SEEPR1OSN)
{
(updateIntegerToEEPROM(0, 0, 0x0, (_count1_Value)));
_SEEPR1OSN=1;
}
}
else
{
if(_SEEPR1OSN)
{
_SEEPR1OSN=0;
}
}
}
byte readByteFromEEPROM(int addres, byte bitAddres, byte chipAddres)
{
return EEPROM.read(addres);
}
void updateByteToEEPROM(int addres, byte bitAddres, byte chipAddres, byte value)
{
return EEPROM.write(addres, value);
}
int readIntegerFromEEPROM(int addres, byte bitAddres, byte chipAddres)
{
byte hight = readByteFromEEPROM(addres, bitAddres, chipAddres);
byte low = readByteFromEEPROM((addres+1), bitAddres, chipAddres);
return word(hight, low);
}
void updateIntegerToEEPROM(int addres, byte bitAddres, byte chipAddres, int value)
{
updateByteToEEPROM(addres, bitAddres, chipAddres, highByte(value));
updateByteToEEPROM((addres+1), bitAddres, chipAddres, lowByte(value));
}
Вложения
Screenshot_urok11.jpg
urok11.ino
(5.07 КБ) 17 скачиваний
Люблю учиться на чужих ошибках.

Аватара пользователя
montirovka
Сержант
Сообщения: 200
Зарегистрирован: 15.02.2021{, 16:16}
Репутация: 39
Откуда: Геленджик
Имя: Сергей

ArduinoDroid и урок 11 Энергонезависимая память Eeprom.

#2

Сообщение montirovka » 23.03.2021{, 11:54}

Упростил скетч до минимума. Записал число 35 в EEPROM и считал из EEPROMA.
СпойлерПоказать
#include <EEPROM.h>
bool _SEEPR1OSN = 0;
void setup()
{
}
void loop()
{
//Плата:1
if(!(0))
{
if(!_SEEPR1OSN)
{
(updateIntegerToEEPROM(0, 0, 0x0, (35)));
_SEEPR1OSN=1;
}
}
else
{
if(_SEEPR1OSN)
{
_SEEPR1OSN=0;
}
}
}
byte readByteFromEEPROM(int addres, byte bitAddres, byte chipAddres)
{
return EEPROM.read(addres);
}
void updateByteToEEPROM(int addres, byte bitAddres, byte chipAddres, byte value)
{
return EEPROM.update(addres, value);
}
int readIntegerFromEEPROM(int addres, byte bitAddres, byte chipAddres)
{
byte hight = readByteFromEEPROM(addres, bitAddres, chipAddres);
byte low = readByteFromEEPROM((addres+1), bitAddres, chipAddres);
return word(hight, low);
}
void updateIntegerToEEPROM(int addres, byte bitAddres, byte chipAddres, int value)
{
updateByteToEEPROM(addres, bitAddres, chipAddres, highByte(value));
updateByteToEEPROM((addres+1), bitAddres, chipAddres, lowByte(value));
}
Открыл в Arduino IDE. Ошибка 'class EEPROMClass' has no member named 'update'
Так что здесь не так?
Вложения
EEPROM_FLProg.ino
(1.06 КБ) 18 скачиваний
EEPROM_FLProg.flp
(27.93 КБ) 18 скачиваний
Люблю учиться на чужих ошибках.

Ответить

Вернуться в «Начинающим»