1
0
Fork 0

handwired/nicekey optimisation (#14788)

* handwired/nicekey optimisation

* Add some consts

* Read address from progmem, pass it into send_string_with_delay_P
This commit is contained in:
Ryan 2021-10-12 00:41:31 +11:00 committed by GitHub
parent 5640b6cd77
commit 633ef1441b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 141 additions and 80 deletions

View file

@ -1,75 +1,132 @@
#include QMK_KEYBOARD_H #include QMK_KEYBOARD_H
#define RANDOM_STRING_DELAY 100
enum custom_keycodes { enum custom_keycodes {
RANDOM_STRING_MACRO = SAFE_RANGE RANDOM_STRING_MACRO = SAFE_RANGE
}; };
const int delay = 100; const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
const char *sentences[] = { LAYOUT(
"I hope you have a great day!\n", RANDOM_STRING_MACRO
"You are an awesome person.\n", )
"I wish I knew you better, you seem nice!\n", };
"Your views restore my faith in humanity\n",
"You are as cool as a norm-critical disney princess\n", const char sentence_01[] PROGMEM = "I hope you have a great day!";
"You have impeccable manners.\n", const char sentence_02[] PROGMEM = "You are an awesome person.";
"You are making me smile\n", const char sentence_03[] PROGMEM = "I wish I knew you better, you seem nice!";
"You are making a difference\n", const char sentence_04[] PROGMEM = "Your views restore my faith in humanity";
"You bring out the best in other people\n", const char sentence_05[] PROGMEM = "You are as cool as a norm-critical disney princess";
"You are all that and a super-size bag of chips.\n", const char sentence_06[] PROGMEM = "You have impeccable manners.";
"You are not someone I pretend to not see in public.\n", const char sentence_07[] PROGMEM = "You are making me smile";
"Are you a beaver, because damn.\n", const char sentence_08[] PROGMEM = "You are making a difference";
"I bet you make babies smile.\n", const char sentence_09[] PROGMEM = "You bring out the best in other people";
"You are awkward, in a cute way. Like an elevator ride, but with puppies.\n", const char sentence_10[] PROGMEM = "You are all that and a super-size bag of chips.";
"Looking like a complete idiot with you is really fun.\n", const char sentence_11[] PROGMEM = "You are not someone I pretend to not see in public.";
"If you cooked something really bad, I would tell you instead of eating it.\n", const char sentence_12[] PROGMEM = "Are you a beaver, because damn.";
"I love how passionate you are about your hobby.\n", const char sentence_13[] PROGMEM = "I bet you make babies smile.";
"Our conversations always make me feel better.\n", const char sentence_14[] PROGMEM = "You are awkward, in a cute way. Like an elevator ride, but with puppies.";
"It is amazing how far out of your way you go to help people.\n", const char sentence_15[] PROGMEM = "Looking like a complete idiot with you is really fun.";
"I am so glad that you wrote something here.\n", const char sentence_16[] PROGMEM = "If you cooked something really bad, I would tell you instead of eating it.";
"Hey you! How nice to see a friendly person in my feed!\n", const char sentence_17[] PROGMEM = "I love how passionate you are about your hobby.";
"I hope we know each other for a long time.\n", const char sentence_18[] PROGMEM = "Our conversations always make me feel better.";
"I bet if Britney Spears knew you, 2008 would have gone a lot differently.\n", const char sentence_19[] PROGMEM = "It is amazing how far out of your way you go to help people.";
"I would trust you with my passwords.\n", const char sentence_20[] PROGMEM = "I am so glad that you wrote something here.";
"You are a great problem solver\n", const char sentence_21[] PROGMEM = "Hey you! How nice to see a friendly person in my feed!";
"I would love to hear you laugh!\n", const char sentence_22[] PROGMEM = "I hope we know each other for a long time.";
"Please, have a monologue about your week, I just want to listen to you!\n", const char sentence_23[] PROGMEM = "I bet if Britney Spears knew you, 2008 would have gone a lot differently.";
"You are very far from being Trump.\n", const char sentence_24[] PROGMEM = "I would trust you with my passwords.";
"I think my dog might like you more than me\n", const char sentence_25[] PROGMEM = "You are a great problem solver";
"I feel like you would be a great person to do a group project with\n", const char sentence_26[] PROGMEM = "I would love to hear you laugh!";
"I bet animals love you\n", const char sentence_27[] PROGMEM = "Please, have a monologue about your week, I just want to listen to you!";
"I bet even Kanye would like you more than himself\n", const char sentence_28[] PROGMEM = "You are very far from being Trump.";
"You are just doing a great job at life\n", const char sentence_29[] PROGMEM = "I think my dog might like you more than me";
"I like how you are challenging me.\n", const char sentence_30[] PROGMEM = "I feel like you would be a great person to do a group project with";
"You would do be a great mother!\n", const char sentence_31[] PROGMEM = "I bet animals love you";
"I... Baked bread for you.\n", const char sentence_32[] PROGMEM = "I bet even Kanye would like you more than himself";
"Wow. You.\n", const char sentence_33[] PROGMEM = "You are just doing a great job at life";
"You would not have let that balrog pass!\n", const char sentence_34[] PROGMEM = "I like how you are challenging me.";
"Thank you.\n", const char sentence_35[] PROGMEM = "You would do be a great mother!";
"You would be standing out in a crowd\n", const char sentence_36[] PROGMEM = "I... Baked bread for you.";
"Your sense of style is amazing.\n", const char sentence_37[] PROGMEM = "Wow. You.";
"You have a beautiful mind.\n", const char sentence_38[] PROGMEM = "You would not have let that balrog pass!";
"I like that big juicy brain of yours\n", const char sentence_39[] PROGMEM = "Thank you.";
"I would share my cinnamon bun with you\n", const char sentence_40[] PROGMEM = "You would be standing out in a crowd";
"I like you more than i like my moms apple pie\n", const char sentence_41[] PROGMEM = "Your sense of style is amazing.";
"You give me the same feeling as a summers night\n", const char sentence_42[] PROGMEM = "You have a beautiful mind.";
"I enjoy you more than the click of my mechanical switch\n", const char sentence_43[] PROGMEM = "I like that big juicy brain of yours";
"I would let you pop my bubble wrap\n", const char sentence_44[] PROGMEM = "I would share my cinnamon bun with you";
"Being near you is like being inside of a poem\n" const char sentence_45[] PROGMEM = "I like you more than i like my moms apple pie";
const char sentence_46[] PROGMEM = "You give me the same feeling as a summers night";
const char sentence_47[] PROGMEM = "I enjoy you more than the click of my mechanical switch";
const char sentence_48[] PROGMEM = "I would let you pop my bubble wrap";
const char sentence_49[] PROGMEM = "Being near you is like being inside of a poem";
PGM_P const sentences[] PROGMEM = {
sentence_01,
sentence_02,
sentence_03,
sentence_04,
sentence_05,
sentence_06,
sentence_07,
sentence_08,
sentence_09,
sentence_10,
sentence_11,
sentence_12,
sentence_13,
sentence_14,
sentence_15,
sentence_16,
sentence_17,
sentence_18,
sentence_19,
sentence_20,
sentence_21,
sentence_22,
sentence_23,
sentence_24,
sentence_25,
sentence_26,
sentence_27,
sentence_28,
sentence_29,
sentence_30,
sentence_31,
sentence_32,
sentence_33,
sentence_34,
sentence_35,
sentence_36,
sentence_37,
sentence_38,
sentence_39,
sentence_40,
sentence_41,
sentence_42,
sentence_43,
sentence_44,
sentence_45,
sentence_46,
sentence_47,
sentence_48,
sentence_49
}; };
bool process_record_user(uint16_t keycode, keyrecord_t *record) { bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) { if (record->event.pressed) {
int sentences_size = sizeof(sentences) / sizeof(sentences[0]); int sentences_size = sizeof(sentences) / sizeof(sentences[0]);
int i = rand() % sentences_size; int i = rand() % sentences_size;
switch (keycode) { switch (keycode) {
case RANDOM_STRING_MACRO: case RANDOM_STRING_MACRO:
send_string_with_delay(sentences[i], delay); send_string_with_delay_P((PGM_P)pgm_read_word(&(sentences[i])), RANDOM_STRING_DELAY);
tap_code(KC_ENT);
return false; return false;
} }
} }
return true;
};
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { return true;
LAYOUT( RANDOM_STRING_MACRO ) }
};

