2020-03-17 01:29:52 +01: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 07:49:18 +02:00
|
|
|
LAYOUT_ortho_1x1(ADC_SAMPLE)
|
2020-03-17 01:29:52 +01: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 07:49:18 +02:00
|
|
|
char buffer[50];
|
2020-03-17 01:29:52 +01:00
|
|
|
sprintf(buffer, "ADC:%u\n", val);
|
|
|
|
#ifdef CONSOLE_ENABLE
|
2023-04-03 06:28:12 +02:00
|
|
|
uprintf("%s", buffer);
|
2020-03-17 01:29:52 +01:00
|
|
|
#else
|
2020-08-17 00:10:48 +02:00
|
|
|
send_string(buffer);
|
2020-03-17 01:29:52 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
|
|
|
// adc_mux pinToMux(pin_t pin) {
|
2020-06-08 07:49:18 +02:00
|
|
|
// return TO_MUX(ADC_CHANNEL_IN1, 0);
|
2020-03-17 01:29:52 +01:00
|
|
|
// };
|