minor: clean formating
This commit is contained in:
parent
48cbeb2c91
commit
908c1de5d4
|
@ -72,10 +72,6 @@ static uint32_t key_when = 0; // when HID keyboard press report is sent
|
||||||
static uint8_t user_paste = 0; // how much of the username is pasted
|
static uint8_t user_paste = 0; // how much of the username is pasted
|
||||||
static uint8_t pass_paste = 0; // how much of the username is pasted
|
static uint8_t pass_paste = 0; // how much of the username is pasted
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
// MACRO CONSTANT TYPEDEF PROTYPES
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
|
|
||||||
// LED blink period, in ms
|
// LED blink period, in ms
|
||||||
#define BLINK_TIME (500U)
|
#define BLINK_TIME (500U)
|
||||||
|
|
||||||
|
@ -147,7 +143,7 @@ static void save_config(void)
|
||||||
crc ^= *(((uint8_t*)&config) + i);
|
crc ^= *(((uint8_t*)&config) + i);
|
||||||
}
|
}
|
||||||
config.crc = crc;
|
config.crc = crc;
|
||||||
|
|
||||||
// save to flash
|
// save to flash
|
||||||
HAL_FLASH_Unlock();
|
HAL_FLASH_Unlock();
|
||||||
FLASH_EraseInitTypeDef EraseInitStruct;
|
FLASH_EraseInitTypeDef EraseInitStruct;
|
||||||
|
@ -192,7 +188,7 @@ int main(void)
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
tud_task(); // tinyusb device task
|
tud_task(); // tinyusb device task
|
||||||
|
|
||||||
// check for credential timeout
|
// check for credential timeout
|
||||||
const uint32_t minutes = board_millis() / 1000 / 60;
|
const uint32_t minutes = board_millis() / 1000 / 60;
|
||||||
if (credentials && ((minutes > entered_when + config.timeout_global) || (minutes > entered_when + TIMEOUT_GLOBAL))) {
|
if (credentials && ((minutes > entered_when + config.timeout_global) || (minutes > entered_when + TIMEOUT_GLOBAL))) {
|
||||||
|
@ -212,14 +208,14 @@ int main(void)
|
||||||
tud_cdc_write_str(str);
|
tud_cdc_write_str(str);
|
||||||
tud_cdc_write_flush();
|
tud_cdc_write_flush();
|
||||||
board_uart_write(str, sizeof(str) - 1);
|
board_uart_write(str, sizeof(str) - 1);
|
||||||
credentials = false;
|
|
||||||
// clear credentials
|
// clear credentials
|
||||||
|
credentials = false;
|
||||||
memset(username, 0, sizeof(username));
|
memset(username, 0, sizeof(username));
|
||||||
memset(password, 0, sizeof(password));
|
memset(password, 0, sizeof(password));
|
||||||
pasted_when = 0;
|
pasted_when = 0;
|
||||||
entered_when = 0;
|
entered_when = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// run the usual tasks
|
// run the usual tasks
|
||||||
led_blinking_task();
|
led_blinking_task();
|
||||||
button_task();
|
button_task();
|
||||||
|
@ -437,7 +433,7 @@ void button_task(void)
|
||||||
static bool button1_ok = false; // if the button is pressed (after debounce)
|
static bool button1_ok = false; // if the button is pressed (after debounce)
|
||||||
static uint32_t button2_ms = 0; // when the button has been pressed (in ms)
|
static uint32_t button2_ms = 0; // when the button has been pressed (in ms)
|
||||||
static bool button2_ok = false; // if the button is pressed (after debounce)
|
static bool button2_ok = false; // if the button is pressed (after debounce)
|
||||||
|
|
||||||
// Poll every 10ms
|
// Poll every 10ms
|
||||||
const uint32_t interval_ms = 10;
|
const uint32_t interval_ms = 10;
|
||||||
static uint32_t start_ms = 0;
|
static uint32_t start_ms = 0;
|
||||||
|
@ -455,7 +451,7 @@ void button_task(void)
|
||||||
tud_remote_wakeup();
|
tud_remote_wakeup();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensure button is pressed
|
// ensure button is pressed
|
||||||
if (button1_pressed && !button1_ok) {
|
if (button1_pressed && !button1_ok) {
|
||||||
if (0 == button1_ms) {
|
if (0 == button1_ms) {
|
||||||
|
@ -505,8 +501,8 @@ void button_task(void)
|
||||||
const char* str = "pasting password\r\n";
|
const char* str = "pasting password\r\n";
|
||||||
board_uart_write((const uint8_t*)str, strlen(str));
|
board_uart_write((const uint8_t*)str, strlen(str));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear button state
|
// clear button state
|
||||||
if (!button1_pressed) {
|
if (!button1_pressed) {
|
||||||
button1_ok = false;
|
button1_ok = false;
|
||||||
|
@ -526,7 +522,7 @@ void tud_hid_report_complete_cb(uint8_t instance, uint8_t const* report, uint16_
|
||||||
(void) instance;
|
(void) instance;
|
||||||
(void) report;
|
(void) report;
|
||||||
(void) len;
|
(void) len;
|
||||||
|
|
||||||
if ((report[0] == REPORT_ID_KEYBOARD) && key_pressed) {
|
if ((report[0] == REPORT_ID_KEYBOARD) && key_pressed) {
|
||||||
//tud_hid_keyboard_report(REPORT_ID_KEYBOARD, 0, NULL); // release press
|
//tud_hid_keyboard_report(REPORT_ID_KEYBOARD, 0, NULL); // release press
|
||||||
send_hid_report(0); // release key
|
send_hid_report(0); // release key
|
||||||
|
|
Loading…
Reference in New Issue