javagoza / TFTVirtualSegmentDisplay

TFT Virtual Seven Segment Library for Arduino
GNU General Public License v3.0
1 stars 1 forks source link

I could use some help with my work in adapting your library to my project #1

Closed bsbrum closed 1 year ago

bsbrum commented 1 year ago

Enrique- Thank you for your work, I am building a motor speed controller for a milling machine, and your library seems to be a solution for the problem I've hit which is a simulated 7-segment display that refreshes quickly. My attempts to use a large 7-segment font are unacceptable. The challenge that I have is that I've adapted your library to my solution, which is based on an Arduino Mega and an ILI9486 3.5" LCD. The LCD driver is through the UTFT package since the Adafruit 2.5" LCD library does not work with this screen. I have 2 problems that I was hoping you might be able to give me some clues to resolve:

  1. I am using the TFTSevenSegmentDecimalDisplay function since this is not for a clock, but I can only get 3 digits to display and I need 4 - as this is a tachometer display to handle up to 3000 revolutions per minute,
  2. The "off" state of the virtual led elements does not seem to be working, so all I see are 8s - photo is attached.

I've scoured through the code, made some modifications and adaptations to try to increase the segment count for the "hundreds" display and figure out the "off" condition, but I am only seeing the three digits as eights.

Any tips would be greatly appreciated. Thanks, again.

IMG_0790

javagoza commented 1 year ago

Hi I have another version with 4 digits modules: https://github.com/javagoza/Remote-IAQ-Monitor

https://github.com/javagoza/Remote-IAQ-Monitor/blob/main/Remote-IAQ-Monitor/TFTSevenSegmentDecimalDisplay.h

image

javagoza commented 1 year ago

image https://community.element14.com/challenges-projects/project14/betterworld/b/blog/posts/simple-remote-air-quality-monitor-project-tutorial

bsbrum commented 1 year ago

Hi I have another version with 4 digits modules: https://github.com/javagoza/Remote-IAQ-Monitor

https://github.com/javagoza/Remote-IAQ-Monitor/blob/main/Remote-IAQ-Monitor/TFTSevenSegmentDecimalDisplay.h

image

Enrique - thank you for this. It did get me past the 4 digit issue. I am still bending my brain around the lcd segment off state issue - this is sent with zero as the value. It may be the result of an early porting edit, I am still on the hunt to solve that.

Thanks, again.

IMG_0792

javagoza commented 1 year ago

Are you setting the offColor as a different color than the onColor?

TFTSevenSegmentDecimalDisplay::TFTSevenSegmentDecimalDisplay(Adafruit_ST7735* tft, int16_t x = 0, int16_t y = 0, int16_t w = 16, int16_t h = 32, uint16_t onColor = 255, uint16_t offColor = 0, int16_t ledWidth = 3 )

bsbrum commented 1 year ago

Yes, on and off are different.

ILI9486UTFT myGLCD(ILI9486,LCDPIN1,LCDPIN2,LCDPIN3,LCDPIN4); TFTSevenSegmentDecimalDisplay tachDisplay(&myGLCD, 30, 30, 60, 110, GREEN, BLACK, 10); TFTSevenSegmentDecimalDisplay inputDisplay(&myGLCD, 160, 250, 20, 35, WHITE, BLACK, 5);

It seems to be the way that the UTFT library sets color. I've been trying a lot of different ways to get around this, but nothing yet has worked - even tried this, using the UTFT setColor method directly in the SevenSegmentDecimalDisplay.cpp without any luck:

if (thousands > 0) {
    m_tft->setColor(0x07E0); // added << green
    digits[THOUSANDS]->on();
    digits[THOUSANDS]->display(thousands % 10);
  } else {
    m_tft->setColor(0x0000); // added << black
    digits[THOUSANDS]->off();
    digits[THOUSANDS]->display(0);
  }
javagoza commented 1 year ago

How did you port the TFTSevenSegmentModule.cpp file? To delete the segments that are off, they are painted with the off color.

draw_F_LeftUpperLed((leds & 32) && m_on ? m_onColor : m_offColor);

void TFTSevenSegmentModule::draw_F_LeftUpperLed(uint16_t color) {
  m_tft->startWrite();
  for (int i = 0; i < m_ledWidth; i++) {
    m_tft->writeFastVLine(m_x + i, m_y + i, m_h / 2 - 2 * i, color);
  }
  m_tft->endWrite();
}

Do you have an option similar to writeFastVLine in the library you use?

bsbrum commented 1 year ago

Enrique- Yes, the UTFT library has "drawVLine" but there is no color option for that function. Which is why I was trying to set it up-stream a bit. I'll see what I can do with that library to add color setting to see if that resolves it.

Thank you for your help.

void TFTSevenSegmentModule::draw_F_LeftUpperLed(uint16_t color) {
  //m_tft->startWrite();
  m_tft->wr
  for (int i = 0; i < m_ledWidth; i++) {
    m_tft->drawVLine(m_x + i, m_y + i, m_h / 2 - 2 * i);
  }
  //m_tft->endWrite();
}
javagoza commented 1 year ago

Then set the color before drawVLine and drawHLine in all the functions that uses those functions in that file

m_tft->setColor(color);
m_tft->drawVLine(m_x + i, m_y + i, m_h / 2 - 2 * i);
javagoza commented 1 year ago

Can you put a link to the library you use?

bsbrum commented 1 year ago

It's here:

http://www.rinkydinkelectronics.com/library.php?id=51

bsbrum commented 1 year ago

m_tft->setColor(color);

Enrique- This suggestion has got me going, thank you. I was headed in this direction but you bumped me there sooner. Thanks.

IMG_0793

javagoza commented 1 year ago

I'm glad you fixed it. Enjoy it! Is the repaint fast enough? In my version, I used a method that allows sending several commands in a row to the display and it did it quite quickly? I see that that library doesn't have those startWrite() and endWrite() methods

bsbrum commented 1 year ago

I am still debugging, so it's too soon to say. I'll let you know. once I get it fully operational. I really appreciate all your effort and assistance. Cheers!

bsbrum commented 1 year ago

Enrique - you are the man! This is working fantastically. I cannot thank you enough.

IMG_0795

javagoza commented 1 year ago

Thanks for the feedback. Cheers!