0xPIT / menu

Minimal AVR LCD Menu System in C
49 stars 49 forks source link

please use pgm_read_ptr instead of pgm_read_word for getting pointers to make the lib portable to 32bits targets #6

Open gzied opened 1 year ago

gzied commented 1 year ago

using pgm_read_word for getting pointers will trim the pointers on 32bits targets. please use pgm_read_ptr instead.

fixed Menu.cpp shall be const char Engine::getLabel(const Item_t item) const { return (const char *)pgm_read_ptr((item == NULL) ? &currentItem->Label : &item->Label); }

const Item_t Engine::getPrev(const Item_t item) const { return (const Item_t *)pgm_read_ptr((item == NULL) ? &currentItem->Previous : &item->Previous); }

const Item_t Engine::getNext(const Item_t item) const { return (const Item_t *)pgm_read_ptr((item == NULL) ? &currentItem->Next : &item->Next); }

const Item_t Engine::getParent(const Item_t item) const { return (const Item_t *)pgm_read_ptr((item == NULL) ? &currentItem->Parent : &item->Parent); }

const Item_t Engine::getChild(const Item_t item) const { return (const Item_t *)pgm_read_ptr((item == NULL) ? &currentItem->Child : &item->Child); }