mirror of
https://github.com/clockworkpi/PicoCalc.git
synced 2025-12-12 10:18:54 +01:00
Add REG_ID_OFF to power off picocalc
add button callback when short press Power key of picocalc
This commit is contained in:
parent
ebdc77ad4a
commit
8b6822a80c
@ -58,6 +58,8 @@ enum key_state
|
|||||||
#define KEY_F9 0x89
|
#define KEY_F9 0x89
|
||||||
#define KEY_F10 0x90
|
#define KEY_F10 0x90
|
||||||
|
|
||||||
|
#define KEY_POWER 0x91
|
||||||
|
|
||||||
typedef void (*key_callback)(char, enum key_state);
|
typedef void (*key_callback)(char, enum key_state);
|
||||||
typedef void (*lock_callback)(bool, bool);
|
typedef void (*lock_callback)(bool, bool);
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,7 @@
|
|||||||
#define DEBUG_UART
|
#define DEBUG_UART
|
||||||
TwoWire Wire2 = TwoWire(CONFIG_PMU_SDA, CONFIG_PMU_SCL);
|
TwoWire Wire2 = TwoWire(CONFIG_PMU_SDA, CONFIG_PMU_SCL);
|
||||||
bool pmu_flag = 0;
|
bool pmu_flag = 0;
|
||||||
bool pmu_online = 0;
|
uint8_t pmu_online = 0;
|
||||||
uint8_t keycb_start = 0;
|
uint8_t keycb_start = 0;
|
||||||
|
|
||||||
uint8_t head_phone_status=LOW;
|
uint8_t head_phone_status=LOW;
|
||||||
@ -168,6 +168,16 @@ void receiveEvent(int howMany) {
|
|||||||
write_buffer[1] = js_bits;
|
write_buffer[1] = js_bits;
|
||||||
write_buffer_len = 2;
|
write_buffer_len = 2;
|
||||||
}break;
|
}break;
|
||||||
|
case REG_ID_OFF:{
|
||||||
|
if(is_write){
|
||||||
|
pmu_online = rcv_data[1];
|
||||||
|
if(pmu_online < 6){
|
||||||
|
pmu_online = 6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
write_buffer[0] = reg;
|
||||||
|
write_buffer[1] = 1;
|
||||||
|
}break;
|
||||||
default: {
|
default: {
|
||||||
write_buffer[0] = 0;
|
write_buffer[0] = 0;
|
||||||
write_buffer[1] = 0;
|
write_buffer[1] = 0;
|
||||||
@ -265,6 +275,12 @@ void check_pmu_int() {
|
|||||||
|
|
||||||
if (!pmu_online) return;
|
if (!pmu_online) return;
|
||||||
|
|
||||||
|
if(pmu_online > 1) {
|
||||||
|
delay(1000*pmu_online);
|
||||||
|
PMU.shutdown();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (time_uptime_ms() - run_time > 20000) {
|
if (time_uptime_ms() - run_time > 20000) {
|
||||||
run_time = millis(); // reset time
|
run_time = millis(); // reset time
|
||||||
pcnt = PMU.getBatteryPercent();
|
pcnt = PMU.getBatteryPercent();
|
||||||
@ -345,6 +361,7 @@ void check_pmu_int() {
|
|||||||
if (PMU.isPekeyShortPressIrq()) {
|
if (PMU.isPekeyShortPressIrq()) {
|
||||||
Serial1.println("isPekeyShortPress");
|
Serial1.println("isPekeyShortPress");
|
||||||
// enterPmuSleep();
|
// enterPmuSleep();
|
||||||
|
key_cb(KEY_POWER,KEY_STATE_PRESSED);//send a KEY_POWER to i2c
|
||||||
|
|
||||||
Serial1.print("Read pmu data buffer .");
|
Serial1.print("Read pmu data buffer .");
|
||||||
uint8_t data[4] = {0};
|
uint8_t data[4] = {0};
|
||||||
|
|||||||
@ -19,6 +19,7 @@ enum reg_id
|
|||||||
REG_ID_BAT = 0x0b,// battery
|
REG_ID_BAT = 0x0b,// battery
|
||||||
REG_ID_C64_MTX = 0x0c,// read c64 matrix
|
REG_ID_C64_MTX = 0x0c,// read c64 matrix
|
||||||
REG_ID_C64_JS = 0x0d, // joystick io bits
|
REG_ID_C64_JS = 0x0d, // joystick io bits
|
||||||
|
REG_ID_OFF = 0x0e, // POWER OFF
|
||||||
REG_ID_LAST,
|
REG_ID_LAST,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user