SRA-VJTI / sra-board-component

ESP-IDF component for SRA Board
https://sravjti.in/sra-board-component/
MIT License
36 stars 20 forks source link

If...else to be replaced by the switch case #19

Closed laukik-hase closed 3 years ago

laukik-hase commented 3 years ago

https://github.com/SRA-VJTI/sra-board-component/blob/d58505f71440e80b5fe426d02a260f7a3d6b5264/src/adc.c#L16

Can this if..else.. block be replaced by a switch statement with a default statement handling cases of channels other than LSA?

ombhilare999 commented 3 years ago

Yes, will replace that if else block by switch statement but I'm not sure about default statement This is the mapping of esp32 pins to ADC channel, default case will be too large. Do we want to make this function universal @laukik-hase ? ADC1_CH0 – GPIO36 ADC1_CH1 – GPIO37 ADC1_CH2 – GPIO38 ADC1_CH3 – GPIO39 ADC1_CH4 – GPIO32 ADC1_CH5- GPIO33 ADC1_CH6 – GPIO34 ADC1_CH7 – GPIO35 ADC2_CH0 – GPIO4 ADC2_CH1 – GPIO0 ADC2_CH2 – GPIO2 ADC2_CH3 – GPIO15 ADC2_CH4 – GPIO13 ADC2_CH5 – GPIO12 ADC2_CH6 – GPIO14 ADC2_CH7 – GPIO27 ADC2_CH8 – GPIO25 ADC2_CH9 – GPIO26

laukik-hase commented 3 years ago

@ombhilare999 As in your else case, you can just break in the default case.

VedantParanjape commented 3 years ago

Fixed in 2d63fcf3f5e5489aae242629211e041012deee8e