redeclaration of 'uint16_t print...or, "Frustrated incorporated"

I know, I know, I haven't done a "Welcome Post" yet...I'm getting to it...shortly...

So here's my dilemma...I'm new at C++ (only been at it for about a month). I am self-teaching the best way I know possible..Hands-on, and lots of reading and screwing things up (I learn best from my own mistakes). I don't (and won't) post things up like "I need help fast! I need someone to code for me..it's urgent!!"...God knows, I cringe and my sphincter puckers when I see people do that.

Well, here we go...I've been Googling and searching for a trick to this, but cannot find anything that makes sense. I'm trying to replicate a project I found online (https://howtomechatronics.com/projects/arduino-touch-screen-music-player-alarm-clock-project/).

I'm using most all the same components that he has listed, but I have a bigger TFT LCD that I want to use (Kuman for Arduino UNO R3 3.5 inch TFT Touch Screen with SD Card Socket w/ Tutorials in CD for Arduino Mega2560 Board SC3A-1,LCD/LED).

I've modified his original sketch as best as I could to fit this LCD (some of you may want to say "butchered", not modified..lol). I keep getting "redeclaration of 'uint16_t print " error messages for every 3rd or 4th instance of printing the color or text to the screen.

// Draws a colon between the hours and the minutes
    uint16_t fillcolor (0, 255, 0);
    uint16_t fillCircle (112, 65, 4);
    uint16_t fillcolor (0, 255, 0);
    uint16_t fillCircle (112, 85, 4);

    uint16_t setFont(SevenSegNumFont);
    uint16_t fillcolor(0, 255, 0);
    uint16_t printNumI(aHours, 32, 50, 2, '0');
    uint16_t printNumI(aMinutes, 128, 50, 2, '0');
    uint16_t fillcolor (255, 255, 255);
    uint16_t drawRoundRect (42, 115, 82, 145);
    uint16_t drawRoundRect (138, 115, 178, 145);
    uint16_t setFont(BigFont);
    uint16_t print("H", 54, 122);
    uint16_t print("M", 150, 122);

And this is the error I get:

alarm-mp3-bedside-clock:265:24: error: redeclaration of 'uint16_t fillcolor'

     uint16_t fillcolor (0, 255, 0);

                        ^

C:\Users\JD\Arduino Sketches\test\alarm-mp3-bedside-clock\alarm-mp3-bedside-clock.ino:260:14: note: 'uint16_t fillcolor' previously declared here

     uint16_t fillcolor(255, 255, 255);

              ^

alarm-mp3-bedside-clock:267:24: error: redeclaration of 'uint16_t fillcolor'

     uint16_t fillcolor (0, 255, 0);

                        ^

C:\Users\JD\Arduino Sketches\test\alarm-mp3-bedside-clock\alarm-mp3-bedside-clock.ino:260:14: note: 'uint16_t fillcolor' previously declared here

     uint16_t fillcolor(255, 255, 255);

              ^

alarm-mp3-bedside-clock:268:25: error: redeclaration of 'uint16_t fillCircle'

     uint16_t fillCircle (112, 85, 4);

                         ^

C:\Users\JD\Arduino Sketches\test\alarm-mp3-bedside-clock\alarm-mp3-bedside-clock.ino:266:14: note: 'uint16_t fillCircle' previously declared here

     uint16_t fillCircle (112, 65, 4);

              ^

alarm-mp3-bedside-clock:270:37: error: redeclaration of 'uint16_t setFont'

     uint16_t setFont(SevenSegNumFont);

                                     ^

C:\Users\JD\Arduino Sketches\test\alarm-mp3-bedside-clock\alarm-mp3-bedside-clock.ino:259:14: note: 'uint16_t setFont' previously declared here

     uint16_t setFont(BigFont);

As much as I hate to ask for help...the wife is getting pissed that I'm investing so much time, with no "visible results" that she can see..Hahahaaa...I can see the progress, but she wants the damn bedside clock/radio...

I'll attach the original code (Dejan_Nedelkovski_clock_radio), and mine (alarm-mp3-bedside-clock) as well, so you can see how I "modified" it...

If you can simply tell me what I did wrong, and what the fix is, I'd be more than happy to go through and fix it...I don't expect anyone to re-write the entire code for me...just gimme a clue...lol...I'm sure it's probably just a missing library...or something else I butchered...

Thanks for any assistance...You guys rock... :slight_smile:

Dejan_Nedelkovski_clock_radio.ino (17.8 KB)

alarm-mp3-bedside-clock.ino (18.6 KB)

   fillcolor (0, 255, 0);
    fillCircle (112, 65, 4);
    fillcolor (0, 255, 0);
    fillCircle (112, 85, 4);

etc, etc.

You're just writing a bunch of bad prototypes otherwise

What is this?

    uint16_t fillcolor (0, 255, 0);
    uint16_t fillCircle (112, 65, 4);
    uint16_t fillcolor (0, 255, 0);
    uint16_t fillCircle (112, 85, 4);

    uint16_t setFont(SevenSegNumFont);
    uint16_t fillcolor(0, 255, 0);
    uint16_t printNumI(aHours, 32, 50, 2, '0');
    uint16_t printNumI(aMinutes, 128, 50, 2, '0');
    uint16_t fillcolor (255, 255, 255);
    uint16_t drawRoundRect (42, 115, 82, 145);
    uint16_t drawRoundRect (138, 115, 178, 145);
    uint16_t setFont(BigFont);
    uint16_t print("H", 54, 122);
    uint16_t print("M", 150, 122);

It looks sort-of like function declarations in a prototype but there are real arguments instead of placeholders.

Each one is a "button" to be displayed on-screen. Attached are images that these lines are supposed to create. Fill colors and fill circles are the background colors behind the bitmaps of the buttons. ?

The above snippets are just a small part of the project...take a gander at the whole sketch so that it makes sense.

Arduino-Touch-Screen-Alarm-Clock-Screen.jpg

Arduino-Touch-Screen-Music-Player-Screen.jpg

@AWOL...I think I get what you're saying...use uint16_t for setup, but then remove them for the loop, right?

Each one is a "button" to be displayed on-screen.

Each what? Each statement? Those statements are not properly written. Function calls do not have a return type defined, so the statements are not function calls. Function prototypes do have a return type, but then every argument also has a type, which those statements do not have.

So, what kind of statements are they supposed to be?

Still, writing a type name in front of those function calls makes no sense. I suspect that a day with a good C++ tutorial would do you a LOT more good than just making up syntax and wondering why it doesn't work. Coding is one of those things that is nearly impossible to "learn by doing" if you don't also include reading he docs too.

If you do then you'll know what that uknt16_t means and you'll know where it goes or doesn't. It has nothing to do with setup or loop. It performs a specific function. Go find out what that is.

I've been reading, decoding, analyzing everything written that I can get my hands on...Do you have a recommendation for reading material? A website, pdf, book, magazine, etc? What's your #1 go-to to read? That's a sincere question..really.

Google "C++ tutorial" and there are several good ones that will be at the top of the results. Pick one. Any of them will be good to learn the basics. Don't just skim it though, read for understanding.

Also, a buddy just gave me a couple pdf's on Arduino coding..."Beginning Arduino Programming"...I know the basics...but not the "laws".

JDBlaine:
Also, a buddy just gave me a couple pdf's on Arduino coding..."Beginning Arduino Programming"...I know the basics...but not the "laws".

Just as a word of advice. Those work for some, but they don't always explain the laws of the language. So reading up on C++ might still be helpful to do first. You don't necessarily have to learn C++ first, but by spending a day reading through one of those tutorials you'll end up saying a lot more "Oh yeah ok I remember reading about that I see how that works now" and a lot less "wtf are they even talking about".

It's really the stuff like what it means when you put a type name like what you had above or what the brackets and braces are all about and when they matter and variable scope and stuff like that. That's the stuff you want to pick up on that the Arduino tutorials IMHO are weak on.

Do you have a recommendation for a C++ write-up that would be useful for that sort of background, and isn’t a 600+ page book that immediately delves deeper into desktop concepts like store and class inheritance that are seldom used in the arduino world?

K&R’s C book is almost ok, but of course has NO C++ info.

I used this one a lot. You just have to keep in mind that they're targeted towards a PC program, so it's cout instead of Serial.print. But all the concepts are the same of variables and functions and stucture.

http://www.cplusplus.com/doc/tutorial/

And here's another. Again, if you just google "C++ tutorial" there will be several that are all pretty similar in the first few hits.