View file

@ -2,12 +2,11 @@
![The first NiceKey](https://s3.eu-central-1.amazonaws.com/mindlevel/nicekey.jpg) ![The first NiceKey](https://s3.eu-central-1.amazonaws.com/mindlevel/nicekey.jpg)
Custom handwired nicekey, a one key keyboard that writes random compliments. Custom handwired nicekey, a one key keyboard that writes random compliments.
Keyboard Maintainer: [spydon](https://github.com/spydon) * Keyboard Maintainer: [spydon](https://github.com/spydon)
Hardware Supported: Custom handwired one key * Hardware Supported: Custom handwired one key
Hardware Availability: * Hardware Availability: n/a
Switch must be connected to pins C6 and B6. Switch must be connected to pins C6 and B6.

View file

@ -5,12 +5,17 @@ MCU = atmega32u4
BOOTLOADER = caterina BOOTLOADER = caterina
# Build Options # Build Options
# comment out to disable the options. # change yes to no to disable
# #
BOOTMAGIC_ENABLE = no # Enable Bootmagic Lite BOOTMAGIC_ENABLE = no # Enable Bootmagic Lite
MOUSEKEY_ENABLE = yes # Mouse keys MOUSEKEY_ENABLE = yes # Mouse keys
EXTRAKEY_ENABLE = yes # Audio control and System control EXTRAKEY_ENABLE = yes # Audio control and System control
CONSOLE_ENABLE = yes # Console for debug CONSOLE_ENABLE = no # Console for debug
COMMAND_ENABLE = yes # Commands for debug and configuration COMMAND_ENABLE = no # Commands for debug and configuration
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
NKRO_ENABLE = no # USB Nkey Rollover
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
AUDIO_ENABLE = no # Audio output