diff options
| -rw-r--r-- | keyboards/handwired/promethium/config.h | 89 | ||||
| -rw-r--r-- | keyboards/handwired/promethium/keymaps/priyadi/keymap.c | 4 | ||||
| -rw-r--r-- | keyboards/handwired/promethium/promethium.c | 19 | ||||
| -rw-r--r-- | keyboards/handwired/promethium/promethium.h | 4 |
4 files changed, 92 insertions, 24 deletions
diff --git a/keyboards/handwired/promethium/config.h b/keyboards/handwired/promethium/config.h index 23fbfd0b9..fd45c2bfe 100644 --- a/keyboards/handwired/promethium/config.h +++ b/keyboards/handwired/promethium/config.h | |||
| @@ -43,38 +43,107 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 43 | #define MATRIX_ROW_PINS { D7, C6, D0, D1, F5, F4, F1, F0 } | 43 | #define MATRIX_ROW_PINS { D7, C6, D0, D1, F5, F4, F1, F0 } |
| 44 | #define UNUSED_PINS | 44 | #define UNUSED_PINS |
| 45 | 45 | ||
| 46 | /* COL2ROW or ROW2COL */ | 46 | /* |
| 47 | * Keyboard Matrix Assignments | ||
| 48 | * | ||
| 49 | * Change this to how you wired your keyboard | ||
| 50 | * COLS: AVR pins used for columns, left to right | ||
| 51 | * ROWS: AVR pins used for rows, top to bottom | ||
| 52 | * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode) | ||
| 53 | * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode) | ||
| 54 | * | ||
| 55 | */ | ||
| 47 | #define DIODE_DIRECTION COL2ROW | 56 | #define DIODE_DIRECTION COL2ROW |
| 48 | 57 | ||
| 49 | /* define if matrix has ghost */ | 58 | // #define BACKLIGHT_PIN B7 |
| 59 | // #define BACKLIGHT_BREATHING | ||
| 60 | // #define BACKLIGHT_LEVELS 3 | ||
| 61 | |||
| 62 | /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ | ||
| 63 | #define DEBOUNCING_DELAY 5 | ||
| 64 | |||
| 65 | /* define if matrix has ghost (lacks anti-ghosting diodes) */ | ||
| 50 | //#define MATRIX_HAS_GHOST | 66 | //#define MATRIX_HAS_GHOST |
| 51 | 67 | ||
| 52 | /* number of backlight levels */ | 68 | /* number of backlight levels */ |
| 53 | #define BACKLIGHT_LEVELS 3 | ||
| 54 | |||
| 55 | /* Set 0 if debouncing isn't needed */ | ||
| 56 | #define DEBOUNCING_DELAY 5 | ||
| 57 | 69 | ||
| 58 | /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ | 70 | /* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ |
| 59 | #define LOCKING_SUPPORT_ENABLE | 71 | // #define LOCKING_SUPPORT_ENABLE |
| 60 | /* Locking resynchronize hack */ | 72 | /* Locking resynchronize hack */ |
| 61 | #define LOCKING_RESYNC_ENABLE | 73 | // #define LOCKING_RESYNC_ENABLE |
| 74 | |||
| 75 | /* | ||
| 76 | * Force NKRO | ||
| 77 | * | ||
| 78 | * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved | ||
| 79 | * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the | ||
| 80 | * makefile for this to work.) | ||
| 81 | * | ||
| 82 | * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N) | ||
| 83 | * until the next keyboard reset. | ||
| 84 | * | ||
| 85 | * NKRO may prevent your keystrokes from being detected in the BIOS, but it is | ||
| 86 | * fully operational during normal computer usage. | ||
| 87 | * | ||
| 88 | * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N) | ||
| 89 | * or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by | ||
| 90 | * bootmagic, NKRO mode will always be enabled until it is toggled again during a | ||
| 91 | * power-up. | ||
| 92 | * | ||
| 93 | */ | ||
| 94 | //#define FORCE_NKRO | ||
| 62 | 95 | ||
| 63 | /* key combination for command */ | 96 | /* key combination for command */ |
| 64 | #define IS_COMMAND() ( \ | 97 | #define IS_COMMAND() ( \ |
| 65 | keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT) | MOD_BIT(KC_LCTRL) | MOD_BIT(KC_RCTRL)) \ | 98 | keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT) | MOD_BIT(KC_LCTRL) | MOD_BIT(KC_RCTRL)) \ |
| 66 | ) | 99 | ) |
| 67 | 100 | ||
| 101 | /* control how magic key switches layers */ | ||
| 102 | //#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS true | ||
| 103 | //#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS true | ||
| 104 | //#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM false | ||
| 105 | |||
| 106 | /* override magic key keymap */ | ||
| 107 | //#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS | ||
| 108 | //#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS | ||
| 109 | //#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM | ||
| 110 | //#define MAGIC_KEY_HELP1 H | ||
| 111 | //#define MAGIC_KEY_HELP2 SLASH | ||
| 112 | //#define MAGIC_KEY_DEBUG D | ||
| 113 | //#define MAGIC_KEY_DEBUG_MATRIX X | ||
| 114 | //#define MAGIC_KEY_DEBUG_KBD K | ||
| 115 | //#define MAGIC_KEY_DEBUG_MOUSE M | ||
| 116 | //#define MAGIC_KEY_VERSION V | ||
| 117 | //#define MAGIC_KEY_STATUS S | ||
| 118 | //#define MAGIC_KEY_CONSOLE C | ||
| 119 | //#define MAGIC_KEY_LAYER0_ALT1 ESC | ||
| 120 | //#define MAGIC_KEY_LAYER0_ALT2 GRAVE | ||
| 121 | //#define MAGIC_KEY_LAYER0 0 | ||
| 122 | //#define MAGIC_KEY_LAYER1 1 | ||
| 123 | //#define MAGIC_KEY_LAYER2 2 | ||
| 124 | //#define MAGIC_KEY_LAYER3 3 | ||
| 125 | //#define MAGIC_KEY_LAYER4 4 | ||
| 126 | //#define MAGIC_KEY_LAYER5 5 | ||
| 127 | //#define MAGIC_KEY_LAYER6 6 | ||
| 128 | //#define MAGIC_KEY_LAYER7 7 | ||
| 129 | //#define MAGIC_KEY_LAYER8 8 | ||
| 130 | //#define MAGIC_KEY_LAYER9 9 | ||
| 131 | //#define MAGIC_KEY_BOOTLOADER PAUSE | ||
| 132 | //#define MAGIC_KEY_LOCK CAPS | ||
| 133 | //#define MAGIC_KEY_EEPROM E | ||
| 134 | //#define MAGIC_KEY_NKRO N | ||
| 135 | //#define MAGIC_KEY_SLEEP_LED Z | ||
| 136 | |||
| 68 | /* | 137 | /* |
| 69 | * Feature disable options | 138 | * Feature disable options |
| 70 | * These options are also useful to firmware size reduction. | 139 | * These options are also useful to firmware size reduction. |
| 71 | */ | 140 | */ |
| 72 | 141 | ||
| 73 | /* disable debug print */ | 142 | /* disable debug print */ |
| 74 | //#define NO_DEBUG | 143 | // #define NO_DEBUG |
| 75 | 144 | ||
| 76 | /* disable print */ | 145 | /* disable print */ |
| 77 | //#define NO_PRINT | 146 | // #define NO_PRINT |
| 78 | 147 | ||
| 79 | /* disable action features */ | 148 | /* disable action features */ |
| 80 | //#define NO_ACTION_LAYER | 149 | //#define NO_ACTION_LAYER |
diff --git a/keyboards/handwired/promethium/keymaps/priyadi/keymap.c b/keyboards/handwired/promethium/keymaps/priyadi/keymap.c index 6eb4e903f..992a03a41 100644 --- a/keyboards/handwired/promethium/keymaps/priyadi/keymap.c +++ b/keyboards/handwired/promethium/keymaps/priyadi/keymap.c | |||
| @@ -987,8 +987,8 @@ void matrix_scan_user(void) { | |||
| 987 | led_set_layer_indicator(); | 987 | led_set_layer_indicator(); |
| 988 | } | 988 | } |
| 989 | 989 | ||
| 990 | void battery_poll(float percentage) { | 990 | void battery_poll(uint8_t level) { |
| 991 | rgbsps_sethsv(LED_IND_BATTERY, percentage*120/100, 255, 15); | 991 | rgbsps_sethsv(LED_IND_BATTERY, level * 120/255, 255, 15); |
| 992 | rgbsps_send(); | 992 | rgbsps_send(); |
| 993 | } | 993 | } |
| 994 | 994 | ||
diff --git a/keyboards/handwired/promethium/promethium.c b/keyboards/handwired/promethium/promethium.c index adfc11e2a..3e369a624 100644 --- a/keyboards/handwired/promethium/promethium.c +++ b/keyboards/handwired/promethium/promethium.c | |||
| @@ -3,20 +3,17 @@ | |||
| 3 | #include "timer.h" | 3 | #include "timer.h" |
| 4 | #include "matrix.h" | 4 | #include "matrix.h" |
| 5 | 5 | ||
| 6 | float battery_percentage(void) { | 6 | // cubic fit {3.3, 0}, {3.5, 2.9}, {3.6, 5}, {3.7, 8.6}, {3.8, 36}, {3.9, 62}, {4.0, 73}, {4.05, 83}, {4.1, 89}, {4.15, 94}, {4.2, 100} |
| 7 | |||
| 8 | uint8_t battery_level(void) { | ||
| 7 | float voltage = analogRead(BATTERY_PIN) * 2 * 3.3 / 1024; | 9 | float voltage = analogRead(BATTERY_PIN) * 2 * 3.3 / 1024; |
| 8 | float percentage = (voltage - 3.5) * 143; | 10 | if (voltage < MIN_VOLTAGE) return 0; |
| 9 | if (percentage > 100) { | 11 | if (voltage > MAX_VOLTAGE) return 255; |
| 10 | return 100; | 12 | return (voltage - MIN_VOLTAGE) / (MAX_VOLTAGE - MIN_VOLTAGE) * 255; |
| 11 | } else if (percentage < 0) { | ||
| 12 | return 0; | ||
| 13 | } else { | ||
| 14 | return percentage; | ||
| 15 | } | ||
| 16 | } | 13 | } |
| 17 | 14 | ||
| 18 | __attribute__ ((weak)) | 15 | __attribute__ ((weak)) |
| 19 | void battery_poll(float percentage) { | 16 | void battery_poll(uint8_t level) { |
| 20 | } | 17 | } |
| 21 | 18 | ||
| 22 | void matrix_init_kb(void) { | 19 | void matrix_init_kb(void) { |
| @@ -29,7 +26,7 @@ void matrix_scan_kb(void) { | |||
| 29 | 26 | ||
| 30 | if (counter > BATTERY_POLL) { | 27 | if (counter > BATTERY_POLL) { |
| 31 | counter = 0; | 28 | counter = 0; |
| 32 | battery_poll(battery_percentage()); | 29 | battery_poll(battery_level()); |
| 33 | } | 30 | } |
| 34 | 31 | ||
| 35 | matrix_scan_user(); | 32 | matrix_scan_user(); |
diff --git a/keyboards/handwired/promethium/promethium.h b/keyboards/handwired/promethium/promethium.h index 6d51f81ca..da37e5c56 100644 --- a/keyboards/handwired/promethium/promethium.h +++ b/keyboards/handwired/promethium/promethium.h | |||
| @@ -7,6 +7,8 @@ | |||
| 7 | #define UNICODE_TYPE_DELAY 0 | 7 | #define UNICODE_TYPE_DELAY 0 |
| 8 | #define BATTERY_PIN 9 | 8 | #define BATTERY_PIN 9 |
| 9 | #define BATTERY_POLL 30000 | 9 | #define BATTERY_POLL 30000 |
| 10 | #define MAX_VOLTAGE 4.2 | ||
| 11 | #define MIN_VOLTAGE 3.2 | ||
| 10 | 12 | ||
| 11 | #define KEYMAP( \ | 13 | #define KEYMAP( \ |
| 12 | k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b, k1c, \ | 14 | k11, k12, k13, k14, k15, k16, k17, k18, k19, k1a, k1b, k1c, \ |
| @@ -103,4 +105,4 @@ enum led_sequence { | |||
| 103 | 105 | ||
| 104 | #endif | 106 | #endif |
| 105 | 107 | ||
| 106 | void battery_poll(float percentage); \ No newline at end of file | 108 | void battery_poll(uint8_t level); \ No newline at end of file |
