Page 1 of 3

[New Feature] store calibration values

Posted: Tue Sep 25, 2012 9:25 pm
by Tectu
Morning Folks,

I made a quick implementation which allows to store the touchpad calibration data when calling tpCalibrate(). This way, you don't need to do tpCalibrate() after each reset.
The interface is similar to the GPIO abstraction for the LCD module itself. The user can decide where and how he wants to store the data. Someone may want to use an external I²C EEprom, another wants to use the SD card, maybe another uses the MCU's internal storage.

When you want to store the calibration data, you have to add #define TOUCHPAD_STORE_CALIBRATION TRUE in your halconf.h and then provide these two functions somewhere in your project (for example in main.c):

Code: Select all

void lld_tpWriteCalibration(struct cal cal) {

}

struct cal lld_tpReadCalibration(void) {

}


What you do in these two functions is up to you. You just have to make sure that you return the same struct which you receive. If you like, you can store two values on your EEprom and two on your SD card, just reassemble it the right way ;-)

This is the calibration struct:

Code: Select all

struct cal {
    float xm;
    float ym;
    float xn;
    float yn;
};



I couldn't test it yet. I would be thankful if someone could try this out and write a small review.

I am open for any critism or improvements.


~ Tectu

Re: store calibration values

Posted: Tue Sep 25, 2012 9:50 pm
by Badger
Nice idea, I will try when I get some time. We should provide an implementation for a BaseBlockDevice, that abstracts MMC over spi, SDC and other block devices. (I use this in the mass storage driver)

Re: store calibration values

Posted: Wed Sep 26, 2012 9:09 am
by Giovanni
We could also think to some kind of "persistent storage" abstraction, it could then be implemented over EEPROM, backup RAM, Flash etc.
It would also be a chance to use that Files Interface :)

Giovanni

Re: store calibration values

Posted: Wed Sep 26, 2012 9:23 am
by Abhishek
I agree with you Giovanni on this point. Something like a Hash Table which can be used to access data via key / value pair would be a better option than just serializing the calibration values.

Maybe something like:

In the main function:
loadSettings(&EEPROM1); or loadSettings(&SDCARD1("chibi.cfg"));

It would cache all the settings in memory, to speed up things.

The program would then write:

writePropertyFloat("X1", value);

and later on:

xcal=readPropertyFloat("X1");

Is it good for a start?

Best Regards

Re: store calibration values

Posted: Wed Sep 26, 2012 9:25 am
by Giovanni
So you want the Windows Registry :)

I would create two layers, this "persistent storage" that handles persistent files, and this registry-like component that would retrieve/store key/value pairs using the persistent storage.

Giovanni

Re: store calibration values

Posted: Wed Sep 26, 2012 9:37 am
by Abhishek
This registry would really be a cool add-on to the RTOS project. How do we go about doing it?

I guess starting with a 24C64 external EEPROM for the persistent storage would be a good option. Though I have seen minINI being ported to FatFS and STM32 systems.

Best Regards
Abhishek

Re: store calibration values

Posted: Wed Sep 26, 2012 9:41 am
by Giovanni
I will define the interface of the persistent storage (an abstract file system basically) and will create a FatFS wrapper, then we will discuss about this registry. Cannot promise times, I am very busy of late.

Giovanni

Re: store calibration values

Posted: Wed Sep 26, 2012 10:25 am
by mobyfab
Why not SQlite then?
It could be use for a lots of things, like if you want to plot some data without storing it in the memory.

We would need to port it first of course.
http://www.sqlite.org/custombuild.html

Re: store calibration values

Posted: Wed Sep 26, 2012 10:27 am
by Tectu
Not sure why we need a new FatFS wrapper? Do you want something completley different than mabl's wrapper, or are you just going to implement it into the RTOS?


~ Tectu

Re: store calibration values

Posted: Wed Sep 26, 2012 10:30 am
by Abhishek
@ Mobyfab, Nice idea, however I am not sure about the implications.

How much memory space (heap) would it require?

BTW, just found this: https://github.com/mabl/mininiChibios. Looks good.

EDIT: @Tectu, the wrapper is actually a connector for the registry architecture proposed.