void print_lhs(string s, string hint) { if(muted) return; cout << "\t" << hint << ":" << s << endl; print_delim(); }
void lhs_buf(const unsigned char * buf, size_t len, const char * hint) { if(muted) return; if(buf != NULL) { printf("\t%s:", hint); print_buffer(buf, len); printf("\n"); } print_delim(); }
uint16_t i2c_probe(void) { int p = 0; const char *del = ","; uint16_t probed = 0; watchdog_periodic(); if(!i2c_start(I2C_AT24MAC_ADDR)) { i2c_stop(); probed |= I2C_AT24MAC; print_delim(p++, "AT24MAC", del); } watchdog_periodic(); if(!i2c_start(I2C_SHT2X_ADDR)) { i2c_stop(); probed |= I2C_SHT2X; print_delim(p++, "SHT2X", del); } watchdog_periodic(); if(!i2c_start(I2C_CO2SA_ADDR)) { i2c_stop(); probed |= I2C_CO2SA; print_delim(p++, "CO2SA", del); } watchdog_periodic(); if(!i2c_start(I2C_BME280_ADDR)) { i2c_stop(); probed |= I2C_BME280; print_delim(p++, "BME280", del); } watchdog_periodic(); if(!i2c_start(I2C_PMS5003_ADDR)) { i2c_stop(); probed |= I2C_PMS5003; print_delim(p++, "PMS5003", del); } return probed; }
int main(void) { book library[MAXBKS]; int count = 0; printf("Please enter the book title.\n"); printf("Press [enter] at the start of a line to stop.\n"); while (count < MAXBKS && gets(library[count].title) != NULL && library[count].title[0] != '\0') { printf("Now enter the author.\n"); gets(library[count].author); printf("Now enter the value.\n"); scanf("%f", &library[count++].value); while (getchar() != '\n') continue; /* clear input line */ if (count < MAXBKS) printf("Enter the next title.\n"); } if (count > 0) { puts("Here is the list of your books:"); print_delim(); print_library(library, count); puts("\nSorted alphabetically:"); print_delim(); sort(library, count, alphabetically); print_library(library, count); puts("\nSorted by value:"); print_delim(); sort(library, count, by_value); print_library(library, count); } else printf("No books? Too bad.\n"); return 0; }