eBoard 🐉  ①⑧⑨
Written for SIA 2017/2018
eBoard.h
Go to the documentation of this file.
1 
6  #ifndef EBOARD_HEADER_GUARD
7  #define EBOARD_HEADER_GUARD
8  #pragma GCC diagnostic push
9  #pragma GCC diagnostic ignored "-Wall"
10  #pragma GCC diagnostic ignored "-Wextra"
11  #pragma pack(push)
12  #pragma pack(16)
13 
15  #define EBOARD_VERSION "3.1.17m"
16  #define EBOARD_VERSION_NBR 327
18  #define VALUE_TO_STRING(x) #x
20  #ifdef DOC
22  #define PREPROCESS_DEBUG 1
24  #endif
25  #define VALUE(x) VALUE_TO_STRING(x)
27  #ifndef PREPROCESS_DEBUG
29  #define PREPROCESS_DEBUG 0
30  #endif
31  #define PPERFORM_PRAGMA(str) _Pragma(#str)
33 
34  #if PREPROCESS_DEBUG == 1
35  #pragma message("You are using eBoard-header " VALUE(EBOARD_VERSION) "{" VALUE(EBOARD_VERSION_NBR) "} written by EagleoutIce")
36  #define DEBUG_MSG(str) PPERFORM_PRAGMA(message ("" #str))
37  #define MACRO_MSG(mac,str) PPERFORM_PRAGMA(message("You set " #mac " to " VALUE(mac) ": " #str))
38  #else
39  #define DEBUG_MSG(str) ;
40  #define MACRO_MSG(mac,str) ;
41  #endif
42 
44  DEBUG_MSG("If you do not want any preprocessing information from this eBoard-Header set PREPROCESS_DEBUG to 0");
45 
46  //i am a guard... leave me alone :D
47  #ifdef DOC
48  DEBUG_MSG("Documentation macro SET => Full doc features enabled");
49  #define ARDUINO 200
50 
53  #define EBOARD_I2C 0x1
54 
58  #define EBOARD_LCD 0x1
59 
62  #define EBOARD_SHIFT_REGISTER 0x1
63 
66  #define EBOARD_BLUETOOTH 0x1
67 
70  #define REPT_TASK
71 
74  #define __AVR_ATmega2560__
75 
78  #define __AVR_ATmega328P__
79 
82  #define EBOARD_NEO 0x1
83 
88  #define HIGHSPEED
89  #define __AVR__
91  #endif
92 
93 
94  #if defined(ARDUINO) //general platform-check [No tab]
95  #include <avr/pgmspace.h>
100  namespace eagle_impl {}
101  using namespace eagle_impl;
102  #ifndef EBOARD_GUESSPATH
103  DEBUG_MSG("You are using Guesspath! Necessary libraries for eBoard will be included automatically");
107  #define EBOARD_GUESSPATH 0x1
108  #else
109  DEBUG_MSG("You are not using Guesspath! Necessary libraries for eBoard have to be included manually");
110  #endif
111 
114  #define main eVirtual_main //main has a different meaning^^
115 
116  #if ARDUINO >= 100 //this could be only Arduino.h but this snippet is portable :D
117  #include "Arduino.h"
118  #else
119  #include <wiring.h>
120  #endif
121 
122  #if not ( defined(__AVR_ATmega2560__) || defined(__AVR_ATmega328P__))
123  #error "This library was build for ARDUINO UNO R3 Aand ARDUINO MEGA 2560!"
124  #endif
125 
126  #include "source/eagle_Comfort.h"
127 
128  #if defined(__AVR_ATmega2560__)
129  DEBUG_MSG("Building for Arduino Mega with ATmega2560");
133  #define PIN_MAX 0x32 //53 pins to address - 4 !!53 is SS
134  #else
135  DEBUG_MSG("Building for Arduino Uno or Nano with ATmega328P");
136  #define PIN_MAX 0xA // 13 Pins to address - 4 !!10 is SS
137  #endif
138 
139  #include <avr/io.h>
140  #include <avr/interrupt.h>
141 
142  #if EBOARD_I2C > 0x0 && EBOARD_GUESSPATH > 0x0
143  DEBUG_MSG("You enabled I²C features");
144  #ifndef twi_h
145  #define twi_h
146  #ifndef TwoWire_h //because it will be included ._.
147  //#define ATMEGA8
148  #include "source/eagle_Twi.h"
149  #endif
150  #endif
151 
152  #ifndef TwoWire_h
153  #include "source/eagle_TwoWire.h"
154  #endif
155 
156  #else
157  DEBUG_MSG("You disabled I²C");
158  #endif
159 
162  #ifndef EBOARD_USE_SPI
163  #define EBOARD_USE_SPI 0x1
164  #endif
165 
166  #if EBOARD_USE_SPI > 0x0
167  DEBUG_MSG("You enabled SPI");
168  #ifndef _SPI_H_INCLUDED
169  #define _SPI_H_INCLUDED
171  #include "source/eagle_SPI.h"
172  #endif
173  #else
174  DEBUG_MSG("You disabled SPI");
175  #endif
176 
177  #if (EBOARD_I2C > 0x0) && (EBOARD_LCD > 0x0)
178  #include <avr/pgmspace.h>
179  DEBUG_MSG("You enabled LCD");
180  #endif
181 
186  static bool STOP = false;
187 
191  #ifdef IGNORE_SIZE
192  DEBUG_MSG("You defined IGNORE_SIZE: byte will be used");
193  typedef byte optVAL_t;
194  #else
195  DEBUG_MSG("You did not define IGNORE_SIZE: int will be used");
196  typedef int optVAL_t;
197  #endif
198 
202  #ifndef EBOARD_DEBUG_MODE
203  #define EBOARD_DEBUG_MODE 0x1
204  #endif
205 
206  #if EBOARD_DEBUG_MODE > 0x0
207  MACRO_MSG(EBOARD_DEBUG_MODE,"Serial feedback will be send to Computer");
208  #else
209  MACRO_MSG(EBOARD_DEBUG_MODE, "No Serial feedback!");
210  #endif
211 
214  #ifndef EBOARD_NANO
215  #define EBOARD_NANO 0x0
216  #endif
217 
218  #if EBOARD_NANO > 0x0 || defined(DOC)
219  #ifndef EBOARD_NANO_STEER
220 
223  #define EBOARD_NANO_STEER 12
224  #endif
225  #ifndef EBOARD_NANO_MAIN
226 
229  #define EBOARD_NANO_MAIN 13
230  #endif
231  MACRO_MSG(EBOARD_NANO,"Using Arduino NANO environment [e.g. remove SoccerBoard]");
232  #if PREPROCESS_DEBUG > 0x1
233  #pragma message("Using " VALUE(EBOARD_NANO_STEER) " as data pin for STEERING MOTOR")
234  #pragma message("Using " VALUE(EBOARD_NANO_MAIN) " as data pin for MAIN (Driving) MOTOR")
235  #endif
236  #else
237  MACRO_MSG(EBOARD_NANO,"Using Arduino UNO/MEGA environment");
238  #endif
239 
243  #ifndef EBOARD_CHECK_PINS
244  #define EBOARD_CHECK_PINS 0x1
245  #endif
246 
247  #if EBOARD_CHECK_PINS > 0x0
248  MACRO_MSG(EBOARD_CHECK_PINS,"Check for Pins enabled");
249  #else
250  MACRO_MSG(EBOARD_CHECK_PINS,"Check for Pins disabled");
251  #endif
252 
253  #ifndef EBOARD_SHIFT_REGISTER
254 
257  #define EBOARD_SHIFT_REGISTER 0x0
258  #endif
259 
260  #if EBOARD_SHIFT_REGISTER > 0x0
261  MACRO_MSG(EBOARD_SHIFT_REGISTER,"Shiftregister enabled");
262  #else
263  MACRO_MSG(EBOARD_SHIFT_REGISTER,"Shiftregister disabled");
264  #endif
265 
269  #ifndef EBOARD_CHECK_PINS_PWM
270  #define EBOARD_CHECK_PINS_PWM 0x1
271  #endif
272 
273  #if EBOARD_CHECK_PINS_PWM > 0x0
274  MACRO_MSG(EBOARD_CHECK_PINS_PWM,"Check for PWM-Pins enabled");
275  #else
276  MACRO_MSG(EBOARD_CHECK_PINS_PWM,"Check for PWM-Pins disabled");
277  #endif
278 
282  #ifndef EBOARD_DEBUG_SPEED
283  #define EBOARD_DEBUG_SPEED 9600
284  #endif
285  #if PREPROCESS_DEBUG > 0x0
286  #pragma message("Set Debugging speed to " VALUE(EBOARD_DEBUG_SPEED))
287  #endif
288 
289 
293  #ifndef EBOARD_SPI_SERVO_MAX
294  #define EBOARD_SPI_SERVO_MAX 2
295  #endif
296  #if PREPROCESS_DEBUG > 0x0
297  #pragma message("Set amount of used Servos to " VALUE(EBOARD_SPI_SERVO_MAX))
298  #endif
299 
302  #ifndef EBOARD_USE_UTILITY
303  #define EBOARD_USE_UTILITY 0x1
304  #endif
305  #if EBOARD_USE_UTILITY > 0x0
306  MACRO_MSG(EBOARD_USE_UTILITY,"Utility features will be implemented");
307  #else
308  MACRO_MSG(EBOARD_USE_UTILITY,"Utility features will not be implemented");
309  #endif
310 
314  #define EBOARD_COPY_AND_PASTE 0x1
315 
318  #ifndef EBOARD_PWM_SPE
319  #define EBOARD_PWM_SPE 1
320  #endif
321  #if PREPROCESS_DEBUG > 0x0
322  #pragma message("Set PWM interval to " VALUE(EBOARD_PWM_SPE) "s")
323  #endif
324 
325  #ifndef EBOARD_I2C
326 
329  #define EBOARD_I2C 0x0 //disabled by default
330  #endif
331 
332  #ifndef EBOARD_BLUETOOTH
333 
336  #define EBOARD_BLUETOOTH 0x0
337  #endif
338 
339  #if EBOARD_BLUETOOTH > 0x0
340  MACRO_MSG(EBOARD_BLUETOOTH,"Bluetooth controls enabled");
341  #else
342  MACRO_MSG(EBOARD_BLUETOOTH,"Bluetooth controls disabled");
343  #endif
344 
348  #ifndef EBOARD_CLAMP
349  #define EBOARD_CLAMP 0x1
350  #endif
351  #if EBOARD_CLAMP > 0x0
352  MACRO_MSG(EBOARD_CLAMP,"Motor Range is set to [0;1023]");
353  #else
354  MACRO_MSG(EBOARD_CLAMP,"Motor Range is set to [-300;300]");
355  #endif
356 
357  #ifndef EBOARD_NEO
358 
361  #define EBOARD_NEO 0x0
362  #endif
363  #if EBOARD_NEO > 0x0
364  MACRO_MSG(EBOARD_NEO,"Adafruit Neo-Pixel support enabled");
365  #else
366  MACRO_MSG(EBOARD_NEO,"Adafruit Neo-Pixel support disabled");
367  #endif
368 
372  #ifndef EBOARD_USE_RESET
373  #define EBOARD_USE_RESET 0x1
374  #endif
375 
376  #if EBOARD_USE_RESET > 0x0
377  #include <avr/wdt.h>
378  MACRO_MSG(EBOARD_USE_RESET,"Software-Reset is available" );
379  #else
380  MACRO_MSG(EBOARD_USE_RESET,"Software-Reset is not available" );
381  #endif
382 
386  #ifndef PIN_BLUETOOTH_STATE
387  #if defined(__AVR_ATmega2560__)
388  #define PIN_BLUETOOTH_STATE 0x13 // 19
389  #else
390  #define PIN_BLUETOOTH_STATE 0x2
391  #endif
392  #endif
393 
397  #ifndef PIN_BLUETOOTH_RX
398  #if defined(__AVR_ATmega2560__)
399  #define PIN_BLUETOOTH_RX 0x13 // 19
400  #else
401  #define PIN_BLUETOOTH_RX 0x2
402  #endif
403  #endif
404 
408  #ifndef PIN_BLUETOOTH_TX
409  #if defined(__AVR_ATmega2560__)
410  #define PIN_BLUETOOTH_TX 0x12 // 18
411  #else
412  #define PIN_BLUETOOTH_TX 0x3
413  #endif
414  #endif
415 
419  #ifndef PIN_MOTOR_DIR
420  #define PIN_MOTOR_DIR 0x4
421  #endif
422 
426  #ifndef PIN_MOTOR_SPE
427  #define PIN_MOTOR_SPE 0x5
428  #endif
429 
433  #ifndef PIN_SHIFT_CLK
434  #define PIN_SHIFT_CLK 0x6
435  #endif
436 
439  #ifndef PIN_SHIFT_DAT
440  #define PIN_SHIFT_DAT 0x7
441  #endif
442 
445  #ifndef PIN_SHIFT_LAT
446  #define PIN_SHIFT_LAT 0x8
447  #endif
448 
449 
450  //done by arduino
451  //if this has an effect... something went wrong :D
452  #ifndef HIGH
453  #define HIGH 1
454  #endif
455  #ifndef LOW
456  #define LOW 0
457  #endif
458 
459  #if (EBOARD_BLUETOOTH > 0x0) && defined(__AVR_ATmega328P__)
460  #if EBOARD_GUESSPATH > 0x0
461  #ifndef SoftwareSerial_h
462  //again to resolve including errors we'll include the SoftwareSerial cpp file
463  #define SoftwareSerial_h
465  #endif
466  #endif
467 
473  #endif
474 
475  #if EBOARD_DEBUG_MODE > 0x0
476 
479  #define __ASSERT_USE_STDERR
480  #include "source/eagle_Assert.h"
481  #endif
482  #include "source/eagle_Checks.h"
483  #if EBOARD_BLUETOOTH > 0x0
484  #include "source/eagle_Bluetooth.h"
485  #endif
486 
487  #if EBOARD_SHIFT_REGISTER > 0x0
488  #include "source/eagle_ShiftExt.h"
489  #endif
490 
491  #include "source/eagle_PinCtrl.h"
492 
493  #ifdef REPT_TASK
494  extern void rept_task(void);
495  DEBUG_MSG("You defined REPT_TASK: you have to define rept_task(void)!");
496  #else
497  DEBUG_MSG("You did not define REPT_TASK: rept_task(void) will not have any effect");
498  #endif
499 
500  #if EBOARD_USE_SPI > 0x0 && (EBOARD_NANO == 0x0)
501  #include "source/eagle_ServoCds55.h"
502 
504  ServoCds55 _servoHandler;
505  #endif
506 
507  #if EBOARD_COPY_AND_PASTE > 0x0 && EBOARD_NANO == 0
508  #include "source/eagle_SoccerBoard.h"
509  #include "source/eagle_I2CInOut.h"
510 
511  #include "source/eagle_AX12Servo.h"
513 
514  #endif
515  #if EBOARD_BLUETOOTH > 0x0
516  #include "source/eagle_RB14Scan.h"
517 
518  #endif
519  #if EBOARD_I2C > 0x0
520  #include "source/eagle_I2C.h"
521  //Beginof LCD configuration
522  #if EBOARD_LCD > 0x0
523  #include "source/eagle_LCD.h"
524  #endif
525  #endif
526  #if EBOARD_NEO > 0x0
527  #include "source/eagle_NeoPixel.h"
528  #endif
529  #if EBOARD_NANO > 0x0 || defined(DOC)
530  //offer more functions
531  #if EBOARD_GUESSPATH > 0x0
532  #include "source/eagle_Servo.h"
533  #endif
534  #endif
535 
536  #if EBOARD_COPY_AND_PASTE > 0x0
537  #include "source/eagle_ReptTask.h"
538  #include "source/eagle_Setup.h"
540  void loop(void);
542  void loop(void){
543  //shall be empty
544  }
546  #endif
547  #if EBOARD_NANO > 0x0 || defined(DOC)
548  #include "source/eagle_NanoMot.h"
549  #endif
550 
551 #else
552  #error This library is build for arduino-devices and should be used only in the Arduino IDE or with a similar linking process
553 #endif
554 #pragma GCC diagnostic pop
555 #pragma pack(pop)
556 
557 #endif
#define EBOARD_CHECK_PINS
Definition: eBoard.h:244
SoftwareSerial _serial(0x13, 0x12)
this is the recomenned-to-use _serial object for bluetooth communcation :D
#define EBOARD_BLUETOOTH
Definition: eBoard.h:66
#define EBOARD_USE_UTILITY
Definition: eBoard.h:303
this namespace contains all the Don&#39;t use manually classes ;)
#define PIN_BLUETOOTH_RX
Definition: eBoard.h:399
#define EBOARD_CLAMP
Definition: eBoard.h:349
static bool STOP
Definition: eBoard.h:186
#define EBOARD_NANO
Definition: eBoard.h:215
#define EBOARD_CHECK_PINS_PWM
Definition: eBoard.h:270
#define EBOARD_NEO
Definition: eBoard.h:82
#define EBOARD_SHIFT_REGISTER
Definition: eBoard.h:62
[SPI] This is used to communicate with the smart servo shield &#160;&#160;&#160;&#160;&#160;&#160;&#160; Don&#39;t use manually ...
#define PIN_BLUETOOTH_TX
Definition: eBoard.h:410
#define EBOARD_USE_RESET
Definition: eBoard.h:373
int optVAL_t
Definition: eBoard.h:196
#define EBOARD_DEBUG_MODE
Definition: eBoard.h:203
This is used to avoid path resolving issues and defines the common known Arduino SoftwareSerial inter...