2016-03-19 17:30:56 +01:00
|
|
|
#include "utils.h"
|
|
|
|
#include "draw.h"
|
|
|
|
#include "i2c.h"
|
|
|
|
|
|
|
|
u16 waitInput(void){
|
|
|
|
u32 pressedkey = 0;
|
|
|
|
u16 key;
|
|
|
|
|
|
|
|
//Wait for no keys to be pressed
|
|
|
|
while(HID_PAD);
|
|
|
|
|
|
|
|
do {
|
|
|
|
//Wait for a key to be pressed
|
|
|
|
while(!HID_PAD);
|
|
|
|
key = HID_PAD;
|
|
|
|
|
|
|
|
//Make sure it's pressed
|
2016-03-20 16:55:49 +01:00
|
|
|
for(u32 i = 0x13000; i; i--){
|
2016-03-19 17:30:56 +01:00
|
|
|
if (key != HID_PAD)
|
|
|
|
break;
|
2016-03-25 18:17:59 +01:00
|
|
|
if(i == 1) pressedkey = 1;
|
2016-03-19 17:30:56 +01:00
|
|
|
}
|
2016-03-25 18:17:59 +01:00
|
|
|
} while(!pressedkey);
|
2016-03-19 17:30:56 +01:00
|
|
|
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
|
2016-03-25 18:17:59 +01:00
|
|
|
void shutdown(u32 mode, const char *message){
|
2016-03-19 17:30:56 +01:00
|
|
|
if(mode){
|
2016-03-25 16:51:09 +01:00
|
|
|
pos_y = drawString(message, 10, pos_y + SPACING_VERT, COLOR_RED);
|
2016-03-25 04:47:07 +01:00
|
|
|
drawString("Press any button to shutdown", 10, pos_y, COLOR_WHITE);
|
|
|
|
waitInput();
|
2016-03-19 17:30:56 +01:00
|
|
|
}
|
|
|
|
i2cWriteRegister(I2C_DEV_MCU, 0x20, 1);
|
|
|
|
while(1);
|
|
|
|
}
|