Skip to content

Commit

Permalink
uintptr_t is now used for address casting.
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFedOne committed Aug 16, 2016
1 parent 6aab840 commit ba824ae
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/LiquidLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ SOFTWARE.

//const char NOTHING[] = " "; ///< 20 spaces, used to clear the display.

void print_me(uint16_t address) {
void print_me(uintptr_t address) {
DEBUG(F("Line (0x")); DEBUG2(address, OCT); DEBUG(F("): "));
return;
address = address;
}


bool LiquidLine::attach_function(uint8_t number, void (*function)(void)) {
print_me((uint16_t)this);
print_me((uintptr_t)this);
if (number <= MAX_FUNCTIONS) {
_function[number - 1] = function;
DEBUG(F("Attached function ")); DEBUGLN(number);
Expand All @@ -48,7 +48,7 @@ bool LiquidLine::attach_function(uint8_t number, void (*function)(void)) {
}

bool LiquidLine::set_focusPosition(Position position, uint8_t column, uint8_t row) {
print_me((uint16_t)this);
print_me((uintptr_t)this);
if (position <= Position::CUSTOM) {
_focusPosition = position;
_focusColumn = column;
Expand Down
8 changes: 4 additions & 4 deletions src/LiquidMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ LiquidMenu::LiquidMenu(LiquidCrystal &liquidCrystal, LiquidScreen &liquidScreen1
}

bool LiquidMenu::add_screen(LiquidScreen &liquidScreen) {
print_me((uint16_t)this);
print_me((uintptr_t)this);
if (_screenCount < MAX_SCREENS) {
_p_liquidScreen[_screenCount] = &liquidScreen;
DEBUG(F("Added a new screen (")); DEBUG(_screenCount); DEBUGLN(F(")"));
Expand Down Expand Up @@ -136,7 +136,7 @@ bool LiquidMenu::change_screen(LiquidScreen &p_liquidScreen) {
// _p_liquidMenu[_currentMenu]->_p_liquidCrystal->clear();
for (uint8_t s = 0; s < _screenCount; s++) {
_p_liquidCrystal->clear();
if ((uint16_t)&p_liquidScreen == (uint16_t) & (*_p_liquidScreen[s])) {
if ((uintptr_t)&p_liquidScreen == (uintptr_t) & (*_p_liquidScreen[s])) {
_currentScreen = s;
update();
DEBUG(F("Switched to screen ("));
Expand All @@ -145,7 +145,7 @@ bool LiquidMenu::change_screen(LiquidScreen &p_liquidScreen) {
return true;
}
}
DEBUG(F("Invalid request for screen change to ")); DEBUGLN((uint16_t)&p_liquidScreen);
DEBUG(F("Invalid request for screen change to ")); DEBUGLN((uintptr_t)&p_liquidScreen);
return false;
}

Expand All @@ -164,7 +164,7 @@ void LiquidMenu::switch_focus(bool forward) {
}

bool LiquidMenu::set_focusPosition(Position position) {
print_me((uint16_t)this);
print_me((uintptr_t)this);
if (position == Position::CUSTOM) {
DEBUGLN(F("Can't set a custom focus position for the whole menu at once"));
return false;
Expand Down
4 changes: 2 additions & 2 deletions src/LiquidMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ Used for convenience when printing the class's address for indentification.
@param address - number to be printed
*/
void print_me(uint16_t address);
void print_me(uintptr_t address);


/// Represents the individual lines printed on the display.
Expand Down Expand Up @@ -291,7 +291,7 @@ class LiquidLine {
*/
template <typename T>
bool add_variable(T &variable) {
print_me((uint16_t)this);
print_me((uintptr_t)this);
if (_variableCount < MAX_VARIABLES) {
_variable[_variableCount] = (void*)&variable;
_variableType[_variableCount] = recognizeType(variable);
Expand Down
6 changes: 3 additions & 3 deletions src/LiquidScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ LiquidScreen::LiquidScreen(LiquidLine &liquidLine1, LiquidLine &liquidLine2,
}

bool LiquidScreen::add_line(LiquidLine &liquidLine) {
print_me((uint16_t)this);
print_me((uintptr_t)this);
if (_lineCount < MAX_LINES) {
_p_liquidLine[_lineCount] = &liquidLine;
DEBUG(F("Added a new line (")); DEBUG(_lineCount); DEBUGLN(F(")"));
Expand All @@ -64,7 +64,7 @@ bool LiquidScreen::add_line(LiquidLine &liquidLine) {
}

bool LiquidScreen::set_focusPosition(Position position) {
print_me((uint16_t)this);
print_me((uintptr_t)this);
if (position == Position::CUSTOM) {
DEBUGLN(F("Can't set focus position to 'CUSTOM' for the whole screen at once"));
return false;
Expand Down Expand Up @@ -96,7 +96,7 @@ void LiquidScreen::print(LiquidCrystal *p_liquidCrystal) const {
}

void LiquidScreen::switch_focus(bool forward) {
print_me((uint16_t)this);
print_me((uintptr_t)this);
do {
if (forward) {
if (_focus < _lineCount) {
Expand Down
6 changes: 3 additions & 3 deletions src/LiquidSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ LiquidSystem::LiquidSystem(LiquidMenu &liquidMenu1, LiquidMenu &liquidMenu2,


bool LiquidSystem::add_menu(LiquidMenu &liquidMenu) {
print_me((uint16_t)this);
print_me((uintptr_t)this);
if (_menuCount < MAX_MENUS) {
_p_liquidMenu[_menuCount] = &liquidMenu;
DEBUG(F("Added a new menu (")); DEBUG(_menuCount); DEBUGLN(F(")"));
Expand All @@ -67,14 +67,14 @@ bool LiquidSystem::add_menu(LiquidMenu &liquidMenu) {
bool LiquidSystem::change_menu(LiquidMenu &p_liquidMenu) {
// _p_liquidMenu[_currentMenu]->_p_liquidCrystal->clear();
for (uint8_t m = 0; m < _menuCount; m++) {
if ((uint16_t)&p_liquidMenu == (uint16_t) & (*_p_liquidMenu[m])) {
if ((uintptr_t)&p_liquidMenu == (uintptr_t) & (*_p_liquidMenu[m])) {
_currentMenu = m;
DEBUG(F("Menu changed to ")); DEBUGLN(_currentMenu);
update();
return true;
}
}
DEBUG(F("Invalid request for menu change to ")); DEBUGLN((uint16_t)&p_liquidMenu);
DEBUG(F("Invalid request for menu change to ")); DEBUGLN((uintptr_t)&p_liquidMenu);
return false;
}

Expand Down

0 comments on commit ba824ae

Please sign in to comment.