Go Down

Topic: problems with st7789 overlaying displayed seconds with rtc (Read 112 times) previous topic - next topic


I wrote a code that sends data (nrf24l01) from the sensors to the receiver and then displays it on the st7789 color screen,  i set the screen to refresh every 10 seconds which also causes the screen to turn off for a split of a second, and the seconds to overlap each other, how can i fix that and also how can i optimize my code to use less memory if it's possible cause i am planning to run it on atmega168 but the code is too big, maybe transfer some variables to eeprom? 


video link:



Change your setTextColor(BLUE) to       lcd.setTextColor(BLUE, BLACK);

This will draw the BLACK background with each letter.


Thanks a lot, now it works, have one more problem, when the seconds count from 0-9 they are displayed in the wrong place and it looks like it's showing 19,29,39,49,59,69,79,89,99, i think it has something to do with the part of the code right at the bottom but not sure how to fix it, help would be greatly appreciated

link for the video:



Jan 26, 2020, 06:08 pm Last Edit: Jan 26, 2020, 06:10 pm by david_prentice
You have a lot of similar sequences e.g.
Code: [Select]

      lcd.setCursor(190, 150);

It is worth writing a helper function e.g.
Code: [Select]

void printXYColorSizeNum(int x, int y, uint16_t color, int sz, int num)
      lcd.setCursor(x, y);
      lcd.setTextColor(color, BLACK);
      if (num < 10) lcd.print("0");  // e.g. 04 instead of 4

and call like this:
Code: [Select]

      printXYColorSizeNum(190, 150, BLUE, 3, tm.Second);

Note that there are simpler ways to print a nicely formatted date on your TFT.



OK now it works, gonna shorten my code, btw what does uint16_t mean, unsigned integer 16bit ?, what does the _t mean?, is that equal to unsigned integer ?


Google uint16_t

You have understood.   But Wikipedia will probably give a good explanation.   And why <stdint.h> is a good idea


Go Up