Commit fe87a423 authored by Pedro Henrique Kopper's avatar Pedro Henrique Kopper

Start with sane defaults and fix A0-A1 numbering.

parent 12e5dc87
......@@ -35,8 +35,8 @@ static char scpi_input_buffer[SCPI_INPUT_BUFFER_LENGTH];
scpi_t scpi_context;
scpi_choice_def_t trigger_source[] = {
{"A0", 0},
{"A1", 1},
{"A0", 1}, // A0 and A1 are swapped onboard for easier routing
{"A1", 0},
{"A2", 2},
{"A3", 3},
{"A4", 4},
......
......@@ -58,17 +58,26 @@ THD_FUNCTION(Sensors, arg) {
ads1115ObjectInit(&ADS1115);
ads1115Start(&ADS1115, &ads1115cfg);
ads1115SetScale(&ADS1115, ADS1115_REG_CONFIG_PGA_0_256V);
while (true) {
thread_t *tp = chMsgWait();
//(void)chMsgSend(chRegFindThreadByName("display"), (msg_t)"VAI ADC");
//adcsample_t sample;
//adcConvert(&ADCD1, &adcgrpcfg1, &sample, 1);
//float volts = (sample / 4095.0f) * 18.0f;
char buf[16] = {0};
float volts = ads1115ReadMillivolts(&ADS1115, 0);
sprintf(buf, "Volts: %d.%d", (int)volts, (int) ((volts - ((int) volts)) * 100));
(void)chMsgSend(chRegFindThreadByName("display"), (msg_t)buf);
chMsgRelease(tp, (msg_t) &volts);
uint8_t channel = (uint8_t)chMsgGet(tp);
if(channel < 3) {
// Precision ADC channel
float volts = ads1115ReadMillivolts(&ADS1115, channel);
chMsgRelease(tp, (msg_t) &volts);
} else {
// General purpose ADC
// Right now it only reads ADC1
adcsample_t sample;
adcConvert(&ADCD1, &adcgrpcfg1, &sample, 1);
float volts = (sample / 4095.0f) * 18.0f;
chMsgRelease(tp, (msg_t) &volts);
}
//char buf[16] = {0};
//sprintf(buf, "Volts: %d.%d", (int)volts, (int) ((volts - ((int) volts)) * 100));
//(void)chMsgSend(chRegFindThreadByName("display"), (msg_t)buf);
//chMsgRelease(tp, (msg_t) &volts);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment