9 Commits

Author SHA1 Message Date
jonny_l480
3a99b8bc5c Adjust analog-sw thresholds, Disable logging (loglevel)
=> tested system with new stripboard and actual hardware: system
works as expected with new all combinations of the 4 switches
connected to 1 adc

- Adjust lookup voltage for switch combinations, after connecting the
stripboard to actualy used pcb (apparently there was a >100
difference using an other adc channel + pcb)

- define loglevel for analogswitches to WARN
2022-09-12 13:19:54 +02:00
jonny_ji7
451981b165 Rework switch-assignment, Update connection-plan
Rework config.cpp and config.hpp:
 - different naming convention for evaluated switch objects
 - thus updated macros for switches

 - add new evalswitch instances for 4 switches on 1 adc
 - update switch assignment, use the 4 new inputs

Update connection plan with new assignment, add stripboard details
2022-09-12 11:50:45 +02:00
jonny_ji7
1f53fabd19 Create gpio_adc component - outsource readAdc()
remove duplicate code:
function readAdc was used in multiple files, outsourced this to gpio
component
2022-09-12 11:19:47 +02:00
jonny_ji7
d2d85952df Add evalSwitch instance for sw on adc (testing)
Test all new changes in switchesAnalog and evaluatedSwitch
2022-09-12 09:58:08 +02:00
jonny_ji7
38ad266488 Remove public handle func, add getState functions
switchesAnalog:
- Add functions for obtaining states from each switch
- Remove public handle function, (now run locally at each state request of
a pin)

- adjust main.cpp to work with new functions
2022-09-12 09:57:22 +02:00
jonny_ji7
a932460924 EvalSwitch: Add func as source, remove dupl code
evaluatedSwitch component:
- remove duplicate code for inverted and non-inverted mode
- add new constructor for instance with a function to obtain current
  input state instead of gpio pin (e.g. needed for 4switches on analog input)
2022-09-12 09:47:06 +02:00
jonny_ji7
09ee67f583 Add code for demuxing 4 switch signals from adc pin
- create new files with code for demultiplexing the 4 switches from the
  one analog signal
- define lookup table with measurements done with the build pcb, test
  switches and esp32 breakout board
- add note do config that gpio used for digital in is now used for
  this multiplexer
- main.cpp: disable control task, run new handle function in a loop for
  testing
2022-09-11 19:58:13 +02:00
jonny_ji7
f52a58aa1c Add schematic, layout, calculations for 4swToAdc
Add details and calculations for a stripboard with a resistor network that makes it
possible to connect 4 switches (to gnd) to one adc pin of the controller
2022-09-11 19:53:57 +02:00
jonny_ji7
7eb06fe228 Add wire-cutter to connection-plan and function-diagram 2022-09-04 11:56:32 +02:00
21 changed files with 1266 additions and 158 deletions

View File

@@ -1,4 +1,6 @@
idf_component_register( idf_component_register(
SRCS "gpio_evaluateSwitch.cpp" SRCS
"gpio_evaluateSwitch.cpp"
"gpio_adc.cpp"
INCLUDE_DIRS "." INCLUDE_DIRS "."
) )

View File

@@ -0,0 +1,21 @@
#include "gpio_adc.hpp"
//=============================
//========= readAdc ===========
//=============================
//function for multisampling an anlog input
int gpio_readAdc(adc1_channel_t adc_channel, bool inverted) {
//make multiple measurements
int adc_reading = 0;
for (int i = 0; i < 32; i++) {
adc_reading += adc1_get_raw(adc_channel);
}
adc_reading = adc_reading / 32;
//return original or inverted result
if (inverted) {
return 4095 - adc_reading;
} else {
return adc_reading;
}
}

View File

@@ -0,0 +1,9 @@
#pragma once
#include <stdio.h>
#include "driver/adc.h"
//function for multisampling an anlog input
//measures 30 times and returns average
//if invertion is used currently 11bit resolution is assumed (subtracts from 4095)
//TODO: rework this function to be more universal
int gpio_readAdc(adc1_channel_t adc_channel, bool inverted = false);

View File

@@ -9,12 +9,12 @@ gpio_evaluatedSwitch::gpio_evaluatedSwitch( //minimal (use default values)
gpio_num = gpio_num_declare; gpio_num = gpio_num_declare;
pullup = true; pullup = true;
inverted = false; inverted = false;
inputSource = inputSource_t::GPIO;
init(); initGpio();
}; };
gpio_evaluatedSwitch::gpio_evaluatedSwitch( //optional parameters given gpio_evaluatedSwitch::gpio_evaluatedSwitch( //optional parameters given
gpio_num_t gpio_num_declare, gpio_num_t gpio_num_declare,
bool pullup_declare, bool pullup_declare,
@@ -23,13 +23,25 @@ gpio_evaluatedSwitch::gpio_evaluatedSwitch( //optional parameters given
gpio_num = gpio_num_declare; gpio_num = gpio_num_declare;
pullup = pullup_declare; pullup = pullup_declare;
inverted = inverted_declare; inverted = inverted_declare;
inputSource = inputSource_t::GPIO;
init(); initGpio();
};
gpio_evaluatedSwitch::gpio_evaluatedSwitch( //with function as input source
bool (*getInputStatePtr_f)(void),
bool inverted_f){
//gpio_num = NULL;
//pullup = NULL;
inverted = inverted_f;
getInputStatePtr = getInputStatePtr_f;
inputSource = inputSource_t::FUNCTION;
}; };
void gpio_evaluatedSwitch::init(){ void gpio_evaluatedSwitch::initGpio(){
ESP_LOGI(TAG, "initializing gpio pin %d", (int)gpio_num); ESP_LOGI(TAG, "initializing gpio pin %d", (int)gpio_num);
//define gpio pin as input //define gpio pin as input
@@ -48,122 +60,85 @@ void gpio_evaluatedSwitch::init(){
}; };
void gpio_evaluatedSwitch::handle(){ //Statemachine for debouncing and edge detection void gpio_evaluatedSwitch::handle(){ //Statemachine for debouncing and edge detection
//--- get pin state with required method ---
switch (inputSource){
case inputSource_t::GPIO: //from gpio pin
if (gpio_get_level(gpio_num) == 0){ //pin low
inputState = true;
} else { //pin high
inputState = false;
}
break;
case inputSource_t::FUNCTION: //from funtion
inputState = (*getInputStatePtr)();
break;
}
//--- invert state ---
//not inverted: switch switches to GND when active
//inverted: switch switched to VCC when active
if (inverted == true){ if (inverted == true){
//========================================================= inputState = !inputState;
//=========== Statemachine for inverted switch ============ }
//=================== (switch to VCC) =====================
//=========================================================
switch (p_state){
default:
p_state = switchState::FALSE;
break;
case switchState::FALSE: //input confirmed high (released)
fallingEdge = false; //reset edge event
if (gpio_get_level(gpio_num) == 1){ //pin high (on)
p_state = switchState::HIGH;
timestampHigh = esp_log_timestamp(); //save timestamp switched from low to high
} else {
msReleased = esp_log_timestamp() - timestampLow; //update duration released
}
break;
case switchState::HIGH: //input recently switched to high (pressed) //=========================================================
if (gpio_get_level(gpio_num) == 1){ //pin still high (on) //========= Statemachine for evaluateing switch ===========
if (esp_log_timestamp() - timestampHigh > minOnMs){ //pin in same state long enough //=========================================================
p_state = switchState::TRUE; switch (p_state){
state = true; default:
risingEdge = true; p_state = switchState::FALSE;
msReleased = timestampHigh - timestampLow; //calculate duration the button was released break;
}
}else{
p_state = switchState::FALSE;
}
break;
case switchState::TRUE: //input confirmed high (pressed) case switchState::FALSE: //input confirmed high (released)
risingEdge = false; //reset edge event fallingEdge = false; //reset edge event
if (gpio_get_level(gpio_num) == 0){ //pin low (off) if (inputState == true){ //pin high (on)
timestampLow = esp_log_timestamp(); p_state = switchState::HIGH;
p_state = switchState::LOW; timestampHigh = esp_log_timestamp(); //save timestamp switched from low to high
} else { } else {
msPressed = esp_log_timestamp() - timestampHigh; //update duration pressed msReleased = esp_log_timestamp() - timestampLow; //update duration released
} }
break;
break; case switchState::HIGH: //input recently switched to high (pressed)
if (inputState == true){ //pin still high (on)
case switchState::LOW: //input recently switched to low (released) if (esp_log_timestamp() - timestampHigh > minOnMs){ //pin in same state long enough
if (gpio_get_level(gpio_num) == 0){ //pin still low (off)
if (esp_log_timestamp() - timestampLow > minOffMs){ //pin in same state long enough
p_state = switchState::FALSE;
msPressed = timestampLow - timestampHigh; //calculate duration the button was pressed
state=false;
fallingEdge=true;
}
}else{
p_state = switchState::TRUE; p_state = switchState::TRUE;
state = true;
risingEdge = true;
msReleased = timestampHigh - timestampLow; //calculate duration the button was released
} }
break; }else{
}
}else{
//=========================================================
//========= Statemachine for not inverted switch ==========
//=================== (switch to GND) =====================
//=========================================================
switch (p_state){
default:
p_state = switchState::FALSE; p_state = switchState::FALSE;
break; }
break;
case switchState::FALSE: //input confirmed high (released) case switchState::TRUE: //input confirmed high (pressed)
fallingEdge = false; //reset edge event risingEdge = false; //reset edge event
if (gpio_get_level(gpio_num) == 0){ //pin low (on) if (inputState == false){ //pin low (off)
p_state = switchState::LOW; timestampLow = esp_log_timestamp();
timestampLow = esp_log_timestamp(); //save timestamp switched from high to low p_state = switchState::LOW;
} else { } else {
msReleased = esp_log_timestamp() - timestampHigh; //update duration released msPressed = esp_log_timestamp() - timestampHigh; //update duration pressed
} }
break;
case switchState::LOW: //input recently switched to low (pressed) break;
if (gpio_get_level(gpio_num) == 0){ //pin still low (on)
if (esp_log_timestamp() - timestampLow > minOnMs){ //pin in same state long enough case switchState::LOW: //input recently switched to low (released)
p_state = switchState::TRUE; if (inputState == false){ //pin still low (off)
state = true; if (esp_log_timestamp() - timestampLow > minOffMs){ //pin in same state long enough
risingEdge = true;
msReleased = timestampLow - timestampHigh; //calculate duration the button was released
}
}else{
p_state = switchState::FALSE; p_state = switchState::FALSE;
msPressed = timestampLow - timestampHigh; //calculate duration the button was pressed
state=false;
fallingEdge=true;
} }
break; }else{
p_state = switchState::TRUE;
case switchState::TRUE: //input confirmed low (pressed) }
risingEdge = false; //reset edge event break;
if (gpio_get_level(gpio_num) == 1){ //pin high (off)
timestampHigh = esp_log_timestamp();
p_state = switchState::HIGH;
} else {
msPressed = esp_log_timestamp() - timestampLow; //update duration pressed
}
break;
case switchState::HIGH: //input recently switched to high (released)
if (gpio_get_level(gpio_num) == 1){ //pin still high (off)
if (esp_log_timestamp() - timestampHigh > minOffMs){ //pin in same state long enough
p_state = switchState::FALSE;
msPressed = timestampHigh - timestampLow; //calculate duration the button was pressed
state=false;
fallingEdge=true;
}
}else{
p_state = switchState::TRUE;
}
break;
}
} }
} }

View File

@@ -18,21 +18,30 @@ extern "C"
//switch to VCC (inverted) and dont use internal pullup: //switch to VCC (inverted) and dont use internal pullup:
//gpio_evaluatedSwitch s3(GPIO_NUM_14 false, true); //gpio_evaluatedSwitch s3(GPIO_NUM_14 false, true);
enum class inputSource_t {GPIO, FUNCTION};
class gpio_evaluatedSwitch { class gpio_evaluatedSwitch {
public: public:
//--- input --- //--- input ---
uint32_t minOnMs = 30; uint32_t minOnMs = 30;
uint32_t minOffMs = 30; uint32_t minOffMs = 30;
gpio_evaluatedSwitch( //constructor minimal (default parameters pullup=true, inverted=false)
//constructor minimal (default parameters pullup=true, inverted=false)
gpio_evaluatedSwitch(
gpio_num_t gpio_num_declare gpio_num_t gpio_num_declare
); );
gpio_evaluatedSwitch( //constructor with optional parameters
//constructor with optional parameters
gpio_evaluatedSwitch(
gpio_num_t gpio_num_declare, gpio_num_t gpio_num_declare,
bool pullup_declare, bool pullup_declare,
bool inverted_declare=false bool inverted_declare=false
); );
//constructor with a function as source for input state instead of a gpio pin
gpio_evaluatedSwitch(bool (*getInputStatePtr_f)(void), bool inverted_f=false);
//--- output --- TODO make readonly? (e.g. public section: const int& x = m_x;) //--- output --- TODO make readonly? (e.g. public section: const int& x = m_x;)
bool state = false; bool state = false;
bool risingEdge = false; bool risingEdge = false;
@@ -47,12 +56,15 @@ class gpio_evaluatedSwitch {
gpio_num_t gpio_num; gpio_num_t gpio_num;
bool pullup; bool pullup;
bool inverted; bool inverted;
bool (*getInputStatePtr)(void); //pointer to function for getting current input state
inputSource_t inputSource = inputSource_t::GPIO;
enum class switchState {TRUE, FALSE, LOW, HIGH}; enum class switchState {TRUE, FALSE, LOW, HIGH};
switchState p_state = switchState::FALSE; switchState p_state = switchState::FALSE;
bool inputState = false;
uint32_t timestampLow = 0; uint32_t timestampLow = 0;
uint32_t timestampHigh = 0; uint32_t timestampHigh = 0;
void init(); void initGpio();
}; };

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@@ -6,6 +6,7 @@ idf_component_register(
"buzzer.cpp" "buzzer.cpp"
"vfd.cpp" "vfd.cpp"
"display.cpp" "display.cpp"
"switchesAnalog.cpp"
INCLUDE_DIRS INCLUDE_DIRS
"." "."
) )

View File

@@ -3,13 +3,19 @@
//--- inputs --- //--- inputs ---
//create and configure objects for evaluated switches //create and configure objects for evaluated switches
gpio_evaluatedSwitch SW_START(GPIO_SW_START, true, false); //pullup true, not inverted (switch to GND, internal pullup used) //gpio_evaluatedSwitch sw_gpio_39(GPIO_NUM_39, false, true); //pullup false, INVERTED (switch to 3V3, pulldown on pcb soldered)
gpio_evaluatedSwitch SW_RESET(GPIO_SW_RESET, true, false); //pullup true, not inverted (switch to GND, internal pullup used) gpio_evaluatedSwitch sw_gpio_34(GPIO_NUM_34, false, true); //pullup false, INVERTED (switch to 3V3, pulldown on pcb soldered)
gpio_evaluatedSwitch SW_SET(GPIO_SW_SET, true, false); //pullup true, not inverted (switch to GND, internal pullup used) gpio_evaluatedSwitch sw_gpio_32(GPIO_NUM_32, true, false); //pullup true, not inverted (switch to GND, internal pullup used)
gpio_evaluatedSwitch SW_PRESET1(GPIO_SW_PRESET1, true, false); //pullup true, not inverted (switch to GND, internal pullup used) gpio_evaluatedSwitch sw_gpio_33(GPIO_NUM_33, true, false); //pullup true, not inverted (switch to GND, internal pullup used)
gpio_evaluatedSwitch SW_PRESET2(GPIO_SW_PRESET2, false, true); //pullup false, INVERTED (switch to 3V3, pulldown on pcb soldered) gpio_evaluatedSwitch sw_gpio_25(GPIO_NUM_25, true, false); //pullup true, not inverted (switch to GND, internal pullup used)
gpio_evaluatedSwitch SW_PRESET3(GPIO_SW_PRESET3, false, true); //pullup false, INVERTED (switch to 3V3, pulldown on pcb soldered) gpio_evaluatedSwitch sw_gpio_26(GPIO_NUM_26, true, false); //pullup true, not inverted (switch to GND, internal pullup used)
//--- switches connected to 4 sw to analog stripboard ---
//evaluated switches with function to obtain the current input state instead of gpio
gpio_evaluatedSwitch sw_gpio_analog_0(&switchesAnalog_getState_sw0);
gpio_evaluatedSwitch sw_gpio_analog_1(&switchesAnalog_getState_sw1);
gpio_evaluatedSwitch sw_gpio_analog_2(&switchesAnalog_getState_sw2);
gpio_evaluatedSwitch sw_gpio_analog_3(&switchesAnalog_getState_sw3);
//create buzzer object with no gap between beep events //create buzzer object with no gap between beep events
buzzer_t buzzer(GPIO_BUZZER, 0); buzzer_t buzzer(GPIO_BUZZER, 0);

View File

@@ -4,6 +4,7 @@ extern "C" {
} }
#include "gpio_evaluateSwitch.hpp" #include "gpio_evaluateSwitch.hpp"
#include "buzzer.hpp" #include "buzzer.hpp"
#include "switchesAnalog.hpp"
//=================================== //===================================
@@ -22,17 +23,34 @@ extern "C" {
//================================== //==================================
//===== define input gpio pins ===== //==== define analog input pins ====
//================================== //==================================
#define GPIO_SW_START GPIO_NUM_26
#define GPIO_SW_RESET GPIO_NUM_25
#define GPIO_SW_SET GPIO_NUM_33
#define GPIO_SW_PRESET1 GPIO_NUM_32
#define GPIO_SW_PRESET2 GPIO_NUM_34
#define GPIO_SW_PRESET3 GPIO_NUM_39
#define GPIO_POTI GPIO_NUM_36 #define GPIO_POTI GPIO_NUM_36
#define ADC_CHANNEL_POTI ADC1_CHANNEL_0 #define ADC_CHANNEL_POTI ADC1_CHANNEL_0
#define GPIO_4SW_TO_ANALOG GPIO_NUM_39
#define ADC_CHANNEL_4SW_TO_ANALOG ADC1_CHANNEL_3 //gpio 39
//ADC1_CHANNEL_0 gpio36
//ADC1_CHANNEL_6 gpio_34
//ADC1_CHANNEL_3 gpio_39
//=====================================
//==== assign switches to objects =====
//=====================================
//see config.cpp for available evaluated switch objects
#define SW_START sw_gpio_26
#define SW_RESET sw_gpio_25
#define SW_SET sw_gpio_analog_0
#define SW_PRESET1 sw_gpio_analog_1
#define SW_PRESET2 sw_gpio_analog_2
#define SW_PRESET3 sw_gpio_analog_3
//unused but already available evaluated inputs
//#define ? sw_gpio_33
//#define ? sw_gpio_32
//#define ? sw_gpio_34
//-------------------------- //--------------------------
@@ -71,14 +89,21 @@ extern "C" {
//===== global variables ===== //===== global variables =====
//============================ //============================
//create global evaluated switch objects //create global evaluated switch objects
//--- inputs --- //--- switches on digital gpio pins ---
//create objects for switches at bottom screw temerinals //extern gpio_evaluatedSwitch sw_gpio_39;
extern gpio_evaluatedSwitch SW_START; extern gpio_evaluatedSwitch sw_gpio_34;
extern gpio_evaluatedSwitch SW_RESET; extern gpio_evaluatedSwitch sw_gpio_32;
extern gpio_evaluatedSwitch SW_SET; extern gpio_evaluatedSwitch sw_gpio_33;
extern gpio_evaluatedSwitch SW_PRESET1; extern gpio_evaluatedSwitch sw_gpio_25;
extern gpio_evaluatedSwitch SW_PRESET2; extern gpio_evaluatedSwitch sw_gpio_26;
extern gpio_evaluatedSwitch SW_PRESET3;
//--- switches connected to 4-sw-to-analog stripboard ---
extern gpio_evaluatedSwitch sw_gpio_analog_0;
extern gpio_evaluatedSwitch sw_gpio_analog_1;
extern gpio_evaluatedSwitch sw_gpio_analog_2;
extern gpio_evaluatedSwitch sw_gpio_analog_3;
//create global buzzer object //create global buzzer object
extern buzzer_t buzzer; extern buzzer_t buzzer;

View File

@@ -23,27 +23,6 @@ QueueHandle_t init_encoder(rotary_encoder_info_t * info){
} }
//=============================
//========= readAdc ===========
//=============================
//function for multisampling an anlog input
int readAdc(adc1_channel_t adc_channel, bool inverted = false) {
//make multiple measurements
int adc_reading = 0;
for (int i = 0; i < 16; i++) {
adc_reading += adc1_get_raw(adc_channel);
}
adc_reading = adc_reading / 16;
//return original or inverted result
if (inverted) {
return 4095 - adc_reading;
} else {
return adc_reading;
}
}
//==================== //====================
@@ -218,7 +197,7 @@ void task_control(void *pvParameter)
//set target length to poti position when SET switch is pressed //set target length to poti position when SET switch is pressed
if (SW_SET.state == true) { if (SW_SET.state == true) {
//read adc //read adc
potiRead = readAdc(ADC_CHANNEL_POTI); //0-4095 potiRead = gpio_readAdc(ADC_CHANNEL_POTI); //0-4095
//scale to target length range //scale to target length range
int lengthTargetNew = (float)potiRead / 4095 * 30000; int lengthTargetNew = (float)potiRead / 4095 * 30000;
//apply hysteresis and round to whole meters //TODO optimize this //apply hysteresis and round to whole meters //TODO optimize this
@@ -326,7 +305,7 @@ void task_control(void *pvParameter)
case MANUAL: //manually control motor via preset buttons + poti case MANUAL: //manually control motor via preset buttons + poti
//read poti value //read poti value
potiRead = readAdc(ADC_CHANNEL_POTI); //0-4095 potiRead = gpio_readAdc(ADC_CHANNEL_POTI); //0-4095
//scale poti to speed levels 0-3 //scale poti to speed levels 0-3
uint8_t level = round( (float)potiRead / 4095 * 3 ); uint8_t level = round( (float)potiRead / 4095 * 3 );
//exit manual mode if preset2 released //exit manual mode if preset2 released

View File

@@ -18,6 +18,7 @@ extern "C"
#include "config.hpp" #include "config.hpp"
#include "gpio_evaluateSwitch.hpp" #include "gpio_evaluateSwitch.hpp"
#include "gpio_adc.hpp"
#include "buzzer.hpp" #include "buzzer.hpp"
#include "vfd.hpp" #include "vfd.hpp"
#include "display.hpp" #include "display.hpp"

View File

@@ -14,6 +14,8 @@ extern "C"
#include "control.hpp" #include "control.hpp"
#include "buzzer.hpp" #include "buzzer.hpp"
#include "switchesAnalog.hpp"
//================================= //=================================
//=========== functions =========== //=========== functions ===========
@@ -78,6 +80,7 @@ extern "C" void app_main()
//define loglevel //define loglevel
esp_log_level_set("*", ESP_LOG_INFO); esp_log_level_set("*", ESP_LOG_INFO);
esp_log_level_set("buzzer", ESP_LOG_ERROR); esp_log_level_set("buzzer", ESP_LOG_ERROR);
esp_log_level_set("switches-analog", ESP_LOG_WARN);
esp_log_level_set("control", ESP_LOG_INFO); esp_log_level_set("control", ESP_LOG_INFO);
//create task for controlling the machine //create task for controlling the machine
@@ -87,4 +90,5 @@ extern "C" void app_main()
//beep at startup //beep at startup
buzzer.beep(3, 70, 50); buzzer.beep(3, 70, 50);
} }

103
main/switchesAnalog.cpp Normal file
View File

@@ -0,0 +1,103 @@
#include "switchesAnalog.hpp"
#define CHECK_BIT(var,pos) (((var)>>(pos)) & 1) //TODO duplicate code: same macro already used in vfd.cpp
//=====================
//===== Variables =====
//=====================
static const char *TAG = "switches-analog"; //tag for logging
int diffMin = 4095;
int adcValue;
int match_index = 0;
//array that describes voltages for all combinations of the 4 inputs
const int lookup_voltages[] = {
//ADC, S3 S2 S1 S0
4095, //0000
3780, //0001
3390, //0010
3040, //0011
2760, //0100
2542, //0101
2395, //0110
2225, //0111
1964, //1000
1845, //1001
1762, //1010
1664, //1011
1573, //1100
1485, //1101
1432, //1110
1363 //1111
};
//===========================
//===== handle function =====
//===========================
//handle demuxing of 4 switches from 1 adc (has to be run repeatedly)
void handle(){
//read current voltage
adcValue = gpio_readAdc(ADC_CHANNEL_4SW_TO_ANALOG);
ESP_LOGI(TAG, "voltage read: %d", adcValue);
//find closest match in lookup table
diffMin = 4095; //reset diffMin each run
for (int i=0; i<16; i++){
int diff = fabs(adcValue - lookup_voltages[i]);
if (diff < diffMin){
diffMin = diff;
match_index = i;
}
}
//get bool values for each input from matched index
bool s0 = CHECK_BIT(match_index, 0);
bool s1 = CHECK_BIT(match_index, 1);
bool s2 = CHECK_BIT(match_index, 2);
bool s3 = CHECK_BIT(match_index, 3);
//bool s1 = ((match_index & 0b1000) == 0b1000);
//bool s2 = ((match_index & 0b0100) == 0b0100);
//bool s3 = ((match_index & 0b0010) == 0b0010);
//bool s4 = ((match_index & 0b0001) == 0b0001);
//log results
ESP_LOGI(TAG, "adcRead: %d, closest-match: %d, diff: %d, index: %d, switches: %d%d%d%d",
adcValue, lookup_voltages[match_index], diffMin, match_index, (int)s3, (int)s2, (int)s1, (int)s0);
}
//====================
//===== getState =====
//====================
//get state of certain switch (0-3)
bool switchesAnalog_getState(int swNumber){
//run handle function to obtain all current input states
handle();
//get relevant bit
bool state = CHECK_BIT(match_index, swNumber);
ESP_LOGI(TAG, "returned state of switch No. %d = %i", swNumber, (int)state);
return state;
}
bool switchesAnalog_getState_sw0(){
return switchesAnalog_getState(0);
}
bool switchesAnalog_getState_sw1(){
return switchesAnalog_getState(1);
}
bool switchesAnalog_getState_sw2(){
return switchesAnalog_getState(2);
}
bool switchesAnalog_getState_sw3(){
return switchesAnalog_getState(3);
}

21
main/switchesAnalog.hpp Normal file
View File

@@ -0,0 +1,21 @@
#pragma once
extern "C"
{
#include <stdio.h>
#include <freertos/FreeRTOS.h>
#include "esp_log.h"
#include "driver/adc.h"
#include <math.h>
}
#include "config.hpp"
#include "gpio_adc.hpp"
//get current state of certain switch
bool switchesAnalog_getState(int swNumber);
bool switchesAnalog_getState_sw0();
bool switchesAnalog_getState_sw1();
bool switchesAnalog_getState_sw2();
bool switchesAnalog_getState_sw3();

75
pcb/4swToAdc.kicad_prl Normal file
View File

@@ -0,0 +1,75 @@
{
"board": {
"active_layer": 0,
"active_layer_preset": "",
"auto_track_width": true,
"hidden_nets": [],
"high_contrast_mode": 0,
"net_color_mode": 1,
"opacity": {
"pads": 1.0,
"tracks": 1.0,
"vias": 1.0,
"zones": 0.6
},
"ratsnest_display_mode": 0,
"selection_filter": {
"dimensions": true,
"footprints": true,
"graphics": true,
"keepouts": true,
"lockedItems": true,
"otherItems": true,
"pads": true,
"text": true,
"tracks": true,
"vias": true,
"zones": true
},
"visible_items": [
0,
1,
2,
3,
4,
5,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
32,
33,
34,
35,
36
],
"visible_layers": "fffffff_ffffffff",
"zone_display_mode": 0
},
"meta": {
"filename": "4-switches-to-adc.kicad_prl",
"version": 3
},
"project": {
"files": []
}
}

294
pcb/4swToAdc.kicad_pro Normal file
View File

@@ -0,0 +1,294 @@
{
"board": {
"layer_presets": []
},
"boards": [],
"cvpcb": {
"equivalence_files": []
},
"erc": {
"erc_exclusions": [],
"meta": {
"version": 0
},
"pin_map": [
[
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
2
],
[
0,
2,
0,
1,
0,
0,
1,
0,
2,
2,
2,
2
],
[
0,
0,
0,
0,
0,
0,
1,
0,
1,
0,
1,
2
],
[
0,
1,
0,
0,
0,
0,
1,
1,
2,
1,
1,
2
],
[
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
2
],
[
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
2
],
[
1,
1,
1,
1,
1,
0,
1,
1,
1,
1,
1,
2
],
[
0,
0,
0,
1,
0,
0,
1,
0,
0,
0,
0,
2
],
[
0,
2,
1,
2,
0,
0,
1,
0,
2,
2,
2,
2
],
[
0,
2,
0,
1,
0,
0,
1,
0,
2,
0,
0,
2
],
[
0,
2,
1,
1,
0,
0,
1,
0,
2,
0,
0,
2
],
[
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2,
2
]
],
"rule_severities": {
"bus_definition_conflict": "error",
"bus_entry_needed": "error",
"bus_label_syntax": "error",
"bus_to_bus_conflict": "error",
"bus_to_net_conflict": "error",
"different_unit_footprint": "error",
"different_unit_net": "error",
"duplicate_reference": "error",
"duplicate_sheet_names": "error",
"extra_units": "error",
"global_label_dangling": "warning",
"hier_label_mismatch": "error",
"label_dangling": "error",
"lib_symbol_issues": "warning",
"multiple_net_names": "warning",
"net_not_bus_member": "warning",
"no_connect_connected": "warning",
"no_connect_dangling": "warning",
"pin_not_connected": "error",
"pin_not_driven": "error",
"pin_to_pin": "warning",
"power_pin_not_driven": "error",
"similar_labels": "warning",
"unannotated": "error",
"unit_value_mismatch": "error",
"unresolved_variable": "error",
"wire_dangling": "error"
}
},
"libraries": {
"pinned_footprint_libs": [],
"pinned_symbol_libs": []
},
"meta": {
"filename": "4-switches-to-adc.kicad_pro",
"version": 1
},
"net_settings": {
"classes": [
{
"bus_width": 12.0,
"clearance": 0.2,
"diff_pair_gap": 0.25,
"diff_pair_via_gap": 0.25,
"diff_pair_width": 0.2,
"line_style": 0,
"microvia_diameter": 0.3,
"microvia_drill": 0.1,
"name": "Default",
"pcb_color": "rgba(0, 0, 0, 0.000)",
"schematic_color": "rgba(0, 0, 0, 0.000)",
"track_width": 0.25,
"via_diameter": 0.8,
"via_drill": 0.4,
"wire_width": 6.0
}
],
"meta": {
"version": 2
},
"net_colors": null
},
"pcbnew": {
"last_paths": {
"gencad": "",
"idf": "",
"netlist": "",
"specctra_dsn": "",
"step": "",
"vrml": ""
},
"page_layout_descr_file": ""
},
"schematic": {
"annotate_start_num": 0,
"drawing": {
"default_line_thickness": 6.0,
"default_text_size": 50.0,
"field_names": [],
"intersheets_ref_own_page": false,
"intersheets_ref_prefix": "",
"intersheets_ref_short": false,
"intersheets_ref_show": false,
"intersheets_ref_suffix": "",
"junction_size_choice": 3,
"label_size_ratio": 0.375,
"pin_symbol_size": 25.0,
"text_offset_ratio": 0.15
},
"legacy_lib_dir": "",
"legacy_lib_list": [],
"meta": {
"version": 1
},
"net_format_name": "",
"page_layout_descr_file": "",
"plot_directory": "",
"spice_adjust_passive_values": false,
"spice_external_command": "spice \"%I\"",
"subpart_first_id": 65,
"subpart_id_separator": 0
},
"sheets": [
[
"0534e379-8bf0-4abf-a148-fc91b6440529",
""
]
],
"text_variables": {}
}

580
pcb/4swToAdc.kicad_sch Normal file
View File

@@ -0,0 +1,580 @@
(kicad_sch (version 20211123) (generator eeschema)
(uuid 0534e379-8bf0-4abf-a148-fc91b6440529)
(paper "A4")
(lib_symbols
(symbol "Device:R" (pin_numbers hide) (pin_names (offset 0)) (in_bom yes) (on_board yes)
(property "Reference" "R" (id 0) (at 2.032 0 90)
(effects (font (size 1.27 1.27)))
)
(property "Value" "R" (id 1) (at 0 0 90)
(effects (font (size 1.27 1.27)))
)
(property "Footprint" "" (id 2) (at -1.778 0 90)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "~" (id 3) (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "ki_keywords" "R res resistor" (id 4) (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "ki_description" "Resistor" (id 5) (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "ki_fp_filters" "R_*" (id 6) (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(symbol "R_0_1"
(rectangle (start -1.016 -2.54) (end 1.016 2.54)
(stroke (width 0.254) (type default) (color 0 0 0 0))
(fill (type none))
)
)
(symbol "R_1_1"
(pin passive line (at 0 3.81 270) (length 1.27)
(name "~" (effects (font (size 1.27 1.27))))
(number "1" (effects (font (size 1.27 1.27))))
)
(pin passive line (at 0 -3.81 90) (length 1.27)
(name "~" (effects (font (size 1.27 1.27))))
(number "2" (effects (font (size 1.27 1.27))))
)
)
)
(symbol "Switch:SW_Push" (pin_numbers hide) (pin_names (offset 1.016) hide) (in_bom yes) (on_board yes)
(property "Reference" "SW" (id 0) (at 1.27 2.54 0)
(effects (font (size 1.27 1.27)) (justify left))
)
(property "Value" "SW_Push" (id 1) (at 0 -1.524 0)
(effects (font (size 1.27 1.27)))
)
(property "Footprint" "" (id 2) (at 0 5.08 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "~" (id 3) (at 0 5.08 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "ki_keywords" "switch normally-open pushbutton push-button" (id 4) (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "ki_description" "Push button switch, generic, two pins" (id 5) (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(symbol "SW_Push_0_1"
(circle (center -2.032 0) (radius 0.508)
(stroke (width 0) (type default) (color 0 0 0 0))
(fill (type none))
)
(polyline
(pts
(xy 0 1.27)
(xy 0 3.048)
)
(stroke (width 0) (type default) (color 0 0 0 0))
(fill (type none))
)
(polyline
(pts
(xy 2.54 1.27)
(xy -2.54 1.27)
)
(stroke (width 0) (type default) (color 0 0 0 0))
(fill (type none))
)
(circle (center 2.032 0) (radius 0.508)
(stroke (width 0) (type default) (color 0 0 0 0))
(fill (type none))
)
(pin passive line (at -5.08 0 0) (length 2.54)
(name "1" (effects (font (size 1.27 1.27))))
(number "1" (effects (font (size 1.27 1.27))))
)
(pin passive line (at 5.08 0 180) (length 2.54)
(name "2" (effects (font (size 1.27 1.27))))
(number "2" (effects (font (size 1.27 1.27))))
)
)
)
(symbol "power:+3V3" (power) (pin_names (offset 0)) (in_bom yes) (on_board yes)
(property "Reference" "#PWR" (id 0) (at 0 -3.81 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "Value" "+3V3" (id 1) (at 0 3.556 0)
(effects (font (size 1.27 1.27)))
)
(property "Footprint" "" (id 2) (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "" (id 3) (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "ki_keywords" "power-flag" (id 4) (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "ki_description" "Power symbol creates a global label with name \"+3V3\"" (id 5) (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(symbol "+3V3_0_1"
(polyline
(pts
(xy -0.762 1.27)
(xy 0 2.54)
)
(stroke (width 0) (type default) (color 0 0 0 0))
(fill (type none))
)
(polyline
(pts
(xy 0 0)
(xy 0 2.54)
)
(stroke (width 0) (type default) (color 0 0 0 0))
(fill (type none))
)
(polyline
(pts
(xy 0 2.54)
(xy 0.762 1.27)
)
(stroke (width 0) (type default) (color 0 0 0 0))
(fill (type none))
)
)
(symbol "+3V3_1_1"
(pin power_in line (at 0 0 90) (length 0) hide
(name "+3V3" (effects (font (size 1.27 1.27))))
(number "1" (effects (font (size 1.27 1.27))))
)
)
)
(symbol "power:GND" (power) (pin_names (offset 0)) (in_bom yes) (on_board yes)
(property "Reference" "#PWR" (id 0) (at 0 -6.35 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "Value" "GND" (id 1) (at 0 -3.81 0)
(effects (font (size 1.27 1.27)))
)
(property "Footprint" "" (id 2) (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "" (id 3) (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "ki_keywords" "power-flag" (id 4) (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "ki_description" "Power symbol creates a global label with name \"GND\" , ground" (id 5) (at 0 0 0)
(effects (font (size 1.27 1.27)) hide)
)
(symbol "GND_0_1"
(polyline
(pts
(xy 0 0)
(xy 0 -1.27)
(xy 1.27 -1.27)
(xy 0 -2.54)
(xy -1.27 -1.27)
(xy 0 -1.27)
)
(stroke (width 0) (type default) (color 0 0 0 0))
(fill (type none))
)
)
(symbol "GND_1_1"
(pin power_in line (at 0 0 270) (length 0) hide
(name "GND" (effects (font (size 1.27 1.27))))
(number "1" (effects (font (size 1.27 1.27))))
)
)
)
)
(junction (at 48.26 87.63) (diameter 0) (color 0 0 0 0)
(uuid 0595abd2-5372-4996-8c85-ea8e7ba6eaf5)
)
(junction (at 48.26 57.15) (diameter 0) (color 0 0 0 0)
(uuid 376c3252-bee9-4eae-8c35-3e8d8aea79a1)
)
(junction (at 60.96 57.15) (diameter 0) (color 0 0 0 0)
(uuid 37f07ef8-0bd0-4983-9e87-070da97b8027)
)
(junction (at 60.96 87.63) (diameter 0) (color 0 0 0 0)
(uuid b858a0b2-392b-42b8-814d-97eec6d10cf5)
)
(junction (at 73.66 57.15) (diameter 0) (color 0 0 0 0)
(uuid caf3ed74-8f3c-4ea2-9837-cc564ece24fc)
)
(junction (at 86.36 57.15) (diameter 0) (color 0 0 0 0)
(uuid e422a210-4268-4494-969d-097a39cbc71b)
)
(junction (at 73.66 87.63) (diameter 0) (color 0 0 0 0)
(uuid f688351c-21fd-46ff-a90d-cc366df00758)
)
(wire (pts (xy 60.96 57.15) (xy 60.96 60.325))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 04af43fa-9f39-49fa-af8f-f49b7bc05656)
)
(wire (pts (xy 60.96 84.455) (xy 60.96 87.63))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 0540396a-1bc2-4b04-906e-7d83c6b66195)
)
(wire (pts (xy 48.26 87.63) (xy 48.26 92.075))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 1787faca-1557-4d40-a0c4-911d17f0770d)
)
(wire (pts (xy 86.36 67.945) (xy 86.36 74.295))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 23b2ab5f-bdf4-4212-b143-bb49653e1b88)
)
(wire (pts (xy 48.26 57.15) (xy 48.26 60.325))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 25a6a709-3fde-41fe-9a0e-cb508d73834a)
)
(wire (pts (xy 73.66 84.455) (xy 73.66 87.63))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 2bc4885e-1811-40f7-9a6d-34ed596c1add)
)
(wire (pts (xy 48.26 41.275) (xy 48.26 45.085))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 2c7d8342-fe94-4a1b-baec-58cd6c3eeca7)
)
(wire (pts (xy 48.26 67.945) (xy 48.26 74.295))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 45921a4d-adb5-4631-b0f7-53468659bc65)
)
(wire (pts (xy 73.66 87.63) (xy 60.96 87.63))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 480fea58-4754-4988-b652-79892cbd4343)
)
(polyline (pts (xy 38.1 33.02) (xy 110.49 33.02))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 4d5b9ff9-ca59-4c44-bce2-c776250d20c0)
)
(wire (pts (xy 60.96 87.63) (xy 48.26 87.63))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 5f8390d2-5874-477d-abd8-600f48800de1)
)
(wire (pts (xy 73.66 57.15) (xy 73.66 60.325))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 689d4ae4-8fb6-467c-812a-f8189081bfa8)
)
(wire (pts (xy 60.96 57.15) (xy 48.26 57.15))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 69ba96dd-74a8-4f3b-85f6-a998f64b3b7e)
)
(wire (pts (xy 86.36 87.63) (xy 73.66 87.63))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 76bc9488-bd39-4e7f-ba21-8968e45bafbd)
)
(polyline (pts (xy 38.1 102.87) (xy 110.49 102.87))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 8fda66e6-cca3-4608-bf63-d40d2a979623)
)
(wire (pts (xy 86.36 60.325) (xy 86.36 57.15))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 92724cbb-f787-4755-8c00-fdaff5e7ac81)
)
(wire (pts (xy 86.36 57.15) (xy 92.71 57.15))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 937bec40-8b53-4b31-acdc-755c933ec2ac)
)
(wire (pts (xy 48.26 52.705) (xy 48.26 57.15))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 9a9c3b93-5397-4f20-8b92-a2c37f8c1874)
)
(wire (pts (xy 86.36 57.15) (xy 73.66 57.15))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid 9c65a4d5-2a36-456c-8138-19c6cad951eb)
)
(wire (pts (xy 60.96 67.945) (xy 60.96 74.295))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid a02e604e-10c2-4767-a22d-4a461b77881e)
)
(polyline (pts (xy 38.1 33.655) (xy 38.1 102.87))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid a2c30be3-07c7-4998-a3ab-a45d0d1aa278)
)
(wire (pts (xy 73.66 57.15) (xy 60.96 57.15))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid acd9d380-e80b-4364-af24-ac27f88537b5)
)
(wire (pts (xy 73.66 67.945) (xy 73.66 74.295))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid c5dfc4f2-d3c5-4fe8-81cc-954989ded559)
)
(wire (pts (xy 86.36 84.455) (xy 86.36 87.63))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid e013a703-8a26-45b6-b9ca-6cd0b0a9ceef)
)
(wire (pts (xy 48.26 84.455) (xy 48.26 87.63))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid e3a717ef-7fbb-42fd-bed3-8552fcbf95b5)
)
(polyline (pts (xy 110.49 102.87) (xy 110.49 33.02))
(stroke (width 0) (type default) (color 0 0 0 0))
(uuid f442d4ab-f8ba-49f9-b732-68585ed0f198)
)
(text "Stripboard\n4 switches to 1 analog input" (at 78.74 38.735 0)
(effects (font (size 1.27 1.27) (thickness 0.254) bold) (justify left bottom))
(uuid c525c9cc-a4a1-4f6e-a0cf-a2cc3419b679)
)
(global_label "esp32 ADC" (shape input) (at 92.71 57.15 0) (fields_autoplaced)
(effects (font (size 1.27 1.27)) (justify left))
(uuid b8dbce7d-0a95-4573-b764-9e68bdd24326)
(property "Intersheet References" "${INTERSHEET_REFS}" (id 0) (at 105.4041 57.0706 0)
(effects (font (size 1.27 1.27)) (justify left) hide)
)
)
(symbol (lib_id "power:GND") (at 48.26 92.075 0) (unit 1)
(in_bom yes) (on_board yes) (fields_autoplaced)
(uuid 07a9d758-a267-455f-b30c-3770f3527e7a)
(property "Reference" "#PWR?" (id 0) (at 48.26 98.425 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "Value" "GND" (id 1) (at 48.26 97.155 0))
(property "Footprint" "" (id 2) (at 48.26 92.075 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "" (id 3) (at 48.26 92.075 0)
(effects (font (size 1.27 1.27)) hide)
)
(pin "1" (uuid e41399a7-f60b-4a80-a126-be056cb007e9))
)
(symbol (lib_id "Switch:SW_Push") (at 60.96 79.375 90) (unit 1)
(in_bom yes) (on_board yes) (fields_autoplaced)
(uuid 28a1ca96-47e6-44c9-b9dc-c435e73ae941)
(property "Reference" "SW2" (id 0) (at 62.23 79.3749 90)
(effects (font (size 1.27 1.27)) (justify right))
)
(property "Value" "SW_Push" (id 1) (at 62.23 80.6449 90)
(effects (font (size 1.27 1.27)) (justify right) hide)
)
(property "Footprint" "" (id 2) (at 55.88 79.375 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "~" (id 3) (at 55.88 79.375 0)
(effects (font (size 1.27 1.27)) hide)
)
(pin "1" (uuid 8b2bb3c1-68dc-4a33-bbda-8e3f735cb89c))
(pin "2" (uuid 19313efc-c6f8-4165-9f12-2f4d196a0916))
)
(symbol (lib_id "Switch:SW_Push") (at 86.36 79.375 90) (unit 1)
(in_bom yes) (on_board yes) (fields_autoplaced)
(uuid 3742357e-3d4f-4d99-8094-756d8329e07a)
(property "Reference" "SW0" (id 0) (at 87.63 79.3749 90)
(effects (font (size 1.27 1.27)) (justify right))
)
(property "Value" "SW_Push" (id 1) (at 87.63 80.6449 90)
(effects (font (size 1.27 1.27)) (justify right) hide)
)
(property "Footprint" "" (id 2) (at 81.28 79.375 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "~" (id 3) (at 81.28 79.375 0)
(effects (font (size 1.27 1.27)) hide)
)
(pin "1" (uuid ed19ccea-334b-4c85-8502-092081da9b5f))
(pin "2" (uuid 2f87aad1-080c-4cf8-9298-8cf8962ebf0b))
)
(symbol (lib_id "Device:R") (at 48.26 48.895 0) (unit 1)
(in_bom yes) (on_board yes) (fields_autoplaced)
(uuid 6eeba788-57b9-45a8-981d-ecd17efd1d54)
(property "Reference" "R_up" (id 0) (at 50.8 47.6249 0)
(effects (font (size 1.27 1.27)) (justify left))
)
(property "Value" "1k" (id 1) (at 50.8 50.1649 0)
(effects (font (size 1.27 1.27)) (justify left))
)
(property "Footprint" "" (id 2) (at 46.482 48.895 90)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "~" (id 3) (at 48.26 48.895 0)
(effects (font (size 1.27 1.27)) hide)
)
(pin "1" (uuid a7fb192a-733f-4bea-a1d7-a207050754dc))
(pin "2" (uuid 76ba5816-0ef3-41eb-80a7-15d3d0d4102f))
)
(symbol (lib_id "Device:R") (at 48.26 64.135 0) (unit 1)
(in_bom yes) (on_board yes)
(uuid 769febe6-b95c-4d37-94fa-e3721ea908aa)
(property "Reference" "R3" (id 0) (at 50.8 62.8649 0)
(effects (font (size 1.27 1.27)) (justify left))
)
(property "Value" "1k" (id 1) (at 50.8 65.4049 0)
(effects (font (size 1.27 1.27)) (justify left))
)
(property "Footprint" "" (id 2) (at 46.482 64.135 90)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "~" (id 3) (at 48.26 64.135 0)
(effects (font (size 1.27 1.27)) hide)
)
(pin "1" (uuid f91d18bf-da3d-43fe-8b9a-c8f17a1ef730))
(pin "2" (uuid 0e5a0907-c70d-45b4-9b1e-755718f7bf45))
)
(symbol (lib_id "Switch:SW_Push") (at 48.26 79.375 90) (unit 1)
(in_bom yes) (on_board yes)
(uuid 864b1f85-f995-433a-9a94-7965edbddf3c)
(property "Reference" "SW3" (id 0) (at 49.53 79.375 90)
(effects (font (size 1.27 1.27)) (justify right))
)
(property "Value" "SW_Push" (id 1) (at 49.53 80.6449 90)
(effects (font (size 1.27 1.27)) (justify right) hide)
)
(property "Footprint" "" (id 2) (at 43.18 79.375 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "~" (id 3) (at 43.18 79.375 0)
(effects (font (size 1.27 1.27)) hide)
)
(pin "1" (uuid ddb4c830-ad05-4916-ada4-5d3ceca231c4))
(pin "2" (uuid 1b4f3986-79e7-4778-acb7-b047f55e11e8))
)
(symbol (lib_id "Device:R") (at 60.96 64.135 0) (unit 1)
(in_bom yes) (on_board yes) (fields_autoplaced)
(uuid 8c50ab84-72ab-438d-a9f1-a710a33b8e06)
(property "Reference" "R2" (id 0) (at 63.5 62.8649 0)
(effects (font (size 1.27 1.27)) (justify left))
)
(property "Value" "2k2" (id 1) (at 63.5 65.4049 0)
(effects (font (size 1.27 1.27)) (justify left))
)
(property "Footprint" "" (id 2) (at 59.182 64.135 90)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "~" (id 3) (at 60.96 64.135 0)
(effects (font (size 1.27 1.27)) hide)
)
(pin "1" (uuid c171a640-9d38-495e-a5d9-7d8f95ea6fee))
(pin "2" (uuid 5e366793-5e2a-4a8a-ba3c-8de861c6f28d))
)
(symbol (lib_id "Switch:SW_Push") (at 73.66 79.375 90) (unit 1)
(in_bom yes) (on_board yes) (fields_autoplaced)
(uuid 93d3db7a-9c33-4a6b-8a4f-9c98164fe8b8)
(property "Reference" "SW1" (id 0) (at 74.93 79.3749 90)
(effects (font (size 1.27 1.27)) (justify right))
)
(property "Value" "SW_Push" (id 1) (at 74.93 80.6449 90)
(effects (font (size 1.27 1.27)) (justify right) hide)
)
(property "Footprint" "" (id 2) (at 68.58 79.375 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "~" (id 3) (at 68.58 79.375 0)
(effects (font (size 1.27 1.27)) hide)
)
(pin "1" (uuid 5f3464d1-5065-4af5-a2f2-3aa2e6eda618))
(pin "2" (uuid bd5f3ec3-2c19-4b99-96ae-a4b755f1a5e1))
)
(symbol (lib_id "power:+3V3") (at 48.26 41.275 0) (unit 1)
(in_bom yes) (on_board yes) (fields_autoplaced)
(uuid a516e0a9-fe24-4120-873c-6f89d1fb49c0)
(property "Reference" "#PWR?" (id 0) (at 48.26 45.085 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "Value" "+3V3" (id 1) (at 48.26 36.195 0))
(property "Footprint" "" (id 2) (at 48.26 41.275 0)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "" (id 3) (at 48.26 41.275 0)
(effects (font (size 1.27 1.27)) hide)
)
(pin "1" (uuid 7edde932-e6ea-4bb3-80d2-0dfb0b34dfdf))
)
(symbol (lib_id "Device:R") (at 73.66 64.135 0) (unit 1)
(in_bom yes) (on_board yes) (fields_autoplaced)
(uuid e38a88e5-32b2-4c8e-8e29-fd613e9fce2a)
(property "Reference" "R1" (id 0) (at 76.2 62.8649 0)
(effects (font (size 1.27 1.27)) (justify left))
)
(property "Value" "4k7" (id 1) (at 76.2 65.4049 0)
(effects (font (size 1.27 1.27)) (justify left))
)
(property "Footprint" "" (id 2) (at 71.882 64.135 90)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "~" (id 3) (at 73.66 64.135 0)
(effects (font (size 1.27 1.27)) hide)
)
(pin "1" (uuid 14717925-77d8-4e5b-87f4-d527a7df25a2))
(pin "2" (uuid 042328ba-54db-4f0f-b129-1e89e595aa37))
)
(symbol (lib_id "Device:R") (at 86.36 64.135 0) (unit 1)
(in_bom yes) (on_board yes) (fields_autoplaced)
(uuid f9457597-177c-435c-90d9-f31193f60883)
(property "Reference" "R0" (id 0) (at 88.9 62.8649 0)
(effects (font (size 1.27 1.27)) (justify left))
)
(property "Value" "8k2" (id 1) (at 88.9 65.4049 0)
(effects (font (size 1.27 1.27)) (justify left))
)
(property "Footprint" "" (id 2) (at 84.582 64.135 90)
(effects (font (size 1.27 1.27)) hide)
)
(property "Datasheet" "~" (id 3) (at 86.36 64.135 0)
(effects (font (size 1.27 1.27)) hide)
)
(pin "1" (uuid a698459c-2acc-4346-a3d9-ec53ed63917d))
(pin "2" (uuid c6c22bf2-3a43-4c40-940f-495f13d46fdd))
)
(sheet_instances
(path "/" (page "1"))
)
(symbol_instances
(path "/07a9d758-a267-455f-b30c-3770f3527e7a"
(reference "#PWR?") (unit 1) (value "GND") (footprint "")
)
(path "/a516e0a9-fe24-4120-873c-6f89d1fb49c0"
(reference "#PWR?") (unit 1) (value "+3V3") (footprint "")
)
(path "/f9457597-177c-435c-90d9-f31193f60883"
(reference "R0") (unit 1) (value "8k2") (footprint "")
)
(path "/e38a88e5-32b2-4c8e-8e29-fd613e9fce2a"
(reference "R1") (unit 1) (value "4k7") (footprint "")
)
(path "/8c50ab84-72ab-438d-a9f1-a710a33b8e06"
(reference "R2") (unit 1) (value "2k2") (footprint "")
)
(path "/769febe6-b95c-4d37-94fa-e3721ea908aa"
(reference "R3") (unit 1) (value "1k") (footprint "")
)
(path "/6eeba788-57b9-45a8-981d-ecd17efd1d54"
(reference "R_up") (unit 1) (value "1k") (footprint "")
)
(path "/3742357e-3d4f-4d99-8094-756d8329e07a"
(reference "SW0") (unit 1) (value "SW_Push") (footprint "")
)
(path "/93d3db7a-9c33-4a6b-8a4f-9c98164fe8b8"
(reference "SW1") (unit 1) (value "SW_Push") (footprint "")
)
(path "/28a1ca96-47e6-44c9-b9dc-c435e73ae941"
(reference "SW2") (unit 1) (value "SW_Push") (footprint "")
)
(path "/864b1f85-f995-433a-9a94-7965edbddf3c"
(reference "SW3") (unit 1) (value "SW_Push") (footprint "")
)
)
)

Binary file not shown.