A precision table clock with wind advisor


Since I am interested in the wind (little wind to fly the radio-controlled planes or a lot of wind to go over the lakes with my inflatable sailing canoe), I made this clock that first synchronizes the time with an NTP server and then on a list of weather stations that can be included in the program.
A warning starts if the wind exceeds a certain value that we can program.
A request is sent to the WindFinder site and the response is saved only for the part of interest to fill a table with the data of 4 days of forecast considering only the daytime hours.

Since the table provided by lvgl does not provide different colors for the cells (at least with the version 7.11 that I use), I made 4 semitransparent labels to highlight the lines with day and hours, and I used the 2 colors available for the background to divide the cells with data from fixed ones, and the result is not bad.
But you can see the video on Youtube and download the code that I insert here in a zipped file (Activate SUBTITLES to see explanations ).

WindFinderAdvisor.zip (245.7 KB)

2 Likes

Cool and complex project! :+1:

BTW, in v8 you have much more control over the tables. See Table (lv_table) — LVGL documentation

I looked at version 8.2 now, but I don’t see any option to change the color of any single cell.
In the version I made for PC I can color the single cell green when the wind exceeds a certain value.

However, given the size of the server response, I didn’t think I could make it on Esp32, then, by eliminating the initial and final part of the response, eliminating the gaps in the incoming data and acquiring 128 bytes at a time and saving on SPIFFS, and examining line by line the result, I was able to conclude it.
And thanks again for the libraries you developed.

The first example I linked shows how to change the properties of any cell with a draw callback. For example to change the bg color of cell (0;4)

static void draw_part_event_cb(lv_event_t * e)
{
    lv_obj_t * obj = lv_event_get_target(e);
    lv_obj_draw_part_dsc_t * dsc = lv_event_get_param(e);
    /*If the cells are drawn...*/
    if(dsc->part == LV_PART_ITEMS) {
        uint32_t row = dsc->id /  lv_table_get_col_cnt(obj);
        uint32_t col = dsc->id - row * lv_table_get_col_cnt(obj);

        if(row == 0 && col == 4) {
            dsc->rect_dsc->bg_color = lv_color_hex(0x123456);
        }
    }
}

...

 lv_obj_add_event_cb(table, draw_part_event_cb, LV_EVENT_DRAW_PART_BEGIN, NULL);

Ty for help Kisvegabor, i need try this options still.

I made some changes: now the current day is also considered if the current time is less than or equal to the time considered to launch the alert.
I introduced FTP to transfer files in or out of SPIFFS to the PC, using for example Total Commander on PC.
In line 637 you can change username and password for connection with ftp:

ftpSrv.begin (“Esp32”, “Esp32”);

and obviously you have to set it the same on Total Commander, in addition to the Local IP address (which you can see when the wifi connection occurs also in the serial output).
In the zipped file you can see the setting of the FTP connection with Total Commander.
Also if you want, you can examine the server response (already deleted the initial image and the final javascript that we don’t care to examine the incoming data) and find it in the Test.txt file on SPIFFS.

WindFinderAlert 2.zip (376.6 KB)

1 Like