There is a lot of useful information here:
Arduino IDE 1.5 3rd party Hardware specification · arduino/Arduino Wiki · GitHub
Unfortunately it isn't really a guide. Arduino has actually been considering using the technical writer supplied to us via the Google Season of Docs program to write such a guide, but there is only one technical writer allocated and a list of potential projects so it's not certain whether that will be the project chosen by the writer.
I think a lot of the hardware core authors used existing hardware cores as a model when they wrote their own. If you can find a core that is somewhat along the lines of what you want to do, then it makes things much easier. There is the ever popular Arduino AVR Boards:
GitHub - arduino/ArduinoCore-avr: The Official Arduino AVR core
Arduino SAMD Boards:
GitHub - arduino/ArduinoCore-samd: Arduino Core for SAMD21 CPU
ESP8266:
GitHub - esp8266/Arduino: ESP8266 core for Arduino
MightyCore:
GitHub - MCUdude/MightyCore: Arduino hardware package for ATmega1284, ATmega644, ATmega324, ATmega324PB, ATmega164, ATmega32, ATmega16 and ATmega8535
ATTinyCore:
GitHub - SpenceKonde/ATTinyCore: Arduino core for ATtiny 1634, 828, x313, x4, x41, x5, x61, x7 and x8
and so on. I actually published a list of all known Arduino hardware cores:
inoplatforms/ino-hardware-package-list.tsv at master · per1234/inoplatforms · GitHub
The great thing is that Arduino's hardware system allows you to reference resources from other cores:
Arduino IDE 1.5 3rd party Hardware specification · arduino/Arduino Wiki · GitHub
That allows you to create custom hardware cores with only a couple files. An example is carlosefr/atmega:
atmega/avr at master · carlosefr/atmega · GitHub
Notice how the entire core is only two files because it references resources from Arduino AVR Boards!
BAM.. Thank you!!
It's not clear to me what you mean by that.
I have a header font.h with a lot of ASCII-Signs. I included it in a matrix-libary (in .ccp file) to put out an array from a character. I want to know what is the right way ("programmer convention") to include the file:
-
the font.h with a font.cpp file
-
only the font.h (now, my option)
-
only the font.h and initialize the arrays with extern
#ifndef __FONT8X8_H__
#define __FONT8X8_H__
uint8_t ascii_8x5_whitespace[8] ={
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000000,
0b00000011
};
*////////////////////
MANY ARRAYS
////////////////////*
uint8_t *ascii [] = {
ascii_8x5_whitespace,
ascii_8x5_exclamationmark,
ascii_8x5_doublequote,
ascii_8x5_hash,
ascii_8x5_dollar,
ascii_8x5_percent,
ascii_8x5_ampersand,
ascii_8x5_singlequote,
ascii_8x5_openparenthesis,
ascii_8x5_closeparenthesis,
ascii_8x5_asterisk,
ascii_8x5_plus,
ascii_8x5_comma,
ascii_8x5_minus,
ascii_8x5_dot,
ascii_8x5_slash,
ascii_8x5_0,
ascii_8x5_1,
ascii_8x5_2,
ascii_8x5_3,
ascii_8x5_4,
ascii_8x5_5,
ascii_8x5_6,
ascii_8x5_7,
ascii_8x5_8,
ascii_8x5_9,
ascii_8x5_colon,
ascii_8x5_semicolon,
ascii_8x5_lessthan,
ascii_8x5_equal,
ascii_8x5_greaterthan,
ascii_8x5_questionmark,
ascii_8x5_at,
ascii_8x5_A,
ascii_8x5_0b,
ascii_8x5_C,
ascii_8x5_D,
ascii_8x5_E,
ascii_8x5_F,
ascii_8x5_G,
ascii_8x5_H,
ascii_8x5_I,
ascii_8x5_J,
ascii_8x5_K,
ascii_8x5_L,
ascii_8x5_M,
ascii_8x5_N,
ascii_8x5_O,
ascii_8x5_P,
ascii_8x5_Q,
ascii_8x5_R,
ascii_8x5_S,
ascii_8x5_T,
ascii_8x5_U,
ascii_8x5_V,
ascii_8x5_W,
ascii_8x5_X,
ascii_8x5_Y,
ascii_8x5_Z,
ascii_8x5_openbracket,
ascii_8x5_backslash,
ascii_8x5_closebracket,
ascii_8x5_carat,
ascii_8x5_underscore,
ascii_8x5_backquote,
ascii_8x5_a,
ascii_8x5_b,
ascii_8x5_c,
ascii_8x5_d,
ascii_8x5_e,
ascii_8x5_f,
ascii_8x5_g,
ascii_8x5_h,
ascii_8x5_i,
ascii_8x5_j,
ascii_8x5_k,
ascii_8x5_l,
ascii_8x5_m,
ascii_8x5_n,
ascii_8x5_o,
ascii_8x5_p,
ascii_8x5_q,
ascii_8x5_r,
ascii_8x5_s,
ascii_8x5_t,
ascii_8x5_u,
ascii_8x5_v,
ascii_8x5_w,
ascii_8x5_x,
ascii_8x5_y,
ascii_8x5_z,
ascii_8x5_openbrace,
ascii_8x5_bar,
ascii_8x5_closebrace,
ascii_8x5_tilde
};
#endif /* __FONT8X8_H__ */
If you have a proper include guard, you should have no problem with multiple #include directives for a library. However, an include guard only protects against multiple inclusions in the same translation unit. It does not protect against inclusions in multiple translation units (nor would you want it to). The .ino files of your sketch are a separate translation unit from .cpp or .c files in a library or even in your sketch. For this reason, it is possible to write code in a .h file that causes a compilation error when the file is #included in multiple translation units. However, it's certainly possible to fix that issue. If you want specific help with the issue, you'll need to post your code.
When i include the font.h file in the matrix-library and in the main.cpp i get an error!
I thought the preprocessor directives prevent this. (Double Insertion)