Safety first (for deletions)

This commit is contained in:
SuchMemeManySkill
2020-12-25 23:10:23 +01:00
parent 9c47d11843
commit a74a8814e1
6 changed files with 67 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
#include "gfx.h"
#include "gfxutils.h"
#include <power/max17050.h>
#include "../hid/hid.h"
void gfx_clearscreen(){
int battery = 0;
@@ -18,6 +19,26 @@ void gfx_clearscreen(){
RESETCOLOR;
}
u32 FromRGBtoU32(u8 r, u8 g, u8 b){
return 0xFF000000 | r << 16 | g << 8 | b;
int MakeHorizontalMenu(MenuEntry_t *entries, int len, int spacesBetween, u32 bg){
u32 initialX = 0, initialY = 0;
u32 highlight = 0;
gfx_con_getpos(&initialX, &initialY);
while (1){
for (int i = 0; i < len; i++){
(highlight == i) ? SETCOLOR(bg, entries[i].optionUnion) : SETCOLOR(entries[i].optionUnion, bg);
gfx_puts(entries[i].name);
gfx_con.y -= spacesBetween * 16;
}
gfx_con_setpos(initialX, initialY);
Input_t *input = hidWait();
if (input->a)
return highlight;
else if (input->b)
return 0;
else if (input->left && highlight > 0)
highlight--;
else if (input->right && highlight < len - 1)
highlight++;
}
}