46 lines
833 B
C
Raw Normal View History

/*
* utils.c
*/
2016-03-19 17:30:56 +01:00
#include "utils.h"
#include "draw.h"
#include "i2c.h"
u32 waitInput(void)
{
u32 pressedKey = 0,
key;
2016-03-19 17:30:56 +01:00
//Wait for no keys to be pressed
while(HID_PAD);
do
{
2016-03-19 17:30:56 +01:00
//Wait for a key to be pressed
while(!HID_PAD);
2016-03-19 17:30:56 +01:00
key = HID_PAD;
//Make sure it's pressed
for(u32 i = 0x13000; i; i--)
{
if(key != HID_PAD) break;
if(i == 1) pressedKey = 1;
2016-03-19 17:30:56 +01:00
}
}
while(!pressedKey);
2016-03-19 17:30:56 +01:00
return key;
}
void shutdown(u32 mode, const char *message)
{
if(mode)
{
2016-06-08 14:41:52 +02:00
posY = drawString(message, 10, posY + SPACING_Y, mode == 1 ? COLOR_RED : COLOR_GREEN);
drawString("Press any button to shutdown", 10, posY, COLOR_WHITE);
waitInput();
2016-03-19 17:30:56 +01:00
}
i2cWriteRegister(I2C_DEV_MCU, 0x20, 1);
while(1);
}