(intermediate)

partial-rewrite
Ben Blazak 2013-03-29 15:48:39 -07:00
parent 7eec5fb237
commit 02fd5471ae
3 changed files with 31 additions and 9 deletions

View File

@ -119,6 +119,12 @@
(http://arduino.cc/forum/index.php/topic,44830.0.html)
(on <http://arduino.cc/>)
* [what happens in os when we dereference a null pointer in c]
(http://stackoverflow.com/questions/12645647/what-happens-in-os-when-we-dereference-a-null-pointer-in-c)
Doesn't apply to AVRs really (since what happens in implementation defined
according to the C standard, and I didn't see AVRs mentioned; and AVRs don't
typically run an OS anyway), but still quite interesting.
### C++ Stuff
* [Google C++ Style Guide]

View File

@ -30,9 +30,9 @@ void kf__release (uint16_t keycode);
void kf__toggle (uint16_t keycode);
void kf__layer__push (uint16_t id__layer);
void kf__layer__pop (uint16_t id__ignore);
void kf__macro__sram (uint16_t pointer);
// void kf__macro__sram (uint16_t pointer); // TODO
void kf__macro__progmem (uint16_t pointer);
void kf__macro__eeprom (uint16_t pointer);
// void kf__macro__eeprom (uint16_t pointer); // TODO
// TODO: chording
//
@ -48,6 +48,15 @@ void kf__macro__eeprom (uint16_t pointer);
// treated as array indices (the burden being on the user not to use indices
// that are too large...)
//
// TODO: kf__macro__eeprom
// - this should probably go into its own little place in 'lib'; it'll need a
// function to write the macro to memory, code to keep track of what's
// written in the eeprom, and stuff like that
//
// TODO: kf__macro__sram
// - is this necessary? will it be confusing (if we already have
// kf__macro__eeprom)? we should probably remove it.
//
// TODO: rewrite layouts to reflect
// - kf__two_keys_capslock() -> kf__toggle_capslock()
// - the removal of kf__send()

View File

@ -13,6 +13,7 @@
#include <avr/pgmspace.h>
#include "../../../../firmware/lib/usb.h"
#include "../../../../firmware/lib/layout/layer-stack.h"
#include "../key-functions.h"
// ----------------------------------------------------------------------------
@ -42,12 +43,18 @@ void kf__layer__pop(uint16_t id__ignore) {
layer_stack__pop_id( ((uint8_t)(id__ignore >> 8)) );
}
void kf__macro__sram(uint16_t pointer) { // TODO
}
void kf__macro__progmem(uint16_t pointer) { // TODO
}
void kf__macro__eeprom(uint16_t pointer) { // TODO
void kf__macro__progmem(uint16_t pointer) { // TODO: test
uint16_t last_element = pointer + 2 * (uint16_t) pgm_read_word(pointer);
kf__function_pointer_t function;
uint16_t argument;
for(pointer += 1; pointer <= last_element; pointer += 2) {
function = (kf__function_pointer_t) pgm_read_word( pointer );
argument = (uint16_t) pgm_read_word( pointer+1 );
if (function)
(*function)(argument);
}
}