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]; ...@@ -35,8 +35,8 @@ static char scpi_input_buffer[SCPI_INPUT_BUFFER_LENGTH];
scpi_t scpi_context; scpi_t scpi_context;
scpi_choice_def_t trigger_source[] = { scpi_choice_def_t trigger_source[] = {
{"A0", 0}, {"A0", 1}, // A0 and A1 are swapped onboard for easier routing
{"A1", 1}, {"A1", 0},
{"A2", 2}, {"A2", 2},
{"A3", 3}, {"A3", 3},
{"A4", 4}, {"A4", 4},
......
...@@ -58,17 +58,26 @@ THD_FUNCTION(Sensors, arg) { ...@@ -58,17 +58,26 @@ THD_FUNCTION(Sensors, arg) {
ads1115ObjectInit(&ADS1115); ads1115ObjectInit(&ADS1115);
ads1115Start(&ADS1115, &ads1115cfg); ads1115Start(&ADS1115, &ads1115cfg);
ads1115SetScale(&ADS1115, ADS1115_REG_CONFIG_PGA_0_256V);
while (true) { while (true) {
thread_t *tp = chMsgWait(); thread_t *tp = chMsgWait();
//(void)chMsgSend(chRegFindThreadByName("display"), (msg_t)"VAI ADC"); uint8_t channel = (uint8_t)chMsgGet(tp);
//adcsample_t sample; if(channel < 3) {
//adcConvert(&ADCD1, &adcgrpcfg1, &sample, 1); // Precision ADC channel
//float volts = (sample / 4095.0f) * 18.0f; float volts = ads1115ReadMillivolts(&ADS1115, channel);
char buf[16] = {0}; chMsgRelease(tp, (msg_t) &volts);
float volts = ads1115ReadMillivolts(&ADS1115, 0); } else {
sprintf(buf, "Volts: %d.%d", (int)volts, (int) ((volts - ((int) volts)) * 100)); // General purpose ADC
(void)chMsgSend(chRegFindThreadByName("display"), (msg_t)buf); // Right now it only reads ADC1
chMsgRelease(tp, (msg_t) &volts); 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