Dayadjustment

ok thanks for the info. I running something similar so In my fist opportunity I will check mine and I will let you know!

thank you for helping me

I add something more to say.
the crash occurs when weekday() == 1 and no day is selected or Sunday is selected .
otherwise everything works well

Hi Mike. I sat down at the PC to do this and realised that I was talking bollocks - nothing new there then!

However, there is an easy way to translate between Timelib days and Blynk days…

Set-up an array of Blynk days where you define the corresponding Timelid day for Blynk day number. As we’re stuck with zero-indexed arrays in C++, the first entry will represent day 0, which obviously doesn’t exist, so we just have to put a number in that location that will never be used - 0 in my example.

// TimeLib format Sun = 1 , Mon = 2 , Tue = 3 , Wed = 4 , Thu = 5 , Fri = 6 , Sat = 7
// Blynk format   Sun = 7 , Mon = 1 , Tue = 2 , Wed = 3 , Thu = 4 , Fri = 5 , Sat = 6

int BlynkDayArray[8]={0,7,1,2,3,4,5,6}; // Zero-based array, translates 1 to 7, 2 to 1, 3 to 2 etc

you can then use BlynkDayArray[TimelibDay]) which will return the correctly translated day.

for example:

Timelib day 4 is a Wednesday, and BlynkDayArray[4] will return 3, which is also Wednesday in Blynk speak.

Timelib day 1 is a Sunday, and BlynkDayArray[1] will return 7, which is also Sunday in Blynk speak.

Hope this makes sense?

Pete…

2 Likes

That seems a very clever way to do it! I will try it in my next project. Thanks for sharing @PeteKnight

ok @PeteKnight,

I already use this to translate weekday () to be displayed on the LCD.
const char *daysArray[] = {“Dim”, “Lun”, “Mar”, “Mer”, “Jeu”, “Ven”, “Sam”};
17-024606

but the problem remains the same with: ‘if (t.isWeekdaySelected (7))’
even if translation between Timelib and Blynk days
the issue always occurs with the 7 when sunday is selected and the day of the week from blynk local server is sunday too

That’s because there isn’t a 7th element in your array. The array is zero-based, so you only have elements 0 to 6.

Pete.

Not too sure about it https://github.com/blynkkk/blynk-library/blob/3f4c883003162570b6e1472aa0b16c6dd73ace58/src/WidgetTimeInput.h#L113

I didn’t spend a lot of time trying to understand it though