cleaned up a bit; minor bugfix

partial-rewrite
Ben Blazak 2014-05-27 23:05:00 -07:00
parent 74c685a8b4
commit f980028d82
6 changed files with 30 additions and 23 deletions

View File

@ -227,7 +227,7 @@ void kb__layout__exec_key_layer ( bool pressed,
// === kb__led__delay__error() ===
/** functions/kb__led__delay__error/description
* Signal a generic error (delays for a total of ~1 second)
* Signal a generic error
*/
// === kb__led__delay__usb_init() ===

View File

@ -8,9 +8,6 @@
* A layout for testing newly build boards
*
* Implements the "layout" section of '.../firmware/keyboard.h'
*
* TODO:
* - update, if i change the semantics `kb__layout__exec_key()`
*/

View File

@ -1,5 +1,5 @@
/* ----------------------------------------------------------------------------
* Copyright (c) 2013 Ben Blazak <benblazak.dev@gmail.com>
* Copyright (c) 2013, 2014 Ben Blazak <benblazak.dev@gmail.com>
* Released under The MIT License (see "doc/licenses/MIT.md")
* Project located at <https://github.com/benblazak/ergodox-firmware>
* ------------------------------------------------------------------------- */
@ -112,13 +112,20 @@ void kb__led__state__ready(void) {
}
void kb__led__delay__error(void) {
// make sure LED states have stabilized
// - i'm not quite sure how long this takes; i would think it'd be nearly
// instant, but a bit of testing seemed to show that even 5ms isn't quite
// long enough; 10ms seems to work; at least we can afford the time here
_delay_ms(10);
struct led_state state = {
.led_1 = kb__led__read(1),
.led_2 = kb__led__read(2),
.led_3 = kb__led__read(3),
};
// delay for a total of ~1 second
kb__led__all_off();
_delay_ms(167);
kb__led__all_on();
_delay_ms(167);
kb__led__all_off();

View File

@ -881,8 +881,7 @@ uint8_t eeprom_macro__play( bool pressed,
k_location += 2;
while (length) {
uint8_t read = read_key_action(k_location, &k);
// // TODO: function not written yet
// kb__layout__exec_key_layer()
kb__layout__exec_key_layer( k.pressed, k.layer, k.row, k.column );
length -= read;
k_location += read;
}

View File

@ -28,18 +28,15 @@
// ----------------------------------------------------------------------------
#if OPT__TWI__FREQUENCY > 400000
#error "OPT__TWI__FREQUENCY must be <= 400000"
#endif
/** macros/OPT__TWI__FREQUENCY/description
* Implementation notes:
* - The max speed for the ATmega32U4 is 400kHz (datasheet sec. 20.1)
* - The max speed for the MCP23017 is 1.7MHz (datasheet pg. 1)
* - The max speed for the MCP23018 is 3.4MHz (datasheet pg. 1)
*
* TODO: do these implementation notes belong in the keyboard "options.h",
* where they're set?
*/
#if OPT__TWI__FREQUENCY > 400000
#error "OPT__TWI__FREQUENCY must be <= 400000"
#endif
// ----------------------------------------------------------------------------

View File

@ -1,5 +1,5 @@
/* ----------------------------------------------------------------------------
* Copyright (c) 2013 Ben Blazak <benblazak.dev@gmail.com>
* Copyright (c) 2013, 2014 Ben Blazak <benblazak.dev@gmail.com>
* Released under The MIT License (see "doc/licenses/MIT.md")
* Project located at <https://github.com/benblazak/ergodox-firmware>
* ------------------------------------------------------------------------- */
@ -73,18 +73,25 @@ int main(void) {
static uint8_t time_scan_started;
if (kb__init()) kb__led__delay__error(); // initialize hardware (besides
// USB and timer)
{
// initialize everything; signal an error (at the end) if one occurs
kb__led__state__power_on();
bool error;
if (usb__init()) kb__led__delay__error();
while (!usb__is_configured());
kb__led__delay__usb_init(); // give the OS time to load drivers, etc.
error = kb__init(); // initialize hardware (besides USB and timer)
if (timer__init()) kb__led__delay__error();
kb__led__state__power_on();
kb__led__state__ready();
error |= usb__init();
while (!usb__is_configured());
kb__led__delay__usb_init(); // give the OS time to load drivers, etc.
error |= timer__init();
kb__led__state__ready();
if (error) kb__led__delay__error();
}
time_scan_started // on the first iteration, scan immediately
= timer__get_milliseconds() - OPT__DEBOUNCE_TIME;