2020-03-17 00:29:52 +00:00
|
|
|
#include QMK_KEYBOARD_H
|
|
|
|
#include "analog.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
enum custom_keycodes {
|
|
|
|
ADC_SAMPLE = SAFE_RANGE,
|
|
|
|
};
|
|
|
|
|
|
|
|
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
2020-06-08 05:49:18 +00:00
|
|
|
LAYOUT_ortho_1x1(ADC_SAMPLE)
|
2020-03-17 00:29:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
|
|
|
switch (keycode) {
|
|
|
|
case ADC_SAMPLE:
|
|
|
|
if (record->event.pressed) {
|
|
|
|
int16_t val = analogReadPin(ADC_PIN);
|
|
|
|
|
2020-06-08 05:49:18 +00:00
|
|
|
char buffer[50];
|
2020-03-17 00:29:52 +00:00
|
|
|
sprintf(buffer, "ADC:%u\n", val);
|
|
|
|
#ifdef CONSOLE_ENABLE
|
2023-04-03 04:28:12 +00:00
|
|
|
uprintf("%s", buffer);
|
2020-03-17 00:29:52 +00:00
|
|
|
#else
|
2020-08-16 22:10:48 +00:00
|
|
|
send_string(buffer);
|
2020-03-17 00:29:52 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
|
|
|
// adc_mux pinToMux(pin_t pin) {
|
2020-06-08 05:49:18 +00:00
|
|
|
// return TO_MUX(ADC_CHANNEL_IN1, 0);
|
2020-03-17 00:29:52 +00:00
|
|
|
// };
|