astyle
This commit is contained in:
parent
fd1e397a3e
commit
2997644d22
@ -33,49 +33,84 @@
|
|||||||
This class has an overhead of two bytes, similar to storing a pointer to an EEPROM cell.
|
This class has an overhead of two bytes, similar to storing a pointer to an EEPROM cell.
|
||||||
***/
|
***/
|
||||||
|
|
||||||
struct EERef{
|
struct EERef {
|
||||||
|
|
||||||
EERef( const int index )
|
EERef(const int index)
|
||||||
: index( index ) {}
|
: index(index) {}
|
||||||
|
|
||||||
//Access/read members.
|
//Access/read members.
|
||||||
uint8_t operator*() const { return eeprom_[index]; }
|
uint8_t operator*() const {
|
||||||
operator uint8_t() const { return **this; }
|
return eeprom_[index];
|
||||||
|
}
|
||||||
|
operator uint8_t() const {
|
||||||
|
return **this;
|
||||||
|
}
|
||||||
|
|
||||||
//Assignment/write members.
|
//Assignment/write members.
|
||||||
EERef &operator=( const EERef &ref ) { return *this = *ref; }
|
EERef &operator=(const EERef &ref) {
|
||||||
EERef &operator=( uint8_t in ) { eeprom_[index] = in; return *this; }
|
return *this = *ref;
|
||||||
EERef &operator +=( uint8_t in ) { return *this = **this + in; }
|
}
|
||||||
EERef &operator -=( uint8_t in ) { return *this = **this - in; }
|
EERef &operator=(uint8_t in) {
|
||||||
EERef &operator *=( uint8_t in ) { return *this = **this * in; }
|
eeprom_[index] = in;
|
||||||
EERef &operator /=( uint8_t in ) { return *this = **this / in; }
|
return *this;
|
||||||
EERef &operator ^=( uint8_t in ) { return *this = **this ^ in; }
|
}
|
||||||
EERef &operator %=( uint8_t in ) { return *this = **this % in; }
|
EERef &operator +=(uint8_t in) {
|
||||||
EERef &operator &=( uint8_t in ) { return *this = **this & in; }
|
return *this = **this + in;
|
||||||
EERef &operator |=( uint8_t in ) { return *this = **this | in; }
|
}
|
||||||
EERef &operator <<=( uint8_t in ) { return *this = **this << in; }
|
EERef &operator -=(uint8_t in) {
|
||||||
EERef &operator >>=( uint8_t in ) { return *this = **this >> in; }
|
return *this = **this - in;
|
||||||
|
}
|
||||||
|
EERef &operator *=(uint8_t in) {
|
||||||
|
return *this = **this * in;
|
||||||
|
}
|
||||||
|
EERef &operator /=(uint8_t in) {
|
||||||
|
return *this = **this / in;
|
||||||
|
}
|
||||||
|
EERef &operator ^=(uint8_t in) {
|
||||||
|
return *this = **this ^ in;
|
||||||
|
}
|
||||||
|
EERef &operator %=(uint8_t in) {
|
||||||
|
return *this = **this % in;
|
||||||
|
}
|
||||||
|
EERef &operator &=(uint8_t in) {
|
||||||
|
return *this = **this & in;
|
||||||
|
}
|
||||||
|
EERef &operator |=(uint8_t in) {
|
||||||
|
return *this = **this | in;
|
||||||
|
}
|
||||||
|
EERef &operator <<=(uint8_t in) {
|
||||||
|
return *this = **this << in;
|
||||||
|
}
|
||||||
|
EERef &operator >>=(uint8_t in) {
|
||||||
|
return *this = **this >> in;
|
||||||
|
}
|
||||||
|
|
||||||
EERef &update( uint8_t in ) { return in != *this ? *this = in : *this; }
|
EERef &update(uint8_t in) {
|
||||||
|
return in != *this ? *this = in : *this;
|
||||||
|
}
|
||||||
|
|
||||||
/** Prefix increment/decrement **/
|
/** Prefix increment/decrement **/
|
||||||
EERef& operator++() { return *this += 1; }
|
EERef& operator++() {
|
||||||
EERef& operator--() { return *this -= 1; }
|
return *this += 1;
|
||||||
|
}
|
||||||
|
EERef& operator--() {
|
||||||
|
return *this -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
/** Postfix increment/decrement **/
|
/** Postfix increment/decrement **/
|
||||||
uint8_t operator++ (int){
|
uint8_t operator++ (int) {
|
||||||
uint8_t ret = **this;
|
uint8_t ret = **this;
|
||||||
return ++(*this), ret;
|
return ++(*this), ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t operator-- (int){
|
uint8_t operator-- (int) {
|
||||||
uint8_t ret = **this;
|
uint8_t ret = **this;
|
||||||
return --(*this), ret;
|
return --(*this), ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int index; //Index of current EEPROM cell.
|
int index; //Index of current EEPROM cell.
|
||||||
|
|
||||||
static uint8_t eeprom_[];
|
static uint8_t eeprom_[];
|
||||||
};
|
};
|
||||||
|
|
||||||
/***
|
/***
|
||||||
@ -131,33 +166,45 @@ struct EEPtr {
|
|||||||
This class is also 100% backwards compatible with earlier Arduino core releases.
|
This class is also 100% backwards compatible with earlier Arduino core releases.
|
||||||
***/
|
***/
|
||||||
|
|
||||||
struct EEPROMClass{
|
struct EEPROMClass {
|
||||||
|
|
||||||
//Basic user access methods.
|
//Basic user access methods.
|
||||||
EERef operator[]( const int idx ) { return idx; }
|
EERef operator[](const int idx) {
|
||||||
uint8_t read( int idx ) { return EERef( idx ); }
|
return idx;
|
||||||
void write( int idx, uint8_t val ) { (EERef( idx )) = val; }
|
}
|
||||||
void update( int idx, uint8_t val ) { EERef( idx ).update( val ); }
|
uint8_t read(int idx) {
|
||||||
|
return EERef(idx);
|
||||||
|
}
|
||||||
|
void write(int idx, uint8_t val) {
|
||||||
|
(EERef(idx)) = val;
|
||||||
|
}
|
||||||
|
void update(int idx, uint8_t val) {
|
||||||
|
EERef(idx).update(val);
|
||||||
|
}
|
||||||
|
|
||||||
//STL and C++11 iteration capability.
|
//STL and C++11 iteration capability.
|
||||||
EEPtr begin() { return 0x00; }
|
EEPtr begin() {
|
||||||
EEPtr end() { return length(); } //Standards requires this to be the item after the last valid entry. The returned pointer is invalid.
|
return 0x00;
|
||||||
uint16_t length();
|
}
|
||||||
|
EEPtr end() {
|
||||||
|
return length(); //Standards requires this to be the item after the last valid entry. The returned pointer is invalid.
|
||||||
|
}
|
||||||
|
uint16_t length();
|
||||||
|
|
||||||
//Functionality to 'get' and 'put' objects to and from EEPROM.
|
//Functionality to 'get' and 'put' objects to and from EEPROM.
|
||||||
template< typename T > T &get( int idx, T &t ){
|
template< typename T > T &get(int idx, T &t) {
|
||||||
EEPtr e = idx;
|
EEPtr e = idx;
|
||||||
uint8_t *ptr = (uint8_t*) &t;
|
uint8_t *ptr = (uint8_t*) &t;
|
||||||
for( int count = sizeof(T) ; count ; --count, ++e ) *ptr++ = *e;
|
for (int count = sizeof(T) ; count ; --count, ++e) *ptr++ = *e;
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T > const T &put( int idx, const T &t ){
|
template< typename T > const T &put(int idx, const T &t) {
|
||||||
EEPtr e = idx;
|
EEPtr e = idx;
|
||||||
const uint8_t *ptr = (const uint8_t*) &t;
|
const uint8_t *ptr = (const uint8_t*) &t;
|
||||||
for( int count = sizeof(T) ; count ; --count, ++e ) (*e).update( *ptr++ );
|
for (int count = sizeof(T) ; count ; --count, ++e)(*e).update(*ptr++);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
extern EEPROMClass EEPROM;
|
extern EEPROMClass EEPROM;
|
||||||
|
@ -63,21 +63,21 @@ class PluggableUSBModule {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class PluggableUSB_ {
|
class PluggableUSB_ {
|
||||||
public:
|
public:
|
||||||
PluggableUSB_() {}
|
PluggableUSB_() {}
|
||||||
bool plug(PluggableUSBModule *node) {
|
bool plug(PluggableUSBModule *node) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
int getInterface(uint8_t *interfaceCount) {
|
int getInterface(uint8_t *interfaceCount) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
int getDescriptor(USBSetup &setup) {
|
int getDescriptor(USBSetup &setup) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
bool setup(USBSetup &setup) {
|
bool setup(USBSetup &setup) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
void getShortName(char *iSerialNum) {}
|
void getShortName(char *iSerialNum) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Replacement for global singleton.
|
// Replacement for global singleton.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user