busvoodoo_global: minor, replace printf with puts

This commit is contained in:
King Kévin 2020-03-09 14:20:04 +01:00
parent b8bce07b84
commit b81df746c6
1 changed files with 51 additions and 51 deletions

View File

@ -254,17 +254,17 @@ void busvoodoo_text_style(enum busvoodoo_text_style_t style)
{
switch (style) {
case BUSVOODOO_TEXT_STYLE_ERROR:
printf("\x1b[31m");
puts("\x1b[31m");
break;
case BUSVOODOO_TEXT_STYLE_WARNING:
printf("\x1b[33m");
puts("\x1b[33m");
break;
case BUSVOODOO_TEXT_STYLE_INFO:
printf("\x1b[32m");
puts("\x1b[32m");
break;
case BUSVOODOO_TEXT_STYLE_RESET:
default:
printf("\x1b[0m");
puts("\x1b[0m");
break;
}
}
@ -713,9 +713,9 @@ static void busvoodoo_global_power(void* argument)
}
} else if (0 == strcmp(argument, "on")) {
if (busvoodoo_vout_switch(true)) { // switch power rail on
printf("power rails switched on\n");
puts("power rails switched on\n");
} else {
printf("power rails switched on but malfunctioning\n");
puts("power rails switched on but malfunctioning\n");
}
power_on:
voltage = busvoodoo_vreg_get(BUSVOODOO_5V_CHANNEL); // get 5V power rail voltage
@ -724,10 +724,10 @@ power_on:
printf("3V3 power rail: %.2fV\n", voltage);
} else if (0 == strcmp(argument, "off")) {
busvoodoo_vout_switch(false); // switch power rail off
printf("power rails switched off\n");
puts("power rails switched off\n");
power_off:
printf("5V power rail: off\n");
printf("3V3 power rail: off\n");
puts("5V power rail: off\n");
puts("3V3 power rail: off\n");
} else {
printf("option malformed: %s\n", argument);
}
@ -741,11 +741,11 @@ static void busvoodoo_global_lv(void* argument)
{
if (NULL == argument) {
if (!gpio_get(GPIO(BUSVOODOO_5VPULLUP_PORT), GPIO(BUSVOODOO_5VPULLUP_PIN))) { // 5V input enabled
printf("5V power rail used");
puts("5V power rail used");
} else if (gpio_get(GPIO(BUSVOODOO_LVEN_PORT), GPIO(BUSVOODOO_LVEN_PIN))) { // LV voltage regulator used
printf("adjustable voltage regulator used");
puts("adjustable voltage regulator used");
} else {
printf("external voltage input");
puts("external voltage input");
}
float voltage = busvoodoo_vreg_get(BUSVOODOO_LV_CHANNEL); // get LV voltage
// print LV voltage
@ -757,7 +757,7 @@ static void busvoodoo_global_lv(void* argument)
} else {
double voltage = *((double*)argument); // get desired voltage
if (0 == voltage) {
printf("LV rail switched off");
puts("LV rail switched off");
} else {
printf("LV rail set to %.2fV", voltage);
}
@ -786,22 +786,22 @@ static void busvoodoo_global_hv(void* argument)
float voltage = busvoodoo_vreg_get(BUSVOODOO_HV_CHANNEL); // get HV voltage
// print LV voltage
if (voltage < 0.1) {
printf("0.00V\n");
puts("0.00V\n");
} else {
printf("%.2fV\n", voltage);
}
} else {
double voltage = *((double*)argument); // get desired voltage
printf("high voltage rail ");
puts("high voltage rail ");
if (voltage <= 3.3) {
printf("switched off");
puts("switched off");
} else {
printf("set to %.2fV", voltage);
}
voltage = busvoodoo_hv_set(voltage); // set HV voltage
// print HV voltage
if (voltage < 0.1) {
printf(": 0.00V\n");
puts(": 0.00V\n");
} else {
printf(": %.2fV\n", voltage);
}
@ -818,7 +818,7 @@ static void busvoodoo_global_adc(void* argument)
float voltage = busvoodoo_vreg_get(BUSVOODOO_ADC_CHANNEL); // get ADC voltage
// print ADC voltage
if (voltage < 0.1) {
printf(": 0.00V\n");
puts(": 0.00V\n");
} else {
printf(": %.2fV\n", voltage);
}
@ -853,32 +853,32 @@ static void busvoodoo_global_pinout(void* argument)
}
space += LENGTH(busvoodoo_global_pinout_rscan) - 1; // add the spaces between the names
// display pinout
printf("RS/CAN connector pinout:\n");
puts("RS/CAN connector pinout:\n");
// display top line
printf("+");
putc('+');
for (uint8_t i = 0; i < space; i++) {
printf("-");
putc('-');
}
printf("+\n");
puts("+\n");
// display pin names
printf("|");
putc('|');
for (int8_t i = LENGTH(busvoodoo_global_pinout_rscan) - 1; i >= 0; i--) {
if (NULL == busvoodoo_global_pinout_rscan[i]) {
printf("x"); // x stands for pin not used
putc('x'); // x stands for pin not used
} else {
printf("%s", busvoodoo_global_pinout_rscan[i]); // print pin name
}
if (i>0) {
printf(" "); // print space between the pin names
if (i > 0) {
putc(' '); // print space between the pin names
}
}
printf("|\n");
puts("|\n");
// display bottom line
printf("+");
putc('+');
for (uint8_t i = 0; i < space; i++) {
printf("-");
putc('-');
}
printf("+\n");
puts("+\n");
no_pinout = false; // remember a pinout has been shown
}
}
@ -909,69 +909,69 @@ static void busvoodoo_global_pinout(void* argument)
}
}
// display pinout
printf("I/O connector pinout:\n");
puts("I/O connector pinout:\n");
// display top line
printf("+");
putc('+');
for (uint16_t i = 0; i < (uint16_t)(spaces[4] + spaces[3] + 1); i++) {
printf("-");
putc('-');
}
for (uint16_t i = 0; i < (uint16_t)(spaces[2] + 2); i++) {
printf(" ");
putc(' ');
}
for (uint16_t i = 0; i < (uint16_t)(spaces[1] + spaces[0] + 1); i++) {
printf("-");
putc('-');
}
printf("+\n");
puts("+\n");
// display top pin names
printf("|");
putc('|');
for (int8_t i = 4; i >= 0; i--) {
if (NULL == busvoodoo_global_pinout_io[i * 2]) {
printf("x"); // x stands for pin not used
putc('x'); // x stands for pin not used
for (int16_t j = 0; j + 1 < spaces[i]; j++) {
printf(" "); // pad to match to bottom pin
putc(' '); // pad to match to bottom pin
}
} else {
printf("%s", busvoodoo_global_pinout_io[i * 2]); // print pin name
for (int16_t j = 0; j + strlen(busvoodoo_global_pinout_io[i * 2]) < spaces[i]; j++) {
printf(" "); // pad to match to bottom pin
putc(' '); // pad to match to bottom pin
}
}
if (i > 0) {
printf(" "); // print space between the pin names
putc(' '); // print space between the pin names
}
}
printf("|\n");
// display bottom pin names
printf("|");
putc('|');
for (int8_t i = 4 ; i >= 0; i--) {
if (NULL == busvoodoo_global_pinout_io[i * 2 + 1]) {
printf("x"); // x stands for pin not used
putc('x'); // x stands for pin not used
for (int16_t j = 0; j + 1 < spaces[i]; j++) {
printf(" "); // pad to match to bottom pin
putc(' '); // pad to match to bottom pin
}
} else {
printf("%s", busvoodoo_global_pinout_io[i * 2 + 1]); // print pin name
for (int16_t j = 0; j + strlen(busvoodoo_global_pinout_io[i * 2 + 1]) < spaces[i]; j++) {
printf(" "); // pad to match to bottom pin
putc(' '); // pad to match to bottom pin
}
}
if (i > 0) {
printf(" "); // print space between the pin names
putc(' '); // print space between the pin names
}
}
printf("|\n");
puts("|\n");
// display bottom line
printf("+");
putc('+');
for (uint16_t i = 0; i < spaces[4] + 1 + spaces[3] + 1 + spaces[2] + 1 + spaces[1] + 1 + spaces[0]; i++) {
printf("-");
putc('-');
}
printf("+\n");
puts("+\n");
no_pinout = false; // remember a pinout has been shown
}
// in case nothing has been displayed
if (no_pinout) {
printf("no pins are used\n");
puts("no pins are used\n");
}
}