{"action":"created","issue":{"url":"https://api.github.com/repos/keyboardio/avr_keyscanner/issues/13","repository_url":"https://api.github.com/repos/keyboardio/avr_keyscanner","labels_url":"https://api.github.com/repos/keyboardio/avr_keyscanner/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/keyboardio/avr_keyscanner/issues/13/comments","events_url":"https://api.github.com/repos/keyboardio/avr_keyscanner/issues/13/events","html_url":"https://github.com/keyboardio/avr_keyscanner/pull/13","id":328847730,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkyMjU4OTEz","number":13,"title":"led spiout improvements","user":{"login":"Gravemind","id":431519,"node_id":"MDQ6VXNlcjQzMTUxOQ==","avatar_url":"https://avatars1.githubusercontent.com/u/431519?v=4","gravatar_id":"","url":"https://api.github.com/users/Gravemind","html_url":"https://github.com/Gravemind","followers_url":"https://api.github.com/users/Gravemind/followers","following_url":"https://api.github.com/users/Gravemind/following{/other_user}","gists_url":"https://api.github.com/users/Gravemind/gists{/gist_id}","starred_url":"https://api.github.com/users/Gravemind/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gravemind/subscriptions","organizations_url":"https://api.github.com/users/Gravemind/orgs","repos_url":"https://api.github.com/users/Gravemind/repos","events_url":"https://api.github.com/users/Gravemind/events{/privacy}","received_events_url":"https://api.github.com/users/Gravemind/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-03T17:48:01Z","updated_at":"2018-06-04T04:58:49Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/keyboardio/avr_keyscanner/pulls/13","html_url":"https://github.com/keyboardio/avr_keyscanner/pull/13","diff_url":"https://github.com/keyboardio/avr_keyscanner/pull/13.diff","patch_url":"https://github.com/keyboardio/avr_keyscanner/pull/13.patch"},"body":"I think I improved `led-spiout` a bit trying get more time to run the debouncer.\r\n\r\nHere are the changes I made:\r\n\r\n- Misc optimizations: `SPI_STC_vect`'s switch, remove redundancies, removed some unneeded `volatile` to help the compiler, simplify `leds_dirty` (no data race). I measured(*) a gain of the time of less than half a keyscan at 14 interval, and 1MHz LED SPI.\r\n\r\n- Reduced SPI frequency back to 512kHz, but kept 1MHz just at startup for the first 'all led off'. **This is what helped most**: I measured(*) `chatter-defense` now never miss more than 2 keyscans while rainbow wave is running. (If the 1MHz (1aa3c74ee8) wasn't only to reduce power-up led flashing, then my change is wrong)\r\n\r\n- Reduced _some_ of the led flickering/flashing at power-up: I think some of the flickering was due to a bug in `led_init()`, caught a \"second flashing\" by adding delays in between init steps: it seemed to launched SPI transfer before initializing spi/port/variables (?), so I clarified the code (init global var at declaration, remove redundancies...).\r\n\r\n- Maybe reduced _some_ more flickering with `led_all_off_no_interrupt` hard-coded without using the interrupt so it should be faster (also helps to safely change back the spi freq at startup).\r\n\r\n- Changed `DISABLE_INTERRUPTS` to custom `PROTECT_LED_WRITES` that only disables the LED SPI interrupt, because all the led update functions are called inside interrupts (`TWI_Rx_Data_Callback` is called from the TWI interrupt), and `DISABLE_INTERRUPTS` re-enables the global interrupt flag, which, I think, is bad and could cause interrupt recursion !?\r\n\r\nIt does not seem to change the size of the flasher Sketch or Global variable (weird because in total there is fewer instructions).\r\n\r\n(*): I benchmarked by using a [new debug miss keyscann with leds](https://github.com/Gravemind/avr_keyscanner/commit/led-spiout-work-debug), less overhead but still non-zero, and the code changes a bit when applied on this branch of f/configurable-scanners-and-debouncers ...\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/keyboardio/avr_keyscanner/issues/comments/394234431","html_url":"https://github.com/keyboardio/avr_keyscanner/pull/13#issuecomment-394234431","issue_url":"https://api.github.com/repos/keyboardio/avr_keyscanner/issues/13","id":394234431,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NDIzNDQzMQ==","user":{"login":"obra","id":45416,"node_id":"MDQ6VXNlcjQ1NDE2","avatar_url":"https://avatars0.githubusercontent.com/u/45416?v=4","gravatar_id":"","url":"https://api.github.com/users/obra","html_url":"https://github.com/obra","followers_url":"https://api.github.com/users/obra/followers","following_url":"https://api.github.com/users/obra/following{/other_user}","gists_url":"https://api.github.com/users/obra/gists{/gist_id}","starred_url":"https://api.github.com/users/obra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/obra/subscriptions","organizations_url":"https://api.github.com/users/obra/orgs","repos_url":"https://api.github.com/users/obra/repos","events_url":"https://api.github.com/users/obra/events{/privacy}","received_events_url":"https://api.github.com/users/obra/received_events","type":"User","site_admin":false},"created_at":"2018-06-04T04:58:49Z","updated_at":"2018-06-04T04:58:49Z","author_association":"MEMBER","body":"Ooh. Thank you for this.\r\n\r\nI'm going to tease this apart into a few different commits.\r\n\r\nI think that some of the LED flash may be related to the bootloader on the attinys not initting the LEDs. (I've read elsewhere that they don't zero their memory on boot) If we had more free space in the bootloader, I'd init the LEDs there."}}
{"actor":{"display_login":"obra"}}