2018-11-02 20:30:51 +01:00
|
|
|
#include "matrix.h"
|
|
|
|
#include "i2c_master.h"
|
2020-11-28 21:02:18 +01:00
|
|
|
#include "md_rgb_matrix.h"
|
2018-11-02 20:30:51 +01:00
|
|
|
#include "suspend.h"
|
|
|
|
|
|
|
|
/** \brief Suspend idle
|
2018-08-29 21:07:52 +02:00
|
|
|
*
|
2018-11-02 20:30:51 +01:00
|
|
|
* FIXME: needs doc
|
|
|
|
*/
|
2019-11-17 15:02:26 +01:00
|
|
|
void suspend_idle(uint8_t time) { /* Note: Not used anywhere currently */
|
|
|
|
}
|
2018-11-02 20:30:51 +01:00
|
|
|
|
|
|
|
/** \brief Run user level Power down
|
2018-08-29 21:07:52 +02:00
|
|
|
*
|
2018-11-02 20:30:51 +01:00
|
|
|
* FIXME: needs doc
|
|
|
|
*/
|
2019-08-30 20:19:03 +02:00
|
|
|
__attribute__((weak)) void suspend_power_down_user(void) {}
|
2018-11-02 20:30:51 +01:00
|
|
|
|
|
|
|
/** \brief Run keyboard level Power down
|
|
|
|
*
|
|
|
|
* FIXME: needs doc
|
|
|
|
*/
|
2019-08-30 20:19:03 +02:00
|
|
|
__attribute__((weak)) void suspend_power_down_kb(void) { suspend_power_down_user(); }
|
2018-11-02 20:30:51 +01:00
|
|
|
|
|
|
|
/** \brief Suspend power down
|
|
|
|
*
|
|
|
|
* FIXME: needs doc
|
|
|
|
*/
|
2019-08-30 20:19:03 +02:00
|
|
|
void suspend_power_down(void) {
|
2019-04-04 03:30:47 +02:00
|
|
|
#ifdef RGB_MATRIX_ENABLE
|
2019-08-30 20:19:03 +02:00
|
|
|
I2C3733_Control_Set(0); // Disable LED driver
|
2019-04-04 03:30:47 +02:00
|
|
|
#endif
|
2018-11-02 20:30:51 +01:00
|
|
|
|
|
|
|
suspend_power_down_kb();
|
|
|
|
}
|
|
|
|
|
2019-08-30 20:19:03 +02:00
|
|
|
__attribute__((weak)) void matrix_power_up(void) {}
|
|
|
|
__attribute__((weak)) void matrix_power_down(void) {}
|
|
|
|
bool suspend_wakeup_condition(void) {
|
2018-11-02 20:30:51 +01:00
|
|
|
matrix_power_up();
|
|
|
|
matrix_scan();
|
|
|
|
matrix_power_down();
|
|
|
|
for (uint8_t r = 0; r < MATRIX_ROWS; r++) {
|
|
|
|
if (matrix_get_row(r)) return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** \brief run user level code immediately after wakeup
|
|
|
|
*
|
|
|
|
* FIXME: needs doc
|
|
|
|
*/
|
2019-08-30 20:19:03 +02:00
|
|
|
__attribute__((weak)) void suspend_wakeup_init_user(void) {}
|
2018-11-02 20:30:51 +01:00
|
|
|
|
|
|
|
/** \brief run keyboard level code immediately after wakeup
|
|
|
|
*
|
|
|
|
* FIXME: needs doc
|
|
|
|
*/
|
2019-08-30 20:19:03 +02:00
|
|
|
__attribute__((weak)) void suspend_wakeup_init_kb(void) { suspend_wakeup_init_user(); }
|
2018-11-02 20:30:51 +01:00
|
|
|
|
|
|
|
/** \brief run immediately after wakeup
|
2018-08-29 21:07:52 +02:00
|
|
|
*
|
2018-11-02 20:30:51 +01:00
|
|
|
* FIXME: needs doc
|
2018-08-29 21:07:52 +02:00
|
|
|
*/
|
2018-11-02 20:30:51 +01:00
|
|
|
void suspend_wakeup_init(void) {
|
2019-04-04 03:30:47 +02:00
|
|
|
#ifdef RGB_MATRIX_ENABLE
|
2019-08-30 20:19:03 +02:00
|
|
|
# ifdef USE_MASSDROP_CONFIGURATOR
|
2019-04-18 15:35:50 +02:00
|
|
|
if (led_enabled) {
|
|
|
|
I2C3733_Control_Set(1);
|
|
|
|
}
|
2019-08-30 20:19:03 +02:00
|
|
|
# else
|
2019-04-04 03:30:47 +02:00
|
|
|
I2C3733_Control_Set(1);
|
2019-08-30 20:19:03 +02:00
|
|
|
# endif
|
2019-04-04 03:30:47 +02:00
|
|
|
#endif
|
2018-08-29 21:07:52 +02:00
|
|
|
|
2018-11-02 20:30:51 +01:00
|
|
|
suspend_wakeup_init_kb();
|
|
|
|
}
|