worked on SPI, fixed some bugs

adjusted LCD code
added code for INA3221
worked on UI
This commit is contained in:
2020-06-24 21:28:44 +02:00
parent 6dfce7803a
commit ccd7f119d3
11 changed files with 258 additions and 88 deletions

View File

@@ -44,15 +44,16 @@ class UI {
UIPainter p;
UIElement root;
UIElement* eFocused = nullptr;
int focusIdx = 0;
//UIElement* eFocused = nullptr;
UIElement* eDown = nullptr;
Color cBackground = Color::fromRGB(180,240,180);
public:
UI() {
root.setRect(0,0,240,320);
UI(int w, int h) {
root.setRect(0,0,w,h);
root.setVisible(true);
p.setFG(cBackground);
p.fillRect(root.getRect());
@@ -77,7 +78,6 @@ public:
}
}
void onTouchDone() {
@@ -87,13 +87,28 @@ public:
}
}
void focusNext() {
root.children[focusIdx]->setFocus(false);
focusIdx = (focusIdx + 1) % root.children.size();
root.children[focusIdx]->setFocus(true);
}
void focusPrev() {
root.children[focusIdx]->setFocus(false);
focusIdx = ((focusIdx - 1) + root.children.size()) % root.children.size();
root.children[focusIdx]->setFocus(true);
}
void draw() {
//debugMod1("UI", "draw %zu elements", elements.size());
// for (UIElement* e : elements) {
// e->_draw(p);
// }
//p.setFG(cBackground);
//p.fillRect(root.getRect());
root._draw(p);
}
};