summaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2013-08-26 20:04:02 +0200
committerVegard Storheil Eriksen <zyp@jvnv.net>2013-08-26 20:04:02 +0200
commit2942ea4465feab44ff89d57680614f47eb3c314b (patch)
tree9cc6460326fe4416915cceff61fa0fa919fcf610 /main.cpp
parent654bf85f7c4075d0e1bb540019da6f37bddb4fa5 (diff)
Use button state for LED control if more than a second passed since last update.
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/main.cpp b/main.cpp
index 0e5298d..8a093b0 100644
--- a/main.cpp
+++ b/main.cpp
@@ -159,6 +159,8 @@ Pin& usb_pu = PA15;
USB_f1 usb(USB, dev_desc_p, conf_desc_p);
+uint32_t last_led_time;
+
class USB_HID : public USB_class_driver {
private:
USB_generic& usb;
@@ -216,6 +218,7 @@ class USB_HID : public USB_class_driver {
if(len == 2) {
uint32_t buf;
usb.read(ep, &buf, len);
+ last_led_time = Time::time();
GPIOC.reg.ODR = buf & 0x7ff;
}
}
@@ -304,7 +307,10 @@ int main() {
usb.process();
uint16_t buttons = (~GPIOB.reg.IDR & 0x7ff);
- //GPIOC.reg.ODR = buttons;
+
+ if(Time::time() - last_led_time > 1000) {
+ GPIOC.reg.ODR = buttons;
+ }
if(usb.ep_ready(1)) {
report_t report = {buttons, uint8_t(TIM2.CNT), uint8_t(TIM3.CNT)};