Add tic.hpp library to C++ program in Codeblocks

I’m having a really tough time getting my C++ program in Codeblocks to recognize the tic.h or tic.hpp library. When I try to add #include <tic.hpp> it says that it can’t find the library. I’m fairly new to this but I have been able to control my stepper motor with the program that I wrote so I’m not completely clueless.
Specifically, I want to read the current position that the Tic thinks it is at before I start to move the motor. Setting a position and sending that to the Tic is pretty simple using ticcmd, but reading the current position doesn’t seem easy at all when using ticcmd. If I could access the tic.hpp library, I think that I could pretty easily access the current position.
I guess what I’m really asking for is help getting the tic.hpp library into Codeblocks or a simple way to read the current position that doesn’t requre the tic libraries. Thanks.

Hello.

Unfortunately, we are not very familiar with Codeblocks, so the support we can offer for it is limited. I do not know if our libraries will work with Codeblocks, but from your description, it sounds like the program cannot find the library files, so you might double check that you have installed the library and that Codeblocks is linking to it in the correct location. You might try posting on their forums for support for that.

If you want to read the current position without our library, you would essentially just need to send a “Get variable” command with an offset of 0x22, then parse the returned bytes. You can find more about the “Get variable” command in the “Command reference” section of the Tic user’s guide and the “Current position” variable in the “Variable reference” section.

The specifics of sending that command depend on whether you’re using the I2C or TTL serial interface. For that, you can refer to the “I2C command encoding” or “Serial command encoding” sections respectively.

By the way, please note that there is no .hpp file; I suspect you meant ‘.cpp’, but the file you should be using in the #include statement is the .h file.

Brandon

Thanks Brandon. What is the format for entering an offset of “wxyz” into the get variable command? I’ve tried a number of ways i.e. ticcmd -s–wxyz, ticcmd -status–“wxyz”, etc. All give the unknown option command.

Sorry for the confusion; in my previous post about the get variable command, I was referring to using the I2C or TTL serial interface on the Tic. The ticcmd command-line utility only works through the USB interface and does not have a direct equivalent to the “Get variables” command. (You can see the available options by just entering “ticcmd” into a command prompt.)

If you’re using ticcmd, you would want your porgram to run “ticcmd --status --full”, parse its output, and extract the information you are interested in. The output of that command uses the YAML format, so if you want to try that approach, you might start by looking for a compatible YAML parser.

By the way, I’m not sure if you meant “wxyz” to be a stand-in for an actual offset value, but please note that “wxzy” is not a valid offset. The offset for the “Current position” variable is 0x22.

Brandon