Xinyuan-LilyGO / T-QT

MIT License
94 stars 31 forks source link

Hour hand doesn't move as it should... fix included #5

Closed Sarah-C closed 1 year ago

Sarah-C commented 1 year ago

If you're finding the hour hand in the factory demo to be a bit wonky... here's the fix.

The hour hand doesn't increment in fractions, so if it's 5 to 3, it looks almost like 5 to 2 because the hour hand hasn't moved on!

The fix shows the hour hand correctly positioned between two numbers for half past the hour:

image

The fix adds on the angle of the minutes scaled to 1/12 of a circle to the angle of the hour hand... which is simply multiplying the minutes by 5.

lvgl_gui.cpp

void update_sensor(lv_timer_t *timer) {
  float volt = (analogRead(PIN_BAT_VOLT) * 2 * 3.3) / 4096;
  char buf[20];
  snprintf(buf, 20, "bat_volt:%.2f V", volt);
  lv_label_set_text(bat_label, buf);

  struct tm timeinfo;
  if (getLocalTime(&timeinfo)) {
    // The line that fixes the hour hand.
    lv_img_set_angle(hour_img, ((timeinfo.tm_hour) * 300 + ((timeinfo.tm_min) * 5)) % 3600);
    lv_img_set_angle(min_img, (timeinfo.tm_min) * 60);
LilyGO commented 1 year ago

thanks for your reminder.Please submit a pull request and I'll merge this.

Sarah-C commented 1 year ago

Checked in here: https://github.com/Sarah-C/T-QT/commit/2980144b879a394d9c9399973fc774039b7895f6

Micky513673326 has been nice enough to submit the pull request. Thank you!

Issue closed.

Sarah-C commented 1 year ago

Closed!