I’m playing with displaying time on an ssd1306 display using lambdas… trying a simple fix to remove the leading 0 the hour variable (for %I from now()), and for some reason it doesn’t want to print a simple blank space for me:
lambda: |-
auto nowTime = id(ha_time).now();
if (nowTime.hour < 10) {
it.strftime(0, 0, id(my_fontlg), "%I:%M:%S %p", nowTime);
it.printf(0, 11, id(my_fontlg), " ");
}
else {
it.strftime(0, 0, id(my_fontlg), "%I:%M:%S %p", nowTime);
}
That seems like it should work, and I get an X in the right spot does if I replace " " with “X”. I know I could just printf and format my own string using .hour, .minute, & .second, but that’s a lot more work, and I figured there’s some simpler way I could fool it to actually print the blank space over that leading 0. Is there a way, or do I have to just slog through string formatting?
[edit: LOL, nevermind I see what’s going on here. I think the space is actually printing, but the graphic code just “adds on pixels”, and doesn’t “turn off” any pixels. That means a space does nothing to the display! I should have figured that out when the X was overlaying the 1 in my example mentioned above. Looks like there’s no way around strings… honestly a bit annoying that the %I has a leading zero… in what case is that desired?! ]