SOLVED - Stuck on my first module

Hi expert module coders.

I’m trying to build my first module.

I’ve got it to compile and load into the rack, but I can’t get numbers to show on my LCD display.

Is there something I have to do to initialise it? It looks like it should just refresh itself automatically.

Can anyone tell me what’s going wrong? There’s no process code yet, just the components. I’ve copied the LCD code from another module, so it should be ok.

Module in rack

Source file

Thanks in advance, Chris.

I’m pretty ignorant about C++, but I thought I might learn something by trying to help.

I noticed that in your code, you have

to_display << std::setw(1) << "9";

whereas in Computerscare’s code its

to_display << std::setw(3) << *value;

so perhaps your hard-coded “9” is causing a problem?

Hi Hamptonio.

I don’t think so. I did that to reduce the potential problem areas. It’s copied from a default line in their code a couple of lines later.

Though I did think it a bit weird as value is an int *, not a string. I might try changing it back.

… nope - same problem.

Best Regards, Chris.

your draw override call needs to call draw in the base class. I don’t know if that’s “it”, but it could be.

Where’s Vec textPos = Vec(6.0f, 17.0f); drawing to? Can you check it’s within your box size?

Thanks both.

However, neither seem to solve my problem.

As far as I can see, vec(6,17) should be in my box. However, I tried other, smaller values with no effect. I also enlarged the box.

I added the line “TransparentWidget::draw(args);” both at the top and bottom of my draw override function, to no effect. However, note that this does not appear in the code I copied, which works fine.

Cheers, Chris.

Anyone else? Still stuck on this.

The module is live - It is responding correctly to both button presses and changes at the inputs. Just won’t display numbers.

Best Regards, Chris.

curious, what was the solution? I am having issues with drawing as well

Hi Bill.

Turned out the widget was loading a specific font, which I hadn’t made available. No error message - it was just writing nothing! Very helpful!

Cheers, Chris.

Are you saying you loaded a font file that didn’t exist and it didn’t log a warning message?

Hi Andrew,

Well I didn’t look at any logfile, But it compiled and executed with no warnings - just failed to display any text. And yes, I made a call to load a font that didn’t exist on my drive.

It’s not possible to check existence of resource files at compile-time. Therefore they are checked at run-time.

Well as I said, I got no warnings either on compile or execution.

If you run rack from command line you’ll see useful messages printed out to the terminal on stderr. If not then it looks like it goes to a log.txt file somewhere. I tend to only run from command line when developing.

Ah ok. that’s a useful tip - thanks!

I was also going to mention that compiling and running with address sanitizer can catch issues like this and more and it aborts immediately. But it’s not a supported build configuration so it’s probably more trouble than it’s worth at this stage :slightly_smiling_face:

no, it’s not more trouble than it’s worth. It’s a little bit of trouble, and you can’t do it on windows. It’s for sure worth it if you have a tricky problem.

1 Like