diff --git a/Accessories.zip b/Accessories.zip index a8a2de8..06035ca 100644 Binary files a/Accessories.zip and b/Accessories.zip differ diff --git a/History/Accessories.1.1.1.zip b/History/Accessories.1.1.1.zip new file mode 100644 index 0000000..06035ca Binary files /dev/null and b/History/Accessories.1.1.1.zip differ diff --git a/extras/Doc/AccessoriesCircularBuffer_8cpp_source.html b/extras/Doc/AccessoriesCircularBuffer_8cpp_source.html index b5c69af..9ccfe34 100644 --- a/extras/Doc/AccessoriesCircularBuffer_8cpp_source.html +++ b/extras/Doc/AccessoriesCircularBuffer_8cpp_source.html @@ -95,9 +95,9 @@
-
1 /*************************************************************
2 project: <Accessories>
3 author: <Thierry PARIS>
4 description: <Class for a circular buffer of data stored in EEPROM>
5 *************************************************************/
6 
7 // Copied from EEPROMExtent library
8 
9 #include "Accessories.h"
10 #ifndef NO_EEPROM
11 #include "AccessoriesCircularBuffer.hpp"
12 #include <EEPROM.h>
13 
14 /*
15 A circular buffer is a way to reduce the use of each EEPROM cell,
16 and improve life time of the full EEPROM memory.
17 An index of bytes is stored at the beginning of the area.
18 Each index represents a data area.
19 
20 |0|1|2|3|4||---0---|---1---|---2---|---3---|---4---|
21 
22 */
23 
24 byte AccessoriesCircularBuffer::FindEnd()
25 {
26  /*
27  prev is the previous value from the item in the list
28  |..|..|prev|i|..|..|
29 
30  we begin with the first item of the list. In this case, the previous is the last one:
31  |i|..|..|..|..|prev|
32  */
33 
34  int prevpos = this->StartListPos + this->ReplicaNumber - 1;
35  byte prev = EEPROM.read(prevpos);
36 
37  for (int i = 0; i < this->ReplicaNumber; i++)
38  {
39  int pos = this->StartListPos + i;
40 
41  // Checks it the current value is really the previous value + 1 :
42  // 4 must be 3+1, 0 must be 255 + 1 !
43  if (prev + 1 != EEPROM.read(pos))
44  return prevpos - this->StartListPos;
45 
46  prev = EEPROM.read(pos);
47  prevpos = pos;
48  }
49 
50  // Should never reach this code !
51 
52  return 255;
53 }
54 
56 {
57  for (int i = this->StartListPos; i < this->StartListPos + (this->ItemSize + 1) * this->ReplicaNumber; i++)
58  EEPROM.write(i, 0);
59 }
60 
62 {
63  byte place = FindEnd();
64  return this->StartListPos + this->ReplicaNumber + (this->ItemSize * place);
65 }
66 
68 {
69  byte place = FindEnd();
70  byte itemNb = EEPROM.read(this->StartListPos + place);
71 
72  place++;
73  if (place >= this->ReplicaNumber)
74  place = 0;
75 
76  EEPROM.update(this->StartListPos + place, ++itemNb);
77 
78  return this->StartListPos + this->ReplicaNumber + (this->ItemSize * place);
79 }
80 
81 #ifdef ACCESSORIES_DEBUG_MODE
82 void AccessoriesCircularBuffer::printStatus()
83 {
84  Serial.print(F("CB Status : "));
85  for (int i = 0; i < this->ReplicaNumber; i++)
86  {
87  Serial.print(F("|"));
88  Serial.print(EEPROM.read(this->StartListPos + i));
89  }
90  Serial.println(F("|"));
91 }
92 #endif
93 #endif
+
1 /*************************************************************
2 project: <Accessories>
3 author: <Thierry PARIS>
4 description: <Class for a circular buffer of data stored in EEPROM>
5 *************************************************************/
6 
7 // Copied from EEPROMExtent library
8 
9 #include "Accessories.h"
10 #ifndef NO_EEPROM
11 #include "AccessoriesCircularBuffer.hpp"
12 #include <EEPROM.h>
13 
14 /*
15 A circular buffer is a way to reduce the use of each EEPROM cell,
16 and improve life time of the full EEPROM memory.
17 An index of bytes is stored at the beginning of the area.
18 Each index represents a data area.
19 
20 |0|1|2|3|4||---0---|---1---|---2---|---3---|---4---|
21 
22 */
23 
24 byte AccessoriesCircularBuffer::FindEnd()
25 {
26  /*
27  prev is the previous value from the item in the list
28  |..|..|prev|i|..|..|
29 
30  we begin with the first item of the list. In this case, the previous is the last one:
31  |i|..|..|..|..|prev|
32  */
33 
34  int prevpos = this->StartListPos + this->ReplicaNumber - 1;
35  byte prev = EEPROM.read(prevpos);
36 
37  for (int i = 0; i < this->ReplicaNumber; i++)
38  {
39  int pos = this->StartListPos + i;
40 
41  // Checks it the current value is really the previous value + 1 :
42  // 4 must be 3+1, 0 must be 255 + 1 !
43  if (prev + 1 != EEPROM.read(pos))
44  return prevpos - this->StartListPos;
45 
46  prev = EEPROM.read(pos);
47  prevpos = pos;
48  }
49 
50  // Should never reach this code !
51 
52  return 255;
53 }
54 
56 {
57  for (int i = this->StartListPos; i < this->StartListPos + (this->ItemSize + 1) * this->ReplicaNumber; i++)
58  EEPROM.write(i, 0);
59 }
60 
62 {
63  byte place = FindEnd();
64  return this->StartListPos + this->ReplicaNumber + (this->ItemSize * place);
65 }
66 
68 {
69  byte place = FindEnd();
70  byte itemNb = EEPROM.read(this->StartListPos + place);
71 
72  place++;
73  if (place >= this->ReplicaNumber)
74  place = 0;
75 
76  EEPROM.update(this->StartListPos + place, ++itemNb);
77 
78  return this->StartListPos + this->ReplicaNumber + (this->ItemSize * place);
79 }
80 
81 #ifdef ACCESSORIES_DEBUG_MODE
82 void AccessoriesCircularBuffer::printStatus()
83 {
84  Serial.print(F("CB Status : "));
85  for (int i = 0; i < this->ReplicaNumber; i++)
86  {
87  Serial.print(F("|"));
88  Serial.print(EEPROM.read(this->StartListPos + i));
89  }
90  Serial.println(F("|"));
91 }
92 #endif
93 #endif
+ -
@@ -105,7 +105,7 @@ @@ -165,7 +165,7 @@

