Arduino Libraries
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
eeprom_report.hpp
Go to the documentation of this file.
1 // Author: Mario S. Könz <mskoenz@gmx.net>
2 // Date: 25.05.2013 19:22:25 EDT
3 // File: eeprom_report.hpp
4 
5 /* This program is free software. It comes without any warranty, to
6  * the extent permitted by applicable law. You can redistribute it
7  * and/or modify it under the terms of the Do What The Fuck You Want
8  * To Public License, Version 2, as published by Sam Hocevar. See
9  * http://www.wtfpl.net/ or COPYING for more details. */
10 
11 #ifndef __EEPROM_REPORT_HEADER
12 #define __EEPROM_REPORT_HEADER
13 
14 #include <ustd/iostream.hpp>
15 
16 #include <Arduino.h>
17 #include <EEPROM.h>
18 
19 namespace diag {
21  typedef uint16_t size_type;
22  public:
23  static size_type const eeprom_capacity = 1024;
24 
25  void reset(byte r = 0xFF) {
26  for(size_type i = 0; i < eeprom_capacity; ++i) {
27  if(EEPROM.read(i) != r)
28  EEPROM.write(i, r);
29  }
30  }
31  void eeprom_report() {
32  const uint8_t mod = 32;
34  << F("+----------------");
35  for(uint8_t i = 0; i < mod; ++i) {
36  ustd::cout << F("---");
37  }
38  ustd::cout << F("+") << ustd::endl
39  << F("| EEPROM Report ");
40  for(uint8_t i = 0; i < mod; ++i) {
41  ustd::cout << F(" ");
42  }
43  ustd::cout << F("|") << ustd::endl
44  << F("+----------------");
45  for(uint8_t i = 0; i < mod; ++i) {
46  ustd::cout << F("---");
47  }
48  ustd::cout << F("+");
49 
50  for(size_type i = 0; i < eeprom_capacity; ++i) {
51  if(i % mod == 0) {
52  if(i != 0)
53  ustd::cout << NONE << F("|");
54 
56  << F("| ");
57  if(i%(3*mod) == 0)
58  ustd::cout << GREEN;
59  ustd::cout << ustd::setw(4) << i << F(" - ") << ustd::setw(4) << i + mod-1 << F(" : ");
60  if(i%(3*mod) == 0)
61  ustd::cout << REDB;
62  }
63  ustd::cout << ustd::setfill('0') << ustd::setbase(16) << ustd::setw(2) << EEPROM.read(i);
64  ustd::cout(1) << F(" "); //cout() means reset all modifier
65  if(i == eeprom_capacity - 1)
66  ustd::cout << NONE << F("|");
67  }
69  ustd::cout << F("+----------------");
70  for(uint8_t i = 0; i < mod; ++i) {
71  ustd::cout << F("---");
72  }
73  ustd::cout << F("+") << ustd::endl;
74  }
76  for(size_type i = 0; i < eeprom_capacity; ++i) {
77  Serial.write(EEPROM.read(i));
78  }
80  }
81  void check(char id = 'e') {
82  if(ustd::cin)
83  {
84  byte x = ustd::cin.peek();
85  if(x == id) {
86  ustd::cin.read();
87  eeprom_report();
88  }
89  }
90  }
91  void check_byte(char id = 'e') {
92  if(ustd::cin) {
93  byte x = ustd::cin.peek();
94  if(x == id) {
95  ustd::cin.read();
97  }
98  }
99  }
100  }mirror;
101 
102  void eeprom_report() {
104  }
105 }//end namespace diag
106 #endif //__EEPROM_REPORT_HEADER
#define GREEN
Definition: color.hpp:15
Definition: eeprom_report.hpp:20
void eeprom_report_data()
Definition: eeprom_report.hpp:75
struct ustd::cin_class cin
static size_type const eeprom_capacity
Definition: eeprom_report.hpp:23
#define NONE
Definition: color.hpp:37
void check_byte(char id= 'e')
Definition: eeprom_report.hpp:91
serial_class Serial
struct ustd::endl_class endl
void eeprom_report()
Definition: eeprom_report.hpp:102
char peek() const
Definition: iostream.hpp:209
char read() const
Definition: iostream.hpp:212
class diag::EEPROM_mirror_class mirror
void eeprom_report()
Definition: eeprom_report.hpp:31
#define REDB
Definition: color.hpp:14
size_type write(char const &data, uint8_t const &len=1)
Definition: std_serial.hpp:88
#define F(x)
Definition: ustd_generic.hpp:15
void reset(byte r=0xFF)
Definition: eeprom_report.hpp:25
ustd::cout_class cout
void check(char id= 'e')
Definition: eeprom_report.hpp:81