CodeBlocks Arduino IDE - real C++ IDE for Arduino development (rev.20130827)

Another question: in the Arduino IDE, I can add a new tab and add another file to the project which I can edit. I do this to break up long sketches into separate, smaller chunks. When I re-open the project, it re-opens all the necessary files in tabs for me to work on. How do I accomplish this in CodeBlocks?

Click "Project" menu and choose "Add Files".

CodeBlocks Arduino slowing down?

I've noticed that Arduino CodeBlocks seems to be slowing down as the newer versions come out - has anyone else experienced this?

I've been using Arduino Codeblocks since release 10120127, and back then, the IDE moved right along - the last couple of versions leading up to 20130428 seem to "hesitate" more often. I've used the same versions on my laptop; with the earlier versions running smoothly, and the later ones hesitating for very noticeable periods of time. Checking the code blocks forums, it looked like the code completion plugin might be the culprit, and sure enough, disabling it has things running smoothly. However, I went back and checked 10120127, and it uses the same 1.0 version of code completion as 20130428, so plugin version isn't the issue. I'd hate to have to leave code completion disabled, as it's one of the real key feature of the IDE.

I've also checked the running processes in windows task manager, and can definitely say CodeBlocks is the only thing running.

Anyone else?

I didn't experience noticable slowing down on my end. I have been modifying and improving the building and uploading stage for Arduino but didn't change anything to the IDE's code editing and completion part.

@Stanley firstly, thanks for this excellent project. Came across this, thanks to another post on arduino forums.

