C++

From Torben's Wiki

General

Basic Variable Types

Number Types

C and C++ : char, int, long, unsigned long
Arduino   : byte, word
inttypes  : int8_t, int16_t, int32_t; uint8_t, uint16_t, uint32_t

preferable use inttypes!

inttype  : Arduino / C/C++
uint8_t  : byte
uint16_t : unsigned int
uint32_t : unsigned long

float

int to float

float f = float(i);

array

initialize all array values with 0

unsigned int barchart_data[128]; 
barchart_data[128] = {0};

shift array to left

for (unsigned int i = 0; i < px_x - 1; i++)
{ // ends at px_x - 2
  barchart_data[i] = barchart_data[i + 1];
}

length of array

sizeof(data) / sizeof(data[0])

Pre Compiler Defines

Using pre compiler defines it can be chosen which part of the sources are actually imported and compiled

#define TM_LOAD_DEVICE_OLED_128X32 1
...
#if TM_LOAD_DEVICE_OLED_128X32 == 1
#include "TM_OLED_128x32_Class.h"
auto my_oled = TM_OLED_128x32_Class();
#endif

Arduino specific