dbuezas / lgt8fx

Board Package for Logic Green LGT8F328P LGT8F328D and LGT8F88D
362 stars 87 forks source link

E2PROM #300

Closed imroend closed 1 year ago

imroend commented 1 year ago

How to read and write my struct to e2prom? Not function for eeprom.put() and eeprom.get()

wollewald commented 1 year ago

It's like on an AVR based Arduino. Try this example:

#include <EEPROM.h>

struct myStruct{
    int a;
    float b;
    char c;
};

void setup(){
    Serial.begin(9600);
    myStruct myWriteStruct = {42, 42.42, 'c'};
    unsigned int address = 0;
    EEPROM.put(address, myWriteStruct);

    myStruct myReadStruct = {};
    EEPROM.get(address, myReadStruct);
    Serial.println(myReadStruct.a);
    Serial.println(myReadStruct.b);
    Serial.println(myReadStruct.c);
}

void loop(){}

It worked on my LQFP32 MiniEVB

imroend commented 1 year ago

Apakah itu menggunakan library EEPROM for avr

wollewald commented 1 year ago

If deepl is correct then this is Indonesian and means: "Does it use the EEPROM library for avr?"

The answer is: You can use it like the AVR EEPROM library but it is different "behind the scenes".

Or in Indonesian:

Jawabannya adalah: Anda dapat menggunakannya seperti perpustakaan EEPROM AVR, tetapi berbeda "di balik layar".

I hope this makes sense!

imroend commented 1 year ago

Saya mendapati niliai kesalahan pada type data int 16937 //int data 42.42 // float data C // char data

Jadi untuk int salah , lainnya benar

imroend commented 1 year ago

![Uploading 16957596641147092191001219699219.jpg…]()

wollewald commented 1 year ago

Translation is:

I got an error value on the int data type 16937 //int data 42.42 // float data C // char data

So for int is wrong, others are right

Don't know what's wrong on your side. I get the correct values. And I can't see the image you tried to upload. Tidak tahu apa yang salah di pihak Anda. Saya mendapatkan nilai yang benar. Dan saya tidak bisa melihat gambar yang Anda coba unggah.

imroend commented 1 year ago

Terimakasih , permasalah terselesaikan dengan menghapus library EEPROM di folder user library/ di my document, mungkin library terbaca di folder tersebut sebelumnya

wollewald commented 1 year ago

For the benefit of other readers, here's the translation:

Thanks, the problem was solved by deleting the EEPROM library in the user library folder / in my documents, maybe the library was read in that folder before