Have gone through this entire thread, and did see one reference to what I was looking for, but no clear answer. So kindly bear with me on these questions about ArduinoDev CodeBlocks IDE (I call it ACI for rest of my mail).

  1. Standard ArduinoIDE has settings to select the Arduino board type. How come, there is nothing similar (or that I could find) on ACI ? In the project creation Wizard, I see only 2 choices "Standard (8-bit AVR)" and "Due", however even between the 8-bit AVR boards/uC's there's a lot of difference in terms of peripherals, pins etc.

  2. To use non-standard arduino-core's like MIT's High-Low Tech (HLT) arduino core for attiny45/85 or @CodingBadly's Arduino-tiny core ? Is there any way to use those cores ?

  3. Was curious about how to add custom Arduino libraries, but I found the answer in one of the replies in this thread. (Just to show that I've read through :slight_smile: )

  4. Do you plan to set up a FAQ re your IDE ? This thread is currently 5-pages long, and not difficult to miss some point in an answer. A FAQ, when you get time, would be so useful.

I am really looking forward to using this IDE. It is just what I was looking for. I having some issues with it right now, though. To use some library, I believe you said all you have to do is copy the files into your project folder and then include them.

So...I copied the normal Servo.h and Servo.cpp files into my project, and then added them to my project. However, when I build, I got four identical errors on four similar areas of code in Servo.cpp

error: cannot convert 'uint8_t* {aka unsigned char*}' to 'volatile uint16_t* {aka volatile short unsigned int*}' for argument '2' to 'void handle_interrupts(timer16_Sequence_t, volatile uint16_t*, volatile uint16_t*)'|

and the four pieces of code are identical, except the timer numbers are changed. the error is on the handle_interrupts line. If anyone is looking for this part of the Servo.cpp code, the first error is on line 105

#if defined(_useTimer1)
SIGNAL (TIMER1_COMPA_vect) 
{ 
  handle_interrupts(_timer1, &TCNT1, &OCR1A); 
}
#endif

I would love to get this working because this seems a much better IDE and i have been looking for an Arduino simulator.

Thanks
Gabriel

Question about CodeBlocks, does it grey out or otherwise highlight any non-functional code inside #if and #ifdef blocks ?


Rob

Hi,

I just installed CodeBlocks (Revision 20130402), and I have tried to use it with my Arduino Mega 2560. It builds without any issues, but it gives an "error generating HEX file" message.

I have just created the default "LED on for one second, then off for one second" routine that is included by default when you create a new project. I saw some people asking the same questions before, but I can not see any specific resolution.

Can anyone please give some advice - or is this a known bug in CodeBlocks when using it with say Arduino Mega?

Thanks!

How do you use the WIRE.h library with the simulator (ARDUSIM)? Cant find a way of adding libraries to a project.

I have a question?
Serial.or::or-> How to automatically prompt members

I downloaded CodeBlocks and tried to open a simple test project and compiling it.

But nothing compiles, not even a single example:

  • A lot of compiler errors which I could eliminate by setting -fpermissive. But why? Why no problems on Arduino IDE??
  • A lot of cannot open/find/missing header file

I tried to add files to the project, but that only results in more compiler errors in the Arduino files (like malloc.c). Some of the header files still can't be found, although I added the complete Arduino libraries folder (recursively) to the project...

So I'm doing something wrong, but can't find any manual to setup codeblocks for the Arduino environment and get a WORKING environment that does compile existing sketches and libraries, just as the Arduino IDE...

Update @8 July:
I downloaded Stanleys ArduinoOBD / obdlogger, and was able to compile that project using Code::Blocks, so at least I know that the intallation of Code::Blocks is ok!
Now if I can find why this project compiles fine, and mine not, I guess I found the problem :stuck_out_tongue:

I really like Code::Blocks features, so must find a way to compile my own sketches and libraries!

gabriel42:

error: cannot convert 'uint8_t* {aka unsigned char*}' to 'volatile uint16_t* {aka volatile short unsigned int*}' for argument '2' to 'void handle_interrupts(timer16_Sequence_t, volatile uint16_t*, volatile uint16_t*)'|

I got the same error today.

Hello,

I have exact same problem and didn't find answer.... can anybody help? If I start ArduinoBuilder manually and select file, it works. I guess there is a problem with settings in CodeBlocks? I tried some, but no success.

I've downloaded version 20130704, but when installed, it says ver 12.11 build nov 25 2012 !?

Thanks,

Damo

janleroux:
Hi,

I just installed CodeBlocks (Revision 20130402), and I have tried to use it with my Arduino Mega 2560. It builds without any issues, but it gives an "error generating HEX file" message.

I have just created the default "LED on for one second, then off for one second" routine that is included by default when you create a new project. I saw some people asking the same questions before, but I can not see any specific resolution.

Can anyone please give some advice - or is this a known bug in CodeBlocks when using it with say Arduino Mega?

Thanks!

Did you choose the board type?

Stanley, board is selected properly in Codeblocks and in Arduino builder (mega2560).

It works ok, if I compile, build in Codeblocks and then manually start Arudino builder, choose hex file manually and upload.

I guess something is wrong in codeblocks porting to arduino builder, but all is original settings, I tried some alterations, but no success, then I owerwrite it with original.

Damo

So error only occurs when you use Arduino Builder manually?
I recommend downloading a complete Arduino Builder if you want to use it manually.
http://www.downloadbestsoft.com/Arduino-Builder.html

No, when I use it manually it works ok.

When it is called from codeblocks error happens.

Hello,

me again :). Stupid windows 7, I think from XP they are getting worse and worse.

I solved the problem - project shouldn't be in the c:\users folder!

Ok, and how do you recompile-rebuild so that the hack starts to work?

TIA,

Fernando.

stanleyhuang:
Actully my long-term goal is to implement a simulator which acts like a http server and use HTML to render the simulation.
About hacking into arduino core files, taking digitalWrite as an example, I just added one line at the end like this:

void digitalWrite(uint8_t pin, uint8_t val)

{
uint8_t timer = digitalPinToTimer(pin);
uint8_t bit = digitalPinToBitMask(pin);
uint8_t port = digitalPinToPort(pin);
volatile uint8_t *out;

if (port == NOT_A_PIN) return;

// If the pin that support PWM output, we need to turn it off
// before doing a digital write.
if (timer != NOT_ON_TIMER) turnOffPWM(timer);

out = portOutputRegister(port);

uint8_t oldSREG = SREG;
cli();

if (val == LOW) {
	*out &= ~bit;
} else {
	*out |= bit;
}

SREG = oldSREG;

#ifdef ARDUSIM
    fprintf(stderr, "[MCU] Pin %d state changed to %s\n", pin, val ? "HIGH" : "LOW");
#endif
}





> tianshuo:
> I see them alright, but I'm not sure where should I start from. I guess maybe the simulator could listen to a port for signals?
> Could someone give an example using wiring_analog.c?

The simulation code is in the core files (a different version). There is no need to rebuild. It is built and linked with sketch.