Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coloured fonts #49

Merged
merged 1 commit into from
Jan 7, 2019
Merged

Coloured fonts #49

merged 1 commit into from
Jan 7, 2019

Conversation

tzarc
Copy link
Contributor

@tzarc tzarc commented Sep 10, 2018

As per the discussion on the blog post -- added support for different coloured meters on the screen.

Replaced the existing conversion code for fonts/graphics as well -- my build machine had serious problems with the latest ImageMagick, so it seemed like the easiest solution was to DIY it. No piping between multiple programs -- load input PNG and export the corresponding rgb565 data.

@kanflo
Copy link
Owner

kanflo commented Oct 1, 2018

Cool! I will look closer into this PR when I have fixed #51 which is quite critical.

@kanflo
Copy link
Owner

kanflo commented Oct 29, 2018

Lots of nice stuff here. I need to think a bit about the colouring scheme before merging as this can be a personal preference.

@f0086
Copy link

f0086 commented Oct 29, 2018

I would love to see a screenshot of some sort on the UI changes.

@tzarc
Copy link
Contributor Author

tzarc commented Oct 29, 2018

I'd put this on the blog post: https://i.imgur.com/k4wdxAz.jpg
Pretty sure the PR has the red/blue swapped, though.

@tzarc
Copy link
Contributor Author

tzarc commented Jan 1, 2019

Should I bother rebasing this to current master, or should I just close the PR?

@Xenoamor
Copy link
Contributor

Xenoamor commented Jan 1, 2019

Having a colour parameter for tft_putch() seems like a good addition to me. We can just have it default as white and if someone wants something custom they'll have to tweak it themselves in the source.

@Xenoamor Xenoamor mentioned this pull request Jan 1, 2019
@kanflo
Copy link
Owner

kanflo commented Jan 1, 2019

Hi @tzarc. No, I definitely don't think you should close this PR. We (as in I and anyone else here interested) should come up with a "style sheet" kind of mechanism where a user can color the UI at build time without dirtying the source code. Some (like me) might prefer the dull monochrome UI which is why I do not want to add colouring.

@tzarc
Copy link
Contributor Author

tzarc commented Jan 1, 2019

No problem, I'll knock something up to allow putting the colours in the Makefile -- something like COLOR_VOLTS, COLOR_AMPS, COLOR_INPUTVOLTS, COLOR_CV_CA, COLOR_ICONS?

Also, now that there's a newer font generator script, should I just split out the PNG converter stuff to a different PR?

I've been using my own font for testing purposes, as well as using FontAwesome for the icon generation -- perhaps the icons should be generated too?

@kanflo
Copy link
Owner

kanflo commented Jan 2, 2019

Yes, I think colours in the makefile should do it.

Using a font for the icons is a clever idea that has not occurred to me, great thinking!

Cool picture of you rig btw. Is it 3D printed?

@Xenoamor
Copy link
Contributor

Xenoamor commented Jan 4, 2019

I too had issues with the latest ImageMagick and had to build it from source which took my VM an hour. Then once I'd grappled with the various files required I got this:
image

I'm going to have a look at your generation of the fonts instead as where as I did get it to 'work' it was a real pain

@Xenoamor
Copy link
Contributor

Xenoamor commented Jan 4, 2019

What are you using to generate your font images @tzarc?

I guess the holygrail would be to point the makefile at a .TTF file and it works it all out from there

@tzarc
Copy link
Contributor Author

tzarc commented Jan 5, 2019

I was originally using the old ImageMagick to generate fonts -- I use a TTF directly (I dislike the Ubuntu one). Haven't swapped back to using my personal selection, but I've put the test generator here:
https://github.com/tzarc/opendps-font

As for your problem -- make sure the buffer sizes at the top of tft.c match the largest glyph size of any of the fonts. You'll get artifacting if you don't as it'll create a buffer overrun!

I doubt it'd work with the repo in its current form, mind you. Will look at consolidating both.

@tzarc
Copy link
Contributor Author

tzarc commented Jan 5, 2019

Yes, I think colours in the makefile should do it.

Using a font for the icons is a clever idea that has not occurred to me, great thinking!

Cool picture of you rig btw. Is it 3D printed?

The repo posted in my previous comment has an example of the icons, including using very condensed CV/CC as icons. Two PR's, or both under this?

And yeah, 3D printed! No the "daily driver' though -- was more just mucking about.

@tzarc
Copy link
Contributor Author

tzarc commented Jan 5, 2019

I've updated my PR to include just the colour changes for output voltage/current and input voltage.

Makefile now accepts arguments COLOR_VOLTAGE, COLOR_AMPERAGE, and
COLOR_INPUT. Color names can be found in ili9163c.h.

Will look at migrating across the image converter at a later stage.

@Xenoamor
Copy link
Contributor

Xenoamor commented Jan 5, 2019

I wonder if we can make a C or python program that will be able to render the files directly from a .ttf. I'll have a look into it when I have some free time. Although then again Ubuntu comes with an easy installer for the older magick version so I'll give yours a spin

