Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 6:9f8adf722fc3, committed 2018-11-19
- Comitter:
- rogeranderson
- Date:
- Mon Nov 19 19:00:30 2018 +0000
- Parent:
- 5:bb12605080d5
- Commit message:
- enable debug
Changed in this revision
| Counter.cpp | Show annotated file Show diff for this revision Revisions of this file |
| Counter.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/Counter.cpp Fri Nov 16 14:52:41 2018 +0000
+++ b/Counter.cpp Mon Nov 19 19:00:30 2018 +0000
@@ -1,10 +1,11 @@
#include "Counter.h"
+#include "mbed.h"
//#define COUNTER_DEBUG
-#ifdef COUNTER_DEBUG
+
Serial debug_out(USBTX, USBRX);
-#endif
+
Counter::Counter()
{
is_new_count = flash_size() - SECTOR_SIZE;
@@ -16,16 +17,15 @@
this->init();
}
-#ifdef COUNTER_DEBUG
+
void Counter::print_memory()
{
int *ptr = (int*) address;
- debug_out.printf("PartyID\tVoteCt\tMemCt\tAddress\r\n");
+ printf("PartyID\tVoteCt\tMemCt\tAddress\r\n");
for(int i=0; i<MAX_LEN; i++) {
- debug_out.printf("%dID\t%d\t%d\t%p\r\n", i, count[i], ptr[i], (ptr+i));
+ printf("%dID\t%d\t%d\t%p\r\n", i, count[i], ptr[i], (ptr+i));
}
}
-#endif
void Counter::init()
{
--- a/Counter.h Fri Nov 16 14:52:41 2018 +0000
+++ b/Counter.h Mon Nov 19 19:00:30 2018 +0000
@@ -28,18 +28,10 @@
class Counter
{
-private:
+public:
int count[MAX_LEN];
int is_new_count;
int address;
- #ifdef COUNTER_DEBUG
- /** Simple print function
- *
- * Prints all memory addresses in count array with values for debugging purposes.
- *
- */
- void print_memory(void);
- #endif
/** Initialize count array
*
* Either initializes count array to zeroes or existing count
@@ -56,7 +48,7 @@
*/
void decrement(int index);
-public:
+//public:
/** Default Constructor
*
@@ -94,6 +86,14 @@
*
*/
void clear();
+
+ /** Simple print function
+ *
+ * Prints all memory addresses in count array with values for debugging purposes.
+ *
+ */
+ void print_memory(void);
+
};
#endif
\ No newline at end of file