If this is defined, the Verbose mode lets you see all actions done by the library, but with a real flood of text to the console... It has no effect if ACCESSORIES_DEBUG_MODE is not activated.

-

Definition at line 463 of file Accessories.h.

+

Definition at line 470 of file Accessories.h.

@@ -180,7 +180,7 @@

If this is defined, the function Accessories::printAccessories() will become available. This is useful to try to understand why a port, or an accessory is not correctly defined. This function uses a lot of memory, so activate it only if necessary, and be careful about your program's memory. You can use the define PRINT_ACCESSORIES() in your sketch instead of a call to Accessories::printAccessories(). If ACCESSORIES_PRINT_ACCESSORIES is not defined, PRINT_ACCESSORIES is defined as empty, so you will not have a compilation error.

-

Definition at line 469 of file Accessories.h.

+

Definition at line 476 of file Accessories.h.

@@ -195,7 +195,7 @@

Default size of action stack.

-

Definition at line 321 of file Accessories.h.

+

Definition at line 328 of file Accessories.h.

@@ -210,7 +210,7 @@

This is used internally by DIO2.h

-

Definition at line 316 of file Accessories.h.

+

Definition at line 323 of file Accessories.h.

@@ -225,7 +225,7 @@

If this is defined, the state of all the library will not be saved to EEPROM.

-

Definition at line 471 of file Accessories.h.

+

Definition at line 478 of file Accessories.h.

@@ -240,7 +240,7 @@

If this is defined, the state of all the library will not be saved to EEPROM.

-

Definition at line 471 of file Accessories.h.

+

Definition at line 478 of file Accessories.h.

@@ -250,7 +250,7 @@
-Go to the documentation of this file.
1 //-------------------------------------------------------------------
2 #ifndef __accessories_H__
3 #define __accessories_H__
4 //-------------------------------------------------------------------
5 
298 // Add a '//' at the beginning of the line to be in
300 // release mode.
301 //#define ACCESSORIES_DEBUG_MODE
302 
304 // Verbose mode lets you see all actions done by the
305 // library, but with a real flood of text to console...
306 // Has no effect if ACCESSORIES_DEBUG_MODE is not activated.
307 //#define ACCESSORIES_DEBUG_VERBOSE_MODE
308 
310 // The function Accessories::printAccessories()
311 // is very heavy in program memory. So to avoid problems
312 // you can make this function available by uncomment the next line.
313 //#define ACCESSORIES_PRINT_ACCESSORIES
314 
316 #define GPIO2_PREFER_SPEED 1
317 
318 #include "DIO2.h"
319 
321 #define ACTION_STACK_SIZE 5
322 
324 // Exclusion area
325 //
326 //NO_GROUP
327 // AccessoryGroup.cpp
328 // AccessoryGroup.hpp
329 //
330 //NO_MOTOR
331 // AccessoryMotor.cpp
332 // AccessoryMotor.hpp
333 // AccessoryMotorOneWay.cpp
334 // AccessoryMotorOneWay.hpp
335 // AccessoryMotorTwoWays.cpp
336 // AccessoryMotorTwoWays.hpp
337 // AFMotor.cpp
338 // AFMotor.hpp
339 //
340 //NO_LIGHT
341 // AccessoryBaseLight.cpp
342 // AccessoryBaseLight.hpp
343 // AccessoryLight.cpp
344 // AccessoryLight.hpp
345 // AccessoryLightMulti.cpp
346 // AccessoryLightMulti.hpp
347 //
348 //NO_MOTOR_LIGHT
349 // PortOnePin.cpp
350 // PortOnePin.hpp
351 // PortTwoPins.cpp
352 // PortTwoPins.hpp
353 // PortTwoPinsEnable.cpp
354 // PortTwoPinsEnable.hpp
355 // PortSpeedDirBrake.cpp
356 // PortSpeedDirBrake.hpp
357 //
358 //NO_SERVO
359 // AccessoryServo.cpp
360 // AccessoryServo.hpp
361 // PortServo.cpp
362 // PortServo.hpp
363 // Servo.cpp
364 // Servo.hpp
365 //
366 //NO_SHIELDL293D
367 // PortShieldL293d.cpp
368 // PortShieldL293d.hpp
369 //
370 //NO_STEPPER
371 // AccessoryStepper.cpp
372 // AccessoryStepper.hpp
373 // DriverStepper.cpp
374 // DriverStepper.hpp
375 // PortStepper.cpp
376 // PortStepper.hpp
377 //
378 
379 //#define NO_GROUP
380 //#define NO_MOTOR
381 //#define NO_SERVO
382 //#define NO_STEPPER
383 //#define NO_LIGHT
384 //#define NO_SHIELDL293D
385 
386 #ifndef VISUALSTUDIO
387 #define NO_EEPROM
388 #endif
389 
390 #ifdef NO_MOTOR
391  #ifdef NO_LIGHT
392  #define NO_MOTOR_LIGHT
393  #endif
394  #ifndef NO_MOTORONEWAY
395  #define NO_MOTORONEWAY
396  #endif
397  #ifndef NO_MOTORTWOWAYS
398  #define NO_MOTORTWOWAYS
399  #endif
400 #endif
401 
402 // For Accessories library, L293D is not compatible with Arduino Due for the moment...
403 #ifdef ARDUINO_ARCH_SAM
404 #ifndef NO_SHIELDL293D
405  #define NO_SHIELDL293D
406 #endif
407 #endif
408 
410 
411 #include "Port.hpp"
412 
413 #ifndef NO_MOTOR
414 #include "AccessoryMotorOneWay.hpp"
415 #include "AccessoryMotorTwoWays.hpp"
416 #endif
417 #ifndef NO_SERVO
418 #include "AccessoryServo.hpp"
419 #endif
420 #ifndef NO_STEPPER
421 #include "AccessoryStepper.hpp"
422 #endif
423 #ifndef NO_LIGHT
424 #include "AccessoryLight.hpp"
425 #include "AccessoryLightMulti.hpp"
426 #endif
427 
428 #ifndef NO_GROUP
429 #include "AccessoryGroup.hpp"
430 #endif
431 
432 #ifndef NO_MOTOR_LIGHT
433 #include "PortOnePin.hpp"
434 #include "PortTwoPins.hpp"
435 #include "PortTwoPinsEnable.hpp"
436 #include "PortSpeedDirBrake.hpp"
437 #endif
438 
439 #ifndef NO_SHIELDL293D
440 #include "PortShieldL293d.hpp"
441 #endif
442 
443 #ifndef NO_SERVO
444 #include "PortServo.hpp"
445 #endif
446 
447 #ifndef NO_STEPPER
448 #include "PortStepper.hpp"
449 #endif
450 
451 #include "Accessories.hpp"
452 #endif
453 
454 #ifdef DOXYGEN_SPECIFIC
455 // DO NOT CHANGE THESE LINES IN THIS BLOCK 'DOXYGEN_SPECIFIC' : Only here for documentation !
456 
460 #define ACCESSORIES_DEBUG_MODE
461 
463 #define ACCESSORIES_DEBUG_VERBOSE_MODE
464 
469 #define ACCESSORIES_PRINT_ACCESSORIES
470 
471 #define NO_EEPROM
472 #endif
+Go to the documentation of this file.
1 //-------------------------------------------------------------------
2 #ifndef __accessories_H__
3 #define __accessories_H__
4 //-------------------------------------------------------------------
5 
305 // Add a '//' at the beginning of the line to be in
307 // release mode.
308 //#define ACCESSORIES_DEBUG_MODE
309 
311 // Verbose mode lets you see all actions done by the
312 // library, but with a real flood of text to console...
313 // Has no effect if ACCESSORIES_DEBUG_MODE is not activated.
314 //#define ACCESSORIES_DEBUG_VERBOSE_MODE
315 
317 // The function Accessories::printAccessories()
318 // is very heavy in program memory. So to avoid problems
319 // you can make this function available by uncomment the next line.
320 //#define ACCESSORIES_PRINT_ACCESSORIES
321 
323 #define GPIO2_PREFER_SPEED 1
324 
325 #include "DIO2.h"
326 
328 #define ACTION_STACK_SIZE 5
329 
331 // Exclusion area
332 //
333 //NO_GROUP
334 // AccessoryGroup.cpp
335 // AccessoryGroup.hpp
336 //
337 //NO_MOTOR
338 // AccessoryMotor.cpp
339 // AccessoryMotor.hpp
340 // AccessoryMotorOneWay.cpp
341 // AccessoryMotorOneWay.hpp
342 // AccessoryMotorTwoWays.cpp
343 // AccessoryMotorTwoWays.hpp
344 // AFMotor.cpp
345 // AFMotor.hpp
346 //
347 //NO_LIGHT
348 // AccessoryBaseLight.cpp
349 // AccessoryBaseLight.hpp
350 // AccessoryLight.cpp
351 // AccessoryLight.hpp
352 // AccessoryLightMulti.cpp
353 // AccessoryLightMulti.hpp
354 //
355 //NO_MOTOR_LIGHT
356 // PortOnePin.cpp
357 // PortOnePin.hpp
358 // PortTwoPins.cpp
359 // PortTwoPins.hpp
360 // PortTwoPinsEnable.cpp
361 // PortTwoPinsEnable.hpp
362 // PortSpeedDirBrake.cpp
363 // PortSpeedDirBrake.hpp
364 //
365 //NO_SERVO
366 // AccessoryServo.cpp
367 // AccessoryServo.hpp
368 // PortServo.cpp
369 // PortServo.hpp
370 // Servo.cpp
371 // Servo.hpp
372 //
373 //NO_SHIELDL293D
374 // PortShieldL293d.cpp
375 // PortShieldL293d.hpp
376 //
377 //NO_STEPPER
378 // AccessoryStepper.cpp
379 // AccessoryStepper.hpp
380 // DriverStepper.cpp
381 // DriverStepper.hpp
382 // PortStepper.cpp
383 // PortStepper.hpp
384 //
385 
386 //#define NO_GROUP
387 //#define NO_MOTOR
388 //#define NO_SERVO
389 //#define NO_STEPPER
390 //#define NO_LIGHT
391 //#define NO_SHIELDL293D
392 
393 #ifndef VISUALSTUDIO
394 #define NO_EEPROM
395 #endif
396 
397 #ifdef NO_MOTOR
398  #ifdef NO_LIGHT
399  #define NO_MOTOR_LIGHT
400  #endif
401  #ifndef NO_MOTORONEWAY
402  #define NO_MOTORONEWAY
403  #endif
404  #ifndef NO_MOTORTWOWAYS
405  #define NO_MOTORTWOWAYS
406  #endif
407 #endif
408 
409 // For Accessories library, L293D is not compatible with Arduino Due for the moment...
410 #ifdef ARDUINO_ARCH_SAM
411 #ifndef NO_SHIELDL293D
412  #define NO_SHIELDL293D
413 #endif
414 #endif
415 
417 
418 #include "Port.hpp"
419 
420 #ifndef NO_MOTOR
421 #include "AccessoryMotorOneWay.hpp"
422 #include "AccessoryMotorTwoWays.hpp"
423 #endif
424 #ifndef NO_SERVO
425 #include "AccessoryServo.hpp"
426 #endif
427 #ifndef NO_STEPPER
428 #include "AccessoryStepper.hpp"
429 #endif
430 #ifndef NO_LIGHT
431 #include "AccessoryLight.hpp"
432 #include "AccessoryLightMulti.hpp"
433 #endif
434 
435 #ifndef NO_GROUP
436 #include "AccessoryGroup.hpp"
437 #endif
438 
439 #ifndef NO_MOTOR_LIGHT
440 #include "PortOnePin.hpp"
441 #include "PortTwoPins.hpp"
442 #include "PortTwoPinsEnable.hpp"
443 #include "PortSpeedDirBrake.hpp"
444 #endif
445 
446 #ifndef NO_SHIELDL293D
447 #include "PortShieldL293d.hpp"
448 #endif
449 
450 #ifndef NO_SERVO
451 #include "PortServo.hpp"
452 #endif
453 
454 #ifndef NO_STEPPER
455 #include "PortStepper.hpp"
456 #endif
457 
458 #include "Accessories.hpp"
459 #endif
460 
461 #ifdef DOXYGEN_SPECIFIC
462 // DO NOT CHANGE THESE LINES IN THIS BLOCK 'DOXYGEN_SPECIFIC' : Only here for documentation !
463 
467 #define ACCESSORIES_DEBUG_MODE
468 
470 #define ACCESSORIES_DEBUG_VERBOSE_MODE
471 
476 #define ACCESSORIES_PRINT_ACCESSORIES
477 
478 #define NO_EEPROM
479 #endif
@@ -124,7 +124,7 @@ @@ -147,7 +147,7 @@ @@ -140,7 +140,7 @@