using very condensed CV/CC as icons

Try to make pull requests for one change at a time if you can. This would be a welcome change though as I've had to pull the thermometer out of mine a few times to free up some FLASH space

@tzarc
Copy link
Contributor Author

tzarc commented Jan 5, 2019

I wonder if we can make a C or python program that will be able to render the files directly from a .ttf. I'll have a look into it when I have some free time

using very condensed CV/CC as icons

Try to make pull requests for one change at a time if you can. This would be a welcome change though as I've had to pull the thermometer out of mine a few times to free up some FLASH space

Precisely why I ripped them out. :)

Font generator-wise... definitely can. This sort of font format was something I used at a previous employer for OpenGL -- I actually wrote the C++ font generator for it for my team. Would be nice to just reproduce it, but alas, corporate ownership etc. etc.
Import freetype, run some generation, save to PNG. Pulling in all the deps for the C project is a bit more of a pain compared to a pip install xxxxxxxx.

That said, Python would most likely be easier than writing it in C, purely from a maintenance perspective.

@tzarc
Copy link
Contributor Author

tzarc commented Jan 5, 2019

I've had to pull the thermometer out of mine a few times to free up some FLASH space

The old PNG converter actually has a commented-out mode for storing fonts as 4bpp monochrome, with the intention of testing with a simple RLE applied to it... need to see if it's worth swapping to that storage mechanism in flash, and decoding at runtime. Not sure about RAM availability, need to check datasheets.

@Xenoamor Xenoamor mentioned this pull request Jan 5, 2019
@Xenoamor
Copy link
Contributor

Xenoamor commented Jan 5, 2019

I can certainly see font compression being a useful addition
image

@tzarc
Copy link
Contributor Author

tzarc commented Jan 6, 2019

Yikes. Yeah, looks like it'd be a good addition.
When the colour stuff gets merged I'll migrate across the PNG conversion stuff, including the 4bpp code. Should free up a significant amount of space, given that the fonts end up being 1/4 the size.

@Xenoamor
Copy link
Contributor

Xenoamor commented Jan 6, 2019

Aren't they currently 8bpp? So it would half the size not quarter?
Also did you get a chance to see the review questions I made for this pull request?

@tzarc
Copy link
Contributor Author

tzarc commented Jan 6, 2019

Aren't they currently 8bpp? So it would half the size not quarter?

Nope, they're 16bpp -- they're RGB565, the buffers themselves being DMA'd to the LCD.
Dropping to 4bpp monochrome means 1/4 the size, but it means there's a decode stage required for each character.

Also did you get a chance to see the review questions I made for this pull request?

Which questions?

@Xenoamor
Copy link
Contributor

Xenoamor commented Jan 6, 2019

Ah of course, thanks for the clarification. Considering we don't want rainbow coloured text I think 4bpp is a no brainer

And I started a review yesterday. Github doesn't do a good job of notifying people about them

Below is a screenshot of what it looks like on my end:
image

@tzarc
Copy link
Contributor Author

tzarc commented Jan 6, 2019

This is what I see:

image

They were a copy over from the old branch, but I think they're actually now wrong -- if there's support for the DPS8005 in the mix, 80,000 mV won't fit into a uint16_t. Will swap them all back to uint32_t.

int32_t max;
int16_t value;
int16_t min;
int16_t max;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the mentality of changing these to int16_t out of interest?

opendps/tft.c Outdated
* @param highlight if true, the character will be inverted
* @retval none
*/
void tft_putch(uint8_t size, char ch, uint32_t x, uint32_t y, uint32_t w, uint32_t h, bool highlight)
void tft_putch(uint8_t size, char ch, uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t color, bool highlight)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe color is defined as a uint16_t in ili9163c.h not a uint32_t

@Xenoamor
Copy link
Contributor

Xenoamor commented Jan 6, 2019

Wow @tzarc, thanks! I've been using this review thing wrong for a while now....
It seems you have to make all the review comments and then submit it before it's visible

@@ -129,12 +129,13 @@ static void number_draw(ui_item_t *_item)
break;
}
uint16_t xpos = _item->x - w;
uint32_t color = item->color;
Copy link
Contributor

@Xenoamor Xenoamor Jan 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a uint16_t I believe. Other than this it looks really good and would be a useful addition

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Fixed up a couple of build warnings in the process, too.

Makefile now accepts arguments COLOR_VOLTAGE, COLOR_AMPERAGE, and
COLOR_INPUT. Color names can be found in ili9163c.h.
@Xenoamor
Copy link
Contributor

Xenoamor commented Jan 7, 2019

Nice to see someone finally slay the mini-printf.c warning message! I'm all happy with this as it stands now

@kanflo kanflo merged commit b45ef61 into kanflo:master Jan 7, 2019
@kanflo
Copy link
Owner

kanflo commented Jan 7, 2019

Thanks @tzarc!

@tzarc tzarc deleted the color-fonts branch February 4, 2019 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants